From 3bd01e3ee79ab7ea2670bc781bf5d1d36cb9e79c Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 13 Jun 2021 14:25:19 +0200 Subject: [PATCH] Cleanup --- qcsrc/common/physics/player.qc | 28 ++++++++++++---------------- qcsrc/common/physics/player.qh | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 2fd3f9fb59..f4e2d912c7 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -527,22 +527,18 @@ bool PM_check_specialcommand(entity this, int buttons) { #ifdef SVQC string c; - if (!buttons) - c = "x"; - else if (buttons == 1) - c = "1"; - else if (buttons == 4) - c = " "; - else if (buttons == 128) - c = "s"; - else if (buttons == 256) - c = "w"; - else if (buttons == 512) - c = "a"; - else if (buttons == 1024) - c = "d"; - else - c = "?"; + switch (buttons) + { + // buttons mapped in PHYS_INPUT_BUTTON_MASK + case 0: c = "x"; break; + case BIT(0): c = "1"; break; + case BIT(2): c = " "; break; + case BIT(7): c = "s"; break; + case BIT(8): c = "w"; break; + case BIT(9): c = "a"; break; + case BIT(10): c = "d"; break; + default: c = "?"; + } if (c == substring(specialcommand, CS(this).specialcommand_pos, 1)) { diff --git a/qcsrc/common/physics/player.qh b/qcsrc/common/physics/player.qh index 9d92581f46..eb044fb24f 100644 --- a/qcsrc/common/physics/player.qh +++ b/qcsrc/common/physics/player.qh @@ -179,17 +179,17 @@ STATIC_INIT(PHYS_INPUT_BUTTON) // used for special commands and idle checking, not from the engine // TODO: cache #define PHYS_INPUT_BUTTON_MASK(s) ( \ - ((1 << 0) * PHYS_INPUT_BUTTON_ATCK(s)) \ - | ((1 << 1) * PHYS_INPUT_BUTTON_JUMP(s)) \ - | ((1 << 2) * PHYS_INPUT_BUTTON_ATCK2(s)) \ - | ((1 << 3) * PHYS_INPUT_BUTTON_ZOOM(s)) \ - | ((1 << 4) * PHYS_INPUT_BUTTON_CROUCH(s)) \ - | ((1 << 5) * PHYS_INPUT_BUTTON_HOOK(s)) \ - | ((1 << 6) * PHYS_INPUT_BUTTON_USE(s)) \ - | ((1 << 7) * PHYS_INPUT_BUTTON_BACKWARD(s)) \ - | ((1 << 8) * PHYS_INPUT_BUTTON_FORWARD(s)) \ - | ((1 << 9) * PHYS_INPUT_BUTTON_LEFT(s)) \ - | ((1 << 10) * PHYS_INPUT_BUTTON_RIGHT(s)) \ + (BIT(0) * PHYS_INPUT_BUTTON_ATCK(s)) \ + | (BIT(1) * PHYS_INPUT_BUTTON_JUMP(s)) \ + | (BIT(2) * PHYS_INPUT_BUTTON_ATCK2(s)) \ + | (BIT(3) * PHYS_INPUT_BUTTON_ZOOM(s)) \ + | (BIT(4) * PHYS_INPUT_BUTTON_CROUCH(s)) \ + | (BIT(5) * PHYS_INPUT_BUTTON_HOOK(s)) \ + | (BIT(6) * PHYS_INPUT_BUTTON_USE(s)) \ + | (BIT(7) * PHYS_INPUT_BUTTON_BACKWARD(s)) \ + | (BIT(8) * PHYS_INPUT_BUTTON_FORWARD(s)) \ + | (BIT(9) * PHYS_INPUT_BUTTON_LEFT(s)) \ + | (BIT(10) * PHYS_INPUT_BUTTON_RIGHT(s)) \ ) #define IS_JUMP_HELD(s) (!((s).flags & FL_JUMPRELEASED)) -- 2.39.2