[Scummvm-git-logs] scummvm master -> da6a70c3e755c07f94a60a1c1a3cdee0e3d717cc

a-yyg 76591232+a-yyg at users.noreply.github.com
Wed Jul 7 20:36:06 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:
f1b4faa3d4 SAGA2: Implement Assignment loading
da6a70c3e7 SAGA2: Imlement Assignment saving


Commit: f1b4faa3d4b54d2672d88378d4f568245a4db32d
    https://github.com/scummvm/scummvm/commit/f1b4faa3d4b54d2672d88378d4f568245a4db32d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-08T04:34:39+09:00

Commit Message:
SAGA2: Implement Assignment loading

Changed paths:
    engines/saga2/actor.cpp
    engines/saga2/assign.cpp
    engines/saga2/assign.h
    engines/saga2/target.cpp
    engines/saga2/target.h


diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 1a8ab09253..a56c6e3c28 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1337,13 +1337,11 @@ Actor::Actor(Common::InSaveFile *in) : GameObject(in) {
 		scriptVar[i] = in->readSint16LE();
 
 	warning("STUB: Actor::Actor(Common::InSaveFile *): unfinished");
-#if 0
 	if (flags & hasAssignment) {
-		bufferPtr = constructAssignment(this, bufferPtr);
+		readAssignment(this, in);
 	} else {
 		_assignment = nullptr;
 	}
-#endif
 
 	appearance = nullptr;
 	moveTask = nullptr;
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 049c277b25..c1d2573a4e 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -66,6 +66,15 @@ ActorAssignment::ActorAssignment(Actor *ac, void **buf) {
 	ac->flags |= hasAssignment;
 }
 
+ActorAssignment::ActorAssignment(Actor *ac, Common::SeekableReadStream *stream) {
+	startFrame = stream->readUint16LE();
+	endFrame = stream->readUint16LE();
+
+	_actor = ac;
+	ac->_assignment = this;
+	ac->flags |= hasAssignment;
+}
+
 //----------------------------------------------------------------------
 //	ActorAssignment destructor
 
@@ -221,6 +230,23 @@ PatrolRouteAssignment::PatrolRouteAssignment(Actor *a, void **buf) :
 	*buf = bufferPtr;
 }
 
+PatrolRouteAssignment::PatrolRouteAssignment(Actor *a, Common::SeekableReadStream *stream) :
+	ActorAssignment(a, stream) {
+	debugC(4, kDebugSaveload, "... Loading PatrolRouteAssignment");
+
+	//  Restore route number
+	routeNo = stream->readSint16LE();
+	//  Restore the starting way point
+	startingWayPoint = stream->readSint16LE();
+	//  Restore the ending way point
+	endingWayPoint = stream->readSint16LE();
+
+	//  Restore the route flags
+	routeFlags = stream->readByte();
+	//  Restore the assignment flags
+	flags = stream->readByte();
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes need to archive the data in this
 //	assignment
@@ -377,6 +403,17 @@ HuntToBeNearLocationAssignment::HuntToBeNearLocationAssignment(Actor *a, void **
 	*buf = (uint16 *)bufferPtr + 1;
 }
 
+HuntToBeNearLocationAssignment::HuntToBeNearLocationAssignment(Actor *a, Common::SeekableReadStream *stream) :
+	ActorAssignment(a, stream) {
+	debugC(4, kDebugSaveload, "... Loading HuntToBeNearLocationAssignment");
+
+	//  Restore the target
+	readTarget(targetMem, stream);
+
+	//  Restore the range
+	range = stream->readUint16LE();
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes need to archive the data in this
 //	assignment
@@ -491,6 +528,19 @@ HuntToBeNearActorAssignment::HuntToBeNearActorAssignment(Actor *a, void **buf) :
 	*buf = bufferPtr;
 }
 
+HuntToBeNearActorAssignment::HuntToBeNearActorAssignment(Actor *a, Common::SeekableReadStream *stream) :
+	ActorAssignment(a, stream) {
+	debugC(4, kDebugSaveload, "... Loading HuntToBeNearActorAssignment");
+
+	readTarget(targetMem, stream);
+
+	//  Restore the range
+	range = stream->readUint16LE();
+
+	//  Restore the flags
+	flags = stream->readByte();
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes need to archive the data in this
 //	assignment
@@ -708,6 +758,16 @@ TetheredAssignment::TetheredAssignment(Actor *ac, void **buf) : ActorAssignment(
 	*buf = a;
 }
 
+TetheredAssignment::TetheredAssignment(Actor *ac, Common::SeekableReadStream *stream) : ActorAssignment(ac, stream) {
+	debugC(4, kDebugSaveload, "... Loading TetheredAssignment");
+
+	//  Read data from buffer
+	minU = stream->readSint16LE();
+	minV = stream->readSint16LE();
+	maxU = stream->readSint16LE();
+	maxV = stream->readSint16LE();
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes need to archive the data in this
 //	assignment
@@ -796,6 +856,18 @@ AttendAssignment::AttendAssignment(Actor *a, void **buf) : ActorAssignment(a, bu
 	*buf = bufferPtr;
 }
 
+AttendAssignment::AttendAssignment(Actor *a, Common::SeekableReadStream *stream) : ActorAssignment(a, stream) {
+	debugC(4, kDebugSaveload, "... Loading AttendAssignment");
+
+	ObjectID    objID;
+
+	//  Get the object ID
+	objID = stream->readUint16LE();
+
+	//  Convert the object ID to an object pointer
+	obj = objID != Nothing ? GameObject::objectAddress(objID) : NULL;
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes need to archive the data in this
 //	assignment
@@ -878,6 +950,34 @@ void *constructAssignment(Actor *a, void *buf) {
 	return buf;
 }
 
+void readAssignment(Actor *a, Common::InSaveFile *in) {
+	//  Get the type which is the first word in the archive buffer
+	int16 type = in->readSint16LE();
+
+	//  Based upon the type, call the correct constructor
+	switch (type) {
+	case patrolRouteAssignment:
+		new PatrolRouteAssignment(a, in);
+		break;
+
+	case huntToBeNearActorAssignment:
+		new HuntToBeNearActorAssignment(a, in);
+		break;
+
+	case huntToBeNearLocationAssignment:
+		new HuntToBeNearLocationAssignment(a, in);
+		break;
+
+	case tetheredWanderAssignment:
+		new TetheredWanderAssignment(a, in);
+		break;
+
+	case attendAssignment:
+		new AttendAssignment(a, in);
+		break;
+	}
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes necessary to archive this actor's
 //	assignment in an archive buffer
diff --git a/engines/saga2/assign.h b/engines/saga2/assign.h
index 8815ed5e4e..53331b9f04 100644
--- a/engines/saga2/assign.h
+++ b/engines/saga2/assign.h
@@ -67,6 +67,8 @@ public:
 	//  Constructor -- reconstruct from archive buffer
 	ActorAssignment(Actor *a, void **buf);
 
+	ActorAssignment(Actor *a, Common::SeekableReadStream *stream);
+
 	//  Destructor
 	virtual ~ActorAssignment(void);
 
@@ -136,6 +138,8 @@ public:
 	//  Constructor -- constructs from archive buffer
 	PatrolRouteAssignment(Actor *a, void **buf);
 
+	PatrolRouteAssignment(Actor *a, Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes need to archive the data in this
 	//  assignment
 	int32 archiveSize(void) const;
@@ -207,6 +211,8 @@ public:
 	//  Constructor -- constructs from archive buffer
 	HuntToBeNearLocationAssignment(Actor *a, void **buf);
 
+	HuntToBeNearLocationAssignment(Actor *a, Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes need to archive the data in this
 	//  assignment
 	int32 archiveSize(void) const;
@@ -289,6 +295,8 @@ public:
 	//  Constructor -- reconstructs from archive buffer
 	HuntToBeNearActorAssignment(Actor *a, void **buf);
 
+	HuntToBeNearActorAssignment(Actor *a, Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes need to archive the data in this
 	//  assignment
 	int32 archiveSize(void) const;
@@ -413,6 +421,8 @@ public:
 
 	TetheredAssignment(Actor *a, void **buf);
 
+	TetheredAssignment(Actor *a, Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes need to archive the data in this
 	//  assignment
 	int32 archiveSize(void) const;
@@ -434,6 +444,8 @@ public:
 	//  Constructor -- constructs from archive buffer
 	TetheredWanderAssignment(Actor *a, void **buf) : TetheredAssignment(a, buf) {}
 
+	TetheredWanderAssignment(Actor *a, Common::SeekableReadStream *stream) : TetheredAssignment(a, stream) {}
+
 	//  Return an integer representing the type of this assignment
 	int16 type(void) const;
 
@@ -456,6 +468,8 @@ public:
 	//  Constructor -- constructs from archive buffer
 	AttendAssignment(Actor *a, void **buf);
 
+	AttendAssignment(Actor *a, Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes need to archive the data in this
 	//  assignment
 	int32 archiveSize(void) const;
@@ -487,6 +501,7 @@ int32 assignmentArchiveSize(Actor *a);
 void *archiveAssignment(Actor *a, void *buf);
 
 void writeAssignment(Actor *a, Common::OutSaveFile *out);
+void readAssignment(Actor *a, Common::InSaveFile *in);
 
 }
 
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index 76ccb3cc74..8f0b6d44a0 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -89,6 +89,48 @@ void *constructTarget(void *mem, void *buf) {
 	return buf;
 }
 
+void readTarget(void *mem, Common::InSaveFile *in) {
+	int16 type = in->readSint16LE();
+
+	switch (type) {
+	case locationTarget:
+		new (mem) LocationTarget(in);
+		break;
+
+	case specificTileTarget:
+		new (mem) SpecificTileTarget(in);
+		break;
+
+	case tilePropertyTarget:
+		new (mem) TilePropertyTarget(in);
+		break;
+
+	case specificMetaTileTarget:
+		new (mem) SpecificMetaTileTarget(in);
+		break;
+
+	case metaTilePropertyTarget:
+		new (mem) MetaTilePropertyTarget(in);
+		break;
+
+	case specificObjectTarget:
+		new (mem)  SpecificObjectTarget(in);
+		break;
+
+	case objectPropertyTarget:
+		new (mem)  ObjectPropertyTarget(in);
+		break;
+
+	case specificActorTarget:
+		new (mem) SpecificActorTarget(in);
+		break;
+
+	case actorPropertyTarget:
+		new (mem) ActorPropertyTarget(in);
+		break;
+	}
+}
+
 int32 targetArchiveSize(const Target *t) {
 	return sizeof(int16) + t->archiveSize();
 }
@@ -169,6 +211,13 @@ LocationTarget::LocationTarget(void **buf) {
 	*buf = &bufferPtr[1];
 }
 
+LocationTarget::LocationTarget(Common::SeekableReadStream *stream) {
+	debugC(5, kDebugSaveload, "...... LocationTarget");
+
+	//  Restore the targe location
+	loc.load(stream);
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes needed to archive this object in
 //	a buffer
@@ -363,6 +412,13 @@ SpecificTileTarget::SpecificTileTarget(void **buf) {
 	*buf = bufferPtr;
 }
 
+SpecificTileTarget::SpecificTileTarget(Common::SeekableReadStream *stream) {
+	debugC(5, kDebugSaveload, "...... SpecificTileTarget");
+
+	//  Restore the tile ID
+	tile = stream->readUint16LE();
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes needed to archive this object in
 //	a buffer
@@ -433,6 +489,13 @@ TilePropertyTarget::TilePropertyTarget(void **buf) {
 	*buf = &bufferPtr[1];
 }
 
+TilePropertyTarget::TilePropertyTarget(Common::SeekableReadStream *stream) {
+	debugC(5, kDebugSaveload, "...... TilePropertyTarget");
+
+	//  Restore the TilePropertyID
+	tileProp = stream->readSint16LE();
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes needed to archive this object in
 //	a buffer
@@ -612,6 +675,14 @@ SpecificMetaTileTarget::SpecificMetaTileTarget(void **buf) {
 	*buf = &bufferPtr[1];
 }
 
+SpecificMetaTileTarget::SpecificMetaTileTarget(Common::SeekableReadStream *stream) {
+	debugC(5, kDebugSaveload, "...... SpecificMetaTileTarget");
+
+	//  Restore the MetaTileID
+	meta.map = stream->readSint16LE();
+	meta.index = stream->readSint16LE();
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes needed to archive this object in
 //	a buffer
@@ -688,6 +759,13 @@ MetaTilePropertyTarget::MetaTilePropertyTarget(void **buf) {
 	*buf = &bufferPtr[1];
 }
 
+MetaTilePropertyTarget::MetaTilePropertyTarget(Common::SeekableReadStream *stream) {
+	debugC(5, kDebugSaveload, "...... MetaTilePropertyTarget");
+
+	//  Restore the MetaTilePropertyID
+	metaProp = stream->readSint16LE();
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes needed to archive this object in
 //	a buffer
@@ -973,6 +1051,13 @@ SpecificObjectTarget::SpecificObjectTarget(void **buf) {
 	*buf = &bufferPtr[1];
 }
 
+SpecificObjectTarget::SpecificObjectTarget(Common::SeekableReadStream *stream) {
+	debugC(5, kDebugSaveload, "...... SpecificObjectTarget");
+
+	//  Restore the ObjectID
+	obj = stream->readUint16LE();
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes needed to archive this object in
 //	a buffer
@@ -1134,6 +1219,13 @@ ObjectPropertyTarget::ObjectPropertyTarget(void **buf) {
 	*buf = &bufferPtr[1];
 }
 
+ObjectPropertyTarget::ObjectPropertyTarget(Common::SeekableReadStream *stream) {
+	debugC(5, kDebugSaveload, "...... ObjectPropertyTarget");
+
+	//  Restore the ObjectPropertyID
+	objProp = stream->readSint16LE();
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes needed to archive this object in
 //	a buffer
@@ -1242,6 +1334,20 @@ SpecificActorTarget::SpecificActorTarget(void **buf) {
 	*buf = bufferPtr + 1;
 }
 
+SpecificActorTarget::SpecificActorTarget(Common::SeekableReadStream *stream) {
+	debugC(5, kDebugSaveload, "...... SpecificActorTarget");
+
+	ObjectID actorID;
+
+	//  Get the actor's ID
+	actorID = stream->readUint16LE();
+
+	//  Convert the actor ID into an Actor pointer
+	a = actorID != Nothing
+	    ? (Actor *)GameObject::objectAddress(actorID)
+	    :   NULL;
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes needed to archive this object in
 //	a buffer
@@ -1436,6 +1542,13 @@ ActorPropertyTarget::ActorPropertyTarget(void **buf) {
 	*buf = &bufferPtr[1];
 }
 
+ActorPropertyTarget::ActorPropertyTarget(Common::SeekableReadStream *stream) {
+	debugC(5, kDebugSaveload, "...... ActorPropertyTarget");
+
+	//  Restore the ActorPropertyID
+	actorProp = stream->readSint16LE();
+}
+
 //----------------------------------------------------------------------
 //	Return the number of bytes needed to archive this object in
 //	a buffer
diff --git a/engines/saga2/target.h b/engines/saga2/target.h
index 11f723e476..b571b0a3e0 100644
--- a/engines/saga2/target.h
+++ b/engines/saga2/target.h
@@ -57,6 +57,7 @@ class Target;
 void deleteTarget(Target *t);
 
 void *constructTarget(void *mem, void *buf);
+void readTarget(void *mem, Common::InSaveFile *in);
 int32 targetArchiveSize(const Target *t);
 void *archiveTarget(const Target *t, void *buf);
 
@@ -192,6 +193,8 @@ public:
 	//  Constructor -- reconstruct from archive buffer
 	LocationTarget(void **buf);
 
+	LocationTarget(Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes needed to archive this object in
 	//  a buffer
 	int32 archiveSize(void) const;
@@ -256,6 +259,8 @@ public:
 	//  Constructor -- reconstruct from archive buffer
 	SpecificTileTarget(void **buf);
 
+	SpecificTileTarget(Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes needed to archive this object in
 	//  a buffer
 	int32 archiveSize(void) const;
@@ -292,6 +297,8 @@ public:
 	//  Constructor -- reconstruct from archive buffer
 	TilePropertyTarget(void **buf);
 
+	TilePropertyTarget(Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes needed to archive this object in
 	//  a buffer
 	int32 archiveSize(void) const;
@@ -346,6 +353,8 @@ public:
 	//  Constructor -- reconstruct from archive buffer
 	SpecificMetaTileTarget(void **buf);
 
+	SpecificMetaTileTarget(Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes needed to archive this object in
 	//  a buffer
 	int32 archiveSize(void) const;
@@ -384,6 +393,8 @@ public:
 	//  Constructor -- reconstruct from archive buffer
 	MetaTilePropertyTarget(void **buf);
 
+	MetaTilePropertyTarget(Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes needed to archive this object in
 	//  a buffer
 	int32 archiveSize(void) const;
@@ -466,6 +477,8 @@ public:
 	//  Constructor -- reconstruct from archive buffer
 	SpecificObjectTarget(void **buf);
 
+	SpecificObjectTarget(Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes needed to archive this object in
 	//  a buffer
 	int32 archiveSize(void) const;
@@ -519,6 +532,8 @@ public:
 	//  Constructor -- reconstruct from archive buffer
 	ObjectPropertyTarget(void **buf);
 
+	ObjectPropertyTarget(Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes needed to archive this object in
 	//  a buffer
 	int32 archiveSize(void) const;
@@ -576,6 +591,8 @@ public:
 	//  Constructor -- reconstruct from archive buffer
 	SpecificActorTarget(void **buf);
 
+	SpecificActorTarget(Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes needed to archive this object in
 	//  a buffer
 	int32 archiveSize(void) const;
@@ -637,6 +654,8 @@ public:
 	//  Constructor -- reconstruct from archive buffer
 	ActorPropertyTarget(void **buf);
 
+	ActorPropertyTarget(Common::SeekableReadStream *stream);
+
 	//  Return the number of bytes needed to archive this object in
 	//  a buffer
 	int32 archiveSize(void) const;


Commit: da6a70c3e755c07f94a60a1c1a3cdee0e3d717cc
    https://github.com/scummvm/scummvm/commit/da6a70c3e755c07f94a60a1c1a3cdee0e3d717cc
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-08T04:34:39+09:00

Commit Message:
SAGA2: Imlement Assignment saving

Changed paths:
    engines/saga2/actor.cpp
    engines/saga2/assign.cpp
    engines/saga2/assign.h
    engines/saga2/objects.cpp
    engines/saga2/target.cpp
    engines/saga2/target.h
    engines/saga2/tcoords.h


diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index a56c6e3c28..f9a69bc111 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1267,6 +1267,8 @@ Actor::Actor(void **buf) : GameObject(buf) {
 }
 
 Actor::Actor(Common::InSaveFile *in) : GameObject(in) {
+	debugC(3, kDebugSaveload, "Loading actor %d", thisID());
+
 	//  Fixup the prototype pointer to point to an actor prototype
 	prototype   =   prototype != nullptr
 	                ? (ProtoObj *)&actorProtos[prototype - objectProtos]
@@ -1336,7 +1338,6 @@ Actor::Actor(Common::InSaveFile *in) : GameObject(in) {
 	for (int i = 0; i < ARRAYSIZE(scriptVar); ++i)
 		scriptVar[i] = in->readSint16LE();
 
-	warning("STUB: Actor::Actor(Common::InSaveFile *): unfinished");
 	if (flags & hasAssignment) {
 		readAssignment(this, in);
 	} else {
@@ -1346,6 +1347,43 @@ Actor::Actor(Common::InSaveFile *in) : GameObject(in) {
 	appearance = nullptr;
 	moveTask = nullptr;
 	curTask = nullptr;
+
+	debugC(4, kDebugSaveload, "... faction = %d", faction);
+	debugC(4, kDebugSaveload, "... colorScheme = %d", colorScheme);
+	debugC(4, kDebugSaveload, "... appearanceID = %d", appearanceID);
+	debugC(4, kDebugSaveload, "... attitude = %d", attitude);
+	debugC(4, kDebugSaveload, "... mood = %d", mood);
+	debugC(4, kDebugSaveload, "... disposition = %d", disposition);
+	debugC(4, kDebugSaveload, "... currentFacing = %d", currentFacing);
+	debugC(4, kDebugSaveload, "... tetherLocU = %d", tetherLocU);
+	debugC(4, kDebugSaveload, "... tetherLocV = %d", tetherLocV);
+	debugC(4, kDebugSaveload, "... tetherDist = %d", tetherDist);
+	debugC(4, kDebugSaveload, "... leftHandObject = %d", leftHandObject);
+	debugC(4, kDebugSaveload, "... rightHandObject = %d", rightHandObject);
+//	debugC(4, kDebugSaveload, "... knowledge = %d", knowledge);
+	debugC(4, kDebugSaveload, "... schedule = %d", schedule);
+//	debugC(4, kDebugSaveload, "... conversationMemory = %d", conversationMemory);
+	debugC(4, kDebugSaveload, "... currentAnimation = %d", currentAnimation);
+	debugC(4, kDebugSaveload, "... currentPose = %d", currentPose);
+	debugC(4, kDebugSaveload, "... animationFlags = %d", animationFlags);
+	debugC(4, kDebugSaveload, "... flags = %d", flags);
+//	debugC(4, kDebugSaveload, "... out = %d", out);
+	debugC(4, kDebugSaveload, "... cycleCount = %d", cycleCount);
+	debugC(4, kDebugSaveload, "... kludgeCount = %d", kludgeCount);
+	debugC(4, kDebugSaveload, "... enchantmentFlags = %d", enchantmentFlags);
+	debugC(4, kDebugSaveload, "... currentGoal = %d", currentGoal);
+	debugC(4, kDebugSaveload, "... deactivationCounter = %d", deactivationCounter);
+//	debugC(4, kDebugSaveload, "... out = %d", out);
+	debugC(4, kDebugSaveload, "... actionCounter = %d", actionCounter);
+	debugC(4, kDebugSaveload, "... effectiveResistance = %d", effectiveResistance);
+	debugC(4, kDebugSaveload, "... effectiveImmunity = %d", effectiveImmunity);
+	debugC(4, kDebugSaveload, "... recPointsPerUpdate = %d", recPointsPerUpdate);
+	debugC(4, kDebugSaveload, "... currentRecoveryPoints = %d", currentRecoveryPoints);
+	debugC(4, kDebugSaveload, "... leaderID = %d", leaderID);
+	debugC(4, kDebugSaveload, "... followersID = %d", followersID);
+//	debugC(4, kDebugSaveload, "... armorObjects = %d", armorObjects);
+	debugC(4, kDebugSaveload, "... currentTargetID = %d", currentTargetID);
+//	debugC(4, kDebugSaveload, "... scriptVar = %d", scriptVar);
 }
 
 //-----------------------------------------------------------------------
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index c1d2573a4e..323dfff940 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -284,6 +284,23 @@ void *PatrolRouteAssignment::archive(void *buf) const {
 	return buf;
 }
 
+void PatrolRouteAssignment::write(Common::OutSaveFile *out) const {
+	debugC(3, kDebugSaveload, "... Saving PatrolRouteAssignment");
+
+	//  Let the base class write its data to the buffer
+	ActorAssignment::write(out);
+
+	//  Store the route number
+	out->writeSint16LE(routeNo);
+	out->writeSint16LE(startingWayPoint);
+	out->writeSint16LE(endingWayPoint);
+
+	//  Store the route flags
+	out->writeByte(routeFlags);
+	//  Store the assignment flags
+	out->writeByte(flags);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the class of this object for archival
 //	reasons.
@@ -441,6 +458,19 @@ void *HuntToBeNearLocationAssignment::archive(void *buf) const {
 	return (uint16 *)buf + 1;
 }
 
+void HuntToBeNearLocationAssignment::write(Common::OutSaveFile *out) const {
+	debugC(3, kDebugSaveload, "... Saving HuntToBeNearLocationAssignment");
+
+	//  Let the base class archive its data
+	ActorAssignment::write(out);
+
+	//  Store the target
+	writeTarget(getTarget(), out);
+
+	//  Store the range
+	out->writeUint16LE(range);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the class of this object for archival
 //	reasons.
@@ -574,6 +604,22 @@ void *HuntToBeNearActorAssignment::archive(void *buf) const {
 	return buf;
 }
 
+void HuntToBeNearActorAssignment::write(Common::OutSaveFile *out) const {
+	debugC(3, kDebugSaveload, "... Saving HuntToBeNearActorAssignment");
+
+	//  Let the base class archive its data
+	ActorAssignment::write(out);
+
+	//  Store the target
+	writeTarget(getTarget(), out);
+
+	//  Store the range
+	out->writeUint16LE(range);
+
+	//  Store the flags
+	out->writeByte(flags);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the class of this object for archival
 //	reasons.
@@ -688,6 +734,19 @@ void *HuntToKillAssignment::archive(void *buf) const {
 	return buf;
 }
 
+void HuntToKillAssignment::write(Common::OutSaveFile *out) const {
+	debugC(3, kDebugSaveload, "... Saving HuntToKillAssignment");
+
+	//  Let the base class archive its data
+	ActorAssignment::write(out);
+
+	//  Store the target
+	writeTarget(getTarget(), out);
+
+	//  Store the flags
+	out->writeByte(flags);
+}
+
 //----------------------------------------------------------------------
 //	Determine if this assignment is still valid
 
@@ -799,6 +858,19 @@ void *TetheredAssignment::archive(void *buf) const {
 	return a;
 }
 
+void TetheredAssignment::write(Common::OutSaveFile *out) const {
+	debugC(3, kDebugSaveload, "... Saving TetheredAssignment");
+
+	//  Let the base class archive its data
+	ActorAssignment::write(out);
+
+	//  Copy data to buffer
+	out->writeSint16LE(minU);
+	out->writeSint16LE(minV);
+	out->writeSint16LE(maxU);
+	out->writeSint16LE(maxV);
+}
+
 /* ===================================================================== *
    TetheredWanderAssignment member functions
  * ===================================================================== */
@@ -896,6 +968,21 @@ void *AttendAssignment::archive(void *buf) const {
 	return (ObjectID *)buf + 1;
 }
 
+void AttendAssignment::write(Common::OutSaveFile *out) const {
+	debugC(3, kDebugSaveload, "... Saving AttendAssignment");
+
+	//  Let the base class write its data to the buffer
+	ActorAssignment::write(out);
+
+	ObjectID    objID;
+
+	//  Convert the object pointer to an object ID
+	objID = obj != NULL ? obj->thisID() : Nothing;
+
+	//  Store the object ID
+	out->writeUint16LE(objID);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the class of this object for archival
 //	reasons.
diff --git a/engines/saga2/assign.h b/engines/saga2/assign.h
index 53331b9f04..ad8b737349 100644
--- a/engines/saga2/assign.h
+++ b/engines/saga2/assign.h
@@ -148,6 +148,8 @@ public:
 	//  to save it on disk
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	//  Return an integer representing the type of this assignment
 	int16 type(void) const;
 
@@ -221,6 +223,8 @@ public:
 	//  to save it on disk
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	int16 type(void) const;
 
 protected:
@@ -305,6 +309,8 @@ public:
 	//  to save it on disk
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	int16 type(void) const;
 
 protected:
@@ -381,6 +387,8 @@ public:
 	//  to save it on disk
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	//  Determine if assignment's time limit is up or if the actor is
 	//  already dead
 	bool isValid(void);
@@ -430,6 +438,8 @@ public:
 	//  Write the data from this assignment object to a buffer in order
 	//  to save it on disk
 	void *archive(void *buf) const;
+
+	void write(Common::OutSaveFile *out) const;
 };
 
 /* ===================================================================== *
@@ -478,6 +488,8 @@ public:
 	//  to save it on disk
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	//  Return an integer representing the type of this assignment
 	int16 type(void) const;
 
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 88cefe08b8..16734a2d18 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -267,6 +267,8 @@ GameObject::GameObject(void **buf) {
 }
 
 GameObject::GameObject(Common::InSaveFile *in) {
+	debugC(3, kDebugSaveload, "Loading object %d", thisID());
+
 	int16 pInd = in->readSint16LE();
 	//  Convert the protoype index into an object proto pointer
 	prototype = pInd != -1
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index 8f0b6d44a0..dddb2d49d4 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -131,6 +131,12 @@ void readTarget(void *mem, Common::InSaveFile *in) {
 	}
 }
 
+void writeTarget(const Target *t, Common::OutSaveFile *out) {
+	out->writeSint16LE(t->getType());
+
+	t->write(out);
+}
+
 int32 targetArchiveSize(const Target *t) {
 	return sizeof(int16) + t->archiveSize();
 }
@@ -236,6 +242,11 @@ void *LocationTarget::archive(void *buf) const {
 	return (TilePoint *)buf + 1;
 }
 
+void LocationTarget::write(Common::OutSaveFile *out) const {
+	//  Store the target location
+	loc.write(out);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the type of target
 
@@ -437,6 +448,11 @@ void *SpecificTileTarget::archive(void *buf) const {
 	return (TileID *)buf + 1;
 }
 
+void SpecificTileTarget::write(Common::OutSaveFile *out) const {
+	//  Store the tile ID
+	out->writeUint16LE(tile);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the type of target
 
@@ -513,6 +529,10 @@ void *TilePropertyTarget::archive(void *buf) const {
 	return (TilePropertyID *)buf + 1;
 }
 
+void TilePropertyTarget::write(Common::OutSaveFile *out) const {
+	out->writeSint16LE(tileProp);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the type of target
 
@@ -704,6 +724,12 @@ void *SpecificMetaTileTarget::archive(void *buf) const {
 	return &bufferPtr[1];
 }
 
+void SpecificMetaTileTarget::write(Common::OutSaveFile *out) const {
+	//  Store the MetaTileID
+	out->writeSint16LE(meta.map);
+	out->writeSint16LE(meta.index);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the type of target
 
@@ -784,6 +810,11 @@ void *MetaTilePropertyTarget::archive(void *buf) const {
 	return (MetaTilePropertyID *)buf + 1;
 }
 
+void MetaTilePropertyTarget::write(Common::OutSaveFile *out) const {
+	//  Store the MetaTilePropertyID
+	out->writeSint16LE(metaProp);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the type of target
 
@@ -1076,6 +1107,11 @@ void *SpecificObjectTarget::archive(void *buf) const {
 	return (ObjectID *)buf + 1;
 }
 
+void SpecificObjectTarget::write(Common::OutSaveFile *out) const {
+	//  Store the ObjectID
+	out->writeUint16LE(obj);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the type of target
 
@@ -1244,6 +1280,11 @@ void *ObjectPropertyTarget::archive(void *buf) const {
 	return (ObjectPropertyID *)buf + 1;
 }
 
+void ObjectPropertyTarget::write(Common::OutSaveFile *out) const {
+	//  Store the ObjectPropertyID
+	out->writeSint16LE(objProp);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the type of target
 
@@ -1369,6 +1410,14 @@ void *SpecificActorTarget::archive(void *buf) const {
 	return (ObjectID *)buf + 1;
 }
 
+void SpecificActorTarget::write(Common::OutSaveFile *out) const {
+	//  Convert the actor pointer to an actor ID;
+	ObjectID actorID = a != NULL ? a->thisID() : Nothing;
+
+	//  Store the actor ID
+	out->writeUint16LE(actorID);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the type of target
 
@@ -1567,6 +1616,11 @@ void *ActorPropertyTarget::archive(void *buf) const {
 	return (ActorPropertyID *)buf + 1;
 }
 
+void ActorPropertyTarget::write(Common::OutSaveFile *out) const {
+	//  Store the ActorPropertyID
+	out->writeSint16LE(actorProp);
+}
+
 //----------------------------------------------------------------------
 //	Return an integer representing the type of target
 
diff --git a/engines/saga2/target.h b/engines/saga2/target.h
index b571b0a3e0..7e3033f4ef 100644
--- a/engines/saga2/target.h
+++ b/engines/saga2/target.h
@@ -58,6 +58,7 @@ void deleteTarget(Target *t);
 
 void *constructTarget(void *mem, void *buf);
 void readTarget(void *mem, Common::InSaveFile *in);
+void writeTarget(const Target *t, Common::OutSaveFile *out);
 int32 targetArchiveSize(const Target *t);
 void *archiveTarget(const Target *t, void *buf);
 
@@ -146,6 +147,8 @@ public:
 	//  Create an archive of this object in the specified buffer
 	virtual void *archive(void *buf) const = 0;
 
+	virtual void write(Common::OutSaveFile *out) const = 0;
+
 	//  Return an integer representing the type of target
 	virtual int16 getType(void) const = 0;
 
@@ -202,6 +205,8 @@ public:
 	//  Create an archive of this object in the specified buffer
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	//  Return an integer representing the type of target
 	int16 getType(void) const;
 
@@ -268,6 +273,8 @@ public:
 	//  Create an archive of this object in the specified buffer
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	//  Return an integer representing the type of target
 	int16 getType(void) const;
 
@@ -306,6 +313,8 @@ public:
 	//  Create an archive of this object in the specified buffer
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	//  Return an integer representing the type of target
 	int16 getType(void) const;
 
@@ -362,6 +371,8 @@ public:
 	//  Create an archive of this object in the specified buffer
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	//  Return an integer representing the type of target
 	int16 getType(void) const;
 
@@ -402,6 +413,8 @@ public:
 	//  Create an archive of this object in the specified buffer
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	//  Return an integer representing the type of target
 	int16 getType(void) const;
 
@@ -486,6 +499,8 @@ public:
 	//  Create an archive of this object in the specified buffer
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	//  Return an integer representing the type of target
 	int16 getType(void) const;
 
@@ -541,6 +556,8 @@ public:
 	//  Create an archive of this object in the specified buffer
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	//  Return an integer representing the type of target
 	int16 getType(void) const;
 
@@ -600,6 +617,8 @@ public:
 	//  Create an archive of this object in the specified buffer
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	//  Return an integer representing the type of target
 	int16 getType(void) const;
 
@@ -663,6 +682,8 @@ public:
 	//  Create an archive of this object in the specified buffer
 	void *archive(void *buf) const;
 
+	void write(Common::OutSaveFile *out) const;
+
 	//  Return an integer representing the type of target
 	int16 getType(void) const;
 
diff --git a/engines/saga2/tcoords.h b/engines/saga2/tcoords.h
index 445ded0e0f..20fe1a3f04 100644
--- a/engines/saga2/tcoords.h
+++ b/engines/saga2/tcoords.h
@@ -150,7 +150,7 @@ struct TilePoint {
 		z = stream->readSint16LE();
 	}
 
-	void write(Common::OutSaveFile *out) {
+	void write(Common::OutSaveFile *out) const {
 		out->writeSint16LE(u);
 		out->writeSint16LE(v);
 		out->writeSint16LE(z);




More information about the Scummvm-git-logs mailing list