The online racing simulator
Searching in All forums
(921 results)
DarkTimes
S2 licensed
Politicians do this all the time, they know the news are just going to condense it down to a 10 second sound bite anyway, so they want to make sure they get their message across. Still, it is extremely embarrassing to watch. I used to not mind Ed Milliband, but at a time when the UK really needs a strong opposition, I don't think he's doing a good job at all. It's shit like this that makes me vote SNP.
DarkTimes
S2 licensed
I've been working on InSim.NET 3.0, that I intend to use to clear up certain annoyances I have with the library currently.

The main issue is that, when InSim.NET 1.0 was written, it was intended to be used with InSimSniffer, which put certain constraints on its design. Firstly it had to match the original InSim protocol as closely as possible, this meant using Scawen's naming conventions and other stuff like that. The rest of the library, stuff what I made, was written to .NET naming conventions. This means the library currently mixes naming conventions, which is an annoyance to me. It also means that some things are harder to do that they could be, which has really come to forefront recently with values containing low/high bits, such as the RST Timing. So I first of all want to clear all that up and rewrite the InSim stuff to .NET conventions, and also add lots of stuff to make using the actual packets much simpler. Obviously this means breaking backwards compatibility.

I've also got very tried of having to laboriously type out the packet handlers each time, and while of course you can write a codesnippet to do it for you, they would work better as events. So the second thing I plan to do is to make each packet a proper .NET event.

Basically the plan is to make InSim.NET 3.0 a higher level library, where appropriate. I think a balance between low and high level, in terms of the API, is what I'm looking for these days.

I've already written most of this, and might try to release a beta/alpha version soon, but I just thought I'd mention it now so as no one is surprised when it comes out. I'm going to fork the CodePlex repository at some point (I'm just working off local repositories at the moment), so the existing codebase and releases will remain, so you won't need to upgrade if you don't want to.
DarkTimes
S2 licensed
Well, as the guy who 'owns' this program, he clearly hasn't read the license it's released under.

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Last edited by DarkTimes, .
DarkTimes
S2 licensed
function getFileExtension(filename) {
return filename.split('.').pop();
}

DarkTimes
S2 licensed
Pushed release for LFS 0.6B to CodePlex. I added the new InSim packets and also reworked the options dialog so you can turn the new packets on/off. You can download the new release from CodePlex. As always please tell me of any bugs you find, or improvements you can suggest.

http://insimsniffer.codeplex.com/releases/
DarkTimes
S2 licensed
SQLite is basically just a cut down version of SQL. It allows you to add a simple file based database to your app without having to worry about the complexities of setting up a proper SQL server. Apart from a few different API calls and a few missing commands, SQLite should be extremely familiar to anyone who's used MySQL or MSSQL. Also it's built into the Python standard library, which means there is absolutely no configuration required to start using it, you just import the sqlite3 module and start executing commands.

http://docs.python.org/library/sqlite3.html

For .NET there is SQL Compact, which is the cut-down version of Microsoft SQL Server, which is basically the same thing and is built into the .NET 4.0 API.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
The Williams Renault returns.

http://news.bbc.co.uk/sport1/hi/formula_one/14018777.stm

I know they won't recapture their former glory, but something about that name is still very evocative for me.
DarkTimes
S2 licensed
Quote from DeadWolfBones :Aside from the first one, the Swedish ones were pretty crap. (Makes sense, since the first book was the only really good one as well.)

Trailer for the US version looks pretty interesting TBH.

I've not seen the movies, but I loved the books. I thought the second one was better than the first, the first took too long to get going and then dissolved into a pretty derivative serial killer yarn. The second was much more enjoyable in my view, despite the implausibility of the ending.

Anyway, rewatched Shaun of the Dead the other night, it just keeps getting hilariouser. Got Let the Right One In to watch, as well as the remastered version of Full Metal Jacket. Good times.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
I'm sure I've linked to this before, but this is an excellent free Python ebook. This was the tutorial that taught me how to code Python. I wrote the first version of pyinsim about an hour after I starting reading this.

http://diveintopython.org/
DarkTimes
S2 licensed
I've been wanting to do an example of using a database with pyinsim for a while, so I knocked up a quick script today. It's a simple lapper app that tracks a users fastest lap on track and stores it in a SQLite database. SQLite is great for this as it comes as part of the Python installation, meaning you don't need to do any setup to use it. Right now the script is very simple, it just sends a message whenever you cross the start/finish line, but I hope to update it more when I have some free time. I'm not a database whizz, so my SQL code might not be the best, but for as simple an app as this it should suffice.

import sqlite3
import pyinsim

# Constants.
DB_NAME = 'lapper.db'
HOST = '127.0.0.1'
PORT = 29999
ADMIN = ''
NAME = 'PyLapper'


# Class to represent the database.
class LapperDB(object):
def __init__(self, db_name):
self.db_name = db_name

def __enter__(self):
self.db = sqlite3.connect(self.db_name)
self.db.text_factory = str # Set text-mode to ASCII
self.db.row_factory = sqlite3.Row
return self

def __exit__(self, type, value, traceback):
self.db.close()

def table_exists(self, table_name):
return self.db.execute('SELECT name FROM sqlite_master WHERE name=?', [table_name]).fetchone()

def init_db(self):
# Create laps table if it does not exist.
if not self.table_exists('laps'):
self.db.execute('CREATE TABLE laps (uname TEXT, track TEXT, car TEXT, ltime INT)')

def get_lap(self, uname, track, car):
conn = self.db.execute('SELECT ltime FROM laps WHERE uname=? AND track=? AND car=?', [uname, track, car])
return conn.fetchone()

def add_lap(self, uname, track, car, ltime):
self.db.execute('INSERT INTO laps (uname, track, car, ltime) VALUES (?, ?, ?, ?)', [uname, track, car, ltime])

def update_lap(self, uname, track, car, ltime):
self.db.execute('UPDATE laps SET ltime=? WHERE uname=? AND track=? AND car=?', [ltime, uname, track, car])

def commit(self):
# Save changes to database.
self.db.commit()


# Globals.
connections = {}
players = {}
track = None

def joined_multiplayer(insim, ism):
# When joined host ask for all players/connections.
insim.send(pyinsim.ISP_TINY, SubT=pyinsim.TINY_NCN, ReqI=1)
insim.send(pyinsim.ISP_TINY, SubT=pyinsim.TINY_NPL, ReqI=1)

def state_changed(insim, sta):
# Keep track of current track.
global track
track = sta.Track

def new_connection(insim, ncn):
connections[ncn.UCID] = ncn

def connection_left(insim, cnl):
del connections[cnl.UCID]

def new_player(insim, npl):
players[npl.PLID] = npl

def player_left(insim, pll):
del players[pll.PLID]

def lap_completed(insim, lap):
# Get player/connection from list.
npl = players[lap.PLID]
ncn = connections[npl.UCID]

# Open DB connection.
with LapperDB(DB_NAME) as db:
# Get lap for this car/track.
row = db.get_lap(ncn.UName, track, npl.CName)
if not row:
# No lap exists.
db.add_lap(ncn.UName, track, npl.CName, lap.LTime)
db.commit()
insim.sendm('first lap on %s/%s' % (track, npl.CName), ncn.UCID)
elif lap.LTime < row['ltime']:
# New fastest lap.
db.update_lap(ncn.UName, track, npl.CName, lap.LTime)
db.commit()
insim.sendm('fastest lap: %s' % pyinsim.timestr(lap.LTime), ncn.UCID)
else:
# Slower lap.
insim.sendm('slower lap: %s' % pyinsim.timestr(lap.LTime), ncn.UCID)

def error(insim, err):
print 'Error:', err

def closed(insim):
print 'Error: no host connected'

def init(insim):
print 'Connected to host (%s:%d)' % (insim.hostaddr[0], insim.hostaddr[1])

def main():
print NAME
print ''.rjust(len(NAME), '-')

# Init DB and create laps table.
print 'Initializing database...',
with LapperDB(DB_NAME) as db:
db.init_db()
print 'done'

# Init InSim and bind events.
insim = pyinsim.insim(HOST, PORT, Admin=ADMIN, IName=NAME)
insim.bind(pyinsim.EVT_ERROR, error)
insim.bind(pyinsim.EVT_CLOSE, closed)
insim.bind(pyinsim.EVT_INIT, init)
insim.bind(pyinsim.ISP_ISM, joined_multiplayer)
insim.bind(pyinsim.ISP_STA, state_changed)
insim.bind(pyinsim.ISP_NCN, new_connection)
insim.bind(pyinsim.ISP_CNL, connection_left)
insim.bind(pyinsim.ISP_NPL, new_player)
insim.bind(pyinsim.ISP_PLL, player_left)
insim.bind(pyinsim.ISP_LAP, lap_completed)

# On connecting request state and host packet.
insim.send(pyinsim.ISP_TINY, SubT=pyinsim.TINY_SST, ReqI=1)
insim.send(pyinsim.ISP_TINY, SubT=pyinsim.TINY_ISM, ReqI=1)

# Start packet receive loop.
pyinsim.run()

if __name__ == '__main__':
main()

Last edited by DarkTimes, .
DarkTimes
S2 licensed
Hehe, it wasn't a hint, it's just that Stack Overflow is the single most useful programming resource on the internet.
DarkTimes
S2 licensed
As far as I'm aware it's just a preference thing, it makes no difference. I actually tend to use single-quotes ' ', purely because you don't have to hold shift to type them, I'm not sure why I didn't in my example.

Again Stack Overflow has it covered.
DarkTimes
S2 licensed

<?php 
function getfiletype(name) {
    return 
name.substr(-4) == ".set";
}
?>

Although to actually get the file extension in JavaScript, have a look at this Stack Overflow question.
DarkTimes
S2 licensed
Hey if people wanna love me I'm not gonna complain!

In seriousness though, I do spend a lot of hours working on these programs with very little feedback, so I'm grateful that people do occasionally find them useful.
DarkTimes
S2 licensed
Incidentally, as some people have worked out, you can follow pyinsim (and InSim.NET) on CodePlex to get automatic email notifications whenever a new version is released. Just sign up to CodePlex and click the 'follow' button above the releases panel. I use this for other projects I'm interested in, it's quite useful actually.
DarkTimes
S2 licensed
Heya, I've pushed a release onto CodePlex for pyinsim 2.0.4.

Changes
  • Updated to LFS 0.6B
  • Now deals better with corrupt packets
  • General tweaks
I've tested the packets and they seem to work OK, but let me know if you have any problems. I removed a lot of unnessesary stuff from insim.py and there's a chance I might have removed something important by mistake. Hopefully not...

Here is an example that prints out the contents of each AutoX object whenever a layout is loaded or edited.

import pyinsim

def autox(insim, axm):
# Print out each object.
for obj in axm.Info:
print vars(obj)

# Init InSim with AXM flags.
insim = pyinsim.insim('127.0.0.1', 29999, Admin='',
Flags=pyinsim.ISF_AXM_EDIT|pyinsim.ISF_AXM_LOAD)

# Bind AXM event.
insim.bind(pyinsim.ISP_AXM, autox)

# Start the packet receive loop.
pyinsim.run()

Here is an example of setting the player cars to open-wheelers only.

import pyinsim

# Init InSim.
insim = pyinsim.insim('127.0.0.1', 29999, Admin='')

# Set all player cars to open-wheelers.
insim.send(pyinsim.ISP_PLC, UCID=255,
Cars=pyinsim.CAR_BF1|pyinsim.CAR_FO8|pyinsim.CAR_FBM|pyinsim.CAR_MRT)

# Receive packets.
pyinsim.run()

If you need examples of other stuff, give us a shout, although it should be pretty self-explanatory.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
Yeah, sorry, I've been busy. I added the new packets to the repository a week or so ago, but I've not had time to test them yet. I'll try and do that today.
DarkTimes
S2 licensed
Quote from Beaver08 :i dont understand why you have a conn.cs all you need to do is define the var

var Conn = Connections[GetConnIdx(PACKET HERE.UCID)];

with the packet here you can replace it with whatever packet you are coding under.

They both mean the same thing, only in one instance you're telling the compiler what type you want, in the other you're telling the compiler "go figure out the type for me". It's entriely down to preference whether you use it or not, the only situation it's required (and why it was added to the language) is for declaring an anonymous object. Sometimes using var makes the code clearer, sometimes it makes the code less clear, sometimes it's needed, sometimes you must declare the full type. There is no right or wrong here.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
Quote from Krammeh :

<?php 

$cars
=array('XFG'=>1'XRG'=>2'XRT'=>4'RB4'=>8'FXO'=>0x10,
                    
'LX4'=>0x20'LX6'=>0x40'MRT'=>0x80'UF1'=>0x100,
                    
'RAC'=>0x200'FZ5'=>0x400'FOX'=>0x800'XFR'=>0x1000,
                    
'UFR'=>0x2000'FO8'=>0x4000'FXR'=>0x8000'XRR'=>0x10000,
                    
'FZR'=>0x20000'FBM'=>0x40000'BF1'=>0x80000);

$PLC = new IS_PLC;
$PLC->UCID($this->connID)->Cars($cars['UF1']+$cars['BF1'])->Send($this->serverID);

?>


I think you use a bitwise OR to combine the cars, so it would be.

$cars['UF1'] | $cars['BF1']

DarkTimes
S2 licensed
I like how Chrome approaches versions, they don't have big flagship releases, like FireFox 4 and IE 9, they're just constantly iterating. The version numbers don't matter and I barely even notice them going up anymore. The goal of Google is to get to the point where you don't even notice the browser being updated. The whole big release thing dates from back when it was an effort to publish a new version, but now Google can push out an update every week. Frankly I see this as an improvement.

Also the whole LFS S2 alpha A, B, C thing is just confusing, especially since they ran out letters and went to 0.6 for no real reason. Just do major.minor.revision alpha/beta/stable like every one else.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
Quote from misiek08 :I don't have so much time to code every packet in Flash now so I'm asking people like Victor to release InSim flash library.

A good tip that I used when creating my InSim stuff was to write a script that parses InSim.txt and converts all the C structs into whatever language you are using, such as Python and C# in my case (although I wrote the script in Python). The script can be a bit fiddly to write, but as the InSim text file is already syntactically correct C code, it's not that difficult to parse. Of course the output may not be completely correct, but it should do 99% of the job for you, then you can add the rest manually. Plus of course once you have written such a script you can change it to produce output for other languages too. I agree that manually coding every packet is not a good idea, as not only is it the most boring code to write, you will also introduce lots of mistakes. A simple script however can do 99% of the job for you.
DarkTimes
S2 licensed
Just create a socket and receive packets normally. A two second search of Google revealed a bunch of info about networking in Flash, including tutorials and official documentation.

You only need to know two things to write InSim code:
  • How to use a TCP socket (there is insane amounts of info about this on Google)
  • How to decode and encode packets of data (again you are not the first person ever to try and do this)
Just do a few searches and figure it out. Writing networking code isn't difficult.
DarkTimes
S2 licensed
Yeah, OK, I totally take that back, they do share click IDs. My bad, sorry.

using (InSim insim1 = new InSim())
using (InSim insim2 = new InSim()) {
insim1.Initialize(new InSimSettings {
Host = "127.0.0.1",
Port = 29999,
Admin = String.Empty,
IName = "InSim 1",
});

insim2.Initialize(new InSimSettings {
Host = "127.0.0.1",
Port = 29999,
Admin = String.Empty,
IName = "InSim 2",
});

insim1.Send(new IS_BTN {
UCID = 255,
ClickID = 1,
H = 10,
W = 40,
L = 4,
T = 20,
ReqI = 1,
BStyle = ButtonStyles.ISB_DARK,
Text = "Button 1",
});

insim2.Send(new IS_BTN {
UCID = 255,
ClickID = 1,
H = 10,
W = 40,
L = 6,
T = 20,
ReqI = 1,
BStyle = ButtonStyles.ISB_DARK,
Text = "Button 2",
});

Console.ReadKey(true);
}

The second button overwrites the first one.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
ASP.NET MVC is a great Web platform, built on the .NET stack. Obviously StackOverflow is famously written in C#. You can download Visual Web Developer 2010 Express, which gives you Microsoft's complete web development toolkit (and the Silverlight SDK). Also check out Phil Haack's blog*, he is the lead developer on .NET MVC.

* While you're at it, also check out Eric Lippert's blog, he is a lead dev on the C# compiler team.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
Each InSim app gets its own click IDs. It would be insane if all InSim apps had to share them.
FGED GREDG RDFGDR GSFDG