(svn r25844) -Change: Increase maximum number of object instances on the map from 64k to about 16M.

This commit is contained in:
frosch
2013-10-12 16:35:50 +00:00
parent 29f5eab56c
commit 69a0c91d63
6 changed files with 13 additions and 12 deletions

View File

@@ -18,7 +18,7 @@
#include "town_type.h"
#include "date_type.h"
typedef Pool<Object, ObjectID, 64, 64000> ObjectPool;
typedef Pool<Object, ObjectID, 64, 0xFF0000> ObjectPool;
extern ObjectPool _object_pool;
/** An object, such as transmitter, on the map. */

View File

@@ -49,7 +49,7 @@ static inline bool IsObjectTypeTile(TileIndex t, ObjectType type)
static inline ObjectID GetObjectIndex(TileIndex t)
{
assert(IsTileType(t, MP_OBJECT));
return _m[t].m2;
return _m[t].m2 | _m[t].m5 << 16;
}
/**
@@ -81,7 +81,7 @@ static inline void MakeObject(TileIndex t, Owner o, ObjectID index, WaterClass w
_m[t].m2 = index;
_m[t].m3 = random;
_m[t].m4 = 0;
_m[t].m5 = 0;
_m[t].m5 = index >> 16;
SB(_m[t].m6, 2, 4, 0);
_me[t].m7 = 0;
}

View File

@@ -28,11 +28,11 @@ static const ObjectType NUM_OBJECTS = 64000; ///< Number of supported o
static const ObjectType INVALID_OBJECT_TYPE = 0xFFFF; ///< An invalid object
/** Unique identifier for an object. */
typedef uint16 ObjectID;
typedef uint32 ObjectID;
struct Object;
struct ObjectSpec;
static const ObjectID INVALID_OBJECT = 0xFFFF; ///< An invalid object
static const ObjectID INVALID_OBJECT = 0xFFFFFFFF; ///< An invalid object
#endif /* OBJECT_TYPE_H */

View File

@@ -2819,9 +2819,9 @@ bool AfterLoadGame()
/* Move ObjectType from map to pool */
for (TileIndex t = 0; t < map_size; t++) {
if (IsTileType(t, MP_OBJECT)) {
Object *o = Object::GetByTile(t);
Object *o = Object::Get(_m[t].m2);
o->type = _m[t].m5;
_m[t].m5 = 0; // cleanup for next usage
_m[t].m5 = 0; // zero upper bits of (now bigger) ObjectID
}
}
}