summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadeline <60828599+munvoseli@users.noreply.github.com>2020-12-23 15:49:35 -0500
committerGitHub <noreply@github.com>2020-12-23 15:49:35 -0500
commit690eb9b3afd93726ce33977f31355587d2563ffc (patch)
treeb5a1d0ff94b805dfe22c2243d102c78e4a0abe8b
parent36def2877de38ad112f3ba2093c1e3ca5d378167 (diff)
Fix potential exploits
Fractional directions crashed my home (modified) server. These changes worked on my home server to prevent crashing.
-rw-r--r--utils/game.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/utils/game.js b/utils/game.js
index 0f27dcf..0d3dccc 100644
--- a/utils/game.js
+++ b/utils/game.js
@@ -357,6 +357,10 @@ function addSetGuidelinePosCommand(player, commandList) {
});
}
+function isDirection(direction) {
+ return (direction === 0 || direction === 1 || direction === 2 || direction === 3);
+}
+
function performStartPlayingCommand(command, player, commandList, done, errorHandler) {
accountUtils.acquireLock(function() {
accountUtils.findAccountByUsername(player.username, function(error, index, result) {
@@ -386,7 +390,8 @@ function performGetTilesCommand(command, player, commandList) {
}
function performWalkCommand(command, player, commandList) {
- player.walk(command.direction);
+ if (isDirection(command.direction))
+ player.walk(command.direction);
}
function performAssertPosCommand(command, player, commandList) {
@@ -455,7 +460,8 @@ function performGetOnlinePlayersCommand(command, player, commandList) {
}
function performRemoveTileCommand(command, player, commandList) {
- player.removeTile(command.direction);
+ if (isDirection(command.direction))
+ player.removeTile(command.direction);
}
function performGetInventoryChangesCommand(command, player, commandList) {
@@ -466,6 +472,8 @@ function performGetInventoryChangesCommand(command, player, commandList) {
}
function performPlaceTileCommand(command, player, commandList) {
+ if (!isDirection(command.direction))
+ return;
var tempResult = player.placeTile(command.direction, command.tile);
if (!tempResult) {
addSetInventoryCommand(player.inventory, commandList);
@@ -473,7 +481,8 @@ function performPlaceTileCommand(command, player, commandList) {
}
function performCollectTileCommand(command, player, commandList) {
- player.collectTile(command.direction);
+ if (isDirection(command.direction))
+ player.collectTile(command.direction);
}
function performGetRespawnPosChangesCommand(command, player, commandList) {