Skip to content
Browse files

Bump arbitrary structure limit of any structure type from 255 to 4294…

…967295.

255 limit was probably due to the important need to save 12 bytes of memory per structure type per player.
  • Loading branch information...
1 parent e87b3c0 commit bea4607858532f7370678f9c261cf5ee452434b5 @Cyp Cyp committed Feb 12, 2011
Showing with 31 additions and 50 deletions.
  1. +7 −26 src/game.cpp
  2. +4 −4 src/multiopt.cpp
  3. +12 −10 src/multiplay.h
  4. +4 −4 src/scriptfuncs.cpp
  5. +4 −6 src/structuredef.h
View
33 src/game.cpp
@@ -2038,31 +2038,12 @@ typedef struct _save_production
UDWORD multiPlayerID; //template to build
} SAVE_PRODUCTION;
-#define STRUCTLIMITS_SAVE_V2 \
- char name[MAX_SAVE_NAME_SIZE_V19]; \
- UBYTE limit; \
- UBYTE player
-
-typedef struct _save_structLimits_v2
-{
- STRUCTLIMITS_SAVE_V2;
-} SAVE_STRUCTLIMITS_V2;
-
-#define STRUCTLIMITS_SAVE_V20 \
- char name[MAX_SAVE_NAME_SIZE]; \
- UBYTE limit; \
- UBYTE player
-
-typedef struct _save_structLimits_v20
-{
- STRUCTLIMITS_SAVE_V20;
-} SAVE_STRUCTLIMITS_V20;
-
-typedef struct _save_structLimits
+struct SAVE_STRUCTLIMITS
{
- STRUCTLIMITS_SAVE_V20;
-} SAVE_STRUCTLIMITS;
-
+ char name[MAX_SAVE_NAME_SIZE];
+ UBYTE limit;
+ UBYTE player;
+};
#define COMMAND_SAVE_V20 \
UDWORD droidID
@@ -9864,7 +9845,7 @@ BOOL loadSaveStructLimitsV(char *pFileData, UDWORD filesize, UDWORD numLimits)
if (psSaveLimits->player < MAX_PLAYERS)
{
- asStructLimits[psSaveLimits->player][statInc].limit = psSaveLimits->limit;
+ asStructLimits[psSaveLimits->player][statInc].limit = psSaveLimits->limit != 255? psSaveLimits->limit : LOTS_OF;
}
else
{
@@ -9926,7 +9907,7 @@ BOOL writeStructLimitsFile(char *pFileName)
for(i = 0; i < numStructureStats; i++, psStructStats++)
{
strcpy(psSaveLimit->name, psStructStats->pName);
- psSaveLimit->limit = asStructLimits[player][i].limit;
+ psSaveLimit->limit = MIN(asStructLimits[player][i].limit, 255);
psSaveLimit->player = (UBYTE)player;
psSaveLimit = (SAVE_STRUCTLIMITS *)((char *)psSaveLimit + sizeof(SAVE_STRUCTLIMITS));
}
View
8 src/multiopt.cpp
@@ -109,8 +109,8 @@ void sendOptions()
// Send the structures changed
for (i = 0; i < ingame.numStructureLimits; i++)
{
- NETuint8_t(&ingame.pStructureLimits[i].id);
- NETuint8_t(&ingame.pStructureLimits[i].limit);
+ NETuint32_t(&ingame.pStructureLimits[i].id);
+ NETuint32_t(&ingame.pStructureLimits[i].limit);
}
updateLimitFlags();
NETuint8_t(&ingame.flags);
@@ -199,8 +199,8 @@ void recvOptions(NETQUEUE queue)
for (i = 0; i < ingame.numStructureLimits; i++)
{
- NETuint8_t(&ingame.pStructureLimits[i].id);
- NETuint8_t(&ingame.pStructureLimits[i].limit);
+ NETuint32_t(&ingame.pStructureLimits[i].id);
+ NETuint32_t(&ingame.pStructureLimits[i].limit);
}
NETuint8_t(&ingame.flags);
View
22 src/multiplay.h
@@ -31,7 +31,8 @@
// /////////////////////////////////////////////////////////////////////////////////////////////////
// Game Options Structure. Enough info to completely describe the static stuff in amultiplay game.
-typedef struct {
+struct MULTIPLAYERGAME
+{
uint8_t type; // DMATCH/CAMPAIGN/SKIRMISH/TEAMPLAY etc...
BOOL scavengers; // whether scavengers are on or off
char map[128]; // name of multiplayer map being used.
@@ -42,16 +43,17 @@ typedef struct {
uint8_t base; // clean/base/base&defence
uint8_t alliance; // no/yes/AIs vs Humans
uint8_t skDiff[MAX_PLAYERS]; // skirmish game difficulty settings. 0x0=OFF 0xff=HUMAN
-} MULTIPLAYERGAME;
+};
-typedef struct
+struct MULTISTRUCTLIMITS
{
- UBYTE id;
- UBYTE limit;
-} MULTISTRUCTLIMITS;
+ uint32_t id;
+ uint32_t limit;
+};
// info used inside games.
-typedef struct {
+struct MULTIPLAYERINGAME
+{
UDWORD PingTimes[MAX_PLAYERS]; // store for pings.
BOOL localOptionsReceived; // used to show if we have game options yet..
BOOL localJoiningInProgress; // used before we know our player number.
@@ -67,17 +69,17 @@ typedef struct {
uint8_t SPcolor; //
UDWORD skScores[MAX_PLAYERS][2]; // score+kills for local skirmish players.
char phrases[5][255]; // 5 favourite text messages.
-} MULTIPLAYERINGAME;
+};
-typedef enum
+enum STRUCTURE_INFO
{
STRUCTUREINFO_MANUFACTURE,
STRUCTUREINFO_CANCELPRODUCTION,
STRUCTUREINFO_HOLDPRODUCTION,
STRUCTUREINFO_RELEASEPRODUCTION,
STRUCTUREINFO_HOLDRESEARCH,
STRUCTUREINFO_RELEASERESEARCH
-} STRUCTURE_INFO;
+};
struct PACKAGED_CHECK
{
View
8 src/scriptfuncs.cpp
@@ -3005,9 +3005,9 @@ BOOL scrSetStructureLimits(void)
}
psStructLimits = asStructLimits[player];
- psStructLimits[structInc].limit = (UBYTE)limit;
+ psStructLimits[structInc].limit = limit;
- psStructLimits[structInc].globalLimit = (UBYTE)limit;
+ psStructLimits[structInc].globalLimit = limit;
return true;
}
@@ -4848,9 +4848,9 @@ BOOL scrSetAllStructureLimits(void)
psStructLimits = asStructLimits[player];
for (i = 0; i < numStructureStats; i++)
{
- psStructLimits[i].limit = (UBYTE)limit;
+ psStructLimits[i].limit = limit;
- psStructLimits[i].globalLimit = (UBYTE)limit;
+ psStructLimits[i].globalLimit = limit;
}
View
10 src/structuredef.h
@@ -285,15 +285,13 @@ struct STRUCTURE : public BASE_OBJECT
UDWORD lastStateTime;
};
-#define LOTS_OF 255 /*highest number the limit can be set to */
+#define LOTS_OF 0xFFFFFFFF // highest number the limit can be set to
struct STRUCTURE_LIMITS
{
- UBYTE limit; /* the number allowed to be built */
- UBYTE currentQuantity; /* the number of the type currently
- built per player*/
-
- UBYTE globalLimit; // multiplayer only. sets the max value selectable (limits changed by player)
+ uint32_t limit; // the number allowed to be built
+ uint32_t currentQuantity; // the number of the type currently built per player
+ uint32_t globalLimit; // multiplayer only. sets the max value selectable (limits changed by player)
};

0 comments on commit bea4607

Please sign in to comment.
Something went wrong with that request. Please try again.