summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-04-03 20:26:26 +0200
committersapier <Sapier at GMX dot net>2014-04-03 20:26:26 +0200
commit28854495b172cdea6c835bb6482200c4e277b040 (patch)
treed4e99bfde9bfe3772f76cc619cb4f5ce4ce158c3 /src
parentaf01a9577e488d17e4f2f9145db723f3902446c9 (diff)
downloadminetest-28854495b172cdea6c835bb6482200c4e277b040.tar.gz
minetest-28854495b172cdea6c835bb6482200c4e277b040.tar.bz2
minetest-28854495b172cdea6c835bb6482200c4e277b040.zip
Performance optimized button to button mask evaluation
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/game.cpp b/src/game.cpp
index a13f1393c..699314d30 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2307,18 +2307,17 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
camera_yaw
);
client.setPlayerControl(control);
- u32 keyPressed=
- 1*(int)input->isKeyDown(getKeySetting("keymap_forward"))+
- 2*(int)input->isKeyDown(getKeySetting("keymap_backward"))+
- 4*(int)input->isKeyDown(getKeySetting("keymap_left"))+
- 8*(int)input->isKeyDown(getKeySetting("keymap_right"))+
- 16*(int)input->isKeyDown(getKeySetting("keymap_jump"))+
- 32*(int)input->isKeyDown(getKeySetting("keymap_special1"))+
- 64*(int)input->isKeyDown(getKeySetting("keymap_sneak"))+
- 128*(int)input->getLeftState()+
- 256*(int)input->getRightState();
LocalPlayer* player = client.getEnv().getLocalPlayer();
- player->keyPressed=keyPressed;
+ player->keyPressed=
+ (((int)input->isKeyDown(getKeySetting("keymap_forward")) & 0x1) << 0) |
+ (((int)input->isKeyDown(getKeySetting("keymap_backward")) & 0x1) << 1) |
+ (((int)input->isKeyDown(getKeySetting("keymap_left")) & 0x1) << 2) |
+ (((int)input->isKeyDown(getKeySetting("keymap_right")) & 0x1) << 3) |
+ (((int)input->isKeyDown(getKeySetting("keymap_jump")) & 0x1) << 4) |
+ (((int)input->isKeyDown(getKeySetting("keymap_special1")) & 0x1) << 5) |
+ (((int)input->isKeyDown(getKeySetting("keymap_sneak")) & 0x1) << 6) |
+ (((int)input->getLeftState() & 0x1) << 7) |
+ (((int)input->getRightState() & 0x1) << 8);
}
/*