Skip to content

Commit 782db03

Browse files
authored
Multiplayer: fix accidental tagging (#4869)
1 parent 997e305 commit 782db03

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

src/packets_input.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,24 @@ TbBool is_mouse_on_map(struct Packet* pckt)
6464
return true;
6565
}
6666

67-
void remember_cursor_subtile(struct PlayerInfo *player) {
67+
void remember_cursor_subtile(struct PlayerInfo *player)
68+
{
6869
struct Packet* pckt = get_packet_direct(player->packet_num);
69-
if (player->interpolated_tagging == true) {
70-
player->previous_cursor_subtile_x = player->cursor_subtile_x;
71-
player->previous_cursor_subtile_y = player->cursor_subtile_y;
72-
player->cursor_subtile_x = coord_subtile((pckt->pos_x));
73-
player->cursor_subtile_y = coord_subtile((pckt->pos_y));
70+
MapSubtlCoord cursor_subtile_x = coord_subtile(pckt->pos_x);
71+
MapSubtlCoord cursor_subtile_y = coord_subtile(pckt->pos_y);
72+
player->previous_cursor_subtile_x = player->cursor_subtile_x;
73+
player->previous_cursor_subtile_y = player->cursor_subtile_y;
74+
if (!player->interpolated_tagging && ((pckt->control_flags & (PCtr_LBtnHeld | PCtr_LBtnRelease)) != 0)) {
75+
player->previous_cursor_subtile_x = cursor_subtile_x;
76+
player->previous_cursor_subtile_y = cursor_subtile_y;
77+
}
78+
player->cursor_subtile_x = cursor_subtile_x;
79+
player->cursor_subtile_y = cursor_subtile_y;
80+
if (player->mouse_on_map && ((pckt->control_flags & (PCtr_LBtnClick | PCtr_LBtnHeld)) != 0)) {
81+
player->interpolated_tagging = true;
7482
} else {
75-
player->cursor_subtile_x = coord_subtile((pckt->pos_x));
76-
player->cursor_subtile_y = coord_subtile((pckt->pos_y));
77-
player->previous_cursor_subtile_x = player->cursor_subtile_x;
78-
player->previous_cursor_subtile_y = player->cursor_subtile_y;
83+
player->interpolated_tagging = false;
7984
}
80-
player->interpolated_tagging = player->mouse_on_map;
8185
}
8286

8387
struct Thing *get_thing_under_hand(struct PlayerInfo *player, MapCoord x, MapCoord y)

0 commit comments

Comments
 (0)