summaryrefslogtreecommitdiff
path: root/src/game/g_client.c
diff options
context:
space:
mode:
authorTheriaca <reichmeister@protonmail.com>2019-01-26 16:17:39 +0100
committerPaweł Redman <pawel.redman@gmail.com>2019-02-10 14:47:47 +0100
commitea57436f20116f0168678539c593a0d0a49c76f9 (patch)
tree93ebb23deed58f9f4705e7363f12c9e37199d3e1 /src/game/g_client.c
parent0ef49ba324e49ad56f37f770702d3716d9c57471 (diff)
convert pers.funds to float, remove pers.fractionalCredit
Diffstat (limited to 'src/game/g_client.c')
-rw-r--r--src/game/g_client.c42
1 files changed, 13 insertions, 29 deletions
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);
}