summaryrefslogtreecommitdiff
path: root/src/game/g_maprotation.c
diff options
context:
space:
mode:
authorPaweł Redman <pawel@redman.xyz>2017-04-13 11:30:00 +0000
committer/dev/humancontroller <devhc@example.com>2017-04-15 12:06:43 +0200
commit5ad9e26c3be1f2ebc6cdb340b685aef30ae16db7 (patch)
tree5ee97c52196122bd8356ad8e09403332e7712fcd /src/game/g_maprotation.c
parent45973dc48641365b31475733bce7af9c3b8603a6 (diff)
import the cQVM game module
replacing the existing one
Diffstat (limited to 'src/game/g_maprotation.c')
-rw-r--r--src/game/g_maprotation.c171
1 files changed, 46 insertions, 125 deletions
diff --git a/src/game/g_maprotation.c b/src/game/g_maprotation.c
index 60fd696..eb76d70 100644
--- a/src/game/g_maprotation.c
+++ b/src/game/g_maprotation.c
@@ -334,68 +334,6 @@ static qboolean G_ParseMapRotation( mapRotation_t *mr, char **text_p )
continue;
}
- else if( !Q_stricmp( token, "*RANDOM*" ) )
- {
- if( mr->numMaps == MAX_MAP_ROTATION_MAPS )
- {
- G_Printf( S_COLOR_RED "ERROR: maximum number of maps in one rotation (%d) reached\n",
- MAX_MAP_ROTATION_MAPS );
- return qfalse;
- }
- mre = &mr->maps[ mr->numMaps ];
- Q_strncpyz( mre->name, token, sizeof( mre->name ) );
-
- token = COM_Parse( text_p );
-
- if( !Q_stricmp( token, "{" ) )
- {
- while( 1 )
- {
- token = COM_Parse( text_p );
-
- if( !token )
- break;
-
- if( !Q_stricmp( token, "}" ) )
- {
- break;
- }
- else
- {
- if( mre->numConditions < MAX_MAP_ROTATION_CONDS )
- {
- mrc = &mre->conditions[ mre->numConditions ];
- mrc->lhs = MCV_SELECTEDRANDOM;
- mrc->unconditional = qfalse;
- Q_strncpyz( mrc->dest, token, sizeof( mrc->dest ) );
-
- mre->numConditions++;
- }
- else
- {
- G_Printf( S_COLOR_YELLOW "WARNING: maximum number of maps for one Random Slot (%d) reached\n",
- MAX_MAP_ROTATION_CONDS );
- }
- }
- }
- if( !mre->numConditions )
- {
- G_Printf( S_COLOR_YELLOW "WARNING: no maps in *RANDOM* section\n" );
- }
- else
- {
- mr->numMaps++;
- mnSet = qtrue;
- }
- }
- else
- {
- G_Printf( S_COLOR_RED "ERROR: *RANDOM* with no section\n" );
- return qfalse;
- }
-
- continue;
- }
else if( !Q_stricmp( token, "}" ) )
return qtrue; //reached the end of this map rotation
@@ -526,7 +464,6 @@ static qboolean G_ParseMapRotationFile( const char *fileName )
for( j = 0; j < mapRotations.rotations[ i ].numMaps; j++ )
{
if( Q_stricmp( mapRotations.rotations[ i ].maps[ j ].name, "*VOTE*") != 0 &&
- Q_stricmp( mapRotations.rotations[ i ].maps[ j ].name, "*RANDOM*") != 0 &&
!G_MapExists( mapRotations.rotations[ i ].maps[ j ].name ) )
{
G_Printf( S_COLOR_RED "ERROR: map \"%s\" doesn't exist\n",
@@ -696,21 +633,6 @@ static void G_IssueMapChange( int rotation )
return;
}
}
- else if(!Q_stricmp( newmap, "*RANDOM*") )
- {
- fileHandle_t f;
-
- G_GetRandomMap( newmap, sizeof( newmap ), rotation, map );
- if( trap_FS_FOpenFile( va("maps/%s.bsp", newmap), &f, FS_READ ) > 0 )
- {
- trap_FS_FCloseFile( f );
- }
- else
- {
- G_AdvanceMapRotation();
- return;
- }
- }
// allow a manually defined g_layouts setting to override the maprotation
if( !g_layouts.string[ 0 ] &&
@@ -720,8 +642,7 @@ static void G_IssueMapChange( int rotation )
mapRotations.rotations[ rotation ].maps[ map ].layouts );
}
- trap_SendConsoleCommand( EXEC_APPEND, va( "map %s\n",
- newmap ) );
+ trap_SendConsoleCommand( EXEC_APPEND, va( "map %s\n", newmap ) );
// load up map defaults if g_mapConfigs is set
G_MapConfigs( newmap );
@@ -808,9 +729,6 @@ static qboolean G_EvaluateMapCondition( mapRotationCondition_t *mrc )
case MCV_VOTE:
// ignore vote for conditions;
break;
- case MCV_SELECTEDRANDOM:
- // ignore vote for conditions;
- break;
default:
case MCV_ERR:
@@ -940,6 +858,51 @@ qboolean G_MapRotationActive( void )
/*
===============
+G_CurrentMapIsRotation
+
+Test if the current map is from the rotation
+===============
+*/
+
+qboolean G_CurrentMapIsRotation( void )
+{
+ char mapname[ 64 ];
+ int map, rotation;
+ int i;
+
+ // Check for an active map rotation,
+ // only return false if rotation is running and current map is not from it
+ if ( !G_MapRotationActive() || g_currentMapRotation.integer == NOT_ROTATING )
+ return qtrue;
+
+ rotation = g_currentMapRotation.integer;
+ if( !( rotation >= 0 && rotation < mapRotations.numRotations ) )
+ return qtrue;
+
+ map = G_GetCurrentMap( rotation );
+ if( !(map >= 0 && map < mapRotations.rotations[ rotation ].numMaps ) )
+ return qtrue;
+
+ trap_Cvar_VariableStringBuffer( "mapname", mapname, sizeof( mapname ) );
+
+ if( !Q_stricmp( mapRotations.rotations[ rotation ].maps[ map ].name, mapname ) )
+ return qtrue;
+
+ if( !Q_stricmp( mapRotations.rotations[ rotation ].maps[ map ].name, "*VOTE*" ) )
+ {
+ for( i = 0; i < mapRotations.rotations[ rotation ].maps[ map ].numConditions; i++ )
+ {
+ if( mapRotations.rotations[ rotation ].maps[ map ].conditions[ i ].lhs == MCV_VOTE &&
+ !Q_stricmp( mapRotations.rotations[ rotation ].maps[ map ].conditions[ i ].dest, mapname ) )
+ return qtrue;
+ }
+ }
+
+ return qfalse;
+}
+
+/*
+===============
G_InitMapRotations
Load and intialise the map rotations
@@ -1173,9 +1136,6 @@ static void G_IntermissionMapVoteMessageReal( gentity_t *ent, int winner, int wi
"^7+------------------+\n", sizeof( string ) );
for( i = 0; i < rotationVoteLen; i++ )
{
- if( !G_MapExists( rotationVoteList[ i ] ) )
- continue;
-
if( i == selection )
color = "^5";
else if( i == index )
@@ -1275,42 +1235,3 @@ void G_IntermissionMapVoteCommand( gentity_t *ent, qboolean next, qboolean choos
G_IntermissionMapVoteMessage( ent );
}
-static qboolean G_GetRandomMap( char *name, int size, int rotation, int map )
-{
- mapRotation_t *mr;
- mapRotationEntry_t *mre;
- mapRotationCondition_t *mrc;
- int i, nummaps;
- int randompick = 0;
- int maplist[ 32 ];
-
- mr = &mapRotations.rotations[ rotation ];
- mre = &mr->maps[ map ];
-
- nummaps = 0;
- //count the number of map votes
- for( i = 0; i < mre->numConditions; i++ )
- {
- mrc = &mre->conditions[ i ];
-
- if( mrc->lhs == MCV_SELECTEDRANDOM )
- {
- //map doesnt exist
- if( !G_MapExists( mrc->dest ) ) {
- continue;
- }
- maplist[ nummaps ] = i;
- nummaps++;
- }
- }
-
- if( nummaps == 0 ) {
- return qfalse;
- }
-
- randompick = (int)( random() * nummaps );
-
- Q_strncpyz( name, mre->conditions[ maplist[ randompick ] ].dest, size );
-
- return qtrue;
-}