diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2019-02-10 14:55:05 +0100 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2019-02-10 14:55:05 +0100 |
commit | b07b3edda86a6739191334b231537165b139f2e5 (patch) | |
tree | c6ba3193b6c699b3cb5379aec2808a4e248d9461 | |
parent | 572c7ab1f9208850fc7a5e0ce1991e2e96e7b01d (diff) |
Refactor G_AddFundsToClient.
-rw-r--r-- | src/game/g_client.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/src/game/g_client.c b/src/game/g_client.c index 0eafac0..b8b4968 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -149,36 +149,30 @@ G_AddFundsToClient */ void G_AddFundsToClient(gclient_t *client, float funds, qboolean cap) { - if (!client || funds == 0) - return; - - if (cap) { - float max = 0.0f; - float buffer = funds; + if (!client) + return; - if (client->pers.teamSelection == PTE_ALIENS) - max = ALIEN_MAX_KILLS; - else if (client->pers.teamSelection == PTE_HUMANS) - max = HUMAN_MAX_CREDITS; + client->pers.funds += funds; + if (client->pers.funds < 0) + client->pers.funds = 0; - buffer = client->pers.funds + funds - max; + if (cap) { + float max; - if (buffer > 0) { - G_OverflowFunds(client, buffer); - client->pers.funds = max; - } else { - client->pers.funds += funds; - } - } else { - client->pers.funds += funds; - } + if (client->pers.teamSelection == PTE_ALIENS) + max = ALIEN_MAX_KILLS; + else + max = HUMAN_MAX_CREDITS; - if (client->pers.funds < 0) - client->pers.funds = 0; + if (client->pers.funds > max) { + G_OverflowFunds(client, client->pers.funds - max); + client->pers.funds = max; + } + } - // keep PERS_CREDIT in sync if not following - if (client->sess.spectatorState != SPECTATOR_FOLLOW) - client->ps.persistant[PERS_CREDIT] = floorf(client->pers.funds); + // keep PERS_CREDIT in sync if not following + if (client->sess.spectatorState != SPECTATOR_FOLLOW) + client->ps.persistant[PERS_CREDIT] = floorf(client->pers.funds); } |