summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_draw.c6
-rw-r--r--src/cgame/cg_event.c2
-rw-r--r--src/game/bg_misc.c21
-rw-r--r--src/game/bg_public.h12
-rw-r--r--src/game/g_client.c5
-rw-r--r--src/game/g_cmds.c68
-rw-r--r--src/game/g_combat.c2
-rw-r--r--src/ui/ui_main.c2
8 files changed, 66 insertions, 52 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index e7c91762..42eebdbe 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -327,7 +327,7 @@ static void CG_DrawPlayerCreditsValue( rectDef_t *rect, vec4_t color )
ps = &cg.snap->ps;
- value = ps->stats[ STAT_CREDIT ];
+ value = ps->persistant[ PERS_CREDIT ];
if( value > -1 )
{
trap_R_SetColor( color );
@@ -343,7 +343,7 @@ static void CG_DrawPlayerBankValue( rectDef_t *rect, vec4_t color )
ps = &cg.snap->ps;
- value = ps->stats[ STAT_BANK ];
+ value = ps->persistant[ PERS_BANK ];
if( value > -1 )
{
trap_R_SetColor( color );
@@ -993,7 +993,7 @@ CG_DrawStatusBar
}
//display amount of credit
- s = va( "%dg", ps->stats[ STAT_CREDIT ] );
+ s = va( "%dg", ps->stats[ PERS_CREDIT ] );
w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
CG_DrawBigString( 635 - w, 35, s, 1.0F);
}
diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c
index dafcfde6..f0b747b0 100644
--- a/src/cgame/cg_event.c
+++ b/src/cgame/cg_event.c
@@ -538,7 +538,7 @@ void CG_Menu( int eventParm )
case MN_A_INFEST:
trap_Cvar_Set( "ui_currentClass", va( "%d %d", cg.snap->ps.stats[ STAT_PCLASS ],
- cg.snap->ps.stats[ STAT_CREDIT ] ) );
+ cg.snap->ps.persistant[ PERS_CREDIT ] ) );
trap_SendConsoleCommand( "menu tremulous_alienupgrade\n" );
break;
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index 3f36f2a9..9f0d2ff4 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -1893,16 +1893,16 @@ float BG_FindBuildDistForClass( int pclass )
BG_ClassCanEvolveFromTo
==============
*/
-qboolean BG_ClassCanEvolveFromTo( int fclass, int tclass, int credits )
+int BG_ClassCanEvolveFromTo( int fclass, int tclass, int credits, int num )
{
int i, j;
//base case
if( credits + 1 == 0 )
- return qfalse;
+ return 0;
if( tclass == PCL_NONE )
- return qfalse;
+ return 0;
for( i = 0; i < bg_numPclasses; i++ )
{
@@ -1910,18 +1910,21 @@ qboolean BG_ClassCanEvolveFromTo( int fclass, int tclass, int credits )
{
for( j = 0; j <= 3; j++ )
if( bg_classList[ i ].children[ j ] == tclass )
- return qtrue;
+ return num + 1;
for( j = 0; j <= 3; j++ )
- if( BG_ClassCanEvolveFromTo( bg_classList[ i ].children[ j ],
- tclass, credits - 1 ) == qtrue )
- return qtrue;
+ {
+ int sub = BG_ClassCanEvolveFromTo( bg_classList[ i ].children[ j ],
+ tclass, credits - 1, num + 1 );
+ if( sub )
+ return sub;
+ }
- return qfalse; //may as well return by this point
+ return 0; //may as well return by this point
}
}
- return qfalse;
+ return 0;
}
/*
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index ac0c0b0d..84e82148 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -223,8 +223,6 @@ typedef enum {
STAT_PTEAM, //TA: player team
STAT_STAMINA, //TA: stamina (human only)
STAT_STATE, //TA: client states e.g. wall climbing
- STAT_CREDIT, //TA: human credit
- STAT_BANK, //TA: human credit in the bank
STAT_MISC, //TA: for uh...misc stuff
STAT_BUILDABLE //TA: which ghost model to display for building
} statIndex_t;
@@ -267,7 +265,9 @@ typedef enum {
PERS_KILLED, // count of the number of times you died
//TA:
- PERS_STATE
+ PERS_STATE,
+ PERS_CREDIT, //TA: human credit
+ PERS_BANK //TA: human credit in the bank
} persEnum_t;
#define PS_WALLCLIMBINGFOLLOW 0x00000001
@@ -715,9 +715,9 @@ typedef enum {
// How many players on the overlay
#define TEAM_MAXOVERLAY 32
-//FIXME: switch to enums at some point
//TA: player classes
-typedef enum {
+typedef enum
+{
PCL_NONE,
//builder classes
@@ -1016,7 +1016,7 @@ float BG_FindStickyForClass( int pclass );
int BG_FindSteptimeForClass( int pclass );
qboolean BG_ClassHasAbility( int pclass, int ability );
float BG_FindBuildDistForClass( int pclass );
-qboolean BG_ClassCanEvolveFromTo( int fclass, int tclass, int credits );
+int BG_ClassCanEvolveFromTo( int fclass, int tclass, int credits, int num );
int BG_FindEvolveTimeForClass( int pclass );
int BG_FindValueOfClass( int pclass );
diff --git a/src/game/g_client.c b/src/game/g_client.c
index b814aa47..0d21a686 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -634,7 +634,7 @@ void useBody( gentity_t *self, gentity_t *other, gentity_t *activator )
for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ )
{
if( BG_ClassCanEvolveFromTo( activator->client->ps.stats[ STAT_PCLASS ],
- i, activator->client->ps.stats[ STAT_CREDIT ] ) &&
+ i, activator->client->ps.persistant[ PERS_CREDIT ], 0 ) &&
BG_FindStagesForClass( i, g_alienStage.integer ) )
break;
}
@@ -1421,7 +1421,8 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn )
client->ps.stats[ STAT_SLOTS ] = 0;
//no credit
- client->ps.stats[ STAT_CREDIT ] = 0;
+ if( !spawn )
+ client->ps.persistant[ PERS_CREDIT ] = 0;
client->ps.eFlags = flags;
client->ps.clientNum = index;
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index a3f5325e..c8e26489 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -259,7 +259,7 @@ void Cmd_Give_f (gentity_t *ent)
if( give_all || Q_stricmp( name, "funds" ) == 0 )
{
- ent->client->ps.stats[ STAT_CREDIT ] += 100;
+ ent->client->ps.persistant[ PERS_CREDIT ] += 123;
if( !give_all )
return;
@@ -629,7 +629,7 @@ void Cmd_Team_f( gentity_t *ent )
if( oldTeam != ent->client->pers.pteam )
{
level.bankCredits[ ent->client->ps.clientNum ] = 0;
- ent->client->ps.stats[ STAT_BANK ] = 0;
+ ent->client->ps.persistant[ PERS_BANK ] = 0;
ent->client->pers.pclass = 0;
ClientSpawn( ent, NULL );
}
@@ -1566,6 +1566,7 @@ void Cmd_Class_f( gentity_t *ent )
vec3_t infestOrigin, infestAngles;
int allowedClasses[ NUM_AC ] = { PCL_A_B_BASE,
PCL_A_O_BASE };
+ int numLevels;
clientNum = ent->client - level.clients;
trap_Argv( 1, s, sizeof( s ) );
@@ -1596,7 +1597,7 @@ void Cmd_Class_f( gentity_t *ent )
if( !Q_stricmp( s, "store" ) )
{
//increment credits
- ent->client->ps.stats[ STAT_CREDIT ]++;
+ ent->client->ps.persistant[ PERS_CREDIT ]++;
//destroy body
G_AddEvent( victim, EV_GIB_ALIEN, DirToByte( up ) );
@@ -1613,11 +1614,15 @@ void Cmd_Class_f( gentity_t *ent )
return;
}
+ numLevels = BG_ClassCanEvolveFromTo( ent->client->ps.stats[ STAT_PCLASS ], ent->client->pers.pclass,
+ ent->client->ps.persistant[ PERS_CREDIT ], 0 );
+
//...check we can evolve to that class
- if( BG_ClassCanEvolveFromTo( ent->client->ps.stats[ STAT_PCLASS ],
- ent->client->pers.pclass, ent->client->ps.stats[ STAT_CREDIT ] ) ||
- BG_FindStagesForClass( ent->client->pers.pclass, g_alienStage.integer ) )
+ if( numLevels && BG_FindStagesForClass( ent->client->pers.pclass, g_alienStage.integer ) )
{
+ //remove credit
+ ent->client->ps.persistant[ PERS_CREDIT ] -= numLevels - 1;
+
//prevent lerping
ent->client->ps.eFlags ^= EF_TELEPORT_BIT;
@@ -1883,7 +1888,7 @@ void Cmd_Buy_f( gentity_t *ent )
}
//can afford this?
- if( BG_FindPriceForWeapon( weapon ) > ent->client->ps.stats[ STAT_CREDIT ] )
+ if( BG_FindPriceForWeapon( weapon ) > ent->client->ps.persistant[ PERS_CREDIT ] )
{
G_AddPredictableEvent( ent, EV_MENU, MN_H_NOFUNDS );
return;
@@ -1930,7 +1935,7 @@ void Cmd_Buy_f( gentity_t *ent )
ent->client->ps.weapon = weapon;
//subtract from funds
- ent->client->ps.stats[ STAT_CREDIT ] -= BG_FindPriceForWeapon( weapon );
+ ent->client->ps.persistant[ PERS_CREDIT ] -= BG_FindPriceForWeapon( weapon );
}
else if( upgrade != UP_NONE )
{
@@ -1942,7 +1947,7 @@ void Cmd_Buy_f( gentity_t *ent )
}
//can afford this?
- if( BG_FindPriceForUpgrade( upgrade ) > ent->client->ps.stats[ STAT_CREDIT ] )
+ if( BG_FindPriceForUpgrade( upgrade ) > ent->client->ps.persistant[ PERS_CREDIT ] )
{
G_AddPredictableEvent( ent, EV_MENU, MN_H_NOFUNDS );
return;
@@ -1973,7 +1978,7 @@ void Cmd_Buy_f( gentity_t *ent )
BG_packItem( upgrade, ent->client->ps.stats );
//subtract from funds
- ent->client->ps.stats[ STAT_CREDIT ] -= BG_FindPriceForUpgrade( upgrade );
+ ent->client->ps.persistant[ PERS_CREDIT ] -= BG_FindPriceForUpgrade( upgrade );
}
else
{
@@ -2035,7 +2040,7 @@ void Cmd_Sell_f( gentity_t *ent )
BG_removeWeapon( weapon, ent->client->ps.stats );
//add to funds
- ent->client->ps.stats[ STAT_CREDIT ] += BG_FindPriceForWeapon( weapon );
+ ent->client->ps.persistant[ PERS_CREDIT ] += BG_FindPriceForWeapon( weapon );
}
}
else if( upgrade != UP_NONE )
@@ -2046,7 +2051,7 @@ void Cmd_Sell_f( gentity_t *ent )
BG_removeItem( upgrade, ent->client->ps.stats );
//add to funds
- ent->client->ps.stats[ STAT_CREDIT ] += BG_FindPriceForUpgrade( upgrade );
+ ent->client->ps.persistant[ PERS_CREDIT ] += BG_FindPriceForUpgrade( upgrade );
}
}
else
@@ -2063,7 +2068,7 @@ Cmd_Statement_f
void Cmd_Statement_f( gentity_t *ent )
{
trap_SendServerCommand( ent-g_entities, va("print \"Credits: %d\n\"",
- ent->client->ps.stats[ STAT_CREDIT ] ) );
+ ent->client->ps.persistant[ PERS_CREDIT ] ) );
}
/*
@@ -2098,7 +2103,7 @@ void Cmd_Deposit_f( gentity_t *ent )
}
if( !Q_stricmp( s, "all" ) )
- amount = ent->client->ps.stats[ STAT_CREDIT ];
+ amount = ent->client->ps.persistant[ PERS_CREDIT ];
else
amount = atoi( s );
@@ -2109,10 +2114,10 @@ void Cmd_Deposit_f( gentity_t *ent )
return;
}
- if( amount <= ent->client->ps.stats[ STAT_CREDIT ] )
+ if( amount <= ent->client->ps.persistant[ PERS_CREDIT ] )
{
- ent->client->ps.stats[ STAT_CREDIT ] -= amount;
- ent->client->ps.stats[ STAT_BANK ] += amount;
+ ent->client->ps.persistant[ PERS_CREDIT ] -= amount;
+ ent->client->ps.persistant[ PERS_BANK ] += amount;
level.bankCredits[ ent->client->ps.clientNum ] += amount;
}
else
@@ -2134,7 +2139,7 @@ void Cmd_Deposit_f( gentity_t *ent )
}
if( !Q_stricmp( s, "all" ) )
- amount = ent->client->ps.stats[ STAT_CREDIT ];
+ amount = ent->client->ps.persistant[ PERS_CREDIT ];
else
amount = atoi( s );
@@ -2145,10 +2150,10 @@ void Cmd_Deposit_f( gentity_t *ent )
return;
}
- if( amount <= ent->client->ps.stats[ STAT_CREDIT ] )
+ if( amount <= ent->client->ps.persistant[ PERS_CREDIT ] )
{
- ent->client->ps.stats[ STAT_CREDIT ] -= amount;
- ent->client->ps.stats[ STAT_BANK ] += amount;
+ ent->client->ps.persistant[ PERS_CREDIT ] -= amount;
+ ent->client->ps.persistant[ PERS_BANK ] += amount;
level.bankCredits[ ent->client->ps.clientNum ] += amount;
}
else
@@ -2202,8 +2207,8 @@ void Cmd_Withdraw_f( gentity_t *ent )
if( amount <= level.bankCredits[ ent->client->ps.clientNum ] )
{
- ent->client->ps.stats[ STAT_CREDIT ] += amount;
- ent->client->ps.stats[ STAT_BANK ] -= amount;
+ ent->client->ps.persistant[ PERS_CREDIT ] += amount;
+ ent->client->ps.persistant[ PERS_BANK ] -= amount;
level.bankCredits[ ent->client->ps.clientNum ] -= amount;
}
else
@@ -2238,8 +2243,8 @@ void Cmd_Withdraw_f( gentity_t *ent )
if( amount <= level.bankCredits[ ent->client->ps.clientNum ] )
{
- ent->client->ps.stats[ STAT_CREDIT ] += amount;
- ent->client->ps.stats[ STAT_BANK ] -= amount;
+ ent->client->ps.persistant[ PERS_CREDIT ] += amount;
+ ent->client->ps.persistant[ PERS_BANK ] -= amount;
level.bankCredits[ ent->client->ps.clientNum ] -= amount;
}
else
@@ -2382,10 +2387,15 @@ void Cmd_Spawnbody_f( gentity_t *ent )
/*void Cmd_Test_f( gentity_t *ent )
{
- if( level.alienKills < 50 )
- level.alienKills = 50;
- else if( level.alienKills < 100 )
- level.alienKills = 100;
+ char s[ MAX_TOKEN_CHARS ];
+ int a, b, c;
+
+ trap_Argv( 1, s, sizeof( s ) );
+ a = atoi( s );
+ trap_Argv( 2, s, sizeof( s ) );
+ b = atoi( s );
+
+ G_Printf( "%d\n", BG_ClassCanEvolveFromTo( a, b, 10000, 0 ) );
}*/
/*
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index de6a3950..f4bae54b 100644
--- a/src/game/g_combat.c
+++ b/src/game/g_combat.c
@@ -371,7 +371,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
numerator = self->credits[ i ];
//add credit
- player->client->ps.stats[ STAT_CREDIT ] += (int)( (float)classValue * ( numerator / denominator ) );
+ player->client->ps.persistant[ PERS_CREDIT ] += (int)( (float)classValue * ( numerator / denominator ) );
}
}
}
diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c
index 63cbbe04..55da8aa9 100644
--- a/src/ui/ui_main.c
+++ b/src/ui/ui_main.c
@@ -3078,7 +3078,7 @@ static void UI_LoadTremAlienUpgrades( )
for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ )
{
- if( BG_ClassCanEvolveFromTo( class, i, credits ) &&
+ if( BG_ClassCanEvolveFromTo( class, i, credits, 0 ) &&
BG_FindStagesForClass( i, stage ) )
{
uiInfo.tremAlienUpgradeList[ j ].text = String_Alloc( BG_FindNameForClassNum( i ) );