Fix weapon switching

This commit is contained in:
Miloslav Číž 2020-07-26 13:15:06 +02:00
parent 4c3fe7167a
commit 46d7b003de
2 changed files with 4 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

8
main.c
View File

@ -1120,13 +1120,13 @@ void SFG_getPlayerWeaponInfo(
void SFG_playerRotateWeapon(uint8_t next)
{
RCL_Unit initialWeapon = SFG_player.weapon;
RCL_Unit increment = next ? 1 : -1;
uint8_t initialWeapon = SFG_player.weapon;
int8_t increment = next ? 1 : -1;
while (1)
{
SFG_player.weapon =
RCL_wrap(SFG_player.weapon + increment,SFG_WEAPONS_TOTAL);
SFG_player.weapon =
(SFG_WEAPONS_TOTAL + SFG_player.weapon + increment) % SFG_WEAPONS_TOTAL;
if (SFG_player.weapon == initialWeapon)
break;