diff --git a/code/__HELPERS/turfs.dm b/code/__HELPERS/turfs.dm index 4c8b62b69dd..554ccd69e0a 100644 --- a/code/__HELPERS/turfs.dm +++ b/code/__HELPERS/turfs.dm @@ -227,19 +227,25 @@ Turf and target are separate in case you want to teleport some distance from a t return locate(final_x, final_y, atom_turf.z) ///Returns a turf based on text inputs, original turf and viewing client -/proc/params_to_turf(scr_loc, turf/origin, client/viewing_client) - if(!scr_loc) +/proc/parse_caught_click_modifiers(list/modifiers, turf/origin, client/viewing_client) + if(!modifiers) return null - var/tX = splittext(scr_loc, ",") - var/tY = splittext(tX[2], ":") - var/tZ = origin.z - tY = tY[1] - tX = splittext(tX[1], ":") - tX = tX[1] + + var/screen_loc = splittext(LAZYACCESS(modifiers, SCREEN_LOC), ",") var/list/actual_view = getviewsize(viewing_client ? viewing_client.view : world.view) - tX = clamp(origin.x + text2num(tX) - round(actual_view[1] / 2) - 1, 1, world.maxx) - tY = clamp(origin.y + text2num(tY) - round(actual_view[2] / 2) - 1, 1, world.maxy) - return locate(tX, tY, tZ) + var/click_turf_x = splittext(screen_loc[1], ":") + var/click_turf_y = splittext(screen_loc[2], ":") + var/click_turf_z = origin.z + + var/click_turf_px = text2num(click_turf_x[2]) + var/click_turf_py = text2num(click_turf_y[2]) + click_turf_x = origin.x + text2num(click_turf_x[1]) - round(actual_view[1] / 2) - 1 + click_turf_y = origin.y + text2num(click_turf_y[1]) - round(actual_view[2] / 2) - 1 + + var/turf/click_turf = locate(clamp(click_turf_x, 1, world.maxx), clamp(click_turf_y, 1, world.maxy), click_turf_z) + LAZYSET(modifiers, ICON_X, "[(click_turf_px - click_turf.pixel_x) + ((click_turf_x - click_turf.x) * world.icon_size)]") + LAZYSET(modifiers, ICON_Y, "[(click_turf_py - click_turf.pixel_y) + ((click_turf_y - click_turf.y) * world.icon_size)]") + return click_turf ///Almost identical to the params_to_turf(), but unused (remove?) /proc/screen_loc_to_turf(text, turf/origin, client/C) diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index c99ba99f702..2de2683c38b 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -528,10 +528,10 @@ var/mob/living/carbon/C = usr C.swap_hand() else - var/turf/T = params_to_turf(LAZYACCESS(modifiers, SCREEN_LOC), get_turf(usr.client ? usr.client.eye : usr), usr.client) - params += "&catcher=1" - if(T) - T.Click(location, control, params) + var/turf/click_turf = parse_caught_click_modifiers(modifiers, get_turf(usr.client ? usr.client.eye : usr), usr.client) + if (click_turf) + modifiers["catcher"] = TRUE + click_turf.Click(click_turf, control, list2params(modifiers)) . = 1 /// MouseWheelOn diff --git a/code/datums/components/fullauto.dm b/code/datums/components/fullauto.dm index 87db8676b21..1ae12792947 100644 --- a/code/datums/components/fullauto.dm +++ b/code/datums/components/fullauto.dm @@ -120,7 +120,8 @@ if(isnull(location) || istype(_target, /atom/movable/screen)) //Clicking on a screen object. if(_target.plane != CLICKCATCHER_PLANE) //The clickcatcher is a special case. We want the click to trigger then, under it. return //If we click and drag on our worn backpack, for example, we want it to open instead. - _target = params_to_turf(modifiers["screen-loc"], get_turf(source.eye), source) + _target = parse_caught_click_modifiers(modifiers, get_turf(source.eye), source) + params = list2params(modifiers) if(!_target) CRASH("Failed to get the turf under clickcatcher") @@ -199,7 +200,8 @@ SIGNAL_HANDLER if(isnull(over_location)) //This happens when the mouse is over an inventory or screen object, or on entering deep darkness, for example. var/list/modifiers = params2list(params) - var/new_target = params_to_turf(modifiers["screen-loc"], get_turf(source.eye), source) + var/new_target = parse_caught_click_modifiers(modifiers, get_turf(source.eye), source) + params = list2params(modifiers) mouse_parameters = params if(!new_target) if(QDELETED(target)) //No new target acquired, and old one was deleted, get us out of here.