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();
|
||||
currentGoal = in->readByte();
|
||||
deactivationCounter = in->readByte();
|
||||
effectiveStats.load(in);
|
||||
effectiveStats.read(in);
|
||||
actionCounter = in->readByte();
|
||||
effectiveResistance = in->readUint16LE();
|
||||
effectiveImmunity = in->readUint16LE();
|
||||
|
|
|
@ -171,28 +171,28 @@ struct ActorAttributes {
|
|||
return skill(id) / skillFracPointsPerLevel + 1;
|
||||
}
|
||||
|
||||
void load(Common::SeekableReadStream *stream) {
|
||||
archery = stream->readByte();
|
||||
swordcraft = stream->readByte();
|
||||
shieldcraft = stream->readByte();
|
||||
bludgeon = stream->readByte();
|
||||
throwing = stream->readByte();
|
||||
spellcraft = stream->readByte();
|
||||
stealth = stream->readByte();
|
||||
agility = stream->readByte();
|
||||
brawn = stream->readByte();
|
||||
lockpick = stream->readByte();
|
||||
pilfer = stream->readByte();
|
||||
firstAid = stream->readByte();
|
||||
spotHidden = stream->readByte();
|
||||
pad = stream->readSByte();
|
||||
vitality = stream->readSint16LE();
|
||||
redMana = stream->readSint16LE();
|
||||
orangeMana = stream->readSint16LE();
|
||||
yellowMana = stream->readSint16LE();
|
||||
greenMana = stream->readSint16LE();
|
||||
blueMana = stream->readSint16LE();
|
||||
violetMana = stream->readSint16LE();
|
||||
void read(Common::InSaveFile *in) {
|
||||
archery = in->readByte();
|
||||
swordcraft = in->readByte();
|
||||
shieldcraft = in->readByte();
|
||||
bludgeon = in->readByte();
|
||||
throwing = in->readByte();
|
||||
spellcraft = in->readByte();
|
||||
stealth = in->readByte();
|
||||
agility = in->readByte();
|
||||
brawn = in->readByte();
|
||||
lockpick = in->readByte();
|
||||
pilfer = in->readByte();
|
||||
firstAid = in->readByte();
|
||||
spotHidden = in->readByte();
|
||||
pad = in->readSByte();
|
||||
vitality = in->readSint16LE();
|
||||
redMana = in->readSint16LE();
|
||||
orangeMana = in->readSint16LE();
|
||||
yellowMana = in->readSint16LE();
|
||||
greenMana = in->readSint16LE();
|
||||
blueMana = in->readSint16LE();
|
||||
violetMana = in->readSint16LE();
|
||||
}
|
||||
|
||||
void write(Common::OutSaveFile *out) {
|
||||
|
@ -261,7 +261,7 @@ struct ResourceActorProtoExtension {
|
|||
}
|
||||
|
||||
void load(Common::SeekableReadStream *stream) {
|
||||
baseStats.load(stream);
|
||||
baseStats.read(stream);
|
||||
combatBehavior = stream->readByte();
|
||||
gruntStyle = stream->readByte();
|
||||
baseEffectFlags = stream->readUint32LE();
|
||||
|
|
|
@ -92,7 +92,6 @@ void initGameState(void) {
|
|||
pauseTimer();
|
||||
|
||||
initGlobals();
|
||||
initImageCache();
|
||||
initTimer();
|
||||
initCalender();
|
||||
initWorlds();
|
||||
|
@ -151,9 +150,9 @@ Common::Error saveGameState(int16 saveNo, char *saveName) {
|
|||
saveActors(out);
|
||||
saveObjects(out);
|
||||
saveBands(out);
|
||||
savePlayerActors(out);
|
||||
|
||||
#if 0
|
||||
savePlayerActors(saveGame);
|
||||
saveCenterActor(saveGame);
|
||||
saveActiveItemStates(saveGame);
|
||||
saveTileCyclingStates(saveGame);
|
||||
|
@ -274,15 +273,15 @@ void loadSavedGameState(int16 saveNo) {
|
|||
} else
|
||||
error("Bands loaded prematurely");
|
||||
break;
|
||||
#if 0
|
||||
|
||||
case MKTAG('P', 'L', 'Y', 'R'):
|
||||
if (loadFlags & loadBandsFlag) {
|
||||
loadPlayerActors(saveGame);
|
||||
loadPlayerActors(in);
|
||||
loadFlags |= loadPlayerActorsFlag;
|
||||
} else
|
||||
error("PlayerActors loaded prematurely");
|
||||
break;
|
||||
#if 0
|
||||
|
||||
case MKTAG('C', 'N', 'T', 'R'):
|
||||
loadCenterActor(saveGame);
|
||||
|
@ -510,7 +509,6 @@ void cleanupGameState(void) {
|
|||
cleanupWorlds();
|
||||
cleanupAudio();
|
||||
cleanupTimer();
|
||||
cleanupImageCache();
|
||||
cleanupGlobals();
|
||||
}
|
||||
|
||||
|
|
|
@ -986,6 +986,51 @@ void savePlayerActors(SaveFileConstructor &saveGame) {
|
|||
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
|
||||
|
||||
|
@ -1032,6 +1077,48 @@ void loadPlayerActors(SaveFileReader &saveGame) {
|
|||
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
|
||||
|
||||
|
|
|
@ -55,14 +55,13 @@ class PlayerActor {
|
|||
friend void cleanupPlayerActors(void);
|
||||
|
||||
ObjectID actorID; // ID of player's actor
|
||||
|
||||
public:
|
||||
int16 portraitType; // Integer representing portrait state
|
||||
// for this player actor
|
||||
uint16 flags; // various flags
|
||||
|
||||
ActorAttributes baseStats; // Base stats for this actor
|
||||
|
||||
|
||||
public:
|
||||
enum PlayerActorFlags {
|
||||
playerAggressive = (1 << 0), // Player is in aggressive mode
|
||||
playerBanded = (1 << 1), // Player is banded
|
||||
|
@ -305,9 +304,11 @@ void initPlayerActors(void);
|
|||
|
||||
// Store the player actor list in a save file
|
||||
void savePlayerActors(SaveFileConstructor &saveGame);
|
||||
void savePlayerActors(Common::OutSaveFile *out);
|
||||
|
||||
// Load the player list data from a save file
|
||||
void loadPlayerActors(SaveFileReader &saveGame);
|
||||
void loadPlayerActors(Common::InSaveFile *in);
|
||||
|
||||
// Cleanup the player actor list
|
||||
void cleanupPlayerActors(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue