Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit cd1aca6

Browse files
authored
[Admin] Makes the lag switch subsystem work (#22958)
* Lag * Moves the subsystem file * Fixes that one line
1 parent cf228af commit cd1aca6

File tree

10 files changed

+214
-7
lines changed

10 files changed

+214
-7
lines changed

code/__HELPERS/icons.dm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,10 @@ GLOBAL_DATUM_INIT(dummySave, /savefile, new("tmp/dummySave.sav")) //Cache of ico
11091109

11101110
var/key
11111111
var/icon/I = thing
1112+
var/mob/target_mob = target
11121113

1114+
if(SSlag_switch.measures[DISABLE_USR_ICON2HTML] && !HAS_TRAIT(target_mob, TRAIT_BYPASS_MEASURES))
1115+
return
11131116
if (!target)
11141117
return
11151118
if (target == world)
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ SUBSYSTEM_DEF(lag_switch)
9191
for(var/mob/user as anything in GLOB.player_list)
9292
if(user.stat == DEAD && !user.client?.holder)
9393
GLOB.keyloop_list -= user
94-
deadchat_broadcast(span_big("To increase performance Observer freelook is now disabled. Please use Orbit, Teleport, and Jump to look around."), message_type = DEADCHAT_ANNOUNCEMENT)
94+
deadchat_broadcast(span_big("To increase performance, Observer freelook is now disabled. Please use Orbit, Teleport, and Jump to look around."), message_type = DEADCHAT_ANNOUNCEMENT)
9595
else
9696
GLOB.keyloop_list |= GLOB.player_list
9797
deadchat_broadcast("Observer freelook has been re-enabled. Enjoy your wooshing.", message_type = DEADCHAT_ANNOUNCEMENT)
@@ -102,15 +102,32 @@ SUBSYSTEM_DEF(lag_switch)
102102
continue
103103
if(!ghost.client.holder && ghost.client.view_size.getView() != ghost.client.view_size.default)
104104
ghost.client.view_size.resetToDefault()
105+
deadchat_broadcast(span_big("To increase performance, Observer custom view range/T-ray views are now disabled."), message_type = DEADCHAT_ANNOUNCEMENT)
106+
else
107+
deadchat_broadcast("Observer custom view range/T-ray views are now re-enabled. Enjoy your wooshing.", message_type = DEADCHAT_ANNOUNCEMENT)
108+
if(DISABLE_RUNECHAT)
109+
if(state)
110+
to_chat(world, span_boldannounce("Runechat has been disabled for performance concerns."))
111+
else
112+
to_chat(world, span_boldannounce("Runechat has been re-enabled."))
113+
if(DISABLE_USR_ICON2HTML)
114+
if(state)
115+
to_chat(world, span_boldannounce("Icon2html has been disabled for performance concerns."))
116+
else
117+
to_chat(world, span_boldannounce("Icon2html has been re-enabled."))
118+
if(DISABLE_NON_OBSJOBS)
119+
var/datum/admins/holder = new(usr)
120+
holder.toggleenter() //This does the same thing, no need for duplicate proc
121+
world.update_status()
122+
/* Commented out since we don't have an implementation of this and I haven't figured out an alternative yet
105123
if(SLOWMODE_SAY)
106124
if(state)
107125
to_chat(world, span_boldannounce("Slowmode for IC/dead chat has been enabled with [slowmode_cooldown/10] seconds between messages."))
108126
else
109127
for(var/client/C as anything in GLOB.clients)
110128
COOLDOWN_RESET(C, say_slowmode)
111129
to_chat(world, span_boldannounce("Slowmode for IC/dead chat has been disabled by an admin."))
112-
if(DISABLE_NON_OBSJOBS)
113-
world.update_status()
130+
*/
114131
if(DISABLE_PARALLAX)
115132
if (state)
116133
to_chat(world, span_boldannounce("Parallax has been disabled for performance concerns."))

code/datums/chatmessage.dm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
stack_trace("/datum/chatmessage created with [isnull(owner) ? "null" : "invalid"] mob owner")
7171
qdel(src)
7272
return
73-
INVOKE_ASYNC(src, PROC_REF(generate_image), text, target, owner, language, extra_classes, lifespan)
73+
if(!SSlag_switch.measures[DISABLE_RUNECHAT] && !HAS_TRAIT(owner, TRAIT_BYPASS_MEASURES))
74+
INVOKE_ASYNC(src, PROC_REF(generate_image), text, target, owner, language, extra_classes, lifespan)
7475

7576
/datum/chatmessage/Destroy()
7677
if (owned_by)

code/datums/elements/footstep.dm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
///Prepares a footstep for living mobs. Determines if it should get played. Returns the turf it should get played on. Note that it is always a /turf/open
7070
/datum/element/footstep/proc/prepare_step(mob/living/source)
7171
var/turf/open/turf = get_turf(source)
72+
if(SSlag_switch.measures[DISABLE_FOOTSTEPS] && !HAS_TRAIT(source, TRAIT_BYPASS_MEASURES))
73+
return
74+
7275
if(!istype(turf))
7376
return
7477

code/modules/admin/admin_verbs.dm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ GLOBAL_PROTECT(admin_verbs_server)
159159
/client/proc/mentor_memo, // YOGS - something stupid about "Mentor memos"
160160
/client/proc/release_queue, // Yogs -- Adds some queue-manipulation verbs
161161
/client/proc/toggle_cdn,
162-
/client/proc/set_next_minetype
162+
/client/proc/set_next_minetype,
163+
/client/proc/lag_switch_panel
163164
)
164165
GLOBAL_LIST_INIT(admin_verbs_debug, world.AVerbsDebug())
165166
GLOBAL_PROTECT(admin_verbs_debug)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/client/proc/lag_switch_panel()
2+
set name = "Lag Switch Panel"
3+
set category = "Server"
4+
if(!check_rights(R_SERVER))
5+
return
6+
var/datum/lag_switch_menu/tgui = new(usr)
7+
tgui.ui_interact(usr)
8+
9+
/datum/lag_switch_menu
10+
var/client/holder
11+
12+
/datum/lag_switch_menu/New(user)
13+
if(istype(user, /client))
14+
var/client/user_client = user
15+
holder = user_client
16+
else
17+
var/mob/user_mob = user
18+
holder = user_mob.client
19+
20+
/datum/lag_switch_menu/ui_interact(mob/user, datum/tgui/ui)
21+
ui = SStgui.try_update_ui(user, src, ui)
22+
if(!ui)
23+
ui = new(user, src, "LagSwitchPanel")
24+
ui.open()
25+
ui.set_autoupdate(TRUE)
26+
27+
/datum/lag_switch_menu/ui_state(mob/user)
28+
return GLOB.admin_state
29+
30+
/datum/lag_switch_menu/ui_close()
31+
qdel(src)
32+
33+
/datum/lag_switch_menu/ui_data(mob/user)
34+
var/list/data = list()
35+
data["dead_keyloop"] = SSlag_switch.measures[DISABLE_DEAD_KEYLOOP]
36+
data["ghost_zoom_tray"] = SSlag_switch.measures[DISABLE_GHOST_ZOOM_TRAY]
37+
data["runechat"] = SSlag_switch.measures[DISABLE_RUNECHAT]
38+
data["icon2html"] = SSlag_switch.measures[DISABLE_USR_ICON2HTML]
39+
data["observerjobs"] = SSlag_switch.measures[DISABLE_NON_OBSJOBS]
40+
data["slowmodesay"] = SSlag_switch.measures[SLOWMODE_SAY]
41+
data["parallax"] = SSlag_switch.measures[DISABLE_PARALLAX]
42+
data["footsteps"] = SSlag_switch.measures[DISABLE_FOOTSTEPS]
43+
return data
44+
45+
/datum/lag_switch_menu/ui_act(action, list/params)
46+
. = ..()
47+
if(.)
48+
return
49+
switch(action)
50+
if("toggle_keyloop")
51+
SSlag_switch.measures[DISABLE_DEAD_KEYLOOP] ? SSlag_switch.set_measure(DISABLE_DEAD_KEYLOOP, 0) : SSlag_switch.set_measure(DISABLE_DEAD_KEYLOOP, 1)
52+
if("toggle_zoomtray")
53+
SSlag_switch.measures[DISABLE_GHOST_ZOOM_TRAY] ? SSlag_switch.set_measure(DISABLE_GHOST_ZOOM_TRAY, 0) : SSlag_switch.set_measure(DISABLE_GHOST_ZOOM_TRAY, 1)
54+
if("toggle_runechat")
55+
SSlag_switch.measures[DISABLE_RUNECHAT] ? SSlag_switch.set_measure(DISABLE_RUNECHAT, 0) : SSlag_switch.set_measure(DISABLE_RUNECHAT, 1)
56+
if("toggle_icon2html")
57+
SSlag_switch.measures[DISABLE_USR_ICON2HTML] ? SSlag_switch.set_measure(DISABLE_USR_ICON2HTML, 0) : SSlag_switch.set_measure(DISABLE_USR_ICON2HTML, 1)
58+
if("toggle_observerjobs")
59+
SSlag_switch.measures[DISABLE_NON_OBSJOBS] ? SSlag_switch.set_measure(DISABLE_NON_OBSJOBS, 0) : SSlag_switch.set_measure(DISABLE_NON_OBSJOBS, 1)
60+
if("toggle_slowmodesay")
61+
SSlag_switch.measures[SLOWMODE_SAY] ? SSlag_switch.set_measure(SLOWMODE_SAY, 0) : SSlag_switch.set_measure(SLOWMODE_SAY, 1)
62+
if("toggle_parallax")
63+
SSlag_switch.measures[DISABLE_PARALLAX] ? SSlag_switch.set_measure(DISABLE_PARALLAX, 0) : SSlag_switch.set_measure(DISABLE_PARALLAX, 1)
64+
if("toggle_footsteps")
65+
SSlag_switch.measures[DISABLE_FOOTSTEPS] ? SSlag_switch.set_measure(DISABLE_FOOTSTEPS, 0) : SSlag_switch.set_measure(DISABLE_FOOTSTEPS, 1)
66+
if("enable_all")
67+
SSlag_switch.set_all_measures(1)
68+
if("disable_all")
69+
SSlag_switch.set_all_measures(0)

code/modules/mob/dead/observer/observer.dm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
509509
set name = "View Range"
510510
set desc = "Change your view range."
511511

512+
if(SSlag_switch.measures[DISABLE_GHOST_ZOOM_TRAY] && !is_admin(usr))
513+
to_chat(usr, span_warning("Observer view range is disabled due to performance concerns."))
514+
return
512515
//yogs start -- Divert this verb to the admin variant if this guy has it
513-
if(check_rights(R_ADMIN,FALSE) && hascall(usr.client,"toggle_view_range"))
516+
if(is_admin(usr) && hascall(usr.client,"toggle_view_range"))
514517
call(usr.client,"toggle_view_range")()
515518
return
516519
//yogs end
@@ -993,6 +996,9 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
993996
set category = "Ghost"
994997
set name = "T-ray view"
995998
set desc = "Toggles a view of sub-floor objects"
999+
if(SSlag_switch.measures[DISABLE_GHOST_ZOOM_TRAY] && !is_admin(usr))
1000+
to_chat(usr, span_warning("Observer T-ray view is disabled due to performance concerns."))
1001+
return
9961002

9971003
var/static/t_ray_view = FALSE
9981004
t_ray_view = !t_ray_view

code/modules/mob/mob_movement.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
return FALSE //This is sota the goto stop mobs from moving var
9494
if(mob.control_object)
9595
return Move_object(direct)
96+
if(mob.stat == DEAD && (SSlag_switch.measures[DISABLE_DEAD_KEYLOOP] && !is_admin(mob)))
97+
return FALSE
9698
if(!isliving(mob))
9799
return mob.Move(n, direct)
98100
if(mob.stat == DEAD)
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { useBackend } from "../backend";
2+
import { Button, Flex, Section } from "../components";
3+
import { Window } from "../layouts";
4+
5+
type Data = {
6+
dead_keyloop: boolean;
7+
ghost_zoom_tray: boolean;
8+
runechat: boolean;
9+
icon2html: boolean;
10+
observerjobs: boolean;
11+
slowmodesay: boolean;
12+
parallax: boolean;
13+
footsteps: boolean;
14+
}
15+
16+
/* Credit to Xoxeyos who ported a port of the Ghost Pool Protection interface (PR #11139), which this follows the same design for the most part. */
17+
export const LagSwitchPanel = (props, context) => {
18+
const { act, data } = useBackend<Data>(context);
19+
const { dead_keyloop, ghost_zoom_tray, runechat, icon2html, observerjobs, slowmodesay, parallax, footsteps } = data;
20+
return (
21+
<Window title="Lag Switch Panel" width={400} height={270}>
22+
<Window.Content>
23+
<Flex>
24+
<Flex.Item grow={1}>
25+
<Section title="Options"
26+
buttons={
27+
<>
28+
<Button
29+
color="good"
30+
icon="plus-circle"
31+
content="Enable Everything"
32+
onClick={() => act("enable_all")} />
33+
<Button
34+
color="bad"
35+
icon="minus-circle"
36+
content="Disable Everything"
37+
onClick={() => act("disable_all")} />
38+
</>
39+
}>
40+
<Button
41+
fluid
42+
textAlign="center"
43+
color={dead_keyloop ? "good" : "bad"}
44+
icon="ghost"
45+
content="Disable ghost freelook (Staff exempted)"
46+
onClick={() => act("toggle_keyloop")} />
47+
<Button
48+
fluid
49+
textAlign="center"
50+
color={ghost_zoom_tray ? "good" : "bad"}
51+
icon="magnifying-glass"
52+
content="Disable ghost view/T-ray (Staff exempted)"
53+
onClick={() => act("toggle_zoomtray")} />
54+
<Button
55+
fluid
56+
textAlign="center"
57+
color={runechat ? "good" : "bad"}
58+
icon="comment"
59+
content="Disable runechat"
60+
onClick={() => act("toggle_runechat")} />
61+
<Button
62+
fluid
63+
textAlign="center"
64+
color={icon2html ? "good" : "bad"}
65+
icon="image"
66+
content="Disable icon2html"
67+
onClick={() => act("toggle_icon2html")} />
68+
<Button
69+
fluid
70+
textAlign="center"
71+
color={observerjobs ? "good" : "bad"}
72+
icon="hammer"
73+
content="Prevent new player joining"
74+
onClick={() => act("toggle_observerjobs")} />
75+
{/* Commented out since we don't have an implementation of this and I haven't figured out an alternative yet
76+
<Button
77+
fluid
78+
textAlign="center"
79+
color={slowmodesay ? "good" : "bad"}
80+
icon="stopwatch"
81+
content="Enable IC/dsay slowmode"
82+
onClick={() => act("toggle_slowmodesay")} />
83+
*/}
84+
<Button
85+
fluid
86+
textAlign="center"
87+
color={parallax ? "good" : "bad"}
88+
icon="map"
89+
content="Disable parallax"
90+
onClick={() => act("toggle_parallax")} />
91+
<Button
92+
fluid
93+
textAlign="center"
94+
color={footsteps ? "good" : "bad"}
95+
icon="shoe-prints"
96+
content="Disable footsteps"
97+
onClick={() => act("toggle_footsteps")} />
98+
</Section>
99+
</Flex.Item>
100+
</Flex>
101+
</Window.Content>
102+
</Window>
103+
);
104+
};

yogstation.dme

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@
404404
#include "code\controllers\controller.dm"
405405
#include "code\controllers\failsafe.dm"
406406
#include "code\controllers\globals.dm"
407-
#include "code\controllers\lag_switch.dm"
408407
#include "code\controllers\master.dm"
409408
#include "code\controllers\subsystem.dm"
410409
#include "code\controllers\configuration\config_entry.dm"
@@ -447,6 +446,7 @@
447446
#include "code\controllers\subsystem\input.dm"
448447
#include "code\controllers\subsystem\ipintel.dm"
449448
#include "code\controllers\subsystem\job.dm"
449+
#include "code\controllers\subsystem\lag_switch.dm"
450450
#include "code\controllers\subsystem\language.dm"
451451
#include "code\controllers\subsystem\lighting.dm"
452452
#include "code\controllers\subsystem\machines.dm"
@@ -1716,6 +1716,7 @@
17161716
#include "code\modules\admin\verbs\ghost_pool_protection.dm"
17171717
#include "code\modules\admin\verbs\hiddenprints.dm"
17181718
#include "code\modules\admin\verbs\individual_logging.dm"
1719+
#include "code\modules\admin\verbs\lag_switch.dm"
17191720
#include "code\modules\admin\verbs\machine_upgrade.dm"
17201721
#include "code\modules\admin\verbs\manipulate_organs.dm"
17211722
#include "code\modules\admin\verbs\map_template_loadverb.dm"

0 commit comments

Comments
 (0)