SAGA2: Implement PlayerActor save/loading
This commit is contained in:
parent
a4e78598e2
commit
3d4a8a6893
5 changed files with 118 additions and 32 deletions
|
@ -1307,7 +1307,7 @@ Actor::Actor(Common::InSaveFile *in) : GameObject(in) {
|
||||||
enchantmentFlags = in->readUint32LE();
|
enchantmentFlags = in->readUint32LE();
|
||||||
currentGoal = in->readByte();
|
currentGoal = in->readByte();
|
||||||
deactivationCounter = in->readByte();
|
deactivationCounter = in->readByte();
|
||||||
effectiveStats.load(in);
|
effectiveStats.read(in);
|
||||||
actionCounter = in->readByte();
|
actionCounter = in->readByte();
|
||||||
effectiveResistance = in->readUint16LE();
|
effectiveResistance = in->readUint16LE();
|
||||||
effectiveImmunity = in->readUint16LE();
|
effectiveImmunity = in->readUint16LE();
|
||||||
|
|
|
@ -171,28 +171,28 @@ struct ActorAttributes {
|
||||||
return skill(id) / skillFracPointsPerLevel + 1;
|
return skill(id) / skillFracPointsPerLevel + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(Common::SeekableReadStream *stream) {
|
void read(Common::InSaveFile *in) {
|
||||||
archery = stream->readByte();
|
archery = in->readByte();
|
||||||
swordcraft = stream->readByte();
|
swordcraft = in->readByte();
|
||||||
shieldcraft = stream->readByte();
|
shieldcraft = in->readByte();
|
||||||
bludgeon = stream->readByte();
|
bludgeon = in->readByte();
|
||||||
throwing = stream->readByte();
|
throwing = in->readByte();
|
||||||
spellcraft = stream->readByte();
|
spellcraft = in->readByte();
|
||||||
stealth = stream->readByte();
|
stealth = in->readByte();
|
||||||
agility = stream->readByte();
|
agility = in->readByte();
|
||||||
brawn = stream->readByte();
|
brawn = in->readByte();
|
||||||
lockpick = stream->readByte();
|
lockpick = in->readByte();
|
||||||
pilfer = stream->readByte();
|
pilfer = in->readByte();
|
||||||
firstAid = stream->readByte();
|
firstAid = in->readByte();
|
||||||
spotHidden = stream->readByte();
|
spotHidden = in->readByte();
|
||||||
pad = stream->readSByte();
|
pad = in->readSByte();
|
||||||
vitality = stream->readSint16LE();
|
vitality = in->readSint16LE();
|
||||||
redMana = stream->readSint16LE();
|
redMana = in->readSint16LE();
|
||||||
orangeMana = stream->readSint16LE();
|
orangeMana = in->readSint16LE();
|
||||||
yellowMana = stream->readSint16LE();
|
yellowMana = in->readSint16LE();
|
||||||
greenMana = stream->readSint16LE();
|
greenMana = in->readSint16LE();
|
||||||
blueMana = stream->readSint16LE();
|
blueMana = in->readSint16LE();
|
||||||
violetMana = stream->readSint16LE();
|
violetMana = in->readSint16LE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(Common::OutSaveFile *out) {
|
void write(Common::OutSaveFile *out) {
|
||||||
|
@ -261,7 +261,7 @@ struct ResourceActorProtoExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(Common::SeekableReadStream *stream) {
|
void load(Common::SeekableReadStream *stream) {
|
||||||
baseStats.load(stream);
|
baseStats.read(stream);
|
||||||
combatBehavior = stream->readByte();
|
combatBehavior = stream->readByte();
|
||||||
gruntStyle = stream->readByte();
|
gruntStyle = stream->readByte();
|
||||||
baseEffectFlags = stream->readUint32LE();
|
baseEffectFlags = stream->readUint32LE();
|
||||||
|
|
|
@ -92,7 +92,6 @@ void initGameState(void) {
|
||||||
pauseTimer();
|
pauseTimer();
|
||||||
|
|
||||||
initGlobals();
|
initGlobals();
|
||||||
initImageCache();
|
|
||||||
initTimer();
|
initTimer();
|
||||||
initCalender();
|
initCalender();
|
||||||
initWorlds();
|
initWorlds();
|
||||||
|
@ -151,9 +150,9 @@ Common::Error saveGameState(int16 saveNo, char *saveName) {
|
||||||
saveActors(out);
|
saveActors(out);
|
||||||
saveObjects(out);
|
saveObjects(out);
|
||||||
saveBands(out);
|
saveBands(out);
|
||||||
|
savePlayerActors(out);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
savePlayerActors(saveGame);
|
|
||||||
saveCenterActor(saveGame);
|
saveCenterActor(saveGame);
|
||||||
saveActiveItemStates(saveGame);
|
saveActiveItemStates(saveGame);
|
||||||
saveTileCyclingStates(saveGame);
|
saveTileCyclingStates(saveGame);
|
||||||
|
@ -274,15 +273,15 @@ void loadSavedGameState(int16 saveNo) {
|
||||||
} else
|
} else
|
||||||
error("Bands loaded prematurely");
|
error("Bands loaded prematurely");
|
||||||
break;
|
break;
|
||||||
#if 0
|
|
||||||
|
|
||||||
case MKTAG('P', 'L', 'Y', 'R'):
|
case MKTAG('P', 'L', 'Y', 'R'):
|
||||||
if (loadFlags & loadBandsFlag) {
|
if (loadFlags & loadBandsFlag) {
|
||||||
loadPlayerActors(saveGame);
|
loadPlayerActors(in);
|
||||||
loadFlags |= loadPlayerActorsFlag;
|
loadFlags |= loadPlayerActorsFlag;
|
||||||
} else
|
} else
|
||||||
error("PlayerActors loaded prematurely");
|
error("PlayerActors loaded prematurely");
|
||||||
break;
|
break;
|
||||||
|
#if 0
|
||||||
|
|
||||||
case MKTAG('C', 'N', 'T', 'R'):
|
case MKTAG('C', 'N', 'T', 'R'):
|
||||||
loadCenterActor(saveGame);
|
loadCenterActor(saveGame);
|
||||||
|
@ -510,7 +509,6 @@ void cleanupGameState(void) {
|
||||||
cleanupWorlds();
|
cleanupWorlds();
|
||||||
cleanupAudio();
|
cleanupAudio();
|
||||||
cleanupTimer();
|
cleanupTimer();
|
||||||
cleanupImageCache();
|
|
||||||
cleanupGlobals();
|
cleanupGlobals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -986,6 +986,51 @@ void savePlayerActors(SaveFileConstructor &saveGame) {
|
||||||
sizeof(archiveBuffer));
|
sizeof(archiveBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void savePlayerActors(Common::OutSaveFile *out) {
|
||||||
|
debugC(2, kDebugSaveload, "Saving PlayerActors");
|
||||||
|
|
||||||
|
const int archiveSize = playerActors * 38;
|
||||||
|
|
||||||
|
out->write("PLYR", 4);
|
||||||
|
out->writeUint32LE(archiveSize);
|
||||||
|
|
||||||
|
for (int i = 0; i < playerActors; i++) {
|
||||||
|
debugC(3, kDebugSaveload, "Saving PlayerActor %d", i);
|
||||||
|
|
||||||
|
PlayerActor *p = &playerList[i];
|
||||||
|
|
||||||
|
// Store the portrait type
|
||||||
|
out->writeSint16LE(p->portraitType);
|
||||||
|
|
||||||
|
// Store the flags
|
||||||
|
out->writeUint16LE(p->flags);
|
||||||
|
|
||||||
|
// Store the base stats
|
||||||
|
p->baseStats.write(out);
|
||||||
|
|
||||||
|
// Store accumulation arrays
|
||||||
|
for (int j = 0; j < numManas; ++j)
|
||||||
|
out->writeSint16LE(p->manaMemory[j]);
|
||||||
|
|
||||||
|
for (int j = 0; j < numSkills; ++j)
|
||||||
|
out->writeByte(p->attribRecPools[j]);
|
||||||
|
|
||||||
|
for (int j = 0; j < numSkills; ++j)
|
||||||
|
out->writeByte(p->attribMemPools[j]);
|
||||||
|
|
||||||
|
// Store the vitality memory
|
||||||
|
out->writeByte(p->vitalityMemory);
|
||||||
|
|
||||||
|
// Store the attack notification flag
|
||||||
|
out->writeByte(p->notifiedOfAttack);
|
||||||
|
|
||||||
|
debugC(4, kDebugSaveload, "... playerList[%d].portraitType = %d", i, p->portraitType);
|
||||||
|
debugC(4, kDebugSaveload, "... playerList[%d].flags = %d", i, p->flags);
|
||||||
|
debugC(4, kDebugSaveload, "... playerList[%d].vitalityMemory = %d", i, p->vitalityMemory);
|
||||||
|
debugC(4, kDebugSaveload, "... playerList[%d].notifiedOfAttack = %d", i, p->notifiedOfAttack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Load the player list data from a save file
|
// Load the player list data from a save file
|
||||||
|
|
||||||
|
@ -1032,6 +1077,48 @@ void loadPlayerActors(SaveFileReader &saveGame) {
|
||||||
readyContainerSetup();
|
readyContainerSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loadPlayerActors(Common::InSaveFile *in) {
|
||||||
|
debugC(2, kDebugSaveload, "Loading PlayerActors");
|
||||||
|
|
||||||
|
for (int i = 0; i < playerActors; i++) {
|
||||||
|
debugC(3, kDebugSaveload, "Loading PlayerActor %d", i);
|
||||||
|
|
||||||
|
PlayerActor *p = &playerList[i];
|
||||||
|
|
||||||
|
// Restore the portrait type
|
||||||
|
p->portraitType = in->readSint16LE();
|
||||||
|
|
||||||
|
// Restore the flags
|
||||||
|
p->flags = in->readUint16LE();
|
||||||
|
|
||||||
|
// Restore the base stats
|
||||||
|
p->baseStats.read(in);
|
||||||
|
|
||||||
|
// Restore the accumulation arrays
|
||||||
|
for (int j = 0; j < numManas; ++j)
|
||||||
|
p->manaMemory[j] = in->readSint16LE();
|
||||||
|
|
||||||
|
for (int j = 0; j < numSkills; ++j)
|
||||||
|
p->attribRecPools[j] = in->readByte();
|
||||||
|
|
||||||
|
for (int j = 0; j < numSkills; ++j)
|
||||||
|
p->attribMemPools[j] = in->readByte();
|
||||||
|
|
||||||
|
// Restore the vitality memory
|
||||||
|
p->vitalityMemory = in->readByte();
|
||||||
|
|
||||||
|
// Restore the attack notification flag
|
||||||
|
p->notifiedOfAttack = in->readByte();
|
||||||
|
|
||||||
|
debugC(4, kDebugSaveload, "... playerList[%d].portraitType = %d", i, p->portraitType);
|
||||||
|
debugC(4, kDebugSaveload, "... playerList[%d].flags = %d", i, p->flags);
|
||||||
|
debugC(4, kDebugSaveload, "... playerList[%d].vitalityMemory = %d", i, p->vitalityMemory);
|
||||||
|
debugC(4, kDebugSaveload, "... playerList[%d].notifiedOfAttack = %d", i, p->notifiedOfAttack);
|
||||||
|
}
|
||||||
|
|
||||||
|
readyContainerSetup();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Cleanup the player actor list
|
// Cleanup the player actor list
|
||||||
|
|
||||||
|
|
|
@ -55,14 +55,13 @@ class PlayerActor {
|
||||||
friend void cleanupPlayerActors(void);
|
friend void cleanupPlayerActors(void);
|
||||||
|
|
||||||
ObjectID actorID; // ID of player's actor
|
ObjectID actorID; // ID of player's actor
|
||||||
|
|
||||||
|
public:
|
||||||
int16 portraitType; // Integer representing portrait state
|
int16 portraitType; // Integer representing portrait state
|
||||||
// for this player actor
|
// for this player actor
|
||||||
uint16 flags; // various flags
|
uint16 flags; // various flags
|
||||||
|
|
||||||
ActorAttributes baseStats; // Base stats for this actor
|
ActorAttributes baseStats; // Base stats for this actor
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum PlayerActorFlags {
|
enum PlayerActorFlags {
|
||||||
playerAggressive = (1 << 0), // Player is in aggressive mode
|
playerAggressive = (1 << 0), // Player is in aggressive mode
|
||||||
playerBanded = (1 << 1), // Player is banded
|
playerBanded = (1 << 1), // Player is banded
|
||||||
|
@ -305,9 +304,11 @@ void initPlayerActors(void);
|
||||||
|
|
||||||
// Store the player actor list in a save file
|
// Store the player actor list in a save file
|
||||||
void savePlayerActors(SaveFileConstructor &saveGame);
|
void savePlayerActors(SaveFileConstructor &saveGame);
|
||||||
|
void savePlayerActors(Common::OutSaveFile *out);
|
||||||
|
|
||||||
// Load the player list data from a save file
|
// Load the player list data from a save file
|
||||||
void loadPlayerActors(SaveFileReader &saveGame);
|
void loadPlayerActors(SaveFileReader &saveGame);
|
||||||
|
void loadPlayerActors(Common::InSaveFile *in);
|
||||||
|
|
||||||
// Cleanup the player actor list
|
// Cleanup the player actor list
|
||||||
void cleanupPlayerActors(void);
|
void cleanupPlayerActors(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue