Restrict number of buildings that can be created from cheating and network
to building limits, and make sure they are sane also for lassat and satlink. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4534 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
ab1629285b
commit
0f012424c3
|
@ -1127,8 +1127,6 @@ BOOL droidStartBuild(DROID *psDroid)
|
|||
intBuildFinished(psDroid);
|
||||
return false;
|
||||
}
|
||||
//add one to current quantity for this player
|
||||
structLimit->currentQuantity++;
|
||||
|
||||
//commented out for demo - 2/1/98
|
||||
//ASSERT( droidNextToStruct(psDroid, (BASE_OBJECT *)psStruct),
|
||||
|
|
|
@ -2093,6 +2093,10 @@ INT_RETVAL intRunWidgets(void)
|
|||
{
|
||||
psStructure = buildStructure(psBuilding, structX, structY,
|
||||
selectedPlayer, false);
|
||||
if (!psStructure)
|
||||
{
|
||||
addConsoleMessage(_("Failed to create building"), LEFT_JUSTIFY, SYSTEM_MESSAGE);
|
||||
}
|
||||
/* NOTE: if this was a regular buildprocess we would
|
||||
* have to call sendBuildStarted(psStructure, <droid>);
|
||||
* In this case there is no droid working on the
|
||||
|
|
|
@ -195,7 +195,6 @@ BOOL recvBuildFinished()
|
|||
UDWORD type,typeindex;
|
||||
UBYTE player;
|
||||
|
||||
|
||||
NETbeginDecode(NET_BUILDFINISHED);
|
||||
NETuint32_t(&structId); // get the struct id.
|
||||
NETuint32_t(&type); // Kind of building.
|
||||
|
@ -244,8 +243,7 @@ BOOL recvBuildFinished()
|
|||
}
|
||||
}
|
||||
// Build the structure
|
||||
psStruct = buildStructure(&(asStructureStats[typeindex]), // Build the structure.
|
||||
x, y, player,true);
|
||||
psStruct = buildStructure(&(asStructureStats[typeindex]), x, y, player, true);
|
||||
|
||||
if (psStruct)
|
||||
{
|
||||
|
|
|
@ -845,12 +845,19 @@ void initStructLimits(void)
|
|||
for (player = 0; player < MAX_PLAYERS; player++)
|
||||
{
|
||||
STRUCTURE_LIMITS *psStructLimits = asStructLimits[player];
|
||||
STRUCTURE_STATS *psStat = asStructureStats;
|
||||
|
||||
for (i=0; i < numStructureStats; i++)
|
||||
for (i = 0; i < numStructureStats; i++)
|
||||
{
|
||||
psStructLimits[i].limit = LOTS_OF;
|
||||
psStructLimits[i].currentQuantity = 0;
|
||||
psStructLimits[i].globalLimit = LOTS_OF;
|
||||
if (isLasSat(psStat) || psStat->type == REF_SAT_UPLINK)
|
||||
{
|
||||
psStructLimits[i].limit = 1;
|
||||
psStructLimits[i].globalLimit = 1;
|
||||
}
|
||||
psStat++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1571,45 +1578,12 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
|
|||
ASSERT(!"invalid structure type", "buildStructure: Invalid structure type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (player == selectedPlayer)
|
||||
// Don't allow more than interface limits
|
||||
if (asStructLimits[player][max].currentQuantity + 1 > asStructLimits[player][max].limit)
|
||||
{
|
||||
//don't allow more than interface limits of certain structures
|
||||
if (pStructureType->type == REF_FACTORY ||
|
||||
pStructureType->type == REF_CYBORG_FACTORY ||
|
||||
pStructureType->type == REF_VTOL_FACTORY)
|
||||
{
|
||||
//NEVER EVER EVER WANT MORE THAN 5 FACTORIES
|
||||
if (asStructLimits[selectedPlayer][max].currentQuantity > MAX_FACTORY)
|
||||
{
|
||||
ASSERT(!"attempting to construct too many factories", "buildStructure: trying to build too many factories (%d max)", MAX_FACTORY);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (pStructureType->type == REF_RESEARCH)
|
||||
{
|
||||
//can only cope with MAX_OBJECTS research facilities
|
||||
if (asStructLimits[selectedPlayer][max].currentQuantity > MAX_OBJECTS)
|
||||
{
|
||||
ASSERT(!"attempting to construct too many research facilities", "buildStructure: trying to build too many research facilities (%d max)", MAX_OBJECTS);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
//HARD_CODE don't ever want more than one Las Sat structure
|
||||
if (isLasSat(pStructureType) && getLasSatExists(selectedPlayer))
|
||||
{
|
||||
ASSERT(!"attempting to build more than 1 Las Sat center", "buildStructure: trying to build too many Las Sat (1 max)");
|
||||
return NULL;
|
||||
}
|
||||
//HARD_CODE don't ever want more than one Sat Uplink structure
|
||||
if (pStructureType->type == REF_SAT_UPLINK)
|
||||
{
|
||||
if (asStructLimits[selectedPlayer][max].currentQuantity > 0)
|
||||
{
|
||||
ASSERT(!"attempting to build more than 1 Sat Uplink", "buildStructure: trying to build too many Sat Uplinks (1 max)");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
debug(LOG_ERROR, "Player %u: Building %s could not be built due to building limits!",
|
||||
player, pStructureType->pName);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// snap the coords to a tile
|
||||
|
@ -1929,6 +1903,7 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
|
|||
gridAddObject((BASE_OBJECT *)psBuilding);
|
||||
|
||||
clustNewStruct(psBuilding);
|
||||
asStructLimits[player][max].currentQuantity++;
|
||||
}
|
||||
else //its an upgrade
|
||||
{
|
||||
|
@ -4846,8 +4821,7 @@ BOOL removeStruct(STRUCTURE *psDel, BOOL bDestroy)
|
|||
}
|
||||
|
||||
//subtract one from the structLimits list so can build another - don't allow to go less than zero!
|
||||
if (asStructLimits[psDel->player][psDel->pStructureType - asStructureStats].
|
||||
currentQuantity)
|
||||
if (asStructLimits[psDel->player][psDel->pStructureType - asStructureStats].currentQuantity)
|
||||
{
|
||||
asStructLimits[psDel->player][psDel->pStructureType - asStructureStats].currentQuantity--;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue