Fix invalid maps

This commit is contained in:
_Bastler 2021-12-16 19:26:28 +01:00
parent 2132fc0323
commit ea49dafea4
2 changed files with 34 additions and 16 deletions

View File

@ -142,6 +142,9 @@ class LocalUserStore {
localStorage.getItem(lastRoomUrl) ?? window.location.protocol + "//" + window.location.host + START_ROOM_URL
);
}
removeLastRoomUrl(): void {
localStorage.removeItem(lastRoomUrl);
}
getLastRoomUrlCacheApi(): Promise<string | undefined> {
if (!("caches" in window)) {
return Promise.resolve(undefined);

View File

@ -429,7 +429,11 @@ export class GameScene extends DirtyScene {
//hook create scene
create(): void {
this.preloading = false;
try {
this.trackDirtyAnims();
} catch (e) {
console.error(e);
}
gameManager.gameSceneIsCreated(this);
urlManager.pushRoomIdToUrl(this.room);
@ -455,6 +459,17 @@ export class GameScene extends DirtyScene {
//initialise map
this.Map = this.add.tilemap(this.MapUrlFile);
const mapDirUrl = this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf("/"));
if (!this.mapFile && this.room.href == localUserStore.getLastRoomUrl()) {
localUserStore.removeLastRoomUrl();
this.scene.start(ErrorSceneName, {
title: "This map seems unaccessible.",
message:
"If you want more information, you may contact administrator or contact us at: partey@bstly.de",
});
return;
}
this.mapFile.tilesets.forEach((tileset: ITiledTileSet) => {
this.Terrains.push(
this.Map.addTilesetImage(