Skip to content

Commit

Permalink
Control Variables: Allow "0" as an item ID
Browse files Browse the repository at this point in the history
Can be used to count how many slots are empty.

Fix #3085
  • Loading branch information
Ghabry committed Sep 13, 2023
1 parent f3a7f1d commit 6f06a33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/game_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,9 @@ void Game_Actor::RemoveWholeEquipment() {
int Game_Actor::GetItemCount(int item_id) {
int number = 0;

if (item_id > 0) {
// quirk: 0 is "no item in slot"
// This can be used to count how many slots are empty
if (item_id >= 0) {
for (int16_t i : GetWholeEquipment()) {
if (item_id == i) {
++number;
Expand Down
2 changes: 1 addition & 1 deletion src/game_party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ int Game_Party::GetItemCount(int item_id) const {

int Game_Party::GetEquippedItemCount(int item_id) const {
int number = 0;
if (item_id > 0) {
if (item_id >= 0) {
for (int i = 0; i < (int) data.party.size(); i++) {
Game_Actor* actor = Main_Data::game_actors->GetActor(data.party[i]);
number += actor->GetItemCount(item_id);
Expand Down

0 comments on commit 6f06a33

Please sign in to comment.