Skip to content

Commit 8482ac7

Browse files
committed
MM: MM1: Persist party chars' selected spells in savegames
1 parent a61f16c commit 8482ac7

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

engines/mm/mm1/data/party.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,15 @@ void Party::synchronize(Common::Serializer &s) {
144144
if (s.isLoading())
145145
resize(partySize);
146146

147-
for (int i = 0; i < partySize; ++i)
148-
(*this)[i].synchronize(s);
147+
for (int i = 0; i < partySize; ++i) {
148+
// Sync the common properties
149+
Character &c = (*this)[i];
150+
c.synchronize(s);
151+
152+
// Sync extra properties
153+
s.syncAsSByte(c._combatSpell);
154+
s.syncAsSByte(c._nonCombatSpell);
155+
}
149156

150157
if (s.isLoading())
151158
g_globals->_currCharacter = &front();

engines/mm/mm1/views_enh/spells/cast_spell.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ void CastSpell::updateSelectedSpell() {
144144
}
145145
}
146146

147+
void CastSpell::charSwitched(Character *priorChar) {
148+
PartyView::charSwitched(priorChar);
149+
updateSelectedSpell();
150+
}
151+
147152
void CastSpell::castSpell(Character *target) {
148153
if (!isMagicAllowed()) {
149154
g_events->send(InfoMessage(STRING["spells.magic_doesnt_work"]));

engines/mm/mm1/views_enh/spells/cast_spell.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ class CastSpell : public PartyView, public MM1::Game::SpellCasting {
5353
*/
5454
void spellError();
5555

56+
protected:
57+
/**
58+
* Called when the selected character has been switched
59+
*/
60+
void charSwitched(Character *priorChar) override;
61+
5662
public:
5763
CastSpell();
5864
virtual ~CastSpell() {}

0 commit comments

Comments
 (0)