[Scummvm-cvs-logs] SF.net SVN: scummvm:[35378] scummvm/trunk/engines/made
john_doe at users.sourceforge.net
john_doe at users.sourceforge.net
Mon Dec 15 10:01:43 CET 2008
Revision: 35378
http://scummvm.svn.sourceforge.net/scummvm/?rev=35378&view=rev
Author: john_doe
Date: 2008-12-15 09:01:43 +0000 (Mon, 15 Dec 2008)
Log Message:
-----------
- Implemented cmd_restart (for the restart functionality in Return to Zork)
Modified Paths:
--------------
scummvm/trunk/engines/made/database.cpp
scummvm/trunk/engines/made/database.h
scummvm/trunk/engines/made/made.cpp
scummvm/trunk/engines/made/made.h
scummvm/trunk/engines/made/script.cpp
Modified: scummvm/trunk/engines/made/database.cpp
===================================================================
--- scummvm/trunk/engines/made/database.cpp 2008-12-15 07:15:29 UTC (rev 35377)
+++ scummvm/trunk/engines/made/database.cpp 2008-12-15 09:01:43 UTC (rev 35378)
@@ -254,6 +254,9 @@
void GameDatabase::open(const char *filename) {
debug(1, "GameDatabase::open() Loading from %s", filename);
+ _isRedSource = false;
+ _filename = filename;
+ _redFilename = "";
Common::File fd;
if (!fd.open(filename))
error("GameDatabase::open() Could not open %s", filename);
@@ -263,6 +266,9 @@
void GameDatabase::openFromRed(const char *redFilename, const char *filename) {
debug(1, "GameDatabase::openFromRed() Loading from %s->%s", redFilename, filename);
+ _isRedSource = true;
+ _filename = filename;
+ _redFilename = redFilename;
Common::MemoryReadStream *fileS = RedReader::loadFromRed(redFilename, filename);
if (!fileS)
error("GameDatabase::openFromRed() Could not load %s from %s", filename, redFilename);
@@ -270,6 +276,21 @@
delete fileS;
}
+void GameDatabase::reload() {
+ if (!_isRedSource) {
+ Common::File fd;
+ if (!fd.open(_filename.c_str()))
+ error("GameDatabase::reload() Could not open %s", _filename.c_str());
+ reloadFromStream(fd);
+ } else {
+ Common::MemoryReadStream *fileS = RedReader::loadFromRed(_redFilename.c_str(), _filename.c_str());
+ if (!fileS)
+ error("GameDatabase::openFromRed() Could not load %s from %s", _filename.c_str(), _redFilename.c_str());
+ reloadFromStream(*fileS);
+ delete fileS;
+ }
+}
+
int16 GameDatabase::getVar(int16 index) {
return (int16)READ_LE_UINT16(_gameState + index * 2);
}
@@ -391,6 +412,10 @@
}
+void GameDatabaseV2::reloadFromStream(Common::SeekableReadStream &sourceS) {
+ // Not used in version 2 games
+}
+
bool GameDatabaseV2::getSavegameDescription(const char *filename, Common::String &description) {
// Not used in version 2 games
return false;
@@ -509,16 +534,16 @@
uint32 objectIndexOffs = sourceS.readUint32LE();
uint16 objectCount = sourceS.readUint16LE();
- uint32 gameStateOffs = sourceS.readUint32LE();
+ _gameStateOffs = sourceS.readUint32LE();
_gameStateSize = sourceS.readUint32LE();
uint32 objectsOffs = sourceS.readUint32LE();
uint32 objectsSize = sourceS.readUint32LE();
_mainCodeObjectIndex = sourceS.readUint16LE();
- debug(2, "objectIndexOffs = %08X; objectCount = %d; gameStateOffs = %08X; gameStateSize = %d; objectsOffs = %08X; objectsSize = %d\n", objectIndexOffs, objectCount, gameStateOffs, _gameStateSize, objectsOffs, objectsSize);
+ debug(2, "objectIndexOffs = %08X; objectCount = %d; gameStateOffs = %08X; gameStateSize = %d; objectsOffs = %08X; objectsSize = %d\n", objectIndexOffs, objectCount, _gameStateOffs, _gameStateSize, objectsOffs, objectsSize);
_gameState = new byte[_gameStateSize];
- sourceS.seek(gameStateOffs);
+ sourceS.seek(_gameStateOffs);
sourceS.read(_gameState, _gameStateSize);
Common::Array<uint32> objectOffsets;
@@ -544,6 +569,11 @@
}
+void GameDatabaseV3::reloadFromStream(Common::SeekableReadStream &sourceS) {
+ sourceS.seek(_gameStateOffs);
+ sourceS.read(_gameState, _gameStateSize);
+}
+
bool GameDatabaseV3::getSavegameDescription(const char *filename, Common::String &description) {
Common::InSaveFile *in;
char desc[64];
Modified: scummvm/trunk/engines/made/database.h
===================================================================
--- scummvm/trunk/engines/made/database.h 2008-12-15 07:15:29 UTC (rev 35377)
+++ scummvm/trunk/engines/made/database.h 2008-12-15 09:01:43 UTC (rev 35378)
@@ -116,6 +116,8 @@
void open(const char *filename);
void openFromRed(const char *redFilename, const char *filename);
+ void reload();
+
Object *getObject(int16 index) const {
if (index >= 1)
return _objects[index - 1];
@@ -150,7 +152,10 @@
byte *_gameState;
uint32 _gameStateSize;
int16 _mainCodeObjectIndex;
+ bool _isRedSource;
+ Common::String _filename, _redFilename;
virtual void load(Common::SeekableReadStream &sourceS) = 0;
+ virtual void reloadFromStream(Common::SeekableReadStream &sourceS) = 0;
};
class GameDatabaseV2 : public GameDatabase {
@@ -165,6 +170,7 @@
protected:
char *_gameText;
void load(Common::SeekableReadStream &sourceS);
+ void reloadFromStream(Common::SeekableReadStream &sourceS);
};
class GameDatabaseV3 : public GameDatabase {
@@ -177,7 +183,9 @@
int16 loadgame(const char *filename, int16 version);
protected:
char *_gameText;
+ uint32 _gameStateOffs;
void load(Common::SeekableReadStream &sourceS);
+ void reloadFromStream(Common::SeekableReadStream &sourceS);
};
} // End of namespace Made
Modified: scummvm/trunk/engines/made/made.cpp
===================================================================
--- scummvm/trunk/engines/made/made.cpp 2008-12-15 07:15:29 UTC (rev 35377)
+++ scummvm/trunk/engines/made/made.cpp 2008-12-15 09:01:43 UTC (rev 35378)
@@ -179,6 +179,11 @@
_timers[timerNum - 1] = -1;
}
+void MadeEngine::resetAllTimers() {
+ for (int i = 0; i < ARRAYSIZE(_timers); i++)
+ _timers[i] = -1;
+}
+
Common::String MadeEngine::getSavegameFilename(int16 saveNum) {
char filename[256];
snprintf(filename, 256, "%s.%03d", getTargetName().c_str(), saveNum);
@@ -237,8 +242,7 @@
Common::Error MadeEngine::go() {
- for (int i = 0; i < ARRAYSIZE(_timers); i++)
- _timers[i] = -1;
+ resetAllTimers();
if (getGameID() == GID_RTZ) {
_engineVersion = 3;
Modified: scummvm/trunk/engines/made/made.h
===================================================================
--- scummvm/trunk/engines/made/made.h 2008-12-15 07:15:29 UTC (rev 35377)
+++ scummvm/trunk/engines/made/made.h 2008-12-15 09:01:43 UTC (rev 35378)
@@ -127,6 +127,7 @@
void resetTimer(int16 timerNum);
int16 allocTimer();
void freeTimer(int16 timerNum);
+ void resetAllTimers();
const Common::String getTargetName() { return _targetName; }
Common::String getSavegameFilename(int16 saveNum);
Modified: scummvm/trunk/engines/made/script.cpp
===================================================================
--- scummvm/trunk/engines/made/script.cpp 2008-12-15 07:15:29 UTC (rev 35377)
+++ scummvm/trunk/engines/made/script.cpp 2008-12-15 09:01:43 UTC (rev 35378)
@@ -554,8 +554,10 @@
}
void ScriptInterpreter::cmd_restart() {
- // TODO: Used in RTZ
- warning("Unimplemented command: cmd_restart");
+ _vm->_dat->reload();
+ _vm->_screen->clearChannels();
+ _vm->resetAllTimers();
+ _stack.setTop(0);
}
void ScriptInterpreter::cmd_rand() {
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