[Scummvm-git-logs] scummvm master -> 0b0c3ed4466520fc0d709f8d40b861f9e228a5fb

a-yyg 76591232+a-yyg at users.noreply.github.com
Thu Jul 15 14:34:48 UTC 2021


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
93f24f239c SAGA2: Make more save chunk sizes portable
0b0c3ed446 SAGA2: Fix Container deletion


Commit: 93f24f239cfe6ed5747f75f4b3dbc69ac3a9db22
    https://github.com/scummvm/scummvm/commit/93f24f239cfe6ed5747f75f4b3dbc69ac3a9db22
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-15T23:33:40+09:00

Commit Message:
SAGA2: Make more save chunk sizes portable

Changed paths:
    engines/saga2/interp.cpp
    engines/saga2/player.cpp
    engines/saga2/player.h
    engines/saga2/script.h
    engines/saga2/tile.cpp
    engines/saga2/tile.h


diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 37c144104e..6bfdbd7c16 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1685,12 +1685,13 @@ void initSAGADataSeg(void) {
 	scriptRes->read(dataSegment, dataSegSize);
 }
 
-void saveSAGADataSeg(Common::OutSaveFile *out) {
+void saveSAGADataSeg(Common::OutSaveFile *outS) {
 	debugC(2, kDebugSaveload, "Saving Data Segment");
 
-	out->write("SDTA", 4);
-	out->writeUint32LE(dataSegSize);
+	outS->write("SDTA", 4);
+	CHUNK_BEGIN;
 	out->write(dataSegment, dataSegSize);
+	CHUNK_END;
 }
 
 void loadSAGADataSeg(Common::InSaveFile *in) {
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index 5acd226e8c..7df8e12975 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -1049,16 +1049,15 @@ void initCenterActor(void) {
 	updateBrotherRadioButtons(FTA_JULIAN);
 }
 
-void saveCenterActor(Common::OutSaveFile *out) {
+void saveCenterActor(Common::OutSaveFile *outS) {
 	debugC(2, kDebugSaveload, "Saving CenterActor");
 
-	const int32 centerActorArchiveSize = 4;
-
-	out->write("CNTR", 4);
-	out->writeUint32LE(centerActorArchiveSize);
+	outS->write("CNTR", 4);
+	CHUNK_BEGIN;
 	//  Store the center actor and view object
 	out->writeSint16LE(centerActor);
 	out->writeUint16LE(viewCenterObject);
+	CHUNK_END;
 
 	debugC(3, kDebugSaveload, "... centerActor = %d", centerActor);
 	debugC(3, kDebugSaveload, "... viewCenterObject = %d", viewCenterObject);
diff --git a/engines/saga2/player.h b/engines/saga2/player.h
index 056880eb9a..ad795237bd 100644
--- a/engines/saga2/player.h
+++ b/engines/saga2/player.h
@@ -307,7 +307,7 @@ void cleanupPlayerActors(void);
 //  Initialize the center actor ID and view object ID
 void initCenterActor(void);
 
-void saveCenterActor(Common::OutSaveFile *out);
+void saveCenterActor(Common::OutSaveFile *outS);
 void loadCenterActor(Common::InSaveFile *in);
 
 //  Do nothing
diff --git a/engines/saga2/script.h b/engines/saga2/script.h
index 20adc9b64d..9c282b540e 100644
--- a/engines/saga2/script.h
+++ b/engines/saga2/script.h
@@ -124,7 +124,7 @@ enum builtinTypes {
 //  Load the SAGA data segment from the resource file
 void initSAGADataSeg(void);
 
-void saveSAGADataSeg(Common::OutSaveFile *out);
+void saveSAGADataSeg(Common::OutSaveFile *outS);
 void loadSAGADataSeg(Common::InSaveFile *in);
 
 //  Dispose of the SAGA data segment -- do nothing
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index da455f0355..37433a78b1 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -904,44 +904,6 @@ TileActivityTaskList::TileActivityTaskList(void) {
 //-----------------------------------------------------------------------
 //	Reconstruct the TileActivityTaskList from an archive buffer
 
-TileActivityTaskList::TileActivityTaskList(void **buf) {
-	warning("STUB: TileActivityTaskList::TileActivityTaskList(void **buf)");
-#if 0
-	void        *bufferPtr = *buf;
-
-	int16       taskCount;
-
-	for (uint i = 0; i < ARRAYSIZE(array); i++) {
-		free.addTail(array[i]);
-	}
-
-	//  Retreive the task count
-	taskCount = READ_LE_INT16(bufferPtr);
-	bufferPtr = (int16 *)bufferPtr + 1;
-
-	for (int i = 0; i < taskCount; i++) {
-		ActiveItem  *tai;
-		uint8       activityType;
-
-		tai = ActiveItem::activeItemAddress(*((ActiveItemID *)bufferPtr));
-		bufferPtr = (ActiveItemID *)bufferPtr + 1;
-
-		activityType = *((uint8 *)bufferPtr);
-		bufferPtr = (uint8 *)bufferPtr + 1;
-
-		if (tai != nullptr) {
-			TileActivityTask    *tat;
-
-			tat = newTask(tai);
-			if (tat != nullptr)
-				tat->activityType = activityType;
-		}
-	}
-
-	*buf = bufferPtr;
-#endif
-}
-
 TileActivityTaskList::TileActivityTaskList(Common::SeekableReadStream *stream) {
 	read(stream);
 }
@@ -950,15 +912,6 @@ TileActivityTaskList::TileActivityTaskList(Common::SeekableReadStream *stream) {
 //	Return the number of bytes needed to archive this
 //	TileActivityTaskList
 
-int32 TileActivityTaskList::archiveSize(void) {
-	int32 size = sizeof(int16);
-
-	for (Common::List<TileActivityTask *>::iterator it = _list.begin(); it != _list.end(); ++it)
-		size += sizeof(ActiveItemID) + sizeof(uint8);
-
-	return size;
-}
-
 void TileActivityTaskList::read(Common::InSaveFile *in) {
 	int16 taskCount;
 
@@ -987,7 +940,7 @@ void TileActivityTaskList::read(Common::InSaveFile *in) {
 	}
 }
 
-void TileActivityTaskList::write(Common::OutSaveFile *out) {
+void TileActivityTaskList::write(Common::MemoryWriteStreamDynamic *out) {
 	int16 taskCount = _list.size();
 
 	//  Store the task count
@@ -1229,16 +1182,13 @@ void moveActiveTerrain(int32 deltaTime) {
 void initTileTasks(void) {
 }
 
-void saveTileTasks(Common::OutSaveFile *out) {
+void saveTileTasks(Common::OutSaveFile *outS) {
 	debugC(2, kDebugSaveload, "Saving TileActivityTasks");
 
-	int32   archiveBufSize;
-	archiveBufSize = aTaskList.archiveSize();
-
-	out->write("TACT", 4);
-	out->writeUint32LE(archiveBufSize);
-
+	outS->write("TACT", 4);
+	CHUNK_BEGIN;
 	aTaskList.write(out);
+	CHUNK_END;
 }
 
 void loadTileTasks(Common::InSaveFile *in, int32 chunkSize) {
@@ -4235,14 +4185,10 @@ void initTileCyclingStates(void) {
 	}
 }
 
-void saveTileCyclingStates(Common::OutSaveFile *out) {
+void saveTileCyclingStates(Common::OutSaveFile *outS) {
 	debugC(2, kDebugSaveload, "Saving TileCyclingStates");
-
-	const int tileCycleArchiveSize = 4 + 1;
-
-	out->write("CYCL", 4);
-	out->writeUint32LE(tileCycleArchiveSize * cycleCount);
-
+	outS->write("CYCL", 4);
+	CHUNK_BEGIN;
 	for (int i = 0; i < cycleCount; i++) {
 		debugC(3, kDebugSaveload, "Saving TileCyclingState %d", i);
 
@@ -4252,6 +4198,7 @@ void saveTileCyclingStates(Common::OutSaveFile *out) {
 		debugC(4, kDebugSaveload, "... counter = %d", cycleList[i].counter);
 		debugC(4, kDebugSaveload, "... currentState = %d", cycleList[i].currentState);
 	}
+	CHUNK_END;
 }
 
 void loadTileCyclingStates(Common::InSaveFile *in) {
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 63ede4d379..a42b4c0f54 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -611,16 +611,10 @@ public:
 	TileActivityTaskList(void);
 
 	//  Reconstruct the TileActivityTaskList from an archive buffer
-	TileActivityTaskList(void **buf);
-
 	TileActivityTaskList(Common::SeekableReadStream *stream);
 
-	//  Return the number of bytes needed to archive this
-	//  TileActivityTaskList
-	int32 archiveSize(void);
-
 	void read(Common::InSaveFile *in);
-	void write(Common::OutSaveFile *out);
+	void write(Common::MemoryWriteStreamDynamic *out);
 
 	//  Cleanup this list
 	void cleanup(void);
@@ -1002,7 +996,7 @@ void initPlatformCache(void);
 //  Initialize the tile activity task list
 void initTileTasks(void);
 
-void saveTileTasks(Common::OutSaveFile *out);
+void saveTileTasks(Common::OutSaveFile *outS);
 void loadTileTasks(Common::InSaveFile *in, int32 chunkSize);
 
 //  Cleanup the tile activity task list
@@ -1016,7 +1010,7 @@ void loadActiveItemStates(Common::InSaveFile *in);
 void cleanupActiveItemStates(void);
 
 void initTileCyclingStates(void);
-void saveTileCyclingStates(Common::OutSaveFile *out);
+void saveTileCyclingStates(Common::OutSaveFile *outS);
 void loadTileCyclingStates(Common::InSaveFile *in);
 void cleanupTileCyclingStates(void);
 


Commit: 0b0c3ed4466520fc0d709f8d40b861f9e228a5fb
    https://github.com/scummvm/scummvm/commit/0b0c3ed4466520fc0d709f8d40b861f9e228a5fb
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-15T23:34:13+09:00

Commit Message:
SAGA2: Fix Container deletion

Changed paths:
    engines/saga2/contain.cpp


diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index c06bf1f8ee..35678628c7 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -1847,12 +1847,17 @@ void loadContainerNodes(Common::InSaveFile *in) {
 }
 
 void cleanupContainerNodes(void) {
+	Common::Array<ContainerNode *> deletionArray;
+
 	for (Common::List<ContainerNode *>::iterator it = g_vm->_containerList->_list.begin(); it != g_vm->_containerList->_list.end(); ++it) {
 		ContainerNode *n = *it;
 
 		if (n->getType() != ContainerNode::readyType)
-			delete n;
+			deletionArray.push_back(*it);
 	}
+
+	for (uint i = 0; i < deletionArray.size(); ++i)
+		delete deletionArray[i];
 }
 
 void updateContainerWindows(void) {




More information about the Scummvm-git-logs mailing list