From b4f7bd74f46219909dcb116d4448a378edc405b7 Mon Sep 17 00:00:00 2001 From: Theriaca Date: Sat, 26 Jan 2019 07:19:44 +0100 Subject: rewrite and optimize G_OverflowCredits() - now always prioritizes poor players - synchronizes PERS_CREDIT once per loop, instead of constantly additionally, rename: - G_AddCreditToClient -> G_AddFundsToClient - G_OverflowCredits -> G_OverflowFunds - 'credit(s)' parameters -> 'funds' --- src/game/g_cmds.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/game/g_cmds.c') diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 8822d1e..aa80248 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -418,7 +418,7 @@ void Cmd_Give_f( gentity_t *ent ) if( give_all || Q_stricmpn( name, "funds", 5 ) == 0 ) { int credits = give_all ? HUMAN_MAX_CREDITS : atoi( name + 6 ); - G_AddCreditToClient( ent->client, credits, qtrue ); + G_AddFundsToClient( ent->client, credits, qtrue ); } if( give_all || Q_stricmp( name, "stamina" ) == 0 ) @@ -3286,7 +3286,7 @@ void Cmd_Class_f( gentity_t *ent ) ent->client->pers.evolveHealthFraction = 1.0f; //remove credit - G_AddCreditToClient( ent->client, -(short)numLevels, qtrue ); + G_AddFundsToClient( ent->client, -(short)numLevels, qtrue ); ent->client->pers.classSelection = newClass; ClientUserinfoChanged( clientNum, qfalse ); VectorCopy( infestOrigin, ent->s.pos.trBase ); @@ -3976,7 +3976,7 @@ void Cmd_Buy_f( gentity_t *ent ) ent->client->ps.stats[ STAT_MISC ] = 0; //subtract from funds - G_AddCreditToClient( ent->client, -(short)BG_FindPriceForWeapon( weapon ), qfalse ); + G_AddFundsToClient( ent->client, -(short)BG_FindPriceForWeapon( weapon ), qfalse ); } else if( upgrade != UP_NONE ) { @@ -4049,7 +4049,7 @@ void Cmd_Buy_f( gentity_t *ent ) G_GiveClientMaxAmmo( ent, qtrue ); //subtract from funds - G_AddCreditToClient( ent->client, -(short)BG_FindPriceForUpgrade( upgrade ), qfalse ); + G_AddFundsToClient( ent->client, -(short)BG_FindPriceForUpgrade( upgrade ), qfalse ); } else { @@ -4116,7 +4116,7 @@ void Cmd_Sell_f( gentity_t *ent ) BG_RemoveWeaponFromInventory( weapon, ent->client->ps.stats ); //add to funds - G_AddCreditToClient( ent->client, (short)BG_FindPriceForWeapon( weapon ), qfalse ); + G_AddFundsToClient( ent->client, (short)BG_FindPriceForWeapon( weapon ), qfalse ); } //if we have this weapon selected, force a new selection @@ -4140,7 +4140,7 @@ void Cmd_Sell_f( gentity_t *ent ) G_GiveClientMaxAmmo( ent, qtrue ); //add to funds - G_AddCreditToClient( ent->client, (short)BG_FindPriceForUpgrade( upgrade ), qfalse ); + G_AddFundsToClient( ent->client, (short)BG_FindPriceForUpgrade( upgrade ), qfalse ); } } else if( !Q_stricmp( s, "weapons" ) ) @@ -4161,7 +4161,7 @@ void Cmd_Sell_f( gentity_t *ent ) BG_RemoveWeaponFromInventory( i, ent->client->ps.stats ); //add to funds - G_AddCreditToClient( ent->client, (short)BG_FindPriceForWeapon( i ), qfalse ); + G_AddFundsToClient( ent->client, (short)BG_FindPriceForWeapon( i ), qfalse ); } //if we have this weapon selected, force a new selection @@ -4197,7 +4197,7 @@ void Cmd_Sell_f( gentity_t *ent ) } //add to funds - G_AddCreditToClient( ent->client, (short)BG_FindPriceForUpgrade( i ), qfalse ); + G_AddFundsToClient( ent->client, (short)BG_FindPriceForUpgrade( i ), qfalse ); } } } @@ -5030,7 +5030,7 @@ void Cmd_PTRCRestore_f( gentity_t *ent ) // set the correct credit etc. ent->client->ps.persistant[ PERS_CREDIT ] = 0; - G_AddCreditToClient( ent->client, connection->clientCredit, qtrue ); + G_AddFundsToClient( ent->client, connection->clientCredit, qtrue ); ent->client->pers.score = connection->clientScore; ent->client->pers.enterTime = connection->clientEnterTime; } @@ -5298,12 +5298,12 @@ static void Cmd_Ignore_f( gentity_t *ent ) } // transfer credits - G_AddCreditToClient( ent->client, -creds, qfalse ); + G_AddFundsToClient( ent->client, -creds, qfalse ); trap_SendServerCommand( ent-g_entities, va( "print \"share: transferred %d %s to %s^7.\n\"", creds, ( team == PTE_HUMANS ) ? "credits" : "evolvepoints", level.clients[ clientNum ].pers.netname ) ); - G_AddCreditToClient( &(level.clients[ clientNum ]), creds, qtrue ); + G_AddFundsToClient( &(level.clients[ clientNum ]), creds, qtrue ); trap_SendServerCommand( clientNum, va( "print \"You have received %d %s from %s^7.\n\"", creds, ( team == PTE_HUMANS ) ? "credits" : "evolvepoints", @@ -5399,7 +5399,7 @@ static void Cmd_Ignore_f( gentity_t *ent ) new_credits = max; } if( amounts[ i ] ) { - G_AddCreditToClient( &(level.clients[ i ]), amounts[ i ], qtrue ); + G_AddFundsToClient( &(level.clients[ i ]), amounts[ i ], qtrue ); donated = qtrue; value -= amounts[ i ]; if( value < portion ) break; @@ -5408,7 +5408,7 @@ static void Cmd_Ignore_f( gentity_t *ent ) } // transfer funds - G_AddCreditToClient( ent->client, value - total, qtrue ); + G_AddFundsToClient( ent->client, value - total, qtrue ); for( i = 0; i < level.maxclients; i++ ) if( amounts[ i ] ) { trap_SendServerCommand( i, -- cgit