diff options
Diffstat (limited to 'src/game/bg_misc.c')
-rw-r--r-- | src/game/bg_misc.c | 2234 |
1 files changed, 646 insertions, 1588 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 90c2254..fa5c1c6 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -37,6 +37,9 @@ modExtremeType_t modEntry[ MOD_BG_COUNT ]; buildableAttributes_t bg_buildableList[ ] = { { + BA_NONE, + }, + { BA_A_SPAWN, //int buildNum; "eggpod", //char *buildName; "Egg", //char *humanName; @@ -74,66 +77,66 @@ buildableAttributes_t bg_buildableList[ ] = qfalse, //qboolean replacable; }, { - BA_A_BARRICADE, //int buildNum; - "barricade", //char *buildName; - "Barricade", //char *humanName; - "team_alien_barricade",//char *entityName; - { "models/buildables/barricade/barricade.md3", 0, 0, 0 }, + BA_A_OVERMIND, //int buildNum; + "overmind", //char *buildName; + "Overmind", //char *humanName; + "team_alien_overmind", //char *entityName; + { "models/buildables/overmind/overmind.md3", 0, 0, 0 }, 1.0f, //float modelScale; - { -35, -35, -15 }, //vec3_t mins; - { 35, 35, 60 }, //vec3_t maxs; + { -45, -45, -15 }, //vec3_t mins; + { 45, 45, 95 }, //vec3_t maxs; 0.0f, //float zOffset; TR_GRAVITY, //trType_t traj; 0.0, //float bounce; - BARRICADE_BP, //int buildPoints; + OVERMIND_BP, //int buildPoints; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages - BARRICADE_HEALTH, //int health; - BARRICADE_REGEN, //int regenRate; - BARRICADE_SPLASHDAMAGE,//int splashDamage; - BARRICADE_SPLASHRADIUS,//int splashRadius; + OVERMIND_HEALTH, //int health; + OVERMIND_REGEN, //int regenRate; + OVERMIND_SPLASHDAMAGE, //int splashDamage; + OVERMIND_SPLASHRADIUS, //int splashRadius; MOD_ASPAWN, //int meansOfDeath; BIT_ALIENS, //int team; ( 1 << WP_ABUILD )|( 1 << WP_ABUILD2 ), //weapon_t buildWeapon; BANIM_IDLE1, //int idleAnim; - 100, //int nextthink; - BARRICADE_BT, //int buildTime; + OVERMIND_ATTACK_REPEAT,//int nextthink; + OVERMIND_BT, //int buildTime; qfalse, //qboolean usable; 0, //int turretRange; 0, //int turretFireSpeed; WP_NONE, //weapon_t turretProjType; - 0.707f, //float minNormal; + 0.95f, //float minNormal; qfalse, //qboolean invertNormal; - qtrue, //qboolean creepTest; - BARRICADE_CREEPSIZE, //int creepSize; + qfalse, //qboolean creepTest; + OVERMIND_CREEPSIZE, //int creepSize; qfalse, //qboolean dccTest; qfalse, //qboolean transparentTest; - qfalse, //qboolean reactorTest; - qfalse, //qboolean replaceable; + qtrue, //qboolean reactorTest; + qtrue, //qboolean replacable; }, { - BA_A_BOOSTER, //int buildNum; - "booster", //char *buildName; - "Booster", //char *humanName; - "team_alien_booster", //char *entityName; - { "models/buildables/booster/booster.md3", 0, 0, 0 }, + BA_A_BARRICADE, //int buildNum; + "barricade", //char *buildName; + "Barricade", //char *humanName; + "team_alien_barricade",//char *entityName; + { "models/buildables/barricade/barricade.md3", 0, 0, 0 }, 1.0f, //float modelScale; - { -26, -26, -9 }, //vec3_t mins; - { 26, 26, 9 }, //vec3_t maxs; + { -35, -35, -15 }, //vec3_t mins; + { 35, 35, 60 }, //vec3_t maxs; 0.0f, //float zOffset; TR_GRAVITY, //trType_t traj; 0.0, //float bounce; - BOOSTER_BP, //int buildPoints; - ( 1 << S2 )|( 1 << S3 ), //int stages - BOOSTER_HEALTH, //int health; - BOOSTER_REGEN, //int regenRate; - BOOSTER_SPLASHDAMAGE, //int splashDamage; - BOOSTER_SPLASHRADIUS, //int splashRadius; + BARRICADE_BP, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages + BARRICADE_HEALTH, //int health; + BARRICADE_REGEN, //int regenRate; + BARRICADE_SPLASHDAMAGE,//int splashDamage; + BARRICADE_SPLASHRADIUS,//int splashRadius; MOD_ASPAWN, //int meansOfDeath; BIT_ALIENS, //int team; ( 1 << WP_ABUILD )|( 1 << WP_ABUILD2 ), //weapon_t buildWeapon; BANIM_IDLE1, //int idleAnim; 100, //int nextthink; - BOOSTER_BT, //int buildTime; + BARRICADE_BT, //int buildTime; qfalse, //qboolean usable; 0, //int turretRange; 0, //int turretFireSpeed; @@ -141,11 +144,11 @@ buildableAttributes_t bg_buildableList[ ] = 0.707f, //float minNormal; qfalse, //qboolean invertNormal; qtrue, //qboolean creepTest; - BOOSTER_CREEPSIZE, //int creepSize; + BARRICADE_CREEPSIZE, //int creepSize; qfalse, //qboolean dccTest; - qtrue, //qboolean transparentTest; + qfalse, //qboolean transparentTest; qfalse, //qboolean reactorTest; - qtrue, //qboolean replacable; + qfalse, //qboolean replaceable; }, { BA_A_ACIDTUBE, //int buildNum; @@ -185,43 +188,6 @@ buildableAttributes_t bg_buildableList[ ] = qfalse, //qboolean replacable; }, { - BA_A_HIVE, //int buildNum; - "hive", //char *buildName; - "Hive", //char *humanName; - "team_alien_hive", //char *entityName; - { "models/buildables/hive/hive.md3", 0, 0, 0 }, - 1.0f, //float modelScale; - { -35, -35, -25 }, //vec3_t mins; - { 35, 35, 25 }, //vec3_t maxs; - 0.0f, //float zOffset; - TR_GRAVITY, //trType_t traj; - 0.0, //float bounce; - HIVE_BP, //int buildPoints; - ( 1 << S3 ), //int stages - HIVE_HEALTH, //int health; - HIVE_REGEN, //int regenRate; - HIVE_SPLASHDAMAGE, //int splashDamage; - HIVE_SPLASHRADIUS, //int splashRadius; - MOD_ASPAWN, //int meansOfDeath; - BIT_ALIENS, //int team; - ( 1 << WP_ABUILD )|( 1 << WP_ABUILD2 ), //weapon_t buildWeapon; - BANIM_IDLE1, //int idleAnim; - 500, //int nextthink; - HIVE_BT, //int buildTime; - qfalse, //qboolean usable; - 0, //int turretRange; - 0, //int turretFireSpeed; - WP_HIVE, //weapon_t turretProjType; - 0.0f, //float minNormal; - qtrue, //qboolean invertNormal; - qtrue, //qboolean creepTest; - HIVE_CREEPSIZE, //int creepSize; - qfalse, //qboolean dccTest; - qfalse, //qboolean transparentTest; - qfalse, //qboolean reactorTest; - qfalse, //qboolean replacable; - }, - { BA_A_TRAPPER, //int buildNum; "trapper", //char *buildName; "Trapper", //char *humanName; @@ -259,43 +225,80 @@ buildableAttributes_t bg_buildableList[ ] = qfalse, //qboolean replacable; }, { - BA_A_OVERMIND, //int buildNum; - "overmind", //char *buildName; - "Overmind", //char *humanName; - "team_alien_overmind", //char *entityName; - { "models/buildables/overmind/overmind.md3", 0, 0, 0 }, + BA_A_BOOSTER, //int buildNum; + "booster", //char *buildName; + "Booster", //char *humanName; + "team_alien_booster", //char *entityName; + { "models/buildables/booster/booster.md3", 0, 0, 0 }, 1.0f, //float modelScale; - { -45, -45, -15 }, //vec3_t mins; - { 45, 45, 95 }, //vec3_t maxs; + { -26, -26, -9 }, //vec3_t mins; + { 26, 26, 9 }, //vec3_t maxs; 0.0f, //float zOffset; TR_GRAVITY, //trType_t traj; 0.0, //float bounce; - OVERMIND_BP, //int buildPoints; - ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages - OVERMIND_HEALTH, //int health; - OVERMIND_REGEN, //int regenRate; - OVERMIND_SPLASHDAMAGE, //int splashDamage; - OVERMIND_SPLASHRADIUS, //int splashRadius; + BOOSTER_BP, //int buildPoints; + ( 1 << S2 )|( 1 << S3 ), //int stages + BOOSTER_HEALTH, //int health; + BOOSTER_REGEN, //int regenRate; + BOOSTER_SPLASHDAMAGE, //int splashDamage; + BOOSTER_SPLASHRADIUS, //int splashRadius; MOD_ASPAWN, //int meansOfDeath; BIT_ALIENS, //int team; ( 1 << WP_ABUILD )|( 1 << WP_ABUILD2 ), //weapon_t buildWeapon; BANIM_IDLE1, //int idleAnim; - OVERMIND_ATTACK_REPEAT,//int nextthink; - OVERMIND_BT, //int buildTime; + 100, //int nextthink; + BOOSTER_BT, //int buildTime; qfalse, //qboolean usable; 0, //int turretRange; 0, //int turretFireSpeed; WP_NONE, //weapon_t turretProjType; - 0.95f, //float minNormal; + 0.707f, //float minNormal; qfalse, //qboolean invertNormal; - qfalse, //qboolean creepTest; - OVERMIND_CREEPSIZE, //int creepSize; + qtrue, //qboolean creepTest; + BOOSTER_CREEPSIZE, //int creepSize; qfalse, //qboolean dccTest; - qfalse, //qboolean transparentTest; - qtrue, //qboolean reactorTest; + qtrue, //qboolean transparentTest; + qfalse, //qboolean reactorTest; qtrue, //qboolean replacable; }, { + BA_A_HIVE, //int buildNum; + "hive", //char *buildName; + "Hive", //char *humanName; + "team_alien_hive", //char *entityName; + { "models/buildables/hive/hive.md3", 0, 0, 0 }, + 1.0f, //float modelScale; + { -35, -35, -25 }, //vec3_t mins; + { 35, 35, 25 }, //vec3_t maxs; + 0.0f, //float zOffset; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; + HIVE_BP, //int buildPoints; + ( 1 << S3 ), //int stages + HIVE_HEALTH, //int health; + HIVE_REGEN, //int regenRate; + HIVE_SPLASHDAMAGE, //int splashDamage; + HIVE_SPLASHRADIUS, //int splashRadius; + MOD_ASPAWN, //int meansOfDeath; + BIT_ALIENS, //int team; + ( 1 << WP_ABUILD )|( 1 << WP_ABUILD2 ), //weapon_t buildWeapon; + BANIM_IDLE1, //int idleAnim; + 500, //int nextthink; + HIVE_BT, //int buildTime; + qfalse, //qboolean usable; + 0, //int turretRange; + 0, //int turretFireSpeed; + WP_HIVE, //weapon_t turretProjType; + 0.0f, //float minNormal; + qtrue, //qboolean invertNormal; + qtrue, //qboolean creepTest; + HIVE_CREEPSIZE, //int creepSize; + qfalse, //qboolean dccTest; + qfalse, //qboolean transparentTest; + qfalse, //qboolean reactorTest; + qfalse, //qboolean replacable; + }, + { BA_A_HOVEL, //int buildNum; "hovel", //char *buildName; "Hovel", //char *humanName; @@ -370,43 +373,6 @@ buildableAttributes_t bg_buildableList[ ] = qfalse, //qboolean replacable; }, { - BA_H_MEDISTAT, //int buildNum; - "medistat", //char *buildName; - "Medistation", //char *humanName; - "team_human_medistat", //char *entityName; - { "models/buildables/medistat/medistat.md3", 0, 0, 0 }, - 1.0f, //float modelScale; - { -35, -35, -7 }, //vec3_t mins; - { 35, 35, 4 }, //vec3_t maxs; - 0.0f, //float zOffset; - TR_GRAVITY, //trType_t traj; - 0.0, //float bounce; - MEDISTAT_BP, //int buildPoints; - ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages - MEDISTAT_HEALTH, //int health; - 0, //int regenRate; - MEDISTAT_SPLASHDAMAGE, //int splashDamage; - MEDISTAT_SPLASHRADIUS, //int splashRadius; - MOD_HSPAWN, //int meansOfDeath; - BIT_HUMANS, //int team; - ( 1 << WP_HBUILD )|( 1 << WP_HBUILD2 ), //weapon_t buildWeapon; - BANIM_IDLE1, //int idleAnim; - 100, //int nextthink; - MEDISTAT_BT, //int buildTime; - qfalse, //qboolean usable; - 0, //int turretRange; - 0, //int turretFireSpeed; - WP_NONE, //weapon_t turretProjType; - 0.95f, //float minNormal; - qfalse, //qboolean invertNormal; - qfalse, //qboolean creepTest; - 0, //int creepSize; - qfalse, //qboolean dccTest; - qtrue, //qboolean transparentTest; - qfalse, //qboolean reactorTest; - qtrue, //qboolean replacable; - }, - { BA_H_MGTURRET, //int buildNum; "mgturret", //char *buildName; "Machinegun Turret", //char *humanName; @@ -483,6 +449,43 @@ buildableAttributes_t bg_buildableList[ ] = qfalse, //qboolean replacable; }, { + BA_H_ARMOURY, //int buildNum; + "arm", //char *buildName; + "Armoury", //char *humanName; + "team_human_armoury", //char *entityName; + { "models/buildables/arm/arm.md3", 0, 0, 0 }, + 1.0f, //float modelScale; + { -40, -40, -13 }, //vec3_t mins; + { 40, 40, 50 }, //vec3_t maxs; + -2.0f, //float zOffset; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; + ARMOURY_BP, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages + ARMOURY_HEALTH, //int health; + 0, //int regenRate; + ARMOURY_SPLASHDAMAGE, //int splashDamage; + ARMOURY_SPLASHRADIUS, //int splashRadius; + MOD_HSPAWN, //int meansOfDeath; + BIT_HUMANS, //int team; + ( 1 << WP_HBUILD )|( 1 << WP_HBUILD2 ), //weapon_t buildWeapon; + BANIM_IDLE1, //int idleAnim; + 100, //int nextthink; + ARMOURY_BT, //int buildTime; + qtrue, //qboolean usable; + 0, //int turretRange; + 0, //int turretFireSpeed; + WP_NONE, //weapon_t turretProjType; + 0.95f, //float minNormal; + qfalse, //qboolean invertNormal; + qfalse, //qboolean creepTest; + 0, //int creepSize; + qfalse, //qboolean dccTest; + qfalse, //qboolean transparentTest; + qfalse, //qboolean reactorTest; + qtrue, //qboolean replacable; + }, + { BA_H_DCC, //int buildNum; "dcc", //char *buildName; "Defence Computer", //char *humanName; @@ -520,30 +523,30 @@ buildableAttributes_t bg_buildableList[ ] = qtrue, //qboolean replacable; }, { - BA_H_ARMOURY, //int buildNum; - "arm", //char *buildName; - "Armoury", //char *humanName; - "team_human_armoury", //char *entityName; - { "models/buildables/arm/arm.md3", 0, 0, 0 }, + BA_H_MEDISTAT, //int buildNum; + "medistat", //char *buildName; + "Medistation", //char *humanName; + "team_human_medistat", //char *entityName; + { "models/buildables/medistat/medistat.md3", 0, 0, 0 }, 1.0f, //float modelScale; - { -40, -40, -13 }, //vec3_t mins; - { 40, 40, 50 }, //vec3_t maxs; - -2.0f, //float zOffset; + { -35, -35, -7 }, //vec3_t mins; + { 35, 35, 4 }, //vec3_t maxs; + 0.0f, //float zOffset; TR_GRAVITY, //trType_t traj; 0.0, //float bounce; - ARMOURY_BP, //int buildPoints; + MEDISTAT_BP, //int buildPoints; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages - ARMOURY_HEALTH, //int health; + MEDISTAT_HEALTH, //int health; 0, //int regenRate; - ARMOURY_SPLASHDAMAGE, //int splashDamage; - ARMOURY_SPLASHRADIUS, //int splashRadius; + MEDISTAT_SPLASHDAMAGE, //int splashDamage; + MEDISTAT_SPLASHRADIUS, //int splashRadius; MOD_HSPAWN, //int meansOfDeath; BIT_HUMANS, //int team; ( 1 << WP_HBUILD )|( 1 << WP_HBUILD2 ), //weapon_t buildWeapon; BANIM_IDLE1, //int idleAnim; 100, //int nextthink; - ARMOURY_BT, //int buildTime; - qtrue, //qboolean usable; + MEDISTAT_BT, //int buildTime; + qfalse, //qboolean usable; 0, //int turretRange; 0, //int turretFireSpeed; WP_NONE, //weapon_t turretProjType; @@ -552,7 +555,7 @@ buildableAttributes_t bg_buildableList[ ] = qfalse, //qboolean creepTest; 0, //int creepSize; qfalse, //qboolean dccTest; - qfalse, //qboolean transparentTest; + qtrue, //qboolean transparentTest; qfalse, //qboolean reactorTest; qtrue, //qboolean replacable; }, @@ -632,7 +635,13 @@ buildableAttributes_t bg_buildableList[ ] = } }; -int bg_numBuildables = sizeof( bg_buildableList ) / sizeof( bg_buildableList[ 0 ] ); +static inline buildableAttributes_t *FindBuildable( int index ) +{ + if( index < BA_NONE || index >= BA_NUM_BUILDABLES ) + Com_Error( ERR_FATAL, "Invalid index in FindBuildable: %i\n", index); + + return bg_buildableList + index; +} /* ============== @@ -643,7 +652,7 @@ int BG_FindBuildNumForName( char *name ) { int i; - for( i = 0; i < bg_numBuildables; i++ ) + for( i = 0; i < BA_NUM_BUILDABLES; i++ ) { if( !Q_stricmp( bg_buildableList[ i ].buildName, name ) ) return bg_buildableList[ i ].buildNum; @@ -662,7 +671,7 @@ int BG_FindBuildNumForEntityName( char *name ) { int i; - for( i = 0; i < bg_numBuildables; i++ ) + for( i = 0; i < BA_NUM_BUILDABLES; i++ ) { if( !Q_stricmp( bg_buildableList[ i ].entityName, name ) ) return bg_buildableList[ i ].buildNum; @@ -679,16 +688,7 @@ BG_FindNameForBuildNum */ char *BG_FindNameForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - return bg_buildableList[ i ].buildName; - } - - //wimp out - return 0; + return FindBuildable( bclass )->buildName; } /* @@ -698,16 +698,7 @@ BG_FindHumanNameForBuildNum */ char *BG_FindHumanNameForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - return bg_buildableList[ i ].humanName; - } - - //wimp out - return 0; + return FindBuildable( bclass )->humanName; } /* @@ -717,16 +708,7 @@ BG_FindEntityNameForBuildNum */ char *BG_FindEntityNameForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - return bg_buildableList[ i ].entityName; - } - - //wimp out - return 0; + return FindBuildable( bclass )->entityName; } /* @@ -736,16 +718,7 @@ BG_FindModelsForBuildNum */ char *BG_FindModelsForBuildable( int bclass, int modelNum ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - return bg_buildableList[ i ].models[ modelNum ]; - } - - //wimp out - return 0; + return FindBuildable( bclass )->models[ modelNum ]; } /* @@ -755,16 +728,7 @@ BG_FindModelScaleForBuildable */ float BG_FindModelScaleForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - return bg_buildableList[ i ].modelScale; - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindModelScaleForBuildable( %d )\n", bclass ); - return 1.0f; + return FindBuildable( bclass )->modelScale; } /* @@ -774,27 +738,13 @@ BG_FindBBoxForBuildable */ void BG_FindBBoxForBuildable( int bclass, vec3_t mins, vec3_t maxs ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - if( mins != NULL ) - VectorCopy( bg_buildableList[ i ].mins, mins ); + buildableAttributes_t *attr = FindBuildable( bclass ); - if( maxs != NULL ) - VectorCopy( bg_buildableList[ i ].maxs, maxs ); + if( mins ) + VectorCopy( attr->mins, mins ); - return; - } - } - - if( mins != NULL ) - VectorCopy( bg_buildableList[ 0 ].mins, mins ); - - if( maxs != NULL ) - VectorCopy( bg_buildableList[ 0 ].maxs, maxs ); + if( maxs ) + VectorCopy( attr->maxs, maxs ); } /* @@ -804,17 +754,7 @@ BG_FindZOffsetForBuildable */ float BG_FindZOffsetForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].zOffset; - } - } - - return 0.0f; + return FindBuildable( bclass )->zOffset; } /* @@ -824,17 +764,7 @@ BG_FindTrajectoryForBuildable */ trType_t BG_FindTrajectoryForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].traj; - } - } - - return TR_GRAVITY; + return FindBuildable( bclass )->traj; } /* @@ -844,17 +774,7 @@ BG_FindBounceForBuildable */ float BG_FindBounceForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].bounce; - } - } - - return 0.0; + return FindBuildable( bclass )->bounce; } /* @@ -864,17 +784,7 @@ BG_FindBuildPointsForBuildable */ int BG_FindBuildPointsForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].buildPoints; - } - } - - return 1000; + return FindBuildable( bclass )->buildPoints; } /* @@ -884,20 +794,7 @@ BG_FindStagesForBuildable */ qboolean BG_FindStagesForBuildable( int bclass, stage_t stage ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - if( bg_buildableList[ i ].stages & ( 1 << stage ) ) - return qtrue; - else - return qfalse; - } - } - - return qfalse; + return !!( FindBuildable( bclass )->stages & ( 1 << stage ) ); } /* @@ -907,17 +804,7 @@ BG_FindHealthForBuildable */ int BG_FindHealthForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].health; - } - } - - return 1000; + return FindBuildable( bclass )->health; } /* @@ -927,17 +814,7 @@ BG_FindRegenRateForBuildable */ int BG_FindRegenRateForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].regenRate; - } - } - - return 0; + return FindBuildable( bclass )->regenRate; } /* @@ -947,17 +824,7 @@ BG_FindSplashDamageForBuildable */ int BG_FindSplashDamageForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].splashDamage; - } - } - - return 50; + return FindBuildable( bclass )->splashDamage; } /* @@ -967,17 +834,7 @@ BG_FindSplashRadiusForBuildable */ int BG_FindSplashRadiusForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].splashRadius; - } - } - - return 200; + return FindBuildable( bclass )->splashRadius; } /* @@ -987,17 +844,7 @@ BG_FindMODForBuildable */ int BG_FindMODForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].meansOfDeath; - } - } - - return MOD_UNKNOWN; + return FindBuildable( bclass )->meansOfDeath; } /* @@ -1007,17 +854,7 @@ BG_FindTeamForBuildable */ int BG_FindTeamForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].team; - } - } - - return BIT_NONE; + return FindBuildable( bclass )->team; } /* @@ -1027,17 +864,7 @@ BG_FindBuildWeaponForBuildable */ weapon_t BG_FindBuildWeaponForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].buildWeapon; - } - } - - return BA_NONE; + return FindBuildable( bclass )->buildWeapon; } /* @@ -1047,17 +874,7 @@ BG_FindAnimForBuildable */ int BG_FindAnimForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].idleAnim; - } - } - - return BANIM_IDLE1; + return FindBuildable( bclass )->idleAnim; } /* @@ -1067,17 +884,7 @@ BG_FindNextThinkForBuildable */ int BG_FindNextThinkForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].nextthink; - } - } - - return 100; + return FindBuildable( bclass )->nextthink; } /* @@ -1087,17 +894,7 @@ BG_FindBuildTimeForBuildable */ int BG_FindBuildTimeForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].buildTime; - } - } - - return 10000; + return FindBuildable( bclass )->buildTime; } /* @@ -1107,17 +904,7 @@ BG_FindUsableForBuildable */ qboolean BG_FindUsableForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].usable; - } - } - - return qfalse; + return FindBuildable( bclass )->usable; } /* @@ -1127,17 +914,7 @@ BG_FindFireSpeedForBuildable */ int BG_FindFireSpeedForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].turretFireSpeed; - } - } - - return 1000; + return FindBuildable( bclass )->turretFireSpeed; } /* @@ -1147,17 +924,7 @@ BG_FindRangeForBuildable */ int BG_FindRangeForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].turretRange; - } - } - - return 1000; + return FindBuildable( bclass )->turretRange; } /* @@ -1167,17 +934,7 @@ BG_FindProjTypeForBuildable */ weapon_t BG_FindProjTypeForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].turretProjType; - } - } - - return WP_NONE; + return FindBuildable( bclass )->turretProjType; } /* @@ -1187,17 +944,7 @@ BG_FindMinNormalForBuildable */ float BG_FindMinNormalForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].minNormal; - } - } - - return 0.707f; + return FindBuildable( bclass )->minNormal; } /* @@ -1207,17 +954,7 @@ BG_FindInvertNormalForBuildable */ qboolean BG_FindInvertNormalForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].invertNormal; - } - } - - return qfalse; + return FindBuildable( bclass )->invertNormal; } /* @@ -1227,17 +964,7 @@ BG_FindCreepTestForBuildable */ int BG_FindCreepTestForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].creepTest; - } - } - - return qfalse; + return FindBuildable( bclass )->creepTest; } /* @@ -1247,17 +974,7 @@ BG_FindCreepSizeForBuildable */ int BG_FindCreepSizeForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].creepSize; - } - } - - return CREEP_BASESIZE; + return FindBuildable( bclass )->creepSize; } /* @@ -1267,17 +984,7 @@ BG_FindDCCTestForBuildable */ int BG_FindDCCTestForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].dccTest; - } - } - - return qfalse; + return FindBuildable( bclass )->dccTest; } /* @@ -1287,17 +994,7 @@ BG_FindUniqueTestForBuildable */ int BG_FindUniqueTestForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].reactorTest; - } - } - - return qfalse; + return FindBuildable( bclass )->reactorTest; } /* @@ -1307,16 +1004,7 @@ BG_FindReplaceableTestForBuildable */ qboolean BG_FindReplaceableTestForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].replaceable; - } - } - return qfalse; + return FindBuildable( bclass )->replaceable; } /* @@ -1326,16 +1014,7 @@ BG_FindTransparentTestForBuildable */ qboolean BG_FindTransparentTestForBuildable( int bclass ) { - int i; - - for( i = 0; i < bg_numBuildables; i++ ) - { - if( bg_buildableList[ i ].buildNum == bclass ) - { - return bg_buildableList[ i ].transparentTest; - } - } - return qfalse; + return FindBuildable( bclass )->transparentTest; } //////////////////////////////////////////////////////////////////////////////// @@ -1848,7 +1527,13 @@ classAttributes_t bg_classList[ ] = }, }; -int bg_numPclasses = sizeof( bg_classList ) / sizeof( bg_classList[ 0 ] ); +static inline classAttributes_t *FindClass( int index ) +{ + if( index < PCL_NONE || index >= PCL_NUM_CLASSES ) + Com_Error( ERR_FATAL, "Invalid index in FindClass: %i\n", index); + + return bg_classList + index; +} /* ============== @@ -1859,7 +1544,7 @@ int BG_FindClassNumForName( char *name ) { int i; - for( i = 0; i < bg_numPclasses; i++ ) + for( i = 0; i < PCL_NUM_CLASSES; i++ ) { if( !Q_stricmp( bg_classList[ i ].className, name ) ) return bg_classList[ i ].classNum; @@ -1876,17 +1561,7 @@ BG_FindNameForClassNum */ char *BG_FindNameForClassNum( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - return bg_classList[ i ].className; - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindNameForClassNum\n" ); - //wimp out - return 0; + return FindClass( pclass )->className; } /* @@ -1896,17 +1571,7 @@ BG_FindHumanNameForClassNum */ char *BG_FindHumanNameForClassNum( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - return bg_classList[ i ].humanName; - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindHumanNameForClassNum\n" ); - //wimp out - return 0; + return FindClass( pclass )->humanName; } /* @@ -1916,17 +1581,7 @@ BG_FindModelNameForClass */ char *BG_FindModelNameForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - return bg_classList[ i ].modelName; - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindModelNameForClass\n" ); - //note: must return a valid modelName! - return bg_classList[ 0 ].modelName; + return FindClass( pclass )->modelName; } /* @@ -1936,18 +1591,7 @@ BG_FindModelScaleForClass */ float BG_FindModelScaleForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].modelScale; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindModelScaleForClass( %d )\n", pclass ); - return 1.0f; + return FindClass( pclass )->modelScale; } /* @@ -1957,17 +1601,7 @@ BG_FindSkinNameForClass */ char *BG_FindSkinNameForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - return bg_classList[ i ].skinName; - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindSkinNameForClass\n" ); - //note: must return a valid modelName! - return bg_classList[ 0 ].skinName; + return FindClass( pclass )->skinName; } /* @@ -1977,18 +1611,7 @@ BG_FindShadowScaleForClass */ float BG_FindShadowScaleForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].shadowScale; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindShadowScaleForClass( %d )\n", pclass ); - return 1.0f; + return FindClass( pclass )->shadowScale; } /* @@ -1998,17 +1621,7 @@ BG_FindHudNameForClass */ char *BG_FindHudNameForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - return bg_classList[ i ].hudName; - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindHudNameForClass\n" ); - //note: must return a valid hudName! - return bg_classList[ 0 ].hudName; + return FindClass( pclass )->hudName; } /* @@ -2018,21 +1631,7 @@ BG_FindStagesForClass */ qboolean BG_FindStagesForClass( int pclass, stage_t stage ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - if( bg_classList[ i ].stages & ( 1 << stage ) ) - return qtrue; - else - return qfalse; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindStagesForClass\n" ); - return qfalse; + return !!( FindClass( pclass )->stages & ( 1 << stage ) ); } /* @@ -2042,45 +1641,22 @@ BG_FindBBoxForClass */ void BG_FindBBoxForClass( int pclass, vec3_t mins, vec3_t maxs, vec3_t cmaxs, vec3_t dmins, vec3_t dmaxs ) { - int i; + classAttributes_t *attr = FindClass( pclass ); - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - if( mins != NULL ) - VectorCopy( bg_classList[ i ].mins, mins ); - - if( maxs != NULL ) - VectorCopy( bg_classList[ i ].maxs, maxs ); - - if( cmaxs != NULL ) - VectorCopy( bg_classList[ i ].crouchMaxs, cmaxs ); + if( mins ) + VectorCopy( attr->mins, mins ); - if( dmins != NULL ) - VectorCopy( bg_classList[ i ].deadMins, dmins ); + if( maxs ) + VectorCopy( attr->maxs, maxs ); - if( dmaxs != NULL ) - VectorCopy( bg_classList[ i ].deadMaxs, dmaxs ); - - return; - } - } + if( cmaxs ) + VectorCopy( attr->crouchMaxs, cmaxs ); - if( mins != NULL ) - VectorCopy( bg_classList[ 0 ].mins, mins ); + if( dmins ) + VectorCopy( attr->deadMins, dmins ); - if( maxs != NULL ) - VectorCopy( bg_classList[ 0 ].maxs, maxs ); - - if( cmaxs != NULL ) - VectorCopy( bg_classList[ 0 ].crouchMaxs, cmaxs ); - - if( dmins != NULL ) - VectorCopy( bg_classList[ 0 ].deadMins, dmins ); - - if( dmaxs != NULL ) - VectorCopy( bg_classList[ 0 ].deadMaxs, dmaxs ); + if( dmaxs ) + VectorCopy( attr->deadMaxs, dmaxs ); } /* @@ -2090,18 +1666,7 @@ BG_FindZOffsetForClass */ float BG_FindZOffsetForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].zOffset; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindZOffsetForClass\n" ); - return 0.0f; + return FindClass( pclass )->zOffset; } /* @@ -2111,29 +1676,13 @@ BG_FindViewheightForClass */ void BG_FindViewheightForClass( int pclass, int *viewheight, int *cViewheight ) { - int i; - int vh = 0; - int cvh = 0; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - vh = bg_classList[ i ].viewheight; - cvh = bg_classList[ i ].crouchViewheight; - break; - } - } + classAttributes_t *attr = FindClass(pclass); - if( vh == 0 ) - vh = bg_classList[ 0 ].viewheight; - if( cvh == 0 ) - cvh = bg_classList[ 0 ].crouchViewheight; + if( viewheight ) + *viewheight = attr->viewheight; - if( viewheight != NULL ) - *viewheight = vh; - if( cViewheight != NULL ) - *cViewheight = cvh; + if ( cViewheight ) + *cViewheight = attr->crouchViewheight; } /* @@ -2143,18 +1692,7 @@ BG_FindHealthForClass */ int BG_FindHealthForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].health; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindHealthForClass\n" ); - return 100; + return FindClass( pclass )->health; } /* @@ -2164,18 +1702,7 @@ BG_FindFallDamageForClass */ float BG_FindFallDamageForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].fallDamage; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindFallDamageForClass\n" ); - return 100; + return FindClass( pclass )->fallDamage; } /* @@ -2185,18 +1712,7 @@ BG_FindRegenRateForClass */ int BG_FindRegenRateForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].regenRate; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindRegenRateForClass\n" ); - return 0; + return FindClass( pclass )->regenRate; } /* @@ -2206,18 +1722,7 @@ BG_FindFovForClass */ int BG_FindFovForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].fov; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindFovForClass\n" ); - return 90; + return FindClass( pclass )->fov; } /* @@ -2227,18 +1732,7 @@ BG_FindBobForClass */ float BG_FindBobForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].bob; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindBobForClass\n" ); - return 0.002; + return FindClass( pclass )->bob; } /* @@ -2248,18 +1742,7 @@ BG_FindBobCycleForClass */ float BG_FindBobCycleForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].bobCycle; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindBobCycleForClass\n" ); - return 1.0f; + return FindClass( pclass )->bobCycle; } /* @@ -2269,18 +1752,7 @@ BG_FindSpeedForClass */ float BG_FindSpeedForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].speed; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindSpeedForClass\n" ); - return 1.0f; + return FindClass( pclass )->speed; } /* @@ -2290,18 +1762,7 @@ BG_FindAccelerationForClass */ float BG_FindAccelerationForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].acceleration; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindAccelerationForClass\n" ); - return 10.0f; + return FindClass( pclass )->acceleration; } /* @@ -2311,18 +1772,7 @@ BG_FindAirAccelerationForClass */ float BG_FindAirAccelerationForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].airAcceleration; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindAirAccelerationForClass\n" ); - return 1.0f; + return FindClass( pclass )->airAcceleration; } /* @@ -2332,18 +1782,7 @@ BG_FindFrictionForClass */ float BG_FindFrictionForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].friction; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindFrictionForClass\n" ); - return 6.0f; + return FindClass( pclass )->friction; } /* @@ -2353,18 +1792,7 @@ BG_FindStopSpeedForClass */ float BG_FindStopSpeedForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].stopSpeed; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindStopSpeedForClass\n" ); - return 100.0f; + return FindClass( pclass )->stopSpeed; } /* @@ -2374,18 +1802,7 @@ BG_FindJumpMagnitudeForClass */ float BG_FindJumpMagnitudeForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].jumpMagnitude; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindJumpMagnitudeForClass\n" ); - return 270.0f; + return FindClass( pclass )->jumpMagnitude; } /* @@ -2395,18 +1812,7 @@ BG_FindKnockbackScaleForClass */ float BG_FindKnockbackScaleForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].knockbackScale; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindKnockbackScaleForClass\n" ); - return 1.0f; + return FindClass( pclass )->knockbackScale; } /* @@ -2416,18 +1822,7 @@ BG_FindSteptimeForClass */ int BG_FindSteptimeForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].steptime; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindSteptimeForClass\n" ); - return 200; + return FindClass( pclass )->steptime; } /* @@ -2437,17 +1832,7 @@ BG_ClassHasAbility */ qboolean BG_ClassHasAbility( int pclass, int ability ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return ( bg_classList[ i ].abilities & ability ); - } - } - - return qfalse; + return !!( FindClass( pclass )->abilities & ability ); } /* @@ -2457,18 +1842,7 @@ BG_FindStartWeaponForClass */ weapon_t BG_FindStartWeaponForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].startWeapon; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindStartWeaponForClass\n" ); - return WP_NONE; + return FindClass( pclass )->startWeapon; } /* @@ -2478,18 +1852,7 @@ BG_FindBuildDistForClass */ float BG_FindBuildDistForClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].buildDist; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindBuildDistForClass\n" ); - return 0.0f; + return FindClass( pclass )->buildDist; } /* @@ -2499,7 +1862,8 @@ BG_ClassCanEvolveFromTo */ int BG_ClassCanEvolveFromTo( int fclass, int tclass, int credits, int num ) { - int i, j, cost; + classAttributes_t *attr = FindClass( fclass ); + int i, cost; cost = BG_FindCostOfClass( tclass ); @@ -2510,30 +1874,22 @@ int BG_ClassCanEvolveFromTo( int fclass, int tclass, int credits, int num ) if( fclass == PCL_NONE || tclass == PCL_NONE ) return -1; - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == fclass ) - { - for( j = 0; j < 3; j++ ) - if( bg_classList[ i ].children[ j ] == tclass ) - return num + cost; - - for( j = 0; j < 3; j++ ) - { - int sub; + for( i = 0; i < 3; i++ ) + if( attr->children[ i ] == tclass ) + return num + cost; - cost = BG_FindCostOfClass( bg_classList[ i ].children[ j ] ); - sub = BG_ClassCanEvolveFromTo( bg_classList[ i ].children[ j ], - tclass, credits - cost, num + cost ); - if( sub >= 0 ) - return sub; - } + for( i = 0; i < 3; i++ ) + { + int sub; - return -1; //may as well return by this point - } + cost = BG_FindCostOfClass( attr->children[ i ] ); + sub = BG_ClassCanEvolveFromTo( attr->children[ i ], + tclass, credits - cost, num + cost ); + if( sub >= 0 ) + return sub; } - return -1; + return -1; //may as well return by this point } /* @@ -2543,18 +1899,7 @@ BG_FindValueOfClass */ int BG_FindValueOfClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].value; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindValueOfClass\n" ); - return 0; + return FindClass( pclass )->value; } /* @@ -2564,18 +1909,7 @@ BG_FindCostOfClass */ int BG_FindCostOfClass( int pclass ) { - int i; - - for( i = 0; i < bg_numPclasses; i++ ) - { - if( bg_classList[ i ].classNum == pclass ) - { - return bg_classList[ i ].cost; - } - } - - Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindCostOfClass\n" ); - return 0; + return FindClass( pclass )->cost; } //////////////////////////////////////////////////////////////////////////////// @@ -2583,221 +1917,249 @@ int BG_FindCostOfClass( int pclass ) weaponAttributes_t bg_weapons[ ] = { { - WP_BLASTER, //int weaponNum; + WP_NONE, + }, + { + WP_ALEVEL0, //int weaponNum; 0, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages - 0, //int slots; - "blaster", //char *weaponName; - "Blaster", //char *weaponHumanName; + SLOT_WEAPON, //int slots; + "level0", //char *weaponName; + "Bite", //char *weaponHumanName; 0, //int maxAmmo; 0, //int maxClips; qtrue, //int infiniteAmmo; qfalse, //int usesEnergy; - BLASTER_REPEAT, //int repeatRate1; + LEVEL0_BITE_REPEAT, //int repeatRate1; 0, //int repeatRate2; 0, //int repeatRate3; 0, //int reloadTime; - BLASTER_K_SCALE, //float knockbackScale; + LEVEL0_BITE_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; qfalse, //qboolean purchasable; - qtrue, //qboolean longRanged; + qfalse, //qboolean longRanged; 0, //int buildDelay; - WUT_HUMANS //WUTeam_t team; + WUT_ALIENS //WUTeam_t team; }, { - WP_MACHINEGUN, //int weaponNum; - RIFLE_PRICE, //int price; + WP_ALEVEL1, //int weaponNum; + 0, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "rifle", //char *weaponName; - "Rifle", //char *weaponHumanName; - RIFLE_CLIPSIZE, //int maxAmmo; - RIFLE_MAXCLIPS, //int maxClips; - qfalse, //int infiniteAmmo; + "level1", //char *weaponName; + "Claws", //char *weaponHumanName; + 0, //int maxAmmo; + 0, //int maxClips; + qtrue, //int infiniteAmmo; qfalse, //int usesEnergy; - RIFLE_REPEAT, //int repeatRate1; + LEVEL1_CLAW_REPEAT, //int repeatRate1; 0, //int repeatRate2; 0, //int repeatRate3; - RIFLE_RELOAD, //int reloadTime; - RIFLE_K_SCALE, //float knockbackScale; + 0, //int reloadTime; + LEVEL1_CLAW_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qtrue, //qboolean purchasable; - qtrue, //qboolean longRanged; + qfalse, //qboolean purchasable; + qfalse, //qboolean longRanged; 0, //int buildDelay; - WUT_HUMANS //WUTeam_t team; + WUT_ALIENS //WUTeam_t team; }, { - WP_SHOTGUN, //int weaponNum; - SHOTGUN_PRICE, //int price; + WP_ALEVEL1_UPG, //int weaponNum; + 0, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "shotgun", //char *weaponName; - "Shotgun", //char *weaponHumanName; - SHOTGUN_SHELLS, //int maxAmmo; - SHOTGUN_MAXCLIPS, //int maxClips; - qfalse, //int infiniteAmmo; + "level1upg", //char *weaponName; + "Claws Upgrade", //char *weaponHumanName; + 0, //int maxAmmo; + 0, //int maxClips; + qtrue, //int infiniteAmmo; qfalse, //int usesEnergy; - SHOTGUN_REPEAT, //int repeatRate1; - 0, //int repeatRate2; + LEVEL1_CLAW_U_REPEAT, //int repeatRate1; + LEVEL1_PCLOUD_REPEAT, //int repeatRate2; 0, //int repeatRate3; - SHOTGUN_RELOAD, //int reloadTime; - SHOTGUN_K_SCALE, //float knockbackScale; - qfalse, //qboolean hasAltMode; + 0, //int reloadTime; + LEVEL1_CLAW_U_K_SCALE,//float knockbackScale; + qtrue, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qtrue, //qboolean purchasable; + qfalse, //qboolean purchasable; qtrue, //qboolean longRanged; 0, //int buildDelay; - WUT_HUMANS //WUTeam_t team; + WUT_ALIENS //WUTeam_t team; }, { - WP_FLAMER, //int weaponNum; - FLAMER_PRICE, //int price; - ( 1 << S2 )|( 1 << S3 ), //int stages + WP_ALEVEL2, //int weaponNum; + 0, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "flamer", //char *weaponName; - "Flame Thrower", //char *weaponHumanName; - FLAMER_GAS, //int maxAmmo; + "level2", //char *weaponName; + "Bite", //char *weaponHumanName; + 0, //int maxAmmo; 0, //int maxClips; - qfalse, //int infiniteAmmo; + qtrue, //int infiniteAmmo; qfalse, //int usesEnergy; - FLAMER_REPEAT, //int repeatRate1; + LEVEL2_CLAW_REPEAT, //int repeatRate1; 0, //int repeatRate2; 0, //int repeatRate3; 0, //int reloadTime; - FLAMER_K_SCALE, //float knockbackScale; + LEVEL2_CLAW_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qtrue, //qboolean purchasable; - qtrue, //qboolean longRanged; + qfalse, //qboolean purchasable; + qfalse, //qboolean longRanged; 0, //int buildDelay; - WUT_HUMANS //WUTeam_t team; + WUT_ALIENS //WUTeam_t team; }, { - WP_CHAINGUN, //int weaponNum; - CHAINGUN_PRICE, //int price; + WP_ALEVEL2_UPG, //int weaponNum; + 0, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "chaingun", //char *weaponName; - "Chaingun", //char *weaponHumanName; - CHAINGUN_BULLETS, //int maxAmmo; + "level2upg", //char *weaponName; + "Zap", //char *weaponHumanName; + 0, //int maxAmmo; 0, //int maxClips; - qfalse, //int infiniteAmmo; + qtrue, //int infiniteAmmo; qfalse, //int usesEnergy; - CHAINGUN_REPEAT, //int repeatRate1; - 0, //int repeatRate2; + LEVEL2_CLAW_U_REPEAT, //int repeatRate1; + LEVEL2_AREAZAP_REPEAT,//int repeatRate2; 0, //int repeatRate3; 0, //int reloadTime; - CHAINGUN_K_SCALE, //float knockbackScale; - qfalse, //qboolean hasAltMode; + LEVEL2_CLAW_U_K_SCALE,//float knockbackScale; + qtrue, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qtrue, //qboolean purchasable; - qtrue, //qboolean longRanged; + qfalse, //qboolean purchasable; + qfalse, //qboolean longRanged; 0, //int buildDelay; - WUT_HUMANS //WUTeam_t team; + WUT_ALIENS //WUTeam_t team; }, { - WP_MASS_DRIVER, //int weaponNum; - MDRIVER_PRICE, //int price; + WP_ALEVEL3, //int weaponNum; + 0, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "mdriver", //char *weaponName; - "Mass Driver", //char *weaponHumanName; - MDRIVER_CLIPSIZE, //int maxAmmo; - MDRIVER_MAXCLIPS, //int maxClips; - qfalse, //int infiniteAmmo; - qtrue, //int usesEnergy; - MDRIVER_REPEAT, //int repeatRate1; + "level3", //char *weaponName; + "Pounce", //char *weaponHumanName; + 0, //int maxAmmo; + 0, //int maxClips; + qtrue, //int infiniteAmmo; + qfalse, //int usesEnergy; + LEVEL3_CLAW_REPEAT, //int repeatRate1; 0, //int repeatRate2; 0, //int repeatRate3; - MDRIVER_RELOAD, //int reloadTime; - MDRIVER_K_SCALE, //float knockbackScale; + 0, //int reloadTime; + LEVEL3_CLAW_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; - qtrue, //qboolean canZoom; - 20.0f, //float zoomFov; - qtrue, //qboolean purchasable; + qfalse, //qboolean canZoom; + 90.0f, //float zoomFov; + qfalse, //qboolean purchasable; + qfalse, //qboolean longRanged; + 0, //int buildDelay; + WUT_ALIENS //WUTeam_t team; + }, + { + WP_ALEVEL3_UPG, //int weaponNum; + 0, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages + SLOT_WEAPON, //int slots; + "level3upg", //char *weaponName; + "Pounce (upgrade)", //char *weaponHumanName; + 3, //int maxAmmo; + 0, //int maxClips; + qtrue, //int infiniteAmmo; + qfalse, //int usesEnergy; + LEVEL3_CLAW_U_REPEAT, //int repeatRate1; + 0, //int repeatRate2; + LEVEL3_BOUNCEBALL_REPEAT,//int repeatRate3; + 0, //int reloadTime; + LEVEL3_CLAW_U_K_SCALE,//float knockbackScale; + qfalse, //qboolean hasAltMode; + qtrue, //qboolean hasThirdMode; + qfalse, //qboolean canZoom; + 90.0f, //float zoomFov; + qfalse, //qboolean purchasable; qtrue, //qboolean longRanged; 0, //int buildDelay; - WUT_HUMANS //WUTeam_t team; + WUT_ALIENS //WUTeam_t team; }, { - WP_PULSE_RIFLE, //int weaponNum; - PRIFLE_PRICE, //int price; - ( 1 << S2 )|( 1 << S3 ), //int stages + WP_ALEVEL4, //int weaponNum; + 0, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "prifle", //char *weaponName; - "Pulse Rifle", //char *weaponHumanName; - PRIFLE_CLIPS, //int maxAmmo; - PRIFLE_MAXCLIPS, //int maxClips; - qfalse, //int infiniteAmmo; - qtrue, //int usesEnergy; - PRIFLE_REPEAT, //int repeatRate1; + "level4", //char *weaponName; + "Charge", //char *weaponHumanName; + 0, //int maxAmmo; + 0, //int maxClips; + qtrue, //int infiniteAmmo; + qfalse, //int usesEnergy; + LEVEL4_CLAW_REPEAT, //int repeatRate1; 0, //int repeatRate2; 0, //int repeatRate3; - PRIFLE_RELOAD, //int reloadTime; - PRIFLE_K_SCALE, //float knockbackScale; + 0, //int reloadTime; + LEVEL4_CLAW_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qtrue, //qboolean purchasable; - qtrue, //qboolean longRanged; + qfalse, //qboolean purchasable; + qfalse, //qboolean longRanged; 0, //int buildDelay; - WUT_HUMANS //WUTeam_t team; + WUT_ALIENS //WUTeam_t team; }, { - WP_LUCIFER_CANNON, //int weaponNum; - LCANNON_PRICE, //int price; - ( 1 << S3 ), //int stages - SLOT_WEAPON, //int slots; - "lcannon", //char *weaponName; - "Lucifer Cannon", //char *weaponHumanName; - LCANNON_AMMO, //int maxAmmo; + WP_BLASTER, //int weaponNum; + 0, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages + 0, //int slots; + "blaster", //char *weaponName; + "Blaster", //char *weaponHumanName; + 0, //int maxAmmo; 0, //int maxClips; - qfalse, //int infiniteAmmo; - qtrue, //int usesEnergy; - LCANNON_REPEAT, //int repeatRate1; - LCANNON_CHARGEREPEAT, //int repeatRate2; + qtrue, //int infiniteAmmo; + qfalse, //int usesEnergy; + BLASTER_REPEAT, //int repeatRate1; + 0, //int repeatRate2; 0, //int repeatRate3; - LCANNON_RELOAD, //int reloadTime; - LCANNON_K_SCALE, //float knockbackScale; - qtrue, //qboolean hasAltMode; + 0, //int reloadTime; + BLASTER_K_SCALE, //float knockbackScale; + qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qtrue, //qboolean purchasable; + qfalse, //qboolean purchasable; qtrue, //qboolean longRanged; 0, //int buildDelay; WUT_HUMANS //WUTeam_t team; }, { - WP_LAS_GUN, //int weaponNum; - LASGUN_PRICE, //int price; + WP_MACHINEGUN, //int weaponNum; + RIFLE_PRICE, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "lgun", //char *weaponName; - "Las Gun", //char *weaponHumanName; - LASGUN_AMMO, //int maxAmmo; - 0, //int maxClips; + "rifle", //char *weaponName; + "Rifle", //char *weaponHumanName; + RIFLE_CLIPSIZE, //int maxAmmo; + RIFLE_MAXCLIPS, //int maxClips; qfalse, //int infiniteAmmo; - qtrue, //int usesEnergy; - LASGUN_REPEAT, //int repeatRate1; + qfalse, //int usesEnergy; + RIFLE_REPEAT, //int repeatRate1; 0, //int repeatRate2; 0, //int repeatRate3; - LASGUN_RELOAD, //int reloadTime; - LASGUN_K_SCALE, //float knockbackScale; + RIFLE_RELOAD, //int reloadTime; + RIFLE_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; @@ -2833,221 +2195,196 @@ weaponAttributes_t bg_weapons[ ] = WUT_HUMANS //WUTeam_t team; }, { - WP_GRENADE, //int weaponNum; - GRENADE_PRICE, //int price; - ( 1 << S2 )|( 1 << S3 ), //int stages - SLOT_NONE, //int slots; - "grenade", //char *weaponName; - "Grenade", //char *weaponHumanName; - 1, //int maxAmmo; - 0, //int maxClips; + WP_SHOTGUN, //int weaponNum; + SHOTGUN_PRICE, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages + SLOT_WEAPON, //int slots; + "shotgun", //char *weaponName; + "Shotgun", //char *weaponHumanName; + SHOTGUN_SHELLS, //int maxAmmo; + SHOTGUN_MAXCLIPS, //int maxClips; qfalse, //int infiniteAmmo; qfalse, //int usesEnergy; - GRENADE_REPEAT, //int repeatRate1; + SHOTGUN_REPEAT, //int repeatRate1; 0, //int repeatRate2; 0, //int repeatRate3; - 0, //int reloadTime; - GRENADE_K_SCALE, //float knockbackScale; + SHOTGUN_RELOAD, //int reloadTime; + SHOTGUN_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qfalse, //qboolean purchasable; - qfalse, //qboolean longRanged; + qtrue, //qboolean purchasable; + qtrue, //qboolean longRanged; 0, //int buildDelay; WUT_HUMANS //WUTeam_t team; }, { - WP_HBUILD, //int weaponNum; - HBUILD_PRICE, //int price; + WP_LAS_GUN, //int weaponNum; + LASGUN_PRICE, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "ckit", //char *weaponName; - "Construction Kit", //char *weaponHumanName; - 0, //int maxAmmo; + "lgun", //char *weaponName; + "Las Gun", //char *weaponHumanName; + LASGUN_AMMO, //int maxAmmo; 0, //int maxClips; - qtrue, //int infiniteAmmo; - qfalse, //int usesEnergy; - HBUILD_REPEAT, //int repeatRate1; - HBUILD_REPEAT, //int repeatRate2; + qfalse, //int infiniteAmmo; + qtrue, //int usesEnergy; + LASGUN_REPEAT, //int repeatRate1; + 0, //int repeatRate2; 0, //int repeatRate3; - 0, //int reloadTime; - 0.0f, //float knockbackScale; - qtrue, //qboolean hasAltMode; + LASGUN_RELOAD, //int reloadTime; + LASGUN_K_SCALE, //float knockbackScale; + qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; qtrue, //qboolean purchasable; - qfalse, //qboolean longRanged; - HBUILD_DELAY, //int buildDelay; + qtrue, //qboolean longRanged; + 0, //int buildDelay; WUT_HUMANS //WUTeam_t team; }, { - WP_HBUILD2, //int weaponNum; - HBUILD2_PRICE, //int price; - ( 1 << S2 )|( 1 << S3 ), //int stages + WP_MASS_DRIVER, //int weaponNum; + MDRIVER_PRICE, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "ackit", //char *weaponName; - "Adv Construction Kit",//char *weaponHumanName; - 0, //int maxAmmo; - 0, //int maxClips; - qtrue, //int infiniteAmmo; - qfalse, //int usesEnergy; - HBUILD2_REPEAT, //int repeatRate1; - HBUILD2_REPEAT, //int repeatRate2; + "mdriver", //char *weaponName; + "Mass Driver", //char *weaponHumanName; + MDRIVER_CLIPSIZE, //int maxAmmo; + MDRIVER_MAXCLIPS, //int maxClips; + qfalse, //int infiniteAmmo; + qtrue, //int usesEnergy; + MDRIVER_REPEAT, //int repeatRate1; + 0, //int repeatRate2; 0, //int repeatRate3; - 0, //int reloadTime; - 0.0f, //float knockbackScale; - qtrue, //qboolean hasAltMode; + MDRIVER_RELOAD, //int reloadTime; + MDRIVER_K_SCALE, //float knockbackScale; + qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; - qfalse, //qboolean canZoom; - 90.0f, //float zoomFov; + qtrue, //qboolean canZoom; + 20.0f, //float zoomFov; qtrue, //qboolean purchasable; - qfalse, //qboolean longRanged; - HBUILD2_DELAY, //int buildDelay; + qtrue, //qboolean longRanged; + 0, //int buildDelay; WUT_HUMANS //WUTeam_t team; }, { - WP_ABUILD, //int weaponNum; - 0, //int price; + WP_CHAINGUN, //int weaponNum; + CHAINGUN_PRICE, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "abuild", //char *weaponName; - "Alien build weapon", //char *weaponHumanName; - 0, //int maxAmmo; + "chaingun", //char *weaponName; + "Chaingun", //char *weaponHumanName; + CHAINGUN_BULLETS, //int maxAmmo; 0, //int maxClips; - qtrue, //int infiniteAmmo; + qfalse, //int infiniteAmmo; qfalse, //int usesEnergy; - ABUILDER_BUILD_REPEAT,//int repeatRate1; - ABUILDER_BUILD_REPEAT,//int repeatRate2; + CHAINGUN_REPEAT, //int repeatRate1; + 0, //int repeatRate2; 0, //int repeatRate3; 0, //int reloadTime; - 0.0f, //float knockbackScale; - qtrue, //qboolean hasAltMode; + CHAINGUN_K_SCALE, //float knockbackScale; + qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; qtrue, //qboolean purchasable; - qfalse, //qboolean longRanged; - ABUILDER_BASE_DELAY, //int buildDelay; - WUT_ALIENS //WUTeam_t team; - }, - { - WP_ABUILD2, //int weaponNum; - 0, //int price; - ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages - SLOT_WEAPON, //int slots; - "abuildupg", //char *weaponName; - "Alien build weapon2",//char *weaponHumanName; - 0, //int maxAmmo; - 0, //int maxClips; - qtrue, //int infiniteAmmo; - qfalse, //int usesEnergy; - ABUILDER_BUILD_REPEAT,//int repeatRate1; - ABUILDER_CLAW_REPEAT, //int repeatRate2; - ABUILDER_BLOB_REPEAT, //int repeatRate3; - 0, //int reloadTime; - ABUILDER_CLAW_K_SCALE,//float knockbackScale; - qtrue, //qboolean hasAltMode; - qtrue, //qboolean hasThirdMode; - qfalse, //qboolean canZoom; - 90.0f, //float zoomFov; - qtrue, //qboolean purchasable; - qfalse, //qboolean longRanged; - ABUILDER_ADV_DELAY, //int buildDelay; - WUT_ALIENS //WUTeam_t team; + qtrue, //qboolean longRanged; + 0, //int buildDelay; + WUT_HUMANS //WUTeam_t team; }, { - WP_ALEVEL0, //int weaponNum; - 0, //int price; - ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages + WP_PULSE_RIFLE, //int weaponNum; + PRIFLE_PRICE, //int price; + ( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "level0", //char *weaponName; - "Bite", //char *weaponHumanName; - 0, //int maxAmmo; - 0, //int maxClips; - qtrue, //int infiniteAmmo; - qfalse, //int usesEnergy; - LEVEL0_BITE_REPEAT, //int repeatRate1; + "prifle", //char *weaponName; + "Pulse Rifle", //char *weaponHumanName; + PRIFLE_CLIPS, //int maxAmmo; + PRIFLE_MAXCLIPS, //int maxClips; + qfalse, //int infiniteAmmo; + qtrue, //int usesEnergy; + PRIFLE_REPEAT, //int repeatRate1; 0, //int repeatRate2; 0, //int repeatRate3; - 0, //int reloadTime; - LEVEL0_BITE_K_SCALE, //float knockbackScale; + PRIFLE_RELOAD, //int reloadTime; + PRIFLE_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qfalse, //qboolean purchasable; - qfalse, //qboolean longRanged; + qtrue, //qboolean purchasable; + qtrue, //qboolean longRanged; 0, //int buildDelay; - WUT_ALIENS //WUTeam_t team; + WUT_HUMANS //WUTeam_t team; }, { - WP_ALEVEL1, //int weaponNum; - 0, //int price; - ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages + WP_FLAMER, //int weaponNum; + FLAMER_PRICE, //int price; + ( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "level1", //char *weaponName; - "Claws", //char *weaponHumanName; - 0, //int maxAmmo; + "flamer", //char *weaponName; + "Flame Thrower", //char *weaponHumanName; + FLAMER_GAS, //int maxAmmo; 0, //int maxClips; - qtrue, //int infiniteAmmo; + qfalse, //int infiniteAmmo; qfalse, //int usesEnergy; - LEVEL1_CLAW_REPEAT, //int repeatRate1; + FLAMER_REPEAT, //int repeatRate1; 0, //int repeatRate2; 0, //int repeatRate3; 0, //int reloadTime; - LEVEL1_CLAW_K_SCALE, //float knockbackScale; + FLAMER_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qfalse, //qboolean purchasable; - qfalse, //qboolean longRanged; + qtrue, //qboolean purchasable; + qtrue, //qboolean longRanged; 0, //int buildDelay; - WUT_ALIENS //WUTeam_t team; + WUT_HUMANS //WUTeam_t team; }, { - WP_ALEVEL1_UPG, //int weaponNum; - 0, //int price; - ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages + WP_LUCIFER_CANNON, //int weaponNum; + LCANNON_PRICE, //int price; + ( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "level1upg", //char *weaponName; - "Claws Upgrade", //char *weaponHumanName; - 0, //int maxAmmo; + "lcannon", //char *weaponName; + "Lucifer Cannon", //char *weaponHumanName; + LCANNON_AMMO, //int maxAmmo; 0, //int maxClips; - qtrue, //int infiniteAmmo; - qfalse, //int usesEnergy; - LEVEL1_CLAW_U_REPEAT, //int repeatRate1; - LEVEL1_PCLOUD_REPEAT, //int repeatRate2; + qfalse, //int infiniteAmmo; + qtrue, //int usesEnergy; + LCANNON_REPEAT, //int repeatRate1; + LCANNON_CHARGEREPEAT, //int repeatRate2; 0, //int repeatRate3; - 0, //int reloadTime; - LEVEL1_CLAW_U_K_SCALE,//float knockbackScale; + LCANNON_RELOAD, //int reloadTime; + LCANNON_K_SCALE, //float knockbackScale; qtrue, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qfalse, //qboolean purchasable; + qtrue, //qboolean purchasable; qtrue, //qboolean longRanged; 0, //int buildDelay; - WUT_ALIENS //WUTeam_t team; + WUT_HUMANS //WUTeam_t team; }, { - WP_ALEVEL2, //int weaponNum; - 0, //int price; - ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages - SLOT_WEAPON, //int slots; - "level2", //char *weaponName; - "Bite", //char *weaponHumanName; - 0, //int maxAmmo; + WP_GRENADE, //int weaponNum; + GRENADE_PRICE, //int price; + ( 1 << S2 )|( 1 << S3 ), //int stages + SLOT_NONE, //int slots; + "grenade", //char *weaponName; + "Grenade", //char *weaponHumanName; + 1, //int maxAmmo; 0, //int maxClips; - qtrue, //int infiniteAmmo; + qfalse, //int infiniteAmmo; qfalse, //int usesEnergy; - LEVEL2_CLAW_REPEAT, //int repeatRate1; + GRENADE_REPEAT, //int repeatRate1; 0, //int repeatRate2; 0, //int repeatRate3; 0, //int reloadTime; - LEVEL2_CLAW_K_SCALE, //float knockbackScale; + GRENADE_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; @@ -3055,25 +2392,25 @@ weaponAttributes_t bg_weapons[ ] = qfalse, //qboolean purchasable; qfalse, //qboolean longRanged; 0, //int buildDelay; - WUT_ALIENS //WUTeam_t team; + WUT_HUMANS //WUTeam_t team; }, { - WP_ALEVEL2_UPG, //int weaponNum; + WP_LOCKBLOB_LAUNCHER, //int weaponNum; 0, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "level2upg", //char *weaponName; - "Zap", //char *weaponHumanName; + "lockblob", //char *weaponName; + "Lock Blob", //char *weaponHumanName; 0, //int maxAmmo; 0, //int maxClips; qtrue, //int infiniteAmmo; qfalse, //int usesEnergy; - LEVEL2_CLAW_U_REPEAT, //int repeatRate1; - LEVEL2_AREAZAP_REPEAT,//int repeatRate2; - 0, //int repeatRate3; + 500, //int repeatRate1; + 500, //int repeatRate2; + 500, //int repeatRate3; 0, //int reloadTime; - LEVEL2_CLAW_U_K_SCALE,//float knockbackScale; - qtrue, //qboolean hasAltMode; + LOCKBLOB_K_SCALE, //float knockbackScale; + qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; @@ -3083,21 +2420,21 @@ weaponAttributes_t bg_weapons[ ] = WUT_ALIENS //WUTeam_t team; }, { - WP_ALEVEL3, //int weaponNum; + WP_HIVE, //int weaponNum; 0, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "level3", //char *weaponName; - "Pounce", //char *weaponHumanName; + "hive", //char *weaponName; + "Hive", //char *weaponHumanName; 0, //int maxAmmo; 0, //int maxClips; qtrue, //int infiniteAmmo; qfalse, //int usesEnergy; - LEVEL3_CLAW_REPEAT, //int repeatRate1; - 0, //int repeatRate2; - 0, //int repeatRate3; + 500, //int repeatRate1; + 500, //int repeatRate2; + 500, //int repeatRate3; 0, //int reloadTime; - LEVEL3_CLAW_K_SCALE, //float knockbackScale; + HIVE_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; @@ -3108,46 +2445,46 @@ weaponAttributes_t bg_weapons[ ] = WUT_ALIENS //WUTeam_t team; }, { - WP_ALEVEL3_UPG, //int weaponNum; + WP_TESLAGEN, //int weaponNum; 0, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "level3upg", //char *weaponName; - "Pounce (upgrade)", //char *weaponHumanName; - 3, //int maxAmmo; + "teslagen", //char *weaponName; + "Tesla Generator", //char *weaponHumanName; + 0, //int maxAmmo; 0, //int maxClips; qtrue, //int infiniteAmmo; - qfalse, //int usesEnergy; - LEVEL3_CLAW_U_REPEAT, //int repeatRate1; - 0, //int repeatRate2; - LEVEL3_BOUNCEBALL_REPEAT,//int repeatRate3; + qtrue, //int usesEnergy; + 500, //int repeatRate1; + 500, //int repeatRate2; + 500, //int repeatRate3; 0, //int reloadTime; - LEVEL3_CLAW_U_K_SCALE,//float knockbackScale; + TESLAGEN_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; - qtrue, //qboolean hasThirdMode; + qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; qfalse, //qboolean purchasable; - qtrue, //qboolean longRanged; + qfalse, //qboolean longRanged; 0, //int buildDelay; - WUT_ALIENS //WUTeam_t team; + WUT_HUMANS //WUTeam_t team; }, { - WP_ALEVEL4, //int weaponNum; + WP_MGTURRET, //int weaponNum; 0, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "level4", //char *weaponName; - "Charge", //char *weaponHumanName; + "mgturret", //char *weaponName; + "Machinegun Turret", //char *weaponHumanName; 0, //int maxAmmo; 0, //int maxClips; qtrue, //int infiniteAmmo; qfalse, //int usesEnergy; - LEVEL4_CLAW_REPEAT, //int repeatRate1; + 0, //int repeatRate1; 0, //int repeatRate2; 0, //int repeatRate3; 0, //int reloadTime; - LEVEL4_CLAW_K_SCALE, //float knockbackScale; + MGTURRET_K_SCALE, //float knockbackScale; qfalse, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; @@ -3155,111 +2492,117 @@ weaponAttributes_t bg_weapons[ ] = qfalse, //qboolean purchasable; qfalse, //qboolean longRanged; 0, //int buildDelay; - WUT_ALIENS //WUTeam_t team; + WUT_HUMANS //WUTeam_t team; }, { - WP_LOCKBLOB_LAUNCHER, //int weaponNum; + WP_ABUILD, //int weaponNum; 0, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "lockblob", //char *weaponName; - "Lock Blob", //char *weaponHumanName; + "abuild", //char *weaponName; + "Alien build weapon", //char *weaponHumanName; 0, //int maxAmmo; 0, //int maxClips; qtrue, //int infiniteAmmo; qfalse, //int usesEnergy; - 500, //int repeatRate1; - 500, //int repeatRate2; - 500, //int repeatRate3; + ABUILDER_BUILD_REPEAT,//int repeatRate1; + ABUILDER_BUILD_REPEAT,//int repeatRate2; + 0, //int repeatRate3; 0, //int reloadTime; - LOCKBLOB_K_SCALE, //float knockbackScale; - qfalse, //qboolean hasAltMode; + 0.0f, //float knockbackScale; + qtrue, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qfalse, //qboolean purchasable; + qtrue, //qboolean purchasable; qfalse, //qboolean longRanged; - 0, //int buildDelay; + ABUILDER_BASE_DELAY, //int buildDelay; WUT_ALIENS //WUTeam_t team; }, { - WP_HIVE, //int weaponNum; + WP_ABUILD2, //int weaponNum; 0, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "hive", //char *weaponName; - "Hive", //char *weaponHumanName; + "abuildupg", //char *weaponName; + "Alien build weapon2",//char *weaponHumanName; 0, //int maxAmmo; 0, //int maxClips; qtrue, //int infiniteAmmo; qfalse, //int usesEnergy; - 500, //int repeatRate1; - 500, //int repeatRate2; - 500, //int repeatRate3; + ABUILDER_BUILD_REPEAT,//int repeatRate1; + ABUILDER_CLAW_REPEAT, //int repeatRate2; + ABUILDER_BLOB_REPEAT, //int repeatRate3; 0, //int reloadTime; - HIVE_K_SCALE, //float knockbackScale; - qfalse, //qboolean hasAltMode; - qfalse, //qboolean hasThirdMode; + ABUILDER_CLAW_K_SCALE,//float knockbackScale; + qtrue, //qboolean hasAltMode; + qtrue, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qfalse, //qboolean purchasable; + qtrue, //qboolean purchasable; qfalse, //qboolean longRanged; - 0, //int buildDelay; + ABUILDER_ADV_DELAY, //int buildDelay; WUT_ALIENS //WUTeam_t team; }, { - WP_MGTURRET, //int weaponNum; - 0, //int price; + WP_HBUILD, //int weaponNum; + HBUILD_PRICE, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "mgturret", //char *weaponName; - "Machinegun Turret", //char *weaponHumanName; + "ckit", //char *weaponName; + "Construction Kit", //char *weaponHumanName; 0, //int maxAmmo; 0, //int maxClips; qtrue, //int infiniteAmmo; qfalse, //int usesEnergy; - 0, //int repeatRate1; - 0, //int repeatRate2; + HBUILD_REPEAT, //int repeatRate1; + HBUILD_REPEAT, //int repeatRate2; 0, //int repeatRate3; 0, //int reloadTime; - MGTURRET_K_SCALE, //float knockbackScale; - qfalse, //qboolean hasAltMode; + 0.0f, //float knockbackScale; + qtrue, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qfalse, //qboolean purchasable; + qtrue, //qboolean purchasable; qfalse, //qboolean longRanged; - 0, //int buildDelay; + HBUILD_DELAY, //int buildDelay; WUT_HUMANS //WUTeam_t team; }, { - WP_TESLAGEN, //int weaponNum; - 0, //int price; - ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages + WP_HBUILD2, //int weaponNum; + HBUILD2_PRICE, //int price; + ( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; - "teslagen", //char *weaponName; - "Tesla Generator", //char *weaponHumanName; + "ackit", //char *weaponName; + "Adv Construction Kit",//char *weaponHumanName; 0, //int maxAmmo; 0, //int maxClips; qtrue, //int infiniteAmmo; - qtrue, //int usesEnergy; - 500, //int repeatRate1; - 500, //int repeatRate2; - 500, //int repeatRate3; + qfalse, //int usesEnergy; + HBUILD2_REPEAT, //int repeatRate1; + HBUILD2_REPEAT, //int repeatRate2; + 0, //int repeatRate3; 0, //int reloadTime; - TESLAGEN_K_SCALE, //float knockbackScale; - qfalse, //qboolean hasAltMode; + 0.0f, //float knockbackScale; + qtrue, //qboolean hasAltMode; qfalse, //qboolean hasThirdMode; qfalse, //qboolean canZoom; 90.0f, //float zoomFov; - qfalse, //qboolean purchasable; + qtrue, //qboolean purchasable; qfalse, //qboolean longRanged; - 0, //int buildDelay; + HBUILD2_DELAY, //int buildDelay; WUT_HUMANS //WUTeam_t team; } }; -int bg_numWeapons = sizeof( bg_weapons ) / sizeof( bg_weapons[ 0 ] ); +static inline weaponAttributes_t *FindWeapon( int index ) +{ + if( index < WP_NONE || index >= WP_NUM_WEAPONS ) + Com_Error( ERR_FATAL, "Invalid index in FindWeapon: %i\n", index); + + return bg_weapons + index; +} /* ============== @@ -3268,17 +2611,7 @@ BG_FindPriceForWeapon */ int BG_FindPriceForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].price; - } - } - - return 100; + return FindWeapon( weapon )->price; } /* @@ -3288,20 +2621,7 @@ BG_FindStagesForWeapon */ qboolean BG_FindStagesForWeapon( int weapon, stage_t stage ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - if( bg_weapons[ i ].stages & ( 1 << stage ) ) - return qtrue; - else - return qfalse; - } - } - - return qfalse; + return !!( FindWeapon( weapon )->stages & ( 1 << stage ) ); } /* @@ -3311,17 +2631,7 @@ BG_FindSlotsForWeapon */ int BG_FindSlotsForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].slots; - } - } - - return SLOT_WEAPON; + return FindWeapon( weapon )->slots; } /* @@ -3331,16 +2641,7 @@ BG_FindNameForWeapon */ char *BG_FindNameForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - return bg_weapons[ i ].weaponName; - } - - //wimp out - return 0; + return FindWeapon( weapon )->weaponName; } /* @@ -3352,7 +2653,7 @@ int BG_FindWeaponNumForName( char *name ) { int i; - for( i = 0; i < bg_numWeapons; i++ ) + for( i = 0; i < WP_NUM_WEAPONS; i++ ) { if( !Q_stricmp( bg_weapons[ i ].weaponName, name ) ) return bg_weapons[ i ].weaponNum; @@ -3369,16 +2670,7 @@ BG_FindHumanNameForWeapon */ char *BG_FindHumanNameForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - return bg_weapons[ i ].weaponHumanName; - } - - //wimp out - return 0; + return FindWeapon( weapon )->weaponHumanName; } /* @@ -3388,26 +2680,13 @@ BG_FindAmmoForWeapon */ void BG_FindAmmoForWeapon( int weapon, int *maxAmmo, int *maxClips ) { - int i; + weaponAttributes_t *attr = FindWeapon( weapon ); - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - if( maxAmmo != NULL ) - *maxAmmo = bg_weapons[ i ].maxAmmo; - if( maxClips != NULL ) - *maxClips = bg_weapons[ i ].maxClips; + if( maxAmmo ) + *maxAmmo = attr->maxAmmo; - //no need to keep going - return; - } - } - - if( maxAmmo != NULL ) - *maxAmmo = 0; - if( maxClips != NULL ) - *maxClips = 0; + if( maxClips ) + *maxClips = attr->maxClips; } /* @@ -3417,17 +2696,7 @@ BG_FindInfinteAmmoForWeapon */ qboolean BG_FindInfinteAmmoForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].infiniteAmmo; - } - } - - return qfalse; + return FindWeapon( weapon )->infiniteAmmo; } /* @@ -3437,17 +2706,7 @@ BG_FindUsesEnergyForWeapon */ qboolean BG_FindUsesEnergyForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].usesEnergy; - } - } - - return qfalse; + return FindWeapon( weapon )->usesEnergy; } /* @@ -3457,15 +2716,7 @@ BG_FindRepeatRate1ForWeapon */ int BG_FindRepeatRate1ForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - return bg_weapons[ i ].repeatRate1; - } - - return 1000; + return FindWeapon( weapon )->repeatRate1; } /* @@ -3475,15 +2726,7 @@ BG_FindRepeatRate2ForWeapon */ int BG_FindRepeatRate2ForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - return bg_weapons[ i ].repeatRate2; - } - - return 1000; + return FindWeapon( weapon )->repeatRate2; } /* @@ -3493,15 +2736,7 @@ BG_FindRepeatRate3ForWeapon */ int BG_FindRepeatRate3ForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - return bg_weapons[ i ].repeatRate3; - } - - return 1000; + return FindWeapon( weapon )->repeatRate3; } /* @@ -3511,17 +2746,7 @@ BG_FindReloadTimeForWeapon */ int BG_FindReloadTimeForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].reloadTime; - } - } - - return 1000; + return FindWeapon( weapon )->reloadTime; } /* @@ -3531,17 +2756,7 @@ BG_FindKnockbackScaleForWeapon */ float BG_FindKnockbackScaleForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].knockbackScale; - } - } - - return 1.0f; + return FindWeapon( weapon )->knockbackScale; } /* @@ -3551,17 +2766,7 @@ BG_WeaponHasAltMode */ qboolean BG_WeaponHasAltMode( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].hasAltMode; - } - } - - return qfalse; + return FindWeapon( weapon )->hasAltMode; } /* @@ -3571,17 +2776,7 @@ BG_WeaponHasThirdMode */ qboolean BG_WeaponHasThirdMode( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].hasThirdMode; - } - } - - return qfalse; + return FindWeapon( weapon )->hasThirdMode; } /* @@ -3591,17 +2786,7 @@ BG_WeaponCanZoom */ qboolean BG_WeaponCanZoom( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].canZoom; - } - } - - return qfalse; + return FindWeapon( weapon )->canZoom; } /* @@ -3611,17 +2796,7 @@ BG_FindZoomFovForWeapon */ float BG_FindZoomFovForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].zoomFov; - } - } - - return qfalse; + return FindWeapon( weapon )->zoomFov; } /* @@ -3631,17 +2806,7 @@ BG_FindPurchasableForWeapon */ qboolean BG_FindPurchasableForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].purchasable; - } - } - - return qfalse; + return FindWeapon( weapon )->purchasable; } /* @@ -3651,17 +2816,7 @@ BG_FindLongRangeForWeapon */ qboolean BG_FindLongRangedForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].longRanged; - } - } - - return qfalse; + return FindWeapon( weapon )->longRanged; } /* @@ -3671,17 +2826,7 @@ BG_FindBuildDelayForWeapon */ int BG_FindBuildDelayForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].buildDelay; - } - } - - return 0; + return FindWeapon( weapon )->buildDelay; } /* @@ -3691,17 +2836,7 @@ BG_FindTeamForWeapon */ WUTeam_t BG_FindTeamForWeapon( int weapon ) { - int i; - - for( i = 0; i < bg_numWeapons; i++ ) - { - if( bg_weapons[ i ].weaponNum == weapon ) - { - return bg_weapons[ i ].team; - } - } - - return WUT_NONE; + return FindWeapon( weapon )->team; } //////////////////////////////////////////////////////////////////////////////// @@ -3709,6 +2844,9 @@ WUTeam_t BG_FindTeamForWeapon( int weapon ) upgradeAttributes_t bg_upgrades[ ] = { { + UP_NONE, + }, + { UP_LIGHTARMOUR, //int upgradeNum; LIGHTARMOUR_PRICE, //int price; ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages @@ -3806,7 +2944,13 @@ upgradeAttributes_t bg_upgrades[ ] = } }; -int bg_numUpgrades = sizeof( bg_upgrades ) / sizeof( bg_upgrades[ 0 ] ); +static inline upgradeAttributes_t *FindUpgrade( int index ) +{ + if( index < UP_NONE || index >= UP_NUM_UPGRADES ) + Com_Error( ERR_FATAL, "Invalid index in FindUpgrade: %i\n", index); + + return bg_upgrades + index; +} /* ============== @@ -3815,17 +2959,7 @@ BG_FindPriceForUpgrade */ int BG_FindPriceForUpgrade( int upgrade ) { - int i; - - for( i = 0; i < bg_numUpgrades; i++ ) - { - if( bg_upgrades[ i ].upgradeNum == upgrade ) - { - return bg_upgrades[ i ].price; - } - } - - return 100; + return FindUpgrade( upgrade )->price; } /* @@ -3835,20 +2969,7 @@ BG_FindStagesForUpgrade */ qboolean BG_FindStagesForUpgrade( int upgrade, stage_t stage ) { - int i; - - for( i = 0; i < bg_numUpgrades; i++ ) - { - if( bg_upgrades[ i ].upgradeNum == upgrade ) - { - if( bg_upgrades[ i ].stages & ( 1 << stage ) ) - return qtrue; - else - return qfalse; - } - } - - return qfalse; + return !!( FindUpgrade( upgrade )->stages & ( 1 << stage ) ); } /* @@ -3858,17 +2979,7 @@ BG_FindSlotsForUpgrade */ int BG_FindSlotsForUpgrade( int upgrade ) { - int i; - - for( i = 0; i < bg_numUpgrades; i++ ) - { - if( bg_upgrades[ i ].upgradeNum == upgrade ) - { - return bg_upgrades[ i ].slots; - } - } - - return SLOT_NONE; + return FindUpgrade( upgrade )->slots; } /* @@ -3878,16 +2989,7 @@ BG_FindNameForUpgrade */ char *BG_FindNameForUpgrade( int upgrade ) { - int i; - - for( i = 0; i < bg_numUpgrades; i++ ) - { - if( bg_upgrades[ i ].upgradeNum == upgrade ) - return bg_upgrades[ i ].upgradeName; - } - - //wimp out - return 0; + return FindUpgrade( upgrade )->upgradeName; } /* @@ -3899,7 +3001,7 @@ int BG_FindUpgradeNumForName( char *name ) { int i; - for( i = 0; i < bg_numUpgrades; i++ ) + for( i = 0; i < UP_NUM_UPGRADES; i++ ) { if( !Q_stricmp( bg_upgrades[ i ].upgradeName, name ) ) return bg_upgrades[ i ].upgradeNum; @@ -3916,16 +3018,7 @@ BG_FindHumanNameForUpgrade */ char *BG_FindHumanNameForUpgrade( int upgrade ) { - int i; - - for( i = 0; i < bg_numUpgrades; i++ ) - { - if( bg_upgrades[ i ].upgradeNum == upgrade ) - return bg_upgrades[ i ].upgradeHumanName; - } - - //wimp out - return 0; + return FindUpgrade( upgrade )->upgradeHumanName; } /* @@ -3935,16 +3028,7 @@ BG_FindIconForUpgrade */ char *BG_FindIconForUpgrade( int upgrade ) { - int i; - - for( i = 0; i < bg_numUpgrades; i++ ) - { - if( bg_upgrades[ i ].upgradeNum == upgrade ) - return bg_upgrades[ i ].icon; - } - - //wimp out - return 0; + return FindUpgrade( upgrade )->icon; } /* @@ -3954,15 +3038,7 @@ BG_FindPurchasableForUpgrade */ qboolean BG_FindPurchasableForUpgrade( int upgrade ) { - int i; - - for( i = 0; i < bg_numUpgrades; i++ ) - { - if( bg_upgrades[ i ].upgradeNum == upgrade ) - return bg_upgrades[ i ].purchasable; - } - - return qfalse; + return FindUpgrade( upgrade )->purchasable; } /* @@ -3972,15 +3048,7 @@ BG_FindUsableForUpgrade */ qboolean BG_FindUsableForUpgrade( int upgrade ) { - int i; - - for( i = 0; i < bg_numUpgrades; i++ ) - { - if( bg_upgrades[ i ].upgradeNum == upgrade ) - return bg_upgrades[ i ].usable; - } - - return qfalse; + return FindUpgrade( upgrade )->usable; } /* @@ -3990,17 +3058,7 @@ BG_FindTeamForUpgrade */ WUTeam_t BG_FindTeamForUpgrade( int upgrade ) { - int i; - - for( i = 0; i < bg_numUpgrades; i++ ) - { - if( bg_upgrades[ i ].upgradeNum == upgrade ) - { - return bg_upgrades[ i ].team; - } - } - - return WUT_NONE; + return FindUpgrade( upgrade )->team; } //////////////////////////////////////////////////////////////////////////////// @@ -5263,7 +4321,7 @@ void BG_MOD_update( void ) if( updated ) return; updated = qtrue; - for( i = 0; i < bg_numBuildables; i++ ) + for( i = 0; i < BA_NUM_BUILDABLES; i++ ) { if( modEntry[ MOD_BG_BUILDABLE_HEALTH ] ) { @@ -5285,7 +4343,7 @@ void BG_MOD_update( void ) } } - for( i = 0; i < bg_numPclasses; i++ ) + for( i = 0; i < PCL_NUM_CLASSES; i++ ) { if( bg_classList[ i ].classNum == PCL_HUMAN || bg_classList[ i ].classNum == PCL_HUMAN_BSUIT ) @@ -5304,7 +4362,7 @@ void BG_MOD_update( void ) } } - for( i = 0; i < bg_numWeapons; i++ ) + for( i = 0; i < WP_NUM_WEAPONS; i++ ) { if( modEntry[ MOD_BG_WEAPON_AMMO ] && bg_weapons[ i ].weaponNum != WP_ALEVEL3_UPG ) |