From 78b79aef3612ce22b76c2aa0e52c97c02f4ab27a Mon Sep 17 00:00:00 2001 From: Jared-Fogle <35135081+Jared-Fogle@users.noreply.github.com> Date: Tue, 22 Sep 2020 23:42:41 -0700 Subject: [PATCH] Block movement now locks turning, migrate old save files to Ctrl (#53871) The block movement key now correctly locks turning like it used to. Old save files are now migrated to Ctrl if they didn't bind it to anything before. This correctly replicates the old behavior. --- code/modules/client/preferences_savefile.dm | 16 +++++++++++- code/modules/keybindings/bindings_atom.dm | 29 ++++++++++++--------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 8afe339e0e5..84ea86d3752 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -5,7 +5,7 @@ // You do not need to raise this if you are adding new values that have sane defaults. // Only raise this value when changing the meaning/format/name/layout of an existing value // where you would want the updater procs below to run -#define SAVEFILE_VERSION_MAX 37 +#define SAVEFILE_VERSION_MAX 38 /* SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn @@ -73,6 +73,20 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car if(clientfps == 0) clientfps = -1 + if (current_version < 38) + var/found_block_movement = FALSE + + for (var/list/key in key_bindings) + for (var/bind in key) + if (bind == "block_movement") + found_block_movement = TRUE + break + if (found_block_movement) + break + + if (!found_block_movement) + LAZYADD(key_bindings["Ctrl"], "block_movement") + /datum/preferences/proc/update_character(current_version, savefile/S) return diff --git a/code/modules/keybindings/bindings_atom.dm b/code/modules/keybindings/bindings_atom.dm index 789c852bcfd..f145786287e 100644 --- a/code/modules/keybindings/bindings_atom.dm +++ b/code/modules/keybindings/bindings_atom.dm @@ -2,17 +2,20 @@ // Only way to do that is to tie the behavior into the focus's keyLoop(). /atom/movable/keyLoop(client/user) - if(!user.movement_locked) - var/movement_dir = NONE - for(var/_key in user.keys_held) - movement_dir = movement_dir | user.movement_keys[_key] - if(user.next_move_dir_add) - movement_dir |= user.next_move_dir_add - if(user.next_move_dir_sub) - movement_dir &= ~user.next_move_dir_sub - // Sanity checks in case you hold left and right and up to make sure you only go up - if((movement_dir & NORTH) && (movement_dir & SOUTH)) - movement_dir &= ~(NORTH|SOUTH) - if((movement_dir & EAST) && (movement_dir & WEST)) - movement_dir &= ~(EAST|WEST) + var/movement_dir = NONE + for(var/_key in user.keys_held) + movement_dir = movement_dir | user.movement_keys[_key] + if(user.next_move_dir_add) + movement_dir |= user.next_move_dir_add + if(user.next_move_dir_sub) + movement_dir &= ~user.next_move_dir_sub + // Sanity checks in case you hold left and right and up to make sure you only go up + if((movement_dir & NORTH) && (movement_dir & SOUTH)) + movement_dir &= ~(NORTH|SOUTH) + if((movement_dir & EAST) && (movement_dir & WEST)) + movement_dir &= ~(EAST|WEST) + + if(user.movement_locked) + setDir(movement_dir) + else user.Move(get_step(src, movement_dir), movement_dir)