Skip to content

Commit

Permalink
XEEN: Replaced conditions array with named field structure
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 2, 2015
1 parent feacce6 commit bef5dbd
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 5 deletions.
44 changes: 41 additions & 3 deletions engines/xeen/saves.cpp
Expand Up @@ -171,6 +171,46 @@ void Party::synchronize(Common::Serializer &s) {

/*------------------------------------------------------------------------*/

Conditions::Conditions() {
_cursed = 0;
_heartBroken = 0;
_weak = 0;
_poisoned = 0;
_diseased = 0;
_insane = 0;
_inLove = 0;
_drunk = 0;
_asleep = 0;
_depressed = 0;
_confused = 0;
_paralyzed = 0;
_unconscious = 0;
_dead = 0;
_stoned = 0;
_eradicated = 0;
}

void Conditions::synchronize(Common::Serializer &s) {
s.syncAsByte(_cursed);
s.syncAsByte(_heartBroken);
s.syncAsByte(_weak);
s.syncAsByte(_poisoned);
s.syncAsByte(_diseased);
s.syncAsByte(_insane);
s.syncAsByte(_inLove);
s.syncAsByte(_drunk);
s.syncAsByte(_asleep);
s.syncAsByte(_depressed);
s.syncAsByte(_confused);
s.syncAsByte(_paralyzed);
s.syncAsByte(_unconscious);
s.syncAsByte(_dead);
s.syncAsByte(_stoned);
s.syncAsByte(_eradicated);
}

/*------------------------------------------------------------------------*/

PlayerStruct::PlayerStruct() {
_sex = MALE;
_race = HUMAN;
Expand All @@ -187,7 +227,6 @@ PlayerStruct::PlayerStruct() {
_currentSpell = 0;
_quickOption = 0;
_lloydSide = 0;
Common::fill(&_conditions[0], &_conditions[16], 0);
_townUnknown = 0;
_unknown2 = 0;
_currentHp = 0;
Expand Down Expand Up @@ -253,8 +292,7 @@ void PlayerStruct::synchronize(Common::Serializer &s) {
_energyResistence.synchronize(s);
_magicResistence.synchronize(s);

for (int i = 0; i < 16; ++i)
s.syncAsByte(_conditions[i]);
_conditions.synchronize(s);

s.syncAsUint16LE(_townUnknown);
s.syncAsByte(_unknown2);
Expand Down
27 changes: 25 additions & 2 deletions engines/xeen/saves.h
Expand Up @@ -49,7 +49,7 @@ enum Skill { THIEVERY = 0, ARMS_MASTER = 1, ASTROLOGER = 2, BODYBUILDER = 3,
SPOT_DOORS = 16, DANGER_SENSE = 17
};

enum Condition { CURSED = 0, HEART_BROKEN = 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
};
Expand Down Expand Up @@ -129,6 +129,29 @@ class AttributePair {
void synchronize(Common::Serializer &s);
};

class Conditions {
byte _cursed;
byte _heartBroken;
byte _weak;
byte _poisoned;
byte _diseased;
byte _insane;
byte _inLove;
byte _drunk;
byte _asleep;
byte _depressed;
byte _confused;
byte _paralyzed;
byte _unconscious;
byte _dead;
byte _stoned;
byte _eradicated;
public:
Conditions();

void synchronize(Common::Serializer &s);
};

class PlayerStruct {
public:
Common::String _name;
Expand Down Expand Up @@ -166,7 +189,7 @@ class PlayerStruct {
AttributePair _poisonResistence;
AttributePair _energyResistence;
AttributePair _magicResistence;
int _conditions[16];
Conditions _conditions;
int _townUnknown;
int _unknown2;
int _currentHp;
Expand Down

0 comments on commit bef5dbd

Please sign in to comment.