Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mob/Machine/Object Processing Subsystems #3559

Merged
merged 9 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 6 additions & 4 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "code\__datastructures\stack.dm"
#include "code\__defines\_compile_options.dm"
#include "code\__defines\_planes+layers.dm"
#include "code\__defines\_tick.dm"
#include "code\__defines\admin.dm"
#include "code\__defines\ai_routing_access.dm"
#include "code\__defines\ao.dm"
Expand All @@ -46,7 +47,6 @@
#include "code\__defines\machinery.dm"
#include "code\__defines\mapping.dm"
#include "code\__defines\materials.dm"
#include "code\__defines\math.dm"
#include "code\__defines\math_physics.dm"
#include "code\__defines\MC.dm"
#include "code\__defines\misc.dm"
Expand Down Expand Up @@ -167,9 +167,6 @@
#include "code\controllers\Processes\alarm.dm"
#include "code\controllers\Processes\chemistry.dm"
#include "code\controllers\Processes\emergencyShuttle.dm"
#include "code\controllers\Processes\machinery.dm"
#include "code\controllers\Processes\mob.dm"
#include "code\controllers\Processes\obj.dm"
#include "code\controllers\Processes\radiation.dm"
#include "code\controllers\Processes\scheduler.dm"
#include "code\controllers\Processes\Shuttle.dm"
Expand All @@ -190,11 +187,15 @@
#include "code\controllers\subsystems\inactivity.dm"
#include "code\controllers\subsystems\legacy.dm"
#include "code\controllers\subsystems\lighting.dm"
#include "code\controllers\subsystems\machines.dm"
#include "code\controllers\subsystems\profiler.dm"
#include "code\controllers\subsystems\sun.dm"
#include "code\controllers\subsystems\trade.dm"
#include "code\controllers\subsystems\processing\airflow.dm"
#include "code\controllers\subsystems\processing\fastprocess.dm"
#include "code\controllers\subsystems\processing\mobs.dm"
#include "code\controllers\subsystems\processing\nano.dm"
#include "code\controllers\subsystems\processing\obj.dm"
#include "code\controllers\subsystems\processing\processing.dm"
#include "code\controllers\voting\_vote.dm"
#include "code\controllers\voting\announce_result.dm"
Expand Down Expand Up @@ -401,6 +402,7 @@
#include "code\game\shuttle_engines.dm"
#include "code\game\sound.dm"
#include "code\game\supplyshuttle.dm"
#include "code\game\world.dm"
#include "code\game\antagonist\_antagonist_setup.dm"
#include "code\game\antagonist\antagonist.dm"
#include "code\game\antagonist\antagonist_add.dm"
Expand Down
21 changes: 8 additions & 13 deletions code/__defines/MC.dm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#define MC_TICK_CHECK ( ( world.tick_usage > Master.current_ticklimit || src.state != SS_RUNNING ) ? pause() : 0 )
#define MC_TICK_CHECK ( ( TICK_USAGE > Master.current_ticklimit || src.state != SS_RUNNING ) ? pause() : 0 )

#define MC_SPLIT_TICK_INIT(phase_count) var/original_tick_limit = Master.current_ticklimit; var/split_tick_phases = ##phase_count
#define MC_SPLIT_TICK \
if(split_tick_phases > 1){\
Master.current_ticklimit = ((original_tick_limit - world.tick_usage) / split_tick_phases) + world.tick_usage;\
Master.current_ticklimit = ((original_tick_limit - TICK_USAGE) / split_tick_phases) + TICK_USAGE;\
--split_tick_phases;\
} else {\
Master.current_ticklimit = original_tick_limit;\
Expand All @@ -20,17 +20,7 @@
#define NEW_SS_GLOBAL(varname) if(varname != src){if(istype(varname)){Recover();qdel(varname);}varname = src;}

/// Register a datum to be processed with a processing subsystem.
#define START_PROCESSING(Processor, Datum) \
if (Datum.is_processing) {\
if(Datum.is_processing != #Processor)\
{\
crash_with("Failed to start processing. [log_info_line(Datum)] is already being processed by [Datum.is_processing] but queue attempt occured on [#Processor]."); \
}\
} else {\
Datum.is_processing = #Processor;\
Processor.processing += Datum;\
}

#define START_PROCESSING(Processor, Datum) if (!Datum.is_processing) {Datum.is_processing = #Processor;Processor.processing += Datum}
/// Unregister a datum with a processing subsystem.
#define STOP_PROCESSING(Processor, Datum) \
if(Datum.is_processing) {\
Expand Down Expand Up @@ -94,4 +84,9 @@ if(Datum.is_processing) {\
NEW_SS_GLOBAL(SS##X);\
PreInit();\
}\
/datum/controller/subsystem/processing/##X/Recover() {\
if(istype(SS##X.processing)) {\
processing = SS##X.processing; \
}\
}\
/datum/controller/subsystem/processing/##X
21 changes: 21 additions & 0 deletions code/__defines/_tick.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#define TICK_LIMIT_RUNNING 80
#define TICK_LIMIT_TO_RUN 78
#define TICK_LIMIT_MC 70
#define TICK_LIMIT_MC_INIT_DEFAULT 98

#define TICK_USAGE world.tick_usage //for general usage
#define TICK_USAGE_REAL world.tick_usage //to be used where the result isn't checked

#define TICK_CHECK ( TICK_USAGE > Master.current_ticklimit )
#define CHECK_TICK if TICK_CHECK stoplag()

//"fancy" math for calculating time in ms from tick_usage percentage and the length of ticks
//percent_of_tick_used * (ticklag * 100(to convert to ms)) / 100(percent ratio)
//collapsed to percent_of_tick_used * tick_lag
#define TICK_DELTA_TO_MS(percent_of_tick_used) ((percent_of_tick_used) * world.tick_lag)
#define TICK_USAGE_TO_MS(starting_tickusage) (TICK_DELTA_TO_MS(TICK_USAGE_REAL - starting_tickusage))

//time of day but automatically adjusts to the server going into the next day within the same round.
//for when you need a reliable time number that doesn't depend on byond time.
#define REALTIMEOFDAY (world.timeofday + (MIDNIGHT_ROLLOVER * MIDNIGHT_ROLLOVER_CHECK))
#define MIDNIGHT_ROLLOVER_CHECK ( GLOB.rollovercheck_last_timeofday != world.timeofday ? update_midnight_rollover() : GLOB.midnight_rollovers )
10 changes: 0 additions & 10 deletions code/__defines/math.dm

This file was deleted.

6 changes: 6 additions & 0 deletions code/__defines/qdel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
//if TESTING is enabled, qdel will call this object's find_references() verb.
//defines for the gc_destroyed var


#define GC_QUEUE_PREQUEUE 1
#define GC_QUEUE_CHECK 2
#define GC_QUEUE_HARDDELETE 3
#define GC_QUEUE_COUNT 3 //increase this when adding more steps.

#define GC_QUEUED_FOR_QUEUING -1
#define GC_QUEUED_FOR_HARD_DEL -2
#define GC_CURRENTLY_BEING_QDELETED -3
Expand Down
2 changes: 0 additions & 2 deletions code/_global_vars/lists/logs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ GLOBAL_LIST_EMPTY(bombers)
GLOBAL_LIST_EMPTY(admin_log)
GLOBAL_LIST_EMPTY(lastsignalers) // Keeps last 100 signals here in format: "[src] used \ref[src] @ location [src.loc]: [freq]/[code]"
GLOBAL_LIST_EMPTY(lawchanges) // Stores who uploaded laws to which silicon-based lifeform, and what the law was.
GLOBAL_VAR(world_runtime_log)
GLOBAL_PROTECT(world_runtime_log)
4 changes: 0 additions & 4 deletions code/_global_vars/lists/objects.dm
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
GLOBAL_DATUM(data_core, /datum/datacore)
// Items that ask to be called every cycle.
GLOBAL_LIST_EMPTY(machines)
GLOBAL_LIST_EMPTY(processing_objects)
GLOBAL_LIST_EMPTY(processing_power_items)
GLOBAL_LIST_EMPTY(active_diseases)
GLOBAL_LIST_EMPTY(med_hud_users) // List of all entities using a medical HUD.
GLOBAL_LIST_EMPTY(sec_hud_users) // List of all entities using a security HUD.
GLOBAL_LIST_EMPTY(hud_icon_reference)
GLOBAL_LIST_EMPTY(traders) //List of all nearby traders

GLOBAL_LIST_EMPTY(listening_objects) // List of objects that need to be able to hear, used to avoid recursive searching through contents.
GLOBAL_LIST_EMPTY(powernets)

GLOBAL_LIST_EMPTY(global_mutations) // List of hidden mutation things.

Expand Down
4 changes: 4 additions & 0 deletions code/_global_vars/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ var/diary = null

GLOBAL_VAR(log_directory)
GLOBAL_PROTECT(log_directory)
GLOBAL_VAR(world_runtime_log)
GLOBAL_PROTECT(world_runtime_log)
GLOBAL_VAR(world_qdel_log)
GLOBAL_PROTECT(world_qdel_log)
1 change: 0 additions & 1 deletion code/_global_vars/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ GLOBAL_LIST_EMPTY(ckey_directory) //all ckeys with associated client


GLOBAL_LIST_EMPTY(player_list) //List of all mobs **with clients attached**. Excludes /mob/new_player
GLOBAL_LIST_EMPTY(mob_list) //List of all mobs, including clientless
GLOBAL_LIST_EMPTY(human_mob_list) //List of all human mobs and sub-types, including clientless
GLOBAL_LIST_EMPTY(silicon_mob_list) //List of all silicon mobs, including clientless
GLOBAL_LIST_EMPTY(living_mob_list_) //List of all alive mobs, including clientless. Excludes /mob/new_player
Expand Down
44 changes: 39 additions & 5 deletions code/_helpers/cmp.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/proc/cmp_numeric_asc(a,b)
return a - b

/proc/cmp_crew_sensor_modifier(var/crew_sensor_modifier/a, var/crew_sensor_modifier/b)
/proc/cmp_appearance_data(var/datum/appearance_data/a, var/datum/appearance_data/b)
return b.priority - a.priority

/proc/cmp_appearance_data(var/datum/appearance_data/a, var/datum/appearance_data/b)
/proc/cmp_camera_ctag_asc(var/obj/machinery/camera/a, var/obj/machinery/camera/b)
return sorttext(b.c_tag, a.c_tag)

/proc/cmp_camera_ctag_dsc(var/obj/machinery/camera/a, var/obj/machinery/camera/b)
return sorttext(a.c_tag, b.c_tag)

/proc/cmp_crew_sensor_modifier(var/crew_sensor_modifier/a, var/crew_sensor_modifier/b)
return b.priority - a.priority

/proc/cmp_follow_holder(var/datum/follow_holder/a, var/datum/follow_holder/b)
Expand All @@ -13,11 +17,41 @@

return a.sort_order - b.sort_order

/proc/cmp_name_or_type_asc(atom/a, atom/b)
return sorttext(istype(b) || ("name" in b.vars) ? b.name : b.type, istype(a) || ("name" in a.vars) ? a.name : a.type)

/proc/cmp_name_asc(atom/a, atom/b)
return sorttext(b.name, a.name)

/proc/cmp_name_dsc(atom/a, atom/b)
return sorttext(a.name, b.name)

/proc/cmp_numeric_asc(a,b)
return a - b

/proc/cmp_subsystem_display(datum/controller/subsystem/a, datum/controller/subsystem/b)
return sorttext(b.name, a.name)

/proc/cmp_subsystem_init(datum/controller/subsystem/a, datum/controller/subsystem/b)
return b.init_order - a.init_order
var/a_init_order = ispath(a) ? initial(a.init_order) : a.init_order
var/b_init_order = ispath(b) ? initial(b.init_order) : b.init_order

return b_init_order - a_init_order //uses initial() so it can be used on types

/proc/cmp_subsystem_priority(datum/controller/subsystem/a, datum/controller/subsystem/b)
return a.priority - b.priority

/proc/cmp_text_asc(a,b)
return sorttext(b, a)

/proc/cmp_text_dsc(a,b)
return sorttext(a, b)

/proc/cmp_qdel_item_time(datum/qdel_item/A, datum/qdel_item/B)
. = B.hard_delete_time - A.hard_delete_time
if (!.)
. = B.destroy_time - A.destroy_time
if (!.)
. = B.failures - A.failures
if (!.)
. = B.qdels - A.qdels
2 changes: 1 addition & 1 deletion code/_helpers/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ proc/isInSight(var/atom/A, var/atom/B)
return get_step(start, EAST)

/proc/get_mob_by_key(var/key)
for(var/mob/M in GLOB.mob_list)
for(var/mob/M in SSmobs.mob_list)
if(M.ckey == lowertext(key))
return M
return null
Expand Down
Loading
Loading