From db90477caeb3fc8d084a0d3822383fe7d254c18a Mon Sep 17 00:00:00 2001 From: zsilencer Date: Sat, 23 Jan 2016 14:16:26 -0700 Subject: [PATCH] add locate player's most recent action button --- data/language/english_uk.txt | 3 ++- src/game.c | 5 +++++ src/localisation/string_ids.h | 1 + src/network/network.cpp | 23 +++++++++++++++++++++++ src/network/network.h | 3 +++ src/windows/player.c | 18 ++++++++++++++++-- 6 files changed, 50 insertions(+), 3 deletions(-) diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index f2aae800b0..de0a106d89 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -3894,7 +3894,7 @@ STR_5552 :{POP16}{POP16}Year {COMMA16}, {PUSH16}{PUSH16}{PUSH16}{STRINGID} {M STR_5553 :Pause game when Steam overlay is open STR_5554 :{SMALLFONT}{BLACK}Enable mountain tool STR_5555 :Show vehicles from other track types -STR_5556 :{SMALLFONT}{BLACK}Kick Player +STR_5556 :{SMALLFONT}{BLACK}Kick player STR_5557 :Stay connected after desynchronisation (Multiplayer) STR_5558 :A restart is required for this setting to take effect STR_5559 :10 min. inspections @@ -4002,6 +4002,7 @@ STR_5660 :Modify Groups STR_5661 :Set Player Group STR_5662 :N/A STR_5663 :Clear Landscape +STR_5702 :{SMALLFONT}{BLACK}Locate player's most recent action STR_5703 :Can't kick the host STR_5704 :Last Action: STR_5705 :Can't set to this group diff --git a/src/game.c b/src/game.c index 69a562d1b0..c77e65faab 100644 --- a/src/game.c +++ b/src/game.c @@ -544,6 +544,11 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int * if (network_get_mode() == NETWORK_MODE_SERVER && !(flags & GAME_COMMAND_FLAG_NETWORKED) && !(flags & GAME_COMMAND_FLAG_GHOST)) { network_set_player_last_action(network_get_player_index(network_get_current_player_id()), command); + rct_xyz16 coord; + coord.x = RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16); + coord.y = RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16); + coord.z = RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16); + network_set_player_last_action_coord(network_get_player_index(network_get_current_player_id()), coord); network_add_player_money_spent(network_get_current_player_id(), cost); } diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index 722d48e4ab..b9141c326e 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -2291,6 +2291,7 @@ enum { STR_ACTION_NA = 5662, STR_ACTION_CLEAR_LANDSCAPE = 5663, + STR_LOCATE_PLAYER_TIP = 5702, STR_CANT_KICK_THE_HOST = 5703, STR_LAST_ACTION = 5704, STR_CANT_SET_TO_THIS_GROUP = 5705, diff --git a/src/network/network.cpp b/src/network/network.cpp index 306fa36788..daca9647e5 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -191,6 +191,7 @@ NetworkPlayer::NetworkPlayer() commands_ran = 0; group = 0; last_action = -999; + last_action_coord = {0}; } void NetworkPlayer::Read(NetworkPacket& packet) @@ -1439,6 +1440,11 @@ void Network::ProcessGameCommandQueue() if (player) { player->last_action = gNetworkActions.FindCommand(command); player->last_action_time = SDL_GetTicks(); + rct_xyz16 coord; + coord.x = RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16); + coord.y = RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16); + coord.z = RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16); + player->last_action_coord = coord; player->AddMoneySpent(cost); } } @@ -1718,6 +1724,11 @@ void Network::Server_Handle_GAMECMD(NetworkConnection& connection, NetworkPacket connection.player->last_action = gNetworkActions.FindCommand(commandCommand); connection.player->last_action_time = SDL_GetTicks(); + rct_xyz16 coord; + coord.x = RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16); + coord.y = RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16); + coord.z = RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16); + connection.player->last_action_coord = coord; connection.player->AddMoneySpent(cost); Server_Send_GAMECMD(args[0], args[1], args[2], args[3], args[4], args[5], args[6], playerid, callback); } @@ -1934,6 +1945,16 @@ void network_set_player_last_action(unsigned int index, int command) gNetwork.player_list[index]->last_action_time = SDL_GetTicks(); } +rct_xyz16 network_get_player_last_action_coord(unsigned int index) +{ + return gNetwork.player_list[index]->last_action_coord; +} + +void network_set_player_last_action_coord(unsigned int index, rct_xyz16 coord) +{ + gNetwork.player_list[index]->last_action_coord = coord; +} + unsigned int network_get_player_commands_ran(unsigned int index) { return gNetwork.player_list[index]->commands_ran; @@ -2235,6 +2256,8 @@ money32 network_get_player_money_spent(unsigned int index) { return MONEY(0, 0); void network_add_player_money_spent(unsigned int index, money32 cost) { } int network_get_player_last_action(unsigned int index) { return -999; } void network_set_player_last_action(unsigned int index, int command) { } +rct_xyz16 network_get_player_last_action_coord(unsigned int index) { return rct_xyz16(0, 0, 0); } +void network_set_player_last_action_coord(unsigned int index, rct_xyz16 coord) { } unsigned int network_get_player_commands_ran(unsigned int index) { return 0; } int network_get_player_index(uint8 id) { return -1; } uint8 network_get_player_group(unsigned int index) { return 0; } diff --git a/src/network/network.h b/src/network/network.h index 55f2188325..76aacc6600 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -161,6 +161,7 @@ public: unsigned int commands_ran; int last_action; uint32 last_action_time; + rct_xyz16 last_action_coord; }; class NetworkAction @@ -424,6 +425,8 @@ money32 network_get_player_money_spent(unsigned int index); void network_add_player_money_spent(unsigned int index, money32 cost); int network_get_player_last_action(unsigned int index); void network_set_player_last_action(unsigned int index, int command); +rct_xyz16 network_get_player_last_action_coord(unsigned int index); +void network_set_player_last_action_coord(unsigned int index, rct_xyz16 coord); unsigned int network_get_player_commands_ran(unsigned int index); int network_get_player_index(uint8 id); uint8 network_get_player_group(unsigned int index); diff --git a/src/windows/player.c b/src/windows/player.c index c96d6b18f5..5d60ad2f70 100644 --- a/src/windows/player.c +++ b/src/windows/player.c @@ -54,6 +54,7 @@ enum WINDOW_PLAYER_WIDGET_IDX { WIDX_TAB_1, WIDX_GROUP, WIDX_GROUP_DROPDOWN, + WIDX_LOCATE, WIDX_KICK }; @@ -65,7 +66,8 @@ rct_widget window_player_overview_widgets[] = { { WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, STR_NONE }, // Tab 1 { WWT_DROPDOWN, 1, 3, 177, 46, 57, 0x0FFFFFFFF, STR_NONE }, // Permission group { WWT_DROPDOWN_BUTTON, 1, 167, 177, 47, 56, 876, STR_NONE }, // - { WWT_FLATBTN, 1, 179, 190, 45, 68, SPR_DEMOLISH, STR_KICK_PLAYER_TIP }, // Kick button + { WWT_FLATBTN, 1, 179, 190, 45, 68, SPR_LOCATE, STR_LOCATE_PLAYER_TIP },// Locate button + { WWT_FLATBTN, 1, 179, 190, 69, 92, SPR_DEMOLISH, STR_KICK_PLAYER_TIP }, // Kick button { WIDGETS_END }, }; @@ -124,6 +126,7 @@ uint32 window_player_page_enabled_widgets[] = { (1 << WIDX_TAB_1) | (1 << WIDX_GROUP) | (1 << WIDX_GROUP_DROPDOWN) | + (1 << WIDX_LOCATE) | (1 << WIDX_KICK) }; @@ -214,6 +217,15 @@ void window_player_overview_mouse_up(rct_window *w, int widgetIndex) case WIDX_TAB_1: window_player_set_page(w, widgetIndex - WIDX_TAB_1); break; + case WIDX_LOCATE:{ + rct_window* mainWindow = window_get_main(); + if (mainWindow != NULL) { + rct_xyz16 coord = network_get_player_last_action_coord(w->number); + if (coord.x && coord.y && coord.z) { + window_scroll_to_location(mainWindow, coord.x, coord.y, coord.z); + } + } + }break; case WIDX_KICK: game_do_command(w->number, GAME_COMMAND_FLAG_APPLY, 0, 0, GAME_COMMAND_KICK_PLAYER, 0, 0); break; @@ -371,8 +383,10 @@ void window_player_overview_invalidate(rct_window *w) window_player_overview_widgets[WIDX_CLOSE].left = w->width - 13; window_player_overview_widgets[WIDX_CLOSE].right = w->width - 3; - window_player_overview_widgets[WIDX_KICK].right = w->width - 2; + window_player_overview_widgets[WIDX_LOCATE].right = w->width - 2; + window_player_overview_widgets[WIDX_LOCATE].left = w->width - 25; + window_player_overview_widgets[WIDX_KICK].right = w->width - 2; window_player_overview_widgets[WIDX_KICK].left = w->width - 25; window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_1);