[Scummvm-git-logs] scummvm master -> 494fd3bb52e054969eb94ed72dc2d12a6e412fd1
dreammaster
dreammaster at scummvm.org
Sat Mar 31 05:03:19 CEST 2018
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c33fce7ac7 XEEN: Removal of deprecated code
494fd3bb52 XEEN: Fixes for giving items via scripts
Commit: c33fce7ac7445dc9d5a9cf767673ab3abb52bdf6
https://github.com/scummvm/scummvm/commit/c33fce7ac7445dc9d5a9cf767673ab3abb52bdf6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-03-30T21:05:52-04:00
Commit Message:
XEEN: Removal of deprecated code
Changed paths:
engines/xeen/interface.cpp
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index 03e6797..810bfd6 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -261,7 +261,6 @@ void Interface::perform() {
Party &party = *_vm->_party;
Scripts &scripts = *_vm->_scripts;
Sound &sound = *_vm->_sound;
- Spells &spells = *_vm->_spells;
const Common::Rect WAIT_BOUNDS(8, 8, 224, 140);
do {
@@ -523,10 +522,6 @@ void Interface::perform() {
draw3d(true);
}
- Character *c = &party._activeParty[(spells._lastCaster < 0 ||
- spells._lastCaster >= (int)party._activeParty.size()) ?
- (int)party._activeParty.size() - 1 : spells._lastCaster];
-
int result = CastSpell::show(_vm);
if (result == 1) {
Commit: 494fd3bb52e054969eb94ed72dc2d12a6e412fd1
https://github.com/scummvm/scummvm/commit/494fd3bb52e054969eb94ed72dc2d12a6e412fd1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-03-30T23:03:15-04:00
Commit Message:
XEEN: Fixes for giving items via scripts
Changed paths:
engines/xeen/item.cpp
engines/xeen/item.h
engines/xeen/party.cpp
engines/xeen/scripts.cpp
diff --git a/engines/xeen/item.cpp b/engines/xeen/item.cpp
index 871f60b..cb18bd4 100644
--- a/engines/xeen/item.cpp
+++ b/engines/xeen/item.cpp
@@ -66,22 +66,30 @@ AttributeCategory XeenItem::getAttributeCategory() const {
}
const char *XeenItem::getItemName(ItemCategory category, uint id) {
- if (id < 82)
- return Res.ITEM_NAMES[category][id];
-
- const char **questItems = (g_vm->getGameID() == GType_Swords) ? Res.QUEST_ITEM_NAMES_SWORDS : Res.QUEST_ITEM_NAMES;
- switch (category) {
- case CATEGORY_WEAPON:
- return questItems[id - 82];
-
- case CATEGORY_ARMOR:
- return questItems[id - 82 + 35];
-
- case CATEGORY_ACCESSORY:
- return questItems[id - 82 + 35 + 14];
-
- default:
- return questItems[id - 82 + 35 + 14 + 11];
+ if (id < 82) {
+ switch (category) {
+ case CATEGORY_WEAPON:
+ return Res.WEAPON_NAMES[id];
+ case CATEGORY_ARMOR:
+ return Res.ARMOR_NAMES[id - 35];
+ case CATEGORY_ACCESSORY:
+ return Res.ACCESSORY_NAMES[id - 49];
+ default:
+ return Res.MISC_NAMES[id];
+ }
+ } else {
+ const char **questItems = (g_vm->getGameID() == GType_Swords) ? Res.QUEST_ITEM_NAMES_SWORDS : Res.QUEST_ITEM_NAMES;
+
+ switch (category) {
+ case CATEGORY_WEAPON:
+ return questItems[id - 82];
+ case CATEGORY_ARMOR:
+ return questItems[id - 82 + 35];
+ case CATEGORY_ACCESSORY:
+ return questItems[id - 82 + 35 + 14];
+ default:
+ return questItems[id - 82 + 35 + 14 + 11];
+ }
}
}
diff --git a/engines/xeen/item.h b/engines/xeen/item.h
index 0fcfa92..105df0e 100644
--- a/engines/xeen/item.h
+++ b/engines/xeen/item.h
@@ -64,9 +64,17 @@ public:
*/
static const char *getItemName(ItemCategory category, uint id);
public:
+ /**
+ * Constructor
+ */
XeenItem();
/**
+ * Constructor
+ */
+ XeenItem(uint id, int material, int bonusFlags) : _id(id), _material(material), _bonusFlags(bonusFlags) {}
+
+ /**
* Clear the data for the item
*/
void clear();
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp
index 42b45a8..d6ef377 100644
--- a/engines/xeen/party.cpp
+++ b/engines/xeen/party.cpp
@@ -827,7 +827,8 @@ void Party::giveTreasureToCharacter(Character &c, ItemCategory category, int ite
w.update();
events.ipause(5);
- const char *itemName = XeenItem::getItemName(category, treasureItem._id);
+ const char *itemName = XeenItem::getItemName(category, (category == CATEGORY_MISC) ?
+ treasureItem._material : treasureItem._id);
w.writeString(Common::String::format(Res.X_FOUND_Y, c._name.c_str(), itemName));
w.update();
c._items[category].sort();
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index d135a4a..9700047 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -1225,64 +1225,46 @@ bool Scripts::cmdSelectRandomChar(ParamsIterator ¶ms) {
bool Scripts::cmdGiveEnchanted(ParamsIterator ¶ms) {
Party &party = *_vm->_party;
-
+ XeenItem *item;
+ int invIndex;
int id = params.readByte();
- int material = params.readByte();
- int flags = params.readByte();
-
- if (id >= 35) {
- if (id < 49) {
- for (int idx = 0; idx < MAX_TREASURE_ITEMS; ++idx) {
- XeenItem &item = party._treasure._armor[idx];
- if (!item.empty()) {
- item._id = id - 35;
- item._material = material;
- item._bonusFlags = flags;
- party._treasure._hasItems = true;
- break;
- }
- }
- return true;
- } else if (id < 60) {
- for (int idx = 0; idx < MAX_TREASURE_ITEMS; ++idx) {
- XeenItem &item = party._treasure._accessories[idx];
- if (!item.empty()) {
- item._id = id - 49;
- item._material = material;
- item._bonusFlags = flags;
- party._treasure._hasItems = true;
- break;
- }
- }
+ // Get category of item to add
+ ItemCategory cat = CATEGORY_WEAPON;
+ if (id < 35) {
+ } else if (id < 49) {
+ cat = CATEGORY_ARMOR;
+ id -= 35;
+ } else if (id < 60) {
+ cat = CATEGORY_ACCESSORY;
+ id -= 49;
+ } else if (id < 82) {
+ cat = CATEGORY_MISC;
+ id -= 60;
+ } else {
+ party._questItems[id - 82]++;
+ }
- return true;
- } else if (id < 82) {
- for (int idx = 0; idx < MAX_TREASURE_ITEMS; ++idx) {
- XeenItem &item = party._treasure._misc[idx];
- if (!item.empty()) {
- item._id = id;
- item._material = material;
- item._bonusFlags = flags;
- party._treasure._hasItems = true;
- break;
- }
- }
+ // Check for an empty slot
+ for (invIndex = 0, item = party._treasure[cat]; invIndex < MAX_TREASURE_ITEMS && !item->empty(); ++invIndex, ++item)
+ ;
- return true;
- } else {
- party._questItems[id - 82]++;
- }
- }
+ if (invIndex == MAX_TREASURE_ITEMS) {
+ // Treasure category entirely full. Should never happen
+ warning("Treasure category was completely filled up");
+ } else {
+ party._treasure._hasItems = true;
- for (int idx = 0; idx < MAX_TREASURE_ITEMS; ++idx) {
- XeenItem &item = party._treasure._weapons[idx];
- if (!item.empty()) {
- item._id = id;
- item._material = material;
- item._bonusFlags = flags;
- party._treasure._hasItems = true;
- break;
+ if (cat == CATEGORY_MISC) {
+ // Handling of misc items. Note that for them, id actually specifies the material field
+ item->_material = id;
+ item->_id = params.readByte();
+ item->_bonusFlags = (item->_material == 10 || item->_material == 11) ? 1 : _vm->getRandomNumber(3, 10);
+ } else {
+ // Weapons, armor, and accessories
+ item->_id = id;
+ item->_material = params.readByte();
+ item->_bonusFlags = params.readByte();
}
}
More information about the Scummvm-git-logs
mailing list