Skip to content

Commit

Permalink
Filter out items that are not allowed in the assigned item slot. Fixes
Browse files Browse the repository at this point in the history
…#977

Yume2kki has for some reasons a weapon in the weapon slot that is actually a switch.
  • Loading branch information
Ghabry committed Aug 8, 2016
1 parent a3bcafc commit 73af48e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/game_actor.cpp
Expand Up @@ -23,6 +23,7 @@
#include "game_message.h"
#include "game_party.h"
#include "main_data.h"
#include "output.h"
#include "player.h"
#include "rpg_skill.h"
#include "util_macro.h"
Expand Down Expand Up @@ -59,6 +60,23 @@ void Game_Actor::Init() {
SetHp(GetMaxHp());
SetSp(GetMaxSp());
SetExp(exp_list[GetLevel() - 1]);

// Filter out invalid equipment
int eq_types[] = { RPG::Item::Type_weapon,
HasTwoWeapons() ? RPG::Item::Type_weapon : RPG::Item::Type_shield,
RPG::Item::Type_armor,
RPG::Item::Type_helmet,
RPG::Item::Type_accessory
};

for (int i = 0; i < 5; ++i) {
const RPG::Item* item = GetEquipment(i);
if (item && item->type != eq_types[i]) {
Output::Debug("Removing invalid item %d (of type %d) from equipment slot %d (needs type %d)",
item->ID, item->type, i, eq_types[i]);
SetEquipment(i, 0);
}
}
}

void Game_Actor::Fixup() {
Expand Down

0 comments on commit 73af48e

Please sign in to comment.