From ea57436f20116f0168678539c593a0d0a49c76f9 Mon Sep 17 00:00:00 2001 From: Theriaca Date: Sat, 26 Jan 2019 16:17:39 +0100 Subject: convert pers.funds to float, remove pers.fractionalCredit --- src/game/g_client.c | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) (limited to 'src/game/g_client.c') diff --git a/src/game/g_client.c b/src/game/g_client.c index ac4a081..5601e3f 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -93,7 +93,7 @@ static void G_OverflowFunds(gclient_t *donor, float funds) { int i; int count = 0; - int max; + float max; gclient_t *clients[MAX_CLIENTS]; if (!g_creditOverflow.integer || !funds) @@ -128,25 +128,17 @@ static void G_OverflowFunds(gclient_t *donor, float funds) if (!funds) break; - if (target->ps.stats[STAT_PTEAM] == PTE_ALIENS) { - buffer = target->pers.funds + target->pers.fractionalCredit + funds - max; - } else { - funds = floor(funds); - buffer = target->pers.funds + funds - max; - } + buffer = target->pers.funds + funds - max; - if (buffer > 0) { + if (buffer > 0) target->pers.funds = max; - target->pers.fractionalCredit = 0.0f; - } else { - target->pers.funds += floor(funds); - target->pers.fractionalCredit += funds - floor(funds); - } + else + target->pers.funds += funds; funds = buffer; // synchronize PERS_CREDIT - target->ps.persistant[PERS_CREDIT] = (int)target->pers.funds; + target->ps.persistant[PERS_CREDIT] = floorf(target->pers.funds); } } @@ -161,32 +153,24 @@ void G_AddFundsToClient(gclient_t *client, float funds, qboolean cap) return; if (cap) { - int max = 0; + float max = 0.0f; float buffer = funds; - if (client->pers.teamSelection == PTE_ALIENS) { + if (client->pers.teamSelection == PTE_ALIENS) max = ALIEN_MAX_KILLS; - client->pers.fractionalCredit += funds; - - if (client->pers.fractionalCredit > 1.0f) { - funds = floor(client->pers.fractionalCredit); - client->pers.fractionalCredit -= funds; - } - } else if (client->pers.teamSelection == PTE_HUMANS) { + else if (client->pers.teamSelection == PTE_HUMANS) max = HUMAN_MAX_CREDITS; - } buffer = client->pers.funds + funds - max; if (buffer > 0) { - G_OverflowFunds(client, buffer + client->pers.fractionalCredit); + G_OverflowFunds(client, buffer); client->pers.funds = max; - client->pers.fractionalCredit = 0.0f; } else { - client->pers.funds += (short)funds; + client->pers.funds += funds; } } else { - client->pers.funds += (short)funds; + client->pers.funds += funds; } if (client->pers.funds < 0) @@ -194,7 +178,7 @@ void G_AddFundsToClient(gclient_t *client, float funds, qboolean cap) // keep PERS_CREDIT in sync if not following if (client->sess.spectatorState != SPECTATOR_FOLLOW) - client->ps.persistant[PERS_CREDIT] = client->pers.funds; + client->ps.persistant[PERS_CREDIT] = floorf(client->pers.funds); } -- cgit