mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Merge branch 'master' of https://github.com/Yawn-Wider/YWPolarisVore into August2020UpstreamPull
August2020UpstreamPull
This commit is contained in:
@@ -237,6 +237,7 @@ var/list/gamemode_cache = list()
|
||||
var/static/dooc_allowed = 1
|
||||
var/static/dsay_allowed = 1
|
||||
|
||||
var/persistence_enabled = 1
|
||||
var/allow_byond_links = 1 //CHOMP Edit turned this on
|
||||
var/allow_discord_links = 1 //CHOMP Edit turned this on
|
||||
var/allow_url_links = 1 // honestly if I were you i'd leave this one off, only use in dire situations //CHOMP Edit bussy.
|
||||
@@ -581,6 +582,9 @@ var/list/gamemode_cache = list()
|
||||
if("protect_roles_from_antagonist")
|
||||
config.protect_roles_from_antagonist = 1
|
||||
|
||||
if ("persistence_enabled")
|
||||
config.persistence_enabled = 1
|
||||
|
||||
if ("probability")
|
||||
var/prob_pos = findtext(value, " ")
|
||||
var/prob_name = null
|
||||
|
||||
@@ -188,7 +188,8 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
|
||||
to_chat(world, "<span class='boldannounce'>[msg]</span>")
|
||||
log_world(msg)
|
||||
|
||||
SERVER_TOOLS_CHAT_BROADCAST("Server Initialization completed!")
|
||||
|
||||
send2chat("Server Initialization completed! - Took [time] second[time == 1 ? "" : "s"].", "bot announce")
|
||||
|
||||
if (!current_runlevel)
|
||||
SetRunLevel(RUNLEVEL_LOBBY)
|
||||
|
||||
@@ -32,7 +32,7 @@ SUBSYSTEM_DEF(ai)
|
||||
while(currentrun.len)
|
||||
var/datum/ai_holder/A = currentrun[currentrun.len]
|
||||
--currentrun.len
|
||||
if(!A || QDELETED(A) || A.busy) // Doesn't exist or won't exist soon or not doing it this tick
|
||||
if(!A || QDELETED(A) || !A.holder?.loc || A.busy) // Doesn't exist or won't exist soon or not doing it this tick
|
||||
continue
|
||||
|
||||
if(process_z[get_z(A.holder)])
|
||||
|
||||
35
code/controllers/subsystems/discord.dm
Normal file
35
code/controllers/subsystems/discord.dm
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Sends a message to TGS chat channels.
|
||||
*
|
||||
* message - The message to send.
|
||||
* channel_tag - Required. If "", the message with be sent to all connected (Game-type for TGS3) channels. Otherwise, it will be sent to TGS4 channels with that tag (Delimited by ','s).
|
||||
*/
|
||||
/proc/send2chat(message, channel_tag)
|
||||
if(channel_tag == null || !world.TgsAvailable())
|
||||
return
|
||||
|
||||
var/datum/tgs_version/version = world.TgsVersion()
|
||||
if(channel_tag == "" || version.suite == 3)
|
||||
world.TgsTargetedChatBroadcast(message, FALSE)
|
||||
return
|
||||
|
||||
var/list/channels_to_use = list()
|
||||
for(var/I in world.TgsChatChannelInfo())
|
||||
var/datum/tgs_chat_channel/channel = I
|
||||
var/list/applicable_tags = splittext(channel.tag, ",")
|
||||
if(channel_tag in applicable_tags)
|
||||
channels_to_use += channel
|
||||
|
||||
if(channels_to_use.len)
|
||||
world.TgsChatBroadcast(message, channels_to_use)
|
||||
|
||||
/**
|
||||
* Sends a message to TGS admin chat channels.
|
||||
*
|
||||
* category - The category of the mssage.
|
||||
* message - The message to send.
|
||||
*/
|
||||
/proc/send2adminchat(category, message)
|
||||
category = replacetext(replacetext(category, "\proper", ""), "\improper", "")
|
||||
message = replacetext(replacetext(message, "\proper", ""), "\improper", "")
|
||||
world.TgsTargetedChatBroadcast("[category] | [message]", TRUE)
|
||||
@@ -43,7 +43,7 @@ SUBSYSTEM_DEF(mobs)
|
||||
if(!M || QDELETED(M))
|
||||
mob_list -= M
|
||||
continue
|
||||
else if(M.low_priority && !(process_z[get_z(M)]))
|
||||
else if(M.low_priority && !(M.loc && process_z[get_z(M)]))
|
||||
slept_mobs++
|
||||
continue
|
||||
|
||||
|
||||
59
code/controllers/subsystems/persistence.dm
Normal file
59
code/controllers/subsystems/persistence.dm
Normal file
@@ -0,0 +1,59 @@
|
||||
SUBSYSTEM_DEF(persistence)
|
||||
name = "Persistence"
|
||||
init_order = INIT_ORDER_PERSISTENCE
|
||||
flags = SS_NO_FIRE
|
||||
var/list/tracking_values = list()
|
||||
var/list/persistence_datums = list()
|
||||
|
||||
/datum/controller/subsystem/persistence/Initialize()
|
||||
. = ..()
|
||||
for(var/thing in subtypesof(/datum/persistent))
|
||||
var/datum/persistent/P = new thing
|
||||
persistence_datums[thing] = P
|
||||
P.Initialize()
|
||||
|
||||
/datum/controller/subsystem/persistence/Shutdown()
|
||||
for(var/thing in persistence_datums)
|
||||
var/datum/persistent/P = persistence_datums[thing]
|
||||
P.Shutdown()
|
||||
|
||||
/datum/controller/subsystem/persistence/proc/track_value(var/atom/value, var/track_type)
|
||||
|
||||
if(config.persistence_enabled == 0) //if the config is not set to persistent nothing will save or load.
|
||||
return
|
||||
|
||||
var/turf/T = get_turf(value)
|
||||
if(!T)
|
||||
return
|
||||
|
||||
var/area/A = get_area(T)
|
||||
if(!A || (A.flags & AREA_FLAG_IS_NOT_PERSISTENT))
|
||||
return
|
||||
|
||||
// if((!T.z in GLOB.using_map.station_levels) || !initialized)
|
||||
if(!T.z in using_map.station_levels)
|
||||
return
|
||||
|
||||
if(!tracking_values[track_type])
|
||||
tracking_values[track_type] = list()
|
||||
tracking_values[track_type] += value
|
||||
|
||||
/datum/controller/subsystem/persistence/proc/forget_value(var/atom/value, var/track_type)
|
||||
if(tracking_values[track_type])
|
||||
tracking_values[track_type] -= value
|
||||
|
||||
|
||||
/datum/controller/subsystem/persistence/proc/show_info(var/mob/user)
|
||||
if(!user.client.holder)
|
||||
return
|
||||
|
||||
var/list/dat = list("<table width = '100%'>")
|
||||
var/can_modify = check_rights(R_ADMIN, 0, user)
|
||||
for(var/thing in persistence_datums)
|
||||
var/datum/persistent/P = persistence_datums[thing]
|
||||
if(P.has_admin_data)
|
||||
dat += P.GetAdminSummary(user, can_modify)
|
||||
dat += "</table>"
|
||||
var/datum/browser/popup = new(user, "admin_persistence", "Persistence Data")
|
||||
popup.set_content(jointext(dat, null))
|
||||
popup.open()
|
||||
@@ -132,7 +132,7 @@ SUBSYSTEM_DEF(skybox)
|
||||
for(var/z in zlevels)
|
||||
skybox_cache["[z]"] = generate_skybox(z)
|
||||
|
||||
for(var/client/C)
|
||||
for(var/client/C in GLOB.clients)
|
||||
var/their_z = get_z(C.mob)
|
||||
if(!their_z) //Nullspace
|
||||
continue
|
||||
|
||||
343
code/controllers/subsystems/tgui.dm
Normal file
343
code/controllers/subsystems/tgui.dm
Normal file
@@ -0,0 +1,343 @@
|
||||
/**
|
||||
* tgui subsystem
|
||||
*
|
||||
* Contains all tgui state and subsystem code.
|
||||
**/
|
||||
|
||||
|
||||
SUBSYSTEM_DEF(tgui)
|
||||
name = "TGUI"
|
||||
wait = 9
|
||||
flags = SS_NO_INIT
|
||||
priority = FIRE_PRIORITY_TGUI
|
||||
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT
|
||||
|
||||
/// A list of UIs scheduled to process
|
||||
var/list/current_run = list()
|
||||
/// A list of open UIs
|
||||
var/list/open_uis = list()
|
||||
/// A list of open UIs, grouped by src_object and ui_key.
|
||||
var/list/open_uis_by_src = list()
|
||||
/// The HTML base used for all UIs.
|
||||
var/basehtml
|
||||
|
||||
/datum/controller/subsystem/tgui/PreInit()
|
||||
basehtml = file2text('tgui/packages/tgui/public/tgui.html')
|
||||
|
||||
/datum/controller/subsystem/tgui/Shutdown()
|
||||
close_all_uis()
|
||||
|
||||
/datum/controller/subsystem/tgui/stat_entry()
|
||||
..("P:[open_uis.len]")
|
||||
|
||||
/datum/controller/subsystem/tgui/fire(resumed = 0)
|
||||
if(!resumed)
|
||||
src.current_run = open_uis.Copy()
|
||||
// Cache for sanic speed (lists are references anyways)
|
||||
var/list/current_run = src.current_run
|
||||
while(current_run.len)
|
||||
var/datum/tgui/ui = current_run[current_run.len]
|
||||
current_run.len--
|
||||
// TODO: Move user/src_object check to process()
|
||||
if(ui && ui.user && ui.src_object)
|
||||
ui.process()
|
||||
else
|
||||
open_uis.Remove(ui)
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* Requests a usable tgui window from the pool.
|
||||
* Returns null if pool was exhausted.
|
||||
*
|
||||
* required user mob
|
||||
* return datum/tgui
|
||||
*/
|
||||
/datum/controller/subsystem/tgui/proc/request_pooled_window(mob/user)
|
||||
if(!user.client)
|
||||
return null
|
||||
var/list/windows = user.client.tgui_windows
|
||||
var/window_id
|
||||
var/datum/tgui_window/window
|
||||
var/window_found = FALSE
|
||||
// Find a usable window
|
||||
for(var/i in 1 to TGUI_WINDOW_HARD_LIMIT)
|
||||
window_id = TGUI_WINDOW_ID(i)
|
||||
window = windows[window_id]
|
||||
// As we are looping, create missing window datums
|
||||
if(!window)
|
||||
window = new(user.client, window_id, pooled = TRUE)
|
||||
// Skip windows with acquired locks
|
||||
if(window.locked)
|
||||
continue
|
||||
if(window.status == TGUI_WINDOW_READY)
|
||||
return window
|
||||
if(window.status == TGUI_WINDOW_CLOSED)
|
||||
window.status = TGUI_WINDOW_LOADING
|
||||
window_found = TRUE
|
||||
break
|
||||
if(!window_found)
|
||||
return null
|
||||
return window
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* Force closes all tgui windows.
|
||||
*
|
||||
* required user mob
|
||||
*/
|
||||
/datum/controller/subsystem/tgui/proc/force_close_all_windows(mob/user)
|
||||
if(user.client)
|
||||
user.client.tgui_windows = list()
|
||||
for(var/i in 1 to TGUI_WINDOW_HARD_LIMIT)
|
||||
var/window_id = TGUI_WINDOW_ID(i)
|
||||
user << browse(null, "window=[window_id]")
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* Force closes the tgui window by window_id.
|
||||
*
|
||||
* required user mob
|
||||
* required window_id string
|
||||
*/
|
||||
/datum/controller/subsystem/tgui/proc/force_close_window(mob/user, window_id)
|
||||
// Close all tgui datums based on window_id.
|
||||
for(var/datum/tgui/ui in user.tgui_open_uis)
|
||||
if(ui.window && ui.window.id == window_id)
|
||||
ui.close(can_be_suspended = FALSE)
|
||||
// Unset machine just to be sure.
|
||||
user.unset_machine()
|
||||
// Close window directly just to be sure.
|
||||
user << browse(null, "window=[window_id]")
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* Get a open UI given a user, src_object, and ui_key and try to update it with data.
|
||||
*
|
||||
* required user mob The mob who opened/is using the UI.
|
||||
* required src_object datum The object/datum which owns the UI.
|
||||
* required ui_key string The ui_key of the UI.
|
||||
*
|
||||
* return datum/tgui The found UI.
|
||||
**/
|
||||
/datum/controller/subsystem/tgui/proc/try_update_ui(
|
||||
mob/user,
|
||||
datum/src_object,
|
||||
datum/tgui/ui)
|
||||
// Look up a UI if it wasn't passed.
|
||||
if(isnull(ui))
|
||||
ui = get_open_ui(user, src_object)
|
||||
// Couldn't find a UI.
|
||||
if(isnull(ui))
|
||||
return null
|
||||
ui.process_status()
|
||||
// UI ended up with the closed status
|
||||
// or is actively trying to close itself.
|
||||
// FIXME: Doesn't actually fix the paper bug.
|
||||
if(ui.status <= STATUS_CLOSE)
|
||||
ui.close()
|
||||
return null
|
||||
ui.send_update()
|
||||
return ui
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Get a open UI given a user, src_object, and ui_key.
|
||||
*
|
||||
* required user mob The mob who opened/is using the UI.
|
||||
* required src_object datum The object/datum which owns the UI.
|
||||
* required ui_key string The ui_key of the UI.
|
||||
*
|
||||
* return datum/tgui The found UI.
|
||||
**/
|
||||
/datum/controller/subsystem/tgui/proc/get_open_ui(mob/user, datum/src_object)
|
||||
var/key = "[REF(src_object)]"
|
||||
// No UIs opened for this src_object
|
||||
if(isnull(open_uis_by_src[key]) || !istype(open_uis_by_src[key], /list))
|
||||
return null // No UIs open.
|
||||
for(var/datum/tgui/ui in open_uis_by_src[key]) // Find UIs for this object.
|
||||
// Make sure we have the right user
|
||||
if(ui.user == user)
|
||||
return ui
|
||||
return null // Couldn't find a UI!
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Update all UIs attached to src_object.
|
||||
*
|
||||
* required src_object datum The object/datum which owns the UIs.
|
||||
*
|
||||
* return int The number of UIs updated.
|
||||
**/
|
||||
/datum/controller/subsystem/tgui/proc/update_uis(datum/src_object)
|
||||
var/count = 0
|
||||
var/key = "[REF(src_object)]"
|
||||
if(isnull(open_uis_by_src[key]) || !istype(open_uis_by_src[key], /list))
|
||||
return count // Couldn't find any UIs for this object.
|
||||
for(var/datum/tgui/ui in open_uis_by_src[key])
|
||||
// Check the UI is valid.
|
||||
if(ui && ui.src_object && ui.user && ui.src_object.tgui_host(ui.user))
|
||||
ui.process(force = 1) // Update the UI.
|
||||
count++ // Count each UI we update.
|
||||
return count
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Close all UIs attached to src_object.
|
||||
*
|
||||
* required src_object datum The object/datum which owns the UIs.
|
||||
*
|
||||
* return int The number of UIs closed.
|
||||
**/
|
||||
/datum/controller/subsystem/tgui/proc/close_uis(datum/src_object)
|
||||
var/count = 0
|
||||
var/key = "[REF(src_object)]"
|
||||
// No UIs opened for this src_object
|
||||
if(isnull(open_uis_by_src[key]) || !istype(open_uis_by_src[key], /list))
|
||||
return count
|
||||
for(var/datum/tgui/ui in open_uis_by_src[key])
|
||||
if(ui && ui.src_object && ui.user && ui.src_object.tgui_host(ui.user)) // Check the UI is valid.
|
||||
ui.close() // Close the UI.
|
||||
count++ // Count each UI we close.
|
||||
return count
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Close all UIs regardless of their attachment to src_object.
|
||||
*
|
||||
* return int The number of UIs closed.
|
||||
**/
|
||||
/datum/controller/subsystem/tgui/proc/close_all_uis()
|
||||
var/count = 0
|
||||
for(var/key in open_uis_by_src)
|
||||
for(var/datum/tgui/ui in open_uis_by_src[key])
|
||||
if(ui && ui.src_object && ui.user && ui.src_object.tgui_host(ui.user)) // Check the UI is valid.
|
||||
ui.close() // Close the UI.
|
||||
count++ // Count each UI we close.
|
||||
return count
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Update all UIs belonging to a user.
|
||||
*
|
||||
* required user mob The mob who opened/is using the UI.
|
||||
* optional src_object datum If provided, only update UIs belonging this src_object.
|
||||
*
|
||||
* return int The number of UIs updated.
|
||||
**/
|
||||
/datum/controller/subsystem/tgui/proc/update_user_uis(mob/user, datum/src_object)
|
||||
var/count = 0
|
||||
if(length(user?.tgui_open_uis) == 0)
|
||||
return count
|
||||
for(var/datum/tgui/ui in user.tgui_open_uis)
|
||||
if(isnull(src_object) || ui.src_object == src_object)
|
||||
ui.process(force = 1)
|
||||
count++
|
||||
return count
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Close all UIs belonging to a user.
|
||||
*
|
||||
* required user mob The mob who opened/is using the UI.
|
||||
* optional src_object datum If provided, only close UIs belonging this src_object.
|
||||
*
|
||||
* return int The number of UIs closed.
|
||||
**/
|
||||
/datum/controller/subsystem/tgui/proc/close_user_uis(mob/user, datum/src_object)
|
||||
var/count = 0
|
||||
if(length(user?.tgui_open_uis) == 0)
|
||||
return count
|
||||
for(var/datum/tgui/ui in user.tgui_open_uis)
|
||||
if(isnull(src_object) || ui.src_object == src_object)
|
||||
ui.close()
|
||||
count++
|
||||
return count
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Add a UI to the list of open UIs.
|
||||
*
|
||||
* required ui datum/tgui The UI to be added.
|
||||
**/
|
||||
/datum/controller/subsystem/tgui/proc/on_open(datum/tgui/ui)
|
||||
var/key = "[REF(ui.src_object)]"
|
||||
if(isnull(open_uis_by_src[key]) || !istype(open_uis_by_src[key], /list))
|
||||
open_uis_by_src[key] = list()
|
||||
ui.user.tgui_open_uis |= ui
|
||||
var/list/uis = open_uis_by_src[key]
|
||||
uis |= ui
|
||||
open_uis |= ui
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Remove a UI from the list of open UIs.
|
||||
*
|
||||
* required ui datum/tgui The UI to be removed.
|
||||
*
|
||||
* return bool If the UI was removed or not.
|
||||
**/
|
||||
/datum/controller/subsystem/tgui/proc/on_close(datum/tgui/ui)
|
||||
var/key = "[REF(ui.src_object)]"
|
||||
if(isnull(open_uis_by_src[key]) || !istype(open_uis_by_src[key], /list))
|
||||
return FALSE
|
||||
// Remove it from the list of processing UIs.
|
||||
open_uis.Remove(ui)
|
||||
// If the user exists, remove it from them too.
|
||||
if(ui.user)
|
||||
ui.user.tgui_open_uis.Remove(ui)
|
||||
var/list/uis = open_uis_by_src[key]
|
||||
uis.Remove(ui)
|
||||
if(length(uis) == 0)
|
||||
open_uis_by_src.Remove(key)
|
||||
return TRUE
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Handle client logout, by closing all their UIs.
|
||||
*
|
||||
* required user mob The mob which logged out.
|
||||
*
|
||||
* return int The number of UIs closed.
|
||||
**/
|
||||
/datum/controller/subsystem/tgui/proc/on_logout(mob/user)
|
||||
return close_user_uis(user)
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Handle clients switching mobs, by transferring their UIs.
|
||||
*
|
||||
* required user source The client's original mob.
|
||||
* required user target The client's new mob.
|
||||
*
|
||||
* return bool If the UIs were transferred.
|
||||
**/
|
||||
/datum/controller/subsystem/tgui/proc/on_transfer(mob/source, mob/target)
|
||||
// The old mob had no open UIs.
|
||||
if(length(source?.tgui_open_uis) == 0)
|
||||
return FALSE
|
||||
if(isnull(target.tgui_open_uis) || !istype(target.tgui_open_uis, /list))
|
||||
target.tgui_open_uis = list()
|
||||
// Transfer all the UIs.
|
||||
for(var/datum/tgui/ui in source.tgui_open_uis)
|
||||
// Inform the UIs of their new owner.
|
||||
ui.user = target
|
||||
target.tgui_open_uis.Add(ui)
|
||||
// Clear the old list.
|
||||
source.tgui_open_uis.Cut()
|
||||
return TRUE
|
||||
@@ -261,6 +261,8 @@ var/global/datum/controller/subsystem/ticker/ticker
|
||||
to_world("<span class='notice'><b>An admin has delayed the round end.</b></span>")
|
||||
end_game_state = END_GAME_DELAYED
|
||||
else if(restart_timeleft <= 0)
|
||||
to_world("<span class='warning'><b>Restarting world!</b></span>")
|
||||
sleep(5)
|
||||
world.Reboot()
|
||||
else if (world.time - last_restart_notify >= 1 MINUTE)
|
||||
to_world("<span class='notice'><b>Restarting in [round(restart_timeleft/600, 1)] minute\s.</b></span>")
|
||||
|
||||
Reference in New Issue
Block a user