[Scummvm-cvs-logs] CVS: scummvm/saga saga.cpp,1.133,1.134 saga.h,1.123,1.124 saveload.cpp,1.25,1.26 sfuncs.cpp,1.160,1.161

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Mon Sep 26 00:23:11 CEST 2005


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

Modified Files:
	saga.cpp saga.h saveload.cpp sfuncs.cpp 
Log Message:
Implemented some trivial IHNM opcodes. I'm not sure if the _ethicsPoints[]
array is large enough though.

These opcodes modify what I assume to be the game state, so that
information needs to be stored in the savegames. Not for ITE, though, so
savegame compatibility is not broken by this. (Not deliberately, at least.)


Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -d -r1.133 -r1.134
--- saga.cpp	21 Sep 2005 10:06:56 -0000	1.133
+++ saga.cpp	26 Sep 2005 07:22:32 -0000	1.134
@@ -118,6 +118,8 @@
 	_puzzle = NULL;
 
 	_frameCount = 0;
+	_globalFlags = 0;
+	memset(_ethicsPoints, 0, sizeof(_ethicsPoints));
 
 	// The Linux version of Inherit the Earth puts all data files in an
 	// 'itedata' sub-directory, except for voices.rsc

Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -d -r1.123 -r1.124
--- saga.h	21 Sep 2005 10:09:58 -0000	1.123
+++ saga.h	26 Sep 2005 07:22:32 -0000	1.124
@@ -570,6 +570,9 @@
 		return isSaveListFull() ? _saveFilesCount : _saveFilesCount + 1;
 	}
 
+	uint32 _globalFlags;
+	byte _ethicsPoints[5];	// TODO: Verify that this is large enough
+
 	int _soundVolume;
 	int _musicVolume;
 	bool _subtitlesEnabled;

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saveload.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- saveload.cpp	3 Sep 2005 07:56:42 -0000	1.25
+++ saveload.cpp	26 Sep 2005 07:22:32 -0000	1.26
@@ -178,6 +178,12 @@
 	// Inset scene
 	out->writeSint32LE(_scene->currentSceneNumber());
 
+	if (getGameType() != GType_ITE) {
+		out->writeUint32LE(_globalFlags);
+		for (int i = 0; i < ARRAYSIZE(_ethicsPoints); i++)
+			out->writeByte(_ethicsPoints[i]);
+	}
+
 	_interface->saveState(out);
 
 	_actor->saveState(out);
@@ -217,6 +223,12 @@
 	// Inset scene
 	insetSceneNumber = in->readSint32LE();
 
+	if (getGameType() != GType_ITE) {
+		_globalFlags = in->readUint32LE();
+		for (int i = 0; i < ARRAYSIZE(_ethicsPoints); i++)
+			_ethicsPoints[i] = in->readByte();
+	}
+
 	_interface->loadState(in);
 
 	_actor->loadState(in);

Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -d -r1.160 -r1.161
--- sfuncs.cpp	25 Sep 2005 00:08:13 -0000	1.160
+++ sfuncs.cpp	26 Sep 2005 07:22:32 -0000	1.161
@@ -1921,23 +1921,43 @@
 }
 
 void Script::sfGetPoints(SCRIPTFUNC_PARAMS) {
-	SF_stub("sfGetPoints", thread, nArgs);
+	int16 index = thread->pop();
+
+	if (index >= 0 && index < ARRAYSIZE(_vm->_ethicsPoints))
+		thread->_returnValue = _vm->_ethicsPoints[index];
+	else
+		thread->_returnValue = 0;
 }
 
 void Script::sfSetGlobalFlag(SCRIPTFUNC_PARAMS) {
-	SF_stub("sfSetGlobalFlag", thread, nArgs);
+	int16 flag = thread->pop();
+
+	if (flag >= 0 && flag < 32)
+		_vm->_globalFlags |= (1 << flag);
 }
 
 void Script::sfClearGlobalFlag(SCRIPTFUNC_PARAMS) {
-	SF_stub("sfClearGlobalFlag", thread, nArgs);
+	int16 flag = thread->pop();
+
+	if (flag >= 0 && flag < 32)
+		_vm->_globalFlags &= ~(1 << flag);
 }
 
 void Script::sfTestGlobalFlag(SCRIPTFUNC_PARAMS) {
-	SF_stub("sfTestGlobalFlag", thread, nArgs);
+	int16 flag = thread->pop();
+
+	if (flag >= 0 && flag < 32 && _vm->_globalFlags & (1 << flag))
+		thread->_returnValue = 1;
+	else
+		thread->_returnValue = 0;
 }
 
 void Script::sfSetPoints(SCRIPTFUNC_PARAMS) {
-	SF_stub("sfSetPoints", thread, nArgs);
+	int16 index = thread->pop();
+	int16 points = thread->pop();
+
+	if (index >= 0 && index < ARRAYSIZE(_vm->_ethicsPoints))
+		_vm->_ethicsPoints[index] = points;
 }
 
 void Script::sfSetSpeechBox(SCRIPTFUNC_PARAMS) {





More information about the Scummvm-git-logs mailing list