Skip to content

Commit

Permalink
XEEN: Changed PlayerStruct to Character
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 24, 2015
1 parent b533822 commit 1f8a5ea
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
8 changes: 4 additions & 4 deletions engines/xeen/interface.cpp
Expand Up @@ -106,7 +106,7 @@ void Interface::manageCharacters(bool soundPlayed) {

// Build up a list of characters on the same Xeen side being loaded
for (int i = 0; i < XEEN_TOTAL_CHARACTERS; ++i) {
PlayerStruct &player = _vm->_roster[i];
Character &player = _vm->_roster[i];
if (player._name.empty() || player._xeenSide != (map._loadDarkSide ? 1 : 0))
continue;

Expand Down Expand Up @@ -300,7 +300,7 @@ void Interface::setupFaces(int charIndex, Common::Array<int> xeenSideChars, bool

Common::Rect &b = _buttons[7 + posIndex]._bounds;
b.moveTo((posIndex & 1) ? 117 : 16, b.top);
PlayerStruct &ps = _vm->_roster[xeenSideChars[charIndex + posIndex]];
Character &ps = _vm->_roster[xeenSideChars[charIndex + posIndex]];
playerNames[posIndex] = isInParty ? IN_PARTY : ps._name;
playerRaces[posIndex] = RACE_NAMES[ps._race];
playerSex[posIndex] = SEX_NAMES[ps._sex];
Expand Down Expand Up @@ -336,7 +336,7 @@ void Interface::charIconsPrint(bool updateFlag) {
for (int idx = 0; idx < (stateFlag ? _vm->_party->_combatPartyCount :
_vm->_party->_partyCount); ++idx) {
int charIndex = stateFlag ? _combatCharIds[idx] : idx;
PlayerStruct &ps = _vm->_party->_activeParty[charIndex];
Character &ps = _vm->_party->_activeParty[charIndex];
Condition charCondition = ps.worstCondition();
int charFrame = FACE_CONDITION_FRAMES[charCondition];

Expand All @@ -352,7 +352,7 @@ void Interface::charIconsPrint(bool updateFlag) {
for (int idx = 0; idx < (stateFlag ? _vm->_party->_combatPartyCount :
_vm->_party->_partyCount); ++idx) {
int charIndex = stateFlag ? _combatCharIds[idx] : idx;
PlayerStruct &ps = _vm->_party->_activeParty[charIndex];
Character &ps = _vm->_party->_activeParty[charIndex];

// Draw the Hp bar
int maxHp = ps.getMaxHP();
Expand Down
40 changes: 20 additions & 20 deletions engines/xeen/party.cpp
Expand Up @@ -42,7 +42,7 @@ void AttributePair::synchronize(Common::Serializer &s) {

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

PlayerStruct::PlayerStruct() {
Character::Character() {
_sex = MALE;
_race = HUMAN;
_xeenSide = 0;
Expand All @@ -69,7 +69,7 @@ PlayerStruct::PlayerStruct() {
_currentCombatSpell = 0;
}

void PlayerStruct::synchronize(Common::Serializer &s) {
void Character::synchronize(Common::Serializer &s) {
char name[16];
Common::fill(&name[0], &name[16], '\0');
strncpy(name, _name.c_str(), 16);
Expand Down Expand Up @@ -149,7 +149,7 @@ void PlayerStruct::synchronize(Common::Serializer &s) {
s.syncAsByte(_currentCombatSpell);
}

Condition PlayerStruct::worstCondition() const {
Condition Character::worstCondition() const {
for (int cond = ERADICATED; cond >= CURSED; --cond) {
if (_conditions[cond])
return (Condition)cond;
Expand All @@ -158,13 +158,13 @@ Condition PlayerStruct::worstCondition() const {
return NO_CONDITION;
}

int PlayerStruct::getAge(bool ignoreTemp) const {
int Character::getAge(bool ignoreTemp) const {
int year = MIN(Party::_vm->_party->_year - _ybDay, 254);

return ignoreTemp ? year : year + _tempAge;
}

int PlayerStruct::getMaxHP() const {
int Character::getMaxHP() const {
int hp = BASE_HP_BY_CLASS[_class];
hp += statBonus(getStat(ENDURANCE, false));
hp += RACE_HP_BONUSES[_race];
Expand All @@ -182,7 +182,7 @@ int PlayerStruct::getMaxHP() const {
return hp;
}

int PlayerStruct::getMaxSP() const {
int Character::getMaxSP() const {
int result = 0;
bool flag = false;
int amount;
Expand Down Expand Up @@ -240,7 +240,7 @@ int PlayerStruct::getMaxSP() const {
/**
* Get the effective value of a given stat for the character
*/
int PlayerStruct::getStat(Attribute attrib, bool applyMod) const {
int Character::getStat(Attribute attrib, bool applyMod) const {
AttributePair attr;
int mode = 0;

Expand Down Expand Up @@ -291,14 +291,14 @@ int PlayerStruct::getStat(Attribute attrib, bool applyMod) const {
return (attr._permanent >= 1) ? attr._permanent : 0;
}

int PlayerStruct::statBonus(int statValue) const {
int Character::statBonus(int statValue) const {
for (int idx = 0; STAT_VALUES[idx] <= statValue; ++idx)
return STAT_BONUSES[idx];

return 0;
}

bool PlayerStruct::charSavingThrow(DamageType attackType) const {
bool Character::charSavingThrow(DamageType attackType) const {
int v, vMax;

if (attackType == DT_PHYSICAL) {
Expand Down Expand Up @@ -335,7 +335,7 @@ bool PlayerStruct::charSavingThrow(DamageType attackType) const {
return Party::_vm->getRandomNumber(1, vMax) <= v;
}

bool PlayerStruct::noActions() {
bool Character::noActions() {
Condition condition = worstCondition();

switch (condition) {
Expand All @@ -355,7 +355,7 @@ bool PlayerStruct::noActions() {
}
}

void PlayerStruct::setAward(int awardId, bool value) {
void Character::setAward(int awardId, bool value) {
int v = awardId;
if (awardId == 73)
v = 126;
Expand All @@ -365,7 +365,7 @@ void PlayerStruct::setAward(int awardId, bool value) {
_awards[v] = value;
}

bool PlayerStruct::hasAward(int awardId) const {
bool Character::hasAward(int awardId) const {
int v = awardId;
if (awardId == 73)
v = 126;
Expand All @@ -375,7 +375,7 @@ bool PlayerStruct::hasAward(int awardId) const {
return _awards[v];
}

int PlayerStruct::getArmorClass(bool baseOnly) const {
int Character::getArmorClass(bool baseOnly) const {
Party &party = *Party::_vm->_party;

int result = statBonus(getStat(SPEED, false)) + itemScan(9);
Expand All @@ -388,7 +388,7 @@ int PlayerStruct::getArmorClass(bool baseOnly) const {
/**
* Returns the thievery skill level, adjusted by class and race
*/
int PlayerStruct::getThievery() const {
int Character::getThievery() const {
int result = getCurrentLevel() * 2;

if (_class == CLASS_NINJA)
Expand Down Expand Up @@ -420,11 +420,11 @@ int PlayerStruct::getThievery() const {
return MAX(result, 0);
}

int PlayerStruct::getCurrentLevel() const {
int Character::getCurrentLevel() const {
return MAX(_level._permanent + _level._temporary, 0);
}

int PlayerStruct::itemScan(int itemId) const {
int Character::itemScan(int itemId) const {
int result = 0;

for (int accessIdx = 0; accessIdx < 3; ++accessIdx) {
Expand Down Expand Up @@ -510,7 +510,7 @@ int PlayerStruct::itemScan(int itemId) const {
/**
* Modifies a passed attribute value based on player's condition
*/
int PlayerStruct::conditionMod(Attribute attrib) const {
int Character::conditionMod(Attribute attrib) const {
if (_conditions[DEAD] || _conditions[STONED] || _conditions[ERADICATED])
return 0;

Expand Down Expand Up @@ -757,7 +757,7 @@ void Party::changeTime(int numMinutes) {

if (((_minutes + numMinutes) / 480) != (_minutes / 480)) {
for (int idx = 0; idx < _partyCount; ++idx) {
PlayerStruct &player = _activeParty[idx];
Character &player = _activeParty[idx];

if (!player._conditions[DEAD] && !player._conditions[STONED] &&
!player._conditions[ERADICATED]) {
Expand Down Expand Up @@ -833,7 +833,7 @@ void Party::changeTime(int numMinutes) {
addTime(numMinutes);

for (int idx = 0; idx < _partyCount; ++idx) {
PlayerStruct &player = _activeParty[idx];
Character &player = _activeParty[idx];

if (player._conditions[CONFUSED] && _vm->getRandomNumber(2) == 1) {
if (player.charSavingThrow(DT_PHYSICAL)) {
Expand Down Expand Up @@ -899,7 +899,7 @@ void Party::addTime(int numMinutes) {

void Party::resetTemps() {
for (int idx = 0; idx < _partyCount; ++idx) {
PlayerStruct &player = _activeParty[idx];
Character &player = _activeParty[idx];

player._magicResistence._temporary = 0;
player._energyResistence._temporary = 0;
Expand Down
10 changes: 5 additions & 5 deletions engines/xeen/party.h
Expand Up @@ -86,7 +86,7 @@ class AttributePair {
void synchronize(Common::Serializer &s);
};

class PlayerStruct {
class Character {
private:
int conditionMod(Attribute attrib) const;
public:
Expand Down Expand Up @@ -135,7 +135,7 @@ class PlayerStruct {
int _currentAdventuringSpell;
int _currentCombatSpell;
public:
PlayerStruct();
Character();
void synchronize(Common::Serializer &s);

Condition worstCondition() const;
Expand Down Expand Up @@ -167,15 +167,15 @@ class PlayerStruct {
int itemScan(int itemId) const;
};

class Roster: public Common::Array<PlayerStruct> {
class Roster: public Common::Array<Character> {
public:
Roster() {}

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

class Party {
friend class PlayerStruct;
friend class Character;
private:
static XeenEngine *_vm;
public:
Expand Down Expand Up @@ -235,7 +235,7 @@ class Party {
bool _characterFlags[30][24];
public:
// Other party related runtime data
Common::Array<PlayerStruct> _activeParty;
Common::Array<Character> _activeParty;
int _combatPartyCount;
bool _partyDead;
bool _newDay;
Expand Down
4 changes: 2 additions & 2 deletions engines/xeen/scripts.cpp
Expand Up @@ -667,7 +667,7 @@ void Scripts::doEndGame2() {
int v2 = 0;

for (int idx = 0; idx < party._partyCount; ++idx) {
PlayerStruct &player = party._activeParty[idx];
Character &player = party._activeParty[idx];
if (player.hasAward(77)) {
v2 = 2;
break;
Expand Down Expand Up @@ -696,7 +696,7 @@ void Scripts::doEnding(const Common::String &endStr, int v2) {
*/
bool Scripts::ifProc(int action, uint32 mask, int mode, int charIndex) {
Party &party = *_vm->_party;
PlayerStruct &ps = party._activeParty[charIndex];
Character &ps = party._activeParty[charIndex];
uint v = 0;

switch (action) {
Expand Down

0 comments on commit 1f8a5ea

Please sign in to comment.