diff options
-rw-r--r-- | engines/xeen/party.cpp | 291 | ||||
-rw-r--r-- | engines/xeen/party.h | 128 | ||||
-rw-r--r-- | engines/xeen/xeen.cpp | 36 | ||||
-rw-r--r-- | engines/xeen/xeen.h | 3 |
4 files changed, 229 insertions, 229 deletions
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index c5f80eb1f5..97b4a768cd 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -40,138 +40,6 @@ void AttributePair::synchronize(Common::Serializer &s) { /*------------------------------------------------------------------------*/ -Party::Party() { - _partyCount = 0; - _realPartyCount = 0; - Common::fill(&_partyMembers[0], &_partyMembers[8], 0); - _mazeDirection = DIR_NORTH; - _mazeId = _priorMazeId = 0; - _levitateActive = false; - _automapOn = false; - _wizardEyeActive = false; - _clairvoyanceActive = false; - _walkOnWaterActive = false; - _blessedActive = false; - _powerShieldActive = false; - _holyBonusActive = false; - _heroismActive = false; - _difficulty = ADVENTURER; - _cloudsEnd = false; - _darkSideEnd = false; - _worldEnd = false; - hour_maybe = 0; - _day = 0; - _year = 0; - _minutes = 0; - _food = 0; - _lightCount = 0; - _torchCount = 0; - _fireResistence = 0; - _electricityResistence = 0; - _coldResistence = 0; - _poisonResistence = 0; - _deathCount = 0; - _winCount = 0; - _lossCount = 0; - _gold = 0; - _gems = 0; - _bankGold = 0; - _bankGems = 0; - _totalTime = 0; - _rested = false; - - Common::fill(&_gameFlags[0], &_gameFlags[512], false); - Common::fill(&_autoNotes[0], &_autoNotes[128], false); - Common::fill(&_quests[0], &_quests[64], false); - Common::fill(&_questItems[0], &_questItems[85], 0); - - for (int i = 0; i < TOTAL_CHARACTERS; ++i) - Common::fill(&_characterFlags[i][0], &_characterFlags[i][24], false); -} - -void Party::synchronize(Common::Serializer &s) { - byte dummy[30]; - Common::fill(&dummy[0], &dummy[30], 0); - - s.syncAsByte(_partyCount); - s.syncAsByte(_realPartyCount); - for (int i = 0; i < 8; ++i) - s.syncAsByte(_partyMembers[i]); - s.syncAsByte(_mazeDirection); - s.syncAsByte(_mazePosition.x); - s.syncAsByte(_mazePosition.y); - s.syncAsByte(_mazeId); - - // Game configuration flags not used in this implementation - s.syncBytes(dummy, 3); - - s.syncAsByte(_priorMazeId); - s.syncAsByte(_levitateActive); - s.syncAsByte(_automapOn); - s.syncAsByte(_wizardEyeActive); - s.syncAsByte(_clairvoyanceActive); - s.syncAsByte(_walkOnWaterActive); - s.syncAsByte(_blessedActive); - s.syncAsByte(_powerShieldActive); - s.syncAsByte(_holyBonusActive); - s.syncAsByte(_heroismActive); - s.syncAsByte(_difficulty); - - for (int i = 0; i < ITEMS_COUNT; ++i) - _blacksmithWeapons[i].synchronize(s); - for (int i = 0; i < ITEMS_COUNT; ++i) - _blacksmithArmor[i].synchronize(s); - for (int i = 0; i < ITEMS_COUNT; ++i) - _blacksmithAccessories[i].synchronize(s); - for (int i = 0; i < ITEMS_COUNT; ++i) - _blacksmithMisc[i].synchronize(s); - - s.syncAsUint16LE(_cloudsEnd); - s.syncAsUint16LE(_darkSideEnd); - s.syncAsUint16LE(_worldEnd); - s.syncAsUint16LE(hour_maybe); - s.syncAsUint16LE(_day); - s.syncAsUint16LE(_year); - s.syncAsUint16LE(_minutes); - s.syncAsUint16LE(_food); - s.syncAsUint16LE(_lightCount); - s.syncAsUint16LE(_torchCount); - s.syncAsUint16LE(_fireResistence); - s.syncAsUint16LE(_electricityResistence); - s.syncAsUint16LE(_coldResistence); - s.syncAsUint16LE(_poisonResistence); - s.syncAsUint16LE(_deathCount); - s.syncAsUint16LE(_winCount); - s.syncAsUint16LE(_lossCount); - s.syncAsUint32LE(_gold); - s.syncAsUint32LE(_gems); - s.syncAsUint32LE(_bankGold); - s.syncAsUint32LE(_bankGems); - s.syncAsUint32LE(_totalTime); - s.syncAsByte(_rested); - SavesManager::syncBitFlags(s, &_gameFlags[0], &_gameFlags[512]); - SavesManager::syncBitFlags(s, &_autoNotes[0], &_autoNotes[128]); - SavesManager::syncBitFlags(s, &_quests[0], &_quests[64]); - - for (int i = 0; i < 85; ++i) - s.syncAsByte(_questItems[i]); - - for (int i = 0; i < ITEMS_COUNT; ++i) - _blacksmithWeapons2[i].synchronize(s); - for (int i = 0; i < ITEMS_COUNT; ++i) - _blacksmithArmor2[i].synchronize(s); - for (int i = 0; i < ITEMS_COUNT; ++i) - _blacksmithAccessories2[i].synchronize(s); - for (int i = 0; i < ITEMS_COUNT; ++i) - _blacksmithMisc2[i].synchronize(s); - - for (int i = 0; i < TOTAL_CHARACTERS; ++i) - SavesManager::syncBitFlags(s, &_characterFlags[i][0], &_characterFlags[i][24]); - s.syncBytes(&dummy[0], 30); -} - -/*------------------------------------------------------------------------*/ - Conditions::Conditions() { _cursed = 0; _heartBroken = 0; @@ -315,4 +183,163 @@ void Roster::synchronize(Common::Serializer &s) { (*this)[i].synchronize(s); } +/*------------------------------------------------------------------------*/ + +Party::Party() { + _partyCount = 0; + _realPartyCount = 0; + Common::fill(&_partyMembers[0], &_partyMembers[8], 0); + _mazeDirection = DIR_NORTH; + _mazeId = _priorMazeId = 0; + _levitateActive = false; + _automapOn = false; + _wizardEyeActive = false; + _clairvoyanceActive = false; + _walkOnWaterActive = false; + _blessedActive = false; + _powerShieldActive = false; + _holyBonusActive = false; + _heroismActive = false; + _difficulty = ADVENTURER; + _cloudsEnd = false; + _darkSideEnd = false; + _worldEnd = false; + hour_maybe = 0; + _day = 0; + _year = 0; + _minutes = 0; + _food = 0; + _lightCount = 0; + _torchCount = 0; + _fireResistence = 0; + _electricityResistence = 0; + _coldResistence = 0; + _poisonResistence = 0; + _deathCount = 0; + _winCount = 0; + _lossCount = 0; + _gold = 0; + _gems = 0; + _bankGold = 0; + _bankGems = 0; + _totalTime = 0; + _rested = false; + + Common::fill(&_gameFlags[0], &_gameFlags[512], false); + Common::fill(&_autoNotes[0], &_autoNotes[128], false); + Common::fill(&_quests[0], &_quests[64], false); + Common::fill(&_questItems[0], &_questItems[85], 0); + + for (int i = 0; i < TOTAL_CHARACTERS; ++i) + Common::fill(&_characterFlags[i][0], &_characterFlags[i][24], false); +} + +void Party::synchronize(Common::Serializer &s) { + byte dummy[30]; + Common::fill(&dummy[0], &dummy[30], 0); + + s.syncAsByte(_partyCount); + s.syncAsByte(_realPartyCount); + for (int i = 0; i < 8; ++i) + s.syncAsByte(_partyMembers[i]); + s.syncAsByte(_mazeDirection); + s.syncAsByte(_mazePosition.x); + s.syncAsByte(_mazePosition.y); + s.syncAsByte(_mazeId); + + // Game configuration flags not used in this implementation + s.syncBytes(dummy, 3); + + s.syncAsByte(_priorMazeId); + s.syncAsByte(_levitateActive); + s.syncAsByte(_automapOn); + s.syncAsByte(_wizardEyeActive); + s.syncAsByte(_clairvoyanceActive); + s.syncAsByte(_walkOnWaterActive); + s.syncAsByte(_blessedActive); + s.syncAsByte(_powerShieldActive); + s.syncAsByte(_holyBonusActive); + s.syncAsByte(_heroismActive); + s.syncAsByte(_difficulty); + + for (int i = 0; i < ITEMS_COUNT; ++i) + _blacksmithWeapons[i].synchronize(s); + for (int i = 0; i < ITEMS_COUNT; ++i) + _blacksmithArmor[i].synchronize(s); + for (int i = 0; i < ITEMS_COUNT; ++i) + _blacksmithAccessories[i].synchronize(s); + for (int i = 0; i < ITEMS_COUNT; ++i) + _blacksmithMisc[i].synchronize(s); + + s.syncAsUint16LE(_cloudsEnd); + s.syncAsUint16LE(_darkSideEnd); + s.syncAsUint16LE(_worldEnd); + s.syncAsUint16LE(hour_maybe); + s.syncAsUint16LE(_day); + s.syncAsUint16LE(_year); + s.syncAsUint16LE(_minutes); + s.syncAsUint16LE(_food); + s.syncAsUint16LE(_lightCount); + s.syncAsUint16LE(_torchCount); + s.syncAsUint16LE(_fireResistence); + s.syncAsUint16LE(_electricityResistence); + s.syncAsUint16LE(_coldResistence); + s.syncAsUint16LE(_poisonResistence); + s.syncAsUint16LE(_deathCount); + s.syncAsUint16LE(_winCount); + s.syncAsUint16LE(_lossCount); + s.syncAsUint32LE(_gold); + s.syncAsUint32LE(_gems); + s.syncAsUint32LE(_bankGold); + s.syncAsUint32LE(_bankGems); + s.syncAsUint32LE(_totalTime); + s.syncAsByte(_rested); + SavesManager::syncBitFlags(s, &_gameFlags[0], &_gameFlags[512]); + SavesManager::syncBitFlags(s, &_autoNotes[0], &_autoNotes[128]); + SavesManager::syncBitFlags(s, &_quests[0], &_quests[64]); + + for (int i = 0; i < 85; ++i) + s.syncAsByte(_questItems[i]); + + for (int i = 0; i < ITEMS_COUNT; ++i) + _blacksmithWeapons2[i].synchronize(s); + for (int i = 0; i < ITEMS_COUNT; ++i) + _blacksmithArmor2[i].synchronize(s); + for (int i = 0; i < ITEMS_COUNT; ++i) + _blacksmithAccessories2[i].synchronize(s); + for (int i = 0; i < ITEMS_COUNT; ++i) + _blacksmithMisc2[i].synchronize(s); + + for (int i = 0; i < TOTAL_CHARACTERS; ++i) + SavesManager::syncBitFlags(s, &_characterFlags[i][0], &_characterFlags[i][24]); + s.syncBytes(&dummy[0], 30); +} + +bool Party::checkSkill(Skill skillId) { + uint total = 0; + for (uint i = 0; i < _activeParty.size(); ++i) { + if (_activeParty[i]->_skills[skillId]) { + ++total; + + switch (skillId) { + case MOUNTAINEER: + case PATHFINDER: + // At least two characters need skill for check to return true + if (total == 2) + return true; + break; + case CRUSADER: + case SWIMMING: + // Entire party must have skill for check to return true + if (total == _activeParty.size()) + return true; + break; + default: + // All other skills only need to have a single player having it + return true; + } + } + } +} + } // End of namespace Xeen diff --git a/engines/xeen/party.h b/engines/xeen/party.h index a42fe6ee98..d52153739d 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -50,7 +50,7 @@ enum Skill { THIEVERY = 0, ARMS_MASTER = 1, ASTROLOGER = 2, BODYBUILDER = 3, SPOT_DOORS = 16, DANGER_SENSE = 17 }; -enum ConditionType { CURSED = 0, HEARTBROKEN = 1, WEAK = 2, POISONED = 3, +enum ConditionType { CURSED = 0, HEART_BROKEN = 1, WEAK = 2, POISONED = 3, DISEASED = 4, INSANE = 5, IN_LOVE = 6, DRUNK = 7, SLEEP = 8, DEPRESSED = 9, CONFUSED = 10, PARALYZED = 11 }; @@ -62,67 +62,6 @@ enum ConditionType { CURSED = 0, HEARTBROKEN = 1, WEAK = 2, POISONED = 3, class XeenEngine; -class Party { -public: - int _partyCount; - int _realPartyCount; - int _partyMembers[8]; - Direction _mazeDirection; - Common::Point _mazePosition; - int _mazeId; - int _priorMazeId; - bool _levitateActive; - bool _automapOn; - bool _wizardEyeActive; - bool _clairvoyanceActive; - bool _walkOnWaterActive; - bool _blessedActive; - bool _powerShieldActive; - bool _holyBonusActive; - bool _heroismActive; - Difficulty _difficulty; - XeenItem _blacksmithWeapons[ITEMS_COUNT]; - XeenItem _blacksmithArmor[ITEMS_COUNT]; - XeenItem _blacksmithAccessories[ITEMS_COUNT]; - XeenItem _blacksmithMisc[ITEMS_COUNT]; - bool _cloudsEnd; - bool _darkSideEnd; - bool _worldEnd; - int hour_maybe; - int _day; - int _year; - int _minutes; - int _food; - int _lightCount; - int _torchCount; - int _fireResistence; - int _electricityResistence; - int _coldResistence; - int _poisonResistence; - int _deathCount; - int _winCount; - int _lossCount; - int _gold; - int _gems; - int _bankGold; - int _bankGems; - int _totalTime; - bool _rested; - bool _gameFlags[512]; - bool _autoNotes[128]; - bool _quests[64]; - int _questItems[85]; - XeenItem _blacksmithWeapons2[ITEMS_COUNT]; - XeenItem _blacksmithArmor2[ITEMS_COUNT]; - XeenItem _blacksmithAccessories2[ITEMS_COUNT]; - XeenItem _blacksmithMisc2[ITEMS_COUNT]; - bool _characterFlags[30][24]; -public: - Party(); - - void synchronize(Common::Serializer &s); -}; - class AttributePair { public: int _permanent; @@ -213,6 +152,71 @@ public: void synchronize(Common::Serializer &s); }; +class Party { +public: + int _partyCount; + int _realPartyCount; + int _partyMembers[8]; + Direction _mazeDirection; + Common::Point _mazePosition; + int _mazeId; + int _priorMazeId; + bool _levitateActive; + bool _automapOn; + bool _wizardEyeActive; + bool _clairvoyanceActive; + bool _walkOnWaterActive; + bool _blessedActive; + bool _powerShieldActive; + bool _holyBonusActive; + bool _heroismActive; + Difficulty _difficulty; + XeenItem _blacksmithWeapons[ITEMS_COUNT]; + XeenItem _blacksmithArmor[ITEMS_COUNT]; + XeenItem _blacksmithAccessories[ITEMS_COUNT]; + XeenItem _blacksmithMisc[ITEMS_COUNT]; + bool _cloudsEnd; + bool _darkSideEnd; + bool _worldEnd; + int hour_maybe; + int _day; + int _year; + int _minutes; + int _food; + int _lightCount; + int _torchCount; + int _fireResistence; + int _electricityResistence; + int _coldResistence; + int _poisonResistence; + int _deathCount; + int _winCount; + int _lossCount; + int _gold; + int _gems; + int _bankGold; + int _bankGems; + int _totalTime; + bool _rested; + bool _gameFlags[512]; + bool _autoNotes[128]; + bool _quests[64]; + int _questItems[85]; + XeenItem _blacksmithWeapons2[ITEMS_COUNT]; + XeenItem _blacksmithArmor2[ITEMS_COUNT]; + XeenItem _blacksmithAccessories2[ITEMS_COUNT]; + XeenItem _blacksmithMisc2[ITEMS_COUNT]; + bool _characterFlags[30][24]; +public: + Common::Array<PlayerStruct *> _activeParty; +public: + Party(); + + void synchronize(Common::Serializer &s); + + bool checkSkill(Skill skillId); +}; + } // End of namespace Xeen #endif /* XEEN_PARTY_H */ diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index a46526e6ec..315e5172b7 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -41,7 +41,6 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc) _screen = nullptr; _sound = nullptr; _eventData = nullptr; - Common::fill(&_activeRoster[0], &_activeRoster[MAX_ACTIVE_PARTY], nullptr); Common::fill(&_partyFaces[0], &_partyFaces[MAX_ACTIVE_PARTY], nullptr); _isEarlyGame = false; _loadDarkSide = 1; @@ -265,9 +264,9 @@ void XeenEngine::setupUI(bool soundPlayed) { _spellFxSprites.load("spellfx.icn"); // Get mappings to the active characters in the party - Common::fill(&_activeRoster[0], &_activeRoster[MAX_ACTIVE_PARTY], nullptr); + _party._activeParty.resize(_party._partyCount); for (int i = 0; i < _party._partyCount; ++i) { - _activeRoster[i] = &_roster[_party._partyMembers[i]]; + _party._activeParty[i] = &_roster[_party._partyMembers[i]]; } _isEarlyGame = _party._minutes >= 300; @@ -342,13 +341,13 @@ void XeenEngine::assembleBorder() { // Draw UI element to indicate whether can spot hidden doors _borderSprites.draw(*_screen, - (_spotDoorsAllowed && checkSkill(SPOT_DOORS)) ? _spotDoorsUIFrame + 28 : 28, + (_spotDoorsAllowed && _party.checkSkill(SPOT_DOORS)) ? _spotDoorsUIFrame + 28 : 28, Common::Point(194, 91)); _spotDoorsUIFrame = (_spotDoorsUIFrame + 1) % 12; // Draw UI element to indicate whether can sense danger _borderSprites.draw(*_screen, - (_dangerSenseAllowed && checkSkill(DANGER_SENSE)) ? _spotDoorsUIFrame + 40 : 40, + (_dangerSenseAllowed && _party.checkSkill(DANGER_SENSE)) ? _spotDoorsUIFrame + 40 : 40, Common::Point(107, 9)); _dangerSenseUIFrame = (_dangerSenseUIFrame + 1) % 12; @@ -356,31 +355,4 @@ void XeenEngine::assembleBorder() { // TODO } -bool XeenEngine::checkSkill(Skill skillId) { - int total = 0; - for (int i = 0; i < _party._partyCount; ++i) { - if (_activeRoster[i]->_skills[skillId]) { - ++total; - - switch (skillId) { - case MOUNTAINEER: - case PATHFINDER: - // At least two characters need skill for check to return true - if (total == 2) - return true; - break; - case CRUSADER: - case SWIMMING: - // Entire party must have skill for check to return true - if (total == _party._partyCount) - return true; - break; - default: - // All other skills only need to have a single player having it - return true; - } - } - } -} - } // End of namespace Xeen diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h index b6ca766088..f63f73d434 100644 --- a/engines/xeen/xeen.h +++ b/engines/xeen/xeen.h @@ -108,8 +108,6 @@ private: void setupGameBackground(); void assembleBorder(); - - bool checkSkill(Skill skillId); protected: /** * Play the game @@ -143,7 +141,6 @@ public: Common::SeekableReadStream *_eventData; Roster _roster; Party _party; - PlayerStruct *_activeRoster[MAX_ACTIVE_PARTY]; public: XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc); virtual ~XeenEngine(); |