Merge pull request #13881 from VOREStation/upstream-merge-8199

[MIRROR] Ports Diagonal Movement [READY FOR MERGE]
This commit is contained in:
Casey
2022-10-09 23:07:54 -04:00
committed by CHOMPStation2
parent 0972599a01
commit 24a6d07198
9 changed files with 54 additions and 32 deletions

View File

@@ -22,7 +22,7 @@ var/global/list/MOVE_KEY_MAPPINGS = list(
// Map text sent by skin.dmf to our numeric codes. (This can be optimized away once we update skin.dmf)
var/movekey = MOVE_KEY_MAPPINGS[movekeyName]
// Validate input. Must be one (and only one) of the key codes)
if(isnull(movekey) || (movekey & ~0xFFF) || (movekey & (movekey - 1)))
log_debug("Client [ckey] sent an illegal movement key down: [movekeyName] ([movekey])")
@@ -54,12 +54,12 @@ var/global/list/MOVE_KEY_MAPPINGS = list(
// Map text sent by skin.dmf to our numeric codes. (This can be optimized away once we update skin.dmf)
var/movekey = MOVE_KEY_MAPPINGS[movekeyName]
// Validate input. Must be one (and only one) of the key codes)
if(isnull(movekey) || (movekey & ~0xFFF) || (movekey & (movekey - 1)))
log_debug("Client [ckey] sent an illegal movement key up: [movekeyName] ([movekey])")
return
// Clear bit indicating we were holding the key
move_keys_held &= ~movekey
mod_keys_held &= ~movekey

View File

@@ -1,15 +1,19 @@
// Set a client's focus to an object and override these procs on that object to let it handle keypresses
/datum/proc/key_down(key, client/user) // Called when a key is pressed down initially
/// Called when a key is pressed down initially
/datum/proc/key_down(key, client/user)
return
/datum/proc/key_up(key, client/user) // Called when a key is released
/// Called when a key is released
/datum/proc/key_up(key, client/user)
return
/datum/proc/keyLoop(client/user) // Called once every server tick
/// Called once every server tick
/datum/proc/keyLoop(client/user)
set waitfor = FALSE
return
/// Set mob's focus
/// TODO - Do we even need this concept?
/// Set mob's focus. TODO: Decide if required.
/mob/proc/set_focus(datum/new_focus)
if(focus == new_focus)
return
@@ -20,15 +24,26 @@
if(!keys)
return ""
var/list/out = list()
if(keys & NORTH_KEY) out += "NORTH"
if(keys & SOUTH_KEY) out += "SOUTH"
if(keys & EAST_KEY) out += "EAST"
if(keys & WEST_KEY) out += "WEST"
if(keys & W_KEY) out += "W"
if(keys & A_KEY) out += "A"
if(keys & S_KEY) out += "S"
if(keys & D_KEY) out += "D"
if(keys & CTRL_KEY) out += "CTRL"
if(keys & SHIFT_KEY) out += "SHIFT"
if(keys & ALT_KEY) out += "ALT"
if(keys & NORTH_KEY)
out += "NORTH"
if(keys & SOUTH_KEY)
out += "SOUTH"
if(keys & EAST_KEY)
out += "EAST"
if(keys & WEST_KEY)
out += "WEST"
if(keys & W_KEY)
out += "W"
if(keys & A_KEY)
out += "A"
if(keys & S_KEY)
out += "S"
if(keys & D_KEY)
out += "D"
if(keys & CTRL_KEY)
out += "CTRL"
if(keys & SHIFT_KEY)
out += "SHIFT"
if(keys & ALT_KEY)
out += "ALT"
return out.Join(" ")