The online racing simulator
Spark, C# and mono
Hi!
I started coding with Spark library but I need to run it on mono on my Debian VPS for InSim's.
Main program code (this is modified example):

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

namespace Spark.Example4
{
/// <summary>
/// Example 4: Helpers. Connects to InSim, requests all players to be sent, the prints out
/// the time of each player that completes a lap.
/// </summary>
class Program
{
// We store the players in a dictionary with the PLID as the key.
static InSim insim;
static Dictionary<int, IS_NPL> _players = new Dictionary<int, IS_NPL>();
static Dictionary<int, IS_NCN> _conns = new Dictionary<int, IS_NCN>();

static void Main()
{
// Create new InSim object.
using (insim = new InSim())
{
// Bind handlers.
insim.Bind<IS_NCN>(NewConn);
insim.Bind<IS_CNL>(ConnLeft);
insim.Bind<IS_NPL>(NewPlayer);
insim.Bind<IS_PLL>(PlayerLeft);
insim.Bind<IS_MCI>(MultiCarInfo);

// Establish the InSim connection.
insim.Connect("62.75.388.55", 65948);

// Initialize InSim.
insim.Send(new IS_ISI { IName = "^3MP 2010 DEMO", Admin="youwonnait", Prefix = '@', Flags = InSimFlags.ISF_MCI, Interval = 1000});

// Request connections.
insim.Send(new IS_TINY { SubT = TinyType.TINY_NCN, ReqI = 255});

// Request players.
insim.Send(new IS_TINY { SubT = TinyType.TINY_NPL, ReqI = 255});

//insim.Bind<IS_MCI>(MultiCarInfo);

// Prevent program from exiting.
insim.Run();
}
}

static void NewConn(IS_NCN ncn)
{
if(_conns.ContainsKey(ncn.UCID)){
_conns[ncn.UCID] = ncn;
}
else{
_conns.Add(ncn.UCID, ncn);
}
Console.WriteLine("New connection: {0} ({1}) #{2}", ncn.PName, ncn.UName, ncn.UCID);
}

static void ConnLeft(IS_CNL cnl)
{
Console.WriteLine("Connection left: {0} ({1}) #{2} Reason: {3}", getConn(cnl.UCID).PName, getConn(cnl.UCID).UName, cnl.UCID, cnl.Reason);
_conns.Remove(cnl.UCID);
}

static void NewPlayer(IS_NPL npl)
{
if (_players.ContainsKey(npl.PLID))
{
// Leaving pits, just update NPL object.
_players[npl.PLID] = npl;
}
else
{
// Add new player.
_players.Add(npl.PLID, npl);
}
Console.WriteLine("New player: {0} (#{1})", npl.PName, npl.UCID);
}

static void PlayerLeft(IS_PLL pll)
{
// Remove player.
_players.Remove(pll.PLID);
}

static void MessageOut(IS_MSO mso)
{
if(mso.Msg == "something"){

}
}

static IS_NPL getPlayer(byte PLID){
Int32 szukaj = Convert.ToInt32(PLID);
return _players[szukaj];
}

static IS_NCN getConn(byte UCID)
{
Int32 szukaj = Convert.ToInt32(UCID);
return _conns[szukaj];
}

static void spectatePlayer(byte PLID) {
Console.WriteLine("Speeding: {0}", getConn(getPlayer(PLID).UCID).UName);
if (getConn(getPlayer(PLID).UCID).UName == "misiek08")
{
insim.Send(new IS_MST { Msg = ("/spec " + getConn(getPlayer(PLID).UCID).UName) });
}
}

static void NodeLapPacket(IS_NLP nlp)
{
foreach (var nlpp in nlp.NodeLaps){
Console.WriteLine("" + nlpp.Lap);
}
}

static void MultiCarInfo(IS_MCI mci)
{
// Loop through each car on track.
foreach (var car in mci.CompCars)
{
IS_NPL npl;
// Get the NPL packet if it exists...
if (_players.TryGetValue(car.PLID, out npl))
{
// Convert LFS speed into Mph.
var kph = MathHelper.SpeedToKph(car.Speed);
// Print nicely formatted string to console.
Console.WriteLine("Speed: {0} {1:F2}", npl.PName, kph);
if (kph > 100)
{
spectatePlayer(car.PLID);
}
}

}
}
}
}

On windows it's working good but on mono it throws:

WARNING: The runtime version supported by this application is unavailable.
Using default runtime: v1.1.4322

** (Spark.Example4.exe:11622): WARNING **: The class System.Collections.Generic.Dictionary`2 could not be loaded, used in mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Unhandled Exception: System.TypeLoadException: Could not load type 'Spark.Example4.Program' from assembly 'Spark.Example4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

I don't think Mono supports .NET 4.0 yet.
Someone told me it supports 4.0 from 2.4 version (I had it) and few ppl said it's 2.6 mono version for 4.0 .NET . I can't find one, strictly answer.
I'm pretty sure it doesn't support .NET 4.0. I might be wrong.
Oh. I found. 2.8 or 3.0 should support 4.0. Now we have 2.6 so it can take a lot of time. So I have to use external lib (not Spark). wine isn't supporting any .NET.
Why do you need to use LFS External instead of Spark?
I can use Spark but tell me how to run it on Debian Lenny via Command Line? It's VPS server.
-
(filur) DELETED by filur

FGED GREDG RDFGDR GSFDG