SCI: Turn reconstruct_scripts into SegManager::reconstructScripts
svn-id: r44806
This commit is contained in:
parent
860f7ce39b
commit
0c457be0fb
2 changed files with 63 additions and 74 deletions
|
@ -572,21 +572,20 @@ static void load_script(EngineState *s, Script *scr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: The following should likely become a SegManager method
|
void SegManager::reconstructScripts(EngineState *s) {
|
||||||
static void reconstruct_scripts(EngineState *s, SegManager *self) {
|
|
||||||
uint i;
|
uint i;
|
||||||
SegmentObj *mobj;
|
SegmentObj *mobj;
|
||||||
|
|
||||||
for (i = 0; i < self->_heap.size(); i++) {
|
for (i = 0; i < _heap.size(); i++) {
|
||||||
if (self->_heap[i]) {
|
mobj = _heap[i];
|
||||||
mobj = self->_heap[i];
|
if (!mobj || mobj->getType() != SEG_TYPE_SCRIPT)
|
||||||
switch (mobj->getType()) {
|
continue;
|
||||||
case SEG_TYPE_SCRIPT: {
|
|
||||||
Script *scr = (Script *)mobj;
|
Script *scr = (Script *)mobj;
|
||||||
|
|
||||||
// FIXME: Unify this code with script_instantiate_*
|
// FIXME: Unify this code with script_instantiate_* ?
|
||||||
load_script(s, scr);
|
load_script(s, scr);
|
||||||
scr->_localsBlock = (scr->_localsSegment == 0) ? NULL : (LocalVariables *)(s->_segMan->_heap[scr->_localsSegment]);
|
scr->_localsBlock = (scr->_localsSegment == 0) ? NULL : (LocalVariables *)(_heap[scr->_localsSegment]);
|
||||||
if (getSciVersion() >= SCI_VERSION_1_1) {
|
if (getSciVersion() >= SCI_VERSION_1_1) {
|
||||||
scr->_exportTable = 0;
|
scr->_exportTable = 0;
|
||||||
scr->_synonyms = 0;
|
scr->_synonyms = 0;
|
||||||
|
@ -608,34 +607,29 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) {
|
||||||
it->_value.base = scr->_buf;
|
it->_value.base = scr->_buf;
|
||||||
it->_value.base_obj = data;
|
it->_value.base_obj = data;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < self->_heap.size(); i++) {
|
for (i = 0; i < _heap.size(); i++) {
|
||||||
if (self->_heap[i]) {
|
mobj = _heap[i];
|
||||||
mobj = self->_heap[i];
|
if (!mobj || mobj->getType() != SEG_TYPE_SCRIPT)
|
||||||
switch (mobj->getType()) {
|
continue;
|
||||||
case SEG_TYPE_SCRIPT: {
|
|
||||||
Script *scr = (Script *)mobj;
|
Script *scr = (Script *)mobj;
|
||||||
|
|
||||||
|
// FIXME: Unify this code with Script::scriptObjInit ?
|
||||||
ObjMap::iterator it;
|
ObjMap::iterator it;
|
||||||
const ObjMap::iterator end = scr->_objects.end();
|
const ObjMap::iterator end = scr->_objects.end();
|
||||||
for (it = scr->_objects.begin(); it != end; ++it) {
|
for (it = scr->_objects.begin(); it != end; ++it) {
|
||||||
byte *data = scr->_buf + it->_value._pos.offset;
|
byte *data = scr->_buf + it->_value._pos.offset;
|
||||||
|
|
||||||
if (getSciVersion() >= SCI_VERSION_1_1) {
|
if (getSciVersion() >= SCI_VERSION_1_1) {
|
||||||
uint16 *funct_area = (uint16 *) (scr->_buf + READ_LE_UINT16( data + 6 ));
|
uint16 *funct_area = (uint16 *)(scr->_buf + READ_LE_UINT16( data + 6 ));
|
||||||
uint16 *prop_area = (uint16 *) (scr->_buf + READ_LE_UINT16( data + 4 ));
|
uint16 *prop_area = (uint16 *)(scr->_buf + READ_LE_UINT16( data + 4 ));
|
||||||
|
|
||||||
it->_value.base_method = funct_area;
|
it->_value.base_method = funct_area;
|
||||||
it->_value.base_vars = prop_area;
|
it->_value.base_vars = prop_area;
|
||||||
} else {
|
} else {
|
||||||
int funct_area = READ_LE_UINT16( data + SCRIPT_FUNCTAREAPTR_OFFSET );
|
int funct_area = READ_LE_UINT16(data + SCRIPT_FUNCTAREAPTR_OFFSET);
|
||||||
Object *base_obj;
|
Object *base_obj;
|
||||||
|
|
||||||
base_obj = s->_segMan->getObject(it->_value.getSpeciesSelector());
|
base_obj = s->_segMan->getObject(it->_value.getSpeciesSelector());
|
||||||
|
@ -652,12 +646,6 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) {
|
||||||
it->_value.base_vars = (uint16 *)(data + it->_value.variable_names_nr * 2 + SCRIPT_SELECTOR_OFFSET);
|
it->_value.base_vars = (uint16 *)(data + it->_value.variable_names_nr * 2 + SCRIPT_SELECTOR_OFFSET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -756,7 +744,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
|
||||||
|
|
||||||
_reset_graphics_input(retval);
|
_reset_graphics_input(retval);
|
||||||
reconstruct_stack(retval);
|
reconstruct_stack(retval);
|
||||||
reconstruct_scripts(retval, retval->_segMan);
|
retval->_segMan->reconstructScripts(retval);
|
||||||
retval->_segMan->reconstructClones();
|
retval->_segMan->reconstructClones();
|
||||||
retval->game_obj = s->game_obj;
|
retval->game_obj = s->game_obj;
|
||||||
retval->script_000 = retval->_segMan->getScript(retval->_segMan->getScriptSegment(0, SCRIPT_GET_DONT_LOAD));
|
retval->script_000 = retval->_segMan->getScript(retval->_segMan->getScriptSegment(0, SCRIPT_GET_DONT_LOAD));
|
||||||
|
|
|
@ -79,6 +79,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void deallocateScript(int script_nr);
|
void deallocateScript(int script_nr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reconstructs scripts. Used when restoring saved games
|
||||||
|
*/
|
||||||
|
void reconstructScripts(EngineState *s);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate whether the specified public function is exported by
|
* Validate whether the specified public function is exported by
|
||||||
* the script in the specified segment.
|
* the script in the specified segment.
|
||||||
|
@ -106,6 +111,7 @@ public:
|
||||||
*/
|
*/
|
||||||
SegmentId getScriptSegment(int script_nr, ScriptLoadType load);
|
SegmentId getScriptSegment(int script_nr, ScriptLoadType load);
|
||||||
|
|
||||||
|
// TODO: document this
|
||||||
reg_t lookupScriptExport(int script_nr, int export_index) {
|
reg_t lookupScriptExport(int script_nr, int export_index) {
|
||||||
SegmentId seg = getScriptSegment(script_nr, SCRIPT_GET_DONT_LOAD);
|
SegmentId seg = getScriptSegment(script_nr, SCRIPT_GET_DONT_LOAD);
|
||||||
return make_reg(seg, validateExportFunc(export_index, seg));
|
return make_reg(seg, validateExportFunc(export_index, seg));
|
||||||
|
@ -169,16 +175,11 @@ public:
|
||||||
*/
|
*/
|
||||||
Clone *allocateClone(reg_t *addr);
|
Clone *allocateClone(reg_t *addr);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reconstructs clones. Used when restoring saved games
|
* Reconstructs clones. Used when restoring saved games
|
||||||
*/
|
*/
|
||||||
void reconstructClones();
|
void reconstructClones();
|
||||||
|
|
||||||
// 3. Objects (static, from Scripts, and dynmic, from Clones)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 4. Stack
|
// 4. Stack
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue