diff --git a/docs/rh-log.txt b/docs/rh-log.txt index b2733cb1aa..c939d9437b 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,8 @@ -August 3, 2009 (Changes by Graf Zahl) +August 4, 2009 +- Fixed: FWeaponSlot::PickWeapon() wrapped around improperly when the starting + value for i was 0. + +August 3, 2009 (Changes by Graf Zahl) - Added kgsws's SummonActor enhancement and bumped netgame and demo versions because this submission changes an existing command. diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 152a4a110a..d4fb4ec5ce 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -776,9 +776,9 @@ AWeapon *FWeaponSlot::PickWeapon(player_t *player) player->ReadyWeapon->SisterWeapon != NULL && player->ReadyWeapon->SisterWeapon->GetClass() == Weapons[i].Type)) { - for (j = (unsigned)(i - 1) % Weapons.Size(); + for (j = (i == 0 ? Weapons.Size() - 1 : i - 1); j != i; - j = (unsigned)(j + Weapons.Size() - 1) % Weapons.Size()) // + Weapons.Size is to avoid underflows + j = (j == 0 ? Weapons.Size() - 1 : j - 1)) { AWeapon *weap = static_cast (player->mo->FindInventory(Weapons[j].Type));