From 0730bd5c4a93f9438a520b608bc587c9c7f5fa48 Mon Sep 17 00:00:00 2001 From: Kent Rasmussen Date: Thu, 4 Jan 2024 09:04:13 +0900 Subject: [PATCH] don't use keys with invalid instance names --- js/game.js | 5 +++++ node/server.js | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/js/game.js b/js/game.js index 2341574..6b0fe4d 100644 --- a/js/game.js +++ b/js/game.js @@ -1943,6 +1943,11 @@ function init_socket(args) ui_log("Can't reach","gray"); transporting=false; } + else if(response=="transport_cant_invalid") + { + ui_log("Instance not found","gray"); + transporting=false; + } else if(response=="transport_cant_item") { ui_log("Item not found","gray"); diff --git a/node/server.js b/node/server.js index a7bc97f..5d2354a 100644 --- a/node/server.js +++ b/node/server.js @@ -5048,8 +5048,15 @@ function init_io() { if (simple_distance(player, { in: f, map: f, x: ref[0], y: ref[1] }) > 120) { return fail_response("transport_cant_reach"); } - if (data.name && instances[data.name] && instances[data.name].map == data.place) { - transport_player_to(player, data.name); + if (data.name) { + // Player requested to enter an existing instance + if (instances[data.name] && instances[data.name].map == data.place) { + // The instance exists + transport_player_to(player, data.name); + } else { + // The instance doesn't exist + return fail_response("transport_cant_invalid"); + } } else { if (!consume_one_by_id(player, item)) { return fail_response("transport_cant_item");