From 67517585e9b55967f5236ed5ebca77173eb2f2e3 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 22 Jul 2008 22:48:21 +0000 Subject: reset keyboard state on r_restart --- src/client/input.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/client/input.cc') diff --git a/src/client/input.cc b/src/client/input.cc index 819ce27..6306fc8 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -453,6 +453,36 @@ void key_released(Key *key) } +void reset() +{ + local_direction = 0.0f; + local_pitch = 0.0f; + local_roll = 0.0f; + if (core::localcontrol()) { + local_thrust = core::localcontrol()->thrust(); + last_control = core::localcontrol()->id(); + } else { + local_thrust = 0; + last_control = 0; + } + mouse_pitch = 0.0f; + mouse_direction = 0.0f; + mouse_x = video::width / 2; + mouse_y = video::height / 2; + render::Camera::reset(); + mouse_control_override = false; + targets::reset(); + render::reset(); + + for (Keyboard::iterator it = keyboard->begin(); it != keyboard->end(); it++) { + Key *key = (*it).second; + if (key) { + key->pressed() = 0; + key->lastpressed() = 0; + } + } +} + void frame(float seconds) { /* -- detect localcontrol() changes --------------- */ -- cgit v1.2.3