Skip to content

Commit 0d58879

Browse files
Fixes assembly interaction window refreshing (#36765)
* Fixes assembly and item interaction window refreshing * removes em here too * makes this properly work inside things, also cuts down redundant code * cuts these down too * wow light tile remote code sucked too * changes it to this function
1 parent a210ab8 commit 0d58879

File tree

6 files changed

+39
-77
lines changed

6 files changed

+39
-77
lines changed

code/game/objects/objs.dm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,22 @@ var/global/list/reagents_to_log = list(FUEL, PLASMA, PACID, SACID, AMUTATIONTOXI
387387
attack_hand(M, TRUE)
388388
in_use = is_in_use
389389

390+
/obj/item/updateUsrDialog()
391+
if(in_use)
392+
var/is_in_use = 0
393+
if(usr)
394+
_using |= usr
395+
if(_using && _using.len)
396+
for(var/mob/M in _using) // Only check things actually messing with us.
397+
if (!M || !M.client || !in_range(loc,M)) // NOT ON MOB
398+
_using.Remove(M)
399+
continue
400+
is_in_use = 1
401+
src.attack_self(M)
402+
403+
// check for TK users
404+
in_use = is_in_use
405+
390406
/obj/proc/updateDialog()
391407
// Check that people are actually using the machine. If not, don't update anymore.
392408
if(in_use)

code/modules/assembly/infrared.dm

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@
150150
var/dat = text("<B>Status</B>: []<BR>\n<B>Visibility</B>: []<BR>", (on ? text("<A href='?src=\ref[];state=0'>ON</A>", src) : text("<A href='?src=\ref[];state=1'>OFF</A>", src)), (src.visible ? text("<A href='?src=\ref[];visible=0'>visible</A>", src) : text("<A href='?src=\ref[];visible=1'>infrared</A>", src)))
151151

152152
dat += {"<B>Direction</B>: <A href='?src=\ref[src];direction=1'>[dir2text(dir)]</A><BR>"}
153-
dat += {"<BR><BR><A href='?src=\ref[src];refresh=1'>Refresh</A>
154-
<BR><BR><A href='?src=\ref[src];close=1'>Close</A>"}
155153
user << browse("<TITLE>Infrared Laser</TITLE><HR>[dat]", "window=infra")
156154
onclose(user, "infra")
157155

@@ -173,10 +171,6 @@
173171
beam.set_visible(visible)
174172
update_icon()
175173

176-
if(href_list["close"])
177-
usr << browse(null, "window=infra")
178-
return
179-
180174
if(href_list["direction"])
181175
var/choice = input("What direction will you aim the laser toward?","Infrared Laser") as null|anything in list("NORTH", "EAST", "SOUTH", "WEST")
182176
if (choice)
@@ -186,8 +180,7 @@
186180
QDEL_NULL(beam)
187181
process()
188182

189-
if(usr)
190-
attack_self(usr)
183+
updateUsrDialog()
191184

192185

193186
/***************************IBeam*********************************/

code/modules/assembly/light_tiler.dm

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
<p><a href='?src=\ref[src];change_color=1'>Change color</a> | <a href='?src=\ref[src];toggle_set_state=1'>Light floors will be turned <b>[set_state ? "ON" : "OFF"]</b></a></p>
8383
<BR>
8484
<p><a href='?src=\ref[src];apply=1'>Activate</a></p>
85-
<p><a href='?src=\ref[src];refresh=1'>Refresh</a></p>
8685
"}
8786

8887
var/datum/browser/popup = new(user, "\ref[src]", "[src]", 500, 300, src)
@@ -126,9 +125,6 @@
126125
work_mode = MODE_ADDING
127126
to_chat(usr, "<span class='info'>When applied to light floors, \the [src] will now connect to them.</span>")
128127

129-
if(usr)
130-
attack_self(usr)
131-
132128
if(href_list["toggle_set_state"])
133129
set_state = !set_state
134130

@@ -137,17 +133,11 @@
137133
else
138134
to_chat(usr, "<span class='info'>Light floors will be turned off.</span>")
139135

140-
if(usr)
141-
attack_self(usr)
142-
143136
if(href_list["delete_all"])
144137
to_chat(usr, "<span class='notice'>Disconnected [connected_floors.len] tiles from the network.</span>")
145138

146139
connected_floors = list()
147140

148-
if(usr)
149-
attack_self(usr)
150-
151141
if(href_list["change_color"])
152142
var/new_color = input(usr, "Please select a new color for \the [src].", "[src]", rgb(color_r,color_g,color_b)) as color
153143

@@ -160,15 +150,10 @@
160150

161151
to_chat(usr, "<span class='info'>Changed color to [color_r];[color_g];[color_b]!</span>")
162152

163-
if(usr)
164-
attack_self(usr)
165-
166153
if(href_list["apply"])
167154
change_floors()
168155

169-
if(href_list["refresh"])
170-
if(usr)
171-
attack_self(usr)
156+
updateUsrDialog()
172157

173158
/obj/item/device/assembly/light_tile_control/proc/change_floors()
174159
if(last_used + cooldown_max > world.time)

code/modules/assembly/proximity.dm

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@
109109
in_proximity = FALSE
110110
sense()
111111

112-
if(timing && (time >= 0))
113-
time--
114-
if(timing && time <= 0)
115-
timing = 0
116-
toggle_scan()
117-
time = default_time
118-
return
112+
if(timing)
113+
if(time >= 0)
114+
time--
115+
else
116+
timing = 0
117+
toggle_scan()
118+
time = default_time
119+
updateUsrDialog()
119120

120121
/obj/item/device/assembly/prox_sensor/dropped()
121122
spawn(0)
@@ -162,9 +163,7 @@
162163

163164
dat += {"<BR><A href='?src=\ref[src];scanning=1'>[scanning?"Armed":"Unarmed"]</A> (Movement sensor active when armed!)
164165
<BR><BR><A href='?src=\ref[src];set_default_time=1'>After countdown, reset time to [(default_time - default_time%60)/60]:[(default_time % 60)]</A>
165-
<BR><BR><A href='?src=\ref[src];refresh=1'>Refresh</A>
166-
<BR><BR><A href='?src=\ref[src];toggle_mode=1'>Mode: [constant_pulse ? PROXMODE_CONSTANT : PROXMODE_ENTER]</A>
167-
<BR><BR><A href='?src=\ref[src];close=1'>Close</A>"}
166+
<BR><BR><A href='?src=\ref[src];toggle_mode=1'>Mode: [constant_pulse ? PROXMODE_CONSTANT : PROXMODE_ENTER]</A>"}
168167
user << browse(dat, "window=prox")
169168
onclose(user, "prox")
170169
return
@@ -201,15 +200,8 @@
201200

202201
if(href_list["toggle_mode"])
203202
constant_pulse = !constant_pulse
204-
return
205-
206-
if(href_list["close"])
207-
usr << browse(null, "window=prox")
208-
return
209-
210-
if(usr)
211-
attack_self(usr)
212203

204+
updateUsrDialog()
213205
return
214206

215207
#undef VALUE_SCANNING

code/modules/assembly/timer.dm

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@
6060
return
6161

6262
/obj/item/device/assembly/timer/process()
63-
if(timing && (time > 0))
64-
time--
65-
if(timing && time <= 0)
66-
if(!repeat)
67-
timing = 0
68-
timer_end()
69-
time = default_time
70-
return
71-
63+
if(timing)
64+
if(time > 0)
65+
time--
66+
else
67+
if(!repeat)
68+
timing = 0
69+
timer_end()
70+
time = default_time
71+
updateUsrDialog()
7272

7373
/obj/item/device/assembly/timer/update_icon()
7474
overlays.len = 0
@@ -88,11 +88,8 @@
8888
var/second = time % 60
8989
var/minute = (time - second) / 60
9090
var/dat = text("<TT><B>Timing Unit</B>\n[] []:[]\n<A href='?src=\ref[];tp=-30'>-</A> <A href='?src=\ref[];tp=-1'>-</A> <A href='?src=\ref[];tp=1'>+</A> <A href='?src=\ref[];tp=30'>+</A>\n</TT>", (timing ? text("<A href='?src=\ref[];time=0'>Timing</A>", src) : text("<A href='?src=\ref[];time=1'>Not Timing</A>", src)), minute, second, src, src, src, src)
91-
9291
dat += "<BR><BR><A href='?src=\ref[src];set_default_time=1'>After countdown, reset time to [(default_time - default_time%60)/60]:[(default_time % 60)]</A>"
93-
dat += {"<BR><BR><A href='?src=\ref[src];refresh=1'>Refresh</A>
94-
<BR><BR><A href='?src=\ref[src];toggle_mode=1'>Mode: [repeat ? TIMEMODE_REPEAT : TIMEMODE_ONCE]</A>
95-
<BR><BR><A href='?src=\ref[src];close=1'>Close</A>"}
92+
dat += "<BR><BR><A href='?src=\ref[src];toggle_mode=1'>Mode: [repeat ? TIMEMODE_REPEAT : TIMEMODE_ONCE]</A>"
9693
user << browse(dat, "window=timer")
9794
onclose(user, "timer")
9895
return
@@ -119,18 +116,11 @@
119116

120117
if(href_list["toggle_mode"])
121118
repeat = !repeat
122-
return
123-
124-
if(href_list["close"])
125-
usr << browse(null, "window=timer")
126-
return
127119

128120
if(href_list["set_default_time"])
129121
default_time = time
130122

131-
if(usr)
132-
attack_self(usr)
133-
123+
updateUsrDialog()
134124
return
135125

136126
/obj/item/device/assembly/timer/send_to_past(var/duration)

code/modules/reagents/dartgun.dm

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,6 @@
168168
/obj/item/weapon/gun/dartgun/can_hit(var/mob/living/target as mob, var/mob/living/user as mob)
169169
return 1
170170

171-
/obj/item/weapon/gun/dartgun/updateUsrDialog()
172-
if(in_use)
173-
var/is_in_use = 0
174-
if ((usr.client && usr.machine == src && src.loc == usr))
175-
is_in_use = 1
176-
src.attack_self(usr)
177-
if (isMoMMI(usr))
178-
if ((usr.client && usr.machine == src && src.loc == usr)) // && M.machine == src is omitted because if we triggered this by using the dialog, it doesn't matter if our machine changed in between triggering it and this - the dialog is probably still supposed to refresh.
179-
is_in_use = 1
180-
src.attack_self(usr)
181-
182-
// check for TK users
183-
in_use = is_in_use
184-
185171
/obj/item/weapon/gun/dartgun/attack_self(mob/user)
186172
user.set_machine(src)
187173
in_use = 1

0 commit comments

Comments
 (0)