mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-24 06:21:18 +00:00
Fix code provided by ring-racers!51
It just straight up wasn't functional, and ERRORMODE pointed me to it Make the provideable amount use INT32 so the max/min macros actually do something (but also don't use nested min-maxes just to reduce reliance on macros)
This commit is contained in:
parent
06cf1b914a
commit
4faf85eab4
2 changed files with 22 additions and 12 deletions
26
src/k_kart.c
26
src/k_kart.c
|
|
@ -72,24 +72,34 @@
|
|||
// comeback is Battle Mode's karma comeback, also bool
|
||||
// mapreset is set when enough players fill an empty server
|
||||
|
||||
UINT8 K_SetPlayerItemAmount(player_t *player, UINT8 amount)
|
||||
UINT8 K_SetPlayerItemAmount(player_t *player, INT32 amount)
|
||||
{
|
||||
player->itemamount = max(min(UINT8_MAX, amount), 0);
|
||||
return player->itemamount;
|
||||
if (amount & ~UINT8_MAX)
|
||||
{
|
||||
// having bits outside of valid range means time to cap
|
||||
amount = (amount < 0) ? 0 : UINT8_MAX;
|
||||
}
|
||||
|
||||
return (player->itemamount = amount);
|
||||
}
|
||||
|
||||
UINT8 K_SetPlayerBackupItemAmount(player_t *player, UINT8 amount)
|
||||
UINT8 K_SetPlayerBackupItemAmount(player_t *player, INT32 amount)
|
||||
{
|
||||
player->backupitemamount = max(min(UINT8_MAX, amount), 0);
|
||||
return player->backupitemamount;
|
||||
if (amount & ~UINT8_MAX)
|
||||
{
|
||||
// having bits outside of valid range means time to cap
|
||||
amount = (amount < 0) ? 0 : UINT8_MAX;
|
||||
}
|
||||
|
||||
return (player->backupitemamount = amount);
|
||||
}
|
||||
|
||||
UINT8 K_AdjustPlayerItemAmount(player_t *player, SINT8 amount)
|
||||
UINT8 K_AdjustPlayerItemAmount(player_t *player, INT32 amount)
|
||||
{
|
||||
return K_SetPlayerItemAmount(player, player->itemamount + amount);
|
||||
}
|
||||
|
||||
UINT8 K_AdjustPlayerBackupItemAmount(player_t *player, SINT8 amount)
|
||||
UINT8 K_AdjustPlayerBackupItemAmount(player_t *player, INT32 amount)
|
||||
{
|
||||
return K_SetPlayerBackupItemAmount(player, player->backupitemamount + amount);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,10 +125,10 @@ Make sure this matches the actual number of states
|
|||
#define AUTORESPAWN_TIME (10*TICRATE)
|
||||
#define AUTORESPAWN_THRESHOLD (7*TICRATE)
|
||||
|
||||
UINT8 K_SetPlayerItemAmount(player_t *player, UINT8 amount);
|
||||
UINT8 K_SetPlayerBackupItemAmount(player_t *player, UINT8 amount);
|
||||
UINT8 K_AdjustPlayerItemAmount(player_t *player, SINT8 amount);
|
||||
UINT8 K_AdjustPlayerBackupItemAmount(player_t *player, SINT8 amount);
|
||||
UINT8 K_SetPlayerItemAmount(player_t *player, INT32 amount);
|
||||
UINT8 K_SetPlayerBackupItemAmount(player_t *player, INT32 amount);
|
||||
UINT8 K_AdjustPlayerItemAmount(player_t *player, INT32 amount);
|
||||
UINT8 K_AdjustPlayerBackupItemAmount(player_t *player, INT32 amount);
|
||||
|
||||
angle_t K_ReflectAngle(angle_t angle, angle_t against, fixed_t maxspeed, fixed_t yourspeed);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue