[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.122,1.123 actor.h,1.66,1.67 saveload.cpp,1.3,1.4

Andrew Kurushin h00ligan at users.sourceforge.net
Thu Apr 28 10:24:07 CEST 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22514

Modified Files:
	actor.cpp actor.h saveload.cpp 
Log Message:
 save load preparetion

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- actor.cpp	27 Apr 2005 11:51:09 -0000	1.122
+++ actor.cpp	28 Apr 2005 17:19:36 -0000	1.123
@@ -2292,6 +2292,51 @@
 #endif
 }
 
+void Actor::saveState(File& out) {
+	uint16 i;
+	
+	out.writeSint32LE(_centerActor == NULL ? -1 : _centerActor->index);
+	out.writeSint32LE(_protagonist == NULL ? -1 : _protagonist->index);
+	out.writeSint16LE(getProtagState());
+
+	for (i = 0; i < _actorsCount; i++) {
+		ActorData *a = _actors[i];
+		a->saveState(out);
+	}
+
+	//TODO: save _activeSpeech
+
+	for (i = 0; i < _objsCount; i++) {
+		ObjectData *o = _objs[i];
+		o->saveState(out);
+	}
+}
+
+void Actor::loadState(File& in) {
+	int32 i;
+
+	i = in.readSint32LE();
+	_centerActor = (i < 0) ? NULL : _actors[i];
+
+	i = in.readSint32LE();
+	_protagonist = (i < 0) ? NULL : _actors[i];
+
+	setProtagState(in.readSint16LE());
+
+	//TODO: load _activeSpeech
+
+	for (i = 0; i < _actorsCount; i++) {
+		ActorData *a = _actors[i];
+		a->loadState(in);
+	}
+
+
+	for (i = 0; i < _objsCount; i++) {
+		ObjectData *o = _objs[i];
+		o->loadState(in);
+	}
+}
+
 // Console wrappers - must be safe to run
 
 void Actor::cmdActorWalkTo(int argc, const char **argv) {

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- actor.h	27 Apr 2005 11:51:10 -0000	1.66
+++ actor.h	28 Apr 2005 17:19:43 -0000	1.67
@@ -428,9 +428,6 @@
 	friend class IsoMap;
 	friend class SagaEngine;
 public:
-	ActorData *_centerActor;
-	ActorData *_protagonist;
-	StringsTable _actorsStrings;
 
 	Actor(SagaEngine *vm);
 	~Actor();
@@ -496,6 +493,9 @@
 		return _activeSpeech.stringsCount > 0;
 	}
 
+	void saveState(File& out);
+	void loadState(File& in);
+
 	void setProtagState(int state);
 	int getProtagState() { return _protagState; }
 	
@@ -537,22 +537,32 @@
 	void removePathPoints();
 	bool validFollowerLocation(const Location &location);
 	
-	int _lastTickMsec;
-	SagaEngine *_vm;
-	RSCFILE_CONTEXT *_actorContext;
-	CommonObjectOrderList _drawOrderList;
 	
 protected:
+//constants
 	int _actorsCount;
 	ActorData **_actors;
 
 	int _objsCount;
 	ObjectData **_objs;
 
-private:
+	SagaEngine *_vm;
+	RSCFILE_CONTEXT *_actorContext;
+
+	StringsTable _actorsStrings;
+	int _lastTickMsec;
+	CommonObjectOrderList _drawOrderList;
+
+//variables
+public:
+	ActorData *_centerActor;
+	ActorData *_protagonist;
+
+protected:
 	SpeechData _activeSpeech;
 	int _protagState;
 
+private:
 //path stuff
 	struct PathNode {
 		Point point;

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saveload.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- saveload.cpp	27 Apr 2005 11:51:11 -0000	1.3
+++ saveload.cpp	28 Apr 2005 17:19:43 -0000	1.4
@@ -46,7 +46,6 @@
 	//TODO: version number
 
 	out.writeSint16LE(_script->_commonBufferSize);
-	out.writeSint16LE(_actor->getProtagState());
 
 	// Surrounding scene
 	out.writeSint32LE(_scene->getOutsetSceneNumber());
@@ -58,15 +57,7 @@
 
 	uint16 i;
 
-	for (i = 0; i < _actor->_actorsCount; i++) {
-		ActorData *a = _actor->_actors[i];
-		a->saveState(out);
-	}
-	
-	for (i = 0; i < _actor->_objsCount; i++) {
-		ObjectData *o = _actor->_objs[i];
-		o->saveState(out);
-	}
+	_actor->saveState(out);
 	
 	for (i = 0; i < _script->_commonBufferSize; i++)
 		out.writeByte(_script->_commonBuffer[i]);
@@ -89,7 +80,6 @@
 		return;
 
 	commonBufferSize = in.readSint16LE();
-	_actor->setProtagState(in.readSint16LE());
 
 	// Surrounding scene
 	scenenum = in.readSint32LE();
@@ -103,17 +93,10 @@
 
 	uint16 i;
 
-	for (i = 0; i < _actor->_actorsCount; i++) {
-		ActorData *a = _actor->_actors[i];
-		a->loadState(in);
-	}
 	
 	_interface->clearInventory(); //TODO: interface load-save-state
 
-	for (i = 0; i < _actor->_objsCount; i++) {
-		ObjectData *o = _actor->_objs[i];
-		o->loadState(in);
-	}
+	_actor->loadState(in);
 	
 	for (i = 0; i < commonBufferSize; i++)
 		_script->_commonBuffer[i] = in.readByte();





More information about the Scummvm-git-logs mailing list