[Scummvm-git-logs] scummvm master -> 13a53f3731dcf3509a71b139d7755ebf9ab508f3

dreammaster dreammaster at scummvm.org
Tue Nov 14 02:37:32 CET 2017


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

Summary:
13a53f3731 XEEN: Added resetBlacksmithWares method


Commit: 13a53f3731dcf3509a71b139d7755ebf9ab508f3
    https://github.com/scummvm/scummvm/commit/13a53f3731dcf3509a71b139d7755ebf9ab508f3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-11-13T20:37:29-05:00

Commit Message:
XEEN: Added resetBlacksmithWares method

Changed paths:
    engines/xeen/dialogs_input.cpp
    engines/xeen/party.cpp
    engines/xeen/party.h


diff --git a/engines/xeen/dialogs_input.cpp b/engines/xeen/dialogs_input.cpp
index 75654f6..f66bd24 100644
--- a/engines/xeen/dialogs_input.cpp
+++ b/engines/xeen/dialogs_input.cpp
@@ -283,7 +283,6 @@ int HowMuch::show(XeenEngine *vm) {
 }
 
 int HowMuch::execute() {
-	Party &party = *_vm->_party;
 	Screen &screen = *_vm->_screen;
 	Window &w = screen._windows[6];
 	Common::String num;
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp
index 3d2f13d..92b7dff 100644
--- a/engines/xeen/party.cpp
+++ b/engines/xeen/party.cpp
@@ -33,6 +33,8 @@
 
 namespace Xeen {
 
+/*------------------------------------------------------------------------*/
+
 Roster::Roster() {
 	resize(TOTAL_CHARACTERS);
 
@@ -392,7 +394,8 @@ void Party::addTime(int numMinutes) {
 
 	if ((_day % 10) == 1 || numMinutes > (24 * 60)) {
 		if (_day != day) {
-			warning("TODO: resetBlacksmith? and giveInterest?");
+			resetBlacksmithWares();
+			giveInterest();
 		}
 	}
 
@@ -1248,7 +1251,7 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int
 		break;
 	case 66: {
 		warning("TODO: Verify case 66");
-		Character c;
+		Character &c = _itemsCharacter;
 		int idx = -1;
 		if (scripts._itemType != 0) {
 			for (idx = 0; idx < 10 && _treasure._misc[idx]._material; ++idx);
@@ -1400,4 +1403,130 @@ void Party::resetYearlyBits() {
 	_gameFlags[0][231] = false;
 }
 
+const int BLACKSMITH_DATA1[4][4] = {
+	{ 15, 5, 5, 5 },{ 5, 10, 5, 5 },{ 0, 5, 10, 5 },{ 0, 0, 0, 5 }
+};
+const int BLACKSMITH_DATA2[4][4] = {
+	{ 10, 5, 0, 5 },{ 10, 5, 5, 5 },{ 0, 5, 5, 10 },{ 0, 5, 10, 0 }
+};
+
+void Party::resetBlacksmithWares() {
+	Character &c = _itemsCharacter;
+	int catCount[4];
+
+	// Clear existing blacksmith wares
+	for (int i = 0; i < 2; ++i) {
+		for (int j = 0; j < ITEMS_COUNT; ++j) {
+			_blacksmithWeapons[i][j].clear();
+			_blacksmithArmor[i][j].clear();
+			_blacksmithAccessories[i][j].clear();
+			_blacksmithWeapons[i][j].clear();
+		}
+	}
+
+	for (int idx1 = 0; idx1 < 4; ++idx1) {
+		Common::fill(&catCount[0], &catCount[4], 0);
+
+		for (int idx2 = 0; idx2 < 4; ++idx2) {
+			for (int idx3 = 0; idx3 < BLACKSMITH_DATA1[idx2][idx1]; ++idx3) {
+				int itemCat = c.makeItem(idx2, 0, 0);
+				if (catCount[itemCat] < 8) {
+					switch (itemCat) {
+					case 0: {
+						XeenItem &item = _blacksmithWeapons[0][idx2 * 4 + catCount[itemCat]];
+						item._id = c._weapons[0]._id;
+						item._material = c._weapons[0]._material;
+						item._bonusFlags = c._weapons[0]._bonusFlags;
+						break;
+					}
+
+					case 1: {
+						XeenItem &item = _blacksmithArmor[0][idx2 * 4 + catCount[itemCat]];
+						item._id = c._weapons[0]._id;
+						item._material = c._weapons[0]._material;
+						item._bonusFlags = c._weapons[0]._bonusFlags;
+						break;
+					}
+
+					case 2: {
+						XeenItem &item = _blacksmithAccessories[0][idx2 * 4 + catCount[itemCat]];
+						item._id = c._weapons[0]._id;
+						item._material = c._weapons[0]._material;
+						item._bonusFlags = c._weapons[0]._bonusFlags;
+						break;
+					}
+
+					case 3: {
+						XeenItem &item = _blacksmithMisc[0][idx2 * 4 + catCount[itemCat]];
+						item._id = c._weapons[0]._id;
+						item._material = c._weapons[0]._material;
+						item._bonusFlags = c._weapons[0]._bonusFlags;
+						break;
+					}
+
+					default:
+						break;
+					}
+
+					++catCount[itemCat];
+				}
+			}
+		}
+	}
+
+	for (int idx1 = 0; idx1 < 4; ++idx1) {
+		Common::fill(&catCount[0], &catCount[4], 0);
+
+		for (int idx2 = 0; idx2 < 4; ++idx2) {
+			for (int idx3 = 0; idx3 < BLACKSMITH_DATA2[idx2][idx1]; ++idx3) {
+				int itemCat = c.makeItem(idx2 + (idx1 >= 2 ? 3 : 1), 0, 0);
+				if (catCount[itemCat] < 8) {
+					switch (itemCat) {
+					case 0: {
+						XeenItem &item = _blacksmithWeapons[1][idx2 * 4 + catCount[itemCat]];
+						item._id = c._weapons[0]._id;
+						item._material = c._weapons[0]._material;
+						item._bonusFlags = c._weapons[0]._bonusFlags;
+						break;
+					}
+
+					case 1: {
+						XeenItem &item = _blacksmithArmor[1][idx2 * 4 + catCount[itemCat]];
+						item._id = c._weapons[0]._id;
+						item._material = c._weapons[0]._material;
+						item._bonusFlags = c._weapons[0]._bonusFlags;
+						break;
+					}
+
+					case 2: {
+						XeenItem &item = _blacksmithAccessories[1][idx2 * 4 + catCount[itemCat]];
+						item._id = c._weapons[0]._id;
+						item._material = c._weapons[0]._material;
+						item._bonusFlags = c._weapons[0]._bonusFlags;
+						break;
+					}
+
+					case 3: {
+						XeenItem &item = _blacksmithMisc[1][idx2 * 4 + catCount[itemCat]];
+						item._id = c._weapons[0]._id;
+						item._material = c._weapons[0]._material;
+						item._bonusFlags = c._weapons[0]._bonusFlags;
+						break;
+					}
+
+					default:
+						break;
+					}
+
+					++catCount[itemCat];
+				}
+			}
+		}
+	}
+}
+
+void Party::giveInterest() {
+
+}
+
 } // End of namespace Xeen
diff --git a/engines/xeen/party.h b/engines/xeen/party.h
index 790540b..adf0ad7 100644
--- a/engines/xeen/party.h
+++ b/engines/xeen/party.h
@@ -77,6 +77,7 @@ class Party {
 	friend class InventoryItems;
 private:
 	static XeenEngine *_vm;
+	Character _itemsCharacter;
 
 	/**
 	 * Give a treasure item to the given character's inventory
@@ -94,6 +95,13 @@ private:
 	void subPartyTime(int time);
 
 	void resetYearlyBits();
+
+	/**
+	 * Resets the inventory that Blacksmiths sell
+	 */
+	void resetBlacksmithWares();
+
+	void giveInterest();
 public:
 	// Dynamic data that's saved
 	Direction _mazeDirection;





More information about the Scummvm-git-logs mailing list