From 21f4446db319df954bdc2628e86b930c3928df1c Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Tue, 27 Oct 2020 19:30:39 +1100 Subject: [PATCH] Fixed bug with sending maps when the map owner has left the party --- src/network/NetworkedMapAndTokens.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/network/NetworkedMapAndTokens.js b/src/network/NetworkedMapAndTokens.js index 89791b6..f3c064e 100644 --- a/src/network/NetworkedMapAndTokens.js +++ b/src/network/NetworkedMapAndTokens.js @@ -276,7 +276,17 @@ function NetworkedMapAndTokens({ session }) { } } - function replyWithFile(file) { + function replyWithFile(resolution) { + let file; + // If the resolution exists send that + if (map.resolutions[resolution]) { + file = map.resolutions[resolution].file; + } else if (map.file) { + // The resolution might not exist for other users so send the file instead + file = map.file; + } else { + return; + } reply( "mapResponse", { @@ -291,19 +301,19 @@ function NetworkedMapAndTokens({ session }) { switch (map.quality) { case "low": - replyWithFile(map.resolutions.low.file); + replyWithFile("low"); break; case "medium": replyWithPreview("low"); - replyWithFile(map.resolutions.medium.file); + replyWithFile("medium"); break; case "high": replyWithPreview("medium"); - replyWithFile(map.resolutions.high.file); + replyWithFile("high"); break; case "ultra": replyWithPreview("medium"); - replyWithFile(map.resolutions.ultra.file); + replyWithFile("ultra"); break; case "original": if (map.resolutions.medium) { @@ -311,10 +321,10 @@ function NetworkedMapAndTokens({ session }) { } else if (map.resolutions.low) { replyWithPreview("low"); } - replyWithFile(map.file); + replyWithFile(); break; default: - replyWithFile(map.file); + replyWithFile(); } } if (id === "mapResponse") {