From caf490617610facdf2fe551eeaa641ab41d95ffc Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Thu, 3 Dec 2020 22:21:44 -0700 Subject: [PATCH] Fix a crash when trying to drop from an empty inventory --- js/game.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/game.js b/js/game.js index cd86460..4db9e3d 100644 --- a/js/game.js +++ b/js/game.js @@ -1209,7 +1209,7 @@ export class Level { return; // Cycle leftwards, i.e., the oldest item moves to the end of the list - if (actor.toolbelt) { + if (actor.toolbelt && actor.toolbelt.length > 1) { actor.toolbelt.push(actor.toolbelt.shift()); this.pending_undo.push(() => actor.toolbelt.unshift(actor.toolbelt.pop())); } @@ -1222,7 +1222,7 @@ export class Level { return; // Drop the oldest item, i.e. the first one - if (actor.toolbelt && (force || ! actor.cell.get_item())) { + if (actor.toolbelt && actor.toolbelt.length > 0 && (force || ! actor.cell.get_item())) { let name = actor.toolbelt[0]; if (name === 'teleport_yellow') { // We can only be dropped on regular floor