[Scummvm-cvs-logs] SF.net SVN: scummvm:[49093] scummvm/trunk/engines/sci/engine
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Wed May 19 10:50:24 CEST 2010
Revision: 49093
http://scummvm.svn.sourceforge.net/scummvm/?rev=49093&view=rev
Author: thebluegr
Date: 2010-05-19 08:50:24 +0000 (Wed, 19 May 2010)
Log Message:
-----------
Removed the exportsAreWide variable from the segment manager and save games, and moved validateExportFunc() in the Script class, thus resolving a TODO
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/game.cpp
scummvm/trunk/engines/sci/engine/kscripts.cpp
scummvm/trunk/engines/sci/engine/savegame.cpp
scummvm/trunk/engines/sci/engine/seg_manager.cpp
scummvm/trunk/engines/sci/engine/seg_manager.h
scummvm/trunk/engines/sci/engine/segment.cpp
scummvm/trunk/engines/sci/engine/segment.h
scummvm/trunk/engines/sci/engine/vm.cpp
Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp 2010-05-19 07:25:06 UTC (rev 49092)
+++ scummvm/trunk/engines/sci/engine/game.cpp 2010-05-19 08:50:24 UTC (rev 49093)
@@ -218,11 +218,6 @@
s->restarting_flags = SCI_GAME_IS_NOT_RESTARTING;
- if (g_sci->_features->detectLofsType() == SCI_VERSION_1_MIDDLE)
- s->_segMan->setExportAreWide(true);
- else
- s->_segMan->setExportAreWide(false);
-
debug(2, "Engine initialized");
return 0;
Modified: scummvm/trunk/engines/sci/engine/kscripts.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kscripts.cpp 2010-05-19 07:25:06 UTC (rev 49092)
+++ scummvm/trunk/engines/sci/engine/kscripts.cpp 2010-05-19 08:50:24 UTC (rev 49093)
@@ -187,12 +187,11 @@
return argv[0];
SegmentId scriptSeg = s->_segMan->getScriptSegment(script, SCRIPT_GET_LOAD);
- Script *scr;
if (!scriptSeg)
return NULL_REG;
- scr = s->_segMan->getScript(scriptSeg);
+ Script *scr = s->_segMan->getScript(scriptSeg);
if (!scr->_numExports) {
// FIXME: Is this fatal? This occurs in SQ4CD
@@ -205,7 +204,7 @@
return NULL_REG;
}
- return make_reg(scriptSeg, s->_segMan->validateExportFunc(index, scriptSeg));
+ return make_reg(scriptSeg, scr->validateExportFunc(index));
}
reg_t kDisposeScript(EngineState *s, int argc, reg_t *argv) {
Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp 2010-05-19 07:25:06 UTC (rev 49092)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp 2010-05-19 08:50:24 UTC (rev 49093)
@@ -221,9 +221,9 @@
}
void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
- s.skip(4, VER(9), VER(9)); // OBSOLETE: Used to be reserved_id
- s.syncAsSint32LE(_exportsAreWide);
- s.skip(4, VER(9), VER(9)); // OBSOLETE: Used to be gc_mark_bits
+ s.skip(4, VER(9), VER(9)); // OBSOLETE: Used to be reserved_id
+ s.skip(4, VER(18), VER(18)); // OBSOLETE: Used to be _exportsAreWide
+ s.skip(4, VER(9), VER(9)); // OBSOLETE: Used to be gc_mark_bits
if (s.isLoading()) {
// Reset _scriptSegMap, to be restored below
Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp 2010-05-19 07:25:06 UTC (rev 49092)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp 2010-05-19 08:50:24 UTC (rev 49093)
@@ -49,7 +49,6 @@
String_seg_id = 0;
#endif
- _exportsAreWide = false;
_resMan = resMan;
createClassTable();
@@ -340,10 +339,6 @@
return true;
}
-void SegManager::setExportAreWide(bool flag) {
- _exportsAreWide = flag;
-}
-
// return the seg if script_id is valid and in the map, else 0
SegmentId SegManager::getScriptSegment(int script_id) const {
return _scriptSegMap.getVal(script_id, 0);
Modified: scummvm/trunk/engines/sci/engine/seg_manager.h
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.h 2010-05-19 07:25:06 UTC (rev 49092)
+++ scummvm/trunk/engines/sci/engine/seg_manager.h 2010-05-19 08:50:24 UTC (rev 49093)
@@ -96,17 +96,6 @@
void reconstructScripts(EngineState *s);
/**
- * Validate whether the specified public function is exported by
- * the script in the specified segment.
- * @param pubfunct Index of the function to validate
- * @param seg Segment ID of the script the check is to
- * be performed for
- * @return NULL if the public function is invalid, its
- * offset into the script's segment otherwise
- */
- uint16 validateExportFunc(int pubfunct, SegmentId seg);
-
- /**
* Determines the segment occupied by a certain script, if any.
* @param script_nr Number of the script to look up
* @return The script's segment ID, or 0 on failure
@@ -125,7 +114,7 @@
// TODO: document this
reg_t lookupScriptExport(int script_nr, int export_index) {
SegmentId seg = getScriptSegment(script_nr, SCRIPT_GET_DONT_LOAD);
- return make_reg(seg, validateExportFunc(export_index, seg));
+ return make_reg(seg, getScript(seg)->validateExportFunc(export_index));
}
// TODO: document this
@@ -171,12 +160,6 @@
*/
void scriptInitialiseLocals(reg_t location);
- /**
- * Tells the segment manager whether exports are wide (32-bit) or not.
- * @param flag true if exports are wide, false otherwise
- */
- void setExportAreWide(bool flag);
-
// 2. Clones
/**
@@ -472,8 +455,6 @@
ResourceManager *_resMan;
- bool _exportsAreWide;
-
SegmentId Clones_seg_id; ///< ID of the (a) clones segment
SegmentId Lists_seg_id; ///< ID of the (a) list segment
SegmentId Nodes_seg_id; ///< ID of the (a) node segment
Modified: scummvm/trunk/engines/sci/engine/segment.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.cpp 2010-05-19 07:25:06 UTC (rev 49092)
+++ scummvm/trunk/engines/sci/engine/segment.cpp 2010-05-19 08:50:24 UTC (rev 49093)
@@ -26,6 +26,7 @@
#include "common/endian.h"
#include "sci/sci.h"
+#include "sci/engine/features.h"
#include "sci/engine/segment.h"
#include "sci/engine/seg_manager.h"
#include "sci/engine/state.h"
@@ -366,22 +367,18 @@
}
}
-// TODO: This method should be Script method. The only reason
-// that it isn't is that it uses _exportsAreWide, which is true if
-// detectLofsType() == SCI_VERSION_1_MIDDLE
-// Maybe _exportsAreWide should become a Script member var, e.g. set
-// by setExportTableOffset?
-uint16 SegManager::validateExportFunc(int pubfunct, SegmentId seg) {
- Script *scr = getScript(seg);
- if (scr->_numExports <= pubfunct) {
+uint16 Script::validateExportFunc(int pubfunct) {
+ bool exportsAreWide = (g_sci->_features->detectLofsType() == SCI_VERSION_1_MIDDLE);
+
+ if (_numExports <= pubfunct) {
warning("validateExportFunc(): pubfunct is invalid");
return 0;
}
- if (_exportsAreWide)
+ if (exportsAreWide)
pubfunct *= 2;
- uint16 offset = READ_SCI11ENDIAN_UINT16((byte *)(scr->_exportTable + pubfunct));
- VERIFY(offset < scr->_bufSize, "invalid export function pointer");
+ uint16 offset = READ_SCI11ENDIAN_UINT16((byte *)(_exportTable + pubfunct));
+ VERIFY(offset < _bufSize, "invalid export function pointer");
return offset;
}
Modified: scummvm/trunk/engines/sci/engine/segment.h
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.h 2010-05-19 07:25:06 UTC (rev 49092)
+++ scummvm/trunk/engines/sci/engine/segment.h 2010-05-19 08:50:24 UTC (rev 49093)
@@ -446,7 +446,6 @@
*/
int getSynonymsNr() const;
-
/**
* Sets the script-relative offset of the exports table.
* @param offset script-relative exports table offset
@@ -454,6 +453,15 @@
void setExportTableOffset(int offset);
/**
+ * Validate whether the specified public function is exported by
+ * the script in the specified segment.
+ * @param pubfunct Index of the function to validate
+ * @return NULL if the public function is invalid, its
+ * offset into the script's segment otherwise
+ */
+ uint16 validateExportFunc(int pubfunct);
+
+ /**
* Sets the script-relative offset of the synonyms associated with this script.
* @param offset script-relative offset of the synonyms block
*/
Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp 2010-05-19 07:25:06 UTC (rev 49092)
+++ scummvm/trunk/engines/sci/engine/vm.cpp 2010-05-19 08:50:24 UTC (rev 49093)
@@ -258,10 +258,12 @@
int seg = s->_segMan->getScriptSegment(script);
Script *scr = s->_segMan->getScriptIfLoaded(seg);
- if (!scr || scr->isMarkedAsDeleted()) // Script not present yet?
+ if (!scr || scr->isMarkedAsDeleted()) { // Script not present yet?
seg = script_instantiate(g_sci->getResMan(), s->_segMan, script);
+ scr = s->_segMan->getScript(seg);
+ }
- const int temp = s->_segMan->validateExportFunc(pubfunct, seg);
+ const int temp = scr->validateExportFunc(pubfunct);
if (!temp) {
#ifdef ENABLE_SCI32
// HACK: Temporarily switch to a warning in SCI32 games until we can figure out why Torin has
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