From 73af48ee013d87d0c39a07393ac912219b836aff Mon Sep 17 00:00:00 2001 From: Ghabry Date: Sun, 7 Aug 2016 14:09:51 +0200 Subject: [PATCH] Filter out items that are not allowed in the assigned item slot. Fixes #977 Yume2kki has for some reasons a weapon in the weapon slot that is actually a switch. --- src/game_actor.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/game_actor.cpp b/src/game_actor.cpp index 08f3841a2f..e2ad5edbec 100644 --- a/src/game_actor.cpp +++ b/src/game_actor.cpp @@ -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" @@ -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() {