forked from goonstation/goonstation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.dm
1534 lines (1266 loc) · 50.2 KB
/
client.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var/global/list/vpn_ip_checks = list() //assoc list of ip = true or ip = false. if ip = true, thats a vpn ip. if its false, its a normal ip.
/client
preload_rsc = 1
var/datum/player/player = null
var/datum/admins/holder = null
var/datum/preferences/preferences = null
var/deadchat = 0
var/changes = 0
var/area = null
var/stealth = 0
var/stealth_hide_fakekey = 0
var/alt_key = 0
var/flourish = 0
var/pray_l = 0
var/fakekey = null
var/suicide = 0
var/observing = 0
var/warned = 0
var/player_mode = 0
var/player_mode_asay = 0
var/player_mode_ahelp = 0
var/player_mode_mhelp = 0
var/only_local_looc = 0
var/deadchatoff = 0
var/local_deadchat = 0
var/queued_click = 0
var/joined_date = null
var/adventure_view = 0
var/list/hidden_verbs = null
var/datum/buildmode_holder/buildmode = null
var/lastbuildtype = 0
var/lastbuildvar = 0
var/lastbuildval = 0
var/lastbuildobj = 0
var/lastadvbuilder = 0
var/djmode = 0
var/non_admin_dj = 0
var/last_soundgroup = null
var/widescreen = 0
var/vert_split = 1
var/tg_controls = 0
var/tg_layout = 0
var/use_chui = 1
var/use_chui_custom_frames = 1
var/ignore_sound_flags = 0
var/has_contestwinner_medal = 0
var/antag_tokens //Number of antagonist tokens available to the player
var/using_antag_token = 0 //Set when the player readies up at round start, and opts to redeem a token.
var/persistent_bank_valid = FALSE
var/persistent_bank = 0 //cross-round persistent cash value (is increased as a function of job paycheck + station score)
var/persistent_bank_item = 0 //Name of a bank item that may have persisted from a previous round. (Using name because I'm assuming saving a string is better than saving a whole datum)
var/datum/reputations/reputations = null
var/list/datum/compid_info_list = list()
var/login_success = 0
var/view_tint
perspective = EYE_PERSPECTIVE
// please ignore this for now thanks in advance - drsingh
#ifdef PROC_LOGGING
var/proc_logging = 0
#endif
// authenticate = 0
// comment out the line below when debugging locally to enable the options & messages menu
control_freak = 1
var/datum/chatOutput/chatOutput = null
var/resourcesLoaded = 0 //Has this client done the mass resource downloading yet?
var/datum/tooltipHolder/tooltipHolder = null
var/chui/window/keybind_menu/keybind_menu = null
var/delete_state = DELETE_STOP
var/list/cloudsaves
var/list/clouddata
var/turf/stathover = null
var/turf/stathover_start = null//forgive me
var/list/qualifiedXpRewards = null
var/datum/interfaceSizeHelper/screen/screenSizeHelper = null
var/datum/interfaceSizeHelper/map/mapSizeHelper = null
var/obj/screen/screenHolder //Invisible, holds images that are used as render_sources.
var/experimental_intents = 0
var/admin_intent = 0
var/hand_ghosts = 1 //pickup ghosts inhand
/client/proc/audit(var/category, var/message, var/target)
if(src.holder && (src.holder.audit & category))
logTheThing("audit", src, target, message)
/client/proc/updateXpRewards()
if(qualifiedXpRewards == null)
qualifiedXpRewards = list()
for(var/X in xpRewards)
var/datum/jobXpReward/R = xpRewards[X]
if(R)
if(R.qualifies(src.key))
qualifiedXpRewards.Add(X)
qualifiedXpRewards[X] = R
return
/client/Del()
if (player_capa && src.login_success)
player_cap_grace[src.ckey] = TIME + 2 MINUTES
/* // THIS THING IS BREAKING THE REST OF THE PROC FOR SOME REASON AND I HAVE NO IDEA WHY
if (current_state < GAME_STATE_FINISHED)
ircbot.event("logout", src.key)
*/
logTheThing("admin", src, null, " has disconnected.")
src.images.Cut() //Probably not needed but eh.
if (src.mob)
src.mob.remove_dialogs()
clients -= src
if(src.holder)
onlineAdmins.Remove(src)
src.holder.dispose()
src.holder = null
src.player?.log_leave_time() //logs leave time, calculates played time on player datum
return ..()
/client/New()
Z_LOG_DEBUG("Client/New", "New connection from [src.ckey] from [src.address] via [src.connection]")
logTheThing("diary", null, src, "Login attempt: [src.ckey] from [src.address] via [src.connection], compid [src.computer_id]", "access")
login_success = 0
if(findtext(src.key, "Telnet @"))
boutput(src, "Sorry, this game does not support Telnet.")
preferences = new
sleep(5 SECONDS)
del(src)
return
logTheThing("admin", src, null, " has connected.")
Z_LOG_DEBUG("Client/New", "[src.ckey] - Connected")
src.player = make_player(key)
src.player.client = src
if (!isnewplayer(src.mob) && !isnull(src.mob)) //playtime logging stuff
src.player.log_join_time()
Z_LOG_DEBUG("Client/New", "[src.ckey] - Player set ([player])")
// moved preferences from new_player so it's accessible in the client scope
if (!preferences)
preferences = new
//Assign custom interface datums
src.chatOutput = new /datum/chatOutput(src)
//src.chui = new /datum/chui(src)
if (!isnewplayer(src.mob))
src.loadResources()
/*
SPAWN_DBG(rand(4,18))
if(proxy_check(src.address))
logTheThing("diary", null, src, "Failed Login: [constructTarget(src,"diary")] - Using a Tor Proxy Exit Node", "access")
if (announce_banlogin) message_admins("<span class='internal'>Failed Login: [src] - Using a Tor Proxy Exit Node (IP: [src.address], ID: [src.computer_id])</span>")
boutput(src, "You may not connect through TOR.")
SPAWN_DBG(0) del(src)
return
*/
Z_LOG_DEBUG("Client/New", "[src.ckey] - Running parent new")
..()
if (join_motd)
boutput(src, "<div class=\"motd\">[join_motd]</div>")
if (IsGuestKey(src.key))
if(!(!src.address || src.address == world.host)) // If you're a host or a developer locally, ignore this check.
var/gueststring = {"
<!doctype html>
<html>
<head>
<title>No guest logins allowed!</title>
<style>
h1, .banreason {
font-color:#F00;
}
</style>
</head>
<body>
<h1>Guest Login Denied</h1>
Don't forget to log in to your byond account prior to connecting to this server.
</body>
</html>
"}
src.mob.Browse(gueststring, "window=getout")
sleep(10)
if (src)
del(src)
return
if (world.time < 7 SECONDS)
if (config.whitelistEnabled && !(admins.Find(src.ckey) && admins[src.ckey] != "Inactive"))
if (!(src.ckey in whitelistCkeys))
sleep(3 SECONDS) //silly wait period bandaid so clients arent booted before whitelist load (probably)
//We're limiting connected players to a whitelist of ckeys (but let active admins in)
if (config.whitelistEnabled && !(admins.Find(src.ckey) && admins[src.ckey] != "Inactive"))
//Key not in whitelist, show them a vaguely sassy message and boot them
if (!(src.ckey in whitelistCkeys))
var/whitelistString = {"
<!doctype html>
<html>
<head>
<title>Server Whitelist Enabled</title>
<style>
h1, .banreason {
font-color:#F00;
}
</style>
</head>
<body>
<h1>Server whitelist enabled</h1>
This server has a player whitelist ON. You are not on the whitelist and will now be forcibly disconnected.
</body>
</html>
"}
src.mob.Browse(whitelistString, "window=whiteout")
sleep(10)
if (src)
del(src)
return
Z_LOG_DEBUG("Client/New", "[src.ckey] - Checking bans")
var/isbanned = checkBan(src.ckey, src.computer_id, src.address, record = 1)
if (isbanned)
Z_LOG_DEBUG("Client/New", "[src.ckey] - Banned!!")
logTheThing("diary", null, src, "Failed Login: [constructTarget(src,"diary")] - Banned", "access")
if (announce_banlogin) message_admins("<span class='internal'>Failed Login: <a href='?src=%admin_ref%;action=notes;target=[src.ckey]'>[src]</a> - Banned (IP: [src.address], ID: [src.computer_id])</span>")
var/banstring = {"
<!doctype html>
<html>
<head>
<title>BANNED!</title>
<style>
h1, .banreason {
font-color:#F00;
}
</style>
</head>
<body>
<h1>You have been banned.</h1>
<span class='banreason'>Reason: [isbanned].</span><br>
If you believe you were unjustly banned, head to <a href=\"https://forum.ss13.co\">the forums</a> and post an appeal.
</body>
</html>
"}
src.mob.Browse(banstring, "window=ripyou")
sleep(10)
if (src)
del(src)
return
Z_LOG_DEBUG("Client/New", "[src.ckey] - Ban check complete")
//vpn check (for ban evasion purposes) api documentation: https://vpnapi.io/api-documentation
#ifdef DO_VPN_CHECKS
if (vpn_blacklist_enabled)
var/vpn_kick_string = {"
<!doctype html>
<html>
<head>
<title>VPN or Proxy Detected</title>
</head>
<body>
<h1>Please disable your VPN, close the game, and rejoin.</h1><br>
</body>
</html>
"}
var/is_vpn_address = global.vpn_ip_checks["[src.address]"]
// We have already checked this user this round and they are indeed on a VPN, kick em
if (is_vpn_address)
logTheThing("admin", src, null, "[src.address] is using a vpn that they've already logged in with during this round.")
logTheThing("diary", src, null, "[src.address] is using a vpn that they've already logged in with during this round.", "admin")
message_admins("[key_name(src)] [src.address] attempted to connect with a VPN or proxy but was kicked!")
src.mob.Browse(vpn_kick_string, "window=vpnbonked")
sleep(3 SECONDS)
if (src)
del(src)
return
// Client has not been checked for VPN status this round, go do so, but only for relatively new accounts
// NOTE: adjust magic numbers here if we approach vpn checker api rate limits
if (isnull(is_vpn_address) && (src.player.rounds_participated < 5 || src.player.rounds_seen < 20))
var/list/data
try
data = apiHandler.queryAPI("vpncheck", list("ip" = src.address), 1)
// Goonhub API error encountered
if (data["error"])
logTheThing("admin", src, null, "unable to check VPN status of [src.address] because: [data["error"]]")
logTheThing("diary", src, null, "unable to check VPN status of [src.address] because: [data["error"]]", "debug")
// Successful Goonhub API query
else
data = json_decode(html_decode(data["response"]))
// VPN checker service returns error responses in a "message" property
if (data["message"])
// Yes, we're forcing a cache for a no-VPN response here on purpose
// Reasoning: The goonhub API has cached the VPN checker error response for the foreseeable future and further queries won't change that
// so we want to avoid spamming the goonhub API this round for literally no gain
global.vpn_ip_checks["[src.address]"] = false
logTheThing("admin", src, null, "unable to check VPN status of [src.address] because: [data["message"]]")
logTheThing("diary", src, null, "unable to check VPN status of [src.address] because: [data["message"]]", "debug")
// Successful VPN check
else
var/list/security_info = data["security"]
// IP is a known VPN, cache locally and kick
if (security_info["vpn"] == true)
global.vpn_ip_checks["[src.address]"] = true
logTheThing("admin", src, null, "[src.address] is using a vpn. vpn info: [json_encode(data["network"])]")
logTheThing("diary", src, null, "[src.address] is using a vpn. vpn info: [json_encode(data["network"])]", "admin")
message_admins("[key_name(src)] [src.address] attempted to connect with a VPN or proxy but was kicked!")
src.mob.Browse(vpn_kick_string, "window=vpnbonked")
sleep(3 SECONDS)
if (src)
del(src)
return
// IP is not a known VPN
else
global.vpn_ip_checks["[src.address]"] = false
catch(var/exception/e)
logTheThing("admin", src, null, "unable to check VPN status of [src.address] because: [e.name]")
logTheThing("diary", src, null, "unable to check VPN status of [src.address] because: [e.name]", "debug")
#endif
//admins and mentors can enter a server through player caps.
if (init_admin())
boutput(src, "<span class='ooc adminooc'>You are an admin! Time for crime.</span>")
else if (player.mentor)
boutput(src, "<span class='ooc mentorooc'>You are a mentor!</span>")
if (!src.holder)
src.verbs += /client/proc/toggle_mentorhelps
else if (player_capa && (total_clients_for_cap() >= player_cap) && (src.ckey in bypassCapCkeys))
boutput(src, "<span class='ooc adminooc'>Welcome! The server has reached the player cap of [player_cap], but you are allowed to bypass the player cap!</span>")
else if (player_capa && (total_clients_for_cap() >= player_cap) && client_has_cap_grace(src))
boutput(src, "<span class='ooc adminooc'>Welcome! The server has reached the player cap of [player_cap], but you were recently disconnected and were caught by the grace period!</span>")
else if(player_capa && (total_clients_for_cap() >= player_cap) && !src.holder)
boutput(src, "<span class='ooc adminooc'>I'm sorry, the player cap of [player_cap] has been reached for this server. You will now be forcibly disconnected</span>")
alert(src.mob,"I'm sorry, the player cap of [player_cap] has been reached for this server. You will now be forcibly disconnected", "SERVER FULL")
del(src)
return
Z_LOG_DEBUG("Client/New", "[src.ckey] - Adding to clients")
clients += src
SPAWN_DBG(0) // to not lock up spawning process
if (IsGuestKey(src.key))
src.has_contestwinner_medal = 0
else if (!config || !config.medal_hub || !config.medal_password)
src.has_contestwinner_medal = 0
else
src.has_contestwinner_medal = world.GetMedal("Too Cool", src.key, config.medal_hub, config.medal_password)
src.initSizeHelpers()
src.tooltipHolder = new /datum/tooltipHolder(src)
src.tooltipHolder.clearOld()
createRenderSourceHolder()
screen += renderSourceHolder
for(var/key in globalImages)
var/image/I = globalImages[key]
src << I
Z_LOG_DEBUG("Client/New", "[src.ckey] - ok mostly done")
SPAWN_DBG(0)
updateXpRewards()
SPAWN_DBG(3 SECONDS)
#ifndef IM_TESTING_SHIT_STOP_BARFING_CHANGELOGS_AT_ME
var/is_newbie = 0
#endif
// new player logic, moving some of the preferences handling procs from new_player.Login
Z_LOG_DEBUG("Client/New", "[src.ckey] - 3 sec spawn stuff")
if (!preferences)
preferences = new
if (istype(src.mob, /mob/new_player))
Z_LOG_DEBUG("Client/New", "[src.ckey] - new player crap")
//Load the preferences up here instead.
if(!preferences.savefile_load(src))
#ifndef IM_TESTING_SHIT_STOP_BARFING_CHANGELOGS_AT_ME
//preferences.randomizeLook()
preferences.ShowChoices(src.mob)
src.mob.Browse(grabResource("html/tgControls.html"),"window=tgcontrolsinfo;size=600x400;title=TG Controls Help")
boutput(src, "<span class='alert'>Welcome! You don't have a character profile saved yet, so please create one. If you're new, check out the <a target='_blank' href='https://wiki.ss13.co/Getting_Started#Fundamentals'>quick-start guide</a> for how to play!</span>")
//hey maybe put some 'new player mini-instructional' prompt here
//ok :)
is_newbie = 1
#endif
else if(!src.holder)
preferences.sanitize_name()
if (noir)
animate_fade_grayscale(src, 50)
#ifndef IM_TESTING_SHIT_STOP_BARFING_CHANGELOGS_AT_ME
if (!changes && preferences.view_changelog && !is_newbie)
if (!cdn)
//src << browse_rsc(file("browserassets/images/changelog/postcardsmall.jpg"))
src << browse_rsc(file("browserassets/images/changelog/88x31.png"))
changes()
if (src.holder && rank_to_level(src.holder.rank) >= LEVEL_MOD) // No admin changelog for goat farts (Convair880).
admin_changes()
#endif
if (src.byond_version < 513 || src.byond_build < 1526)
if (alert(src, "Please update BYOND to the latest version! Would you like to be taken to the download page? Make sure to download the stable release.", "ALERT", "Yes", "No") == "Yes")
src << link("http://www.byond.com/download/")
else
alert(src, "You won't be able to play without updating, sorry!")
del(src)
return
// Let's throw it here, why not! -ZeWaka
#if DM_BUILD < 1526 && !defined(SPACEMAN_DMM)
#error Please update your BYOND version to the latest stable release.
#endif
else
if (noir)
animate_fade_grayscale(src, 1)
preferences.savefile_load(src)
load_antag_tokens()
load_persistent_bank()
src.mob.reset_keymap()
Z_LOG_DEBUG("Client/New", "[src.ckey] - setjoindate")
setJoinDate()
if (winget(src, null, "hwmode") != "true")
alert(src, "Hardware rendering is disabled. This may cause errors displaying lighting, manifesting as BIG WHITE SQUARES.\nPlease enable hardware rendering from the byond preferences menu.","Potential Rendering Issue")
ircbot.event("login", src.key)
#if defined(RP_MODE) && !defined(IM_TESTING_SHIT_STOP_BARFING_CHANGELOGS_AT_ME)
src.verbs += /client/proc/cmd_rp_rules
if (istype(src.mob, /mob/new_player))
src.cmd_rp_rules()
#endif
//Cloud data
if (cdn)
// Fetch via HTTP from goonhub
var/datum/http_request/request = new()
request.prepare(RUSTG_HTTP_METHOD_GET, "http://spacebee.goonhub.com/api/cloudsave?list&ckey=[ckey]&api_key=[config.ircbot_api]", "", "")
request.begin_async()
UNTIL(request.is_complete())
var/datum/http_response/response = request.into_response()
if (response.errored || !response.body)
logTheThing("debug", src, null, "failed to have their cloud data loaded: Couldn't reach Goonhub")
return
var/list/ret = json_decode(response.body)
if(ret["status"] == "error")
logTheThing( "debug", src, null, "failed to have their cloud data loaded: [ret["error"]["error"]]" )
else
cloudsaves = ret["saves"]
clouddata = ret["cdata"]
load_antag_tokens()
load_persistent_bank()
var/decoded = cloud_get("audio_volume")
if(decoded)
var/cur = volumes.len
volumes = json_decode(decoded)
volumes.len = cur
if(current_state <= GAME_STATE_PREGAME && src.antag_tokens)
boutput(src, "<b>You have [src.antag_tokens] antag tokens!</b>")
if(istype(src.mob, /mob/new_player))
var/mob/new_player/M = src.mob
M.new_player_panel() // update if tokens available
if(do_compid_analysis)
do_computerid_test(src) //Will ban yonder fucker in case they are prix
check_compid_list(src) //Will analyze their computer ID usage patterns for aberrations
//WIDESCREEN STUFF
var/splitter_value = text2num(winget( src, "mainwindow.mainvsplit", "splitter" ))
var/widescreen_checked = winget( src, "menu.set_wide", "is-checked" ) == "true"
if (widescreen_checked)
if (splitter_value < 67.0)
src.set_widescreen(1)
var/is_vert_splitter = winget( src, "menu.horiz_split", "is-checked" ) != "true"
if (is_vert_splitter)
if (splitter_value >= 67.0) //Was this client using widescreen last time? save that!
src.set_widescreen(1, splitter_value)
src.screenSizeHelper.registerOnLoadCallback(CALLBACK(src, "checkScreenAspect"))
else
set_splitter_orientation(0, splitter_value)
src.set_widescreen(1, splitter_value)
winset( src, "menu", "horiz_split.is-checked=true" )
//End widescreen stuff
//blendmode stuff
var/distort_checked = winget( src, "menu.zoom_distort", "is-checked" ) == "true"
winset( src, "mapwindow.map", "zoom-mode=[distort_checked ? "distort" : "normal"]" )
//blendmode end
// cursed darkmode stuff
src.sync_dark_mode()
if(winget(src, "menu.fullscreen", "is-checked") == "true")
winset(src, null, "mainwindow.titlebar=false;mainwindow.is-maximized=true")
if(winget(src, "menu.hide_status_bar", "is-checked") == "true")
winset(src, null, "mainwindow.statusbar=false")
if(winget(src, "menu.hide_menu", "is-checked") == "true")
winset(src, null, "mainwindow.menu='';menub.is-visible = true")
// cursed darkmode end
//tg controls stuff
tg_controls = winget( src, "menu.tg_controls", "is-checked" ) == "true"
tg_layout = winget( src, "menu.tg_layout", "is-checked" ) == "true"
//tg controls end
use_chui = winget( src, "menu.use_chui", "is-checked" ) == "true"
use_chui_custom_frames = winget( src, "menu.use_chui_custom_frames", "is-checked" ) == "true"
//wow its the future we can choose between 3 fps values omg
if (winget( src, "menu.fps_chunky", "is-checked" ) == "true")
src.tick_lag = CLIENTSIDE_TICK_LAG_CHUNKY
else if (winget( src, "menu.fps_creamy", "is-checked" ) == "true")
src.tick_lag = CLIENTSIDE_TICK_LAG_CREAMY
else
src.tick_lag = CLIENTSIDE_TICK_LAG_SMOOTH
//game stuf
hand_ghosts = winget( src, "menu.use_hand_ghosts", "is-checked" ) == "true"
//sound
if (winget( src, "menu.speech_sounds", "is-checked" ) == "true")
ignore_sound_flags |= SOUND_SPEECH
if (winget( src, "menu.all_sounds", "is-checked" ) == "true")
ignore_sound_flags |= SOUND_ALL
if (winget( src, "menu.vox_sounds", "is-checked" ) == "true")
ignore_sound_flags |= SOUND_VOX
src.reputations = new(src)
// Set view tint
view_tint = winget( src, "menu.set_tint", "is-checked" ) == "true"
if(src.holder && src.holder.level >= LEVEL_CODER)
src.control_freak = 0
if (browse_item_initial_done)
SPAWN_DBG(0)
sendItemIcons(src)
// fixing locked ability holders
var/datum/abilityHolder/ability_holder = src.mob.abilityHolder
ability_holder?.locked = FALSE
var/datum/abilityHolder/composite/composite = ability_holder
if(istype(composite))
for(var/datum/abilityHolder/inner_holder in composite.holders)
inner_holder.locked = FALSE
Z_LOG_DEBUG("Client/New", "[src.ckey] - new() finished.")
login_success = 1
/*
/client/proc/write_gauntlet_matches()
return
*/
/client/proc/init_admin()
if(!address || (world.address == src.address))
admins[src.ckey] = "Host"
if (admins.Find(src.ckey) && !src.holder)
src.holder = new /datum/admins(src)
src.holder.rank = admins[src.ckey]
update_admins(admins[src.ckey])
onlineAdmins |= (src)
if (!NT.Find(src.ckey))
NT.Add(src.ckey)
return 1
return 0
/client/proc/clear_admin()
if(src.holder)
src.holder.dispose()
src.holder = null
src.clear_admin_verbs()
src.update_admins(null)
onlineAdmins -= src
/client/proc/checkScreenAspect(list/params)
if (params.len)
if ((params["screenW"]/params["screenH"]) == (4/3))
SPAWN_DBG(6 SECONDS)
if(alert(src, "You appear to be using a 4:3 aspect ratio! The Horizontal Split option is reccomended for your display. Activate Horizontal Split?",,"Yes","No") == "Yes")
set_splitter_orientation(0)
winset( src, "menu", "horiz_split.is-checked=true" )
/client/Command(command)
command = html_encode(command)
out(src, "<span class='alert'>Command \"[command]\" not recognised</span>")
/client/proc/load_antag_tokens()
var/savefile/AT = LoadSavefile("data/AntagTokens.sav")
if (!AT)
if( cloud_available() )
antag_tokens = cloud_get( "antag_tokens" ) ? text2num(cloud_get( "antag_tokens" )) : 0
return
var/ATtoken
AT[ckey] >> ATtoken
if (!ATtoken)
antag_tokens = cloud_get( "antag_tokens" ) ? text2num(cloud_get( "antag_tokens" )) : 0
return
else
antag_tokens = ATtoken
if( cloud_available() )
antag_tokens += text2num( cloud_get( "antag_tokens" ) || "0" )
var/failed = cloud_put( "antag_tokens", antag_tokens )
if( failed )
logTheThing( "debug", src, null, "Failed to store antag tokens in the ~cloud~: [failed]" )
else
AT[ckey] << null
/client/proc/set_antag_tokens(amt as num)
antag_tokens = amt
if( cloud_available() )
cloud_put( "antag_tokens", amt )
/*
var/savefile/AT = LoadSavefile("data/AntagTokens.sav")
if (!AT) return
if (antag_tokens < 0) antag_tokens = 0
AT[ckey] << antag_tokens*/
/client/proc/use_antag_token()
src.set_antag_tokens(--antag_tokens)
/client/proc/load_persistent_bank()
//var/savefile/PB = LoadSavefile("data/PersistentBank.sav")
//if (!PB)
// if( cloud_available() )
// persistent_bank = cloud_get( "persistent_bank" ) ? text2num(cloud_get( "persistent_bank" )) : 0
// return
//var/bank = 0
//PB[ckey] >> bank
//if (!bank)
persistent_bank_valid = cloud_available()
persistent_bank = cloud_get( "persistent_bank" ) ? text2num(cloud_get( "persistent_bank" )) : 0
// return
//else
// persistent_bank = bank
if( !persistent_bank && cloud_available() )
logTheThing( "debug", src, null, "first cloud_get failed but cloud is available!" )
persistent_bank += text2num( cloud_get( "persistent_bank" ) || "0" )
var/failed = cloud_put( "persistent_bank", persistent_bank )
if( failed )
logTheThing( "debug", src, null, "Failed to store persistent cash in the ~cloud~: [failed]" )
//else
// PB[ckey] << null
persistent_bank_item = cloud_get( "persistent_bank_item" )
if( !persistent_bank_item && cloud_available() )
persistent_bank_item = cloud_get( "persistent_bank_item" )
var/failed = cloud_put( "persistent_bank_item", persistent_bank_item )
if( failed )
logTheThing( "debug", src, null, "Failed to store persistent bank item in the ~cloud~: [failed]" )
//MBC TODO : PERSISTENTBANK_VERSION_MIN, MAX FOR BANKING SO WE CAN WIPE AWAY EVERYONE'S HARD WORK WITH A SINGLE LINE OF CODE CHANGE
// defines are already set, just do the checks here ok
// ok in retrospect i don't think we need this so I'm not doing it. leaving this comment here though! for fun! (in case SOMEONE changes their mind)
/client/proc/set_last_purchase(datum/bank_purchaseable/purchase)
if (!purchase || purchase == 0 || !purchase.carries_over)
persistent_bank_item = "none"
if( cloud_available() )
cloud_put( "persistent_bank_item", "none" )
else
persistent_bank_item = purchase.name
if( cloud_available() )
cloud_put( "persistent_bank_item", persistent_bank_item )
/client/proc/set_persistent_bank(amt as num)
persistent_bank = amt
if( cloud_available() )
cloud_put( "persistent_bank", amt )
/*
var/savefile/PB = LoadSavefile("data/PersistentBank.sav")
if (!PB) return
PB[ckey] << amt
*/
//MBC TODO : DO SOME LOGGING ON ADD_TO_BANK() AND TRY_BANK_PURCHASE()
/client/proc/add_to_bank(amt as num)
if(!persistent_bank_valid)
load_persistent_bank()
if(!persistent_bank_valid)
return
var/new_bank_value = persistent_bank + amt
src.set_persistent_bank(new_bank_value)
/client/proc/sub_from_bank(datum/bank_purchaseable/purchase)
add_to_bank(-purchase.cost)
/client/proc/bank_can_afford(amt as num)
var/new_bank_value = persistent_bank - amt
if (new_bank_value >= 0)
return 1
else
return 0
/client/proc/is_mentor()
return player.mentor
/client/proc/can_see_mentor_pms()
return (src.player?.mentor || src.holder) && src.player?.see_mentor_pms
var/global/curr_year = null
var/global/curr_month = null
var/global/curr_day = null
/client/proc/jd_warning(var/jd)
if (!curr_year)
curr_year = text2num(time2text(world.realtime, "YYYY"))
if (!curr_month)
curr_month = text2num(time2text(world.realtime, "MM"))
if (!curr_day)
curr_day = text2num(time2text(world.realtime, "DD"))
var/deliver_warning = 0
var/y = text2num(copytext(jd, 1, 5))
var/m = text2num(copytext(jd, 6, 8))
var/d = text2num(copytext(jd, 9, 11))
if (curr_month == 1 && curr_day <= 4)
if (y == curr_year - 1 && m == 12 && d >= 31 - (4 - curr_day))
deliver_warning = 1
else if (y == curr_year && m == 1)
deliver_warning = 1
else if (curr_day <= 4)
if (y == curr_year)
if (m == curr_month - 1 && d >= 28 - (4 - curr_day))
deliver_warning = 1
else if (m == curr_month)
deliver_warning = 1
else if (y == curr_year && m == curr_month && d >= curr_day - 4)
deliver_warning = 1
if (deliver_warning)
var/msg = "(IP: [address], ID: [computer_id]) has a recent join date of [jd]."
message_admins("[key_name(src)] [msg]")
var/addr = address
var/ck = ckey
var/cid = computer_id
SPAWN_DBG(0)
if (geoip_check(addr))
var/addData[] = new()
addData["ckey"] = ck
addData["compID"] = cid
addData["ip"] = addr
addData["reason"] = "Ban evader: computer ID collision." // haha get fucked
addData["akey"] = "Marquesas"
addData["mins"] = 0
var/slt = rand(600, 3000)
logTheThing("admin", null, null, "Evasion geoip autoban triggered on [key], will execute in [slt / 10] seconds.")
message_admins("Autobanning evader [key] in [slt / 10] seconds.")
sleep(slt)
addBan(addData)
/proc/geoip_check(var/addr)
set background = 1
var/list/vl = world.Export("http://ip-api.com/json/[addr]")
if (!("CONTENT" in vl) || vl["STATUS"] != "200 OK")
sleep(3000)
return geoip_check(addr)
var/jd = html_encode(file2text(vl["CONTENT"]))
// hardcoding argentina for now
//var/c_text = "Argentina"
//var/r_text = "Entre Rios"
//var/i_text = "Federal"
var/asshole_proxy_provider = "AnchorFree"
//if (findtext(jd, c_text) && findtext(jd, r_text) && findtext(jd, i_text))
// logTheThing("admin", null, null, "Banned location: Argentina, Entre Rios, Federal for IP [addr].")
// return 1
if (findtext(jd, asshole_proxy_provider))
logTheThing("admin", null, null, "Banned proxy: AnchorFree Hotspot Shield [addr].")
return 1
return 0
/client/proc/setJoinDate()
joined_date = ""
// Get join date from BYOND members page
var/datum/http_request/request = new()
request.prepare(RUSTG_HTTP_METHOD_GET, "http://byond.com/members/[src.ckey]?format=text", "", "")
request.begin_async()
UNTIL(request.is_complete())
var/datum/http_response/response = request.into_response()
if (response.errored || !response.body)
logTheThing("debug", null, null, "setJoinDate: Failed to get join date response for [src.ckey].")
return
var/savefile/save = new
save.ImportText("/", response.body)
save.cd = "general"
joined_date = save["joined"]
jd_warning(joined_date)
/client/verb/ping()
set name = "Ping"
boutput(usr, "Pong")
/client/verb/changeServer(var/server as text)
set name = "Change Server"
set hidden = 1
var/serverURL
var/serverName
switch (server)
if (1, "rp")
serverName = "Goonstation Roleplay"
serverURL = "byond://goon1.goonhub.com:26100"
if (2, "main")
serverName = "Goonstation"
serverURL = "byond://goon2.goonhub.com:26200"
if (3, "main2")
serverName = "Goonstation Roleplay Overflow"
serverURL = "byond://goon3.goonhub.com:26300"
if (4, "main3")
serverName = "Goonstation Overflow"
serverURL = "byond://goon4.goonhub.com:26400"
if (serverURL)
boutput(usr, "You are being redirected to [serverName]...")
usr << link(serverURL)
/*
/client/verb/Newcastcycle()
set hidden = 1
if (!(ishuman(usr))) return
var/mob/living/carbon/human/H = usr
if (istype(H.wear_suit, /obj/item/clothing/suit/wizrobe/abuttontest))
var/obj/screen/ability_button/spell/U = H.wear_suit.ability_buttons[2]
U.execute_ability()
*/
/client/Stat()
. = ..()
if(src.stathover)
if(get_turf(mob) != stathover_start || get_dist( stathover, get_turf(mob) ) >= 5)
stathover = null
return
stat( stathover )//tg makes a new panel, thats ugly tho
for( var/atom/A in stathover )
if( !A.mouse_opacity || A.invisibility > mob.see_invisible ) continue
stat( A )
if (!src.holder)//todo : maybe give admins a toggle
sleep(1.2 SECONDS) //and make this number larger
else
sleep(0.1 SECONDS)
/client/Topic(href, href_list)
if (!usr || isnull(usr.client))
return
// Tgui Topic middleware
if(tgui_Topic(href_list))
return
var/mob/M
if (href_list["target"])
var/targetCkey = href_list["target"]
M = whois_ckey_to_mob_reference(targetCkey)
switch(href_list["action"])
if ("priv_msg_irc")
if (!src || !src.mob)
return
var/target = href_list["nick"]
var/t = input("Message:", text("Private message to [target] (Discord)")) as null|text
if(!(src.holder && (src.holder.rank in list("Host", "Coder"))))
t = strip_html(t,500)
if (!( t ))
return
boutput(src.mob, "<span class='ahelp' class=\"bigPM\">Admin PM to-<b>[target] (Discord)</b>: [t]</span>")
logTheThing("admin_help", src, null, "<b>PM'd [target]</b>: [t]")
logTheThing("diary", src, null, "PM'd [target]: [t]", "ahelp")
var/ircmsg[] = new()
ircmsg["key"] = src.mob && src ? src.key : ""
ircmsg["name"] = src.mob.real_name
ircmsg["key2"] = target
ircmsg["name2"] = "Discord"
ircmsg["msg"] = html_decode(t)
ircbot.export("pm", ircmsg)
//we don't use message_admins here because the sender/receiver might get it too
for (var/client/C)
if (!C.mob) continue
var/mob/K = C.mob
if(C.holder && C.key != usr.key)
if (C.player_mode && !C.player_mode_ahelp)
continue
else
boutput(K, "<span class='ahelp'><b>PM: [key_name(src.mob,0,0)][(src.mob.real_name ? "/"+src.mob.real_name : "")] <A HREF='?src=\ref[C.holder];action=adminplayeropts;targetckey=[src.ckey]' class='popt'><i class='icon-info-sign'></i></A> <i class='icon-arrow-right'></i> [target] (Discord)</b>: [t]</span>")
if ("priv_msg")
do_admin_pm(href_list["target"], usr) // See \admin\adminhelp.dm, changed to work off of ckeys instead of mobs.
if ("mentor_msg_irc")
if (!usr || !usr.client)
return
var/target = href_list["nick"]
var/t = input("Message:", text("Mentor Message")) as null|text
if(!(src.holder && (src.holder.rank in list("Host", "Coder"))))
t = strip_html(t,500)
if (!( t ))
return
boutput(src.mob, "<span class='mhelp'><b>MENTOR PM: TO [target] (Discord)</b>: <span class='message'>[t]</span></span>")
logTheThing("mentor_help", src, null, "<b>Mentor PM'd [target]</b>: [t]")
logTheThing("diary", src, null, "Mentor PM'd [target]: [t]", "admin")
var/ircmsg[] = new()
ircmsg["key"] = src.mob && src ? src.key : ""
ircmsg["name"] = src.mob.real_name
ircmsg["key2"] = target
ircmsg["name2"] = "Discord"
ircmsg["msg"] = html_decode(t)
ircbot.export("mentorpm", ircmsg)