Posted 13-Jul-11 15:18 by TheJoker

c# dev kit question - correction

looks like c# requires more code to make this stable..

declare debugmap like this:
internal unsafe struct DebugMapStruct
{
public fixed Int32 map[66000];
}

inside empire we now add this:

DebugMapStruct debugmap;
public unsafe void setdebugmap(int loc,int value)
{
fixed (Int32* p = debugmap.map)
{
*(p+loc) = value;

}
}

and in empire constructor we put:

unsafe
{
debugmap = new DebugMapStruct();
fixed (void* p = debugmap.map)
{
serverCall(Protocol.sSetDebugMap, Us.ID, 0, p);
}
}



another side note perhaps to the c# devkit.
It seems to create alot of "new" locations all the time.
Seems a bit weird considering there are actually only so many of them.

personally I created a location map:
Location[] locationmap;
which I filled like this:
locationmap = new Location[Map.Size];
for (int i=0; i < Map.Size ; i++)
locationmap[i] = new Location(this,i);
this way I can lookup a few things slightly faster without
creating tons of objects in memory.
location class is in essense almost completely static in relationship to its ID variable really.. so some of the functions could've been included directly in map perhaps?
but yea c# devkit is nice so far !





Answer This Posting

User Name

New user

Password

Change password

Subject

Text

Administration

Password