mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
-Almost every instance of 'for(mob in world)' has been killed. Because GODDAMN was it being run a bunch. Instead, a series of global lists have been made, and they are all handled auto-magically through New()'s, Del()'s, Login()'s, death()'s, etc... Lists are as follows: -mob_list : Contains all atom/mobs by ref -player_list : Like mob_list, but only contains mobs with clients attached -admin_list : Like player_list, but holds all mobs with clients attached and admin status -living_mob_list : Contains all mobs that ARE alive, regardless of client status -dead_mob_list : Contains all mobs that are dead, which comes down to corpses and ghosts -cable_list : A list containing every obj/structure/cable in existence Note: There is an object (/obj/item/debuglist) that you can use to check the contents of each of the lists except for cables (Since getting a message saying "a cable," x9001 isn't very helpful) These lists have been tested as much as I could on my own, and have been mostly implemented. There are still places where they could be used, but for now it's important that the core is working. If this all checks out I would really like to implement it into the MC as well, simply so it doesn't check call Life() on every mob by checking for all the ones in world every damn tick. Just testing locally I was able to notice improvements with certain aspects, like admin verbs being MUCH more responsive (They checked for every mob in the world every time they were clicked), many sources of needless lag were cut out (Like Adminwho and Who checking every single mob when clicked), and due to the cable_list powernet rebuilding is MUCH more efficient, because instead of checking for every cable in the world every time a powernet was broken (read: A cable was deleted), it runs though the pre-made list, and even with a singulo tearing all the way across the station, the powernet load was VERY small compared to pretty much everything else. If you want to know how any of this works, check global_lists.dm, there I have it rigorously commented, and it should provide an understanding of what's going on. Mob related in worlds before this commit: 1262 After: 4 I'm helping git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4179 316c924e-a436-60f5-8080-3fe189b3f50e
112 lines
4.8 KiB
Plaintext
112 lines
4.8 KiB
Plaintext
//allows right clicking mobs to send an admin PM to their client, forwards the selected mob's client to cmd_admin_pm
|
|
/client/proc/cmd_admin_pm_context(mob/M as mob in mob_list)
|
|
set category = null
|
|
set name = "Admin PM Mob"
|
|
if(!holder)
|
|
src << "<font color='red'>Error: Admin-PM-Context: Only administrators may use this command.</font>"
|
|
return
|
|
if( !ismob(M) || !M.client ) return
|
|
cmd_admin_pm(M.client,null)
|
|
feedback_add_details("admin_verb","APMM") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
|
|
|
//shows a list of clients we could send PMs to, then forwards our choice to cmd_admin_pm
|
|
/client/proc/cmd_admin_pm_panel()
|
|
set category = "Admin"
|
|
set name = "Admin PM"
|
|
if(!holder)
|
|
src << "<font color='red'>Error: Admin-PM-Panel: Only administrators may use this command.</font>"
|
|
return
|
|
var/list/client/targets[0]
|
|
for(var/client/T)
|
|
if(T.mob)
|
|
if(istype(T.mob, /mob/new_player))
|
|
targets["(New Player) - [T]"] = T
|
|
else if(istype(T.mob, /mob/dead/observer))
|
|
targets["[T.mob.name](Ghost) - [T]"] = T
|
|
else
|
|
targets["[T.mob.real_name](as [T.mob.name]) - [T]"] = T
|
|
else
|
|
targets["(No Mob) - [T]"] = T
|
|
var/list/sorted = sortList(targets)
|
|
var/target = input(src,"To whom shall we send a message?","Admin PM",null) in sorted|null
|
|
cmd_admin_pm(targets[target],null)
|
|
feedback_add_details("admin_verb","APM") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
|
|
|
|
|
//takes input from cmd_admin_pm_context, cmd_admin_pm_panel or /client/Topic and sends them a PM.
|
|
//Fetching a message if needed. src is the sender and C is the target client
|
|
/client/proc/cmd_admin_pm(var/client/C, var/msg)
|
|
if(src.muted_adminhelp)
|
|
src << "<font color='red'>Error: Admin-PM: You are unable to use admin PM-s (muted by admins).</font>"
|
|
return
|
|
|
|
if( !C || !istype(C,/client) )
|
|
if(holder) src << "<font color='red'>Error: Admin-PM: Client not found.</font>"
|
|
else adminhelp(msg) //admin we are replying to left. adminhelp instead
|
|
return
|
|
|
|
//get message text, limit it's length.and clean/escape html
|
|
if(!msg)
|
|
msg = input(src,"Message:", "Private message to [C.key]") as text|null
|
|
|
|
if(!msg) return
|
|
if(!C)
|
|
if(holder) src << "<font color='red'>Error: Admin-PM: Client not found.</font>"
|
|
else adminhelp(msg) //admin we are replying to has vanished, adminhelp instead
|
|
return
|
|
|
|
if (src.handle_spam_prevention(msg,MUTE_ADMINHELP))
|
|
return
|
|
|
|
//clean the message if it's not sent by a GA or GM
|
|
if( !holder || !(holder.rank in list("Game Admin", "Game Master")) )
|
|
msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN))
|
|
if(!msg) return
|
|
|
|
if(C.holder)
|
|
if(holder) //both are admins
|
|
C << "<font color='red'>Admin PM from-<b>[key_name(src, C, 1)]</b>: [msg]</font>"
|
|
src << "<font color='blue'>Admin PM to-<b>[key_name(C, src, 1)]</b>: [msg]</font>"
|
|
|
|
else //recipient is an admin but sender is not
|
|
C << "<font color='red'>Reply PM from-<b>[key_name(src, C, 1)]</b>: [msg]</font>"
|
|
src << "<font color='blue'>PM to-<b>Admins</b>: [msg]</font>"
|
|
|
|
//play the recieving admin the adminhelp sound (if they have them enabled)
|
|
if(C.sound_adminhelp)
|
|
C << 'adminhelp.ogg'
|
|
|
|
else
|
|
if(holder) //sender is an admin but recipient is not. Do BIG RED TEXT
|
|
C << "<font color='red' size='4'><b>-- Administrator private message --</b></font>"
|
|
C << "<font color='red'>Admin PM from-<b>[key_name(src, C, 0)]</b>: [msg]</font>"
|
|
C << "<font color='red'><i>Click on the administrator's name to reply.</i></font>"
|
|
src << "<font color='blue'>Admin PM to-<b>[key_name(C, src, 1)]</b>: [msg]</font>"
|
|
|
|
//always play non-admin recipients the adminhelp sound
|
|
C << 'adminhelp.ogg'
|
|
|
|
//AdminPM popup for ApocStation and anybody else who wants to use it. Set it with POPUP_ADMIN_PM in config.txt ~Carn
|
|
if(config.popup_admin_pm)
|
|
spawn() //so we don't hold the caller proc up
|
|
var/sender = src
|
|
var/sendername = key
|
|
var/reply = input(C, msg,"Admin PM from-[sendername]", "") as text|null //show message and await a reply
|
|
if(C && reply)
|
|
if(sender)
|
|
C.cmd_admin_pm(sender,reply) //sender is still about, let's reply to them
|
|
else
|
|
adminhelp(reply) //sender has left, adminhelp instead
|
|
return
|
|
|
|
else //neither are admins
|
|
src << "<font color='red'>Error: Admin-PM: Non-admin to non-admin PM communication is forbidden.</font>"
|
|
return
|
|
|
|
log_admin("PM: [key_name(src)]->[key_name(C)]: [msg]")
|
|
|
|
//we don't use message_admins here because the sender/receiver might get it too
|
|
for(var/client/X) //there are fewer clients than mobs
|
|
if(X.holder && X.key!=key && X.key!=C.key) //check client/X is an admin and isn't the sender or recipient
|
|
X << "<B><font color='blue'>PM: [key_name(src, X, 0)]->[key_name(C, X, 0)]:</B> \blue [msg]</font>" //inform X
|