[Scummvm-git-logs] scummvm master -> 27c3e44551870339cd9709f06d8200933d4406f5

dreammaster dreammaster at scummvm.org
Sat Dec 30 03:45:09 CET 2017


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d0c04053dd XEEN: Fix intermittant crash leaving Dwarf Mine
8f8166236c XEEN: Simplify itemScan method
27c3e44551 XEEN: Comments for the Character class methods


Commit: d0c04053dd2acce2a9afa675099d304cbf7c9a70
    https://github.com/scummvm/scummvm/commit/d0c04053dd2acce2a9afa675099d304cbf7c9a70
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-12-29T21:16:11-05:00

Commit Message:
XEEN: Fix intermittant crash leaving Dwarf Mine

Changed paths:
    engines/xeen/scripts.cpp


diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index 74b7eb3..59e12f6 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -468,7 +468,8 @@ bool Scripts::cmdTeleport(ParamsIterator &params) {
 	Sound &sound = *_vm->_sound;
 
 	windows.closeAll();
-
+	
+	bool restartFlag = _event->_opcode == OP_TeleportAndContinue;
 	int mapId = params.readByte();
 	Common::Point pt;
 
@@ -519,11 +520,13 @@ bool Scripts::cmdTeleport(ParamsIterator &params) {
 
 	events.clearEvents();
 
-	if (_event->_opcode == OP_TeleportAndContinue) {
+	if (restartFlag) {
+		// Draw the new location and start any script at that location
 		intf.draw3d(true);
 		_lineNum = 0;
 		return true;
 	} else {
+		// Stop executing the script
 		return cmdExit(params);
 	}
 }


Commit: 8f8166236c7aa9c37868131ccf0fb77e40655d4b
    https://github.com/scummvm/scummvm/commit/8f8166236c7aa9c37868131ccf0fb77e40655d4b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-12-29T21:29:40-05:00

Commit Message:
XEEN: Simplify itemScan method

Changed paths:
    engines/xeen/character.cpp


diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index 67760ce..e68cb19 100644
--- a/engines/xeen/character.cpp
+++ b/engines/xeen/character.cpp
@@ -1125,87 +1125,80 @@ uint Character::getCurrentLevel() const {
 int Character::itemScan(int itemId) const {
 	int result = 0;
 
-	for (int accessIdx = 0; accessIdx < 3; ++accessIdx) {
-		switch (accessIdx) {
-		case 0:
-			for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) {
-				const XeenItem &item = _weapons[idx];
+	// Weapons
+	for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) {
+		const XeenItem &item = _weapons[idx];
 
-				if (item._frame && !(item._bonusFlags & 0xC0) && itemId < 11
-						&& itemId != 3 && item._material >= 59 && item._material <= 130) {
-					int mIndex = (int)item.getAttributeCategory();
-					if (mIndex > PERSONALITY)
-						++mIndex;
+		if (item._frame && !(item._bonusFlags & 0xC0) && itemId < 11
+				&& itemId != 3 && item._material >= 59 && item._material <= 130) {
+			int mIndex = (int)item.getAttributeCategory();
+			if (mIndex > PERSONALITY)
+				++mIndex;
 
-					if (mIndex == itemId)
-						result += Res.ATTRIBUTE_BONUSES[item._material - 59];
-				}
+			if (mIndex == itemId)
+				result += Res.ATTRIBUTE_BONUSES[item._material - 59];
+		}
+	}
+
+	// Armor
+	for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) {
+		const XeenItem &item = _armor[idx];
+
+		if (item._frame && !(item._bonusFlags & 0xC0)) {
+			if (itemId < 11 && itemId != 3 && item._material >= 59 && item._material <= 130) {
+				int mIndex = (int)item.getAttributeCategory();
+				if (mIndex > PERSONALITY)
+					++mIndex;
+
+				if (mIndex == itemId)
+					result += Res.ATTRIBUTE_BONUSES[item._material - 59];
 			}
-			break;
 
-		case 1:
-			for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) {
-				const XeenItem &item = _armor[idx];
+			if (itemId > 10 && item._material < 37) {
+				int mIndex = item.getElementalCategory() + 11;
 
-				if (item._frame && !(item._bonusFlags & 0xC0)) {
-					if (itemId < 11 && itemId != 3 && item._material >= 59 && item._material <= 130) {
-						int mIndex = (int)item.getAttributeCategory();
-						if (mIndex > PERSONALITY)
-							++mIndex;
+				if (mIndex == itemId) {
+					result += Res.ELEMENTAL_RESISTENCES[item._material];
+				}
+			}
 
-						if (mIndex == itemId)
-							result += Res.ATTRIBUTE_BONUSES[item._material - 59];
-					}
+			if (itemId == 9) {
+				result += Res.ARMOR_STRENGTHS[item._id];
 
-					if (itemId > 10 && item._material < 37) {
-						int mIndex = item.getElementalCategory() + 11;
+				if (item._material >= 37 && item._material <= 58)
+					result += Res.METAL_LAC[item._material - 37];
+			}
+		}
+	}
 
-						if (mIndex == itemId) {
-							result += Res.ELEMENTAL_RESISTENCES[item._material];
-						}
-					}
+	// Accessories
+	for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) {
+		const XeenItem &item = _accessories[idx];
 
-					if (itemId == 9) {
-						result += Res.ARMOR_STRENGTHS[item._id];
+		if (item._frame && !(item._bonusFlags & 0xC0)) {
+			if (itemId < 11 && itemId != 3 && item._material >= 59 && item._material <= 130) {
+				int mIndex = (int)item.getAttributeCategory();
+				if (mIndex > PERSONALITY)
+					++mIndex;
 
-						if (item._material >= 37 && item._material <= 58)
-							result += Res.METAL_LAC[item._material - 37];
-					}
+				if (mIndex == itemId) {
+					result += Res.ATTRIBUTE_BONUSES[item._material - 59];
 				}
 			}
-			break;
 
-		case 2:
-			for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) {
-				const XeenItem &item = _accessories[idx];
-
-				if (item._frame && !(item._bonusFlags & 0xC0)) {
-					if (itemId < 11 && itemId != 3 && item._material >= 59 && item._material <= 130) {
-						int mIndex = (int)item.getAttributeCategory();
-						if (mIndex > PERSONALITY)
-							++mIndex;
-
-						if (mIndex == itemId) {
-							result += Res.ATTRIBUTE_BONUSES[item._material - 59];
-						}
-					}
-
-					if (itemId > 10 && item._material < 37) {
-						int mIndex = item.getElementalCategory() + 11;
-
-						if (mIndex == itemId)
-							result += Res.ELEMENTAL_RESISTENCES[item._material];
-					}
-
-					if (itemId == 9) {
-						result += Res.ARMOR_STRENGTHS[item._id];
-						if (item._material >= 37 && item._material <= 58) {
-							result += Res.METAL_LAC[item._material - 37];
-						}
-					}
+			if (itemId > 10 && item._material < 37) {
+				int mIndex = item.getElementalCategory() + 11;
+
+				if (mIndex == itemId)
+					result += Res.ELEMENTAL_RESISTENCES[item._material];
+			}
+
+			if (itemId == 9) {
+				result += Res.ARMOR_STRENGTHS[item._id];
+				if (item._material >= 37 && item._material <= 58) {
+					result += Res.METAL_LAC[item._material - 37];
 				}
 			}
-			break;
 		}
 	}
 


Commit: 27c3e44551870339cd9709f06d8200933d4406f5
    https://github.com/scummvm/scummvm/commit/27c3e44551870339cd9709f06d8200933d4406f5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-12-29T21:36:24-05:00

Commit Message:
XEEN: Comments for the Character class methods

Changed paths:
    engines/xeen/character.cpp
    engines/xeen/character.h
    engines/xeen/dialogs_party.cpp


diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index e68cb19..d70ea8a 100644
--- a/engines/xeen/character.cpp
+++ b/engines/xeen/character.cpp
@@ -1818,7 +1818,7 @@ void Character::subtractHitPoints(int amount) {
 	}
 }
 
-bool Character::hasSpecialItem() const {
+bool Character::hasSlayerSword() const {
 	for (uint idx = 0; idx < INV_ITEMS_TOTAL; ++idx) {
 		if (_weapons[idx]._id == 34)
 			// Character has Xeen Slayer sword
diff --git a/engines/xeen/character.h b/engines/xeen/character.h
index 76b1dae..4dde341 100644
--- a/engines/xeen/character.h
+++ b/engines/xeen/character.h
@@ -104,14 +104,29 @@ public:
 public:
 	XeenItem();
 
+	/**
+	 * Clear the data for the item
+	 */
 	void clear();
 
+	/**
+	 * Returns true if no item is set
+	 */
 	bool empty() const { return _id != 0; }
 
+	/**
+	 * Synchronizes the data for the item
+	 */
 	void synchronize(Common::Serializer &s);
 
+	/**
+	 * Gets the elemental category for the item
+	 */
 	ElementalCategory getElementalCategory() const;
 
+	/**
+	 * Gets the attribute category for the item
+	 */
 	AttributeCategory getAttributeCategory() const;
 };
 
@@ -130,6 +145,9 @@ public:
 	InventoryItems(Character *character, ItemCategory category);
 	virtual ~InventoryItems() {}
 
+	/**
+	 * Clears the set of items
+	 */
 	void clear();
 
 	/**
@@ -144,6 +162,9 @@ public:
 
 	virtual Common::String getFullDescription(int itemIndex, int displayNum = 15) = 0;
 
+	/**
+	 * Returns the identified details for an item
+	 */
 	Common::String getIdentifiedDetails(int itemIndex);
 
 	/**
@@ -151,6 +172,9 @@ public:
 	 */
 	bool discardItem(int itemIndex);
 
+	/**
+	 * Equips an item
+	 */
 	virtual void equipItem(int itemIndex) {}
 
 	/**
@@ -163,6 +187,9 @@ public:
 	 */
 	void sort();
 
+	/**
+	 * Enchants an item
+	 */
 	virtual void enchantItem(int itemIndex, int amount);
 
 	/**
@@ -189,6 +216,9 @@ public:
 	 */
 	virtual Common::String getFullDescription(int itemIndex, int displayNum);
 
+	/**
+	 * Enchants a weapon
+	 */
 	virtual void enchantItem(int itemIndex, int amount);
 };
 
@@ -210,6 +240,9 @@ public:
 	 */
 	virtual Common::String getFullDescription(int itemIndex, int displayNum);
 
+	/**
+	 * Enchants an armor
+	 */
 	virtual void enchantItem(int itemIndex, int amount);
 };
 
@@ -328,8 +361,14 @@ public:
 public:
 	Character();
 
+	/**
+	 * Clears the data for a character
+	 */
 	void clear();
 
+	/**
+	 * Synchronizes data for the character
+	 */
 	void synchronize(Common::Serializer &s);
 
 	/**
@@ -357,8 +396,14 @@ public:
 	 */
 	int getAge(bool ignoreTemp = false) const;
 
+	/**
+	 * Gets the maximum hit points for a character
+	 */
 	int getMaxHP() const;
 
+	/**
+	 * Gets the maximum spell points for a character
+	 */
 	int getMaxSP() const;
 
 	/**
@@ -372,10 +417,19 @@ public:
 	 */
 	static int statColor(int amount, int threshold);
 
+	/**
+	 * Returns the bonus the character gets for stats
+	 */
 	int statBonus(uint statValue) const;
 
+	/**
+	 * Returns true if the character passes a saving throw for a given attack type
+	 */
 	bool charSavingThrow(DamageType attackType) const;
 
+	/**
+	 * Returns true if the character is unable to perform any action
+	 */
 	bool noActions();
 
 	/**
@@ -388,6 +442,9 @@ public:
 	 */
 	bool hasAward(int awardId) const;
 
+	/**
+	 * Returns the character's armor class
+	 */
 	int getArmorClass(bool baseOnly = false) const;
 
 	/**
@@ -397,16 +454,34 @@ public:
 
 	uint getCurrentLevel() const;
 
+	/**
+	 * Scans the character's inventory for the given item
+	 */
 	int itemScan(int itemId) const;
 
+	/**
+	 * Sets various attributes of a character
+	 */
 	void setValue(int id, uint value);
 
+	/**
+	 * Returns true if the character is a member of the current town's guild
+	 */
 	bool guildMember() const;
 
+	/**
+	 * Returns the experience required to reach the next level
+	 */
 	uint experienceToNextLevel() const;
 
+	/**
+	 * Returns the next level the character will reach
+	 */
 	uint nextExperienceLevel() const;
 
+	/**
+	 * Returns the character's current experience
+	 */
 	uint getCurrentExperience() const;
 
 	/**
@@ -419,6 +494,9 @@ public:
 	 */
 	int getNumAwards() const;
 
+	/**
+	 * Creates an item and adds it to the inventory
+	 */
 	int makeItem(int p1, int itemIndex, int p3);
 
 	/**
@@ -427,14 +505,23 @@ public:
 	void addHitPoints(int amount);
 
 	/**
-	 * Remove hit points fromo the character
+	 * Remove hit points from the character
 	 */
 	void subtractHitPoints(int amount);
 
-	bool hasSpecialItem() const;
+	/**
+	 * Returns true if the character has the Xeen Slayer Sword
+	 */
+	bool hasSlayerSword() const;
 
+	/**
+	 * Returns true if the character has a missile weapon, such as a bow
+	 */
 	bool hasMissileWeapon() const;
 
+	/**
+	 * Returns a category index for a character, used such for indexing into spell data
+	 */
 	int getClassCategory() const;
 };
 
diff --git a/engines/xeen/dialogs_party.cpp b/engines/xeen/dialogs_party.cpp
index 39b4615..f4d95ca 100644
--- a/engines/xeen/dialogs_party.cpp
+++ b/engines/xeen/dialogs_party.cpp
@@ -222,7 +222,7 @@ void PartyDialog::execute() {
 					if (charButtonValue != 0) {
 						int charIndex = charButtonValue - Common::KEYCODE_1 + startingChar;
 						Character &c = party._roster[_charList[charIndex]];
-						if (c.hasSpecialItem()) {
+						if (c.hasSlayerSword()) {
 							ErrorScroll::show(_vm, Res.HAS_SLAYER_SWORD);
 						} else {
 							Common::String msg = Common::String::format(Res.SURE_TO_DELETE_CHAR,





More information about the Scummvm-git-logs mailing list