Skip to content

Commit

Permalink
WAGE: Correctly specify target name for dumped scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 29, 2017
1 parent 5eaa48e commit 31eb472
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
12 changes: 5 additions & 7 deletions engines/wage/script.cpp
Expand Up @@ -76,8 +76,7 @@ Common::String Script::Operand::toString() {
}
}

Script::Script(Common::SeekableReadStream *data, int num) : _data(data) {
_engine = NULL;
Script::Script(Common::SeekableReadStream *data, int num, WageEngine *engine) : _data(data), _engine(engine) {
_world = NULL;

_loopCount = 0;
Expand All @@ -93,9 +92,9 @@ Script::Script(Common::SeekableReadStream *data, int num) : _data(data) {
Common::String name;

if (num == -1)
name = Common::String::format("./dumps/%s-global.txt", ConfMan.get("gameid").c_str());
name = Common::String::format("./dumps/%s-global.txt", _engine->getTargetName());
else
name = Common::String::format("./dumps/%s-%d.txt", ConfMan.get("gameid").c_str(), num);
name = Common::String::format("./dumps/%s-%d.txt", _engine->getTargetName(), num);

if (!out.open(name)) {
warning("Can not open dump file %s", name.c_str());
Expand Down Expand Up @@ -174,12 +173,11 @@ Common::String Script::preprocessInputText(Common::String inputText) {
return inputText;
}

bool Script::execute(World *world, int loopCount, Common::String *inputText, Designed *inputClick, WageEngine *engine) {
bool Script::execute(World *world, int loopCount, Common::String *inputText, Designed *inputClick) {
_world = world;
_loopCount = loopCount;
_inputText = inputText;
_inputClick = inputClick;
_engine = engine;
_handled = false;
Common::String input;

Expand Down Expand Up @@ -257,7 +255,7 @@ bool Script::execute(World *world, int loopCount, Common::String *inputText, Des

if (_world->_globalScript != this) {
debug(1, "Executing global script...");
bool globalHandled = _world->_globalScript->execute(_world, _loopCount, &input, _inputClick, _engine);
bool globalHandled = _world->_globalScript->execute(_world, _loopCount, &input, _inputClick);
if (globalHandled)
_handled = true;
} else if (!input.empty()) {
Expand Down
4 changes: 2 additions & 2 deletions engines/wage/script.h
Expand Up @@ -52,7 +52,7 @@ namespace Wage {

class Script {
public:
Script(Common::SeekableReadStream *data, int num);
Script(Common::SeekableReadStream *data, int num, WageEngine *engine);
~Script();

private:
Expand Down Expand Up @@ -130,7 +130,7 @@ class Script {
public:
void print();
void printLine(int offset);
bool execute(World *world, int loopCount, Common::String *inputText, Designed *inputClick, WageEngine *engine);
bool execute(World *world, int loopCount, Common::String *inputText, Designed *inputClick);

private:
Common::String preprocessInputText(Common::String inputText);
Expand Down
2 changes: 1 addition & 1 deletion engines/wage/wage.cpp
Expand Up @@ -431,7 +431,7 @@ void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickI

bool monsterWasNull = (_monster == NULL);
Script *script = playerScene->_script != NULL ? playerScene->_script : _world->_globalScript;
bool handled = script->execute(_world, _loopCount++, textInput, clickInput, this);
bool handled = script->execute(_world, _loopCount++, textInput, clickInput);

playerScene = _world->_player->_currentScene;

Expand Down
2 changes: 2 additions & 0 deletions engines/wage/wage.h
Expand Up @@ -127,6 +127,8 @@ class WageEngine : public Engine {
void processTurn(Common::String *textInput, Designed *clickInput);
void regen();

const char *getTargetName() { return _targetName.c_str(); }

private:
bool loadWorld(Common::MacResManager *resMan);
void performInitialSetup();
Expand Down
4 changes: 2 additions & 2 deletions engines/wage/world.cpp
Expand Up @@ -132,7 +132,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {

// Load global script
res = resMan->getResource(MKTAG('G','C','O','D'), resArray[0]);
_globalScript = new Script(res, -1);
_globalScript = new Script(res, -1, _engine);

// TODO: read creator

Expand Down Expand Up @@ -209,7 +209,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {

res = resMan->getResource(MKTAG('A','C','O','D'), *iter);
if (res != NULL)
scene->_script = new Script(res, *iter);
scene->_script = new Script(res, *iter, _engine);

res = resMan->getResource(MKTAG('A','T','X','T'), *iter);
if (res != NULL) {
Expand Down

0 comments on commit 31eb472

Please sign in to comment.