[Scummvm-git-logs] scummvm master -> 04988e6626d7da187a9cf4ff27e7fb1b6ca0c080
a-yyg
76591232+a-yyg at users.noreply.github.com
Wed Jul 21 12:40:05 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:
27fec511ae SAGA2: Move actorList to Saga2Engine
40e91565a6 SAGA2: Fix MotionTask cleanup
04988e6626 SAGA2: Enable loading from launcher
Commit: 27fec511ae3db32d275b748bd02166647c82abda
https://github.com/scummvm/scummvm/commit/27fec511ae3db32d275b748bd02166647c82abda
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-21T21:39:07+09:00
Commit Message:
SAGA2: Move actorList to Saga2Engine
Changed paths:
engines/saga2/actor.cpp
engines/saga2/band.cpp
engines/saga2/objects.cpp
engines/saga2/saga2.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index f8a920235b..1daccdbc53 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -65,10 +65,6 @@ extern uint8 identityColors[256];
extern hResContext *listRes; // object list resource handle
-extern Actor *actorList;
-
-extern int32 actorListSize;
-
extern int16 actorLimboCount;
bool unstickObject(GameObject *obj);
@@ -1455,7 +1451,7 @@ Actor *Actor::newActor(
// Search actor list for first scavangable actor
for (i = kPlayerActors; i < kActorCount; i++) {
- a = &actorList[i];
+ a = g_vm->_actorList[i];
if ((a->flags & temporary)
&& !a->isActivated()
@@ -3390,7 +3386,7 @@ bool Actor::makeSavingThrow(void) {
// Determine if the actors are currently initialized
bool areActorsInitialized(void) {
- return actorList != NULL;
+ return g_vm->_actorList.size() > 0;
}
int16 GetRandomBetween(int start, int end) {
@@ -3403,13 +3399,12 @@ void updateActorStates(void) {
static const int32 evalRate = 8;
static const int32 evalRateMask = evalRate - 1;
static int32 baseActorIndex = evalRateMask;
- extern Actor *actorList;
int32 actorIndex;
actorIndex = baseActorIndex = (baseActorIndex + 1) & evalRateMask;
while (actorIndex < kActorCount) {
- Actor *a = &actorList[actorIndex];
+ Actor *a = g_vm->_actorList[actorIndex];
if (isWorld(a->IDParent()))
a->evaluateNeeds();
@@ -3419,7 +3414,7 @@ void updateActorStates(void) {
updatesViaScript = 0;
for (actorIndex = 0; actorIndex < kActorCount; actorIndex++) {
- Actor *a = &actorList[actorIndex];
+ Actor *a = g_vm->_actorList[actorIndex];
if (isWorld(a->IDParent()) && a->isActivated())
a->updateState();
@@ -3493,13 +3488,6 @@ void initActors(void) {
if (resourceActorCount < 1)
error("Unable to load Actors");
- // Allocate memory for the actor list
- actorListSize = kActorCount * sizeof(Actor);
- actorList = new Actor[kActorCount]();
-
- if (!actorList)
- error("Unable to load Actors");
-
if ((stream = loadResourceToStream(listRes, actorListID, "res actor list")) == nullptr)
error("Unable to load Actors");
@@ -3512,26 +3500,26 @@ void initActors(void) {
delete stream;
for (i = 0; i < resourceActorCount; i++) {
- Actor *a = &actorList[i];
-
// Initialize the actors with the resource data
- new (a) Actor(resourceActorList[i]);
+ Actor *a = new Actor(resourceActorList[i]);
- actorList[i]._index = i + ActorBaseID;
+ a->_index = i + ActorBaseID;
+
+ g_vm->_actorList.push_back(a);
}
// Place all of the extra actors in actor limbo
for (; i < kActorCount; i++) {
- Actor *a = &actorList[i];
+ Actor *a = new Actor;
- new (a) Actor;
+ a->_index = i + ActorBaseID;
- actorList[i]._index = i + ActorBaseID;
+ g_vm->_actorList.push_back(a);
}
- actorList[0].disposition = dispositionPlayer + 0;
- actorList[1].disposition = dispositionPlayer + 1;
- actorList[2].disposition = dispositionPlayer + 2;
+ g_vm->_actorList[0]->disposition = dispositionPlayer + 0;
+ g_vm->_actorList[1]->disposition = dispositionPlayer + 1;
+ g_vm->_actorList[2]->disposition = dispositionPlayer + 2;
}
void saveActors(Common::OutSaveFile *outS) {
@@ -3544,7 +3532,7 @@ void saveActors(Common::OutSaveFile *outS) {
debugC(3, kDebugSaveload, "... kActorCount = %d", kActorCount);
for (int i = 0; i < kActorCount; ++i)
- actorList[i].write(out);
+ g_vm->_actorList[i]->write(out);
CHUNK_END;
}
@@ -3556,17 +3544,13 @@ void loadActors(Common::InSaveFile *in) {
debugC(3, kDebugSaveload, "... kActorCount = %d", kActorCount);
- // Allocate the actor array
- actorListSize = kActorCount * sizeof(Actor);
- actorList = new Actor[kActorCount]();
- if (actorList == NULL)
- error("Unable to load Actors");
-
for (int i = 0; i < kActorCount; i++) {
// Initilize actors with archive data
- new (&actorList[i]) Actor(in);
+ Actor *a = new Actor(in);
- actorList[i]._index = i + ActorBaseID;
+ a->_index = i + ActorBaseID;
+
+ g_vm->_actorList.push_back(a);
}
}
@@ -3574,14 +3558,11 @@ void loadActors(Common::InSaveFile *in) {
// Cleanup the actor list
void cleanupActors(void) {
- if (actorList != NULL) {
- int16 i;
-
- for (i = 0; i < kActorCount; i++)
- actorList[i].~Actor();
+ if (g_vm->_actorList.size() > 0) {
+ for (int i = 0; i < kActorCount; i++)
+ delete g_vm->_actorList[i];
- delete[] actorList;
- actorList = NULL;
+ g_vm->_actorList.clear();
}
}
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index 5f4f2a30c5..d8868f8d0e 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -30,8 +30,6 @@
namespace Saga2 {
-extern Actor *actorList;
-
//----------------------------------------------------------------------
// BandList constructor -- simply place each element of the array in
// the inactive list
@@ -229,8 +227,8 @@ void loadBands(Common::InSaveFile *in, int32 chunkSize) {
// Reconstruct followers for actors
for (int i = 0; i < kActorCount; ++i) {
- BandID id = actorList[i]._followersID;
- actorList[i].followers = id != NoBand
+ BandID id = g_vm->_actorList[i]->_followersID;
+ g_vm->_actorList[i]->followers = id != NoBand
? getBandAddress(id)
: nullptr;
}
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 3d58fa3796..5040745a38 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -73,8 +73,6 @@ int16 objectProtoCount, // object prototype count
GameObject *objectList = nullptr; // list of all objects
const int16 objectCount = 4971; // count of objects
-Actor *actorList = nullptr; // list of all actors
-
GameWorld *worldList = nullptr; // list of all worlds
int16 worldCount; // number of worlds
@@ -352,7 +350,7 @@ bool isActor(GameObject *obj) {
if (obj->_index >= kActorCount + ActorBaseID || obj->_index < ActorBaseID)
return false;
- return (&actorList[obj->_index - ActorBaseID] == obj);
+ return (g_vm->_actorList[obj->_index - ActorBaseID] == obj);
}
bool isWorld(GameObject *obj) {
@@ -386,7 +384,7 @@ GameObject *GameObject::objectAddress(ObjectID id) {
if (id - ActorBaseID >= kActorCount)
error("Invalid object ID: %d!", id);
- return actorList != nullptr ? &actorList[id - ActorBaseID] : nullptr;
+ return (int)g_vm->_actorList.size() > id - ActorBaseID ? g_vm->_actorList[id - ActorBaseID] : nullptr;
}
ProtoObj *GameObject::protoAddress(ObjectID id) {
@@ -405,11 +403,11 @@ int32 GameObject::nameIndexToID(uint16 ind) {
}
for (int i = 0; i < kActorCount; ++i) {
- if (actorList[i]._data.nameIndex == ind)
- return actorList[i].thisID();
+ if (g_vm->_actorList[i]->_data.nameIndex == ind)
+ return g_vm->_actorList[i]->thisID();
- if (actorList[i].prototype && actorList[i].prototype->nameIndex == ind)
- return actorList[i].thisID();
+ if (g_vm->_actorList[i]->prototype && g_vm->_actorList[i]->prototype->nameIndex == ind)
+ return g_vm->_actorList[i]->thisID();
}
for (int i = 0; i < worldCount; ++i) {
@@ -3005,7 +3003,7 @@ void initObjects(void) {
// Make a pass over the actor list appending each actor to their
// parent's child list
for (i = 0; i < kActorCount; i++) {
- Actor *a = &actorList[i];
+ Actor *a = g_vm->_actorList[i];
if (a->_data.parentID == Nothing) {
a->append(ActorLimbo);
@@ -4568,7 +4566,7 @@ void doBackgroundSimulation(void) {
while (actorUpdateCount--) {
Actor *a;
- a = &actorList[actorIndex++];
+ a = g_vm->_actorList[actorIndex++];
// Wrap the counter around to the beginning if needed
if (actorIndex >= kActorCount) actorIndex = 0;
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index f0d99aefce..58ee9d8927 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -136,6 +136,7 @@ public:
WeaponStuff _weaponRack[kMaxWeapons];
weaponID _loadedWeapons;
Common::Array<char *> _nameList;
+ Common::Array<Actor *> _actorList;
Common::Array<PlayerActor *> _playerList;
Common::Array<ProtoObj *> _objectProtos;
Common::Array<ActorProto *> _actorProtos;
Commit: 40e91565a6137732c1f13044e4c8264a929e12dc
https://github.com/scummvm/scummvm/commit/40e91565a6137732c1f13044e4c8264a929e12dc
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-21T21:39:07+09:00
Commit Message:
SAGA2: Fix MotionTask cleanup
Changed paths:
engines/saga2/motion.cpp
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index e9a97ab090..f6b253f1a7 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -399,8 +399,12 @@ void MotionTaskList::write(Common::MemoryWriteStreamDynamic *out) {
// Cleanup the motion tasks
void MotionTaskList::cleanup(void) {
- for (Common::List<MotionTask *>::iterator it = _list.begin(); it != _list.end(); ++it)
+ for (Common::List<MotionTask *>::iterator it = _list.begin(); it != _list.end(); ++it) {
+ abortPathFind(*it);
+ (*it)->pathFindTask = NULL;
+
delete *it;
+ }
_list.clear();
}
Commit: 04988e6626d7da187a9cf4ff27e7fb1b6ca0c080
https://github.com/scummvm/scummvm/commit/04988e6626d7da187a9cf4ff27e7fb1b6ca0c080
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-21T21:39:07+09:00
Commit Message:
SAGA2: Enable loading from launcher
Changed paths:
engines/saga2/main.cpp
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index ee41c9c97b..d63f492d7d 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -24,6 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#include "common/config-manager.h"
#include "common/debug.h"
#include "common/events.h"
#include "common/memstream.h"
@@ -149,6 +150,7 @@ bool setupGame(void);
void mainEnable(void);
void mainDisable(void);
void lightsOut(void);
+void updateMainDisplay(void);
void cleanupGame(void); // auto-cleanup function
void parseCommandLine(int argc, char *argv[]);
@@ -190,6 +192,28 @@ void main_saga2() {
cleanExit = gameInitialized;
if (gameInitialized) {
+ if (ConfMan.hasKey("save_slot")) {
+ reDrawScreen();
+
+ disableUserControls();
+ cleanupGameState();
+
+ fadeDown();
+
+ loadSavedGameState(ConfMan.getInt("save_slot"));
+
+ if (GameMode::newmodeFlag)
+ GameMode::update();
+ updateActiveRegions();
+ enableUserControls();
+ updateMainDisplay();
+ drawMainDisplay();
+ enablePaletteChanges();
+ updateAllUserControls();
+ fadeUp();
+ reDrawScreen();
+ }
+
mainLoop(cleanExit, 0, NULL);
}
More information about the Scummvm-git-logs
mailing list