[Scummvm-cvs-logs] SF.net SVN: scummvm: [26296] scummvm/trunk/engines/scumm
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sat Mar 24 23:30:18 CET 2007
Revision: 26296
http://scummvm.svn.sourceforge.net/scummvm/?rev=26296&view=rev
Author: fingolfin
Date: 2007-03-24 15:30:17 -0700 (Sat, 24 Mar 2007)
Log Message:
-----------
Cleaning up various issues with the Indy3 IQ patch
Modified Paths:
--------------
scummvm/trunk/engines/scumm/intern.h
scummvm/trunk/engines/scumm/script_v5.cpp
scummvm/trunk/engines/scumm/scumm.h
Modified: scummvm/trunk/engines/scumm/intern.h
===================================================================
--- scummvm/trunk/engines/scumm/intern.h 2007-03-24 21:18:08 UTC (rev 26295)
+++ scummvm/trunk/engines/scumm/intern.h 2007-03-24 22:30:17 UTC (rev 26296)
@@ -59,6 +59,8 @@
uint16 xStrips, yStrips;
bool isDrawn;
} _flashlight;
+
+ char _saveLoadVarsFilename[256];
public:
ScummEngine_v5(OSystem *syst, const DetectorResult &dr);
Modified: scummvm/trunk/engines/scumm/script_v5.cpp
===================================================================
--- scummvm/trunk/engines/scumm/script_v5.cpp 2007-03-24 21:18:08 UTC (rev 26295)
+++ scummvm/trunk/engines/scumm/script_v5.cpp 2007-03-24 22:30:17 UTC (rev 26296)
@@ -860,6 +860,15 @@
setResult(width);
}
+enum StringIds {
+ // The string IDs used by Indy3 to store the episode resp. series IQ points.
+ // Note that we save the episode IQ points but load the series IQ points,
+ // which matches the original Indy3 save/load code. See also the notes
+ // on Feature Request #1666521.
+ STRINGID_IQ_EPISODE = 7,
+ STRINGID_IQ_SERIES = 9
+};
+
void ScummEngine_v5::o5_saveLoadVars() {
if (fetchScriptByte() == 1)
saveVars();
@@ -869,7 +878,6 @@
void ScummEngine_v5::saveVars() {
int a, b;
- static char filename[256];
while ((_opcode = fetchScriptByte()) != 0) {
switch (_opcode & 0x1F) {
@@ -884,7 +892,7 @@
a = getVarOrDirectByte(PARAM_1);
b = getVarOrDirectByte(PARAM_2);
- if (a == RESID_IQ_EPISODE && b == RESID_IQ_EPISODE) {
+ if (a == STRINGID_IQ_EPISODE && b == STRINGID_IQ_EPISODE) {
if (_game.id == GID_INDY3) {
saveIQPoints();
}
@@ -894,14 +902,14 @@
break;
case 0x03: // open file
a = resStrLen(_scriptPointer);
- strncpy(filename, (const char *)_scriptPointer, a);
- filename[a] = '\0';
+ strncpy(_saveLoadVarsFilename, (const char *)_scriptPointer, a);
+ _saveLoadVarsFilename[a] = '\0';
_scriptPointer += a + 1;
break;
case 0x04:
return;
case 0x1F: // close file
- filename[0] = '\0';
+ _saveLoadVarsFilename[0] = '\0';
return;
}
}
@@ -909,7 +917,6 @@
void ScummEngine_v5::loadVars() {
int a, b;
- static char filename[256];
while ((_opcode = fetchScriptByte()) != 0) {
switch (_opcode & 0x1F) {
@@ -931,7 +938,7 @@
char name[32];
bool avail_saves[100];
- if (a == RESID_IQ_SERIES && b == RESID_IQ_SERIES) {
+ if (a == STRINGID_IQ_SERIES && b == STRINGID_IQ_SERIES) {
// Zak256 loads the IQ script-slot but does not use it -> ignore it
if(_game.id == GID_INDY3) {
loadIQPoints();
@@ -967,44 +974,42 @@
break;
case 0x03: // open file
a = resStrLen(_scriptPointer);
- strncpy(filename, (const char *)_scriptPointer, a);
- filename[a] = '\0';
+ strncpy(_saveLoadVarsFilename, (const char *)_scriptPointer, a);
+ _saveLoadVarsFilename[a] = '\0';
_scriptPointer += a + 1;
break;
case 0x04:
return;
case 0x1F: // close file
- filename[0] = '\0';
+ _saveLoadVarsFilename[0] = '\0';
return;
}
}
}
void ScummEngine_v5::saveIQPoints() {
- // save series IQ-points
+ // save Indy3 IQ-points
Common::OutSaveFile *file;
- char filename[256];
+ Common::String filename = _targetName + ".iq";
- sprintf(filename, "%s.iq", _targetName.c_str());
- file = _saveFileMan->openForSaving(filename);
+ file = _saveFileMan->openForSaving(filename.c_str());
if (file != NULL) {
- int size = getResourceSize(rtString, RESID_IQ_EPISODE);
- byte *ptr = getResourceAddress(rtString, RESID_IQ_EPISODE);
+ int size = getResourceSize(rtString, STRINGID_IQ_EPISODE);
+ byte *ptr = getResourceAddress(rtString, STRINGID_IQ_EPISODE);
file->write(ptr, size);
delete file;
}
}
void ScummEngine_v5::loadIQPoints() {
- // load series IQ-points
+ // load Indy3 IQ-points
Common::InSaveFile *file;
- char filename[256];
+ Common::String filename = _targetName + ".iq";
- sprintf(filename, "%s.iq", _targetName.c_str());
- file = _saveFileMan->openForLoading(filename);
+ file = _saveFileMan->openForLoading(filename.c_str());
if (file != NULL) {
- int size = getResourceSize(rtString, RESID_IQ_SERIES);
- byte *ptr = getResourceAddress(rtString, RESID_IQ_SERIES);
+ int size = getResourceSize(rtString, STRINGID_IQ_SERIES);
+ byte *ptr = getResourceAddress(rtString, STRINGID_IQ_SERIES);
byte *tmp = (byte*)malloc(size);
int nread = file->read(tmp, size);
if (nread == size) {
Modified: scummvm/trunk/engines/scumm/scumm.h
===================================================================
--- scummvm/trunk/engines/scumm/scumm.h 2007-03-24 21:18:08 UTC (rev 26295)
+++ scummvm/trunk/engines/scumm/scumm.h 2007-03-24 22:30:17 UTC (rev 26296)
@@ -328,12 +328,7 @@
rtNumTypes = 22
};
-enum ResIds {
- RESID_IQ_EPISODE = 7,
- RESID_IQ_SERIES = 9
-};
-
/**
* The 'resource manager' class. Currently doesn't really deserve to be called
* a 'class', at least until somebody gets around to OOfying this more.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list