[Scummvm-cvs-logs] SF.net SVN: scummvm:[49328] scummvm/trunk/engines/sci/engine

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sun May 30 18:38:09 CEST 2010


Revision: 49328
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49328&view=rev
Author:   thebluegr
Date:     2010-05-30 16:38:08 +0000 (Sun, 30 May 2010)

Log Message:
-----------
Made load_script() a member of the Script class

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/segment.cpp
    scummvm/trunk/engines/sci/engine/segment.h

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2010-05-30 16:14:31 UTC (rev 49327)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2010-05-30 16:38:08 UTC (rev 49328)
@@ -757,27 +757,6 @@
 	retval->stack_top = stack->_entries + stack->_capacity;
 }
 
-static void load_script(EngineState *s, Script *scr) {
-	scr->_buf = (byte *)malloc(scr->getBufSize());
-	assert(scr->_buf);
-
-	Resource *script = g_sci->getResMan()->findResource(ResourceId(kResourceTypeScript, scr->_nr), 0);
-	assert(script != 0);
-
-	assert(scr->getBufSize() >= script->size);
-	memcpy(scr->_buf, script->data, script->size);
-
-	if (getSciVersion() >= SCI_VERSION_1_1) {
-		Resource *heap = g_sci->getResMan()->findResource(ResourceId(kResourceTypeHeap, scr->_nr), 0);
-		assert(heap != 0);
-
-		scr->_heapStart = scr->_buf + scr->getScriptSize();
-
-		assert(scr->getBufSize() - scr->getScriptSize() <= heap->size);
-		memcpy(scr->_heapStart, heap->data, heap->size);
-	}
-}
-
 // TODO: Move thie function to a more appropriate place, such as vm.cpp or script.cpp
 void SegManager::reconstructScripts(EngineState *s) {
 	uint i;
@@ -791,7 +770,7 @@
 		Script *scr = (Script *)mobj;
 
 		// FIXME: Unify this code with script_instantiate_* ?
-		load_script(s, scr);
+		scr->load(g_sci->getResMan());
 		scr->_localsBlock = (scr->_localsSegment == 0) ? NULL : (LocalVariables *)(_heap[scr->_localsSegment]);
 		if (getSciVersion() >= SCI_VERSION_1_1) {
 			scr->_exportTable = 0;

Modified: scummvm/trunk/engines/sci/engine/segment.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.cpp	2010-05-30 16:14:31 UTC (rev 49327)
+++ scummvm/trunk/engines/sci/engine/segment.cpp	2010-05-30 16:38:08 UTC (rev 49328)
@@ -147,6 +147,27 @@
 	return true;
 }
 
+void Script::load(ResourceManager *resMan) {
+	Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, _nr), 0);
+	assert(script != 0);
+
+	_buf = (byte *)malloc(_bufSize);
+	assert(_buf);
+
+	assert(_bufSize >= script->size);
+	memcpy(_buf, script->data, script->size);
+
+	if (getSciVersion() >= SCI_VERSION_1_1) {
+		Resource *heap = resMan->findResource(ResourceId(kResourceTypeHeap, _nr), 0);
+		assert(heap != 0);
+
+		_heapStart = _buf + _scriptSize;
+
+		assert(_bufSize - _scriptSize <= heap->size);
+		memcpy(_heapStart, heap->data, heap->size);
+	}
+}
+
 void Script::setScriptSize(int script_nr, ResourceManager *resMan) {
 	Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0);
 	Resource *heap = resMan->findResource(ResourceId(kResourceTypeHeap, script_nr), 0);

Modified: scummvm/trunk/engines/sci/engine/segment.h
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.h	2010-05-30 16:14:31 UTC (rev 49327)
+++ scummvm/trunk/engines/sci/engine/segment.h	2010-05-30 16:38:08 UTC (rev 49328)
@@ -364,6 +364,7 @@
 
 	void freeScript();
 	bool init(int script_nr, ResourceManager *resMan);
+	void load(ResourceManager *resMan);
 
 	virtual bool isValidOffset(uint16 offset) const;
 	virtual SegmentRef dereference(reg_t pointer);


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