diff options
author | Tim Angus <tim@ngus.net> | 2005-11-29 23:46:54 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2005-11-29 23:46:54 +0000 |
commit | 220e346d79355e818015a983f55a48190184a784 (patch) | |
tree | 270f6cde9f50785fbf665301f1703d836070afdc | |
parent | 046697c4b9369c02e730f1e16617e09876619864 (diff) |
* Lowered steptime for spectator
* Added worldspawn keys to disable specific game elements
-rw-r--r-- | entities.def | 4 | ||||
-rw-r--r-- | src/cgame/cg_draw.c | 3 | ||||
-rw-r--r-- | src/cgame/cg_view.c | 5 | ||||
-rw-r--r-- | src/game/bg_misc.c | 167 | ||||
-rw-r--r-- | src/game/bg_public.h | 5 | ||||
-rw-r--r-- | src/game/g_active.c | 2 | ||||
-rw-r--r-- | src/game/g_cmds.c | 40 | ||||
-rw-r--r-- | src/game/g_local.h | 9 | ||||
-rw-r--r-- | src/game/g_main.c | 115 | ||||
-rw-r--r-- | src/game/g_spawn.c | 31 | ||||
-rw-r--r-- | src/game/g_trigger.c | 123 | ||||
-rw-r--r-- | src/ui/ui_main.c | 201 |
12 files changed, 505 insertions, 200 deletions
diff --git a/entities.def b/entities.def index 87ed6127..5ba9daca 100644 --- a/entities.def +++ b/entities.def @@ -1621,6 +1621,10 @@ alienMaxStage: The highest stage the aliens are allowed to use [0/1/2]. Defaults alienStage2Threshold: The number of kills the aliens must aquire to advance to stage 2. Defaults to 50. alienStage3Threshold: The number of kills the aliens must aquire to advance to stage 3. Defaults to 100. +disabledEquipment: A comma delimited list of human weapons or upgrades to disable for this map. +disabledClasses: A comma delimited list of alien weapons to disable for this map. +disabledBuildables: A comma delimited list of buildables to disable for this map. + _ambient OR ambient: Adds a constant value to overall lighting. Use is not recommended. Ambient light will have a tendency to flatten out variations in light and shade. _color: RGB value for ambient light color (default is 0 0 0). diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 7fd6226d..104968a6 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -551,7 +551,8 @@ static qboolean CG_AtHighestClass( void ) if( BG_ClassCanEvolveFromTo( cg.predictedPlayerState.stats[ STAT_PCLASS ], i, ALIEN_MAX_KILLS, 0 ) >= 0 && - BG_FindStagesForClass( i, cgs.alienStage ) ) + BG_FindStagesForClass( i, cgs.alienStage ) + /*FIXME && G_ClassIsAllowed( i )*/ ) { superiorClasses = qtrue; break; diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c index 95c0de7b..5dc58e30 100644 --- a/src/cgame/cg_view.c +++ b/src/cgame/cg_view.c @@ -360,10 +360,7 @@ static void CG_StepOffset( void ) else VectorSet( normal, 0.0f, 0.0f, 1.0f ); - if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR ) - steptime = 200; - else - steptime = BG_FindSteptimeForClass( ps->stats[ STAT_PCLASS ] ); + steptime = BG_FindSteptimeForClass( ps->stats[ STAT_PCLASS ] ); // smooth out stair climbing timeDelta = cg.time - cg.stepTime; diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 579137fe..4fc2ffc0 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -1474,7 +1474,7 @@ classAttributes_t bg_classList[ ] = 90, //int fov; 0.000f, //float bob; 1.0f, //float bobCycle; - 350, //int steptime; + 0, //int steptime; 600, //float speed; 10.0f, //float acceleration; 1.0f, //float airAcceleration; @@ -5081,3 +5081,168 @@ int atoi_neg( char *token, qboolean allowNegative ) return value; } + +/* +=============== +BG_ParseCSVEquipmentList +=============== +*/ +void BG_ParseCSVEquipmentList( const char *string, weapon_t *weapons, int weaponsSize, + upgrade_t *upgrades, int upgradesSize ) +{ + char buffer[ MAX_STRING_CHARS ]; + int i = 0, j = 0; + char *p, *q; + qboolean EOS = qfalse; + + Q_strncpyz( buffer, string, MAX_STRING_CHARS ); + + p = q = buffer; + + while( *p != '\0' ) + { + //skip to first , or EOS + while( *p != ',' && *p != '\0' ) + p++; + + if( *p == '\0' ) + EOS = qtrue; + + *p = '\0'; + + //strip leading whitespace + while( *q == ' ' ) + q++; + + if( weaponsSize ) + weapons[ i ] = BG_FindWeaponNumForName( q ); + + if( upgradesSize ) + upgrades[ j ] = BG_FindUpgradeNumForName( q ); + + if( weaponsSize && weapons[ i ] == WP_NONE && + upgradesSize && upgrades[ j ] == UP_NONE ) + Com_Printf( S_COLOR_YELLOW "WARNING: unknown equipment %s\n", q ); + else if( weaponsSize && weapons[ i ] != WP_NONE ) + i++; + else if( upgradesSize && upgrades[ j ] != UP_NONE ) + j++; + + if( !EOS ) + { + p++; + q = p; + } + else + break; + + if( i == ( weaponsSize - 1 ) || j == ( upgradesSize - 1 ) ) + break; + } + + if( weaponsSize ) + weapons[ i ] = WP_NONE; + + if( upgradesSize ) + upgrades[ j ] = UP_NONE; +} + +/* +=============== +BG_ParseCSVClassList +=============== +*/ +void BG_ParseCSVClassList( const char *string, pClass_t *classes, int classesSize ) +{ + char buffer[ MAX_STRING_CHARS ]; + int i = 0; + char *p, *q; + qboolean EOS = qfalse; + + Q_strncpyz( buffer, string, MAX_STRING_CHARS ); + + p = q = buffer; + + while( *p != '\0' ) + { + //skip to first , or EOS + while( *p != ',' && *p != '\0' ) + p++; + + if( *p == '\0' ) + EOS = qtrue; + + *p = '\0'; + + //strip leading whitespace + while( *q == ' ' ) + q++; + + classes[ i ] = BG_FindClassNumForName( q ); + + if( classes[ i ] == PCL_NONE ) + Com_Printf( S_COLOR_YELLOW "WARNING: unknown class %s\n", q ); + else + i++; + + if( !EOS ) + { + p++; + q = p; + } + else + break; + } + + classes[ i ] = PCL_NONE; +} + +/* +=============== +BG_ParseCSVBuildableList +=============== +*/ +void BG_ParseCSVBuildableList( const char *string, buildable_t *buildables, int buildablesSize ) +{ + char buffer[ MAX_STRING_CHARS ]; + int i = 0; + char *p, *q; + qboolean EOS = qfalse; + + Q_strncpyz( buffer, string, MAX_STRING_CHARS ); + + p = q = buffer; + + while( *p != '\0' ) + { + //skip to first , or EOS + while( *p != ',' && *p != '\0' ) + p++; + + if( *p == '\0' ) + EOS = qtrue; + + *p = '\0'; + + //strip leading whitespace + while( *q == ' ' ) + q++; + + buildables[ i ] = BG_FindClassNumForName( q ); + + if( buildables[ i ] == BA_NONE ) + Com_Printf( S_COLOR_YELLOW "WARNING: unknown buildable %s\n", q ); + else + i++; + + if( !EOS ) + { + p++; + q = p; + } + else + break; + } + + buildables[ i ] = BA_NONE; +} diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 5cc157e4..25f5a90d 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -1291,3 +1291,8 @@ float round( float v ); float atof_neg( char *token, qboolean allowNegative ); int atoi_neg( char *token, qboolean allowNegative ); + +void BG_ParseCSVEquipmentList( const char *string, weapon_t *weapons, int weaponsSize, + upgrade_t *upgrades, int upgradesSize ); +void BG_ParseCSVClassList( const char *string, pClass_t *classes, int classesSize ); +void BG_ParseCSVBuildableList( const char *string, buildable_t *buildables, int buildablesSize ); diff --git a/src/game/g_active.c b/src/game/g_active.c index 846397db..54ae33e8 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -1322,7 +1322,7 @@ void ClientThink_real( gentity_t *ent ) { if( BG_ClassCanEvolveFromTo( client->ps.stats[ STAT_PCLASS ], j, client->ps.persistant[ PERS_CREDIT ], 0 ) >= 0 && - BG_FindStagesForClass( j, g_alienStage.integer ) ) + BG_FindStagesForClass( j, g_alienStage.integer ) && G_ClassIsAllowed( j ) ) { upgrade = qtrue; break; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 4491cd77..540bedd0 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1114,19 +1114,15 @@ void Cmd_Class_f( gentity_t *ent ) clientNum = ent->client - level.clients; trap_Argv( 1, s, sizeof( s ) ); - if( BG_FindStagesForClass( PCL_ALIEN_BUILDER0_UPG, g_alienStage.integer ) ) - { - allowedClasses[ 0 ] = PCL_ALIEN_BUILDER0; - allowedClasses[ 1 ] = PCL_ALIEN_BUILDER0_UPG; - allowedClasses[ 2 ] = PCL_ALIEN_LEVEL0; - numClasses = 3; - } - else - { - allowedClasses[ 0 ] = PCL_ALIEN_BUILDER0; - allowedClasses[ 1 ] = PCL_ALIEN_LEVEL0; - numClasses = 2; - } + if( G_ClassIsAllowed( PCL_ALIEN_BUILDER0 ) ) + allowedClasses[ numClasses++ ] = PCL_ALIEN_BUILDER0; + + if( G_ClassIsAllowed( PCL_ALIEN_BUILDER0_UPG ) && + BG_FindStagesForClass( PCL_ALIEN_BUILDER0_UPG, g_alienStage.integer ) ) + allowedClasses[ numClasses++ ] = PCL_ALIEN_BUILDER0; + + if( G_ClassIsAllowed( PCL_ALIEN_LEVEL0 ) ) + allowedClasses[ numClasses++ ] = PCL_ALIEN_LEVEL0; if( ent->client->pers.teamSelection == PTE_ALIENS && !( ent->client->ps.stats[ STAT_STATE ] & SS_INFESTING ) && @@ -1211,7 +1207,9 @@ void Cmd_Class_f( gentity_t *ent ) if( !tr.startsolid && tr2.fraction == 1.0f ) { //...check we can evolve to that class - if( numLevels >= 0 && BG_FindStagesForClass( ent->client->pers.classSelection, g_alienStage.integer ) ) + if( numLevels >= 0 && + BG_FindStagesForClass( ent->client->pers.classSelection, g_alienStage.integer ) && + G_ClassIsAllowed( ent->client->pers.classSelection ) ) { ent->client->pers.evolveHealthFraction = (float)ent->client->ps.stats[ STAT_HEALTH ] / (float)BG_FindHealthForClass( currentClass ); @@ -1255,7 +1253,8 @@ void Cmd_Class_f( gentity_t *ent ) for( i = 0; i < numClasses; i++ ) { if( allowedClasses[ i ] == ent->client->pers.classSelection && - BG_FindStagesForClass( ent->client->pers.classSelection, g_alienStage.integer ) ) + BG_FindStagesForClass( ent->client->pers.classSelection, g_alienStage.integer ) && + G_ClassIsAllowed( ent->client->pers.classSelection ) ) { G_PushSpawnQueue( &level.alienSpawnQueue, clientNum ); return; @@ -1285,11 +1284,11 @@ void Cmd_Class_f( gentity_t *ent ) ent->client->ps.stats[ STAT_PCLASS ] = PCL_HUMAN; //set the item to spawn with - if( !Q_stricmp( s, BG_FindNameForWeapon( WP_MACHINEGUN ) ) ) + if( !Q_stricmp( s, BG_FindNameForWeapon( WP_MACHINEGUN ) ) && G_WeaponIsAllowed( WP_MACHINEGUN ) ) ent->client->pers.humanItemSelection = WP_MACHINEGUN; - else if( !Q_stricmp( s, BG_FindNameForWeapon( WP_HBUILD ) ) ) + else if( !Q_stricmp( s, BG_FindNameForWeapon( WP_HBUILD ) ) && G_WeaponIsAllowed( WP_HBUILD ) ) ent->client->pers.humanItemSelection = WP_HBUILD; - else if( !Q_stricmp( s, BG_FindNameForWeapon( WP_HBUILD2 ) ) && + else if( !Q_stricmp( s, BG_FindNameForWeapon( WP_HBUILD2 ) ) && G_WeaponIsAllowed( WP_HBUILD2 ) && BG_FindStagesForWeapon( WP_HBUILD2, g_humanStage.integer ) ) ent->client->pers.humanItemSelection = WP_HBUILD2; else @@ -1563,7 +1562,7 @@ void Cmd_Buy_f( gentity_t *ent ) } //are we /allowed/ to buy this? - if( !BG_FindStagesForWeapon( weapon, g_humanStage.integer ) ) + if( !BG_FindStagesForWeapon( weapon, g_humanStage.integer ) || !G_WeaponIsAllowed( weapon ) ) { G_SendCommandFromServer( ent-g_entities, va( "print \"You can't buy this item\n\"" ) ); return; @@ -1626,7 +1625,7 @@ void Cmd_Buy_f( gentity_t *ent ) } //are we /allowed/ to buy this? - if( !BG_FindStagesForUpgrade( upgrade, g_humanStage.integer ) ) + if( !BG_FindStagesForUpgrade( upgrade, g_humanStage.integer ) || !G_UpgradeIsAllowed( upgrade ) ) { G_SendCommandFromServer( ent-g_entities, va( "print \"You can't buy this item\n\"" ) ); return; @@ -1838,6 +1837,7 @@ void Cmd_Build_f( gentity_t *ent ) ( ( 1 << ent->client->ps.weapon ) & BG_FindBuildWeaponForBuildable( buildable ) ) && !( ent->client->ps.stats[ STAT_STATE ] & SS_INFESTING ) && !( ent->client->ps.stats[ STAT_STATE ] & SS_HOVELING ) && + G_BuildableIsAllowed( buildable ) && ( ( team == PTE_ALIENS && BG_FindStagesForBuildable( buildable, g_alienStage.integer ) ) || ( team == PTE_HUMANS && BG_FindStagesForBuildable( buildable, g_humanStage.integer ) ) ) ) { diff --git a/src/game/g_local.h b/src/game/g_local.h index a7078ace..002d4cb5 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -877,6 +877,11 @@ void SendScoreboardMessageToAllClients( void ); void QDECL G_Printf( const char *fmt, ... ); void QDECL G_Error( const char *fmt, ... ); +qboolean G_WeaponIsAllowed( weapon_t weapon ); +qboolean G_UpgradeIsAllowed( upgrade_t upgrade ); +qboolean G_ClassIsAllowed( pClass_t class ); +qboolean G_BuildableIsAllowed( buildable_t buildable ); + // // g_client.c // @@ -1069,6 +1074,10 @@ extern vmCvar_t g_alienMaxStage; extern vmCvar_t g_alienStage2Threshold; extern vmCvar_t g_alienStage3Threshold; +extern vmCvar_t g_disabledEquipment; +extern vmCvar_t g_disabledClasses; +extern vmCvar_t g_disabledBuildables; + extern vmCvar_t g_debugMapRotation; extern vmCvar_t g_currentMapRotation; extern vmCvar_t g_currentMap; diff --git a/src/game/g_main.c b/src/game/g_main.c index 8ae93622..1afb6744 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -90,6 +90,10 @@ vmCvar_t g_alienMaxStage; vmCvar_t g_alienStage2Threshold; vmCvar_t g_alienStage3Threshold; +vmCvar_t g_disabledEquipment; +vmCvar_t g_disabledClasses; +vmCvar_t g_disabledBuildables; + vmCvar_t g_debugMapRotation; vmCvar_t g_currentMapRotation; vmCvar_t g_currentMap; @@ -174,6 +178,10 @@ static cvarTable_t gameCvarTable[ ] = { &g_alienStage2Threshold, "g_alienStage2Threshold", "20", 0, 0, qfalse }, { &g_alienStage3Threshold, "g_alienStage3Threshold", "40", 0, 0, qfalse }, + { &g_disabledEquipment, "g_disabledEquipment", "", CVAR_ROM, 0, qfalse }, + { &g_disabledClasses, "g_disabledClasses", "", CVAR_ROM, 0, qfalse }, + { &g_disabledBuildables, "g_disabledBuildables", "", CVAR_ROM, 0, qfalse }, + { &g_debugMapRotation, "g_debugMapRotation", "0", 0, 0, qfalse }, { &g_currentMapRotation, "g_currentMapRotation", "-1", 0, 0, qfalse }, // -1 = NOT_ROTATING { &g_currentMap, "g_currentMap", "0", 0, 0, qfalse }, @@ -446,6 +454,110 @@ static void G_GenerateParticleFileList( void ) } } +typedef struct gameElements_s +{ + buildable_t buildables[ BA_NUM_BUILDABLES ]; + pClass_t classes[ PCL_NUM_CLASSES ]; + weapon_t weapons[ WP_NUM_WEAPONS ]; + upgrade_t upgrades[ UP_NUM_UPGRADES ]; +} gameElements_t; + +static gameElements_t disabledGameElements; + +/* +============ +G_InitAllowedGameElements +============ +*/ +static void G_InitAllowedGameElements( void ) +{ + BG_ParseCSVEquipmentList( g_disabledEquipment.string, + disabledGameElements.weapons, WP_NUM_WEAPONS, + disabledGameElements.upgrades, UP_NUM_UPGRADES ); + + BG_ParseCSVClassList( g_disabledClasses.string, + disabledGameElements.classes, PCL_NUM_CLASSES ); + + BG_ParseCSVBuildableList( g_disabledBuildables.string, + disabledGameElements.buildables, BA_NUM_BUILDABLES ); +} + +/* +============ +G_WeaponIsAllowed +============ +*/ +qboolean G_WeaponIsAllowed( weapon_t weapon ) +{ + int i; + + for( i = 0; i < WP_NUM_WEAPONS && + disabledGameElements.weapons[ i ] != WP_NONE; i++ ) + { + if( disabledGameElements.weapons[ i ] == weapon ) + return qfalse; + } + + return qtrue; +} + +/* +============ +G_UpgradeIsAllowed +============ +*/ +qboolean G_UpgradeIsAllowed( upgrade_t upgrade ) +{ + int i; + + for( i = 0; i < UP_NUM_UPGRADES && + disabledGameElements.upgrades[ i ] != UP_NONE; i++ ) + { + if( disabledGameElements.upgrades[ i ] == upgrade ) + return qfalse; + } + + return qtrue; +} + +/* +============ +G_ClassIsAllowed +============ +*/ +qboolean G_ClassIsAllowed( pClass_t class ) +{ + int i; + + for( i = 0; i < PCL_NUM_CLASSES && + disabledGameElements.classes[ i ] != PCL_NONE; i++ ) + { + if( disabledGameElements.classes[ i ] == class ) + return qfalse; + } + + return qtrue; +} + +/* +============ +G_BuildableIsAllowed +============ +*/ +qboolean G_BuildableIsAllowed( buildable_t buildable ) +{ + int i; + + for( i = 0; i < BA_NUM_BUILDABLES && + disabledGameElements.buildables[ i ] != BA_NONE; i++ ) + { + if( disabledGameElements.buildables[ i ] == buildable ) + return qfalse; + } + + return qtrue; +} + /* ============ G_InitGame @@ -526,6 +638,9 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) // parse the key/value pairs and spawn gentities G_SpawnEntitiesFromString( ); + // the map might disable some things + G_InitAllowedGameElements( ); + // general initialization G_FindTeams( ); diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index 2c279757..39db22be 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -318,24 +318,14 @@ qboolean G_CallSpawn( gentity_t *ent ) //check buildable spawn functions if( ( buildable = BG_FindBuildNumForEntityName( ent->classname ) ) != BA_NONE ) { - /*if( BG_FindStagesForBuildable( buildable, 1 ) )*/ - if( qtrue ) + if( buildable == BA_A_SPAWN || buildable == BA_H_SPAWN ) { - if( buildable == BA_A_SPAWN || buildable == BA_H_SPAWN ) - { - ent->s.angles[ YAW ] += 180.0f; - AngleNormalize360( ent->s.angles[ YAW ] ); - } - - G_SpawnBuildable( ent, buildable ); - return qtrue; - } - else - { - G_Printf( S_COLOR_YELLOW "WARNING: %s not allowed in stage 1\n", - BG_FindHumanNameForBuildable( buildable ) ); - return qfalse; + ent->s.angles[ YAW ] += 180.0f; + AngleNormalize360( ent->s.angles[ YAW ] ); } + + G_SpawnBuildable( ent, buildable ); + return qtrue; } // check normal spawn functions @@ -647,6 +637,15 @@ void SP_worldspawn( void ) G_SpawnString( "enableBreath", "0", &s ); trap_Cvar_Set( "g_enableBreath", s ); + G_SpawnString( "disabledEquipment", "", &s ); + trap_Cvar_Set( "g_disabledEquipment", s ); + + G_SpawnString( "disabledClasses", "", &s ); + trap_Cvar_Set( "g_disabledClasses", s ); + + G_SpawnString( "disabledBuildables", "", &s ); + trap_Cvar_Set( "g_disabledBuildables", s ); + g_entities[ ENTITYNUM_WORLD ].s.number = ENTITYNUM_WORLD; g_entities[ ENTITYNUM_WORLD ].classname = "worldspawn"; diff --git a/src/game/g_trigger.c b/src/game/g_trigger.c index e928cc69..d92e44b4 100644 --- a/src/game/g_trigger.c +++ b/src/game/g_trigger.c @@ -617,10 +617,7 @@ SP_trigger_buildable */ void SP_trigger_buildable( gentity_t *self ) { - char *buffer; - int i = 0; - char *p, *q; - qboolean EOS = qfalse; + char *buffer; G_SpawnFloat( "wait", "0.5", &self->wait ); G_SpawnFloat( "random", "0", &self->random ); @@ -633,39 +630,7 @@ void SP_trigger_buildable( gentity_t *self ) G_SpawnString( "buildables", "", &buffer ); - p = q = buffer; - - while( *p != '\0' ) - { - //skip to first , or EOS - while( *p != ',' && *p != '\0' ) - p++; - - if( *p == '\0' ) - EOS = qtrue; - - *p = '\0'; - - //strip leading whitespace - while( *q == ' ' ) - q++; - - self->bTriggers[ i ] = BG_FindBuildNumForName( q ); - if( self->bTriggers[ i ] == BA_NONE ) - G_Printf( S_COLOR_YELLOW "WARNING: unknown buildable %s in trigger_buildable\n", q ); - else - i++; - - if( !EOS ) - { - p++; - q = p; - } - else - break; - } - - self->bTriggers[ i ] = BA_NONE; + BG_ParseCSVBuildableList( buffer, self->bTriggers, BA_NUM_BUILDABLES ); self->touch = trigger_buildable_touch; self->use = trigger_buildable_use; @@ -757,10 +722,7 @@ SP_trigger_class */ void SP_trigger_class( gentity_t *self ) { - char *buffer; - int i = 0; - char *p, *q; - qboolean EOS = qfalse; + char *buffer; G_SpawnFloat( "wait", "0.5", &self->wait ); G_SpawnFloat( "random", "0", &self->random ); @@ -773,39 +735,7 @@ void SP_trigger_class( gentity_t *self ) G_SpawnString( "classes", "", &buffer ); - p = q = buffer; - - while( *p != '\0' ) - { - //skip to first , or EOS - while( *p != ',' && *p != '\0' ) - p++; - - if( *p == '\0' ) - EOS = qtrue; - - *p = '\0'; - - //strip leading whitespace - while( *q == ' ' ) - q++; - - self->cTriggers[ i ] = BG_FindClassNumForName( q ); - if( self->cTriggers[ i ] == PCL_NONE ) - G_Printf( S_COLOR_YELLOW "WARNING: unknown class %s in trigger_class\n", q ); - else - i++; - - if( !EOS ) - { - p++; - q = p; - } - else - break; - } - - self->cTriggers[ i ] = PCL_NONE; + BG_ParseCSVClassList( buffer, self->cTriggers, PCL_NUM_CLASSES ); self->touch = trigger_class_touch; self->use = trigger_class_use; @@ -906,10 +836,7 @@ SP_trigger_equipment */ void SP_trigger_equipment( gentity_t *self ) { - char *buffer; - int i = 0, j = 0; - char *p, *q; - qboolean EOS = qfalse; + char *buffer; G_SpawnFloat( "wait", "0.5", &self->wait ); G_SpawnFloat( "random", "0", &self->random ); @@ -922,44 +849,8 @@ void SP_trigger_equipment( gentity_t *self ) G_SpawnString( "equipment", "", &buffer ); - p = q = buffer; - - while( *p != '\0' ) - { - //skip to first , or EOS - while( *p != ',' && *p != '\0' ) - p++; - - if( *p == '\0' ) - EOS = qtrue; - - *p = '\0'; - - //strip leading whitespace - while( *q == ' ' ) - q++; - - self->wTriggers[ i ] = BG_FindWeaponNumForName( q ); - self->uTriggers[ j ] = BG_FindUpgradeNumForName( q ); - - if( self->wTriggers[ i ] == WP_NONE && self->uTriggers[ j ] == UP_NONE ) - G_Printf( S_COLOR_YELLOW "WARNING: unknown equipment %s in trigger_class\n", q ); - else if( self->wTriggers[ i ] != WP_NONE ) - i++; - else if( self->uTriggers[ j ] != UP_NONE ) - j++; - - if( !EOS ) - { - p++; - q = p; - } - else - break; - } - - self->wTriggers[ i ] = WP_NONE; - self->uTriggers[ j ] = UP_NONE; + BG_ParseCSVEquipmentList( buffer, self->wTriggers, WP_NUM_WEAPONS, + self->uTriggers, UP_NUM_UPGRADES ); self->touch = trigger_equipment_touch; self->use = trigger_equipment_use; diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index 85b3fdb9..19f9bb73 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -3186,34 +3186,160 @@ static void UI_LoadTremTeams( void ) } /* +============ +UI_WeaponIsAllowed +============ +*/ +qboolean UI_WeaponIsAllowed( weapon_t weapon ) +{ + int i; + weapon_t weapons[ WP_NUM_WEAPONS ]; + char cvar[ MAX_CVAR_VALUE_STRING ]; + + trap_Cvar_VariableStringBuffer( "g_disabledEquipment", + cvar, MAX_CVAR_VALUE_STRING ); + + BG_ParseCSVEquipmentList( cvar, weapons, WP_NUM_WEAPONS, NULL, 0 ); + + for( i = 0; i < WP_NUM_WEAPONS && + weapons[ i ] != WP_NONE; i++ ) + { + if( weapons[ i ] == weapon ) + return qfalse; + } + + return qtrue; +} + +/* +============ +UI_UpgradeIsAllowed +============ +*/ +qboolean UI_UpgradeIsAllowed( upgrade_t upgrade ) +{ + int i; + upgrade_t upgrades[ UP_NUM_UPGRADES ]; + char cvar[ MAX_CVAR_VALUE_STRING ]; + + trap_Cvar_VariableStringBuffer( "g_disabledEquipment", + cvar, MAX_CVAR_VALUE_STRING ); + + BG_ParseCSVEquipmentList( cvar, NULL, 0, upgrades, UP_NUM_UPGRADES ); + + for( i = 0; i < UP_NUM_UPGRADES && + upgrades[ i ] != UP_NONE; i++ ) + { + if( upgrades[ i ] == upgrade ) + return qfalse; + } + + return qtrue; +} + +/* +============ +UI_ClassIsAllowed +============ +*/ +qboolean UI_ClassIsAllowed( pClass_t class ) +{ + int i; + pClass_t classes[ PCL_NUM_CLASSES ]; + char cvar[ MAX_CVAR_VALUE_STRING ]; + + trap_Cvar_VariableStringBuffer( "g_disabledClasses", + cvar, MAX_CVAR_VALUE_STRING ); + + BG_ParseCSVClassList( cvar, classes, PCL_NUM_CLASSES ); + + for( i = 0; i < PCL_NUM_CLASSES && + classes[ i ] != PCL_NONE; i++ ) + { + if( classes[ i ] == class ) + return qfalse; + } + + return qtrue; +} + +/* +============ +UI_BuildableIsAllowed +============ +*/ +qboolean UI_BuildableIsAllowed( buildable_t buildable ) +{ + int i; + buildable_t buildables[ BA_NUM_BUILDABLES ]; + char cvar[ MAX_CVAR_VALUE_STRING ]; + + trap_Cvar_VariableStringBuffer( "g_disabledBuildables", + cvar, MAX_CVAR_VALUE_STRING ); + + BG_ParseCSVBuildableList( cvar, buildables, BA_NUM_BUILDABLES ); + + for( i = 0; i < BA_NUM_BUILDABLES && + buildables[ i ] != BA_NONE; i++ ) + { + if( buildables[ i ] == buildable ) + return qfalse; + } + + return qtrue; +} + +/* +=============== +UI_AddClass +=============== +*/ +static void UI_AddClass( pClass_t class ) +{ + uiInfo.tremAlienClassList[ uiInfo.tremAlienClassCount ].text = + String_Alloc( BG_FindHumanNameForClassNum( class ) ); + uiInfo.tremAlienClassList[ uiInfo.tremAlienClassCount ].cmd = + String_Alloc( va( "cmd class %s\n", BG_FindNameForClassNum( class ) ) ); + uiInfo.tremAlienClassList[ uiInfo.tremAlienClassCount ].infopane = + UI_FindInfoPaneByName( va( "%sclass", BG_FindNameForClassNum( class ) ) ); + + uiInfo.tremAlienClassCount++; +} + +/* =============== UI_LoadTremAlienClasses =============== */ static void UI_LoadTremAlienClasses( void ) { - pClass_t bClass; + uiInfo.tremAlienClassCount = 0; - uiInfo.tremAlienClassCount = 2; + if( UI_ClassIsAllowed( PCL_ALIEN_LEVEL0 ) ) + UI_AddClass( PCL_ALIEN_LEVEL0 ); - uiInfo.tremAlienClassList[ 0 ].text = - String_Alloc( BG_FindHumanNameForClassNum( PCL_ALIEN_LEVEL0 ) ); - uiInfo.tremAlienClassList[ 0 ].cmd = - String_Alloc( va( "cmd class %s\n", BG_FindNameForClassNum( PCL_ALIEN_LEVEL0 ) ) ); - uiInfo.tremAlienClassList[ 0 ].infopane = - UI_FindInfoPaneByName( va( "%sclass", BG_FindNameForClassNum( PCL_ALIEN_LEVEL0 ) ) ); + if( UI_ClassIsAllowed( PCL_ALIEN_BUILDER0_UPG ) && + BG_FindStagesForClass( PCL_ALIEN_BUILDER0_UPG, UI_GetCurrentAlienStage( ) ) ) + UI_AddClass( PCL_ALIEN_BUILDER0_UPG ); + else if( UI_ClassIsAllowed( PCL_ALIEN_BUILDER0 ) ) + UI_AddClass( PCL_ALIEN_BUILDER0 ); +} - if( BG_FindStagesForClass( PCL_ALIEN_BUILDER0_UPG, UI_GetCurrentAlienStage( ) ) ) - bClass = PCL_ALIEN_BUILDER0_UPG; - else - bClass = PCL_ALIEN_BUILDER0; +/* +=============== +UI_AddItem +=============== +*/ +static void UI_AddItem( weapon_t weapon ) +{ + uiInfo.tremHumanItemList[ uiInfo.tremHumanItemCount ].text = + String_Alloc( BG_FindHumanNameForWeapon( weapon ) ); + uiInfo.tremHumanItemList[ uiInfo.tremHumanItemCount ].cmd = + String_Alloc( va( "cmd class %s\n", BG_FindNameForWeapon( weapon ) ) ); + uiInfo.tremHumanItemList[ uiInfo.tremHumanItemCount ].infopane = + UI_FindInfoPaneByName( va( "%sitem", BG_FindNameForWeapon( weapon ) ) ); - uiInfo.tremAlienClassList[ 1 ].text = - String_Alloc( BG_FindHumanNameForClassNum( bClass ) ); - uiInfo.tremAlienClassList[ 1 ].cmd = - String_Alloc( va( "cmd class %s\n", BG_FindNameForClassNum( bClass ) ) ); - uiInfo.tremAlienClassList[ 1 ].infopane = - UI_FindInfoPaneByName( va( "%sclass", BG_FindNameForClassNum( bClass ) ) ); + uiInfo.tremHumanItemCount++; } /* @@ -3223,28 +3349,16 @@ UI_LoadTremHumanItems */ static void UI_LoadTremHumanItems( void ) { - weapon_t bWeapon; - - uiInfo.tremHumanItemCount = 2; + uiInfo.tremHumanItemCount = 0; - uiInfo.tremHumanItemList[ 0 ].text = - String_Alloc( BG_FindHumanNameForWeapon( WP_MACHINEGUN ) ); - uiInfo.tremHumanItemList[ 0 ].cmd = - String_Alloc( va( "cmd class %s\n", BG_FindNameForWeapon( WP_MACHINEGUN ) ) ); - uiInfo.tremHumanItemList[ 0 ].infopane = - UI_FindInfoPaneByName( va( "%sitem", BG_FindNameForWeapon( WP_MACHINEGUN ) ) ); - - if( BG_FindStagesForWeapon( WP_HBUILD2, UI_GetCurrentHumanStage( ) ) ) - bWeapon = WP_HBUILD2; - else - bWeapon = WP_HBUILD; + if( UI_WeaponIsAllowed( WP_MACHINEGUN ) ) + UI_AddItem( WP_MACHINEGUN ); - uiInfo.tremHumanItemList[ 1 ].text = - String_Alloc( BG_FindHumanNameForWeapon( bWeapon ) ); - uiInfo.tremHumanItemList[ 1 ].cmd = - String_Alloc( va( "cmd class %s\n", BG_FindNameForWeapon( bWeapon ) ) ); - uiInfo.tremHumanItemList[ 1 ].infopane = - UI_FindInfoPaneByName( va( "%sitem", BG_FindNameForWeapon( bWeapon ) ) ); + if( UI_WeaponIsAllowed( WP_HBUILD2 ) && + BG_FindStagesForWeapon( WP_HBUILD2, UI_GetCurrentHumanStage( ) ) ) + UI_AddItem( WP_HBUILD2 ); + else if( UI_WeaponIsAllowed( WP_HBUILD ) ) + UI_AddItem( WP_HBUILD ); } /* @@ -3340,6 +3454,7 @@ static void UI_LoadTremHumanArmouryBuys( ) if( BG_FindTeamForWeapon( i ) == WUT_HUMANS && BG_FindPurchasableForWeapon( i ) && BG_FindStagesForWeapon( i, stage ) && + UI_WeaponIsAllowed( i ) && !( BG_FindSlotsForWeapon( i ) & slots ) && !( weapons & ( 1 << i ) ) ) { @@ -3361,6 +3476,7 @@ static void UI_LoadTremHumanArmouryBuys( ) if( BG_FindTeamForUpgrade( i ) == WUT_HUMANS && BG_FindPurchasableForUpgrade( i ) && BG_FindStagesForUpgrade( i, stage ) && + UI_UpgradeIsAllowed( i ) && !( BG_FindSlotsForUpgrade( i ) & slots ) && !( upgrades & ( 1 << i ) ) ) { @@ -3444,7 +3560,8 @@ static void UI_LoadTremAlienUpgrades( ) for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) { if( BG_ClassCanEvolveFromTo( class, i, credits, 0 ) >= 0 && - BG_FindStagesForClass( i, stage ) ) + BG_FindStagesForClass( i, stage ) && + UI_ClassIsAllowed( i ) ) { uiInfo.tremAlienUpgradeList[ j ].text = String_Alloc( BG_FindHumanNameForClassNum( i ) ); uiInfo.tremAlienUpgradeList[ j ].cmd = @@ -3479,7 +3596,8 @@ static void UI_LoadTremAlienBuilds( ) { if( BG_FindTeamForBuildable( i ) == BIT_ALIENS && BG_FindBuildWeaponForBuildable( i ) & weapons && - BG_FindStagesForBuildable( i, stage ) ) + BG_FindStagesForBuildable( i, stage ) && + UI_BuildableIsAllowed( i ) ) { uiInfo.tremAlienBuildList[ j ].text = String_Alloc( BG_FindHumanNameForBuildable( i ) ); @@ -3515,7 +3633,8 @@ static void UI_LoadTremHumanBuilds( ) { if( BG_FindTeamForBuildable( i ) == BIT_HUMANS && BG_FindBuildWeaponForBuildable( i ) & weapons && - BG_FindStagesForBuildable( i, stage ) ) + BG_FindStagesForBuildable( i, stage ) && + UI_BuildableIsAllowed( i ) ) { uiInfo.tremHumanBuildList[ j ].text = String_Alloc( BG_FindHumanNameForBuildable( i ) ); |