diff options
author | Leon Krause <lk@leonkrause.com> | 2018-03-27 11:25:03 +0200 |
---|---|---|
committer | Leon Krause <lk@leonkrause.com> | 2018-03-27 11:26:34 +0200 |
commit | 3014e48ec5a985b9d143ba27b91e32b933dcfdad (patch) | |
tree | 7dee99e5b9146f754c3d4358600c94d7db427a50 /platform/javascript | |
parent | d373029382208226a55ddfc028a3261e0dc8279b (diff) |
Fix engine.js startGame() when loading from directory
Diffstat (limited to 'platform/javascript')
-rw-r--r-- | platform/javascript/engine.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js index be8d04dd5e..e4839af433 100644 --- a/platform/javascript/engine.js +++ b/platform/javascript/engine.js @@ -14,6 +14,13 @@ var loadingFiles = {}; + function getPathLeaf(path) { + + while (path.endsWith('/')) + path = path.slice(0, -1); + return path.slice(path.lastIndexOf('/') + 1); + } + function getBasePath(path) { if (path.endsWith('/')) @@ -25,8 +32,7 @@ function getBaseName(path) { - path = getBasePath(path); - return path.slice(path.lastIndexOf('/') + 1); + return getPathLeaf(getBasePath(path)); } Engine = function Engine() { @@ -123,7 +129,12 @@ this.startGame = function(mainPack) { executableName = getBaseName(mainPack); - return Promise.all([this.init(getBasePath(mainPack)), this.preloadFile(mainPack)]).then( + return Promise.all([ + // Load from directory, + this.init(getBasePath(mainPack)), + // ...but write to root where the engine expects it. + this.preloadFile(mainPack, getPathLeaf(mainPack)) + ]).then( Function.prototype.apply.bind(synchronousStart, this, []) ); }; |