Skip to content

Commit

Permalink
XEEN: Fix showing correct names for quest items
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Dec 30, 2017
1 parent 1bc519a commit 7b7a23a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
19 changes: 19 additions & 0 deletions engines/xeen/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@ AttributeCategory XeenItem::getAttributeCategory() const {
return (AttributeCategory)idx;
}

const char *XeenItem::getItemName(ItemCategory category, uint id) {
if (id < 82)
return Res.ITEM_NAMES[category][id];

switch (category) {
case CATEGORY_WEAPON:
return Res.QUEST_ITEM_NAMES[id - 82];

case CATEGORY_ARMOR:
return Res.QUEST_ITEM_NAMES[id - 82 + 35];

case CATEGORY_ACCESSORY:
return Res.QUEST_ITEM_NAMES[id - 82 + 35 + 14];

default:
return Res.QUEST_ITEM_NAMES[id - 82 + 35 + 14 + 11];
}
}

/*------------------------------------------------------------------------*/

InventoryItems::InventoryItems(Character *character, ItemCategory category):
Expand Down
5 changes: 5 additions & 0 deletions engines/xeen/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ class XeenItem {
uint _id;
int _bonusFlags;
int _frame;
public:
/**
* Return the name of the item
*/
static const char *getItemName(ItemCategory category, uint id);
public:
XeenItem();

Expand Down
6 changes: 2 additions & 4 deletions engines/xeen/party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,17 +713,15 @@ void Party::giveTreasureToCharacter(Character &c, ItemCategory category, int ite
if (treasureItem._id < 82) {
// Copy item into the character's inventory
c._items[category][INV_ITEMS_TOTAL - 1] = treasureItem;
c._items[category].sort();
}

w.writeString(Res.GIVE_TREASURE_FORMATTING);
w.update();
events.ipause(5);

w.writeString(Common::String::format(Res.X_FOUND_Y, c._name.c_str(),
Res.ITEM_NAMES[category][treasureItem._id]));
const char *itemName = XeenItem::getItemName(category, treasureItem._id);
w.writeString(Common::String::format(Res.X_FOUND_Y, c._name.c_str(), itemName));
w.update();

events.ipause(5);
}

Expand Down

0 comments on commit 7b7a23a

Please sign in to comment.