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

dreammaster dreammaster at scummvm.org
Fri Mar 23 01:30:47 CET 2018


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:
d725d78ec5 XEEN: Fix implementation of breakAllItems
8080907927 XEEN: Fix bought items going into correct character's inventory
27ef37b400 XEEN: Add original copy protection dialog


Commit: d725d78ec5e58d84433634ce1d6171c722df46bc
    https://github.com/scummvm/scummvm/commit/d725d78ec5e58d84433634ce1d6171c722df46bc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-03-22T18:31:18-04:00

Commit Message:
XEEN: Fix implementation of breakAllItems

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


diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index ba81852..47d43d8 100644
--- a/engines/xeen/character.cpp
+++ b/engines/xeen/character.cpp
@@ -38,8 +38,7 @@ void AttributePair::synchronize(Common::Serializer &s) {
 /*------------------------------------------------------------------------*/
 
 Character::Character():
-		_weapons(this), _armor(this), _accessories(this), _misc(this),
-		_items(_weapons, _armor, _accessories, _misc) {
+		_weapons(this), _armor(this), _accessories(this), _misc(this), _items(this) {
 	clear();
 	_faceSprites = nullptr;
 	_rosterId = -1;
diff --git a/engines/xeen/character.h b/engines/xeen/character.h
index 9a757b5..c169e6c 100644
--- a/engines/xeen/character.h
+++ b/engines/xeen/character.h
@@ -130,11 +130,11 @@ public:
 	bool _hasSpells;
 	int8 _currentSpell;
 	QuickAction _quickOption;
-	InventoryItemsGroup _items;
 	WeaponItems _weapons;
 	ArmorItems _armor;
 	AccessoryItems _accessories;
 	MiscItems _misc;
+	InventoryItemsGroup _items;
 	int _lloydSide;
 	AttributePair _fireResistence;
 	AttributePair _coldResistence;
diff --git a/engines/xeen/item.cpp b/engines/xeen/item.cpp
index b722d91..fe9e4ab 100644
--- a/engines/xeen/item.cpp
+++ b/engines/xeen/item.cpp
@@ -629,30 +629,31 @@ Common::String MiscItems::getAttributes(XeenItem &item, const Common::String &cl
 }
 /*------------------------------------------------------------------------*/
 
-InventoryItemsGroup::InventoryItemsGroup(InventoryItems &weapons, InventoryItems &armor,
-		InventoryItems &accessories, InventoryItems &misc) {
-	_itemSets[0] = &weapons;
-	_itemSets[1] = &armor;
-	_itemSets[2] = &accessories;
-	_itemSets[3] = &misc;
-}
-
 InventoryItems &InventoryItemsGroup::operator[](ItemCategory category) {
-	return *_itemSets[category];
+	switch (category) {
+	case CATEGORY_WEAPON:
+		return _owner->_weapons;
+	case CATEGORY_ARMOR:
+		return _owner->_armor;
+	case CATEGORY_ACCESSORY:
+		return _owner->_accessories;
+	default:
+		return _owner->_misc;
+	}
 }
 
 void InventoryItemsGroup::breakAllItems() {
 	for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) {
-		if ((*_itemSets[0])[idx]._id != 34) {
-			(*_itemSets[0])[idx]._bonusFlags |= ITEMFLAG_BROKEN;
-			(*_itemSets[0])[idx]._frame = 0;
+		if (_owner->_weapons[idx]._id != 34) {
+			_owner->_weapons[idx]._bonusFlags |= ITEMFLAG_BROKEN;
+			_owner->_weapons[idx]._frame = 0;
 		}
 
-		(*_itemSets[1])[idx]._bonusFlags |= ITEMFLAG_BROKEN;
-		(*_itemSets[2])[idx]._bonusFlags |= ITEMFLAG_BROKEN;
-		(*_itemSets[3])[idx]._bonusFlags |= ITEMFLAG_BROKEN;
-		(*_itemSets[1])[idx]._frame = 0;
-		(*_itemSets[2])[idx]._frame = 0;
+		_owner->_armor[idx]._bonusFlags |= ITEMFLAG_BROKEN;
+		_owner->_accessories[idx]._bonusFlags |= ITEMFLAG_BROKEN;
+		_owner->_misc[idx]._bonusFlags |= ITEMFLAG_BROKEN;
+		_owner->_armor[idx]._frame = 0;
+		_owner->_accessories[idx]._frame = 0;
 	}
 }
 
diff --git a/engines/xeen/item.h b/engines/xeen/item.h
index 871bd1c..c79de0c 100644
--- a/engines/xeen/item.h
+++ b/engines/xeen/item.h
@@ -259,10 +259,9 @@ public:
 
 class InventoryItemsGroup {
 private:
-	InventoryItems *_itemSets[4];
+	Character *_owner;
 public:
-	InventoryItemsGroup(InventoryItems &weapons, InventoryItems &armor,
-		InventoryItems &accessories, InventoryItems &misc);
+	InventoryItemsGroup(Character *owner) : _owner(owner) {}
 
 	/**
 	 * Returns the inventory items for a given category


Commit: 808090792749e4f6f819373f20225fa055a5f932
    https://github.com/scummvm/scummvm/commit/808090792749e4f6f819373f20225fa055a5f932
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-03-22T19:17:54-04:00

Commit Message:
XEEN: Fix bought items going into correct character's inventory

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


diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index 47d43d8..9fde26e 100644
--- a/engines/xeen/character.cpp
+++ b/engines/xeen/character.cpp
@@ -37,13 +37,69 @@ void AttributePair::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
-Character::Character():
-		_weapons(this), _armor(this), _accessories(this), _misc(this), _items(this) {
+Character::Character(): _weapons(this), _armor(this), _accessories(this), _misc(this), _items(this) {
 	clear();
 	_faceSprites = nullptr;
 	_rosterId = -1;
 }
 
+Character::Character(const Character &src) : _weapons(this), _armor(this), _accessories(this), _misc(this), _items(this) {
+	clear();
+
+	_faceSprites = src._faceSprites;
+	_rosterId = src._rosterId;
+	_name = src._name;
+	_sex = src._sex;
+	_race = src._race;
+	_xeenSide = src._xeenSide;
+	_class = src._class;
+	_might = src._might;
+	_intellect = src._intellect;
+	_personality = src._personality;
+	_endurance = src._endurance;
+	_speed = src._speed;
+	_accuracy = src._accuracy;
+	_luck = src._luck;
+	_ACTemp = src._ACTemp;
+	_level = src._level;
+	_birthDay = src._birthDay;
+	_tempAge = src._tempAge;
+	Common::copy(&src._skills[0], &src._skills[18], &_skills[0]);
+	Common::copy(&src._awards[0], &src._awards[128], &_awards[0]);
+	Common::copy(&src._spells[0], &src._spells[SPELLS_PER_CLASS], &_spells[0]);
+	_lloydMap = src._lloydMap;
+	_lloydPosition = src._lloydPosition;
+	_hasSpells = src._hasSpells;
+	_currentSpell = src._currentSpell;
+	_quickOption = src._quickOption;
+	_weapons = src._weapons;
+	_armor = src._armor;
+	_accessories = src._accessories;
+	_misc = src._misc;
+	_lloydSide = src._lloydSide;
+	_fireResistence = src._fireResistence;
+	_coldResistence = src._coldResistence;
+	_electricityResistence = src._electricityResistence;
+	_poisonResistence = src._poisonResistence;
+	_energyResistence = src._energyResistence;
+	_magicResistence = src._magicResistence;
+	Common::copy(&src._conditions[0], &src._conditions[16], &_conditions[0]);
+	_townUnknown = src._townUnknown;
+	_savedMazeId = src._savedMazeId;
+	_currentHp = src._currentHp;
+	_currentSp = src._currentSp;
+	_birthYear = src._birthYear;
+	_experience = src._experience;
+	_currentAdventuringSpell = src._currentAdventuringSpell;
+	_currentCombatSpell = src._currentCombatSpell;
+
+	for (ItemCategory category = CATEGORY_WEAPON; category <= CATEGORY_MISC; category = (ItemCategory)((int)category + 1)) {
+		const InventoryItems &srcItems = src._items[category];
+		InventoryItems &destItems = _items[category];
+		destItems = srcItems;
+	}
+}
+
 void Character::clear() {
 	_sex = MALE;
 	_race = HUMAN;
diff --git a/engines/xeen/character.h b/engines/xeen/character.h
index c169e6c..5aa62d1 100644
--- a/engines/xeen/character.h
+++ b/engines/xeen/character.h
@@ -155,9 +155,17 @@ public:
 	SpriteResource *_faceSprites;
 	int _rosterId;
 public:
+	/**
+	 * Constructor
+	 */
 	Character();
 
 	/**
+	 * Constructor
+	 */
+	Character(const Character &src);
+
+	/**
 	 * Clears the data for a character
 	 */
 	void clear();
diff --git a/engines/xeen/item.cpp b/engines/xeen/item.cpp
index fe9e4ab..fb8dd24 100644
--- a/engines/xeen/item.cpp
+++ b/engines/xeen/item.cpp
@@ -93,6 +93,14 @@ void InventoryItems::clear() {
 		operator[](idx).clear();
 }
 
+InventoryItems &InventoryItems::operator=(const InventoryItems &src) {
+	Common::Array<XeenItem>::clear();
+	assert(src.size() == INV_ITEMS_TOTAL);
+	for (uint idx = 0; idx < INV_ITEMS_TOTAL; ++idx)
+		push_back(src[idx]);
+	return *this;
+}
+
 bool InventoryItems::passRestrictions(int itemId, bool suppressError) const {
 	CharacterClass charClass = _character->_class;
 
@@ -642,6 +650,19 @@ InventoryItems &InventoryItemsGroup::operator[](ItemCategory category) {
 	}
 }
 
+const InventoryItems &InventoryItemsGroup::operator[](ItemCategory category) const {
+	switch (category) {
+	case CATEGORY_WEAPON:
+		return _owner->_weapons;
+	case CATEGORY_ARMOR:
+		return _owner->_armor;
+	case CATEGORY_ACCESSORY:
+		return _owner->_accessories;
+	default:
+		return _owner->_misc;
+	}
+}
+
 void InventoryItemsGroup::breakAllItems() {
 	for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) {
 		if (_owner->_weapons[idx]._id != 34) {
diff --git a/engines/xeen/item.h b/engines/xeen/item.h
index c79de0c..044d73e 100644
--- a/engines/xeen/item.h
+++ b/engines/xeen/item.h
@@ -116,6 +116,11 @@ public:
 	void clear();
 
 	/**
+	 * Handles copying items from one character to another
+	 */
+	InventoryItems &operator=(const InventoryItems &src);
+
+	/**
 	 * Return whether a given item passes class-based usage restrictions
 	 * @param itemId		Item Index
 	 * @param suppressError	If true, no dialog is shown if the item doesn't pass restrictions
@@ -269,6 +274,11 @@ public:
 	InventoryItems &operator[](ItemCategory category);
 
 	/**
+	 * Returns the inventory items for a given category
+	 */
+	const InventoryItems &operator[](ItemCategory category) const;
+
+	/**
 	 * Breaks all the items in a given character's inventory
 	 */
 	void breakAllItems();


Commit: 27ef37b4004e10e9052115372d99a1af16897654
    https://github.com/scummvm/scummvm/commit/27ef37b4004e10e9052115372d99a1af16897654
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-03-22T20:22:52-04:00

Commit Message:
XEEN: Add original copy protection dialog

Changed paths:
  A engines/xeen/dialogs/dialogs_copy_protection.cpp
  A engines/xeen/dialogs/dialogs_copy_protection.h
    devtools/create_xeen/constants.cpp
    dists/engine-data/xeen.ccs
    engines/xeen/module.mk
    engines/xeen/resources.cpp
    engines/xeen/resources.h
    engines/xeen/scripts.cpp


diff --git a/devtools/create_xeen/constants.cpp b/devtools/create_xeen/constants.cpp
index 9075ed5..db1c73d 100644
--- a/devtools/create_xeen/constants.cpp
+++ b/devtools/create_xeen/constants.cpp
@@ -176,7 +176,15 @@ const char *const WHO_WILL = "\x03""c\x0B""000\x09""000%s\x0A\x0A"
 
 const char *const HOW_MUCH = "\x3""cHow Much\n\n";
 
-const char *const WHATS_THE_PASSWORD = "What's the Password?";
+const char *const WHATS_THE_PASSWORD = "\x3""cWhat's the Password?\n"
+	"\n"
+	"Please turn to page %u, go to\n"
+	"line %u, and type in word %u.\v067\t000Spaces are not counted as words or lines.  "
+	"Hyphenated words are treated as one word.  Any line that has any text is considered a line."
+	"\x3""c\v040\t000\n";
+
+const char *const PASSWORD_INCORRECT = "\x3""c\v040\n"
+	"\f32Incorrect!\fd";
 
 const char *const IN_NO_CONDITION = "\x0B""007%s is not in any condition to perform actions!";
 
@@ -1892,6 +1900,7 @@ void writeConstants(CCArchive &cc) {
 	file.syncString(WHO_WILL);
 	file.syncString(HOW_MUCH);
 	file.syncString(WHATS_THE_PASSWORD);
+	file.syncString(PASSWORD_INCORRECT);
 	file.syncString(IN_NO_CONDITION);
 	file.syncString(NOTHING_HERE);
 	file.syncStrings(TERRAIN_TYPES, 6);
diff --git a/dists/engine-data/xeen.ccs b/dists/engine-data/xeen.ccs
index 3c7bcbc..801168a 100644
Binary files a/dists/engine-data/xeen.ccs and b/dists/engine-data/xeen.ccs differ
diff --git a/engines/xeen/dialogs/dialogs_copy_protection.cpp b/engines/xeen/dialogs/dialogs_copy_protection.cpp
new file mode 100644
index 0000000..7788cb5
--- /dev/null
+++ b/engines/xeen/dialogs/dialogs_copy_protection.cpp
@@ -0,0 +1,100 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "xeen/dialogs/dialogs_copy_protection.h"
+#include "xeen/dialogs/dialogs_input.h"
+#include "xeen/resources.h"
+#include "xeen/xeen.h"
+
+namespace Xeen {
+
+bool CopyProtection::show(XeenEngine *vm) {
+	CopyProtection *dlg = new CopyProtection(vm);
+	int result = dlg->execute();
+	delete dlg;
+
+	return result;
+}
+
+CopyProtection::CopyProtection(XeenEngine *vm) : Input(vm, &(*vm->_windows)[11]) {
+	loadEntries();
+}
+
+bool CopyProtection::execute() {
+	EventsManager &events = *_vm->_events;
+	Sound &sound = *_vm->_sound;
+	Window &w = *_window;
+	bool result = false;
+	Common::String line;
+
+	// Choose a random entry
+	ProtectionEntry &protEntry = _entries[_vm->getRandomNumber(_entries.size() - 1)];
+	Common::String msg = Common::String::format(Res.WHATS_THE_PASSWORD,
+		protEntry._pageNum, protEntry._lineNum, protEntry._wordNum);
+
+	w.open();
+	w.writeString(msg);
+	w.update();
+
+	for (int tryNum = 0; tryNum < 3 && !_vm->shouldExit(); ++tryNum) {
+		line.clear();
+		if (getString(line, 20, 200, false) && !line.compareToIgnoreCase(protEntry._text)) {
+			sound.playFX(20);
+			result = true;
+			break;
+		}
+
+		sound.playFX(21);
+		w.writeString("\x3l\v040\n\x4""200");
+		w.writeString(Res.PASSWORD_INCORRECT);
+		w.update();
+
+		events.updateGameCounter();
+		events.wait(50, false);
+	}
+
+	w.close();
+	return result;
+}
+
+void CopyProtection::loadEntries() {
+	FileManager &files = *g_vm->_files;
+	File f(files._ccNum ? "timer.drv" : "cpstruct");
+	ProtectionEntry pe;
+	byte seed = 0;
+	char text[13];
+
+	while (f.pos() < f.size()) {
+		pe._pageNum = f.readByte() ^ seed++;
+		pe._lineNum = f.readByte() ^ seed++;
+		pe._wordNum = f.readByte() ^ seed++;
+
+		for (int idx = 0; idx < 13; ++idx)
+			text[idx] = f.readByte() ^ seed++;
+		text[12] = '\0';
+		pe._text = Common::String(text);
+
+		_entries.push_back(pe);
+	}
+}
+
+} // End of namespace Xeen
diff --git a/engines/xeen/dialogs/dialogs_copy_protection.h b/engines/xeen/dialogs/dialogs_copy_protection.h
new file mode 100644
index 0000000..97c8a6a
--- /dev/null
+++ b/engines/xeen/dialogs/dialogs_copy_protection.h
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef XEEN_DIALOGS_COPY_PROTECTION_H
+#define XEEN_DIALOGS_COPY_PROTECTION_H
+
+#include "xeen/dialogs/dialogs_input.h"
+#include "common/array.h"
+
+namespace Xeen {
+
+class CopyProtection : public Input {
+	struct ProtectionEntry {
+		uint8 _pageNum;
+		uint8 _lineNum;
+		uint8 _wordNum;
+		Common::String _text;
+	};
+private:
+	Common::Array<ProtectionEntry> _entries;
+private:
+	/**
+	 * Constructor
+	 */
+	CopyProtection(XeenEngine *vm);
+
+	/**
+	 * Execute the dialog
+	 */
+	bool execute();
+
+	/**
+	 * Load the copy protection entries
+	 */
+	void loadEntries();
+public:
+	/**
+	 * Show the dialog
+	 */
+	static bool show(XeenEngine *vm);
+};
+
+} // End of namespace Xeen
+
+#endif /* XEEN_DIALOGS_COPY_PROTECTION_H */
diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk
index 0154b85..9f6075b 100644
--- a/engines/xeen/module.mk
+++ b/engines/xeen/module.mk
@@ -14,6 +14,7 @@ MODULE_OBJS := \
 	dialogs/dialogs_awards.o \
 	dialogs/dialogs_char_info.o \
 	dialogs/dialogs_control_panel.o \
+	dialogs/dialogs_copy_protection.o \
 	dialogs/dialogs_create_char.o \
 	dialogs/dialogs_difficulty.o \
 	dialogs/dialogs_dismiss.o \
diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp
index 45e0989..7c804b1 100644
--- a/engines/xeen/resources.cpp
+++ b/engines/xeen/resources.cpp
@@ -72,6 +72,7 @@ void Resources::loadData() {
 	file.syncString(WHO_WILL);
 	file.syncString(HOW_MUCH);
 	file.syncString(WHATS_THE_PASSWORD);
+	file.syncString(PASSWORD_INCORRECT);
 	file.syncString(IN_NO_CONDITION);
 	file.syncString(NOTHING_HERE);
 	file.syncStrings(TERRAIN_TYPES, 6);
diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h
index 08aa90e..3e70987 100644
--- a/engines/xeen/resources.h
+++ b/engines/xeen/resources.h
@@ -126,6 +126,7 @@ public:
 	const char *WHO_WILL;
 	const char *HOW_MUCH;
 	const char *WHATS_THE_PASSWORD;
+	const char *PASSWORD_INCORRECT;
 	const char *IN_NO_CONDITION;
 	const char *NOTHING_HERE;
 	const char *TERRAIN_TYPES[6];
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index 3b989ab..2df48d5 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -22,6 +22,7 @@
 
 #include "common/config-manager.h"
 #include "xeen/scripts.h"
+#include "xeen/dialogs/dialogs_copy_protection.h"
 #include "xeen/dialogs/dialogs_input.h"
 #include "xeen/dialogs/dialogs_whowill.h"
 #include "xeen/dialogs/dialogs_query.h"
@@ -1841,8 +1842,8 @@ bool Scripts::copyProtectionCheck() {
 	if (!ConfMan.getBool("copy_protection"))
 		return true;
 
-	// Currently not implemented
-	return true;
+	// Show the copy protection dialog
+	return CopyProtection::show(_vm);
 }
 
 void Scripts::display(bool justifyFlag, int var46) {





More information about the Scummvm-git-logs mailing list