Skip to content

Commit 35c4d84

Browse files
authored
Fix tagging around map edge (dkfans#3050)
Fixes dkfans#3046
1 parent aa37752 commit 35c4d84

File tree

4 files changed

+23
-32
lines changed

4 files changed

+23
-32
lines changed

src/engine_render.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8446,8 +8446,6 @@ static void draw_keepsprite_unscaled_in_buffer(unsigned short kspr_n, short angl
84468446

84478447
static void update_frontview_pointed_block(unsigned long laaa, unsigned char qdrant, long w, long h, long qx, long qy)
84488448
{
8449-
TbBool out_of_bounds = false;
8450-
84518449
TbGraphicsWindow ewnd;
84528450
struct Column *colmn;
84538451
unsigned long mask;
@@ -8472,10 +8470,6 @@ static void update_frontview_pointed_block(unsigned long laaa, unsigned char qdr
84728470
stl_x = (pos_x >> 8) + x_offs[qdrant];
84738471
stl_y = (pos_y >> 8) + y_offs[qdrant];
84748472

8475-
if (stl_x < 0 || stl_x > gameadd.map_subtiles_x - 1 || stl_y < -2 || stl_y > gameadd.map_subtiles_y) {
8476-
out_of_bounds = true;
8477-
}
8478-
84798473
mapblk = get_map_block_at(stl_x, stl_y);
84808474
if (!map_block_invalid(mapblk))
84818475
{
@@ -8514,7 +8508,6 @@ static void update_frontview_pointed_block(unsigned long laaa, unsigned char qdr
85148508
}
85158509

85168510
struct PlayerInfo *player = get_my_player();
8517-
player->mouse_is_offmap = out_of_bounds;
85188511
}
85198512

85208513
void create_frontview_map_volume_box(struct Camera *cam, unsigned char stl_width, TbBool single_subtile, long line_color)

src/main.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,7 +2212,7 @@ void interp_fix_mouse_light_off_map(struct PlayerInfo *player)
22122212
// This fixes the interpolation issue of moving the mouse off map in one position then back onto the map far elsewhere.
22132213
struct Light* light = &game.lish.lights[player->cursor_light_idx];
22142214

2215-
if (player->mouse_is_offmap == true) {
2215+
if (player->mouse_on_map == false) {
22162216
light->disable_interp_for_turns = 2;
22172217
}
22182218
if (light->disable_interp_for_turns > 0) {
@@ -3184,7 +3184,6 @@ void update_block_pointed(int i,long x, long x_frac, long y, long y_frac)
31843184

31853185
void update_blocks_pointed(void)
31863186
{
3187-
TbBool out_of_bounds = false;
31883187
long x;
31893188
long y;
31903189
long x_frac;
@@ -3231,17 +3230,11 @@ void update_blocks_pointed(void)
32313230
if ((x >= 0) && (x < gameadd.map_subtiles_x) && (y >= 0) && (y < gameadd.map_subtiles_y))
32323231
{
32333232
update_block_pointed(i,x,x_frac,y,y_frac);
3234-
} else {
3235-
out_of_bounds = true;
32363233
}
32373234
hori_ptr_y -= hori_hdelta_y;
32383235
vert_ptr_y -= vert_hdelta_y;
32393236
}
32403237
}
3241-
3242-
struct PlayerInfo *player = get_my_player();
3243-
player->mouse_is_offmap = out_of_bounds;
3244-
32453238
SYNCDBG(19,"Finished");
32463239
}
32473240

src/packets_input.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,31 @@ extern TbBool packets_process_cheats(
5858

5959
extern void update_double_click_detection(long plyr_idx);
6060

61-
TbBool fix_previous_cursor_subtile_when_offmap;
61+
// Returns false if mouse is on map edges or on GUI
62+
TbBool is_mouse_on_map(struct Packet* pckt)
63+
{
64+
int x = (pckt->pos_x >> 8) / 3;
65+
int y = (pckt->pos_y >> 8) / 3;
66+
if (x == 0) {return false;}
67+
if (y == 0) {return false;}
68+
if (x == gameadd.map_tiles_x-1) {return false;}
69+
if (y == gameadd.map_tiles_y-1) {return false;}
70+
return true;
71+
}
72+
6273
void remember_cursor_subtile(struct PlayerInfo *player) {
6374
struct Packet* pckt = get_packet_direct(player->packet_num);
75+
TbBool badPacket = (pckt->pos_x == 0) && (pckt->pos_y == 0);
76+
6477
player->previous_cursor_subtile_x = player->cursor_subtile_x;
6578
player->previous_cursor_subtile_y = player->cursor_subtile_y;
66-
67-
TbBool badPacket = (pckt->pos_x == 0) && (pckt->pos_y == 0);
68-
TbBool onGui = ((pckt->control_flags & PCtr_Gui) != 0);
79+
player->cursor_subtile_x = coord_subtile((pckt->pos_x));
80+
player->cursor_subtile_y = coord_subtile((pckt->pos_y));
6981

70-
if (onGui == true || player->mouse_is_offmap == true || badPacket == true) {
71-
// Off field
72-
fix_previous_cursor_subtile_when_offmap = true;
73-
} else {
74-
// On field
75-
player->cursor_subtile_x = coord_subtile((pckt->pos_x));
76-
player->cursor_subtile_y = coord_subtile((pckt->pos_y));
77-
if (fix_previous_cursor_subtile_when_offmap == true) {
78-
fix_previous_cursor_subtile_when_offmap = false;
79-
player->previous_cursor_subtile_x = player->cursor_subtile_x;
80-
player->previous_cursor_subtile_y = player->cursor_subtile_y;
81-
}
82+
// Off field
83+
if (player->mouse_on_map == false || badPacket == true) {
84+
player->previous_cursor_subtile_x = player->cursor_subtile_x;
85+
player->previous_cursor_subtile_y = player->cursor_subtile_y;
8286
}
8387
}
8488

@@ -661,6 +665,7 @@ TbBool process_dungeon_control_packet_clicks(long plyr_idx)
661665
SYNCDBG(6,"Starting for player %d state %s",(int)plyr_idx,player_state_code_name(player->work_state));
662666
player->full_slab_cursor = 1;
663667
packet_left_button_double_clicked[plyr_idx] = 0;
668+
player->mouse_on_map = is_mouse_on_map(pckt);
664669
remember_cursor_subtile(player);
665670
if ((pckt->control_flags & PCtr_Gui) != 0)
666671
return false;

src/player_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ short cursor_light_idx;
257257
MapSubtlCoord cursor_subtile_y;
258258
MapSubtlCoord previous_cursor_subtile_x;
259259
MapSubtlCoord previous_cursor_subtile_y;
260-
TbBool mouse_is_offmap;
260+
TbBool mouse_on_map;
261261
TbBool roomspace_drag_paint_mode;
262262
unsigned char roomspace_l_shape;
263263
TbBool roomspace_horizontal_first;

0 commit comments

Comments
 (0)