* Remove macro TERRAIN_TYPES which was just an alias for TER_MAX (and replace all instances of it with TER_MAX)

* Move some variables into a more local scope


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4918 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-05-04 15:12:37 +00:00
parent 7b12081033
commit fd9b608a6c
3 changed files with 12 additions and 14 deletions

View File

@ -9536,7 +9536,7 @@ BOOL loadTerrainTypeMap(const char *pFileData, UDWORD filesize)
return false;
}
if (*pType > TERRAIN_TYPES)
if (*pType > TER_MAX)
{
debug( LOG_ERROR, "loadTerrainTypeMap: terrain type out of range" );
abort();

View File

@ -46,9 +46,6 @@ typedef enum _terrain_type
TER_MAX,
} TYPE_OF_TERRAIN;
/* change these if you change above - maybe wrap up in enumerate? */
#define TERRAIN_TYPES TER_MAX
#define TALLOBJECT_YMAX (200)
#define TALLOBJECT_ADJUST (300)

View File

@ -1684,12 +1684,11 @@ BOOL loadPropulsionTypes(const char *pPropTypeData, UDWORD bufferSize)
BOOL loadTerrainTable(const char *pTerrainTableData, UDWORD bufferSize)
{
const unsigned int NumEntries = numCR(pTerrainTableData, bufferSize);
TERRAIN_TABLE *pTerrainTable;
unsigned int i = 0, j = 0;
unsigned int i;
UDWORD terrainType, propulsionType, speedFactor;
//allocate storage for the stats
asTerrainTable = (TERRAIN_TABLE *)malloc(sizeof(TERRAIN_TABLE) * NUM_PROP_TYPES * TERRAIN_TYPES);
asTerrainTable = (TERRAIN_TABLE *)malloc(sizeof(*asTerrainTable) * NUM_PROP_TYPES * TER_MAX);
if (asTerrainTable == NULL)
{
@ -1699,16 +1698,17 @@ BOOL loadTerrainTable(const char *pTerrainTableData, UDWORD bufferSize)
}
//initialise the storage to 100
for (i=0; i < TERRAIN_TYPES; i++)
for (i = 0; i < TER_MAX; ++i)
{
for (j=0; j < NUM_PROP_TYPES; j++)
unsigned int j;
for (j = 0; j < NUM_PROP_TYPES; j++)
{
pTerrainTable = asTerrainTable + (i * NUM_PROP_TYPES + j);
TERRAIN_TABLE * const pTerrainTable = &asTerrainTable[i * NUM_PROP_TYPES + j];
pTerrainTable->speedFactor = 100;
}
}
for (i=0; i < NumEntries; i++)
for (i = 0; i < NumEntries; ++i)
{
//read the data into the storage - the data is delimeted using comma's
sscanf(pTerrainTableData,"%d,%d,%d",
@ -1721,11 +1721,12 @@ BOOL loadTerrainTable(const char *pTerrainTableData, UDWORD bufferSize)
//check that none of the entries are 0 otherwise this will stop a droid dead in its tracks
//and it will not be able to move again!
for (i=0; i < TERRAIN_TYPES; i++)
for (i = 0; i < TER_MAX; ++i)
{
for (j=0; j < NUM_PROP_TYPES; j++)
unsigned int j;
for (j = 0; j < NUM_PROP_TYPES; ++j)
{
pTerrainTable = asTerrainTable + (i * NUM_PROP_TYPES + j);
TERRAIN_TABLE * const pTerrainTable = asTerrainTable + (i * NUM_PROP_TYPES + j);
if (pTerrainTable->speedFactor == 0)
{
debug( LOG_ERROR, "loadTerrainTable: Invalid propulsion/terrain table entry" );