Skip to content

Commit

Permalink
ZVISION: Refactoring script manager, massive changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marisa-Chan committed Oct 25, 2013
1 parent 8e4070c commit c0a709d
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 271 deletions.
7 changes: 0 additions & 7 deletions engines/zvision/actions.cpp
Expand Up @@ -124,7 +124,6 @@ ActionDisableControl::ActionDisableControl(const Common::String &line) {
bool ActionDisableControl::execute(ZVision *engine) {
debug("Disabling control %u", _key);

engine->getScriptManager()->disableControl(_key);

return true;
}
Expand All @@ -141,7 +140,6 @@ ActionEnableControl::ActionEnableControl(const Common::String &line) {
bool ActionEnableControl::execute(ZVision *engine) {
debug("Enabling control %u", _key);

engine->getScriptManager()->enableControl(_key);

return true;
}
Expand Down Expand Up @@ -220,8 +218,6 @@ bool ActionPreloadAnimation::execute(ZVision *engine) {
// TODO: Check if the Control already exists

// Create the control, but disable it until PlayPreload is called
engine->getScriptManager()->addControl(new AnimationControl(engine, _key, _fileName));
engine->getScriptManager()->disableControl(_key);
return true;
}

Expand Down Expand Up @@ -267,9 +263,6 @@ bool ActionPlayPreloadAnimation::execute(ZVision *engine) {
control->setXPos(_x1);
control->setYPost(_y1);

// Enable the control. ScriptManager will take care of the rest
control->enable();

return true;
}

Expand Down
1 change: 0 additions & 1 deletion engines/zvision/console.cpp
Expand Up @@ -197,7 +197,6 @@ bool Console::cmdParseAllScrFiles(int argc, const char **argv) {
SearchMan.listMatchingMembers(list, "*.scr");

for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
_engine->getScriptManager()->parseScrFile((*iter)->getName());
}

return true;
Expand Down
5 changes: 0 additions & 5 deletions engines/zvision/save_manager.cpp
Expand Up @@ -128,8 +128,6 @@ void SaveManager::writeSaveGameData(Common::OutSaveFile *file) {
// Write out the current state table values
scriptManager->serializeStateTable(file);

// Write out any controls needing to save state
scriptManager->serializeControls(file);
}

Common::Error SaveManager::loadGame(uint slot) {
Expand Down Expand Up @@ -160,9 +158,6 @@ Common::Error SaveManager::loadGame(uint slot) {
// Load the room
scriptManager->changeLocation(world, room, node, view, offset);

// Update the controls
scriptManager->deserializeControls(saveFile);

return Common::kNoError;
}

Expand Down
36 changes: 19 additions & 17 deletions engines/zvision/scr_file_handling.cpp
Expand Up @@ -37,7 +37,7 @@

namespace ZVision {

void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) {
void ScriptManager::parseScrFile(const Common::String &fileName, script_scope &scope) {
Common::File file;
if (!file.open(fileName)) {
warning("Script file not found: %s", fileName.c_str());
Expand All @@ -58,17 +58,18 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal)
if (line.matchString("puzzle:*", true)) {
Puzzle *puzzle = new Puzzle();
sscanf(line.c_str(), "puzzle:%u", &(puzzle->key));

if (getStateFlag(puzzle->key) & Puzzle::ONCE_PER_INST)
setStateValue(puzzle->key, 0);
parsePuzzle(puzzle, file);
if (isGlobal) {
_globalPuzzles.push_back(puzzle);
} else {
_activePuzzles.push_back(puzzle);
}
scope._puzzles.push_back(puzzle);

} else if (line.matchString("control:*", true)) {
parseControl(line, file);
Control *ctrl = parseControl(line, file);
if (ctrl)
scope._controls.push_back(ctrl);
}
}
scope.proc_count = 0;
}

void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream) {
Expand All @@ -81,12 +82,14 @@ void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stre
} else if (line.matchString("results {", true)) {
parseResults(stream, puzzle->resultActions);
} else if (line.matchString("flags {", true)) {
puzzle->flags = parseFlags(stream);
setStateFlag(puzzle->key, parseFlags(stream));
}

line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
}

puzzle->addedBySetState = 0;
}

bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::List<Common::List<Puzzle::CriteriaEntry> > &criteriaList) const {
Expand Down Expand Up @@ -273,7 +276,7 @@ uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
return flags;
}

void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) {
Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) {
uint32 key;
char controlTypeBuffer[20];

Expand All @@ -282,21 +285,20 @@ void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea
Common::String controlType(controlTypeBuffer);

if (controlType.equalsIgnoreCase("push_toggle")) {
_activeControls.push_back(new PushToggleControl(_engine, key, stream));
return;
return new PushToggleControl(_engine, key, stream);
} else if (controlType.equalsIgnoreCase("flat")) {
Control::parseFlatControl(_engine);
return;
return NULL;
} else if (controlType.equalsIgnoreCase("pana")) {
Control::parsePanoramaControl(_engine, stream);
return;
return NULL;
} else if (controlType.equalsIgnoreCase("tilt")) {
Control::parseTiltControl(_engine, stream);
return;
return NULL;
} else if (controlType.equalsIgnoreCase("lever")) {
_activeControls.push_back(new LeverControl(_engine, key, stream));
return;
return new LeverControl(_engine, key, stream);
}
return NULL;
}

} // End of namespace ZVision

0 comments on commit c0a709d

Please sign in to comment.