Skip to content

Commit

Permalink
negative durability bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wkdgmr committed Oct 8, 2023
1 parent 83d5813 commit 7a5e473
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,22 +596,25 @@ bool DamageWeapon(Player &player, unsigned damageFrequency)
}

player.InvBody[INVLOC_HAND_LEFT]._iDurability--;
if (player.InvBody[INVLOC_HAND_LEFT]._iDurability <= 0) {
CalcPlrInv(player, true);
return true;
if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability <= 0) {
player.InvBody[INVLOC_HAND_RIGHT]._iDurability = 0;
}
CalcPlrInv(player, true);
return true;
}

if (!player.InvBody[INVLOC_HAND_RIGHT].isEmpty() && player.InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON) {
if (!player.InvBody[INVLOC_HAND_RIGHT].isEmpty() && player.InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON
&& !(player.InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND)) {
if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE) {
return false;
}

player.InvBody[INVLOC_HAND_RIGHT]._iDurability--;
if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) {
CalcPlrInv(player, true);
return true;
if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability <= 0) {
player.InvBody[INVLOC_HAND_RIGHT]._iDurability = 0;
}
CalcPlrInv(player, true);
return true;
}

if (player.InvBody[INVLOC_HAND_LEFT].isEmpty() && player.InvBody[INVLOC_HAND_RIGHT]._itype == ItemType::Shield) {
Expand All @@ -620,10 +623,11 @@ bool DamageWeapon(Player &player, unsigned damageFrequency)
}

player.InvBody[INVLOC_HAND_RIGHT]._iDurability--;
if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) {
CalcPlrInv(player, true);
return true;
if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability <= 0) {
player.InvBody[INVLOC_HAND_RIGHT]._iDurability = 0;
}
CalcPlrInv(player, true);
return true;
}

if (player.InvBody[INVLOC_HAND_RIGHT].isEmpty() && player.InvBody[INVLOC_HAND_LEFT]._itype == ItemType::Shield) {
Expand All @@ -632,10 +636,11 @@ bool DamageWeapon(Player &player, unsigned damageFrequency)
}

player.InvBody[INVLOC_HAND_LEFT]._iDurability--;
if (player.InvBody[INVLOC_HAND_LEFT]._iDurability == 0) {
CalcPlrInv(player, true);
return true;
if (player.InvBody[INVLOC_HAND_LEFT]._iDurability <= 0) {
player.InvBody[INVLOC_HAND_RIGHT]._iDurability = 0;
}
CalcPlrInv(player, true);
return true;
}

return false;
Expand Down Expand Up @@ -1315,17 +1320,19 @@ void DamageParryItem(Player &player)
}

player.InvBody[INVLOC_HAND_LEFT]._iDurability--;
if (player.InvBody[INVLOC_HAND_LEFT]._iDurability == 0) {
CalcPlrInv(player, true);
if (player.InvBody[INVLOC_HAND_LEFT]._iDurability <= 0) {
player.InvBody[INVLOC_HAND_RIGHT]._iDurability = 0;
}
CalcPlrInv(player, true);
}

if (player.InvBody[INVLOC_HAND_RIGHT]._itype == ItemType::Shield) {
if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability != DUR_INDESTRUCTIBLE) {
player.InvBody[INVLOC_HAND_RIGHT]._iDurability--;
if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) {
CalcPlrInv(player, true);
if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability <= 0) {
player.InvBody[INVLOC_HAND_RIGHT]._iDurability = 0;
}
CalcPlrInv(player, true);
}
}
}
Expand Down

0 comments on commit 7a5e473

Please sign in to comment.