XEEN: Changed PlayerStruct to Character

This commit is contained in:
Paul Gilbert 2015-01-24 09:29:17 -05:00
parent b533822c06
commit 1f8a5ea24a
4 changed files with 31 additions and 31 deletions

View File

@ -106,7 +106,7 @@ start:
// Build up a list of characters on the same Xeen side being loaded // Build up a list of characters on the same Xeen side being loaded
for (int i = 0; i < XEEN_TOTAL_CHARACTERS; ++i) { 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)) if (player._name.empty() || player._xeenSide != (map._loadDarkSide ? 1 : 0))
continue; continue;
@ -300,7 +300,7 @@ void Interface::setupFaces(int charIndex, Common::Array<int> xeenSideChars, bool
Common::Rect &b = _buttons[7 + posIndex]._bounds; Common::Rect &b = _buttons[7 + posIndex]._bounds;
b.moveTo((posIndex & 1) ? 117 : 16, b.top); 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; playerNames[posIndex] = isInParty ? IN_PARTY : ps._name;
playerRaces[posIndex] = RACE_NAMES[ps._race]; playerRaces[posIndex] = RACE_NAMES[ps._race];
playerSex[posIndex] = SEX_NAMES[ps._sex]; playerSex[posIndex] = SEX_NAMES[ps._sex];
@ -336,7 +336,7 @@ void Interface::charIconsPrint(bool updateFlag) {
for (int idx = 0; idx < (stateFlag ? _vm->_party->_combatPartyCount : for (int idx = 0; idx < (stateFlag ? _vm->_party->_combatPartyCount :
_vm->_party->_partyCount); ++idx) { _vm->_party->_partyCount); ++idx) {
int charIndex = stateFlag ? _combatCharIds[idx] : idx; int charIndex = stateFlag ? _combatCharIds[idx] : idx;
PlayerStruct &ps = _vm->_party->_activeParty[charIndex]; Character &ps = _vm->_party->_activeParty[charIndex];
Condition charCondition = ps.worstCondition(); Condition charCondition = ps.worstCondition();
int charFrame = FACE_CONDITION_FRAMES[charCondition]; int charFrame = FACE_CONDITION_FRAMES[charCondition];
@ -352,7 +352,7 @@ void Interface::charIconsPrint(bool updateFlag) {
for (int idx = 0; idx < (stateFlag ? _vm->_party->_combatPartyCount : for (int idx = 0; idx < (stateFlag ? _vm->_party->_combatPartyCount :
_vm->_party->_partyCount); ++idx) { _vm->_party->_partyCount); ++idx) {
int charIndex = stateFlag ? _combatCharIds[idx] : idx; int charIndex = stateFlag ? _combatCharIds[idx] : idx;
PlayerStruct &ps = _vm->_party->_activeParty[charIndex]; Character &ps = _vm->_party->_activeParty[charIndex];
// Draw the Hp bar // Draw the Hp bar
int maxHp = ps.getMaxHP(); int maxHp = ps.getMaxHP();

View File

@ -42,7 +42,7 @@ void AttributePair::synchronize(Common::Serializer &s) {
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
PlayerStruct::PlayerStruct() { Character::Character() {
_sex = MALE; _sex = MALE;
_race = HUMAN; _race = HUMAN;
_xeenSide = 0; _xeenSide = 0;
@ -69,7 +69,7 @@ PlayerStruct::PlayerStruct() {
_currentCombatSpell = 0; _currentCombatSpell = 0;
} }
void PlayerStruct::synchronize(Common::Serializer &s) { void Character::synchronize(Common::Serializer &s) {
char name[16]; char name[16];
Common::fill(&name[0], &name[16], '\0'); Common::fill(&name[0], &name[16], '\0');
strncpy(name, _name.c_str(), 16); strncpy(name, _name.c_str(), 16);
@ -149,7 +149,7 @@ void PlayerStruct::synchronize(Common::Serializer &s) {
s.syncAsByte(_currentCombatSpell); s.syncAsByte(_currentCombatSpell);
} }
Condition PlayerStruct::worstCondition() const { Condition Character::worstCondition() const {
for (int cond = ERADICATED; cond >= CURSED; --cond) { for (int cond = ERADICATED; cond >= CURSED; --cond) {
if (_conditions[cond]) if (_conditions[cond])
return (Condition)cond; return (Condition)cond;
@ -158,13 +158,13 @@ Condition PlayerStruct::worstCondition() const {
return NO_CONDITION; return NO_CONDITION;
} }
int PlayerStruct::getAge(bool ignoreTemp) const { int Character::getAge(bool ignoreTemp) const {
int year = MIN(Party::_vm->_party->_year - _ybDay, 254); int year = MIN(Party::_vm->_party->_year - _ybDay, 254);
return ignoreTemp ? year : year + _tempAge; return ignoreTemp ? year : year + _tempAge;
} }
int PlayerStruct::getMaxHP() const { int Character::getMaxHP() const {
int hp = BASE_HP_BY_CLASS[_class]; int hp = BASE_HP_BY_CLASS[_class];
hp += statBonus(getStat(ENDURANCE, false)); hp += statBonus(getStat(ENDURANCE, false));
hp += RACE_HP_BONUSES[_race]; hp += RACE_HP_BONUSES[_race];
@ -182,7 +182,7 @@ int PlayerStruct::getMaxHP() const {
return hp; return hp;
} }
int PlayerStruct::getMaxSP() const { int Character::getMaxSP() const {
int result = 0; int result = 0;
bool flag = false; bool flag = false;
int amount; int amount;
@ -240,7 +240,7 @@ int PlayerStruct::getMaxSP() const {
/** /**
* Get the effective value of a given stat for the character * 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; AttributePair attr;
int mode = 0; int mode = 0;
@ -291,14 +291,14 @@ int PlayerStruct::getStat(Attribute attrib, bool applyMod) const {
return (attr._permanent >= 1) ? attr._permanent : 0; 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) for (int idx = 0; STAT_VALUES[idx] <= statValue; ++idx)
return STAT_BONUSES[idx]; return STAT_BONUSES[idx];
return 0; return 0;
} }
bool PlayerStruct::charSavingThrow(DamageType attackType) const { bool Character::charSavingThrow(DamageType attackType) const {
int v, vMax; int v, vMax;
if (attackType == DT_PHYSICAL) { if (attackType == DT_PHYSICAL) {
@ -335,7 +335,7 @@ bool PlayerStruct::charSavingThrow(DamageType attackType) const {
return Party::_vm->getRandomNumber(1, vMax) <= v; return Party::_vm->getRandomNumber(1, vMax) <= v;
} }
bool PlayerStruct::noActions() { bool Character::noActions() {
Condition condition = worstCondition(); Condition condition = worstCondition();
switch (condition) { switch (condition) {
@ -355,7 +355,7 @@ bool PlayerStruct::noActions() {
} }
} }
void PlayerStruct::setAward(int awardId, bool value) { void Character::setAward(int awardId, bool value) {
int v = awardId; int v = awardId;
if (awardId == 73) if (awardId == 73)
v = 126; v = 126;
@ -365,7 +365,7 @@ void PlayerStruct::setAward(int awardId, bool value) {
_awards[v] = value; _awards[v] = value;
} }
bool PlayerStruct::hasAward(int awardId) const { bool Character::hasAward(int awardId) const {
int v = awardId; int v = awardId;
if (awardId == 73) if (awardId == 73)
v = 126; v = 126;
@ -375,7 +375,7 @@ bool PlayerStruct::hasAward(int awardId) const {
return _awards[v]; return _awards[v];
} }
int PlayerStruct::getArmorClass(bool baseOnly) const { int Character::getArmorClass(bool baseOnly) const {
Party &party = *Party::_vm->_party; Party &party = *Party::_vm->_party;
int result = statBonus(getStat(SPEED, false)) + itemScan(9); int result = statBonus(getStat(SPEED, false)) + itemScan(9);
@ -388,7 +388,7 @@ int PlayerStruct::getArmorClass(bool baseOnly) const {
/** /**
* Returns the thievery skill level, adjusted by class and race * Returns the thievery skill level, adjusted by class and race
*/ */
int PlayerStruct::getThievery() const { int Character::getThievery() const {
int result = getCurrentLevel() * 2; int result = getCurrentLevel() * 2;
if (_class == CLASS_NINJA) if (_class == CLASS_NINJA)
@ -420,11 +420,11 @@ int PlayerStruct::getThievery() const {
return MAX(result, 0); return MAX(result, 0);
} }
int PlayerStruct::getCurrentLevel() const { int Character::getCurrentLevel() const {
return MAX(_level._permanent + _level._temporary, 0); return MAX(_level._permanent + _level._temporary, 0);
} }
int PlayerStruct::itemScan(int itemId) const { int Character::itemScan(int itemId) const {
int result = 0; int result = 0;
for (int accessIdx = 0; accessIdx < 3; ++accessIdx) { for (int accessIdx = 0; accessIdx < 3; ++accessIdx) {
@ -510,7 +510,7 @@ int PlayerStruct::itemScan(int itemId) const {
/** /**
* Modifies a passed attribute value based on player's condition * 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]) if (_conditions[DEAD] || _conditions[STONED] || _conditions[ERADICATED])
return 0; return 0;
@ -757,7 +757,7 @@ void Party::changeTime(int numMinutes) {
if (((_minutes + numMinutes) / 480) != (_minutes / 480)) { if (((_minutes + numMinutes) / 480) != (_minutes / 480)) {
for (int idx = 0; idx < _partyCount; ++idx) { for (int idx = 0; idx < _partyCount; ++idx) {
PlayerStruct &player = _activeParty[idx]; Character &player = _activeParty[idx];
if (!player._conditions[DEAD] && !player._conditions[STONED] && if (!player._conditions[DEAD] && !player._conditions[STONED] &&
!player._conditions[ERADICATED]) { !player._conditions[ERADICATED]) {
@ -833,7 +833,7 @@ void Party::changeTime(int numMinutes) {
addTime(numMinutes); addTime(numMinutes);
for (int idx = 0; idx < _partyCount; ++idx) { 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._conditions[CONFUSED] && _vm->getRandomNumber(2) == 1) {
if (player.charSavingThrow(DT_PHYSICAL)) { if (player.charSavingThrow(DT_PHYSICAL)) {
@ -899,7 +899,7 @@ void Party::addTime(int numMinutes) {
void Party::resetTemps() { void Party::resetTemps() {
for (int idx = 0; idx < _partyCount; ++idx) { for (int idx = 0; idx < _partyCount; ++idx) {
PlayerStruct &player = _activeParty[idx]; Character &player = _activeParty[idx];
player._magicResistence._temporary = 0; player._magicResistence._temporary = 0;
player._energyResistence._temporary = 0; player._energyResistence._temporary = 0;

View File

@ -86,7 +86,7 @@ public:
void synchronize(Common::Serializer &s); void synchronize(Common::Serializer &s);
}; };
class PlayerStruct { class Character {
private: private:
int conditionMod(Attribute attrib) const; int conditionMod(Attribute attrib) const;
public: public:
@ -135,7 +135,7 @@ public:
int _currentAdventuringSpell; int _currentAdventuringSpell;
int _currentCombatSpell; int _currentCombatSpell;
public: public:
PlayerStruct(); Character();
void synchronize(Common::Serializer &s); void synchronize(Common::Serializer &s);
Condition worstCondition() const; Condition worstCondition() const;
@ -167,7 +167,7 @@ public:
int itemScan(int itemId) const; int itemScan(int itemId) const;
}; };
class Roster: public Common::Array<PlayerStruct> { class Roster: public Common::Array<Character> {
public: public:
Roster() {} Roster() {}
@ -175,7 +175,7 @@ public:
}; };
class Party { class Party {
friend class PlayerStruct; friend class Character;
private: private:
static XeenEngine *_vm; static XeenEngine *_vm;
public: public:
@ -235,7 +235,7 @@ public:
bool _characterFlags[30][24]; bool _characterFlags[30][24];
public: public:
// Other party related runtime data // Other party related runtime data
Common::Array<PlayerStruct> _activeParty; Common::Array<Character> _activeParty;
int _combatPartyCount; int _combatPartyCount;
bool _partyDead; bool _partyDead;
bool _newDay; bool _newDay;

View File

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