X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fgame.h;h=61f780bee91115667f10d9ef1b5f2742086c915f;hb=63867b1a372a4d1a4a4ffdec9d0862b094211a89;hp=1c831c530067527c3bda16135109ec2728eae465;hpb=4e1f50035e860a00636ca5d804c267119df99601;p=minetest.git diff --git a/src/game.h b/src/game.h index 1c831c530..61f780bee 100644 --- a/src/game.h +++ b/src/game.h @@ -35,11 +35,14 @@ class KeyList : protected std::list { const_iterator f(begin()); const_iterator e(end()); - while (f!=e) { + + while (f != e) { if (*f == key) return f; + ++f; } + return e; } @@ -47,16 +50,22 @@ class KeyList : protected std::list { iterator f(begin()); iterator e(end()); - while (f!=e) { + + while (f != e) { if (*f == key) return f; + ++f; } + return e; } public: - void clear() { super::clear(); } + void clear() + { + super::clear(); + } void set(const KeyPress &key) { @@ -67,6 +76,7 @@ class KeyList : protected std::list void unset(const KeyPress &key) { iterator p(find(key)); + if (p != end()) erase(p); } @@ -74,6 +84,7 @@ class KeyList : protected std::list void toggle(const KeyPress &key) { iterator p(this->find(key)); + if (p != end()) erase(p); else @@ -98,7 +109,7 @@ class InputHandler virtual bool isKeyDown(const KeyPress &keyCode) = 0; virtual bool wasKeyDown(const KeyPress &keyCode) = 0; - + virtual v2s32 getMousePos() = 0; virtual void setMousePos(s32 x, s32 y) = 0; @@ -114,33 +125,30 @@ class InputHandler virtual bool getRightReleased() = 0; virtual void resetLeftReleased() = 0; virtual void resetRightReleased() = 0; - + virtual s32 getMouseWheel() = 0; - virtual void step(float dtime) {}; + virtual void step(float dtime) {} - virtual void clear() {}; + virtual void clear() {} }; class ChatBackend; /* to avoid having to include chat.h */ struct SubgameSpec; -void the_game( - bool &kill, - bool random_input, - InputHandler *input, - IrrlichtDevice *device, - gui::IGUIFont* font, - std::string map_dir, - std::string playername, - std::string password, - std::string address, // If "", local server is used - u16 port, - std::wstring &error_message, - ChatBackend &chat_backend, - const SubgameSpec &gamespec, // Used for local game - bool simple_singleplayer_mode -); +void the_game(bool *kill, + bool random_input, + InputHandler *input, + IrrlichtDevice *device, + const std::string &map_dir, + const std::string &playername, + const std::string &password, + const std::string &address, // If "", local server is used + u16 port, + std::wstring &error_message, + ChatBackend &chat_backend, + const SubgameSpec &gamespec, // Used for local game + bool simple_singleplayer_mode); #endif