aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2015-02-10 23:40:45 -0500
committerPaul Gilbert2015-02-10 23:40:45 -0500
commit50ae4f95229e9a11b86884aa1fa1dffb6cfdc7a8 (patch)
tree1de724821842aef7cb906a441d1660ea023d96e4 /engines
parente59617834503da077c27c5dff37f620bb1e9f0c1 (diff)
downloadscummvm-rg350-50ae4f95229e9a11b86884aa1fa1dffb6cfdc7a8.tar.gz
scummvm-rg350-50ae4f95229e9a11b86884aa1fa1dffb6cfdc7a8.tar.bz2
scummvm-rg350-50ae4f95229e9a11b86884aa1fa1dffb6cfdc7a8.zip
XEEN: Refactored _partyCount and _partyMembers into the _activeParty array
Diffstat (limited to 'engines')
-rw-r--r--engines/xeen/character.cpp4
-rw-r--r--engines/xeen/character.h1
-rw-r--r--engines/xeen/dialogs.cpp1
-rw-r--r--engines/xeen/dialogs_char_info.cpp4
-rw-r--r--engines/xeen/dialogs_dismiss.cpp2
-rw-r--r--engines/xeen/dialogs_exchange.cpp3
-rw-r--r--engines/xeen/dialogs_party.cpp213
-rw-r--r--engines/xeen/dialogs_party.h16
-rw-r--r--engines/xeen/dialogs_quick_ref.cpp4
-rw-r--r--engines/xeen/dialogs_spells.cpp2
-rw-r--r--engines/xeen/dialogs_whowill.cpp6
-rw-r--r--engines/xeen/interface.cpp2
-rw-r--r--engines/xeen/interface_map.cpp8
-rw-r--r--engines/xeen/party.cpp54
-rw-r--r--engines/xeen/party.h4
-rw-r--r--engines/xeen/resources.cpp6
-rw-r--r--engines/xeen/resources.h5
-rw-r--r--engines/xeen/scripts.cpp10
-rw-r--r--engines/xeen/town.cpp24
19 files changed, 256 insertions, 113 deletions
diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index dc193f45be..e7b5d23ecc 100644
--- a/engines/xeen/character.cpp
+++ b/engines/xeen/character.cpp
@@ -689,6 +689,8 @@ Character::Character():
_weapons(this), _armor(this), _accessories(this), _misc(this),
_items(_weapons, _armor, _accessories, _misc) {
clear();
+ _faceSprites = nullptr;
+ _rosterId = -1;
}
void Character::clear() {
@@ -734,8 +736,6 @@ void Character::clear() {
_armor.clear();
_accessories.clear();
_misc.clear();
-
- _faceSprites = nullptr;
}
void Character::synchronize(Common::Serializer &s) {
diff --git a/engines/xeen/character.h b/engines/xeen/character.h
index 53dee33980..59f4ba65b6 100644
--- a/engines/xeen/character.h
+++ b/engines/xeen/character.h
@@ -260,6 +260,7 @@ public:
int _currentCombatSpell;
SpriteResource *_faceSprites;
+ int _rosterId;
public:
Character();
diff --git a/engines/xeen/dialogs.cpp b/engines/xeen/dialogs.cpp
index b25a8e13c0..ff4eaf622a 100644
--- a/engines/xeen/dialogs.cpp
+++ b/engines/xeen/dialogs.cpp
@@ -33,6 +33,7 @@ namespace Xeen {
*/
void ButtonContainer::saveButtons() {
_savedButtons.push(_buttons);
+ clearButtons();
}
/*
diff --git a/engines/xeen/dialogs_char_info.cpp b/engines/xeen/dialogs_char_info.cpp
index 36ca5bdd4c..de16e9559e 100644
--- a/engines/xeen/dialogs_char_info.cpp
+++ b/engines/xeen/dialogs_char_info.cpp
@@ -282,7 +282,7 @@ void CharacterInfo::addButtons() {
Common::String CharacterInfo::loadCharacterDetails(const Character &c) {
Condition condition = c.worstCondition();
Party &party = *_vm->_party;
- int foodVal = party._food / party._partyCount / 3;
+ int foodVal = party._food / party._activeParty.size() / 3;
int totalResist =
c._fireResistence._permanent + c.itemScan(11) + c._fireResistence._temporary +
@@ -498,7 +498,7 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) {
case 18: {
// Food
- int food = (party._food / party._partyCount) / 3;
+ int food = (party._food / party._activeParty.size()) / 3;
msg = Common::String::format(FOOD_TEXT, STAT_NAMES[attrib],
party._food, food, food != 1 ? "s" : "");
break;
diff --git a/engines/xeen/dialogs_dismiss.cpp b/engines/xeen/dialogs_dismiss.cpp
index b512b66806..0c28affa6c 100644
--- a/engines/xeen/dialogs_dismiss.cpp
+++ b/engines/xeen/dialogs_dismiss.cpp
@@ -71,7 +71,7 @@ void Dismiss::execute() {
w.open();
} else {
Character tempChar = party._activeParty[_buttonValue];
- int charIndex = party._partyMembers[_buttonValue];
+ int charIndex = party._activeParty[_buttonValue]._rosterId;
// party.sortParty();
diff --git a/engines/xeen/dialogs_exchange.cpp b/engines/xeen/dialogs_exchange.cpp
index 0418b4037c..0b1e538b38 100644
--- a/engines/xeen/dialogs_exchange.cpp
+++ b/engines/xeen/dialogs_exchange.cpp
@@ -51,9 +51,8 @@ void ExchangeDialog::execute(Character *&c, int &charIndex) {
if (_buttonValue >= Common::KEYCODE_F1 && _buttonValue <= Common::KEYCODE_F6) {
_buttonValue -= Common::KEYCODE_F1;
- if (_buttonValue < party._partyCount) {
+ if (_buttonValue < (int)party._activeParty.size()) {
SWAP(party._activeParty[charIndex], party._activeParty[_buttonValue]);
- SWAP(party._partyMembers[charIndex], party._partyMembers[_buttonValue]);
charIndex = _buttonValue;
c = &party._activeParty[charIndex];
diff --git a/engines/xeen/dialogs_party.cpp b/engines/xeen/dialogs_party.cpp
index 9202187b6a..618d29781d 100644
--- a/engines/xeen/dialogs_party.cpp
+++ b/engines/xeen/dialogs_party.cpp
@@ -30,7 +30,11 @@
namespace Xeen {
- void PartyDialog::show(XeenEngine *vm) {
+PartyDialog::PartyDialog(XeenEngine *vm) : ButtonContainer(),
+ PartyDrawer(vm), _vm(vm) {
+}
+
+void PartyDialog::show(XeenEngine *vm) {
PartyDialog *dlg = new PartyDialog(vm);
dlg->execute();
delete dlg;
@@ -41,6 +45,7 @@ void PartyDialog::execute() {
Map &map = *_vm->_map;
Party &party = *_vm->_party;
Screen &screen = *_vm->_screen;
+ SoundManager &sound = *_vm->_sound;
bool modeFlag = false;
int startingChar = 0;
@@ -49,31 +54,29 @@ void PartyDialog::execute() {
while (!_vm->shouldQuit()) {
_vm->_mode = MODE_1;
- Common::Array<int> xeenSideChars;
-
- party.loadActiveParty();
// Build up a list of characters on the same Xeen side being loaded
+ _charList.clear();
for (int i = 0; i < XEEN_TOTAL_CHARACTERS; ++i) {
Character &player = party._roster[i];
if (player._name.empty() || player._xeenSide != (map._loadDarkSide ? 1 : 0))
continue;
- xeenSideChars.push_back(i);
+ _charList.push_back(i);
}
Window &w = screen._windows[11];
w.open();
- setupFaces(startingChar, xeenSideChars, false);
+ setupFaces(startingChar, false);
w.writeString(_displayText);
w.drawList(&_faceDrawStructs[0], 4);
- _iconSprites.draw(w, 0, Common::Point(16, 100));
- _iconSprites.draw(w, 2, Common::Point(52, 100));
- _iconSprites.draw(w, 4, Common::Point(87, 100));
- _iconSprites.draw(w, 6, Common::Point(122, 100));
- _iconSprites.draw(w, 8, Common::Point(157, 100));
- _iconSprites.draw(w, 10, Common::Point(192, 100));
+ _uiSprites.draw(w, 0, Common::Point(16, 100));
+ _uiSprites.draw(w, 2, Common::Point(52, 100));
+ _uiSprites.draw(w, 4, Common::Point(87, 100));
+ _uiSprites.draw(w, 6, Common::Point(122, 100));
+ _uiSprites.draw(w, 8, Common::Point(157, 100));
+ _uiSprites.draw(w, 10, Common::Point(192, 100));
screen.loadPalette("mm4.pal");
if (modeFlag) {
@@ -104,7 +107,7 @@ void PartyDialog::execute() {
case Common::KEYCODE_SPACE:
case Common::KEYCODE_e:
case Common::KEYCODE_x:
- if (party._partyCount == 0) {
+ if (party._activeParty.size() == 0) {
ErrorScroll::show(_vm, NO_ONE_TO_ADVENTURE_WITH);
} else {
if (_vm->_mode != MODE_0) {
@@ -119,7 +122,6 @@ void PartyDialog::execute() {
}
w.close();
- party._realPartyCount = party._partyCount;
party._mazeId = party._priorMazeId;
party.copyPartyToRoster();
@@ -136,7 +138,7 @@ void PartyDialog::execute() {
case Common::KEYCODE_F6:
// Show character info
_buttonValue -= Common::KEYCODE_F1;
- if (_buttonValue < party._partyCount)
+ if (_buttonValue < (int)party._activeParty.size())
CharacterInfo::show(_vm, _buttonValue);
break;
@@ -145,15 +147,49 @@ void PartyDialog::execute() {
case Common::KEYCODE_3:
case Common::KEYCODE_4:
_buttonValue -= Common::KEYCODE_1 - 7;
+ if ((_buttonValue - 7 + startingChar) < (int)_charList.size()) {
+ // Check if the selected character is already in the party
+ uint idx = 0;
+ for (; idx < party._activeParty.size(); ++idx) {
+ if (_charList[_buttonValue - 7 + startingChar] ==
+ party._activeParty[idx]._rosterId)
+ break;
+ }
+
+ if (idx == party._activeParty.size()) {
+ sound.playFX(21);
+ ErrorScroll::show(_vm, YOUR_PARTY_IS_FULL);
+ } else {
+ party._activeParty.push_back(party._roster[
+ _charList[_buttonValue - 7 + startingChar]]);
+ error("TODO");
+ }
+ }
+ // TODO
+ break;
+
+ case Common::KEYCODE_UP:
+ case Common::KEYCODE_KP8:
+ if (startingChar > 0) {
+ startingChar -= 4;
+ startingCharChanged(startingChar);
+ }
+ break;
+ case Common::KEYCODE_DOWN:
+ case Common::KEYCODE_KP2:
// TODO
break;
case Common::KEYCODE_c:
- if (xeenSideChars.size() == 24) {
+ // Create
+ if (_charList.size() == XEEN_TOTAL_CHARACTERS) {
ErrorScroll::show(_vm, YOUR_ROSTER_IS_FULL);
} else {
screen.fadeOut(4);
w.close();
+
+ createChar();
+
party.copyPartyToRoster();
_vm->_saves->writeCharFile();
screen.fadeOut(4);
@@ -162,25 +198,20 @@ void PartyDialog::execute() {
}
break;
case Common::KEYCODE_d:
+ // Delete character
break;
case Common::KEYCODE_r:
- if (party._partyCount > 0) {
- // TODO
- }
- break;
-
- case Common::KEYCODE_UP:
- case Common::KEYCODE_KP8:
- if (startingChar > 0) {
- startingChar -= 4;
- startingCharChanged(xeenSideChars, startingChar);
+ // Remove character
+ if (party._activeParty.size() > 0) {
+ int charButtonValue = selectCharacter(false, startingChar);
+ if (charButtonValue != 0) {
+ party.copyPartyToRoster();
+ party._activeParty.remove_at(charButtonValue - Common::KEYCODE_F1);
+ }
+ startingCharChanged(startingChar);
}
- // TODO
- break;
- case Common::KEYCODE_DOWN:
- case Common::KEYCODE_KP2:
- // TODO
break;
+
default:
break;
}
@@ -189,18 +220,18 @@ void PartyDialog::execute() {
}
void PartyDialog::loadButtons() {
- _iconSprites.load("inn.icn");
- addButton(Common::Rect(16, 100, 40, 120), Common::KEYCODE_UP, &_iconSprites);
- addButton(Common::Rect(52, 100, 76, 120), Common::KEYCODE_DOWN, &_iconSprites);
- addButton(Common::Rect(87, 100, 111, 120), Common::KEYCODE_d, &_iconSprites);
- addButton(Common::Rect(122, 100, 146, 120), Common::KEYCODE_r, &_iconSprites);
- addButton(Common::Rect(157, 100, 181, 120), Common::KEYCODE_c, &_iconSprites);
- addButton(Common::Rect(192, 100, 116, 120), Common::KEYCODE_x, &_iconSprites);
- addButton(Common::Rect(0, 0, 0, 0), Common::KEYCODE_ESCAPE, &_iconSprites, false);
- addButton(Common::Rect(16, 16, 48, 48), Common::KEYCODE_1, &_iconSprites, false);
- addButton(Common::Rect(117, 16, 149, 48), Common::KEYCODE_2, &_iconSprites, false);
- addButton(Common::Rect(59, 59, 91, 91), Common::KEYCODE_3, &_iconSprites, false);
- addButton(Common::Rect(117, 59, 151, 91), Common::KEYCODE_4, &_iconSprites, false);
+ _uiSprites.load("inn.icn");
+ addButton(Common::Rect(16, 100, 40, 120), Common::KEYCODE_UP, &_uiSprites);
+ addButton(Common::Rect(52, 100, 76, 120), Common::KEYCODE_DOWN, &_uiSprites);
+ addButton(Common::Rect(87, 100, 111, 120), Common::KEYCODE_d, &_uiSprites);
+ addButton(Common::Rect(122, 100, 146, 120), Common::KEYCODE_r, &_uiSprites);
+ addButton(Common::Rect(157, 100, 181, 120), Common::KEYCODE_c, &_uiSprites);
+ addButton(Common::Rect(192, 100, 116, 120), Common::KEYCODE_x, &_uiSprites);
+ addButton(Common::Rect(0, 0, 0, 0), Common::KEYCODE_ESCAPE, &_uiSprites, false);
+ addButton(Common::Rect(16, 16, 48, 48), Common::KEYCODE_1, &_uiSprites, false);
+ addButton(Common::Rect(117, 16, 149, 48), Common::KEYCODE_2, &_uiSprites, false);
+ addButton(Common::Rect(59, 59, 91, 91), Common::KEYCODE_3, &_uiSprites, false);
+ addButton(Common::Rect(117, 59, 151, 91), Common::KEYCODE_4, &_uiSprites, false);
}
void PartyDialog::initDrawStructs() {
@@ -218,7 +249,7 @@ void PartyDialog::setupBackground() {
/**
* Sets up the faces for display in the party dialog
*/
-void PartyDialog::setupFaces(int firstDisplayChar, Common::Array<int> xeenSideChars, bool updateFlag) {
+void PartyDialog::setupFaces(int firstDisplayChar, bool updateFlag) {
Party &party = *_vm->_party;
Common::String charNames[4];
Common::String charRaces[4];
@@ -228,8 +259,8 @@ void PartyDialog::setupFaces(int firstDisplayChar, Common::Array<int> xeenSideCh
int charId;
for (posIndex = 0; posIndex < 4; ++posIndex) {
- charId = (firstDisplayChar + posIndex) >= (int)xeenSideChars.size() ? -1 :
- xeenSideChars[firstDisplayChar + posIndex];
+ charId = (firstDisplayChar + posIndex) >= (int)_charList.size() ? -1 :
+ _charList[firstDisplayChar + posIndex];
bool isInParty = party.isInParty(charId);
if (charId == -1) {
@@ -240,7 +271,7 @@ void PartyDialog::setupFaces(int firstDisplayChar, Common::Array<int> xeenSideCh
Common::Rect &b = _buttons[7 + posIndex]._bounds;
b.moveTo((posIndex & 1) ? 117 : 16, b.top);
- Character &ps = party._roster[xeenSideChars[firstDisplayChar + posIndex]];
+ Character &ps = party._roster[_charList[firstDisplayChar + posIndex]];
charNames[posIndex] = isInParty ? IN_PARTY : ps._name;
charRaces[posIndex] = RACE_NAMES[ps._race];
charSex[posIndex] = SEX_NAMES[ps._sex];
@@ -251,7 +282,7 @@ void PartyDialog::setupFaces(int firstDisplayChar, Common::Array<int> xeenSideCh
// Set up the sprite set to use for each face
for (int posIndex = 0; posIndex < 4; ++posIndex) {
- if ((firstDisplayChar + posIndex) >= (int)xeenSideChars.size())
+ if ((firstDisplayChar + posIndex) >= (int)_charList.size())
_faceDrawStructs[posIndex]._sprites = nullptr;
else
_faceDrawStructs[posIndex]._sprites = party._roster[posIndex]._faceSprites;
@@ -265,9 +296,91 @@ void PartyDialog::setupFaces(int firstDisplayChar, Common::Array<int> xeenSideCh
);
}
-void PartyDialog::startingCharChanged(Common::Array<int> &charList, int firstDisplayChar) {
+void PartyDialog::startingCharChanged(int firstDisplayChar) {
+ Window &w = _vm->_screen->_windows[11];
+
+ setupFaces(firstDisplayChar, true);
+ w.writeString(_displayText);
+ w.drawList(_faceDrawStructs, 4);
+
+ _uiSprites.draw(w, 0, Common::Point(16, 100));
+ _uiSprites.draw(w, 2, Common::Point(52, 100));
+ _uiSprites.draw(w, 4, Common::Point(87, 100));
+ _uiSprites.draw(w, 6, Common::Point(122, 100));
+ _uiSprites.draw(w, 8, Common::Point(157, 100));
+ _uiSprites.draw(w, 10, Common::Point(192, 100));
+
+ w.update();
+}
+
+void PartyDialog::createChar() {
+ error("TODO: createChar");
+}
+
+int PartyDialog::selectCharacter(bool isDelete, int firstDisplayChar) {
+ EventsManager &events = *_vm->_events;
Party &party = *_vm->_party;
- // TODO
+ Screen &screen = *_vm->_screen;
+ Window &w = screen._windows[28];
+
+ SpriteResource iconSprites;
+ iconSprites.load("esc.icn");
+
+ w.setBounds(Common::Rect(50, isDelete ? 112 : 76, 266, isDelete ? 148 : 112));
+ w.open();
+ w.writeString(Common::String::format(REMOVE_OR_DELETE_WHICH,
+ REMOVE_DELETE[isDelete ? 1 : 0]));
+ iconSprites.draw(w, 0, Common::Point(225, isDelete ? 120 : 84));
+ w.update();
+
+ saveButtons();
+ addButton(Common::Rect(225, isDelete ? 120 : 84, 249, isDelete ? 140 : 104),
+ Common::KEYCODE_ESCAPE, &iconSprites);
+ addButton(Common::Rect(16, 16, 48, 48), Common::KEYCODE_1, &iconSprites, false);
+ addButton(Common::Rect(117, 16, 149, 48), Common::KEYCODE_2, &iconSprites, false);
+ addButton(Common::Rect(16, 59, 48, 91), Common::KEYCODE_3, &iconSprites, false);
+ addButton(Common::Rect(117, 59, 149, 91), Common::KEYCODE_4, &iconSprites, false);
+
+ int result = -1, v;
+ while (!_vm->shouldQuit() && result == -1) {
+ _buttonValue = 0;
+ while (!_vm->shouldQuit() && !_buttonValue) {
+ events.pollEventsAndWait();
+ checkEvents(_vm);
+ }
+
+ switch (_buttonValue) {
+ case Common::KEYCODE_ESCAPE:
+ result = 0;
+ break;
+
+ case Common::KEYCODE_F1:
+ case Common::KEYCODE_F2:
+ case Common::KEYCODE_F3:
+ case Common::KEYCODE_F4:
+ case Common::KEYCODE_F5:
+ case Common::KEYCODE_F6:
+ v = _buttonValue - Common::KEYCODE_F1;
+ if (v < (int)party._activeParty.size())
+ result = _buttonValue;
+ break;
+
+ case Common::KEYCODE_1:
+ case Common::KEYCODE_2:
+ case Common::KEYCODE_3:
+ case Common::KEYCODE_4:
+ v = _buttonValue - Common::KEYCODE_1;
+ if ((firstDisplayChar + v) < (int)_charList.size())
+ result = _buttonValue;
+
+ default:
+ break;
+ }
+ }
+
+ w.close();
+ restoreButtons();
+ return result == -1 ? 0 : result;
}
} // End of namespace Xeen
diff --git a/engines/xeen/dialogs_party.h b/engines/xeen/dialogs_party.h
index 327c29953b..082c43bb22 100644
--- a/engines/xeen/dialogs_party.h
+++ b/engines/xeen/dialogs_party.h
@@ -25,19 +25,21 @@
#include "common/array.h"
#include "xeen/dialogs.h"
+#include "xeen/interface.h"
#include "xeen/screen.h"
#include "xeen/sprites.h"
namespace Xeen {
-class PartyDialog : public ButtonContainer {
+class PartyDialog : public ButtonContainer, public PartyDrawer {
private:
XeenEngine *_vm;
- SpriteResource _iconSprites;
+ SpriteResource _uiSprites;
DrawStruct _faceDrawStructs[4];
Common::String _displayText;
+ Common::Array<int> _charList;
- PartyDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+ PartyDialog(XeenEngine *vm);
void execute();
@@ -49,9 +51,13 @@ private:
void drawParty(bool updateFlag);
- void setupFaces(int firstDisplayChar, Common::Array<int> xeenSideChars, bool updateFlag);
+ void setupFaces(int firstDisplayChar, bool updateFlag);
- void startingCharChanged(Common::Array<int> &charList, int firstDisplayChar);
+ void startingCharChanged(int firstDisplayChar);
+
+ void createChar();
+
+ int selectCharacter(bool isDelete, int firstDisplayChar);
public:
static void show(XeenEngine *vm);
};
diff --git a/engines/xeen/dialogs_quick_ref.cpp b/engines/xeen/dialogs_quick_ref.cpp
index 6c8da5ef86..f4066a0de5 100644
--- a/engines/xeen/dialogs_quick_ref.cpp
+++ b/engines/xeen/dialogs_quick_ref.cpp
@@ -42,7 +42,7 @@ void QuickReferenceDialog::execute() {
events.setCursor(0);
for (uint idx = 0; idx < (combat._globalCombat == 2 ? party._combatParty.size() :
- party._partyCount); ++idx) {
+ party._activeParty.size()); ++idx) {
Character &c = combat._globalCombat == 2 ? *party._combatParty[idx] :
party._activeParty[idx];
Condition condition = c.worstCondition();
@@ -59,7 +59,7 @@ void QuickReferenceDialog::execute() {
);
}
- int food = (party._food / party._partyCount) / 3;
+ int food = (party._food / party._activeParty.size()) / 3;
Common::String msg = Common::String::format(QUICK_REFERENCE,
lines[0].c_str(), lines[1].c_str(), lines[2].c_str(),
lines[3].c_str(), lines[4].c_str(), lines[5].c_str(),
diff --git a/engines/xeen/dialogs_spells.cpp b/engines/xeen/dialogs_spells.cpp
index dc05be611d..0ce0259b45 100644
--- a/engines/xeen/dialogs_spells.cpp
+++ b/engines/xeen/dialogs_spells.cpp
@@ -111,7 +111,7 @@ Character *SpellsScroll::execute(Character *c, int v2) {
case Common::KEYCODE_F6:
if (_vm->_mode != MODE_COMBAT) {
_buttonValue -= Common::KEYCODE_F1;
- if (_buttonValue < party._partyCount) {
+ if (_buttonValue < (int)party._activeParty.size()) {
c = &party._activeParty[_buttonValue];
spells._lastCaster = _buttonValue;
intf.highlightChar(_buttonValue);
diff --git a/engines/xeen/dialogs_whowill.cpp b/engines/xeen/dialogs_whowill.cpp
index fb845a6d9a..10bbae26ee 100644
--- a/engines/xeen/dialogs_whowill.cpp
+++ b/engines/xeen/dialogs_whowill.cpp
@@ -44,7 +44,7 @@ int WhoWill::execute(int message, int action, bool type) {
Town &town = *_vm->_town;
int numFrames;
- if (party._partyCount <= 1)
+ if (party._activeParty.size() <= 1)
// Unless there's at least two characters, just return the first one
return 1;
@@ -53,7 +53,7 @@ int WhoWill::execute(int message, int action, bool type) {
Common::String actionStr = type ? map._events._text[action] : WHO_WILL_ACTIONS[action];
Common::String msg = Common::String::format(WHO_WILL, actionStr.c_str(),
- WHO_ACTIONS[message], party._partyCount);
+ WHO_ACTIONS[message], party._activeParty.size());
screen._windows[36].open();
screen._windows[36].writeString(msg);
@@ -86,7 +86,7 @@ int WhoWill::execute(int message, int action, bool type) {
break;
} else if (_buttonValue >= 201 && _buttonValue <= 206) {
_buttonValue -= 201;
- if (_buttonValue > party._partyCount)
+ if (_buttonValue > (int)party._activeParty.size())
continue;
if (party._activeParty[_buttonValue - 1].noActions())
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index 7c9e8a323a..b88b64af5f 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -433,7 +433,7 @@ void Interface::perform() {
case Common::KEYCODE_F5:
case Common::KEYCODE_F6:
_buttonValue -= Common::KEYCODE_F1;
- if (_buttonValue < party._partyCount) {
+ if (_buttonValue < (int)party._activeParty.size()) {
CharacterInfo::show(_vm, _buttonValue);
if (party._stepped)
moveMonsters();
diff --git a/engines/xeen/interface_map.cpp b/engines/xeen/interface_map.cpp
index beaf241f40..ad53b7c069 100644
--- a/engines/xeen/interface_map.cpp
+++ b/engines/xeen/interface_map.cpp
@@ -4397,8 +4397,8 @@ void InterfaceMap::drawIndoors() {
// Check for any character shooting
_isShooting = false;
- for (int i = 0; i < _vm->_party->_partyCount; ++i) {
- if (_vm->_combat->_shooting[i])
+ for (uint idx = 0; idx < _vm->_party->_activeParty.size(); ++idx) {
+ if (_vm->_combat->_shooting[idx])
_isShooting = true;
}
@@ -4475,8 +4475,8 @@ void InterfaceMap::drawOutdoors() {
// Check for any character shooting
_isShooting = false;
- for (int i = 0; i < _vm->_party->_partyCount; ++i) {
- if (_vm->_combat->_shooting[i])
+ for (uint idx = 0; idx < _vm->_party->_activeParty.size(); ++idx) {
+ if (_vm->_combat->_shooting[idx])
_isShooting = true;
}
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp
index f14a0bfb1a..cd1dc21264 100644
--- a/engines/xeen/party.cpp
+++ b/engines/xeen/party.cpp
@@ -36,6 +36,9 @@ Roster::Roster() {
resize(TOTAL_CHARACTERS);
for (int idx = 0; idx < TOTAL_CHARACTERS; ++idx) {
+ // Set the index of the character in the roster list
+ operator[](idx)._rosterId = idx;
+
if (idx < XEEN_TOTAL_CHARACTERS) {
// Load new character resource
Common::String name = Common::String::format("char%02d.fac", idx + 1);
@@ -48,7 +51,7 @@ Roster::Roster() {
}
void Roster::synchronize(Common::Serializer &s) {
- for (uint i = 0; i < 30; ++i)
+ for (uint i = 0; i < TOTAL_CHARACTERS; ++i)
(*this)[i].synchronize(s);
}
@@ -58,9 +61,6 @@ XeenEngine *Party::_vm;
Party::Party(XeenEngine *vm) {
_vm = vm;
- _partyCount = 0;
- _realPartyCount = 0;
- Common::fill(&_partyMembers[0], &_partyMembers[8], 0);
_mazeDirection = DIR_NORTH;
_mazeId = _priorMazeId = 0;
_levitateActive = false;
@@ -120,11 +120,25 @@ Party::Party(XeenEngine *vm) {
void Party::synchronize(Common::Serializer &s) {
byte dummy[30];
Common::fill(&dummy[0], &dummy[30], 0);
+ int partyCount = _activeParty.size();
+
+ int8 partyMembers[MAX_PARTY_COUNT];
+ if (s.isSaving()) {
+ Common::fill(&partyMembers[0], &partyMembers[8], -1);
+ for (uint idx = 0; idx < _activeParty.size(); ++idx)
+ partyMembers[idx] = _activeParty[idx]._rosterId;
+ } else {
+ _activeParty.clear();
+ }
+
+ s.syncAsByte(partyCount); // Party count
+ s.syncAsByte(partyCount); // Real party count
+ for (int idx = 0; idx < MAX_PARTY_COUNT; ++idx) {
+ s.syncAsByte(partyMembers[idx]);
+ if (s.isLoading() && idx < partyCount && partyMembers[idx] != -1)
+ _activeParty.push_back(_roster[partyMembers[idx]]);
+ }
- 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);
@@ -199,10 +213,7 @@ void Party::synchronize(Common::Serializer &s) {
}
void Party::loadActiveParty() {
- _activeParty.resize(_partyCount);
- for (int i = 0; i < _partyCount; ++i) {
- _activeParty[i] = _roster[_partyMembers[i]];
- }
+ // No implementation needed
}
bool Party::checkSkill(Skill skillId) {
@@ -235,17 +246,20 @@ bool Party::checkSkill(Skill skillId) {
}
bool Party::isInParty(int charId) {
- for (int i = 0; i < 8; ++i) {
- if (_partyMembers[i] == charId)
+ for (uint i = 0; i < _activeParty.size(); ++i) {
+ if (_activeParty[i]._rosterId == charId)
return true;
}
return false;
}
+/**
+ * Copy the currently active party characters' data back to the roster
+ */
void Party::copyPartyToRoster() {
- for (int i = 0; i < _partyCount; ++i) {
- _roster[_partyMembers[i]] = _activeParty[i];
+ for (uint i = 0; i < _activeParty.size(); ++i) {
+ _roster[_activeParty[i]._rosterId] = _activeParty[i];
}
}
@@ -257,7 +271,7 @@ void Party::changeTime(int numMinutes) {
bool killed = false;
if (((_minutes + numMinutes) / 480) != (_minutes / 480)) {
- for (int idx = 0; idx < _partyCount; ++idx) {
+ for (int idx = 0; idx < (int)_activeParty.size(); ++idx) {
Character &player = _activeParty[idx];
if (!player._conditions[DEAD] && !player._conditions[STONED] &&
@@ -333,7 +347,7 @@ void Party::changeTime(int numMinutes) {
// Increment the time
addTime(numMinutes);
- for (int idx = 0; idx < _partyCount; ++idx) {
+ for (int idx = 0; idx < (int)_activeParty.size(); ++idx) {
Character &player = _activeParty[idx];
if (player._conditions[CONFUSED] && _vm->getRandomNumber(2) == 1) {
@@ -383,7 +397,7 @@ void Party::addTime(int numMinutes) {
if (_rested || _vm->_mode == MODE_SLEEPING) {
_rested = false;
} else {
- for (int idx = 0; idx < _partyCount; ++idx) {
+ for (int idx = 0; idx < (int)_activeParty.size(); ++idx) {
if (_activeParty[idx]._conditions[WEAK] >= 0)
_activeParty[idx]._conditions[WEAK]++;
}
@@ -399,7 +413,7 @@ void Party::addTime(int numMinutes) {
}
void Party::resetTemps() {
- for (int idx = 0; idx < _partyCount; ++idx) {
+ for (int idx = 0; idx < (int)_activeParty.size(); ++idx) {
Character &player = _activeParty[idx];
player._magicResistence._temporary = 0;
diff --git a/engines/xeen/party.h b/engines/xeen/party.h
index a91b398931..58bfbd2c39 100644
--- a/engines/xeen/party.h
+++ b/engines/xeen/party.h
@@ -44,6 +44,7 @@ enum Difficulty { ADVENTURER = 0, WARRIOR = 1 };
#define TOTAL_CHARACTERS 30
#define XEEN_TOTAL_CHARACTERS 24
#define MAX_ACTIVE_PARTY 6
+#define MAX_PARTY_COUNT 8
#define TOTAL_STATS 7
#define TOTAL_QUEST_ITEMS 85
#define TOTAL_QUEST_FLAGS 56
@@ -64,9 +65,6 @@ private:
static XeenEngine *_vm;
public:
// Dynamic data that's saved
- int _partyCount;
- int _realPartyCount;
- int _partyMembers[8];
Direction _mazeDirection;
Common::Point _mazePosition;
int _mazeId;
diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp
index e9178505ad..d309fe9cd4 100644
--- a/engines/xeen/resources.cpp
+++ b/engines/xeen/resources.cpp
@@ -1436,4 +1436,10 @@ const char *const SOME_CHARS_MAY_DIE = "Some Chars may die. Rest anyway?";
const char *const CANT_DISMISS_LAST_CHAR = "You cannot dismiss your last character!";
+const char *const REMOVE_DELETE[2] = { "Remove", "Delete" };
+
+const char *const REMOVE_OR_DELETE_WHICH = "\x3l\t010\v005%s which character?";
+
+const char *const YOUR_PARTY_IS_FULL = "\v007Your party is full!";
+
} // End of namespace Xeen
diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h
index d4e1c11694..a1734ce323 100644
--- a/engines/xeen/resources.h
+++ b/engines/xeen/resources.h
@@ -495,6 +495,11 @@ extern const char *const SOME_CHARS_MAY_DIE;
extern const char *const CANT_DISMISS_LAST_CHAR;
+extern const char *const REMOVE_DELETE[2];
+extern const char *const REMOVE_OR_DELETE_WHICH;
+
+extern const char *const YOUR_PARTY_IS_FULL;
+
} // End of namespace Xeen
#endif /* XEEN_RESOURCES_H */
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index 7ced6afa3f..6ab4c1fe13 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -426,7 +426,7 @@ void Scripts::cmdIf(Common::Array<byte> &params) {
result = ifProc(params[0], mask, _event->_opcode - 8, _charIndex - 1);
} else {
result = false;
- for (int idx = 0; idx < party._partyCount && !result; ++idx) {
+ for (int idx = 0; idx < (int)party._activeParty.size() && !result; ++idx) {
if (_charIndex == 0 || (_charIndex == 8 && idx != _v2)) {
result = ifProc(params[0], mask, _event->_opcode - 8, idx);
}
@@ -488,7 +488,7 @@ void Scripts::cmdSetChar(Common::Array<byte> &params) {
return;
}
} else {
- _charIndex = _vm->getRandomNumber(1, _vm->_party->_partyCount);
+ _charIndex = _vm->getRandomNumber(1, _vm->_party->_activeParty.size());
}
_v2 = 1;
@@ -576,7 +576,7 @@ void Scripts::cmdGiveExtended(Common::Array<byte> &params) {
result = ifProc(params[0], mask, _event->_opcode - OP_If1, _charIndex - 1);
} else {
result = false;
- for (int idx = 0; idx < party._partyCount && !result; ++idx) {
+ for (int idx = 0; idx < (int)party._activeParty.size() && !result; ++idx) {
if (_charIndex == 0 || (_charIndex == 8 && _v2 != idx)) {
result = ifProc(params[0], mask, _event->_opcode - OP_If1, idx);
}
@@ -726,7 +726,7 @@ void Scripts::cmdSetVar(Common::Array<byte> &params) {
party._activeParty[_charIndex - 1].setValue(params[0], val);
} else {
// Set value for entire party
- for (int idx = 0; idx < party._partyCount; ++idx) {
+ for (int idx = 0; idx < (int)party._activeParty.size(); ++idx) {
if (_charIndex == 0 || (_charIndex == 8 && _v2 != idx)) {
party._activeParty[idx].setValue(params[0], val);
}
@@ -870,7 +870,7 @@ void Scripts::doEndGame2() {
Party &party = *_vm->_party;
int v2 = 0;
- for (int idx = 0; idx < party._partyCount; ++idx) {
+ for (uint idx = 0; idx < party._activeParty.size(); ++idx) {
Character &player = party._activeParty[idx];
if (player.hasAward(77)) {
v2 = 2;
diff --git a/engines/xeen/town.cpp b/engines/xeen/town.cpp
index 25f332a010..f68a554b5f 100644
--- a/engines/xeen/town.cpp
+++ b/engines/xeen/town.cpp
@@ -532,7 +532,7 @@ Character *Town::doBlacksmithOptions(Character *c) {
if (_buttonValue >= Common::KEYCODE_F1 && _buttonValue <= Common::KEYCODE_F6) {
// Switch character
_buttonValue -= Common::KEYCODE_F1;
- if (_buttonValue < party._partyCount) {
+ if (_buttonValue < (int)party._activeParty.size()) {
c = &party._activeParty[_buttonValue];
intf.highlightChar(_buttonValue);
}
@@ -554,7 +554,7 @@ Character *Town::doGuildOptions(Character *c) {
if (_buttonValue >= Common::KEYCODE_F1 && _buttonValue <= Common::KEYCODE_F6) {
// Switch character
_buttonValue -= Common::KEYCODE_F1;
- if (_buttonValue < party._partyCount) {
+ if (_buttonValue < (int)party._activeParty.size()) {
c = &party._activeParty[_buttonValue];
intf.highlightChar(_buttonValue);
@@ -598,7 +598,7 @@ Character *Town::doTavernOptions(Character *c) {
case Common::KEYCODE_F6:
// Switch character
_buttonValue -= Common::KEYCODE_F1;
- if (_buttonValue < party._partyCount) {
+ if (_buttonValue < (int)party._activeParty.size()) {
c = &party._activeParty[_buttonValue];
intf.highlightChar(_buttonValue);
_v21 = 0;
@@ -632,27 +632,27 @@ Character *Town::doTavernOptions(Character *c) {
case Common::KEYCODE_f: {
// Food
if (party._mazeId == (isDarkCc ? 29 : 28)) {
- _v22 = party._partyCount * 15;
+ _v22 = party._activeParty.size() * 15;
_v23 = 10;
idx = 0;
} else if (isDarkCc && party._mazeId == 31) {
- _v22 = party._partyCount * 60;
+ _v22 = party._activeParty.size() * 60;
_v23 = 100;
idx = 1;
} else if (!isDarkCc && party._mazeId == 30) {
- _v22 = party._partyCount * 50;
+ _v22 = party._activeParty.size() * 50;
_v23 = 50;
idx = 1;
} else if (isDarkCc) {
- _v22 = party._partyCount * 120;
+ _v22 = party._activeParty.size() * 120;
_v23 = 250;
idx = 2;
} else if (party._mazeId == 49) {
- _v22 = party._partyCount * 120;
+ _v22 = party._activeParty.size() * 120;
_v23 = 100;
idx = 2;
} else {
- _v22 = party._partyCount * 15;
+ _v22 = party._activeParty.size() * 15;
_v23 = 10;
idx = 0;
}
@@ -717,7 +717,7 @@ Character *Town::doTavernOptions(Character *c) {
party._mazeDirection = DIR_SOUTH;
party._priorMazeId = party._mazeId;
- for (int idx = 0; idx < party._partyCount; ++idx) {
+ for (uint idx = 0; idx < party._activeParty.size(); ++idx) {
party._activeParty[idx]._savedMazeId = party._mazeId;
party._activeParty[idx]._xeenSide = map._loadDarkSide;
}
@@ -799,7 +799,7 @@ Character *Town::doTempleOptions(Character *c) {
case Common::KEYCODE_F6:
// Switch character
_buttonValue -= Common::KEYCODE_F1;
- if (_buttonValue < party._partyCount) {
+ if (_buttonValue < (int)party._activeParty.size()) {
c = &party._activeParty[_buttonValue];
intf.highlightChar(_buttonValue);
_dayOfWeek = 0;
@@ -900,7 +900,7 @@ Character *Town::doTrainingOptions(Character *c) {
case Common::KEYCODE_F6:
// Switch character
_buttonValue -= Common::KEYCODE_F1;
- if (_buttonValue < party._partyCount) {
+ if (_buttonValue < (int)party._activeParty.size()) {
_v2 = _buttonValue;
c = &party._activeParty[_buttonValue];
intf.highlightChar(_buttonValue);