diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-14 16:30:44 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-14 16:30:44 +0000 |
commit | 8381ec4111505692a9058db37412adb872bedd3e (patch) | |
tree | afabb776a5f3b6696e021266c8fa1023c1b71fcb /src | |
parent | e7d91341bc0ee21f4b31fefb77c34b14c13c618d (diff) | |
download | mana-8381ec4111505692a9058db37412adb872bedd3e.tar.gz mana-8381ec4111505692a9058db37412adb872bedd3e.tar.bz2 mana-8381ec4111505692a9058db37412adb872bedd3e.tar.xz mana-8381ec4111505692a9058db37412adb872bedd3e.zip |
Hide mouse when the application doesn't have mouse focus.
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 6 | ||||
-rw-r--r-- | src/game.cpp | 32 | ||||
-rw-r--r-- | src/game.h | 1 | ||||
-rw-r--r-- | src/graphics.cpp | 10 | ||||
-rw-r--r-- | src/net/protocol.h | 21 |
5 files changed, 27 insertions, 43 deletions
diff --git a/src/being.cpp b/src/being.cpp index 204065a5..c63c2bb2 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -279,14 +279,8 @@ void Being::nextStep() y = newY; action = WALK; walk_time += speed / 10; - if (this == player_node) { - walk_status = 1; - } } else { action = STAND; - if (this == player_node) { - walk_status = 0; - } } frame = 0; } diff --git a/src/game.cpp b/src/game.cpp index 1ec08e0c..7481ea9a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -68,16 +68,6 @@ class DeatchNoticeListener : public gcn::ActionListener { } } deathNoticeListener; -/** - * Finite states machine to keep track of player walking status (2 steps - * linear prediction) - * - * 0 = Standing - * 1 = Walking without confirm packet - * 2 = Walking with confirm - */ -char walk_status = 0; - Uint32 refresh_time(Uint32 interval, void *param) { @@ -280,7 +270,7 @@ void do_input() equipmentWindow->setVisible(!equipmentWindow->isVisible()); used = true; } - else if (keysym.sym == SDLK_b) { + else if (keysym.sym == SDLK_b) { buddyWindow->setVisible(!buddyWindow->isVisible()); used = true; } @@ -332,7 +322,7 @@ void do_input() case SE: id = find_floor_item_by_cor(player_node->x+1, player_node->y+1); break; - default: + default: break; } WFIFOW(0) = net_w_value(0x009f); @@ -637,15 +627,13 @@ void do_parse() } break; - // Success to walk request - case 0x0087: - if (walk_status == 1) { - if ((unsigned int)(RFIFOL(2)) > (unsigned int)(server_tick)) { - walk_status = 2; - server_tick = RFIFOL(2); - } - } + case SMSG_WALK_RESPONSE: + // It is assumed by the client any request to walk actually + // succeeds on the server. The plan is to have a correction + // message when the server senses the client has the wrong + // idea. break; + // Add new being / stop monster case 0x0078: being = findNode(RFIFOL(2)); @@ -819,7 +807,7 @@ void do_parse() // TODO: // Maybe also handle identified, etc // handle zeny as well - + tradeWindow->addItem( tradeWindow->partnerItems->getFreeSlot(), RFIFOW(6), false, RFIFOL(2), false); @@ -977,7 +965,6 @@ void do_parse() player_node->x = RFIFOW(18); player_node->y = RFIFOW(20); current_npc = 0; - walk_status = 0; // Send "map loaded" WFIFOW(0) = net_w_value(0x007d); WFIFOSET(2); @@ -1108,7 +1095,6 @@ void do_parse() being->frame = 0; if (RFIFOB(26) == 2) { being->action = SIT; - walk_status = 0; } else if (RFIFOB(26) == 3) { being->action = STAND; @@ -58,7 +58,6 @@ extern char map_path[480]; extern int fps, frame, current_npc; -extern char walk_status; extern volatile int tick_time; extern int server_tick; extern bool displayPathToMouse; diff --git a/src/graphics.cpp b/src/graphics.cpp index 5ff02aa8..7da5520c 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -130,10 +130,14 @@ void Graphics::drawImageRect( void Graphics::updateScreen() { - // Draw mouse before flipping int mouseX, mouseY; - SDL_GetMouseState(&mouseX, &mouseY); - mouseCursor->draw(screen, mouseX - 5, mouseY - 2); + Uint8 button = SDL_GetMouseState(&mouseX, &mouseY); + + if (SDL_GetAppState() & SDL_APPMOUSEFOCUS || button & SDL_BUTTON(1)) + { + // Draw mouse before flipping + mouseCursor->draw(screen, mouseX - 5, mouseY - 2); + } if (useOpenGL) { glFlush(); diff --git a/src/net/protocol.h b/src/net/protocol.h index 9a755e63..14c21d59 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -25,16 +25,17 @@ #define _TMW_PROTOCOL_H // Packets from server to client -#define SMSG_LOGIN_SUCCESS 0x0073 // Logged in, starting location -#define SMSG_REMOVE_BEING 0x0080 // Died, logged out, teleport, etc. -#define SMSG_MOVE_BEING 0x007b // A nearby monster moves -#define SMSG_PLAYER_UPDATE_1 0x01d8 // -#define SMSG_PLAYER_UPDATE_2 0x01d9 // -#define SMSG_MOVE_PLAYER_BEING 0x01da // A nearby player moves -#define SMSG_CHANGE_BEING_LOOKS 0x00c3 // -#define SMSG_BEING_CHAT 0x008d // A being talks -#define SMSG_MY_BEING_CHAT 0x008e // My being talks -#define SMSG_GM_CHAT 0x009a // GM announce +#define SMSG_LOGIN_SUCCESS 0x0073 /**< Logged in, starting location */ +#define SMSG_REMOVE_BEING 0x0080 /**< Died, logged out, teleport ... */ +#define SMSG_MOVE_BEING 0x007b /**< A nearby monster moves */ +#define SMSG_PLAYER_UPDATE_1 0x01d8 +#define SMSG_PLAYER_UPDATE_2 0x01d9 +#define SMSG_MOVE_PLAYER_BEING 0x01da /**< A nearby player moves */ +#define SMSG_CHANGE_BEING_LOOKS 0x00c3 +#define SMSG_BEING_CHAT 0x008d /**< A being talks */ +#define SMSG_MY_BEING_CHAT 0x008e /**< My being talks */ +#define SMSG_GM_CHAT 0x009a /**< GM announce */ +#define SMSG_WALK_RESPONSE 0x0087 /** Packet length by id */ |