[Scummvm-git-logs] scummvm master -> 3d4a8a6893d53f86da0a46c151b103bd0533ab8f
a-yyg
76591232+a-yyg at users.noreply.github.com
Thu Jul 8 17:33:02 UTC 2021
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
74294c8049 SAGA2: Implement Bands save/loading
a4e78598e2 SAGA2: Move _imagaCache constructor to Saga2Engine
3d4a8a6893 SAGA2: Implement PlayerActor save/loading
Commit: 74294c80492448ba6155149891c8c19770656f7b
https://github.com/scummvm/scummvm/commit/74294c80492448ba6155149891c8c19770656f7b
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-08T23:04:49+09:00
Commit Message:
SAGA2: Implement Bands save/loading
Changed paths:
engines/saga2/band.cpp
engines/saga2/band.h
engines/saga2/loadsave.cpp
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index b4b6376bbd..971c375c6a 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -54,6 +54,8 @@ public:
// Reconstruct from an archive buffer
void *restore(void *buf);
+ void read(Common::InSaveFile *in);
+
// Return the number of bytes necessary to archive this task list
// in a buffer
int32 archiveSize(void);
@@ -61,6 +63,8 @@ public:
// Create an archive of the task list in an archive buffer
void *archive(void *buf);
+ void write(Common::OutSaveFile *out);
+
// Place a Band from the inactive list into the active
// list.
Band *newBand(void);
@@ -129,6 +133,23 @@ void *BandList::restore(void *buf) {
return buf;
}
+void BandList::read(Common::InSaveFile *in) {
+ int16 bandCount;
+ // Get the count of bands and increment the buffer pointer
+ bandCount = in->readSint16LE();
+
+ // Iterate through the archive data, reconstructing the Bands
+ for (int i = 0; i < bandCount; i++) {
+ BandID id;
+
+ // Retreive the Band's id number
+ id = in->readSint16LE();
+ debugC(3, kDebugSaveload, "Loading Band %d", id);
+
+ _list[id] = new Band(in);
+ }
+}
+
//----------------------------------------------------------------------
// Return the number of bytes necessary to archive this TaskList
@@ -171,6 +192,30 @@ void *BandList::archive(void *buf) {
return buf;
}
+void BandList::write(Common::OutSaveFile *out) {
+ int16 bandCount = 0;
+
+ // Count the active bands
+ for (int i = 0; i < kNumBands; i++)
+ if (_list[i])
+ bandCount++;
+
+ // Store the band count in the archive buffer
+ out->writeSint16LE(bandCount);
+ debugC(3, kDebugSaveload, "... bandCount = %d", bandCount);
+
+ // Iterate through the bands, archiving each
+ for (int i = 0; i < kNumBands; i++) {
+ if (_list[i]) {
+ // Store the Band's id number
+ out->writeSint16LE(i);
+ debugC(3, kDebugSaveload, "Saving Band %d", i);
+
+ _list[i]->write(out);
+ }
+ }
+}
+
//----------------------------------------------------------------------
// Place a Band into the active list and return its address
@@ -293,6 +338,19 @@ void saveBands(SaveFileConstructor &saveGame) {
free(archiveBuffer);
}
+void saveBands(Common::OutSaveFile *out) {
+ debugC(2, kDebugSaveload, "Saving Bands");
+
+ int32 archiveBufSize;
+
+ archiveBufSize = g_vm->_bandList->archiveSize();
+
+ out->write("BAND", 4);
+ out->writeUint32LE(archiveBufSize);
+
+ g_vm->_bandList->write(out);
+}
+
//----------------------------------------------------------------------
// Load the bandList from a save file
@@ -322,6 +380,20 @@ void loadBands(SaveFileReader &saveGame) {
free(archiveBuffer);
}
+void loadBands(Common::InSaveFile *in, int32 chunkSize) {
+ debugC(2, kDebugSaveload, "Loading Bands");
+
+ // If there is no saved data, simply call the default constructor
+ if (chunkSize == 0) {
+ g_vm->_bandList = new BandList;
+ return;
+ }
+
+ // Reconstruct taskList from archived data
+ g_vm->_bandList = new BandList;
+ g_vm->_bandList->read(in);
+}
+
//----------------------------------------------------------------------
// Cleanup the bandList
@@ -376,6 +448,36 @@ Band::Band(void **buf) {
g_vm->_bandList->addBand(this);
}
+Band::Band(Common::InSaveFile *in) {
+ ObjectID leaderID = in->readUint16LE();
+
+ // Restore the leader pointer
+ assert(isActor(leaderID));
+ leader = (Actor *)GameObject::objectAddress(leaderID);
+
+ debugC(4, kDebugSaveload, "... leaderID = %d", leaderID);
+
+ // Restore the member count
+ memberCount = in->readSint16LE();
+ assert(memberCount < ARRAYSIZE(members));
+
+ debugC(4, kDebugSaveload, "... memberCount = %d", memberCount);
+
+ for (int i = 0; i < maxBandMembers; i++)
+ members[i] = nullptr;
+
+ // Restore the member pointers
+ for (int i = 0; i < memberCount; i++) {
+ ObjectID id = in->readUint16LE();
+ assert(isActor(id));
+ members[i] = (Actor *)GameObject::objectAddress(id);
+
+ debugC(4, kDebugSaveload , "... id = %d", id);
+ }
+
+ g_vm->_bandList->addBand(this);
+}
+
//----------------------------------------------------------------------
// Return the number of bytes needed to archive this object in a
// buffer
@@ -409,4 +511,22 @@ void *Band::archive(void *buf) {
return buf;
}
+void Band::write(Common::OutSaveFile *out) {
+ // Store the leader's ID
+ out->writeUint16LE(leader->thisID());
+
+ debugC(4, kDebugSaveload, "... leader->thisID() = %d", leader->thisID());
+
+ // Store the member count
+ out->writeSint16LE(memberCount);
+
+ debugC(4, kDebugSaveload, "... memberCount = %d", memberCount);
+
+ // Store the members' ID's
+ for (int i = 0; i < memberCount; i++) {
+ out->writeUint16LE(members[i]->thisID());
+ debugC(4, kDebugSaveload, "... members[%d]->thisID() = %d", i, members[i]->thisID());
+ }
+}
+
} // end of namespace Saga2
diff --git a/engines/saga2/band.h b/engines/saga2/band.h
index 8f8e15233c..34598478b3 100644
--- a/engines/saga2/band.h
+++ b/engines/saga2/band.h
@@ -53,8 +53,10 @@ Band *getBandAddress(BandID id);
void initBands(void);
// Save the active band structures in a save file
void saveBands(SaveFileConstructor &saveGame);
+void saveBands(Common::OutSaveFile *out);
// Load the band structures from a save file
void loadBands(SaveFileReader &saveGame);
+void loadBands(Common::InSaveFile *in, int32 chunkSize);
// Cleanup the band list
void cleanupBands(void);
@@ -76,6 +78,8 @@ public:
// Constructor -- reconstruct from archive buffer
Band(void **buf);
+ Band(Common::InSaveFile *in);
+
~Band() { deleteBand(this); }
// Return the number of bytes needed to archive this object in a
@@ -85,6 +89,8 @@ public:
// Archive this object in a buffer
void *archive(void *buf);
+ void write(Common::OutSaveFile *out);
+
Actor *getLeader(void) {
return leader;
}
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index 9ec1cb698f..63207cfe21 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -150,9 +150,9 @@ Common::Error saveGameState(int16 saveNo, char *saveName) {
saveWorlds(out);
saveActors(out);
saveObjects(out);
+ saveBands(out);
#if 0
- saveBands(saveGame);
savePlayerActors(saveGame);
saveCenterActor(saveGame);
saveActiveItemStates(saveGame);
@@ -266,15 +266,15 @@ void loadSavedGameState(int16 saveNo) {
loadObjects(in);
loadFlags |= loadObjectsFlag;
break;
-#if 0
case MKTAG('B', 'A', 'N', 'D'):
if (loadFlags & loadActorsFlag) {
- loadBands(saveGame);
+ loadBands(in, chunkSize);
loadFlags |= loadBandsFlag;
} else
error("Bands loaded prematurely");
break;
+#if 0
case MKTAG('P', 'L', 'Y', 'R'):
if (loadFlags & loadBandsFlag) {
Commit: a4e78598e2b5bd3f08c78c55ef098c5e625ed4a1
https://github.com/scummvm/scummvm/commit/a4e78598e2b5bd3f08c78c55ef098c5e625ed4a1
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-09T02:17:19+09:00
Commit Message:
SAGA2: Move _imagaCache constructor to Saga2Engine
Changed paths:
engines/saga2/imagcach.cpp
engines/saga2/imagcach.h
engines/saga2/saga2.cpp
diff --git a/engines/saga2/imagcach.cpp b/engines/saga2/imagcach.cpp
index a50707b4f3..6fe544df88 100644
--- a/engines/saga2/imagcach.cpp
+++ b/engines/saga2/imagcach.cpp
@@ -35,14 +35,6 @@ namespace Saga2 {
extern char *idname(long s);
#endif
-void initImageCache() {
- g_vm->_imageCache = new CImageCache;
-}
-
-void cleanupImageCache() {
- delete g_vm->_imageCache;
-}
-
CImageNode::CImageNode(hResContext *con, uint32 resID) {
if (con) {
#if DEBUG
diff --git a/engines/saga2/imagcach.h b/engines/saga2/imagcach.h
index 9c6e790430..84249fe454 100644
--- a/engines/saga2/imagcach.h
+++ b/engines/saga2/imagcach.h
@@ -29,9 +29,6 @@
namespace Saga2 {
-void initImageCache(void);
-void cleanupImageCache(void);
-
/* ===================================================================== *
ImageNode class which defines a re-entrant image resource
* ===================================================================== */
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index e821a65c7e..650c16b3d6 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -37,6 +37,7 @@
#include "saga2/gdraw.h"
#include "saga2/mouseimg.h"
#include "saga2/contain.h"
+#include "saga2/imagcach.h"
namespace Saga2 {
@@ -54,7 +55,6 @@ Saga2Engine::Saga2Engine(OSystem *syst)
g_vm = this;
_bandList = nullptr;
- _imageCache = nullptr;
_mouseInfo = nullptr;
_smkDecoder = nullptr;
_videoX = _videoY = 0;
@@ -70,6 +70,8 @@ Saga2Engine::Saga2Engine(OSystem *syst)
SearchMan.addSubDirectoryMatching(gameDataDir, "drivers");
_loadedWeapons = 0;
+
+ _imageCache = new CImageCache;
}
Saga2Engine::~Saga2Engine() {
@@ -79,6 +81,7 @@ Saga2Engine::~Saga2Engine() {
// Dispose your resources here
delete _rnd;
+ delete _imageCache;
}
Common::Error Saga2Engine::run() {
Commit: 3d4a8a6893d53f86da0a46c151b103bd0533ab8f
https://github.com/scummvm/scummvm/commit/3d4a8a6893d53f86da0a46c151b103bd0533ab8f
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-09T02:31:52+09:00
Commit Message:
SAGA2: Implement PlayerActor save/loading
Changed paths:
engines/saga2/actor.cpp
engines/saga2/actor.h
engines/saga2/loadsave.cpp
engines/saga2/player.cpp
engines/saga2/player.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index f9a69bc111..4557362f96 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -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();
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index 5150d856e0..b5c20483e7 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -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();
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index 63207cfe21..e98d0a7fa0 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -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();
}
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index 5d62cfebac..52008185cd 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -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
diff --git a/engines/saga2/player.h b/engines/saga2/player.h
index 280afeb30a..0c1faf99eb 100644
--- a/engines/saga2/player.h
+++ b/engines/saga2/player.h
@@ -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);
More information about the Scummvm-git-logs
mailing list