diff options
author | Tim Angus <tim@ngus.net> | 2007-09-23 11:06:06 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2007-09-23 11:06:06 +0000 |
commit | 9aad6b35602637dc06f6c04fbd01664b6c1896bb (patch) | |
tree | 55d65e32dd92b9152e9ae7d7dc90d930a02b484f /src/game/g_maprotation.c | |
parent | a0d2fd3ce21bc91b5d715ee60e1df2a463168350 (diff) |
* Do a second pass when compiling map rotation scripts to catch incorrect map
and/or rotation names
Diffstat (limited to 'src/game/g_maprotation.c')
-rw-r--r-- | src/game/g_maprotation.c | 62 |
1 files changed, 47 insertions, 15 deletions
diff --git a/src/game/g_maprotation.c b/src/game/g_maprotation.c index b1972258..adc7793d 100644 --- a/src/game/g_maprotation.c +++ b/src/game/g_maprotation.c @@ -49,6 +49,26 @@ static qboolean G_MapExists( char *name ) /* =============== +G_RotationExists + +Check if a rotation exists +=============== +*/ +static qboolean G_RotationExists( char *name ) +{ + int i; + + for( i = 0; i < mapRotations.numRotations; i++ ) + { + if( Q_strncmp( mapRotations.rotations[ i ].name, name, MAX_QPATH ) == 0 ) + return qtrue; + } + + return qfalse; +} + +/* +=============== G_ParseCommandSection Parse a map rotation command section @@ -161,12 +181,6 @@ static qboolean G_ParseMapRotation( mapRotation_t *mr, char **text_p ) mrc = &mre->conditions[ mre->numConditions ]; mrc->unconditional = qtrue; - - if( !G_MapExists( token ) ) - { - G_Printf( S_COLOR_RED "ERROR: map \"%s\" doesn't exist\n", token ); - return qfalse; - } Q_strncpyz( mrc->dest, token, sizeof( mrc->dest ) ); if( mre->numConditions == MAX_MAP_ROTATION_CONDS ) @@ -277,12 +291,6 @@ static qboolean G_ParseMapRotation( mapRotation_t *mr, char **text_p ) else mr->numMaps++; - if( !G_MapExists( token ) ) - { - G_Printf( S_COLOR_RED "ERROR: map \"%s\" doesn't exist\n", token ); - return qfalse; - } - Q_strncpyz( mre->name, token, sizeof( mre->name ) ); mnSet = qtrue; } @@ -300,7 +308,7 @@ Load the map rotations from a map rotation file static qboolean G_ParseMapRotationFile( const char *fileName ) { char *text_p; - int i; + int i, j, k; int len; char *token; char text[ 20000 ]; @@ -392,6 +400,32 @@ static qboolean G_ParseMapRotationFile( const char *fileName ) } } + for( i = 0; i < mapRotations.numRotations; i++ ) + { + for( j = 0; j < mapRotations.rotations[ i ].numMaps; j++ ) + { + if( !G_MapExists( mapRotations.rotations[ i ].maps[ j ].name ) ) + { + G_Printf( S_COLOR_RED "ERROR: map \"%s\" doesn't exist\n", + mapRotations.rotations[ i ].maps[ j ].name ); + return qfalse; + } + + for( k = 0; k < mapRotations.rotations[ i ].maps[ j ].numConditions; k++ ) + { + if( !G_MapExists( mapRotations.rotations[ i ].maps[ j ].conditions[ k ].dest ) && + !G_RotationExists( mapRotations.rotations[ i ].maps[ j ].conditions[ k ].dest ) ) + { + G_Printf( S_COLOR_RED "ERROR: conditional destination \"%s\" doesn't exist\n", + mapRotations.rotations[ i ].maps[ j ].conditions[ k ].dest ); + return qfalse; + } + + } + + } + } + return qtrue; } @@ -575,8 +609,6 @@ static mapConditionType_t G_ResolveConditionDestination( int *n, char *name ) } } - //this should probably be prevented by a 2nd pass at compile time - //but i'm lazy (FIXME) return MCT_ERR; } |