Skip to content

Commit

Permalink
Use more of MAX_PLAYERS in the code rather than plain numbers. Define…
Browse files Browse the repository at this point in the history
… MAX_PLAYERS for scripts. From patch by Cyp.
  • Loading branch information
perim committed Jan 5, 2011
1 parent 6a99f44 commit 7f5da6a
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 25 deletions.
1 change: 0 additions & 1 deletion data/base/multiplay/skirmish/ai.slo
Expand Up @@ -30,7 +30,6 @@
// Base threat range in world units
#define W_BASE_THREAT_RANGE ((17 + (mapWidth + mapHeight) / 2 / 35) * TILE)
#define ALL_ALLIES -1
#define MAX_PLAYERS 8

#define BASE_DEFEND_DURATION (3 * 60)
#define BASE_DEFEND_RADIUS (15 * TILE)
Expand Down
4 changes: 2 additions & 2 deletions data/base/multiplay/skirmish/rules.slo
Expand Up @@ -62,7 +62,7 @@ event initialisedEvent(CALL_GAMEINIT)
addReticuleButton(DESIGN);

playnum = 0;
while (playnum < 8)
while (playnum < MAX_PLAYERS)
{
enableStructure(command ,playnum); //make structures available to build
enableStructure(factory ,playnum);
Expand All @@ -86,7 +86,7 @@ event initialisedEvent(CALL_GAMEINIT)
event initialisedEventTwo(CALL_GAMEINIT)
{
playnum = 0;
while (playnum < 8)
while (playnum < MAX_PLAYERS)
{
count = 0;
while (count < numBaseRes)
Expand Down
1 change: 0 additions & 1 deletion data/mods/multiplay/dydo-ai/multiplay/skirmish/ai.slo
Expand Up @@ -101,7 +101,6 @@ Improve the way the units are gathered. dyDo should be abale to attack from vari
#define EVENT_CHECK_NUMBER 23

#define NUM_AI_PERSONALITIES 4
#define MAX_PLAYERS 8
#define TILE 128
#define MAX_DROIDS 150

Expand Down
1 change: 0 additions & 1 deletion data/mods/multiplay/semperfi/multiplay/skirmish/ai.slo
Expand Up @@ -30,7 +30,6 @@
// Base threat range in world units
#define W_BASE_THREAT_RANGE ((17 + (mapWidth + mapHeight) / 2 / 35) * TILE)
#define ALL_ALLIES -1
#define MAX_PLAYERS 8

#define BASE_DEFEND_DURATION (3 * 60)
#define BASE_DEFEND_RADIUS (15 * TILE)
Expand Down
2 changes: 1 addition & 1 deletion lib/netplay/netplay.h
Expand Up @@ -136,7 +136,7 @@ typedef enum

#define SESSION_JOINDISABLED 1

#define MAX_CONNECTED_PLAYERS 8
#define MAX_CONNECTED_PLAYERS MAX_PLAYERS
#define MAX_TMP_SOCKETS 16

typedef struct { //Available game storage... JUST FOR REFERENCE!
Expand Down
2 changes: 1 addition & 1 deletion src/mission.cpp
Expand Up @@ -638,7 +638,7 @@ void missionFlyTransportersIn( SDWORD iPlayer, BOOL bTrackTransporter )
UWORD iX, iY, iZ;
SDWORD iLandX, iLandY, iDx, iDy;

ASSERT_OR_RETURN(, iPlayer < 8, "Flying nonexistent player %d's transporters in", iPlayer);
ASSERT_OR_RETURN(, iPlayer < MAX_PLAYERS, "Flying nonexistent player %d's transporters in", iPlayer);

bTrackingTransporter = bTrackTransporter;

Expand Down
4 changes: 2 additions & 2 deletions src/mission.h
Expand Up @@ -34,8 +34,8 @@
* The number of areas that can be defined to prevent buildings being placed -
* used for Transporter Landing Zones 0-7 are for players, 8 = LIMBO_LANDING
*/
#define MAX_NOGO_AREAS 9
#define LIMBO_LANDING 8
#define MAX_NOGO_AREAS (MAX_PLAYERS + 1)
#define LIMBO_LANDING MAX_PLAYERS

/** Set by scrFlyInTransporter. True if were currenly tracking the transporter. */
extern BOOL bTrackingTransporter;
Expand Down
2 changes: 2 additions & 0 deletions src/scripttabs.cpp
Expand Up @@ -2004,6 +2004,8 @@ CONST_SYMBOL asConstantTable[] =

// multiplayer

{ "MAX_PLAYERS", VAL_INT, false, MAX_PLAYERS, NULL, NULL, 0.0f },

{ "CAMPAIGN", VAL_INT, false, CAMPAIGN, NULL, NULL, 0.0f },
{ "SKIRMISH", VAL_INT, false, SKIRMISH, NULL, NULL, 0.0f },

Expand Down
18 changes: 2 additions & 16 deletions src/structure.cpp
Expand Up @@ -2543,9 +2543,6 @@ static bool IsFactoryCommanderGroupFull(const FACTORY* psFactory)
// Disallow manufacture of units once these limits are reached,
// doesn't mean that these numbers can't be exceeded if units are
// put down in the editor or by the scripts.
static UWORD MaxDroidsAllowedPerPlayer[MAX_PLAYERS] = {100, 999, 999, 999, 999, 999, 999, 999};
// FIXME: We should have this variable user defined.
static UWORD MaxDroidsAllowedPerPlayerMultiPlayer[MAX_PLAYERS] = {450, 450, 450, 450, 450, 450, 450, 450};

BOOL IsPlayerStructureLimitReached(UDWORD PlayerNumber)
{
Expand All @@ -2556,7 +2553,7 @@ BOOL IsPlayerStructureLimitReached(UDWORD PlayerNumber)

UDWORD getMaxDroids(UDWORD PlayerNumber)
{
return (bMultiPlayer ? MaxDroidsAllowedPerPlayerMultiPlayer[PlayerNumber] : MaxDroidsAllowedPerPlayer[PlayerNumber] );
return bMultiPlayer? 450 : PlayerNumber == 0? 100 : 999;

}

Expand All @@ -2565,18 +2562,7 @@ BOOL IsPlayerDroidLimitReached(UDWORD PlayerNumber)
{
unsigned int numDroids = getNumDroids(PlayerNumber) + getNumMissionDroids(PlayerNumber) + getNumTransporterDroids(PlayerNumber);

if (bMultiPlayer)
{
if ( numDroids >= MaxDroidsAllowedPerPlayerMultiPlayer[PlayerNumber] )
return true;
}
else
{
if( numDroids >= MaxDroidsAllowedPerPlayer[PlayerNumber] )
return true;
}

return false;
return numDroids >= getMaxDroids(PlayerNumber);
}


Expand Down

0 comments on commit 7f5da6a

Please sign in to comment.