summaryrefslogtreecommitdiff
path: root/src
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
parent0ef49ba324e49ad56f37f770702d3716d9c57471 (diff)
convert pers.funds to float, remove pers.fractionalCredit
Diffstat (limited to 'src')
-rw-r--r--src/game/g_client.c42
-rw-r--r--src/game/g_local.h3
-rw-r--r--src/game/tremulous.h4
3 files changed, 16 insertions, 33 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);
}
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 4d70a33..c701da2 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -408,8 +408,7 @@ typedef struct
// used to save playerState_t values while in SPECTATOR_FOLLOW mode
int score;
- int funds;
- float fractionalCredit; // alien-only
+ float funds;
int ping;
int lastTeamStatus;
diff --git a/src/game/tremulous.h b/src/game/tremulous.h
index f46aea6..1752db9 100644
--- a/src/game/tremulous.h
+++ b/src/game/tremulous.h
@@ -601,8 +601,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define AVG_FALL_DISTANCE ((MIN_FALL_DISTANCE+MAX_FALL_DISTANCE)/2.0f)
#define HUMAN_MAXED 900 //a human with a strong selection of weapons/upgrades
-#define HUMAN_MAX_CREDITS 2000
-#define ALIEN_MAX_KILLS 9
+#define HUMAN_MAX_CREDITS 2000.0f
+#define ALIEN_MAX_KILLS 9.0f
#define ALIEN_MAX_SINGLE_KILLS 3
#define FREEKILL_PERIOD 120000 //msec