The online racing simulator
Searching in All forums
(921 results)
DarkTimes
S2 licensed
You'll need to specify exactly what errors you're getting as it works fine for me.

I've updated the cruise example to add a !save command and also a few other small tweaks. You can specify a list of admin usernames with the ADMIN_USERNAMES variable.

Remember as well that you need to have a folder called 'users' in the same directory as the script is being run from.
Last edited by DarkTimes, .
DarkTimes
S2 licensed


OK, so that appears to be the unicode character for 'telephone sign' (2121), which is actually in the Japanese code page twice! at both 8784 and at
FA5A. So basically you will find it in LFS under Japanese in either 87 or FA.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
I've also created a simple help file with the documentation, that you can download separably. It's not perfect, a couple of small things are missing, but it works reasonably well.

Edit: help file removed, it is now a part of the official download.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
As you'll notice the old InSim.Run() method has been removed, as it was just confusing to most people. You now need to keep the application open yourself, which there are several ways to handle.

Firstly you can do it simply, like in my examples above.

Console.WriteLine("Press any key to exit...");

// Block until the user presses a key.
Console.ReadKey(true);

With this method it's easy to close the application by mistake, so it would be better to use a specific key combination. Here's an example of how you would do that.

Console.WriteLine("Press Ctrl+Z to exit...");

// Poll for the correct key combination.
ConsoleKeyInfo key;
do
{
key = Console.ReadKey(true);
}
while (!key.Modifiers.HasFlag(ConsoleModifiers.Control) && key.Key != ConsoleKey.Z);

Alternatively you can have the program stay open until the connection with LFS has been closed.

while (insim.IsConnected)
{
Thread.Sleep(200);
}

Of course if you're using the library from a GUI application then the program will stay open automatically.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
I have released InSim.NET 2.0.0 Beta to CodePlex project site. The download link can be found here:

http://insimdotnet.codeplex.com/releases/

Features in this release
  • Full InSim, InSim Relay, OutSim and OutGauge support
  • Better support for .NET languages other than C#
  • Improvements to string encoding/decoding
  • General API improvements
  • Mercurial source control repository
Changes

There are quite a few changes in this release, although most stuff will be familiar to people who have used to library before. There are too many changes to recount from the top of my head but I'll try to give the bullet-points.

InSim

Firstly the biggest change you'll notice is that you now initialize the InSim connection differently. To initialize the connection you now use the new InSim.Initialize(InSimSettings) method. Like so:

using System;
using InSimDotNet;

class Program
{
static void Main()
{
// Create new InSim object.
using (InSim insim = new InSim())
{
// Initialize InSim.
insim.Initialize(new InSimSettings
{
Host = "127.0.0.1",
Port = 29999,
Admin = String.Empty,
});

// Send message 'Hello, InSim!' to the game chat.
insim.Send("/msg Hello, InSim!");

// Stop program from exiting.
Console.WriteLine("Press any key to exit...");
Console.ReadKey(true);
}
}
}

Also the way in which you bind packets has changed slightly, as you now must always specify a InSim parameter on the packet handler. Like this:

using System;
using InSimDotNet;
using InSimDotNet.Packets;

class Program
{
static void Main()
{
using (InSim insim = new InSim())
{
// Bind packet handler.
insim.Bind<IS_MSO>(MessageOut);

insim.Initialize(new InSimSettings
{
Host = "127.0.0.1",
Port = 29999,
Admin = String.Empty,
});

// Stop program from exiting.
Console.WriteLine("Press any key to exit...");
Console.ReadKey(true);
}
}

// Packet handler now must specify a InSim parameter.
static void MessageOut(InSim insim, IS_MSO mso)
{
Console.WriteLine(mso.Msg);
}
}

With the changes to the way you initialize InSim, you can now specify a separate UDP port for MCI and NLP updates.

using System;
using InSimDotNet;
using InSimDotNet.Packets;

class Program
{
static void Main()
{
using (InSim insim = new InSim())
{
insim.Bind<IS_MCI>(MultiCarInfo);

insim.Initialize(new InSimSettings
{
Host = "127.0.0.1",
Port = 29999,
Admin = String.Empty,
UdpPort = 30000, // Specify UDP port
Interval = 1000, // Update interval (milliseconds)
Flags = InSimFlags.ISF_MCI, // Enable MCI updates
});

// Stop program from exiting.
Console.WriteLine("Press any key to exit...");
Console.ReadKey(true);
}
}

// Handle MCI packet.
static void MultiCarInfo(InSim insim, IS_MCI mci)
{
foreach (CompCar car in mci.Info)
{
// Do something with CompCar.
}
}
}

InSim Relay

InSim relay works exactly as before, except now you initialize it by setting the InSimSettings.IsRelayHost property to true.

using System;
using InSimDotNet;

class Program
{
static void Main()
{
using (InSim insim = new InSim())
{
insim.Initialize(new InSimSettings
{
IsRelayHost = true, // Initialize InSim Relay.
});

// Stop program from exiting.
Console.WriteLine("Press any key to exit...");
Console.ReadKey(true);
}
}
}

When IsRelayHost is set all other settings are ignored.

OutGauge and OutSim

There is now full OutSim and OutGauge support. Here is an example of using OutSim.

using System;
using InSimDotNet.Out;

class Program
{
static void Main()
{
// Create new OutSim object.
using (OutSim outsim = new OutSim())
{
// Bind OutSim packet event.
outsim.PacketReceived += new EventHandler<OutSimEventArgs>(outsim_PacketReceived);

// Start listening for packets sent from LFS.
outsim.Connect("127.0.0.1", 30000);

// Stop program from exiting.
Console.WriteLine("Press any key to exit...");
Console.ReadKey(true);
}
}

static void outsim_PacketReceived(object sender, OutSimEventArgs e)
{
// Do something with packet.
OutSimPack packet = e.Packet;
}
}

Download

You can download the InSim.NET 2.0.0 Beta from CodePlex right now!
Last edited by DarkTimes, .
DarkTimes
S2 licensed
We can figure out it, as the LFS code pages are the same as the ones used by Windows. You can use Character Map (Program Files > Accessories > System Tools, make sure to select Advanced View) to find the required character, then look it up in the related Windows code page. That should tell you where to find it inside LFS.

Edit: If you can tell me exactly which character it is I can look it up for you. Sorry, but I don't speak Chinese.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
That won't make it more random.

To make it more random, you should not create a new instance of the Random class each time, instead make a single instance and call the Next() each time you need a number. This will reduce the number of collisions in the random number generator.

Thing is though with such a small sample of numbers you will get a lot of collisions naturally. You can simply add some logic to the code to stop it picking the same two random numbers in a row. This will make it appear more random than it is because it won't repeat so much. Here is some badly written example code.

Random random = new Random();
int? lastRandomNumber;

int GetRandomNumber(int min, int max)
{
// Keep picking numbers until we get a new one.
int randomNumber = 0;
do
{
randomNumber = random.Next(min, max);
}
while (randomNumber == (lastRandomNumber ?? -1));

// Store last random for next check.
lastRandomNumber = randomNumber;

return randomNumber;
}

Last edited by DarkTimes, .
DarkTimes
S2 licensed
Quote from mariuba2 :
Can someone update LFS_External? Cause They say Trox gave up coding or somthing?

T-RonX never released the source code for LFS_External so it's not possible for anyone to update it.
DarkTimes
S2 licensed
Quote from hyntty :Sure it's daft as hell, you can't actually do anything smart with it

Except, you know, YouTube, BitTorrent and Eve Online...
DarkTimes
S2 licensed
This is untested, but something like this should work. Obviously you need to add it to the CMD_LOOKUP dict.

def cmd_save(insim, ncn, args):
if ncn.Admin:
[save_user_vars(n.UName, n) for n in connections.values() if n.UCID]
insim.sendm('^3| ^7The users have been saved!', ncn.UCID)
else:
insim.sendm('^3| ^7You are not an admin', ncn.UCID)

Or if you only want yourself to be able to do it and not just any admin replace the first line.

if ncn.UName == 'learjet45':
pass

DarkTimes
S2 licensed
I hadn't really thought about it up until now, but the way I was figuring out the elapsed time was kinda low-tech and not very accurate. I've updated it to use a high-performance timer which gives much more accurate readings.

As ever it's on CodePlex.
DarkTimes
S2 licensed
Quote from Dygear :It feels like that's the easy way out. It would be, but I don't think that's fair to the people who started using PRISM. I will get PDO support I just have to think of a good way to impalement it so it's not insane for everyone. I think I have a lot of programming ahead of me.

I don't consider it the easy way out, more an acknowledgement that anything you write will be generic (by requirements) and won't be honed for any kind of specific purpose. Also your forcing developers into writing against whatever you think is best, which may not suit what they're trying to do. For instance I'm sure most PHP developers are quite happy writing SQL queries, whereas I would much rather find a nice ORM layer to use. And as filur says, if plugins can talk to each other, then what's to stop you having different plugins for different database systems.

Also the idea of storing key/value pairs and serializing objects isn't that daft. I mean, that's how World of Warcraft addons do it. I've no idea what PHP's object serializer is like, but being a dynamic language I'm guessing it's probably pretty good.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
Quote from Dygear :I really don't like the PDO, it sucks to program for in the context of PRISM. If anyone has any ideas I'm willing to listen. (filur, ripnet, & Victor I'm lookign at you guys.)

I would suggest that PRISM should only provide simple storage for key/value pairs and maybe serialized objects. If a plugin wants or needs more advanced storage they can implement it themselves.
DarkTimes
S2 licensed
I dunno if you guys listen to any programmer podcasts, but I'd suggest giving a shot to This Developer's Life, which started this... eh, last... year. It's very good and quite partisan in its affiliations and doesn't focus on any specific technology or platform. Anyway just thought I'd suggest it.

For .NET specific podcasts I'd suggest HanselMinutes and of course .NET Rocks!
DarkTimes
S2 licensed
Quote from S14 DRIFT :To be honest, this could have been a good thread for some intellectual discussion on computer systems (which is hard to find these days!) but since people from Scotland insist in pretending like I know everything (I don't), it kind of dulls the fun so I would rather whore some other part of the forum where the average IQ is below 75.

I thought my last post was quite informative actually, I gave a background history and everything! I've been watching videos about the UAC given by the team that made it, they are pretty clever guys. You can Google for them easily, but I'd suggest starting off with this one. Some of that stuff may not make sense if you aren't a programmer, but it should give you an idea that these guys aren't full of crap, and they really did pour a huge amount of effort and resources into the system. Also the system makes a lot of sense.

Incidentally, I never set out to have an intellectual discussion. My suggestion was meant in the best interests of the game. I had no idea it would be so inflammatory. I highly recommend that people watch the video I posted about the UAC before they make any more remarks here, just so we know we're on the same page.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
Quote from Victor :yeah hummm So atm it's all in unix line endings (LF), which I'm personally fine with, but when windows users open an ini file in notepad, it's unreadable.
So like you say, we have to find a way to keep things, or releases at least in CRLF format. That means we all have to work in CRLF format as well I guess, or at least save them like that.

I know I'm several months late, but there is a great article about CRLF by Raymond Chen.

To sum up you might as well always use CRLF.
DarkTimes
S2 licensed
Quote from PoVo :Basically yes, the same thing as my solution is used on the Example.

The purpose of my example was to show that what you are trying to do is possible without making the constructor for CompCar public. If you really wanna make CompCar constructable then you can edit the CompCar.cs class to add a blank public constructor and recompile the library.

But as I showed in my example you don't need to do this to be able to store a reference to the CompCar for access later, it currently works as it is.

Edit: The reason that CompCar has an internal constructor instead of a public one is because it requires a parameter that's an internal data-structure called PacketReader, which is not available outside of the assembly (for complicated reasons). At the time it was written I considered providing an alternative public constructor, but realized that if you are trying to create an instance of CompCar then either you are doing something wrong or something the library was never designed to do (in which case the library should be redesigned). The reason that you don't need to worry about constructors when using LFS_External is because all packets in that library are structs and not classes, so automatically provide default constructors like all value-types. However the reason that all packets are structs in LFS_External is an implementation detail and was not made because of a design decision.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
It's always a good idea to make a backup of any files before you tweak them, for this very reason. There's not really anyway to fix it except to uninstall LFS and reinstall it. If you know which files have been changed you can get replacements from a friend who has an unmodified copy of the game and just paste them in. If not then backup all your setups/replay etc.. and reinstall the game.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
OK - you're getting me to actually type stuff, which I'm not good at.

Quote from S14 DRIFT :Reading back what I wrote last night while in a mood, I can see how it perhaps came across as "aggressive" but the point stands...then again people are easily insulted ON THE INTERNET....INTERNET...LOL INTERNET.

I for one didn't say I was insulted, I said your post was ad hominen, which it was. You have said absolutely nothing to refute my original point, which is that LFS should be changed to work correctly on Windows 6 series operating systems, a change that would be trivial to implement. All your arguments are about how people that use UAC are idiots and how you're smarter than the guys who wrote the OS you're using.

Quote :
I'm justifying it by saying that asking permission every time something is run is not a security feature, or an benefit, it's a blanket policy put in place.

Quote :It's just that I don't rely on a program that says "are you sure you want to run this" to protect me. Pretty much any antivirus/security software would pick up 99% of keyloggers that are availible and if they were clever enough to avoid heuristic scanning from anti virus programs then they would be clever enough to avoid UAC.

From these two quotes it seems a pretty safe bet that you don't know what UAC is or how it works. The idea that UAC is just a bunch of annoying dialog prompts is a very common fallacy. UAC is to do with the way that processes are started on Windows, so it's not possible for it to be circumvented by 'clever' viruses.

The failure of Windows in the past to separate system space from user space has been the cause of a whole class of security vulnerabilities, which Microsoft has now closed off through the addition of UAC. In previous versions of Windows you were an administrator by default, and Windows made it hard (in many cases impossible) for you to run as anything else (partly because programmers coded on admin accounts too). Now they've changed it round so you are a standard user by default and Windows makes it hard to do things as an administrator.

The thing is, and this is how Windows is designed, 99.9% of programs don't need to do anything that requires administrator privililedges. The only programs that need admin status are installers and programs that manipulate the Windows system (such as, you know, explorer.exe). Any program which requires admin rights and does not either install something or manipulate system files is badly designed. Sadly many programs are badly designed, with complete disregard for the way in which Windows security works, and that's probably why so many people complain about (seemingly) needless prompts. My suggestion is that the Scawen fixes this small issue, changes the default location in which files are saved, and makes LFS comply with the way in which games on Windows are supposed to work. The way those guys in Seattle, who aren't as smart as S14, designed it to work.

Really, what settings people may choose to run on their machines is irrelevant, LFS should continue to work if you install it in Program Files (where program files are supposed to go and no it doesn't mention this anywhere in the LFS installer or the readme so Whiskey can shutup) and are running in the least privileged mode. You may not like UAC, but whether you turn it off, you use it through paranoia, or because you're seven and that's the only way your dad will let you, it should not make any difference to LFS.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
Quote from S14 DRIFT :Ugh, haven't read this thread but read the OP and got straight onto writing this.

Firstly, UAC is pointless. It doesn't do anything to add to security, all it does is ask for your permission everytime you or any program tries to do anything with your computer.

Do both yourself and the world at large a massive favour and disable it. E.Reiljans's fix is pretty decent, to be fair.

But back to my point, unless you are in a network of computers which hold extremely volitile company data (which I very much doubt you are since you want to run LFS), there is absolutely no steadfast reason why you would want UAC enabled. I know plenty of large business clients who don't run it because it's more of a pain in the ass than it is a security measure.

If you are a home user (which you probably are) then why the **** would you want UAC active on your machine? Just turn it off...stop living under the impression that the world and his script kiddie are trying to gain access to your computer to steal your collection of family photographs and light rock music. THEY'RE NOT - so stop banging on about having a "secure environment" because basic anti virus and intrusion protection (even NAT) is more than enough for home users, even small businesses.

Further to add to my dismay, even after you've been given a workaround, you continue to "have issues".

For as long as I can remember in most windows environments from XP onwards, you need to have administrative priveledges at least install, and normally run some programs (which includes games along with other executables). It is just how Windows is and your whines will not change that.

Moody S14 is now heading to bed, 2 hours late.

Wow what an aggressive post. That you also managed to completely miss the point is just bonus.

Quote :By the way that was not a personal dig at you...

Reread it then, your post is completely ad hominem and comes across as nothing but a "dig" at me. I'm sorry for daring to suggest that LFS should follow the design-guidelines laid out by the engineers who made Windows, and that the changes to make it adhere to those guidelines are so completely trivial to implement that it makes no sense not to.

Anyway, whatever...
Last edited by DarkTimes, .
DarkTimes
S2 licensed
OK here is a quick example I've written that shows saving the CompCar object in a connection object. It's a simple app that prints out the users location when the type the command '!location'.

using System;
using System.Collections.Generic;
using Spark;
using Spark.Helpers;
using Spark.Packets;

namespace ConsoleApplication4
{
class Program
{
// Class to store connection info.
class Connection
{
public CompCar Car { get; set; }
}

static Dictionary<int, IS_NPL> players = new Dictionary<int, IS_NPL>();
static Dictionary<int, Connection> connections = new Dictionary<int, Connection>();

static void Main(string[] args)
{
using (InSim insim = new InSim())
{
insim.Bind<IS_ISM>(InSimMulti);
insim.Bind<IS_NCN>(NewConnection);
insim.Bind<IS_NPL>(NewPlayer);
insim.Bind<IS_MCI>(MultiCarInfo);
insim.Bind<IS_MSO>(MessageOut);

// Connect to InSim.
insim.Connect("127.0.0.1", 29999);
insim.Send(new IS_ISI
{
Prefix = '!',
Interval = 1000,
Flags = InSimFlags.ISF_MCI,
});

// Request host packet.
insim.Send(new IS_TINY { ReqI = 1, SubT = TinyType.TINY_ISM });

Console.WriteLine("Press any key to exit...");
Console.ReadKey(true);
}
}

static void InSimMulti(InSim insim, IS_ISM ism)
{
// Whenever we connect to a host request the player and connection lists.
insim.Send(new IS_TINY { ReqI = 1, SubT = TinyType.TINY_NCN });
insim.Send(new IS_TINY { ReqI = 1, SubT = TinyType.TINY_NPL });
}

static void NewPlayer(InSim insim, IS_NPL npl)
{
// Add new player.
players[npl.PLID] = npl;
}

static void NewConnection(InSim insim, IS_NCN ncn)
{
// Add new connection.
connections[ncn.UCID] = new Connection();
}

static void MultiCarInfo(InSim insim, IS_MCI mci)
{
foreach (CompCar car in mci.CompCars)
{
IS_NPL npl;
Connection conn;
if (players.TryGetValue(car.PLID, out npl) &&
connections.TryGetValue(npl.UCID, out conn))
{
// Update car on connection.
conn.Car = car;
}
}
}

static void MessageOut(InSim insim, IS_MSO mso)
{
if (mso.UserType == UserType.MSO_PREFIX)
{
// Parse command.
string args = mso.Msg.Substring(mso.TextStart);
if (args.Equals("!location", StringComparison.InvariantCultureIgnoreCase))
{
Connection conn = connections[mso.UCID];

// Check we have received a compcar for this connection yet.
if (conn.Car != null)
{
// Send location message.
string message = String.Format(
"X: {0:F2} Y: {1:F2} Z: {2:F2}",
MathHelper.LengthToMeters(conn.Car.X),
MathHelper.LengthToMeters(conn.Car.Y),
MathHelper.LengthToMeters(conn.Car.Z));

insim.Send(message, mso.UCID);
}
}
}
}
}
}

Last edited by DarkTimes, .
DarkTimes
S2 licensed
Where is the NullReferenceException being thrown in your code? That's where the actual problem is, all this stuff about CompCar is just getting in the way. You said in your first post:

Quote from PoVo :When trying to put info from MCI onto this, I get the usual "Object reference not set to an instance of an object" error... so then I tried this:

It sounds to me like this is the actual problem we need to solve. I'm sorry, but I need to see more code. I'm not trying to be funny, but I do really believe that you're making the solution to this more complicated that it needs to be.
DarkTimes
S2 licensed
The data should not go into AppData, of course it would be stupid to save replays and screenshots in a hidden folder. A better idea would be to create a LFS folder under the user's name, or maybe in the My Games folder. Then have little sub-folders for replays, screenshots or other stuff.
DarkTimes
S2 licensed
Quote from pipa :Well and in another year microsoft comes out with a new clever security system that wants to protect the user of himself and lfs needs to be adapted for that again.

Don't see the point, just set your properties to "always run as administrator" and you should be fine.

Not 100% sure though, since uac was the first thing i turned off.

The point is that LFS forces you to run it with elevated privileges when it doesn't actually require those privileges. The whole idea of storing user files in the user's profile has been around in Windows for a long time, it just wasn't enforced until Vista. If you don't wanna run Windows in a secure way then that's your choice, but a well designed program should be able to work no matter how you have configured your security settings. You should not have to flag a game as 'administrator only' just to play it.
Last edited by DarkTimes, .
FGED GREDG RDFGDR GSFDG