Skip to content

Commit

Permalink
- fix relative path mounting game archives
Browse files Browse the repository at this point in the history
- rework ParseMovie to run action if failing to load movie
  • Loading branch information
dgengin committed Jun 23, 2016
1 parent 0e7b5b8 commit a35d5d7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
21 changes: 16 additions & 5 deletions src/Parser/ParseMovie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,27 @@ namespace Parser
return;
}

std::shared_ptr<Action> action;
if (elem.HasMember("onComplete"))
{
action = parseAction(game, elem["onComplete"]);
}
auto movie = std::make_shared<Movie2>(elem["file"].GetString());
if (movie->load() == false)
{
if (action != nullptr)
{
game.Events().addBack(action);
}
return;
}
else
{
if (action != nullptr)
{
movie->setActionComplete(action);
}
}

auto anchor = getAnchor(elem, "anchor");
movie->setAnchor(anchor);
Expand All @@ -47,11 +63,6 @@ namespace Parser

movie->Visible(getBool(elem, "visible", true));

if (elem.HasMember("onComplete"))
{
movie->setActionComplete(parseAction(game, elem["onComplete"]));
}

game.Resources().addDrawable(elem["id"].GetString(), movie);

try
Expand Down
12 changes: 8 additions & 4 deletions src/Parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ namespace Parser
if (lastIdx != std::string::npos)
{
filePath = filePath.substr(0, lastIdx);
}

if (Utils::endsWith(filePath, "\\") == false &&
Utils::endsWith(filePath, "/") == false)
if (Utils::endsWith(filePath, "\\") == false &&
Utils::endsWith(filePath, "/") == false)
{
filePath += PHYSFS_getDirSeparator();
}
}
else
{
filePath += PHYSFS_getDirSeparator();
filePath = std::string(".") + PHYSFS_getDirSeparator();
}

game.setPath(filePath);
Expand Down

0 comments on commit a35d5d7

Please sign in to comment.