Merge pull request #2167 from Aurorastation/map-development

New Map Meme is Real
This commit is contained in:
skull132
2017-05-03 22:04:39 +03:00
committed by GitHub
1061 changed files with 42025 additions and 14410 deletions
+4
View File
@@ -6,9 +6,13 @@ Thumbs.db
*.dmb
*.lk
*.backup
*.before
data/
cfg/
build_log.txt
__pycache__/
*.py[cod]
*$py.class
/.atom-build.json
.vscode/
-1
View File
@@ -43,4 +43,3 @@ script:
- DreamDaemon baystation12.dmb -invisible -trusted -core 2>&1 | tee log.txt
- grep "All Unit Tests Passed" log.txt
- (! grep "runtime error:" log.txt)
- (! grep 'Process scheduler caught exception processing' log.txt)
+108 -55
View File
@@ -17,27 +17,35 @@
#include "code\stylesheet.dm"
#include "code\world.dm"
#include "code\__defines\_compile_options.dm"
#include "code\__defines\_layers.dm"
#include "code\__defines\admin.dm"
#include "code\__defines\atmos.dm"
#include "code\__defines\btime.dm"
#include "code\__defines\callback.dm"
#include "code\__defines\chemistry.dm"
#include "code\__defines\damage_organs.dm"
#include "code\__defines\dna.dm"
#include "code\__defines\dview.dm"
#include "code\__defines\gamemode.dm"
#include "code\__defines\hydroponics.dm"
#include "code\__defines\items_clothing.dm"
#include "code\__defines\lighting.dm"
#include "code\__defines\lists.dm"
#include "code\__defines\machinery.dm"
#include "code\__defines\master_controller.dm"
#include "code\__defines\math_physics.dm"
#include "code\__defines\mining.dm"
#include "code\__defines\misc.dm"
#include "code\__defines\mobs.dm"
#include "code\__defines\process_scheduler.dm"
#include "code\__defines\qdel.dm"
#include "code\__defines\radio.dm"
#include "code\__defines\regex.dm"
#include "code\__defines\research.dm"
#include "code\__defines\species_languages.dm"
#include "code\__defines\subsystem-defines.dm"
#include "code\__defines\subsystem-priority.dm"
#include "code\__defines\targeting.dm"
#include "code\__defines\turfs.dm"
#include "code\__defines\ZAS.dm"
#include "code\_helpers\areas.dm"
#include "code\_helpers\atmospherics.dm"
#include "code\_helpers\datum_pool.dm"
@@ -45,6 +53,7 @@
#include "code\_helpers\functional.dm"
#include "code\_helpers\game.dm"
#include "code\_helpers\global_lists.dm"
#include "code\_helpers\icon_smoothing.dm"
#include "code\_helpers\icons.dm"
#include "code\_helpers\items.dm"
#include "code\_helpers\lists.dm"
@@ -62,6 +71,9 @@
#include "code\_helpers\type2type.dm"
#include "code\_helpers\unsorted.dm"
#include "code\_helpers\vector.dm"
#include "code\_helpers\sorting\__main.dm"
#include "code\_helpers\sorting\cmp.dm"
#include "code\_helpers\sorting\TimSort.dm"
#include "code\_onclick\adjacent.dm"
#include "code\_onclick\ai.dm"
#include "code\_onclick\click.dm"
@@ -119,61 +131,80 @@
#include "code\ATMOSPHERICS\components\unary\unary_base.dm"
#include "code\ATMOSPHERICS\components\unary\vent_pump.dm"
#include "code\ATMOSPHERICS\components\unary\vent_scrubber.dm"
#include "code\controllers\autotransfer.dm"
#include "code\controllers\communications.dm"
#include "code\controllers\configuration.dm"
#include "code\controllers\emergency_shuttle_controller.dm"
#include "code\controllers\controller.dm"
#include "code\controllers\hooks-defs.dm"
#include "code\controllers\hooks.dm"
#include "code\controllers\law.dm"
#include "code\controllers\master_controller.dm"
#include "code\controllers\shuttle_controller.dm"
#include "code\controllers\subsystems.dm"
#include "code\controllers\verbs.dm"
#include "code\controllers\voting.dm"
#include "code\controllers\Processes\air.dm"
#include "code\controllers\Processes\alarm.dm"
#include "code\controllers\Processes\chemistry.dm"
#include "code\controllers\Processes\disease.dm"
#include "code\controllers\Processes\effects.dm"
#include "code\controllers\Processes\emergencyShuttle.dm"
#include "code\controllers\Processes\event.dm"
#include "code\controllers\Processes\explosives.dm"
#include "code\controllers\Processes\garbage.dm"
#include "code\controllers\Processes\inactivity.dm"
#include "code\controllers\Processes\lighting.dm"
#include "code\controllers\Processes\machinery.dm"
#include "code\controllers\Processes\mob.dm"
#include "code\controllers\Processes\modifier.dm"
#include "code\controllers\Processes\nanoui.dm"
#include "code\controllers\Processes\night_lighting.dm"
#include "code\controllers\Processes\obj.dm"
#include "code\controllers\Processes\scheduler.dm"
#include "code\controllers\Processes\Shuttle.dm"
#include "code\controllers\Processes\sun.dm"
#include "code\controllers\Processes\supply.dm"
#include "code\controllers\Processes\ticker.dm"
#include "code\controllers\Processes\turf.dm"
#include "code\controllers\Processes\vote.dm"
#include "code\controllers\Processes\wireless.dm"
#include "code\controllers\ProcessScheduler\core\_stubs.dm"
#include "code\controllers\ProcessScheduler\core\process.dm"
#include "code\controllers\ProcessScheduler\core\processScheduler.dm"
#include "code\controllers\master\admin.dm"
#include "code\controllers\master\failsafe.dm"
#include "code\controllers\master\master.dm"
#include "code\controllers\master\subsystem.dm"
#include "code\controllers\subsystems\air.dm"
#include "code\controllers\subsystems\alarm.dm"
#include "code\controllers\subsystems\arrivals.dm"
#include "code\controllers\subsystems\assets.dm"
#include "code\controllers\subsystems\chemistry.dm"
#include "code\controllers\subsystems\effects.dm"
#include "code\controllers\subsystems\emergency_shuttle.dm"
#include "code\controllers\subsystems\event.dm"
#include "code\controllers\subsystems\explosives.dm"
#include "code\controllers\subsystems\garbage-debug.dm"
#include "code\controllers\subsystems\garbage.dm"
#include "code\controllers\subsystems\icon_smooth.dm"
#include "code\controllers\subsystems\icon_updates.dm"
#include "code\controllers\subsystems\law.dm"
#include "code\controllers\subsystems\lighting.dm"
#include "code\controllers\subsystems\machinery.dm"
#include "code\controllers\subsystems\mob.dm"
#include "code\controllers\subsystems\nanoui.dm"
#include "code\controllers\subsystems\night_lighting.dm"
#include "code\controllers\subsystems\object.dm"
#include "code\controllers\subsystems\openturf.dm"
#include "code\controllers\subsystems\orbit.dm"
#include "code\controllers\subsystems\pai.dm"
#include "code\controllers\subsystems\parallax.dm"
#include "code\controllers\subsystems\radio.dm"
#include "code\controllers\subsystems\statistics.dm"
#include "code\controllers\subsystems\sun.dm"
#include "code\controllers\subsystems\supply.dm"
#include "code\controllers\subsystems\ticker.dm"
#include "code\controllers\subsystems\timer.dm"
#include "code\controllers\subsystems\vote.dm"
#include "code\controllers\subsystems\wireless.dm"
#include "code\controllers\subsystems\initialization\asteroid.dm"
#include "code\controllers\subsystems\initialization\atoms.dm"
#include "code\controllers\subsystems\initialization\misc_early.dm"
#include "code\controllers\subsystems\initialization\misc_late.dm"
#include "code\controllers\subsystems\initialization\xenoarch.dm"
#include "code\controllers\subsystems\processing\airflow.dm"
#include "code\controllers\subsystems\processing\calamity.dm"
#include "code\controllers\subsystems\processing\disease.dm"
#include "code\controllers\subsystems\processing\disposals.dm"
#include "code\controllers\subsystems\processing\fast_process.dm"
#include "code\controllers\subsystems\processing\modifiers.dm"
#include "code\controllers\subsystems\processing\overlays.dm"
#include "code\controllers\subsystems\processing\pipenet.dm"
#include "code\controllers\subsystems\processing\plants.dm"
#include "code\controllers\subsystems\processing\processing.dm"
#include "code\controllers\subsystems\processing\shuttle.dm"
#include "code\datums\ai_law_sets.dm"
#include "code\datums\ai_laws.dm"
#include "code\datums\api.dm"
#include "code\datums\beam.dm"
#include "code\datums\browser.dm"
#include "code\datums\callback.dm"
#include "code\datums\category.dm"
#include "code\datums\computerfiles.dm"
#include "code\datums\datacore.dm"
#include "code\datums\discord_bot.dm"
#include "code\datums\disease.dm"
#include "code\datums\feedback.dm"
#include "code\datums\mind.dm"
#include "code\datums\mixed.dm"
#include "code\datums\modules.dm"
#include "code\datums\scheduled_task.dm"
#include "code\datums\server_greeting.dm"
#include "code\datums\sun.dm"
#include "code\datums\supplypacks.dm"
#include "code\datums\diseases\appendicitis.dm"
#include "code\datums\diseases\beesease.dm"
@@ -231,6 +262,8 @@
#include "code\datums\observation\moved.dm"
#include "code\datums\observation\observation.dm"
#include "code\datums\observation\task_triggered.dm"
#include "code\datums\radio\frequency.dm"
#include "code\datums\radio\signal.dm"
#include "code\datums\repositories\cameras.dm"
#include "code\datums\repositories\crew.dm"
#include "code\datums\repositories\repository.dm"
@@ -273,8 +306,8 @@
#include "code\defines\procs\hud.dm"
#include "code\defines\procs\radio.dm"
#include "code\defines\procs\sd_Alert.dm"
#include "code\defines\procs\statistics.dm"
#include "code\game\atoms.dm"
#include "code\game\atoms_init.dm"
#include "code\game\atoms_movable.dm"
#include "code\game\base_turf.dm"
#include "code\game\periodic_news.dm"
@@ -318,6 +351,7 @@
#include "code\game\area\ai_monitored.dm"
#include "code\game\area\areas.dm"
#include "code\game\area\asteroid_areas.dm"
#include "code\game\area\aurora_lift_areas.dm"
#include "code\game\area\Space Station 13 areas.dm"
#include "code\game\dna\dna2.dm"
#include "code\game\dna\dna2_domutcheck.dm"
@@ -331,7 +365,6 @@
#include "code\game\gamemodes\events.dm"
#include "code\game\gamemodes\game_mode.dm"
#include "code\game\gamemodes\game_mode_latespawn.dm"
#include "code\game\gamemodes\gameticker.dm"
#include "code\game\gamemodes\objective.dm"
#include "code\game\gamemodes\setupgame.dm"
#include "code\game\gamemodes\calamity\calamity.dm"
@@ -423,6 +456,7 @@
#include "code\game\machinery\cell_charger.dm"
#include "code\game\machinery\cloning.dm"
#include "code\game\machinery\constructable_frame.dm"
#include "code\game\machinery\crusher_piston.dm"
#include "code\game\machinery\cryo.dm"
#include "code\game\machinery\cryopod.dm"
#include "code\game\machinery\deployable.dm"
@@ -442,6 +476,7 @@
#include "code\game\machinery\machinery.dm"
#include "code\game\machinery\magnet.dm"
#include "code\game\machinery\mass_driver.dm"
#include "code\game\machinery\megavend.dm"
#include "code\game\machinery\navbeacon.dm"
#include "code\game\machinery\newscaster.dm"
#include "code\game\machinery\nuclear_bomb.dm"
@@ -457,8 +492,8 @@
#include "code\game\machinery\spaceheater.dm"
#include "code\game\machinery\status_display.dm"
#include "code\game\machinery\status_display_ai.dm"
#include "code\game\machinery\status_display_snowflakes.dm"
#include "code\game\machinery\suit_storage_unit.dm"
#include "code\game\machinery\supply_display.dm"
#include "code\game\machinery\supplybeacon.dm"
#include "code\game\machinery\syndicatebeacon.dm"
#include "code\game\machinery\teleporter.dm"
@@ -500,7 +535,6 @@
#include "code\game\machinery\computer\Operating.dm"
#include "code\game\machinery\computer\pod.dm"
#include "code\game\machinery\computer\prisoner.dm"
#include "code\game\machinery\computer\prisonshuttle.dm"
#include "code\game\machinery\computer\RCON_Console.dm"
#include "code\game\machinery\computer\robot.dm"
#include "code\game\machinery\computer\security.dm"
@@ -748,6 +782,7 @@
#include "code\game\objects\items\weapons\circuitboards\machinery\research.dm"
#include "code\game\objects\items\weapons\circuitboards\machinery\shieldgen.dm"
#include "code\game\objects\items\weapons\circuitboards\machinery\telecomms.dm"
#include "code\game\objects\items\weapons\circuitboards\machinery\trashcompactor.dm"
#include "code\game\objects\items\weapons\circuitboards\machinery\unary_atmos.dm"
#include "code\game\objects\items\weapons\grenades\anti_photon_grenade.dm"
#include "code\game\objects\items\weapons\grenades\chem_grenade.dm"
@@ -797,6 +832,7 @@
#include "code\game\objects\items\weapons\tanks\tank_types.dm"
#include "code\game\objects\items\weapons\tanks\tanks.dm"
#include "code\game\objects\random\random.dm"
#include "code\game\objects\structures\banner.dm"
#include "code\game\objects\structures\barsign.dm"
#include "code\game\objects\structures\bedsheet_bin.dm"
#include "code\game\objects\structures\coathanger.dm"
@@ -1026,6 +1062,7 @@
#include "code\modules\cargo\randomstock.dm"
#include "code\modules\cciaa\cciaa.dm"
#include "code\modules\cciaa\cciaa_items.dm"
#include "code\modules\client\asset_cache.dm"
#include "code\modules\client\client defines.dm"
#include "code\modules\client\client procs.dm"
#include "code\modules\client\movement.dm"
@@ -1245,12 +1282,10 @@
#include "code\modules\holodeck\HolodeckObjects.dm"
#include "code\modules\holodeck\HolodeckPrograms.dm"
#include "code\modules\http\post_request.dm"
#include "code\modules\hydroponics\_hydro_setup.dm"
#include "code\modules\hydroponics\grown.dm"
#include "code\modules\hydroponics\grown_inedible.dm"
#include "code\modules\hydroponics\grown_predefined.dm"
#include "code\modules\hydroponics\seed.dm"
#include "code\modules\hydroponics\seed_controller.dm"
#include "code\modules\hydroponics\seed_datums.dm"
#include "code\modules\hydroponics\seed_machines.dm"
#include "code\modules\hydroponics\seed_mobs.dm"
@@ -1283,7 +1318,6 @@
#include "code\modules\lighting\lighting_corner.dm"
#include "code\modules\lighting\lighting_overlay.dm"
#include "code\modules\lighting\lighting_profiler.dm"
#include "code\modules\lighting\lighting_setup.dm"
#include "code\modules\lighting\lighting_source.dm"
#include "code\modules\lighting\lighting_turf.dm"
#include "code\modules\lighting\lighting_verbs.dm"
@@ -1302,10 +1336,13 @@
#include "code\modules\mining\coins.dm"
#include "code\modules\mining\machine_input_output_plates.dm"
#include "code\modules\mining\machine_processing.dm"
#include "code\modules\mining\machine_rigpress.dm"
#include "code\modules\mining\machine_stacking.dm"
#include "code\modules\mining\machine_unloading.dm"
#include "code\modules\mining\machine_vending.dm"
#include "code\modules\mining\mine_items.dm"
#include "code\modules\mining\mine_turfs.dm"
#include "code\modules\mining\minebot.dm"
#include "code\modules\mining\mineral_effect.dm"
#include "code\modules\mining\mint.dm"
#include "code\modules\mining\money_bag.dm"
@@ -1504,7 +1541,6 @@
#include "code\modules\mob\living\silicon\pai\life.dm"
#include "code\modules\mob\living\silicon\pai\pai.dm"
#include "code\modules\mob\living\silicon\pai\personality.dm"
#include "code\modules\mob\living\silicon\pai\recruit.dm"
#include "code\modules\mob\living\silicon\pai\say.dm"
#include "code\modules\mob\living\silicon\pai\software.dm"
#include "code\modules\mob\living\silicon\pai\software_modules.dm"
@@ -1576,6 +1612,7 @@
#include "code\modules\mob\living\simple_animal\hostile\commanded\_command_defines.dm"
#include "code\modules\mob\living\simple_animal\hostile\commanded\bear_companion.dm"
#include "code\modules\mob\living\simple_animal\hostile\commanded\commanded.dm"
#include "code\modules\mob\living\simple_animal\hostile\retaliate\cavern.dm"
#include "code\modules\mob\living\simple_animal\hostile\commanded\guard_dog.dm"
#include "code\modules\mob\living\simple_animal\hostile\retaliate\clown.dm"
#include "code\modules\mob\living\simple_animal\hostile\retaliate\drone.dm"
@@ -1612,6 +1649,7 @@
#include "code\modules\modular_computers\file_system\programs\antagonist\dos.dm"
#include "code\modules\modular_computers\file_system\programs\antagonist\hacked_camera.dm"
#include "code\modules\modular_computers\file_system\programs\antagonist\revelation.dm"
#include "code\modules\modular_computers\file_system\programs\civilian\crusher_control.dm"
#include "code\modules\modular_computers\file_system\programs\command\card.dm"
#include "code\modules\modular_computers\file_system\programs\command\comm.dm"
#include "code\modules\modular_computers\file_system\programs\engineering\_engineering.dm"
@@ -1648,6 +1686,8 @@
#include "code\modules\multiz\_stubs.dm"
#include "code\modules\multiz\basic.dm"
#include "code\modules\multiz\movement.dm"
#include "code\modules\multiz\openspace.dm"
#include "code\modules\multiz\openspace_overlay.dm"
#include "code\modules\multiz\pipes.dm"
#include "code\modules\multiz\structures.dm"
#include "code\modules\multiz\turf.dm"
@@ -1678,6 +1718,7 @@
#include "code\modules\nano\modules\nano_module.dm"
#include "code\modules\nano\modules\power_monitor.dm"
#include "code\modules\nano\modules\rcon.dm"
#include "code\modules\orbit\orbit.dm"
#include "code\modules\organs\blood.dm"
#include "code\modules\organs\misc.dm"
#include "code\modules\organs\organ.dm"
@@ -1771,6 +1812,7 @@
#include "code\modules\projectiles\guns\energy\laser.dm"
#include "code\modules\projectiles\guns\energy\lawgiver.dm"
#include "code\modules\projectiles\guns\energy\magic.dm"
#include "code\modules\projectiles\guns\energy\mining.dm"
#include "code\modules\projectiles\guns\energy\nuclear.dm"
#include "code\modules\projectiles\guns\energy\pulse.dm"
#include "code\modules\projectiles\guns\energy\rifle.dm"
@@ -1885,7 +1927,6 @@
#include "code\modules\research\xenoarchaeology\chemistry.dm"
#include "code\modules\research\xenoarchaeology\geosample.dm"
#include "code\modules\research\xenoarchaeology\manuals.dm"
#include "code\modules\research\xenoarchaeology\master_controller.dm"
#include "code\modules\research\xenoarchaeology\misc.dm"
#include "code\modules\research\xenoarchaeology\artifact\artifact.dm"
#include "code\modules\research\xenoarchaeology\artifact\artifact_autocloner.dm"
@@ -1970,6 +2011,7 @@
#include "code\modules\shuttles\departmental.dm"
#include "code\modules\shuttles\escape_pods.dm"
#include "code\modules\shuttles\shuttle.dm"
#include "code\modules\shuttles\shuttle_arrival.dm"
#include "code\modules\shuttles\shuttle_console.dm"
#include "code\modules\shuttles\shuttle_emergency.dm"
#include "code\modules\shuttles\shuttle_ferry.dm"
@@ -2063,6 +2105,14 @@
#include "code\modules\telesci\gps.dm"
#include "code\modules\telesci\telepad.dm"
#include "code\modules\telesci\telesci_computer.dm"
#include "code\modules\turbolift\_Aurora-areas.dm"
#include "code\modules\turbolift\turbolift.dm"
#include "code\modules\turbolift\turbolift_areas.dm"
#include "code\modules\turbolift\turbolift_console.dm"
#include "code\modules\turbolift\turbolift_door.dm"
#include "code\modules\turbolift\turbolift_floor.dm"
#include "code\modules\turbolift\turbolift_map.dm"
#include "code\modules\turbolift\turbolift_turfs.dm"
#include "code\modules\udp\ship_udp.dm"
#include "code\modules\vehicles\bike.dm"
#include "code\modules\vehicles\cargo_train.dm"
@@ -2093,6 +2143,7 @@
#include "code\unit_tests\map_tests.dm"
#include "code\unit_tests\mob_tests.dm"
#include "code\unit_tests\observation_tests.dm"
#include "code\unit_tests\ss_test.dm"
#include "code\unit_tests\unit_test.dm"
#include "code\unit_tests\zas_tests.dm"
#include "code\ZAS\_docs.dm"
@@ -2101,7 +2152,6 @@
#include "code\ZAS\Connection.dm"
#include "code\ZAS\ConnectionGroup.dm"
#include "code\ZAS\ConnectionManager.dm"
#include "code\ZAS\Controller.dm"
#include "code\ZAS\Debug.dm"
#include "code\ZAS\Diagnostic.dm"
#include "code\ZAS\Fire.dm"
@@ -2111,10 +2161,13 @@
#include "code\ZAS\Zone.dm"
#include "interface\interface.dm"
#include "interface\skin.dmf"
#include "maps\exodus-1.dmm"
#include "maps\exodus-2.dmm"
#include "maps\exodus-3.dmm"
#include "maps\exodus-4.dmm"
#include "maps\exodus-5.dmm"
#include "maps\exodus-6.dmm"
#include "maps\Aurora-MapDev\aurora-0.dmm"
#include "maps\Aurora-MapDev\aurora-1.dmm"
#include "maps\Aurora-MapDev\aurora-2.dmm"
#include "maps\Aurora-MapDev\aurora-3.dmm"
#include "maps\Aurora-MapDev\aurora-4.dmm"
#include "maps\Aurora-MapDev\aurora-5.dmm"
#include "maps\Aurora-MapDev\aurora-6.dmm"
#include "maps\Aurora-MapDev\aurora-7.dmm"
#include "maps\Aurora-MapDev\aurora-8.dmm"
// END_INCLUDE
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+19 -2
View File
@@ -11,7 +11,9 @@ Pipelines + Other Objects -> Pipe network
*/
/obj/machinery/atmospherics
auto_init = 0
var/auto_init = 0
var/no_special_init = FALSE
anchored = 1
idle_power_usage = 0
@@ -44,6 +46,18 @@ Pipelines + Other Objects -> Pipe network
pipe_color = null
..()
/obj/machinery/atmospherics/proc/initialize()
// Atmos machines are snowflakes and call initialize on themselves.
// Do not refactor initialize() to Initialize() unless you know what you are doing.
/obj/machinery/atmospherics/Initialize(mapload, ...)
if (no_special_init)
return ..()
. = ..()
if (mapload)
initialize()
/obj/machinery/atmospherics/attackby(atom/A, mob/user as mob)
if(istype(A, /obj/item/device/pipe_painter))
return
@@ -116,6 +130,9 @@ obj/machinery/atmospherics/proc/check_connect_types(obj/machinery/atmospherics/a
/obj/machinery/atmospherics/proc/reassign_network(datum/pipe_network/old_network, datum/pipe_network/new_network)
// Used when two pipe_networks are combining
/obj/machinery/atmospherics/proc/remove_network(datum/pipe_network/network)
reassign_network(network, null)
/obj/machinery/atmospherics/proc/return_network_air(datum/network/reference)
// Return a list of gas_mixture(s) in the object
// associated with reference pipe_network for use in rebuilding the networks gases list
@@ -124,4 +141,4 @@ obj/machinery/atmospherics/proc/check_connect_types(obj/machinery/atmospherics/a
/obj/machinery/atmospherics/proc/disconnect(obj/machinery/atmospherics/reference)
/obj/machinery/atmospherics/update_icon()
return null
return null
@@ -42,19 +42,20 @@ obj/machinery/atmospherics/binary
return null
Destroy()
loc = null
QDEL_NULL(air1)
QDEL_NULL(air2)
if(node1)
node1.disconnect(src)
qdel(network1)
QDEL_NULL(network1)
if(node2)
node2.disconnect(src)
qdel(network2)
QDEL_NULL(network2)
node1 = null
node2 = null
..()
return ..()
initialize()
if(node1 && node2) return
@@ -130,4 +131,4 @@ obj/machinery/atmospherics/binary
update_icon()
update_underlays()
return null
return null
@@ -161,10 +161,10 @@
//Radio remote control
/obj/machinery/atmospherics/binary/dp_vent_pump/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, filter = RADIO_ATMOSIA)
radio_connection = SSradio.add_object(src, frequency, filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/dp_vent_pump/proc/broadcast_status()
if(!radio_connection)
@@ -250,12 +250,10 @@
)
if(signal.data["status"])
spawn(2)
broadcast_status()
addtimer(CALLBACK(src, .proc/broadcast_status), 2, TIMER_UNIQUE)
return //do not update_icon
spawn(2)
broadcast_status()
addtimer(CALLBACK(src, .proc/broadcast_status), 2, TIMER_UNIQUE)
update_icon()
#undef DEFAULT_PRESSURE_DELTA
@@ -96,10 +96,10 @@
//Radio remote control
/obj/machinery/atmospherics/binary/passive_gate/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, filter = RADIO_ATMOSIA)
radio_connection = SSradio.add_object(src, frequency, filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/passive_gate/proc/broadcast_status()
if(!radio_connection)
@@ -152,12 +152,10 @@
regulate_mode = text2num(signal.data["set_flow_rate"])
if("status" in signal.data)
spawn(2)
broadcast_status()
addtimer(CALLBACK(src, .proc/broadcast_status), 2, TIMER_UNIQUE)
return //do not update_icon
spawn(2)
broadcast_status()
addtimer(CALLBACK(src, .proc/broadcast_status), 2, TIMER_UNIQUE)
update_icon()
return
@@ -48,7 +48,7 @@
node1 = null
node2 = null
..()
return ..()
process()
..()
@@ -92,10 +92,10 @@ Thus, the two variables affect pump operation are set in New():
//Radio remote control
/obj/machinery/atmospherics/binary/pump/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, filter = RADIO_ATMOSIA)
radio_connection = SSradio.add_object(src, frequency, filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/pump/proc/broadcast_status()
if(!radio_connection)
@@ -169,12 +169,10 @@ Thus, the two variables affect pump operation are set in New():
)
if(signal.data["status"])
spawn(2)
broadcast_status()
addtimer(CALLBACK(src, .proc/broadcast_status), 2, TIMER_UNIQUE)
return //do not update_icon
spawn(2)
broadcast_status()
addtimer(CALLBACK(src, .proc/broadcast_status), 2, TIMER_UNIQUE)
update_icon()
return
@@ -28,7 +28,7 @@
input = null
output = null
filters.Cut()
..()
return ..()
/obj/machinery/atmospherics/omni/filter/sort_ports()
for(var/datum/omni_port/P in ports)
@@ -261,4 +261,4 @@
else
initialize_directions |= P.dir
P.connect()
P.update = 1
P.update = 1
@@ -52,7 +52,7 @@
/obj/machinery/atmospherics/omni/mixer/Destroy()
inputs.Cut()
output = null
..()
return ..()
/obj/machinery/atmospherics/omni/mixer/sort_ports()
for(var/datum/omni_port/P in ports)
@@ -293,4 +293,4 @@
/obj/machinery/atmospherics/omni/mixer/proc/con_lock(var/port = NORTH)
for(var/datum/omni_port/P in inputs)
if(P.dir == port)
P.con_lock = !P.con_lock
P.con_lock = !P.con_lock
@@ -240,7 +240,7 @@
qdel(P.network)
P.node = null
..()
return ..()
/obj/machinery/atmospherics/omni/initialize()
for(var/datum/omni_port/P in ports)
@@ -72,7 +72,7 @@
node = null
..()
return ..()
/obj/machinery/atmospherics/portables_connector/initialize()
if(node) return
@@ -31,10 +31,10 @@
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/trinary/filter/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, RADIO_ATMOSIA)
radio_connection = SSradio.add_object(src, frequency, RADIO_ATMOSIA)
/obj/machinery/atmospherics/trinary/filter/New()
..()
@@ -51,23 +51,25 @@ obj/machinery/atmospherics/trinary
return null
Destroy()
loc = null
QDEL_NULL(air1)
QDEL_NULL(air2)
QDEL_NULL(air3)
if(node1)
node1.disconnect(src)
qdel(network1)
QDEL_NULL(network1)
if(node2)
node2.disconnect(src)
qdel(network2)
QDEL_NULL(network2)
if(node3)
node3.disconnect(src)
qdel(network3)
QDEL_NULL(network3)
node1 = null
node2 = null
node3 = null
..()
return ..()
initialize()
if(node1 && node2 && node3) return
@@ -164,4 +166,4 @@ obj/machinery/atmospherics/trinary
update_underlays()
return null
return null
+5 -5
View File
@@ -116,7 +116,7 @@
node2 = null
node3 = null
..()
return ..()
/obj/machinery/atmospherics/tvalve/proc/go_to_side()
@@ -313,10 +313,10 @@
//Radio remote control
/obj/machinery/atmospherics/tvalve/digital/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, RADIO_ATMOSIA)
radio_connection = SSradio.add_object(src, frequency, RADIO_ATMOSIA)
@@ -453,10 +453,10 @@
//Radio remote control -eh?
/obj/machinery/atmospherics/tvalve/mirrored/digital/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, RADIO_ATMOSIA)
radio_connection = SSradio.add_object(src, frequency, RADIO_ATMOSIA)
/obj/machinery/atmospherics/tvalve/mirrored/digital/initialize()
..()
@@ -32,14 +32,14 @@
process()
..()
if(!partner)
if(QDELETED(partner))
return 0
if(!air_master || air_master.current_cycle <= update_cycle)
if(!SSair || SSair.times_fired <= update_cycle)
return 0
update_cycle = air_master.current_cycle
partner.update_cycle = air_master.current_cycle
update_cycle = SSair.times_fired
partner.update_cycle = SSair.times_fired
var/air_heat_capacity = air_contents.heat_capacity()
var/other_air_heat_capacity = partner.air_contents.heat_capacity()
@@ -93,10 +93,10 @@
flick("inject", src)
/obj/machinery/atmospherics/unary/outlet_injector/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency)
radio_connection = SSradio.add_object(src, frequency)
/obj/machinery/atmospherics/unary/outlet_injector/proc/broadcast_status()
if(!radio_connection)
@@ -142,13 +142,11 @@
volume_rate = between(0, number, air_contents.volume)
if(signal.data["status"])
spawn(2)
broadcast_status()
addtimer(CALLBACK(src, .proc/broadcast_status), 2, TIMER_UNIQUE)
return //do not update_icon
spawn(2)
broadcast_status()
addtimer(CALLBACK(src, .proc/broadcast_status), 2, TIMER_UNIQUE)
update_icon()
/obj/machinery/atmospherics/unary/outlet_injector/hide(var/i)
update_underlays()
update_underlays()
@@ -29,15 +29,15 @@
return null
Destroy()
loc = null
QDEL_NULL(air_contents)
if(node)
node.disconnect(src)
qdel(network)
QDEL_NULL(network)
node = null
..()
return ..()
initialize()
if(node) return
@@ -100,4 +100,4 @@
/obj/machinery/atmospherics/unary/vent_scrubber/proc/is_welded()
if (welded > 0)
return 1
return 0
return 0
+29 -29
View File
@@ -72,17 +72,33 @@
/obj/machinery/atmospherics/unary/vent_pump/New()
..()
air_contents.volume = ATMOS_DEFAULT_VOLUME_PUMP
/obj/machinery/atmospherics/unary/vent_pump/Initialize()
. = ..()
icon = null
initial_loc = get_area(loc)
area_uid = initial_loc.uid
if (!id_tag)
assign_uid()
id_tag = num2text(uid)
//some vents work his own special way
radio_filter_in = frequency==1439?(RADIO_FROM_AIRALARM):null
radio_filter_out = frequency==1439?(RADIO_TO_AIRALARM):null
if(frequency)
radio_connection = register_radio(src, frequency, frequency, radio_filter_in)
initialize()
// Different from the above.
/obj/machinery/atmospherics/unary/vent_pump/initialize()
..()
broadcast_status()
/obj/machinery/atmospherics/unary/vent_pump/Destroy()
unregister_radio(src, frequency)
..()
return ..()
/obj/machinery/atmospherics/unary/vent_pump/high_volume
name = "Large Air Vent"
@@ -103,14 +119,10 @@
air_contents.volume = ATMOS_DEFAULT_VOLUME_PUMP + 500 //meant to match air injector
/obj/machinery/atmospherics/unary/vent_pump/update_icon(var/safety = 0)
if(!check_icon_cache())
return
if (!node)
use_power = 0
overlays.Cut()
var/vent_icon = "vent"
var/vent_icon = ""
var/turf/T = get_turf(src)
if(!istype(T))
@@ -126,7 +138,7 @@
else
vent_icon += "[use_power ? "[pump_direction ? "out" : "in"]" : "off"]"
overlays += icon_manager.get_atmos_icon("device", , , vent_icon)
icon_state = vent_icon
/obj/machinery/atmospherics/unary/vent_pump/update_underlays()
if(..())
@@ -240,27 +252,17 @@
"flow_rate" = last_flow_rate
)
if(!initial_loc.air_vent_names[id_tag])
var/new_name = "[initial_loc.name] Vent Pump #[initial_loc.air_vent_names.len+1]"
initial_loc.air_vent_names[id_tag] = new_name
var/area/A = get_area(src)
if(!A.air_vent_names[id_tag])
var/new_name = "[A.name] Vent Pump #[A.air_vent_names.len+1]"
A.air_vent_names[id_tag] = new_name
src.name = new_name
initial_loc.air_vent_info[id_tag] = signal.data
A.air_vent_info[id_tag] = signal.data
radio_connection.post_signal(src, signal, radio_filter_out)
return 1
/obj/machinery/atmospherics/unary/vent_pump/initialize()
..()
//some vents work his own special way
radio_filter_in = frequency==1439?(RADIO_FROM_AIRALARM):null
radio_filter_out = frequency==1439?(RADIO_TO_AIRALARM):null
if(frequency)
radio_connection = register_radio(src, frequency, frequency, radio_filter_in)
src.broadcast_status()
/obj/machinery/atmospherics/unary/vent_pump/receive_signal(datum/signal/signal)
if(stat & (NOPOWER|BROKEN))
return
@@ -338,13 +340,12 @@
return
if(signal.data["status"] != null)
spawn(2)
broadcast_status()
addtimer(CALLBACK(src, .proc/broadcast_status), 2, TIMER_UNIQUE)
return //do not update_icon
//log_debug("DEBUG \[[world.timeofday]\]: vent_pump/receive_signal: unknown command \"[signal.data["command"]]\"\n[signal.debug_print()]")
spawn(2)
broadcast_status()
addtimer(CALLBACK(src, .proc/broadcast_status), 2, TIMER_UNIQUE)
update_icon()
return
@@ -418,8 +419,7 @@
if(initial_loc)
initial_loc.air_vent_info -= id_tag
initial_loc.air_vent_names -= id_tag
..()
return
return ..()
#undef DEFAULT_PRESSURE_DELTA
@@ -28,6 +28,7 @@
var/radio_filter_in
var/welded = 0
//no_special_init = TRUE
/obj/machinery/atmospherics/unary/vent_scrubber/on
use_power = 1
@@ -37,39 +38,47 @@
..()
air_contents.volume = ATMOS_DEFAULT_VOLUME_FILTER
icon = null
/obj/machinery/atmospherics/unary/vent_scrubber/Initialize()
. = ..()
initial_loc = get_area(loc)
area_uid = initial_loc.uid
if (!id_tag)
assign_uid()
id_tag = num2text(uid)
radio_filter_in = frequency==initial(frequency)?(RADIO_FROM_AIRALARM):null
radio_filter_out = frequency==initial(frequency)?(RADIO_TO_AIRALARM):null
if (frequency)
set_frequency(frequency)
initialize()
/obj/machinery/atmospherics/unary/vent_scrubber/initialize()
..()
broadcast_status()
/obj/machinery/atmospherics/unary/vent_scrubber/Destroy()
unregister_radio(src, frequency)
..()
return ..()
/obj/machinery/atmospherics/unary/vent_scrubber/update_icon(var/safety = 0)
if(!check_icon_cache())
return
overlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
var/scrubber_icon = "scrubber"
if(welded)
scrubber_icon += "weld"
if (welded)
icon_state = "weld"
return
if (!powered() || !use_power)
icon_state = "off"
else if (scrubbing)
icon_state = "on"
else
if(!powered())
scrubber_icon += "off"
else
scrubber_icon += "[use_power ? "[scrubbing ? "on" : "in"]" : "off"]"
overlays += icon_manager.get_atmos_icon("device", , , scrubber_icon)
icon_state = "in"
/obj/machinery/atmospherics/unary/vent_scrubber/update_underlays()
if(..())
underlays.Cut()
@@ -85,9 +94,9 @@
add_underlay(T,, dir)
/obj/machinery/atmospherics/unary/vent_scrubber/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
radio_connection = radio_controller.add_object(src, frequency, radio_filter_in)
radio_connection = SSradio.add_object(src, frequency, radio_filter_in)
/obj/machinery/atmospherics/unary/vent_scrubber/proc/broadcast_status()
if(!radio_connection)
@@ -111,23 +120,17 @@
"filter_n2o" = ("sleeping_agent" in scrubbing_gas),
"sigtype" = "status"
)
if(!initial_loc.air_scrub_names[id_tag])
var/new_name = "[initial_loc.name] Air Scrubber #[initial_loc.air_scrub_names.len+1]"
initial_loc.air_scrub_names[id_tag] = new_name
var/area/A = get_area(src)
if(!A.air_scrub_names[id_tag])
var/new_name = "[A.name] Air Scrubber #[A.air_scrub_names.len+1]"
A.air_scrub_names[id_tag] = new_name
src.name = new_name
initial_loc.air_scrub_info[id_tag] = signal.data
A.air_scrub_info[id_tag] = signal.data
radio_connection.post_signal(src, signal, radio_filter_out)
return 1
/obj/machinery/atmospherics/unary/vent_scrubber/initialize()
..()
radio_filter_in = frequency==initial(frequency)?(RADIO_FROM_AIRALARM):null
radio_filter_out = frequency==initial(frequency)?(RADIO_TO_AIRALARM):null
if (frequency)
set_frequency(frequency)
src.broadcast_status()
/obj/machinery/atmospherics/unary/vent_scrubber/process()
..()
@@ -242,13 +245,11 @@
return
if(signal.data["status"] != null)
spawn(2)
broadcast_status()
addtimer(CALLBACK(src, .proc/broadcast_status), 2, TIMER_UNIQUE)
return //do not update_icon
// log_debug("DEBUG \[[world.timeofday]\]: vent_scrubber/receive_signal: unknown command \"[signal.data["command"]]\"\n[signal.debug_print()]")
spawn(2)
broadcast_status()
addtimer(CALLBACK(src, .proc/broadcast_status), 2, TIMER_UNIQUE)
update_icon()
return
@@ -320,5 +321,5 @@
if(initial_loc)
initial_loc.air_scrub_info -= id_tag
initial_loc.air_scrub_names -= id_tag
..()
return
return ..()
+3 -3
View File
@@ -83,7 +83,7 @@
node1 = null
node2 = null
..()
return ..()
/obj/machinery/atmospherics/valve/proc/open()
if(open) return 0
@@ -272,10 +272,10 @@
icon_state = "valve[open]nopower"
/obj/machinery/atmospherics/valve/digital/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, RADIO_ATMOSIA)
radio_connection = SSradio.add_object(src, frequency, RADIO_ATMOSIA)
/obj/machinery/atmospherics/valve/digital/initialize()
..()
+62 -49
View File
@@ -1,6 +1,4 @@
var/global/list/datum/pipe_network/pipe_networks = list()
datum/pipe_network
/datum/pipe_network
var/list/datum/gas_mixture/gases = list() //All of the gas_mixtures continuously connected in this network
var/volume = 0 //caches the total volume for atmos machines to use in gas calculations
@@ -11,68 +9,83 @@ datum/pipe_network
var/update = 1
//var/datum/gas_mixture/air_transient = null
New()
//air_transient = new()
/*
/datum/pipe_network/New()
//air_transient = new()
..()
..()*/
proc/process()
//Equalize gases amongst pipe if called for
if(update)
update = 0
reconcile_air() //equalize_gases(gases)
/datum/pipe_network/process()
//Equalize gases amongst pipe if called for
if(update)
update = 0
reconcile_air() //equalize_gases(gases)
//Give pipelines their process call for pressure checking and what not. Have to remove pressure checks for the time being as pipes dont radiate heat - Mport
//for(var/datum/pipeline/line_member in line_members)
// line_member.process()
//Give pipelines their process call for pressure checking and what not. Have to remove pressure checks for the time being as pipes dont radiate heat - Mport
//for(var/datum/pipeline/line_member in line_members)
// line_member.process()
proc/build_network(obj/machinery/atmospherics/start_normal, obj/machinery/atmospherics/reference)
//Purpose: Generate membership roster
//Notes: Assuming that members will add themselves to appropriate roster in network_expand()
/datum/pipe_network/proc/build_network(obj/machinery/atmospherics/start_normal, obj/machinery/atmospherics/reference)
//Purpose: Generate membership roster
//Notes: Assuming that members will add themselves to appropriate roster in network_expand()
if(!start_normal)
qdel(src)
if(!start_normal)
qdel(src)
start_normal.network_expand(src, reference)
start_normal.network_expand(src, reference)
update_network_gases()
update_network_gases()
if((normal_members.len>0)||(line_members.len>0))
pipe_networks += src
else
qdel(src)
if((normal_members.len>0)||(line_members.len>0))
START_PROCESSING(SSpipenet, src)
else
qdel(src)
proc/merge(datum/pipe_network/giver)
if(giver==src) return 0
/datum/pipe_network/proc/merge(datum/pipe_network/giver)
if(giver==src) return 0
normal_members |= giver.normal_members
normal_members |= giver.normal_members
line_members |= giver.line_members
line_members |= giver.line_members
for(var/obj/machinery/atmospherics/normal_member in giver.normal_members)
normal_member.reassign_network(giver, src)
for(var/obj/machinery/atmospherics/normal_member in giver.normal_members)
normal_member.reassign_network(giver, src)
for(var/datum/pipeline/line_member in giver.line_members)
line_member.network = src
for(var/datum/pipeline/line_member in giver.line_members)
line_member.network = src
update_network_gases()
return 1
update_network_gases()
return 1
proc/update_network_gases()
//Go through membership roster and make sure gases is up to date
/datum/pipe_network/proc/update_network_gases()
//Go through membership roster and make sure gases is up to date
gases = list()
volume = 0
gases = list()
volume = 0
for(var/obj/machinery/atmospherics/normal_member in normal_members)
var/result = normal_member.return_network_air(src)
if(result) gases += result
for(var/obj/machinery/atmospherics/normal_member in normal_members)
var/result = normal_member.return_network_air(src)
if(result) gases += result
for(var/datum/pipeline/line_member in line_members)
gases += line_member.air
for(var/datum/gas_mixture/air in gases)
volume += air.volume
for(var/datum/pipeline/line_member in line_members)
gases += line_member.air
for(var/datum/gas_mixture/air in gases)
volume += air.volume
proc/reconcile_air()
equalize_gases(gases)
/datum/pipe_network/proc/reconcile_air()
equalize_gases(gases)
/datum/pipe_network/Destroy(force = FALSE)
STOP_PROCESSING(SSpipenet, src)
for (var/datum/pipeline/pipeline in line_members)
pipeline.network = null
line_members = null
for (var/obj/machinery/atmospherics/thing in normal_members)
thing.remove_network(src)
normal_members = null
return ..()
+168 -161
View File
@@ -1,5 +1,5 @@
datum/pipeline
/datum/pipeline
var/datum/gas_mixture/air
var/list/obj/machinery/atmospherics/pipe/members
@@ -9,208 +9,215 @@ datum/pipeline
var/alert_pressure = 0
Destroy()
if(network)
qdel(network)
/datum/pipeline/Destroy()
if(network)
QDEL_NULL(network)
if(air && air.volume)
temporarily_store_air()
qdel(air)
if(air && air.volume)
temporarily_store_air()
QDEL_NULL(air)
..()
for (var/obj/machinery/atmospherics/pipe/thing in members)
thing.parent = null
proc/process()//This use to be called called from the pipe networks
return ..()
//Check to see if pressure is within acceptable limits
var/pressure = air.return_pressure()
if(pressure > alert_pressure)
for(var/obj/machinery/atmospherics/pipe/member in members)
if(!member.check_pressure(pressure))
break //Only delete 1 pipe per process
proc/temporarily_store_air()
//Update individual gas_mixtures by volume ratio
/datum/pipeline/resetVariables()
..("members", "edges")
members = list()
edges = list()
/datum/pipeline/process()//This use to be called called from the pipe networks
//Check to see if pressure is within acceptable limits
var/pressure = air.return_pressure()
if(pressure > alert_pressure)
for(var/obj/machinery/atmospherics/pipe/member in members)
member.air_temporary = new
member.air_temporary.copy_from(air)
member.air_temporary.volume = member.volume
member.air_temporary.multiply(member.volume / air.volume)
if(!member.check_pressure(pressure))
break //Only delete 1 pipe per process
proc/build_pipeline(obj/machinery/atmospherics/pipe/base)
/datum/pipeline/proc/temporarily_store_air()
//Update individual gas_mixtures by volume ratio
for(var/obj/machinery/atmospherics/pipe/member in members)
member.air_temporary = new
member.air_temporary.copy_from(air)
member.air_temporary.volume = member.volume
member.air_temporary.multiply(member.volume / air.volume)
/datum/pipeline/proc/build_pipeline(obj/machinery/atmospherics/pipe/base)
air = new
var/list/possible_expansions = list(base)
members = list(base)
edges = list()
var/volume = base.volume
base.parent = src
alert_pressure = base.alert_pressure
if(base.air_temporary)
air = base.air_temporary
base.air_temporary = null
else
air = new
var/list/possible_expansions = list(base)
members = list(base)
edges = list()
while(possible_expansions.len>0)
for(var/obj/machinery/atmospherics/pipe/borderline in possible_expansions)
var/volume = base.volume
base.parent = src
alert_pressure = base.alert_pressure
var/list/result = borderline.pipeline_expansion()
var/edge_check = result.len
if(base.air_temporary)
air = base.air_temporary
base.air_temporary = null
else
air = new
if(result.len>0)
for(var/obj/machinery/atmospherics/pipe/item in result)
if(!members.Find(item))
members += item
possible_expansions += item
while(possible_expansions.len>0)
for(var/obj/machinery/atmospherics/pipe/borderline in possible_expansions)
volume += item.volume
item.parent = src
var/list/result = borderline.pipeline_expansion()
var/edge_check = result.len
alert_pressure = min(alert_pressure, item.alert_pressure)
if(result.len>0)
for(var/obj/machinery/atmospherics/pipe/item in result)
if(!members.Find(item))
members += item
possible_expansions += item
if(item.air_temporary)
air.merge(item.air_temporary)
volume += item.volume
item.parent = src
edge_check--
alert_pressure = min(alert_pressure, item.alert_pressure)
if(edge_check>0)
edges += borderline
if(item.air_temporary)
air.merge(item.air_temporary)
possible_expansions -= borderline
edge_check--
air.volume = volume
if(edge_check>0)
edges += borderline
/datum/pipeline/proc/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
possible_expansions -= borderline
if(new_network.line_members.Find(src))
return 0
air.volume = volume
new_network.line_members += src
proc/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
network = new_network
if(new_network.line_members.Find(src))
return 0
for(var/obj/machinery/atmospherics/pipe/edge in edges)
for(var/obj/machinery/atmospherics/result in edge.pipeline_expansion())
if(!istype(result,/obj/machinery/atmospherics/pipe) && (result!=reference))
result.network_expand(new_network, edge)
new_network.line_members += src
return 1
network = new_network
/datum/pipeline/proc/return_network(obj/machinery/atmospherics/reference)
if(!network)
network = new /datum/pipe_network
network.build_network(src, null)
//technically passing these parameters should not be allowed
//however pipe_network.build_network(..) and pipeline.network_extend(...)
// were setup to properly handle this case
for(var/obj/machinery/atmospherics/pipe/edge in edges)
for(var/obj/machinery/atmospherics/result in edge.pipeline_expansion())
if(!istype(result,/obj/machinery/atmospherics/pipe) && (result!=reference))
result.network_expand(new_network, edge)
return network
return 1
/datum/pipeline/proc/mingle_with_turf(turf/simulated/target, mingle_volume)
var/datum/gas_mixture/air_sample = air.remove_ratio(mingle_volume/air.volume)
air_sample.volume = mingle_volume
proc/return_network(obj/machinery/atmospherics/reference)
if(!network)
network = new /datum/pipe_network()
network.build_network(src, null)
//technically passing these parameters should not be allowed
//however pipe_network.build_network(..) and pipeline.network_extend(...)
// were setup to properly handle this case
if(istype(target) && target.zone)
//Have to consider preservation of group statuses
var/datum/gas_mixture/turf_copy = new
return network
turf_copy.copy_from(target.zone.air)
turf_copy.volume = target.zone.air.volume //Copy a good representation of the turf from parent group
proc/mingle_with_turf(turf/simulated/target, mingle_volume)
var/datum/gas_mixture/air_sample = air.remove_ratio(mingle_volume/air.volume)
air_sample.volume = mingle_volume
equalize_gases(list(air_sample, turf_copy))
air.merge(air_sample)
if(istype(target) && target.zone)
//Have to consider preservation of group statuses
var/datum/gas_mixture/turf_copy = new
turf_copy.subtract(target.zone.air)
turf_copy.copy_from(target.zone.air)
turf_copy.volume = target.zone.air.volume //Copy a good representation of the turf from parent group
target.zone.air.merge(turf_copy)
equalize_gases(list(air_sample, turf_copy))
air.merge(air_sample)
else
var/datum/gas_mixture/turf_air = target.return_air()
turf_copy.subtract(target.zone.air)
equalize_gases(list(air_sample, turf_air))
air.merge(air_sample)
//turf_air already modified by equalize_gases()
target.zone.air.merge(turf_copy)
if(network)
network.update = 1
else
var/datum/gas_mixture/turf_air = target.return_air()
/datum/pipeline/proc/temperature_interact(turf/target, share_volume, thermal_conductivity)
var/total_heat_capacity = air.heat_capacity()
var/partial_heat_capacity = total_heat_capacity*(share_volume/air.volume)
equalize_gases(list(air_sample, turf_air))
air.merge(air_sample)
//turf_air already modified by equalize_gases()
if(istype(target, /turf/simulated))
var/turf/simulated/modeled_location = target
if(network)
network.update = 1
if(modeled_location.blocks_air)
proc/temperature_interact(turf/target, share_volume, thermal_conductivity)
var/total_heat_capacity = air.heat_capacity()
var/partial_heat_capacity = total_heat_capacity*(share_volume/air.volume)
if(istype(target, /turf/simulated))
var/turf/simulated/modeled_location = target
if(modeled_location.blocks_air)
if((modeled_location.heat_capacity>0) && (partial_heat_capacity>0))
var/delta_temperature = air.temperature - modeled_location.temperature
var/heat = thermal_conductivity*delta_temperature* \
(partial_heat_capacity*modeled_location.heat_capacity/(partial_heat_capacity+modeled_location.heat_capacity))
air.temperature -= heat/total_heat_capacity
modeled_location.temperature += heat/modeled_location.heat_capacity
else
var/delta_temperature = 0
var/sharer_heat_capacity = 0
if(modeled_location.zone)
delta_temperature = (air.temperature - modeled_location.zone.air.temperature)
sharer_heat_capacity = modeled_location.zone.air.heat_capacity()
else
delta_temperature = (air.temperature - modeled_location.air.temperature)
sharer_heat_capacity = modeled_location.air.heat_capacity()
var/self_temperature_delta = 0
var/sharer_temperature_delta = 0
if((sharer_heat_capacity>0) && (partial_heat_capacity>0))
var/heat = thermal_conductivity*delta_temperature* \
(partial_heat_capacity*sharer_heat_capacity/(partial_heat_capacity+sharer_heat_capacity))
self_temperature_delta = -heat/total_heat_capacity
sharer_temperature_delta = heat/sharer_heat_capacity
else
return 1
air.temperature += self_temperature_delta
if(modeled_location.zone)
modeled_location.zone.air.temperature += sharer_temperature_delta/modeled_location.zone.air.group_multiplier
else
modeled_location.air.temperature += sharer_temperature_delta
else
if((target.heat_capacity>0) && (partial_heat_capacity>0))
var/delta_temperature = air.temperature - target.temperature
if((modeled_location.heat_capacity>0) && (partial_heat_capacity>0))
var/delta_temperature = air.temperature - modeled_location.temperature
var/heat = thermal_conductivity*delta_temperature* \
(partial_heat_capacity*target.heat_capacity/(partial_heat_capacity+target.heat_capacity))
(partial_heat_capacity*modeled_location.heat_capacity/(partial_heat_capacity+modeled_location.heat_capacity))
air.temperature -= heat/total_heat_capacity
if(network)
network.update = 1
modeled_location.temperature += heat/modeled_location.heat_capacity
else
var/delta_temperature = 0
var/sharer_heat_capacity = 0
if(modeled_location.zone)
delta_temperature = (air.temperature - modeled_location.zone.air.temperature)
sharer_heat_capacity = modeled_location.zone.air.heat_capacity()
else
delta_temperature = (air.temperature - modeled_location.air.temperature)
sharer_heat_capacity = modeled_location.air.heat_capacity()
var/self_temperature_delta = 0
var/sharer_temperature_delta = 0
if((sharer_heat_capacity>0) && (partial_heat_capacity>0))
var/heat = thermal_conductivity*delta_temperature* \
(partial_heat_capacity*sharer_heat_capacity/(partial_heat_capacity+sharer_heat_capacity))
self_temperature_delta = -heat/total_heat_capacity
sharer_temperature_delta = heat/sharer_heat_capacity
else
return 1
air.temperature += self_temperature_delta
if(modeled_location.zone)
modeled_location.zone.air.temperature += sharer_temperature_delta/modeled_location.zone.air.group_multiplier
else
modeled_location.air.temperature += sharer_temperature_delta
else
if((target.heat_capacity>0) && (partial_heat_capacity>0))
var/delta_temperature = air.temperature - target.temperature
var/heat = thermal_conductivity*delta_temperature* \
(partial_heat_capacity*target.heat_capacity/(partial_heat_capacity+target.heat_capacity))
air.temperature -= heat/total_heat_capacity
if(network)
network.update = 1
//surface must be the surface area in m^2
proc/radiate_heat_to_space(surface, thermal_conductivity)
var/gas_density = air.total_moles/air.volume
thermal_conductivity *= min(gas_density / ( RADIATOR_OPTIMUM_PRESSURE/(R_IDEAL_GAS_EQUATION*GAS_CRITICAL_TEMPERATURE) ), 1) //mult by density ratio
// We only get heat from the star on the exposed surface area.
// If the HE pipes gain more energy from AVERAGE_SOLAR_RADIATION than they can radiate, then they have a net heat increase.
var/heat_gain = AVERAGE_SOLAR_RADIATION * (RADIATOR_EXPOSED_SURFACE_AREA_RATIO * surface) * thermal_conductivity
// Previously, the temperature would enter equilibrium at 26C or 294K.
// Only would happen if both sides (all 2 square meters of surface area) were exposed to sunlight. We now assume it aligned edge on.
// It currently should stabilise at 129.6K or -143.6C
heat_gain -= surface * STEFAN_BOLTZMANN_CONSTANT * thermal_conductivity * (air.temperature - COSMIC_RADIATION_TEMPERATURE) ** 4
air.add_thermal_energy(heat_gain)
if(network)
network.update = 1
/datum/pipeline/proc/radiate_heat_to_space(surface, thermal_conductivity)
var/gas_density = air.total_moles/air.volume
thermal_conductivity *= min(gas_density / ( RADIATOR_OPTIMUM_PRESSURE/(R_IDEAL_GAS_EQUATION*GAS_CRITICAL_TEMPERATURE) ), 1) //mult by density ratio
// We only get heat from the star on the exposed surface area.
// If the HE pipes gain more energy from AVERAGE_SOLAR_RADIATION than they can radiate, then they have a net heat increase.
var/heat_gain = AVERAGE_SOLAR_RADIATION * (RADIATOR_EXPOSED_SURFACE_AREA_RATIO * surface) * thermal_conductivity
// Previously, the temperature would enter equilibrium at 26C or 294K.
// Only would happen if both sides (all 2 square meters of surface area) were exposed to sunlight. We now assume it aligned edge on.
// It currently should stabilise at 129.6K or -143.6C
heat_gain -= surface * STEFAN_BOLTZMANN_CONSTANT * thermal_conductivity * (air.temperature - COSMIC_RADIATION_TEMPERATURE) ** 4
air.add_thermal_energy(heat_gain)
if(network)
network.update = 1
+4 -3
View File
@@ -98,9 +98,10 @@ obj/machinery/atmospherics/pipe/simple/heat_exchanging
h_g = 64 + (h_g - 64)*scale
h_b = 64 + (h_b - 64)*scale
animate(src, color = rgb(h_r, h_g, h_b), time = 20, easing = SINE_EASING)
var/list/animate_targets = get_above_oo() + src
for (var/thing in animate_targets)
var/atom/movable/AM = thing
animate(AM, color = rgb(h_r, h_g, h_b), time = 20, easing = SINE_EASING)
obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction
+3 -3
View File
@@ -101,7 +101,7 @@ obj/machinery/atmospherics/mains_pipe
Destroy()
disconnect()
..()
return ..()
initialize()
for(var/i = 1 to nodes.len)
@@ -657,10 +657,10 @@ obj/machinery/atmospherics/mains_pipe/valve
proc
set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, RADIO_ATMOSIA)
radio_connection = SSradio.add_object(src, frequency, RADIO_ATMOSIA)
var/frequency = 0
var/id = null
+59 -36
View File
@@ -64,11 +64,12 @@
return parent.return_network(reference)
/obj/machinery/atmospherics/pipe/Destroy()
qdel(parent)
QDEL_NULL(parent)
if(air_temporary)
loc.assume_air(air_temporary)
QDEL_NULL(air_temporary)
..()
return ..()
/obj/machinery/atmospherics/pipe/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (istype(src, /obj/machinery/atmospherics/pipe/tank))
@@ -231,7 +232,10 @@
if(node2)
node2.disconnect(src)
..()
node1 = null
node2 = null
return ..()
/obj/machinery/atmospherics/pipe/simple/pipeline_expansion()
return list(node1, node2)
@@ -250,7 +254,7 @@
alpha = 255
overlays.Cut()
cut_overlays()
if(!node1 && !node2)
var/turf/T = get_turf(src)
@@ -261,9 +265,9 @@
qdel(meter)
qdel(src)
else if(node1 && node2)
overlays += icon_manager.get_atmos_icon("pipe", , pipe_color, "[pipe_icon]intact[icon_connect_type]")
add_overlay(icon_manager.get_atmos_icon("pipe", , pipe_color, "[pipe_icon]intact[icon_connect_type]"))
else
overlays += icon_manager.get_atmos_icon("pipe", , pipe_color, "[pipe_icon]exposed[node1?1:0][node2?1:0][icon_connect_type]")
add_overlay(icon_manager.get_atmos_icon("pipe", , pipe_color, "[pipe_icon]exposed[node1?1:0][node2?1:0][icon_connect_type]"))
/obj/machinery/atmospherics/pipe/simple/update_underlays()
return
@@ -302,12 +306,12 @@
/obj/machinery/atmospherics/pipe/simple/disconnect(obj/machinery/atmospherics/reference)
if(reference == node1)
if(istype(node1, /obj/machinery/atmospherics/pipe))
qdel(parent)
QDEL_NULL(parent)
node1 = null
if(reference == node2)
if(istype(node2, /obj/machinery/atmospherics/pipe))
qdel(parent)
QDEL_NULL(parent)
node2 = null
update_icon()
@@ -462,22 +466,26 @@
if(node3)
node3.disconnect(src)
..()
node1 = null
node2 = null
node3 = null
return ..()
/obj/machinery/atmospherics/pipe/manifold/disconnect(obj/machinery/atmospherics/reference)
if(reference == node1)
if(istype(node1, /obj/machinery/atmospherics/pipe))
qdel(parent)
QDEL_NULL(parent)
node1 = null
if(reference == node2)
if(istype(node2, /obj/machinery/atmospherics/pipe))
qdel(parent)
QDEL_NULL(parent)
node2 = null
if(reference == node3)
if(istype(node3, /obj/machinery/atmospherics/pipe))
qdel(parent)
QDEL_NULL(parent)
node3 = null
update_icon()
@@ -509,9 +517,11 @@
qdel(meter)
qdel(src)
else
overlays.Cut()
overlays += icon_manager.get_atmos_icon("manifold", , pipe_color, "core" + icon_connect_type)
overlays += icon_manager.get_atmos_icon("manifold", , , "clamps" + icon_connect_type)
cut_overlays()
add_overlay(icon_manager.get_atmos_icon("manifold", , pipe_color, "core" + icon_connect_type))
add_overlay(icon_manager.get_atmos_icon("manifold", , , "clamps" + icon_connect_type))
// Can't handle underlays with SSoverlay.
underlays.Cut()
var/turf/T = get_turf(src)
@@ -703,27 +713,32 @@
if(node4)
node4.disconnect(src)
..()
node1 = null
node2 = null
node3 = null
node4 = null
return ..()
/obj/machinery/atmospherics/pipe/manifold4w/disconnect(obj/machinery/atmospherics/reference)
if(reference == node1)
if(istype(node1, /obj/machinery/atmospherics/pipe))
qdel(parent)
QDEL_NULL(parent)
node1 = null
if(reference == node2)
if(istype(node2, /obj/machinery/atmospherics/pipe))
qdel(parent)
QDEL_NULL(parent)
node2 = null
if(reference == node3)
if(istype(node3, /obj/machinery/atmospherics/pipe))
qdel(parent)
QDEL_NULL(parent)
node3 = null
if(reference == node4)
if(istype(node4, /obj/machinery/atmospherics/pipe))
qdel(parent)
QDEL_NULL(parent)
node4 = null
update_icon()
@@ -757,9 +772,10 @@
qdel(meter)
qdel(src)
else
overlays.Cut()
overlays += icon_manager.get_atmos_icon("manifold", , pipe_color, "4way" + icon_connect_type)
overlays += icon_manager.get_atmos_icon("manifold", , , "clamps_4way" + icon_connect_type)
cut_overlays()
add_overlay(icon_manager.get_atmos_icon("manifold", , pipe_color, "4way" + icon_connect_type))
add_overlay(icon_manager.get_atmos_icon("manifold", , , "clamps_4way" + icon_connect_type))
underlays.Cut()
/*
@@ -953,12 +969,14 @@
if(node)
node.disconnect(src)
..()
node = null
return ..()
/obj/machinery/atmospherics/pipe/cap/disconnect(obj/machinery/atmospherics/reference)
if(reference == node)
if(istype(node, /obj/machinery/atmospherics/pipe))
qdel(parent)
QDEL_NULL(parent)
node = null
update_icon()
@@ -977,8 +995,8 @@
alpha = 255
overlays.Cut()
overlays += icon_manager.get_atmos_icon("pipe", , pipe_color, "cap")
cut_overlays()
add_overlay(icon_manager.get_atmos_icon("pipe", , pipe_color, "cap"))
/obj/machinery/atmospherics/pipe/cap/initialize()
for(var/obj/machinery/atmospherics/target in get_step(src, dir))
@@ -1067,7 +1085,9 @@
if(node1)
node1.disconnect(src)
..()
node1 = null
return ..()
/obj/machinery/atmospherics/pipe/tank/pipeline_expansion()
return list(node1)
@@ -1097,7 +1117,7 @@
/obj/machinery/atmospherics/pipe/tank/disconnect(obj/machinery/atmospherics/reference)
if(reference == node1)
if(istype(node1, /obj/machinery/atmospherics/pipe))
qdel(parent)
QDEL_NULL(parent)
node1 = null
update_underlays()
@@ -1237,7 +1257,9 @@
if(node1)
node1.disconnect(src)
..()
node1 = null
return ..()
/obj/machinery/atmospherics/pipe/vent/pipeline_expansion()
return list(node1)
@@ -1265,7 +1287,7 @@
/obj/machinery/atmospherics/pipe/vent/disconnect(obj/machinery/atmospherics/reference)
if(reference == node1)
if(istype(node1, /obj/machinery/atmospherics/pipe))
qdel(parent)
QDEL_NULL(parent)
node1 = null
update_icon()
@@ -1292,8 +1314,8 @@
alpha = 255
overlays.Cut()
overlays += icon_manager.get_atmos_icon("pipe", , pipe_color, "universal")
cut_overlays()
add_overlay(icon_manager.get_atmos_icon("pipe", , pipe_color, "universal"))
underlays.Cut()
if (node1)
@@ -1307,7 +1329,7 @@
universal_underlays(node2)
else
universal_underlays(,dir)
universal_underlays(dir, -180)
universal_underlays(,turn(dir, -180))
/obj/machinery/atmospherics/pipe/simple/visible/universal/update_underlays()
..()
@@ -1327,8 +1349,9 @@
alpha = 255
overlays.Cut()
overlays += icon_manager.get_atmos_icon("pipe", , pipe_color, "universal")
cut_overlays()
add_overlay(icon_manager.get_atmos_icon("pipe", , pipe_color, "universal"))
underlays.Cut()
if (node1)
+5 -107
View File
@@ -78,115 +78,13 @@ obj/item/check_airflow_movable(n)
return 0
return 1
/*
/atom/movable/proc/GotoAirflowDest(n)
if(!airflow_dest) return
if(airflow_speed < 0) return
if(last_airflow > world.time - vsc.airflow_delay) return
if(airflow_speed)
airflow_speed = n/max(get_dist(src,airflow_dest),1)
return
if(airflow_dest == loc)
step_away(src,loc)
if(!src.AirflowCanMove(n))
return
if(ismob(src))
src << "<span class='danger'>You are sucked away by airflow!</span>"
last_airflow = world.time
var/airflow_falloff = 9 - sqrt((x - airflow_dest.x) ** 2 + (y - airflow_dest.y) ** 2)
if(airflow_falloff < 1)
airflow_dest = null
return
airflow_speed = min(max(n * (9/airflow_falloff),1),9)
var
xo = airflow_dest.x - src.x
yo = airflow_dest.y - src.y
od = 0
airflow_dest = null
if(!density)
density = 1
od = 1
while(airflow_speed > 0)
if(airflow_speed <= 0) break
airflow_speed = min(airflow_speed,15)
airflow_speed -= vsc.airflow_speed_decay
if(airflow_speed > 7)
if(airflow_time++ >= airflow_speed - 7)
if(od)
density = 0
sleep(1 * tick_multiplier)
else
if(od)
density = 0
sleep(max(1,10-(airflow_speed+3)) * tick_multiplier)
if(od)
density = 1
if ((!( src.airflow_dest ) || src.loc == src.airflow_dest))
src.airflow_dest = locate(min(max(src.x + xo, 1), world.maxx), min(max(src.y + yo, 1), world.maxy), src.z)
if ((src.x == 1 || src.x == world.maxx || src.y == 1 || src.y == world.maxy))
break
if(!istype(loc, /turf))
break
step_towards(src, src.airflow_dest)
var/mob/M = src
if(istype(M) && M.client)
M.setMoveCooldown(vsc.airflow_mob_slowdown)
airflow_dest = null
airflow_speed = 0
airflow_time = 0
if(od)
density = 0
and
/atom/movable/proc/RepelAirflowDest(n)
if(!airflow_dest) return
if(airflow_speed < 0) return
if(last_airflow > world.time - vsc.airflow_delay) return
if(airflow_speed)
airflow_speed = n/max(get_dist(src,airflow_dest),1)
return
if(airflow_dest == loc)
step_away(src,loc)
if(!src.AirflowCanMove(n))
return
if(ismob(src))
src << "<span clas='danger'>You are pushed away by airflow!</span>"
last_airflow = world.time
var/airflow_falloff = 9 - sqrt((x - airflow_dest.x) ** 2 + (y - airflow_dest.y) ** 2)
if(airflow_falloff < 1)
airflow_dest = null
return
airflow_speed = min(max(n * (9/airflow_falloff),1),9)
var
xo = -(airflow_dest.x - src.x)
yo = -(airflow_dest.y - src.y)
od = 0
airflow_dest = null
if(!density)
density = 1
od = 1
while(airflow_speed > 0)
if(airflow_speed <= 0) return
airflow_speed = min(airflow_speed,15)
airflow_speed -= vsc.airflow_speed_decay
if(airflow_speed > 7)
if(airflow_time++ >= airflow_speed - 7)
sleep(1 * tick_multiplier)
else
sleep(max(1,10-(airflow_speed+3)) * tick_multiplier)
if ((!( src.airflow_dest ) || src.loc == src.airflow_dest))
src.airflow_dest = locate(min(max(src.x + xo, 1), world.maxx), min(max(src.y + yo, 1), world.maxy), src.z)
if ((src.x == 1 || src.x == world.maxx || src.y == 1 || src.y == world.maxy))
return
if(!istype(loc, /turf))
return
step_towards(src, src.airflow_dest)
if(ismob(src) && src:client)
src:client:move_delay = world.time + vsc.airflow_mob_slowdown
airflow_dest = null
airflow_speed = 0
airflow_time = 0
if(od)
density = 0
have been moved to SSairflow.
*/
/atom/movable/Bump(atom/A)
if(airflow_speed > 0 && airflow_dest)
+9 -6
View File
@@ -29,11 +29,8 @@
//Convenience function for atoms to update turfs they occupy
/atom/movable/proc/update_nearby_tiles(need_rebuild)
if(!air_master)
return 0
for(var/turf/simulated/turf in locs)
air_master.mark_for_update(turf)
SSair.mark_for_update(turf)
return 1
@@ -54,9 +51,9 @@ turf/c_airblock(turf/other)
#ifdef ZASDBG
ASSERT(isturf(other))
#endif
if(blocks_air || other.blocks_air)
if(((blocks_air & AIR_BLOCKED) || (other.blocks_air & AIR_BLOCKED)))
return BLOCKED
//Z-level handling code. Always block if there isn't an open space.
#ifdef ZLEVELS
if(other.z != src.z)
@@ -66,6 +63,12 @@ turf/c_airblock(turf/other)
if(!istype(other, /turf/simulated/open)) return BLOCKED
#endif
if(((blocks_air & ZONE_BLOCKED) || (other.blocks_air & ZONE_BLOCKED)))
if(z == other.z)
return ZONE_BLOCKED
else
return AIR_BLOCKED
var/result = 0
for(var/atom/movable/M in contents)
result |= M.c_airblock(other)
+9 -9
View File
@@ -5,7 +5,7 @@
/*
Overview:
Connections are made between turfs by air_master.connect(). They represent a single point where two zones converge.
Connections are made between turfs by SSair.connect(). They represent a single point where two zones converge.
Class Vars:
A - Always a simulated turf.
@@ -60,19 +60,19 @@ Class Procs:
/connection/New(turf/simulated/A, turf/simulated/B)
#ifdef ZASDBG
ASSERT(air_master.has_valid_zone(A))
//ASSERT(air_master.has_valid_zone(B))
ASSERT(SSair.has_valid_zone(A))
//ASSERT(SSair.has_valid_zone(B))
#endif
src.A = A
src.B = B
zoneA = A.zone
if(!istype(B))
mark_space()
edge = air_master.get_edge(A.zone,B)
edge = SSair.get_edge(A.zone,B)
edge.add_connection(src)
else
zoneB = B.zone
edge = air_master.get_edge(A.zone,B.zone)
edge = SSair.get_edge(A.zone,B.zone)
edge.add_connection(src)
/connection/proc/mark_direct()
@@ -108,7 +108,7 @@ Class Procs:
erase()
return
var/block_status = air_master.air_blocked(A,B)
var/block_status = SSair.air_blocked(A,B)
if(block_status & AIR_BLOCKED)
//world << "Blocked connection."
erase()
@@ -133,7 +133,7 @@ Class Procs:
return
else
edge.remove_connection(src)
edge = air_master.get_edge(A.zone, B)
edge = SSair.get_edge(A.zone, B)
edge.add_connection(src)
zoneA = A.zone
@@ -155,7 +155,7 @@ Class Procs:
//world << "Zones changed, \..."
if(A.zone && B.zone)
edge.remove_connection(src)
edge = air_master.get_edge(A.zone, B.zone)
edge = SSair.get_edge(A.zone, B.zone)
edge.add_connection(src)
zoneA = A.zone
zoneB = B.zone
@@ -165,4 +165,4 @@ Class Procs:
return
//world << "valid."
//world << "valid."
+25 -17
View File
@@ -2,7 +2,7 @@
Overview:
These are what handle gas transfers between zones and into space.
They are found in a zone's edges list and in air_master.edges.
They are found in a zone's edges list and in SSair.edges.
Each edge updates every air tick due to their role in gas transfer.
They come in two flavors, /connection_edge/zone and /connection_edge/unsimulated.
As the type names might suggest, they handle inter-zone and spacelike connections respectively.
@@ -72,10 +72,12 @@ Class Procs:
/connection_edge/proc/add_connection(connection/c)
coefficient++
if(c.direct()) direct++
//world << "Connection added: [type] Coefficient: [coefficient]"
// log_debug("Connection added: [type] Coefficient: [coefficient]")
/connection_edge/proc/remove_connection(connection/c)
//world << "Connection removed: [type] Coefficient: [coefficient-1]"
// log_debug("Connection removed: [type] Coefficient: [coefficient-1]")
coefficient--
if(coefficient <= 0)
erase()
@@ -84,8 +86,8 @@ Class Procs:
/connection_edge/proc/contains_zone(zone/Z)
/connection_edge/proc/erase()
air_master.remove_edge(src)
//world << "[type] Erased."
SSair.remove_edge(src)
// log_debug("[type] Erased.")
/connection_edge/proc/tick()
@@ -128,7 +130,8 @@ Class Procs:
A.edges.Add(src)
B.edges.Add(src)
//id = edge_id(A,B)
//world << "New edge between [A] and [B]"
// log_debug("New edge between [A] and [B]")
/connection_edge/zone/add_connection(connection/c)
. = ..()
@@ -170,18 +173,19 @@ Class Procs:
if(equiv)
if(direct)
erase()
air_master.merge(A, B)
SSair.merge(A, B)
return
else
A.air.equalize(B.air)
air_master.mark_edge_sleeping(src)
SSair.mark_edge_sleeping(src)
air_master.mark_zone_update(A)
air_master.mark_zone_update(B)
SSair.mark_zone_update(A)
SSair.mark_zone_update(B)
/connection_edge/zone/recheck()
if(!A.air.compare(B.air))
air_master.mark_edge_active(src)
// Edges with only one side being vacuum need processing no matter how close.
if(!A.air.compare(B.air, vacuum_exception = 1))
SSair.mark_edge_active(src)
//Helper proc to get connections for a zone.
/connection_edge/zone/proc/get_connected_zone(zone/from)
@@ -197,7 +201,8 @@ Class Procs:
A.edges.Add(src)
air = B.return_air()
//id = 52*A.id
//world << "New edge from [A] to [B]."
// log_debug("New edge from [A] to [B].")
/connection_edge/unsimulated/add_connection(connection/c)
. = ..()
@@ -230,13 +235,16 @@ Class Procs:
if(equiv)
A.air.copy_from(air)
air_master.mark_edge_sleeping(src)
SSair.mark_edge_sleeping(src)
air_master.mark_zone_update(A)
SSair.mark_zone_update(A)
/connection_edge/unsimulated/recheck()
if(!A.air.compare(air))
air_master.mark_edge_active(src)
// Edges with only one side being vacuum need processing no matter how close.
// Note: This handles the glaring flaw of a room holding pressure while exposed to space, but
// does not specially handle the less common case of a simulated room exposed to an unsimulated pressurized turf.
if(!A.air.compare(air, vacuum_exception = 1))
SSair.mark_edge_active(src)
proc/ShareHeat(datum/gas_mixture/A, datum/gas_mixture/B, connecting_tiles)
//This implements a simplistic version of the Stefan-Boltzmann law.
+2 -2
View File
@@ -16,7 +16,7 @@ Class Procs:
Preferable to accessing the connection directly because it checks validity.
place(connection/c, d)
Called by air_master.connect(). Sets the connection in the specified direction to c.
Called by SSair.connect(). Sets the connection in the specified direction to c.
update_all()
Called after turf/update_air_properties(). Updates the validity of all connections on this turf.
@@ -99,4 +99,4 @@ Class Procs:
#endif
/connection_manager/proc/check(connection/c)
return c && c.valid()
return c && c.valid()
-375
View File
@@ -1,375 +0,0 @@
var/datum/controller/air_system/air_master
var/tick_multiplier = 2
/*
Overview:
The air controller does everything. There are tons of procs in here.
Class Vars:
zones - All zones currently holding one or more turfs.
edges - All processing edges.
tiles_to_update - Tiles scheduled to update next tick.
zones_to_update - Zones which have had their air changed and need air archival.
active_hotspots - All processing fire objects.
active_zones - The number of zones which were archived last tick. Used in debug verbs.
next_id - The next UID to be applied to a zone. Mostly useful for debugging purposes as zones do not need UIDs to function.
Class Procs:
mark_for_update(turf/T)
Adds the turf to the update list. When updated, update_air_properties() will be called.
When stuff changes that might affect airflow, call this. It's basically the only thing you need.
add_zone(zone/Z) and remove_zone(zone/Z)
Adds zones to the zones list. Does not mark them for update.
air_blocked(turf/A, turf/B)
Returns a bitflag consisting of:
AIR_BLOCKED - The connection between turfs is physically blocked. No air can pass.
ZONE_BLOCKED - There is a door between the turfs, so zones cannot cross. Air may or may not be permeable.
has_valid_zone(turf/T)
Checks the presence and validity of T's zone.
May be called on unsimulated turfs, returning 0.
merge(zone/A, zone/B)
Called when zones have a direct connection and equivalent pressure and temperature.
Merges the zones to create a single zone.
connect(turf/simulated/A, turf/B)
Called by turf/update_air_properties(). The first argument must be simulated.
Creates a connection between A and B.
mark_zone_update(zone/Z)
Adds zone to the update list. Unlike mark_for_update(), this one is called automatically whenever
air is returned from a simulated turf.
equivalent_pressure(zone/A, zone/B)
Currently identical to A.air.compare(B.air). Returns 1 when directly connected zones are ready to be merged.
get_edge(zone/A, zone/B)
get_edge(zone/A, turf/B)
Gets a valid connection_edge between A and B, creating a new one if necessary.
has_same_air(turf/A, turf/B)
Used to determine if an unsimulated edge represents a specific turf.
Simulated edges use connection_edge/contains_zone() for the same purpose.
Returns 1 if A has identical gases and temperature to B.
remove_edge(connection_edge/edge)
Called when an edge is erased. Removes it from processing.
*/
//Geometry lists
/datum/controller/air_system/var/list/zones = list()
/datum/controller/air_system/var/list/edges = list()
//Geometry updates lists
/datum/controller/air_system/var/list/tiles_to_update = list()
/datum/controller/air_system/var/list/zones_to_update = list()
/datum/controller/air_system/var/list/active_fire_zones = list()
/datum/controller/air_system/var/list/active_hotspots = list()
/datum/controller/air_system/var/list/active_edges = list()
/datum/controller/air_system/var/active_zones = 0
/datum/controller/air_system/var/current_cycle = 0
/datum/controller/air_system/var/update_delay = 5 //How long between check should it try to process atmos again.
/datum/controller/air_system/var/failed_ticks = 0 //How many ticks have runtimed?
/datum/controller/air_system/var/tick_progress = 0
/datum/controller/air_system/var/next_id = 1 //Used to keep track of zone UIDs.
/datum/controller/air_system/proc/Setup()
//Purpose: Call this at the start to setup air groups geometry
// (Warning: Very processor intensive but only must be done once per round)
//Called by: Gameticker/Master controller
//Inputs: None.
//Outputs: None.
#ifndef ZASDBG
set background = 1
#endif
admin_notice("<span class='danger'>Processing Geometry...</span>", R_DEBUG)
sleep(-1)
var/start_time = world.timeofday
var/simulated_turf_count = 0
for(var/turf/simulated/S in world)
simulated_turf_count++
S.update_air_properties()
admin_notice({"<span class='danger'>Geometry initialized in [round(0.1*(world.timeofday-start_time),0.1)] seconds.</span>
<span class='info'>
Total Simulated Turfs: [simulated_turf_count]
Total Zones: [zones.len]
Total Edges: [edges.len]
Total Active Edges: [active_edges.len ? "<span class='danger'>[active_edges.len]</span>" : "None"]
Total Unsimulated Turfs: [world.maxx*world.maxy*world.maxz - simulated_turf_count]
</span>"}, R_DEBUG)
// spawn Start()
/datum/controller/air_system/proc/Start()
//Purpose: This is kicked off by the master controller, and controls the processing of all atmosphere.
//Called by: Master controller
//Inputs: None.
//Outputs: None.
#ifndef ZASDBG
set background = 1
#endif
while(1)
Tick()
sleep(max(5,update_delay*tick_multiplier))
/datum/controller/air_system/proc/Tick()
. = 1 //Set the default return value, for runtime detection.
current_cycle++
//If there are tiles to update, do so.
tick_progress = "updating turf properties"
var/list/updating
if(tiles_to_update.len)
updating = tiles_to_update
tiles_to_update = list()
#ifdef ZASDBG
var/updated = 0
#endif
//defer updating of self-zone-blocked turfs until after all other turfs have been updated.
//this hopefully ensures that non-self-zone-blocked turfs adjacent to self-zone-blocked ones
//have valid zones when the self-zone-blocked turfs update.
var/list/deferred = list()
for(var/turf/T in updating)
//check if the turf is self-zone-blocked
if(T.c_airblock(T) & ZONE_BLOCKED)
deferred += T
continue
T.update_air_properties()
T.post_update_air_properties()
T.needs_air_update = 0
#ifdef ZASDBG
T.overlays -= mark
updated++
#endif
//sleep(1)
for(var/turf/T in deferred)
T.update_air_properties()
T.post_update_air_properties()
T.needs_air_update = 0
#ifdef ZASDBG
T.overlays -= mark
updated++
#endif
#ifdef ZASDBG
if(updated != updating.len)
tick_progress = "[updating.len - updated] tiles left unupdated."
world << "<span class='danger'>[tick_progress]</span>"
. = 0
#endif
//Where gas exchange happens.
if(.)
tick_progress = "processing edges"
for(var/connection_edge/edge in active_edges)
edge.tick()
//Process fire zones.
if(.)
tick_progress = "processing fire zones"
for(var/zone/Z in active_fire_zones)
Z.process_fire()
//Process hotspots.
if(.)
tick_progress = "processing hotspots"
for(var/obj/fire/fire in active_hotspots)
fire.process()
//Process zones.
if(.)
tick_progress = "updating zones"
active_zones = zones_to_update.len
if(zones_to_update.len)
updating = zones_to_update
zones_to_update = list()
for(var/zone/zone in updating)
zone.tick()
zone.needs_update = 0
if(.)
tick_progress = "success"
/datum/controller/air_system/proc/add_zone(zone/z)
zones.Add(z)
z.name = "Zone [next_id++]"
mark_zone_update(z)
/datum/controller/air_system/proc/remove_zone(zone/z)
zones.Remove(z)
zones_to_update.Remove(z)
/datum/controller/air_system/proc/air_blocked(turf/A, turf/B)
#ifdef ZASDBG
ASSERT(isturf(A))
ASSERT(isturf(B))
#endif
var/ablock = A.c_airblock(B)
if(ablock == BLOCKED) return BLOCKED
return ablock | B.c_airblock(A)
/datum/controller/air_system/proc/has_valid_zone(turf/simulated/T)
#ifdef ZASDBG
ASSERT(istype(T))
#endif
return istype(T) && T.zone && !T.zone.invalid
/datum/controller/air_system/proc/merge(zone/A, zone/B)
#ifdef ZASDBG
ASSERT(istype(A))
ASSERT(istype(B))
ASSERT(!A.invalid)
ASSERT(!B.invalid)
ASSERT(A != B)
#endif
if(A.contents.len < B.contents.len)
A.c_merge(B)
mark_zone_update(B)
else
B.c_merge(A)
mark_zone_update(A)
/datum/controller/air_system/proc/connect(turf/simulated/A, turf/simulated/B)
#ifdef ZASDBG
ASSERT(istype(A))
ASSERT(isturf(B))
ASSERT(A.zone)
ASSERT(!A.zone.invalid)
//ASSERT(B.zone)
ASSERT(A != B)
#endif
var/block = air_master.air_blocked(A,B)
if(block & AIR_BLOCKED) return
var/direct = !(block & ZONE_BLOCKED)
var/space = !istype(B)
if(!space)
if(min(A.zone.contents.len, B.zone.contents.len) < ZONE_MIN_SIZE || (direct && (equivalent_pressure(A.zone,B.zone) || current_cycle == 0)))
merge(A.zone,B.zone)
return
var
a_to_b = get_dir(A,B)
b_to_a = get_dir(B,A)
if(!A.connections) A.connections = new
if(!B.connections) B.connections = new
if(A.connections.get(a_to_b)) return
if(B.connections.get(b_to_a)) return
if(!space)
if(A.zone == B.zone) return
var/connection/c = new /connection(A,B)
A.connections.place(c, a_to_b)
B.connections.place(c, b_to_a)
if(direct) c.mark_direct()
/datum/controller/air_system/proc/mark_for_update(turf/T)
#ifdef ZASDBG
ASSERT(isturf(T))
#endif
if(T.needs_air_update) return
tiles_to_update |= T
#ifdef ZASDBG
T.overlays += mark
#endif
T.needs_air_update = 1
/datum/controller/air_system/proc/mark_zone_update(zone/Z)
#ifdef ZASDBG
ASSERT(istype(Z))
#endif
if(Z.needs_update) return
zones_to_update.Add(Z)
Z.needs_update = 1
/datum/controller/air_system/proc/mark_edge_sleeping(connection_edge/E)
#ifdef ZASDBG
ASSERT(istype(E))
#endif
if(E.sleeping) return
active_edges.Remove(E)
E.sleeping = 1
/datum/controller/air_system/proc/mark_edge_active(connection_edge/E)
#ifdef ZASDBG
ASSERT(istype(E))
#endif
if(!E.sleeping) return
active_edges.Add(E)
E.sleeping = 0
/datum/controller/air_system/proc/equivalent_pressure(zone/A, zone/B)
return A.air.compare(B.air)
/datum/controller/air_system/proc/get_edge(zone/A, zone/B)
if(istype(B))
for(var/connection_edge/zone/edge in A.edges)
if(edge.contains_zone(B)) return edge
var/connection_edge/edge = new/connection_edge/zone(A,B)
edges.Add(edge)
edge.recheck()
return edge
else
for(var/connection_edge/unsimulated/edge in A.edges)
if(has_same_air(edge.B,B)) return edge
var/connection_edge/edge = new/connection_edge/unsimulated(A,B)
edges.Add(edge)
edge.recheck()
return edge
/datum/controller/air_system/proc/has_same_air(turf/A, turf/B)
if(A.oxygen != B.oxygen) return 0
if(A.nitrogen != B.nitrogen) return 0
if(A.phoron != B.phoron) return 0
if(A.carbon_dioxide != B.carbon_dioxide) return 0
if(A.temperature != B.temperature) return 0
return 1
/datum/controller/air_system/proc/remove_edge(connection_edge/E)
edges.Remove(E)
if(!E.sleeping) active_edges.Remove(E)
+3 -3
View File
@@ -1,13 +1,13 @@
client/proc/ZoneTick()
/*client/proc/ZoneTick()
set category = "Debug"
set name = "Process Atmos"
var/result = air_master.Tick()
var/result = SSair.tick(true)
if(result)
src << "Sucessfully Processed."
else
src << "Failed to process! ([air_master.tick_progress])"
src << "Failed to process! ([SSair.tick_progress])"*/
client/proc/Zone_Info(turf/T as null|turf)
+6 -6
View File
@@ -63,7 +63,7 @@ turf/proc/hotspot_expose(exposed_temperature, exposed_volume, soh = 0)
fuel_objs.Cut()
if(!fire_tiles.len)
air_master.active_fire_zones.Remove(src)
SSair.active_fire_zones.Remove(src)
/zone/proc/remove_liquidfuel(var/used_liquid_fuel, var/remove_fire=0)
if(!fuel_objs.len)
@@ -100,7 +100,7 @@ turf/proc/hotspot_expose(exposed_temperature, exposed_volume, soh = 0)
return 1
fire = new(src, fl)
air_master.active_fire_zones |= zone
SSair.active_fire_zones |= zone
var/obj/effect/decal/cleanable/liquid_fuel/fuel = locate() in src
zone.fire_tiles |= src
@@ -128,7 +128,7 @@ turf/proc/hotspot_expose(exposed_temperature, exposed_volume, soh = 0)
var/turf/simulated/my_tile = loc
if(!istype(my_tile) || !my_tile.zone)
if(my_tile.fire == src)
if(my_tile && my_tile.fire == src)
my_tile.fire = null
RemoveFire()
return 1
@@ -197,7 +197,7 @@ turf/proc/hotspot_expose(exposed_temperature, exposed_volume, soh = 0)
set_light(3, 1, color)
firelevel = fl
air_master.active_hotspots.Add(src)
SSair.active_hotspots.Add(src)
/obj/fire/proc/fire_color(var/env_temperature)
var/temperature = max(4000*sqrt(firelevel/vsc.fire_firelevel_multiplier), env_temperature)
@@ -206,7 +206,7 @@ turf/proc/hotspot_expose(exposed_temperature, exposed_volume, soh = 0)
/obj/fire/Destroy()
RemoveFire()
..()
return ..()
/obj/fire/proc/RemoveFire()
var/turf/T = loc
@@ -215,7 +215,7 @@ turf/proc/hotspot_expose(exposed_temperature, exposed_volume, soh = 0)
T.fire = null
loc = null
air_master.active_hotspots.Remove(src)
SSair.active_hotspots.Remove(src)
/turf/simulated/var/fire_protection = 0 //Protects newly extinguished tiles from being overrun again.
+39 -36
View File
@@ -5,10 +5,10 @@
/turf/var/datum/gas_mixture/air
/turf/simulated/proc/update_graphic(list/graphic_add = null, list/graphic_remove = null)
if(graphic_add && graphic_add.len)
overlays += graphic_add
if(graphic_remove && graphic_remove.len)
overlays -= graphic_remove
if (LAZYLEN(graphic_add))
add_overlay(graphic_add.Copy(), TRUE) // We need to copy because SSoverlay will mutate this list & add appearance objects.
if(LAZYLEN(graphic_remove))
cut_overlay(graphic_remove.Copy(), TRUE)
/turf/proc/update_air_properties()
var/block = c_airblock(src)
@@ -41,9 +41,9 @@
if(istype(unsim, /turf/simulated))
var/turf/simulated/sim = unsim
if(air_master.has_valid_zone(sim))
if(SSair.has_valid_zone(sim))
air_master.connect(sim, src)
SSair.connect(sim, src)
/*
Simple heuristic for determining if removing the turf from it's zone will not partition the zone (A very bad thing).
@@ -52,54 +52,56 @@
*/
/turf/simulated/proc/can_safely_remove_from_zone()
#ifdef ZLEVELS
return 0 //TODO generalize this to multiz.
#else
if(!zone) return 1
var/check_dirs = get_zone_neighbours(src)
var/unconnected_dirs = check_dirs
for(var/dir in list(NORTHWEST, NORTHEAST, SOUTHEAST, SOUTHWEST))
var/to_check = list(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST)
#ifdef ZLEVELS
to_check += list(NORTHUP, EASTUP, WESTUP, SOUTHUP, NORTHDOWN, EASTDOWN, WESTDOWN, SOUTHDOWN)
#endif
for(var/dir in to_check)
//for each pair of "adjacent" cardinals (e.g. NORTH and WEST, but not NORTH and SOUTH)
if((dir & check_dirs) == dir)
//check that they are connected by the corner turf
var/connected_dirs = get_zone_neighbours(get_step(src, dir))
if(connected_dirs && (dir & turn(connected_dirs, 180)) == dir)
if(connected_dirs && (dir & reverse_dir[connected_dirs]) == dir)
unconnected_dirs &= ~dir //they are, so unflag the cardinals in question
//it is safe to remove src from the zone if all cardinals are connected by corner turfs
return !unconnected_dirs
#endif
//helper for can_safely_remove_from_zone()
/turf/simulated/proc/get_zone_neighbours(turf/simulated/T)
. = 0
if(istype(T) && T.zone)
for(var/dir in cardinal)
var/to_check = cardinal.Copy()
#ifdef ZLEVELS
to_check += list(UP, DOWN)
#endif
for(var/dir in to_check)
var/turf/simulated/other = get_step(T, dir)
if(istype(other) && other.zone == T.zone && !(other.c_airblock(T) & AIR_BLOCKED) && get_dist(src, other) <= 1)
. |= dir
/turf/simulated/update_air_properties()
if(zone && zone.invalid)
c_copy_air()
if(zone && zone.invalid) //this turf's zone is in the process of being rebuilt
c_copy_air() //not very efficient :(
zone = null //Easier than iterating through the list at the zone.
var/s_block = c_airblock(src)
if(s_block & AIR_BLOCKED)
#ifdef ZASDBG
if(verbose) world << "Self-blocked."
if(verbose) log_debug("Self-blocked.")
//dbg(blocked)
#endif
if(zone)
var/zone/z = zone
if(can_safely_remove_from_zone()) //Helps normal airlocks avoid rebuilding zones all the time
c_copy_air() //we aren't rebuilding, but hold onto the old air so it can be readded
z.remove(src)
else
z.rebuild()
@@ -125,7 +127,7 @@
if(block & AIR_BLOCKED)
#ifdef ZASDBG
if(verbose) world << "[d] is blocked."
if(verbose) log_debug("[d] is blocked.")
//unsim.dbg(air_blocked, turn(180,d))
#endif
@@ -135,7 +137,7 @@
if(r_block & AIR_BLOCKED)
#ifdef ZASDBG
if(verbose) world << "[d] is blocked."
if(verbose) log_debug("[d] is blocked.")
//dbg(air_blocked, d)
#endif
@@ -156,17 +158,18 @@
var/turf/simulated/sim = unsim
sim.open_directions |= reverse_dir[d]
if(air_master.has_valid_zone(sim))
if(SSair.has_valid_zone(sim))
//Might have assigned a zone, since this happens for each direction.
if(!zone)
//We do not merge if
//We do not merge if
// they are blocking us and we are not blocking them, or if
// we are blocking them and not blocking ourselves - this prevents tiny zones from forming on doorways.
if(((block & ZONE_BLOCKED) && !(r_block & ZONE_BLOCKED)) || ((r_block & ZONE_BLOCKED) && !(s_block & ZONE_BLOCKED)))
#ifdef ZASDBG
if(verbose) world << "[d] is zone blocked."
if(verbose) log_debug("[d] is zone blocked.")
//dbg(zone_blocked, d)
#endif
@@ -180,22 +183,22 @@
#ifdef ZASDBG
dbg(assigned)
if(verbose) world << "Added to [zone]"
if(verbose) log_debug("Added to [zone]")
#endif
else if(sim.zone != zone)
#ifdef ZASDBG
if(verbose) world << "Connecting to [sim.zone]"
if(verbose) log_debug("Connecting to [sim.zone]")
#endif
air_master.connect(src, sim)
SSair.connect(src, sim)
#ifdef ZASDBG
else if(verbose) world << "[d] has same zone."
else if(verbose) log_debug("[d] has same zone.")
else if(verbose) world << "[d] has invalid zone."
else if(verbose) log_debug("[d] has invalid zone.")
#endif
else
@@ -204,7 +207,7 @@
if(!postponed) postponed = list()
postponed.Add(unsim)
if(!air_master.has_valid_zone(src)) //Still no zone, make a new one.
if(!SSair.has_valid_zone(src)) //Still no zone, make a new one.
var/zone/newzone = new/zone()
newzone.add(src)
@@ -217,7 +220,7 @@
//At this point, a zone should have happened. If it hasn't, don't add more checks, fix the bug.
for(var/turf/T in postponed)
air_master.connect(src, T)
SSair.connect(src, T)
/turf/proc/post_update_air_properties()
if(connections) connections.update_all()
@@ -273,7 +276,7 @@
/turf/simulated/return_air()
if(zone)
if(!zone.invalid)
air_master.mark_zone_update(zone)
SSair.mark_zone_update(zone)
return zone.air
else
if(!air)
+26 -23
View File
@@ -40,23 +40,24 @@ Class Procs:
*/
/zone/var/name
/zone/var/invalid = 0
/zone/var/list/contents = list()
/zone/var/list/fire_tiles = list()
/zone/var/list/fuel_objs = list()
/zone
var/name
var/invalid = 0
var/list/contents = list()
var/list/fire_tiles = list()
var/list/fuel_objs = list()
/zone/var/needs_update = 0
var/needs_update = 0
/zone/var/list/edges = list()
var/list/edges = list()
/zone/var/datum/gas_mixture/air = new
var/datum/gas_mixture/air = new
/zone/var/list/graphic_add = list()
/zone/var/list/graphic_remove = list()
var/list/graphic_add = list()
var/list/graphic_remove = list()
/zone/New()
air_master.add_zone(src)
SSair.add_zone(src)
air.temperature = TCMB
air.group_multiplier = 1
air.volume = CELL_VOLUME
@@ -65,17 +66,16 @@ Class Procs:
#ifdef ZASDBG
ASSERT(!invalid)
ASSERT(istype(T))
ASSERT(!air_master.has_valid_zone(T))
ASSERT(!SSair.has_valid_zone(T))
#endif
var/datum/gas_mixture/turf_air = T.return_air()
add_tile_air(turf_air)
T.zone = src
contents.Add(T)
contents += T
if(T.fire)
var/obj/effect/decal/cleanable/liquid_fuel/fuel = locate() in T
fire_tiles.Add(T)
air_master.active_fire_zones |= src
SSair.active_fire_zones |= src
if(fuel) fuel_objs += fuel
T.update_graphic(air.graphic)
@@ -86,8 +86,8 @@ Class Procs:
ASSERT(T.zone == src)
soft_assert(T in contents, "Lists are weird broseph")
#endif
contents.Remove(T)
fire_tiles.Remove(T)
contents -= T
fire_tiles -= T
if(T.fire)
var/obj/effect/decal/cleanable/liquid_fuel/fuel = locate() in T
fuel_objs -= fuel
@@ -118,24 +118,27 @@ Class Procs:
if(E.contains_zone(into))
continue //don't need to rebuild this edge
for(var/turf/T in E.connecting_turfs)
air_master.mark_for_update(T)
SSair.mark_for_update(T)
/zone/proc/c_invalidate()
invalid = 1
air_master.remove_zone(src)
SSair.remove_zone(src)
#ifdef ZASDBG
for(var/turf/simulated/T in contents)
T.dbg(invalid_zone)
#endif
/zone/proc/rebuild()
set waitfor = FALSE
if(invalid) return //Short circuit for explosions where rebuild is called many times over.
c_invalidate()
for(var/turf/simulated/T in contents)
T.update_graphic(graphic_remove = air.graphic) //we need to remove the overlays so they're not doubled when the zone is rebuilt
//T.dbg(invalid_zone)
T.needs_air_update = 0 //Reset the marker so that it will be added to the list.
air_master.mark_for_update(T)
SSair.mark_for_update(T)
CHECK_TICK
/zone/proc/add_tile_air(datum/gas_mixture/tile_air)
//air.volume += CELL_VOLUME
@@ -146,7 +149,7 @@ Class Procs:
air.group_multiplier = contents.len+1
/zone/proc/tick()
if(air.temperature >= PHORON_FLASHPOINT && !(src in air_master.active_fire_zones) && air.check_combustability() && contents.len)
if(air.temperature >= PHORON_FLASHPOINT && !(src in SSair.active_fire_zones) && air.check_combustability() && contents.len)
var/turf/T = pick(contents)
if(istype(T))
T.create_fire(vsc.fire_firelevel_multiplier)
@@ -165,7 +168,7 @@ Class Procs:
M << name
for(var/g in air.gas)
M << "[gas_data.name[g]]: [air.gas[g]]"
M << "P: [air.return_pressure()] kPa V: [air.volume]L T: [air.temperature]°K ([air.temperature - T0C]°C)"
M << "P: [air.return_pressure()] kPa V: [air.volume]L T: [air.temperature]K ([air.temperature - T0C]C)"
M << "O2 per N2: [(air.gas["nitrogen"] ? air.gas["oxygen"]/air.gas["nitrogen"] : "N/A")] Moles: [air.total_moles]"
M << "Simulated: [contents.len] ([air.group_multiplier])"
//M << "Unsimulated: [unsimulated_contents.len]"
@@ -185,4 +188,4 @@ Class Procs:
M << "Space Edges: [space_edges] ([space_coefficient] connections)"
//for(var/turf/T in unsimulated_contents)
// M << "[T] at ([T.x],[T.y])"
// M << "[T] at ([T.x],[T.y])"
+2 -2
View File
@@ -15,7 +15,7 @@ Every air tick:
Important Functions:
air_master.mark_for_update(turf)
SSair.mark_for_update(turf)
When stuff happens, call this. It works on everything. You basically don't need to worry about any other
functions besides CanPass().
@@ -28,7 +28,7 @@ Notes for people who used ZAS before:
*/
//#define ZASDBG
//#define ZLEVELS
#define ZLEVELS
#define AIR_BLOCKED 1
#define ZONE_BLOCKED 2
+9
View File
@@ -0,0 +1,9 @@
//#define ZASDBG
//#define ZLEVELS
#define AIR_BLOCKED 1
#define ZONE_BLOCKED 2
#define BLOCKED 3
#define ZONE_MIN_SIZE 14 //zones with less than this many turfs will always merge, even if the connection is not direct
+4
View File
@@ -0,0 +1,4 @@
#define PLANE_SPACE_BACKGROUND -98
#define PLANE_SPACE_PARALLAX (PLANE_SPACE_BACKGROUND + 1) // -97
#define PLANE_SPACE_DUST (PLANE_SPACE_PARALLAX + 1) // -96
#define PLANE_ABOVE_PARALLAX (PLANE_SPACE_BACKGROUND + 3) // -95
+1
View File
@@ -27,6 +27,7 @@
#define MAX_HIGH_PRESSURE_DAMAGE 4 // This used to be 20... I got this much random rage for some retarded decision by polymorph?! Polymorph now lies in a pool of blood with a katana jammed in his spleen. ~Errorage --PS: The katana did less than 20 damage to him :(
#define LOW_PRESSURE_DAMAGE 2 // The amount of damage someone takes when in a low pressure area. (The pressure threshold is so low that it doesn't make sense to do any calculations, so it just applies this flat value).
#define MINIMUM_PRESSURE_DIFFERENCE_TO_SUSPEND (MINIMUM_AIR_TO_SUSPEND*R_IDEAL_GAS_EQUATION*T20C)/CELL_VOLUME // Minimum pressure difference between zones to suspend
#define MINIMUM_AIR_RATIO_TO_SUSPEND 0.05 // Minimum ratio of air that must move to/from a tile to suspend group processing
#define MINIMUM_AIR_TO_SUSPEND (MOLES_CELLSTANDARD * MINIMUM_AIR_RATIO_TO_SUSPEND) // Minimum amount of air that has to move before a group processing can be suspended
#define MINIMUM_MOLES_DELTA_TO_MOVE (MOLES_CELLSTANDARD * MINIMUM_AIR_RATIO_TO_SUSPEND) // Either this must be active
-18
View File
@@ -1,18 +0,0 @@
// Comment this out if the external btime library is unavailable
#define PRECISE_TIMER_AVAILABLE
#ifdef PRECISE_TIMER_AVAILABLE
var/global/__btime__libName = "btime.[world.system_type==MS_WINDOWS?"dll":"so"]"
#define TimeOfHour (__extern__timeofhour)
#define __extern__timeofhour text2num(call(__btime__libName, "gettime")())
/hook/startup/proc/checkbtime()
try
// This will always return 1 unless the btime library cannot be accessed
if(TimeOfHour || 1) return 1
catch(var/exception/e)
log_to_dd("PRECISE_TIMER_AVAILABLE is defined in btime.dm, but calling the btime library failed: [e]")
log_to_dd("This is a fatal error. The world will now shut down.")
del(world)
#else
#define TimeOfHour (world.timeofday % 36000)
#endif
+4
View File
@@ -0,0 +1,4 @@
#define GLOBAL_PROC "some_magic_bullshit"
#define CALLBACK new /datum/callback
#define INVOKE_ASYNC ImmediateInvokeAsync
@@ -56,4 +56,4 @@
#define TRAIT_BIOLUM 36
#define TRAIT_BIOLUM_COLOUR 37
#define TRAIT_IMMUTABLE 38
#define TRAIT_FLESH_COLOUR 39
#define TRAIT_FLESH_COLOUR 39
+18 -2
View File
@@ -1,13 +1,19 @@
#define LIGHTING_INTERVAL 2 // Frequency, in 1/10ths of a second, of the lighting process.
#define LIGHTING_HEIGHT 1 // height off the ground of light sources on the pseudo-z-axis, you should probably leave this alone
#define LIGHTING_ROUND_VALUE 1 / 128 //Value used to round lumcounts, values smaller than 1/255 don't matter (if they do, thanks sinking points), greater values will make lighting less precise, but in turn increase performance, VERY SLIGHTLY.
#define LIGHTING_ROUND_VALUE 1 / 200 //Value used to round lumcounts, values smaller than 1/255 don't matter (if they do, thanks sinking points), greater values will make lighting less precise, but in turn increase performance, VERY SLIGHTLY.
#define LIGHTING_ICON 'icons/effects/lighting_overlay.dmi' // icon used for lighting shading effects
#define LIGHTING_BASE_ICON_STATE "matrix"
#define LIGHTING_BASE_ICON_STATE "matrix" // icon_state used for normal color-matrix based lighting overlays.
#define LIGHTING_STATION_ICON_STATE "tubedefault" // icon_state used for lighting overlays that are just displaying standard station lighting.
#define LIGHTING_DARKNESS_ICON_STATE "black" // icon_state used for lighting overlays with no luminosity.
#define LIGHTING_SOFT_THRESHOLD 0.001 // If the max of the lighting lumcounts of each spectrum drops below this, disable luminosity on the lighting overlays.
// If defined, a tiny random number will be added to lighting matrixes to prevent a memory leak bug in v510 and below.
// Enabling this disables lighting rounding.
#define LIGHTING_USE_MEMORY_HACK
// If I were you I'd leave this alone.
#define LIGHTING_BASE_MATRIX \
list \
@@ -41,6 +47,12 @@
#define CL_MATRIX_CB 19
#define CL_MATRIX_CA 20
// This color of overlay is very common - most of the station is this color when lit fully.
// Tube lights are a bluish-white, so we can't just assume 1-1-1 is full-illumination.
#define LIGHTING_DEFAULT_TUBE_R 0.96
#define LIGHTING_DEFAULT_TUBE_G 1
#define LIGHTING_DEFAULT_TUBE_B 1
//Some defines to generalise colours used in lighting.
//Important note on colors. Colors can end up significantly different from the basic html picture, especially when saturated
#define LIGHT_COLOR_RED "#FA8282" //Warm but extremely diluted red. rgb(250, 130, 130)
@@ -91,3 +103,7 @@
// Just so we can avoid unneeded proc calls when profiling is disabled.
#define L_PROF(O,T) if (lighting_profiling) {lprof_write(O,T);}
#if !defined(LIGHTING_USE_MEMORY_HACK) && DM_VERSION < 511
#warn You appear to be using a pre-511 version of BYOND, but have the memory leak hack disabled. You may encounter server crashes due to a memory leak in BYOND 510 and below's handling of color matrixes.
#endif
+8
View File
@@ -0,0 +1,8 @@
#define LAZYINITLIST(L) if (!L) L = list()
#define UNSETEMPTY(L) if (L && !L.len) L = null
#define LAZYREMOVE(L, I) if(L) { L -= I; if(!L.len) { L = null; } }
#define LAZYADD(L, I) if(!L) { L = list(); } L += I;
#define LAZYACCESS(L, I) (L ? (isnum(I) ? (I > 0 && I <= L.len ? L[I] : null) : L[I]) : null)
#define LAZYLEN(L) length(L)
#define LAZYCLEARLIST(L) if(L) L.Cut()
+78
View File
@@ -0,0 +1,78 @@
#define TICK_LIMIT_RUNNING 80
#define TICK_LIMIT_TO_RUN 78
#define TICK_LIMIT_MC 70
#define TICK_LIMIT_MC_INIT config.mc_init_tick_limit
#define TICK_LIMIT_MC_INIT_DEFAULT 98
#define MC_TICK_CHECK ( world.tick_usage > CURRENT_TICKLIMIT ? pause() : 0 )
// For multi-step subsystems that want to split their tick into multiple parts.
#define MC_SPLIT_TICK_INIT(phase_count) var/original_tick_limit = CURRENT_TICKLIMIT; var/split_tick_phases = ##phase_count
#define MC_SPLIT_TICK \
if(split_tick_phases > 1){\
CURRENT_TICKLIMIT = ((original_tick_limit - world.tick_usage) / split_tick_phases) + world.tick_usage;\
--split_tick_phases;\
} else {\
CURRENT_TICKLIMIT = original_tick_limit;\
}
// Used to smooth out costs to try and avoid oscillation.
#define MC_AVERAGE_FAST(average, current) (0.7 * (average) + 0.3 * (current))
#define MC_AVERAGE(average, current) (0.8 * (average) + 0.2 * (current))
#define MC_AVERAGE_SLOW(average, current) (0.9 * (average) + 0.1 * (current))
#define NEW_SS_GLOBAL(varname) if(varname != src){if(istype(varname)){Recover();qdel(varname);}varname = src;}
//SubSystem flags (Please design any new flags so that the default is off, to make adding flags to subsystems easier)
//subsystem should fire during pre-game lobby.
#define SS_FIRE_IN_LOBBY 1
//subsystem does not initialize.
#define SS_NO_INIT 2
//subsystem does not fire.
// (like can_fire = 0, but keeps it from getting added to the processing subsystems list)
// (Requires a MC restart to change)
#define SS_NO_FIRE 4
//subsystem only runs on spare cpu (after all non-background subsystems have ran that tick)
// SS_BACKGROUND has its own priority bracket
#define SS_BACKGROUND 8
//subsystem does not tick check, and should not run unless there is enough time (or its running behind (unless background))
#define SS_NO_TICK_CHECK 16
//Treat wait as a tick count, not DS, run every wait ticks.
// (also forces it to run first in the tick, above even SS_NO_TICK_CHECK subsystems)
// (implies SS_FIRE_IN_LOBBY because of how it works)
// (overrides SS_BACKGROUND)
// This is designed for basically anything that works as a mini-mc (like SStimer)
#define SS_TICKER 32
//keep the subsystem's timing on point by firing early if it fired late last fire because of lag
// ie: if a 20ds subsystem fires say 5 ds late due to lag or what not, its next fire would be in 15ds, not 20ds.
#define SS_KEEP_TIMING 64
//Calculate its next fire after its fired.
// (IE: if a 5ds wait SS takes 2ds to run, its next fire should be 5ds away, not 3ds like it normally would be)
// This flag overrides SS_KEEP_TIMING
#define SS_POST_FIRE_TIMING 128
// Don't display in processes panel.
#define SS_NO_DISPLAY 256
//SUBSYSTEM STATES
#define SS_IDLE 0 //aint doing shit.
#define SS_QUEUED 1 //queued to run
#define SS_RUNNING 2 //actively running
#define SS_PAUSED 3 //paused by mc_tick_check
#define SS_SLEEPING 4 //fire() slept.
#define SS_PAUSING 5 //in the middle of pausing
// Subsystem init-states, used for the initialization MC panel.
#define SS_INITSTATE_NONE 0
#define SS_INITSTATE_STARTED 1
#define SS_INITSTATE_DONE 2
+21 -12
View File
@@ -267,14 +267,8 @@
#define LAYER_ABOVE_TABLE 2.81
// Stoplag.
#define TICK_LIMIT 80
#define TICK_CHECK ( world.tick_usage > TICK_LIMIT ? stoplag() : 0 )
#define CHECK_TICK if (world.tick_usage > TICK_LIMIT) stoplag()
// Effect Systems.
#define EFFECT_CONTINUE 0 // Keep processing.
#define EFFECT_HALT 1 // Stop processing, but don't qdel.
#define EFFECT_DESTROY 2 // qdel.
#define TICK_CHECK ( world.tick_usage > CURRENT_TICKLIMIT ? stoplag() : 0 )
#define CHECK_TICK if (world.tick_usage > CURRENT_TICKLIMIT) stoplag()
// Performance bullshit.
@@ -286,10 +280,11 @@
)
#define get_turf(A) (get_step(A, 0))
#define QDELETED(TARGET) (!TARGET || TARGET.gcDestroyed)
#define QDEL_NULL(item) qdel(item); item = null
// Shim until addtimer is merged or I figure out if it is safe to use scheduler for this.
#define QDEL_IN(OBJ, TIME) spawn(TIME) qdel(OBJ)
#define UNTIL(X) while(!(X)) stoplag()
#define MIDNIGHT_ROLLOVER 864000 //number of deciseconds in a day
#define DEBUG_REF(D) (D ? "[D]|\ref[D]" : "NULL")
#define DEBUG_REF(D) (D ? "\ref[D]|[D] ([D.type])" : "NULL")
@@ -299,3 +294,17 @@
#define OVEN 0x4
#define CANDYMAKER 0x8
#define CEREALMAKER 0x10
// MultiZAS directions.
#define NORTHUP (NORTH|UP)
#define EASTUP (EAST|UP)
#define SOUTHUP (SOUTH|UP)
#define WESTUP (WEST|UP)
#define NORTHDOWN (NORTH|DOWN)
#define EASTDOWN (EAST|DOWN)
#define SOUTHDOWN (SOUTH|DOWN)
#define WESTDOWN (WEST|DOWN)
#define NL_NOT_DISABLED 0
#define NL_TEMPORARY_DISABLE 1
#define NL_PERMANENT_DISABLE 2
+3 -1
View File
@@ -183,4 +183,6 @@
#define TYPE_HUMANOID 4//Humans, skrell, unathi, tajara, vaurca, diona, IPC, vox
#define TYPE_WIERD 8//Slimes, constructs, demons, and other creatures of a magical or bluespace nature.
// Maximum number of chickens allowed at once.
// If the number of chickens on the map exceeds this, laid eggs will not hatch.
#define MAX_CHICKENS 50
-34
View File
@@ -1,34 +0,0 @@
// Process status defines
#define PROCESS_STATUS_IDLE 1
#define PROCESS_STATUS_QUEUED 2
#define PROCESS_STATUS_RUNNING 3
#define PROCESS_STATUS_MAYBE_HUNG 4
#define PROCESS_STATUS_PROBABLY_HUNG 5
#define PROCESS_STATUS_HUNG 6
// Process time thresholds
#define PROCESS_DEFAULT_HANG_WARNING_TIME 300 // 30 seconds
#define PROCESS_DEFAULT_HANG_ALERT_TIME 600 // 60 seconds
#define PROCESS_DEFAULT_HANG_RESTART_TIME 900 // 90 seconds
#define PROCESS_DEFAULT_SCHEDULE_INTERVAL 50 // 50 ticks
#define PROCESS_DEFAULT_TICK_ALLOWANCE 20 // 20% of one tick
// SCHECK macros
// This references src directly to work around a weird bug with try/catch
#define SCHECK sleepCheck()
#define F_SCHECK \
calls_since_last_scheck = 0; \
if (killed) CRASH("A killed process is still running somehow..."); \
if (hung) { \
handleHung(); \
CRASH("Process [name] hung and was restarted."); \
} \
if (world.tick_usage > 100 || (world.tick_usage - tick_start) > tick_allowance) { \
sleep(world.tick_lag); \
cpu_defer_count++; \
last_slept = TimeOfHour; \
tick_start = world.tick_usage; \
}
#define PSCHED_CHECK_TICK (world.tick_usage > 100 || (world.tick_usage - tick_start) > tick_allowance)
+23
View File
@@ -0,0 +1,23 @@
//defines that give qdel hints. these can be given as a return in destory() or by calling
#define QDEL_HINT_QUEUE 0 //qdel should queue the object for deletion.
#define QDEL_HINT_LETMELIVE 1 //qdel should let the object live after calling destory.
#define QDEL_HINT_IWILLGC 2 //functionally the same as the above. qdel should assume the object will gc on its own, and not check it.
#define QDEL_HINT_HARDDEL 3 //qdel should assume this object won't gc, and queue a hard delete using a hard reference.
#define QDEL_HINT_HARDDEL_NOW 4 //qdel should assume this object won't gc, and hard del it post haste.
#define QDEL_HINT_FINDREFERENCE 5 //functionally identical to QDEL_HINT_QUEUE if TESTING is not enabled in _compiler_options.dm.
//if TESTING is enabled, qdel will call this object's find_references() verb.
#define QDEL_HINT_POOL 6 //qdel should pool this object instead of deleting it.
//defines for the gcDestroyed var
#define GC_QUEUED_FOR_QUEUING -1
#define GC_QUEUED_FOR_HARD_DEL -2
#define GC_CURRENTLY_BEING_QDELETED -3
#define QDELING(X) (X.gcDestroyed)
#define QDELETED(X) (!X || X.gcDestroyed)
#define QDESTROYING(X) (!X || X.gcDestroyed == GC_CURRENTLY_BEING_QDELETED)
#define QDEL_IN(item, time) addtimer(CALLBACK(GLOBAL_PROC, .proc/qdel, item), time, TIMER_STOPPABLE)
#define QDEL_NULL(item) qdel(item); item = null
+74
View File
@@ -0,0 +1,74 @@
var/const/RADIO_LOW_FREQ = 1200
var/const/PUBLIC_LOW_FREQ = 1441
var/const/PUBLIC_HIGH_FREQ = 1489
var/const/RADIO_HIGH_FREQ = 1600
var/const/BOT_FREQ = 1447
var/const/COMM_FREQ = 1353
var/const/ERT_FREQ = 1345
var/const/AI_FREQ = 1343
var/const/DTH_FREQ = 1341
var/const/SYND_FREQ = 1213
var/const/ENT_FREQ = 1461 //entertainment frequency. This is not a diona exclusive frequency.
// department channels
var/const/PUB_FREQ = 1459
var/const/SEC_FREQ = 1359
var/const/ENG_FREQ = 1357
var/const/MED_FREQ = 1355
var/const/SCI_FREQ = 1351
var/const/SRV_FREQ = 1349
var/const/SUP_FREQ = 1347
// internal department channels
var/const/MED_I_FREQ = 1485
var/const/SEC_I_FREQ = 1475
var/list/radiochannels = list(
"Common" = PUB_FREQ,
"Science" = SCI_FREQ,
"Command" = COMM_FREQ,
"Medical" = MED_FREQ,
"Engineering" = ENG_FREQ,
"Security" = SEC_FREQ,
"Response Team" = ERT_FREQ,
"Special Ops" = DTH_FREQ,
"Mercenary" = SYND_FREQ,
"Supply" = SUP_FREQ,
"Service" = SRV_FREQ,
"AI Private" = AI_FREQ,
"Entertainment" = ENT_FREQ,
"Medical(I)" = MED_I_FREQ,
"Security(I)" = SEC_I_FREQ
)
// central command channels, i.e deathsquid & response teams
var/list/CENT_FREQS = list(ERT_FREQ, DTH_FREQ)
// Antag channels, i.e. Syndicate
var/list/ANTAG_FREQS = list(SYND_FREQ)
//Department channels, arranged lexically
var/list/DEPT_FREQS = list(AI_FREQ, COMM_FREQ, ENG_FREQ, MED_FREQ, SEC_FREQ, SCI_FREQ, SRV_FREQ, SUP_FREQ, ENT_FREQ)
#define TRANSMISSION_WIRE 0
#define TRANSMISSION_RADIO 1
/* filters */
//When devices register with the radio controller, they might register under a certain filter.
//Other devices can then choose to send signals to only those devices that belong to a particular filter.
//This is done for performance, so we don't send signals to lots of machines unnecessarily.
//This filter is special because devices belonging to default also recieve signals sent to any other filter.
var/const/RADIO_DEFAULT = "radio_default"
var/const/RADIO_TO_AIRALARM = "radio_airalarm" //air alarms
var/const/RADIO_FROM_AIRALARM = "radio_airalarm_rcvr" //devices interested in recieving signals from air alarms
var/const/RADIO_CHAT = "radio_telecoms"
var/const/RADIO_ATMOSIA = "radio_atmos"
var/const/RADIO_NAVBEACONS = "radio_navbeacon"
var/const/RADIO_AIRLOCK = "radio_airlock"
var/const/RADIO_SECBOT = "radio_secbot"
var/const/RADIO_MULEBOT = "radio_mulebot"
var/const/RADIO_MAGNETS = "radio_magnet"
var/const/RADIO_ARRIVALS = "radio_arrvl"
+62
View File
@@ -0,0 +1,62 @@
// -- SSprocessing stuff --
#define START_PROCESSING(Processor, Datum) if (!Datum.isprocessing) {Datum.isprocessing = 1;Processor.processing += Datum}
#define STOP_PROCESSING(Processor, Datum) Datum.isprocessing = 0;Processor.processing -= Datum
// -- SStimer stuff --
//Don't run if there is an identical unique timer active
#define TIMER_UNIQUE 0x1
//For unique timers: Replace the old timer rather then not start this one
#define TIMER_OVERRIDE 0x2
//Timing should be based on how timing progresses on clients, not the sever.
// tracking this is more expensive,
// should only be used in conjuction with things that have to progress client side, such as animate() or sound()
#define TIMER_CLIENT_TIME 0x4
//Timer can be stopped using deltimer()
#define TIMER_STOPPABLE 0x8
//To be used with TIMER_UNIQUE
//prevents distinguishing identical timers with the wait variable
#define TIMER_NO_HASH_WAIT 0x10
//number of byond ticks that are allowed to pass before the timer subsystem thinks it hung on something
#define TIMER_NO_INVOKE_WARNING 600
// -- SSatoms stuff --
// SSatoms Initialization state.
#define INITIALIZATION_INSSATOMS 0 //New should not call Initialize
#define INITIALIZATION_INNEW_MAPLOAD 1 //New should call Initialize(TRUE)
#define INITIALIZATION_INNEW_REGULAR 2 //New should call Initialize(FALSE)
// Initialize() hints for SSatoms.
#define INITIALIZE_HINT_NORMAL 0 //Nothing happens
#define INITIALIZE_HINT_LATELOAD 1 //Call LateInitialize
#define INITIALIZE_HINT_QDEL 2 //Call qdel on the atom
#define INITIALIZE_HINT_LATEQDEL 3 //Call qdel on the atom instead of LateInitialize
// -- SSoverlays --
#define CUT_OVERLAY_IN(ovr, time) addtimer(CALLBACK(src, /atom/.proc/cut_overlay, ovr), time, TIMER_STOPPABLE | TIMER_CLIENT_TIME)
// -- SSticker --
#define ROUND_IS_STARTED (SSticker.current_state >= GAME_STATE_PLAYING)
// -- SSeffects --
// tick/process() return vals.
#define EFFECT_CONTINUE 0 // Keep processing.
#define EFFECT_HALT 1 // Stop processing, but don't qdel.
#define EFFECT_DESTROY 2 // qdel.
// Effect helpers.
#define QUEUE_EFFECT(effect) if (!effect.isprocessing) {effect.isprocessing = TRUE; SSeffects.effect_systems += effect;}
#define QUEUE_VISUAL(visual) if (!visual.isprocessing) {visual.isprocessing = TRUE; SSeffects.visuals += visual;}
#define STOP_EFFECT(effect) effect.isprocessing = FALSE; SSeffects.effect_systems -= effect;
#define STOP_VISUAL(visual) visual.isprocessing = FALSE; SSeffects.visuals -= visual;
// -- SSopenturf --
#define CHECK_OO_EXISTENCE(OO) if (OO && !istype(OO.loc, /turf/simulated/open)) { qdel(OO); }
#define UPDATE_OO_IF_PRESENT CHECK_OO_EXISTENCE(bound_overlay); if (bound_overlay) { update_oo(); }
+65
View File
@@ -0,0 +1,65 @@
#define SS_INIT_MISC_FIRST 16
#define SS_INIT_SEEDS 15
#define SS_INIT_ASTEROID 14 // Asteroid generation.
#define SS_INIT_SHUTTLE 13 // Shuttle setup.
#define SS_INIT_PARALLAX 12 // Parallax image cache generation. Must run before ghosts are able to join, but after SSatoms.
#define SS_INIT_ATOMS 11 // World initialization. Will trigger lighting updates.
#define SS_INIT_CARGO 10 // Random warehouse generation. Runs after SSatoms because it assumes objects are initialized when it runs.
#define SS_INIT_PIPENET 9 // Initial pipenet build.
#define SS_INIT_MACHINERY 8 // Machinery prune and powernet build.
#define SS_INIT_AIR 7 // Air setup and pre-bake.
#define SS_INIT_NIGHT 6 // Nightmode controller. Will trigger lighting updates.
#define SS_INIT_SMOOTHING 5 // Object icon smoothing. Creates overlays.
#define SS_INIT_OVERLAY 4 // Overlay flush.
#define SS_INIT_OPENTURF 3 // Openturf should be after smoothing so it copies the smoothed turfs. Causes lighting updates.
#define SS_INIT_MISC 2 // Default.
#define SS_INIT_LIGHTING 1 // Generation of lighting overlays and pre-bake.
#define SS_INIT_LOBBY 0 // Ghosts can join here.
// Something to remember when setting priorities: SS_TICKER runs before Normal, which runs before SS_BACKGROUND.
// Each group has its own priority bracket.
// SS_BACKGROUND handles high server load differently than Normal and SS_TICKER do.
// SS_TICKER
#define SS_PRIORITY_OVERLAY 500 // Applies overlays. May cause overlay pop-in if it gets behind.
#define SS_PRIORITY_ORBIT 30 // Orbit datum updates.
#define SS_PRIORITY_SMOOTHING 35 // Smooth turf generation.
// Normal
#define SS_PRIORITY_TICKER 200 // Gameticker.
#define SS_PRIORITY_MOB 150 // Mob Life().
#define SS_PRIORITY_NANOUI 120 // UI updates.
#define SS_PRIORITY_VOTE 110
#define SS_PRIORITY_MACHINERY 95 // Machinery + powernet ticks.
#define SS_PRIORITY_CHEMISTRY 90 // Multi-tick chemical reactions.
#define SS_PRIORITY_SHUTTLE 85 // Shuttle movement.
#define SS_PRIORITY_CALAMITY 80 // Singularity, Tesla, Nar'sie, blob, etc.
#define SS_PRIORITY_AIR 75 // ZAS processing.
#define SS_PRIORITY_EVENT 70
#define SS_PRIORITY_AIRFLOW 65 // Handles object movement due to ZAS airflow.
#define SS_PRIORITY_DISEASE 60 // Disease ticks.
#define SS_PRIORITY_ALARMS 50
#define SS_PRIORITY_PLANTS 40 // Spreading plant effects.
#define SS_PRIORITY_ICON_UPDATE 30 // Queued icon updates. Mostly used by APCs.
#define SS_PRIORITY_LIGHTING 20 // Queued lighting engine updates.
#define SS_PRIORITY_AIRFLOW 15
// SS_BACKGROUND
#define SS_PRIORITY_EFFECTS 10 // Effect master (Sparks)
#define SS_PRIORITY_OPENTURF 9 // Open turf icon generation/updates.
#define SS_PRIORITY_EXPLOSIVES 8 // Explosion processor. Doesn't have much effect on explosion tick-checking.
#define SS_PRIORITY_WIRELESS 7
#define SS_PRIORITY_ARRIVALS 6 // Centcomm arrivals shuttle auto-launch.
#define SS_PRIORITY_MODIFIER 5
// SS_BACKGROUND
#define SS_PRIORITY_PROCESSING 11 // Generic datum processor. Replaces objects processor.
#define SS_PRIORITY_OBJECTS 10
#define SS_PRIORITY_DISPOSALS 9 // Disposal holder movement.
#define SS_PRIORITY_EFFECTS 8 // Effect master (Sparks)
#define SS_PRIORITY_EXPLOSIVES 7 // Explosion processor. Doesn't have much effect on explosion tick-checking.
#define SS_PRIORITY_WIRELESS 6 // Handles pairing of wireless devices. Usually will be asleep.
#define SS_PRIORITY_NIGHT 5 // Nightmode.
#define SS_PRIORITY_STATISTICS 4 // Player population polling & AFK kick.
#define SS_PRIORITY_SUN 3 // Sun movement & Solar tracking.
#define SS_PRIORITY_GARBAGE 2 // Garbage collection.
+43 -11
View File
@@ -1,18 +1,50 @@
//Takes: Area type as text string or as typepath OR an instance of the area.
//Returns: A list of all turfs in areas of that type in the world.
/proc/get_area_turfs(var/areatype, var/list/predicates)
if(!areatype) return null
if(istext(areatype)) areatype = text2path(areatype)
if(isarea(areatype))
//Returns: A list of all turfs in areas of that type of that type in the world.
/proc/get_area_turfs(areatype, var/list/predicates, target_z = 0, subtypes=TRUE)
if(istext(areatype))
areatype = text2path(areatype)
else if(isarea(areatype))
var/area/areatemp = areatype
areatype = areatemp.type
else if(!ispath(areatype))
return null
var/list/turfs = new/list()
for(var/areapath in typesof(areatype))
var/area/A = locate(areapath)
for(var/turf/T in A.contents)
if(!predicates || all_predicates_true(list(T), predicates))
turfs += T
var/list/turfs = list()
if(subtypes)
var/list/cache = typecacheof(areatype)
for(var/V in all_areas)
var/area/A = V
if(!cache[A.type])
continue
for(var/turf/T in A)
if(target_z == 0 || target_z == T.z)
if (predicates && predicates.len)
var/predicates_true = TRUE
for (var/predicate in predicates)
if (!call(predicate)(T))
predicates_true = FALSE
break
if (predicates_true)
turfs += T
else
turfs += T
else
for(var/V in all_areas)
var/area/A = V
if(A.type != areatype)
continue
for(var/turf/T in A)
if (target_z == 0 || target_z == T.z)
if (predicates && predicates.len)
var/predicates_true = TRUE
for (var/predicate in predicates)
if (!call(predicate)(T))
predicates_true = FALSE
break
if (predicates_true)
turfs += T
else
turfs += T
return turfs
/proc/pick_area_turf(var/areatype, var/list/predicates)
+6 -4
View File
@@ -22,11 +22,9 @@
if(length(masterdatumPool[type]) <= 0)
#ifdef DEBUG_DATUM_POOL
if(ticker)
to_chat(world, text("DEBUG_DATUM_POOL: new proc has been called ([] | []).", type, list2params(B)))
to_chat(world, text("DEBUG_DATUM_POOL: new proc has been called ([] | []).", type, list2params(B)))
#endif
//so the GC knows we're pooling this type.
if(isnull(masterdatumPool[type]))
masterdatumPool[type] = list()
@@ -71,7 +69,7 @@
to_chat(world, text("DEBUG_DATUM_POOL: returnToPool([]) exceeds [] discarding...", D.type, MAINTAINING_OBJECT_POOL_COUNT))
#endif
qdel(D)
qdel(D, force = TRUE)
return
if(isnull(masterdatumPool[D.type]))
@@ -136,6 +134,10 @@
if (!check_rights(R_DEBUG))
return
if (!LAZYLEN(pooledvariables))
usr << "No objects have been added to the datum pool."
return
var/type = input("What is the typepath for the pooled object variables you wish to view?", "Pooled Variables") in pooledvariables|null
if(!type)
+17 -7
View File
@@ -394,13 +394,6 @@ proc/isInSight(var/atom/A, var/atom/B)
for(var/client/C in group)
C.screen -= O
/proc/flick_overlay(image/I, list/show_to, duration)
for(var/client/C in show_to)
C.images += I
spawn(duration)
for(var/client/C in show_to)
C.images -= I
datum/projectile_data
var/src_x
var/src_y
@@ -566,3 +559,20 @@ datum/projectile_data
/proc/round_is_spooky(var/spookiness_threshold = config.cult_ghostwriter_req_cultists)
return (cult.current_antagonists.len > spookiness_threshold)
/proc/remove_images_from_clients(image/I, list/show_to)
for(var/client/C in show_to)
C.images -= I
/proc/flick_overlay(image/I, list/show_to, duration)
for(var/client/C in show_to)
C.images += I
addtimer(CALLBACK(GLOBAL_PROC, /.proc/remove_images_from_clients, I, show_to), duration)
/proc/flick_overlay_view(image/I, atom/target, duration) //wrapper for the above, flicks to everyone who can see the target atom
var/list/viewing = list()
for(var/m in viewers(target))
var/mob/M = m
if(M.client)
viewing += M.client
flick_overlay(I, viewing, duration)
+9 -8
View File
@@ -96,7 +96,7 @@ var/global/list/cloaking_devices = list()
var/list/paths
//Hair - Initialise all /datum/sprite_accessory/hair into an list indexed by hair-style name
paths = typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair
paths = subtypesof(/datum/sprite_accessory/hair)
for(var/path in paths)
var/datum/sprite_accessory/hair/H = new path()
hair_styles_list[H.name] = H
@@ -108,7 +108,7 @@ var/global/list/cloaking_devices = list()
hair_styles_female_list += H.name
//Facial Hair - Initialise all /datum/sprite_accessory/facial_hair into an list indexed by facialhair-style name
paths = typesof(/datum/sprite_accessory/facial_hair) - /datum/sprite_accessory/facial_hair
paths = subtypesof(/datum/sprite_accessory/facial_hair)
for(var/path in paths)
var/datum/sprite_accessory/facial_hair/H = new path()
facial_hair_styles_list[H.name] = H
@@ -120,21 +120,22 @@ var/global/list/cloaking_devices = list()
facial_hair_styles_female_list += H.name
//Surgery Steps - Initialize all /datum/surgery_step into a list
paths = typesof(/datum/surgery_step)-/datum/surgery_step
paths = subtypesof(/datum/surgery_step)
for(var/T in paths)
var/datum/surgery_step/S = new T
surgery_steps += S
sort_surgeries()
sortTim(surgery_steps, /proc/cmp_surgery)
//List of job. I can't believe this was calculated multiple times per tick!
paths = typesof(/datum/job)-/datum/job
paths = subtypesof(/datum/job)
paths -= exclude_jobs
for(var/T in paths)
var/datum/job/J = new T
joblist[J.title] = J
//Languages and species.
paths = typesof(/datum/language)-/datum/language
paths = subtypesof(/datum/language)
for(var/T in paths)
var/datum/language/L = new T
all_languages[L.name] = L
@@ -145,7 +146,7 @@ var/global/list/cloaking_devices = list()
language_keys[lowertext(L.key)] = L
var/rkey = 0
paths = typesof(/datum/species)-/datum/species
paths = subtypesof(/datum/species)
for(var/T in paths)
rkey++
var/datum/species/S = new T
@@ -158,7 +159,7 @@ var/global/list/cloaking_devices = list()
whitelisted_species += S.name
//Posters
paths = typesof(/datum/poster) - /datum/poster
paths = subtypesof(/datum/poster)
for(var/T in paths)
var/datum/poster/P = new T
poster_designs += P
+429
View File
@@ -0,0 +1,429 @@
//generic (by snowflake) tile smoothing code; smooth your icons with this!
/*
Each tile is divided in 4 corners, each corner has an image associated to it; the tile is then overlayed by these 4 images
To use this, just set your atom's 'smooth' var to 1. If your atom can be moved/unanchored, set its 'can_be_unanchored' var to 1.
If you don't want your atom's icon to smooth with anything but atoms of the same type, set the list 'canSmoothWith' to null;
Otherwise, put all types you want the atom icon to smooth with in 'canSmoothWith' INCLUDING THE TYPE OF THE ATOM ITSELF.
Each atom has its own icon file with all the possible corner states. See 'smooth_wall.dmi' for a template.
DIAGONAL SMOOTHING INSTRUCTIONS
To make your atom smooth diagonally you need all the proper icon states (see 'smooth_wall.dmi' for a template) and
to add the 'SMOOTH_DIAGONAL' flag to the atom's smooth var (in addition to either SMOOTH_TRUE or SMOOTH_MORE).
For turfs, what appears under the diagonal corners depends on the turf that was in the same position previously: if you make a wall on
a plating floor, you will see plating under the diagonal wall corner, if it was space, you will see space.
If you wish to map a diagonal wall corner with a fixed underlay, you must configure the turf's 'fixed_underlay' list var, like so:
fixed_underlay = list("icon"='icon_file.dmi', "icon_state"="iconstatename")
A non null 'fixed_underlay' list var will skip copying the previous turf appearance and always use the list. If the list is
not set properly, the underlay will default to regular floor plating.
To see an example of a diagonal wall, see '/turf/closed/wall/shuttle' and its subtypes.
*/
//Redefinitions of the diagonal directions so they can be stored in one var without conflicts
#define N_NORTH 2
#define N_SOUTH 4
#define N_EAST 16
#define N_WEST 256
#define N_NORTHEAST 32
#define N_NORTHWEST 512
#define N_SOUTHEAST 64
#define N_SOUTHWEST 1024
#define SMOOTH_FALSE 0 //not smooth
#define SMOOTH_TRUE 1 //smooths with exact specified types or just itself
#define SMOOTH_MORE 2 //smooths with all subtypes of specified types or just itself (this value can replace SMOOTH_TRUE)
#define SMOOTH_DIAGONAL 4 //if atom should smooth diagonally, this should be present in 'smooth' var
#define SMOOTH_BORDER 8 //atom will smooth with the borders of the map
#define SMOOTH_QUEUED 16 //atom is currently queued to smooth.
#define NULLTURF_BORDER 123456789
#define DEFAULT_UNDERLAY_ICON 'icons/turf/floors.dmi'
#define DEFAULT_UNDERLAY_ICON_STATE "plating"
#define DEFAULT_UNDERLAY_IMAGE image(DEFAULT_UNDERLAY_ICON, DEFAULT_UNDERLAY_ICON_STATE)
/atom
var/smooth = SMOOTH_FALSE
var/top_left_corner
var/top_right_corner
var/bottom_left_corner
var/bottom_right_corner
var/list/canSmoothWith = null // TYPE PATHS I CAN SMOOTH WITH~~~~~ If this is null and atom is smooth, it smooths only with itself
/atom/movable/var/can_be_unanchored = 0
/turf/var/list/fixed_underlay = null
/proc/calculate_adjacencies(atom/A)
if(!A.loc)
return 0
var/adjacencies = 0
var/atom/movable/AM
if(istype(A, /atom/movable))
AM = A
if(AM.can_be_unanchored && !AM.anchored)
return 0
for(var/direction in cardinal)
AM = find_type_in_direction(A, direction)
if(AM == NULLTURF_BORDER)
if((A.smooth & SMOOTH_BORDER))
adjacencies |= 1 << direction
else if( (AM && !istype(AM)) || (istype(AM) && AM.anchored) )
adjacencies |= 1 << direction
if(adjacencies & N_NORTH)
if(adjacencies & N_WEST)
AM = find_type_in_direction(A, NORTHWEST)
if(AM == NULLTURF_BORDER)
if((A.smooth & SMOOTH_BORDER))
adjacencies |= N_NORTHWEST
else if( (AM && !istype(AM)) || (istype(AM) && AM.anchored) )
adjacencies |= N_NORTHWEST
if(adjacencies & N_EAST)
AM = find_type_in_direction(A, NORTHEAST)
if(AM == NULLTURF_BORDER)
if((A.smooth & SMOOTH_BORDER))
adjacencies |= N_NORTHEAST
else if( (AM && !istype(AM)) || (istype(AM) && AM.anchored) )
adjacencies |= N_NORTHEAST
if(adjacencies & N_SOUTH)
if(adjacencies & N_WEST)
AM = find_type_in_direction(A, SOUTHWEST)
if(AM == NULLTURF_BORDER)
if((A.smooth & SMOOTH_BORDER))
adjacencies |= N_SOUTHWEST
else if( (AM && !istype(AM)) || (istype(AM) && AM.anchored) )
adjacencies |= N_SOUTHWEST
if(adjacencies & N_EAST)
AM = find_type_in_direction(A, SOUTHEAST)
if(AM == NULLTURF_BORDER)
if((A.smooth & SMOOTH_BORDER))
adjacencies |= N_SOUTHEAST
else if( (AM && !istype(AM)) || (istype(AM) && AM.anchored) )
adjacencies |= N_SOUTHEAST
return adjacencies
//do not use, use queue_smooth(atom)
/proc/smooth_icon(atom/A)
if(!A || !A.smooth)
return
A.smooth &= ~SMOOTH_QUEUED
if (!A.z)
return
if(QDELETED(A))
return
if((A.smooth & SMOOTH_TRUE) || (A.smooth & SMOOTH_MORE))
var/adjacencies = calculate_adjacencies(A)
if(A.smooth & SMOOTH_DIAGONAL)
A.diagonal_smooth(adjacencies)
else
cardinal_smooth(A, adjacencies)
/atom/proc/diagonal_smooth(adjacencies)
switch(adjacencies)
if(N_NORTH|N_WEST)
replace_smooth_overlays("d-se","d-se-0")
if(N_NORTH|N_EAST)
replace_smooth_overlays("d-sw","d-sw-0")
if(N_SOUTH|N_WEST)
replace_smooth_overlays("d-ne","d-ne-0")
if(N_SOUTH|N_EAST)
replace_smooth_overlays("d-nw","d-nw-0")
if(N_NORTH|N_WEST|N_NORTHWEST)
replace_smooth_overlays("d-se","d-se-1")
if(N_NORTH|N_EAST|N_NORTHEAST)
replace_smooth_overlays("d-sw","d-sw-1")
if(N_SOUTH|N_WEST|N_SOUTHWEST)
replace_smooth_overlays("d-ne","d-ne-1")
if(N_SOUTH|N_EAST|N_SOUTHEAST)
replace_smooth_overlays("d-nw","d-nw-1")
else
cardinal_smooth(src, adjacencies)
return
icon_state = ""
return adjacencies
//only walls should have a need to handle underlays
/turf/simulated/wall/diagonal_smooth(adjacencies)
adjacencies = reverse_ndir(..())
if(adjacencies)
var/list/U = list()
if(fixed_underlay)
if(fixed_underlay["space"])
var/image/I = image('icons/turf/space_parallax1.dmi',"[icon_state]")
I.plane = PLANE_SPACE_DUST
I.alpha = 80
I.blend_mode = BLEND_ADD
U += I
else
U += image(fixed_underlay["icon"], fixed_underlay["icon_state"], layer=TURF_LAYER)
else
var/turf/T = get_step(src, turn(adjacencies, 180))
if(T && (T.density || T.smooth))
T = get_step(src, turn(adjacencies, 135))
if(T && (T.density || T.smooth))
T = get_step(src, turn(adjacencies, 225))
if(istype(T, /turf/space) && !istype(T, /turf/space/transit))
var/image/I = image('icons/turf/space_parallax1.dmi',"[icon_state]")
I.plane = PLANE_SPACE_DUST
I.alpha = 80
I.blend_mode = BLEND_ADD
U += I
else if(T && !T.density && !T.smooth)
U += T
else if(baseturf && !initial(baseturf.density) && !initial(baseturf.smooth))
U += image(initial(baseturf.icon), initial(baseturf.icon_state), layer=TURF_LAYER)
else
U += DEFAULT_UNDERLAY_IMAGE
underlays = U
// And a copypaste for unsimulated walls.
/turf/unsimulated/wall/diagonal_smooth(adjacencies)
adjacencies = reverse_ndir(..())
if(adjacencies)
var/list/U = list()
if(fixed_underlay)
if(fixed_underlay["space"])
var/image/I = image('icons/turf/space_parallax1.dmi',"[icon_state]")
I.plane = PLANE_SPACE_DUST
I.alpha = 80
I.blend_mode = BLEND_ADD
U += I
else
U += image(fixed_underlay["icon"], fixed_underlay["icon_state"], layer=TURF_LAYER)
else
var/turf/T = get_step(src, turn(adjacencies, 180))
if(T && (T.density || T.smooth))
T = get_step(src, turn(adjacencies, 135))
if(T && (T.density || T.smooth))
T = get_step(src, turn(adjacencies, 225))
if(istype(T, /turf/space) && !istype(T, /turf/space/transit))
var/image/I = image('icons/turf/space_parallax1.dmi',"[icon_state]")
I.plane = PLANE_SPACE_DUST
I.alpha = 80
I.blend_mode = BLEND_ADD
U += I
else if(T && !T.density && !T.smooth)
U += T
else if(baseturf && !initial(baseturf.density) && !initial(baseturf.smooth))
U += image(initial(baseturf.icon), initial(baseturf.icon_state), layer=TURF_LAYER)
else
U += DEFAULT_UNDERLAY_IMAGE
underlays = U
/proc/cardinal_smooth(atom/A, adjacencies)
//NW CORNER
var/nw = "1-i"
if((adjacencies & N_NORTH) && (adjacencies & N_WEST))
if(adjacencies & N_NORTHWEST)
nw = "1-f"
else
nw = "1-nw"
else
if(adjacencies & N_NORTH)
nw = "1-n"
else if(adjacencies & N_WEST)
nw = "1-w"
//NE CORNER
var/ne = "2-i"
if((adjacencies & N_NORTH) && (adjacencies & N_EAST))
if(adjacencies & N_NORTHEAST)
ne = "2-f"
else
ne = "2-ne"
else
if(adjacencies & N_NORTH)
ne = "2-n"
else if(adjacencies & N_EAST)
ne = "2-e"
//SW CORNER
var/sw = "3-i"
if((adjacencies & N_SOUTH) && (adjacencies & N_WEST))
if(adjacencies & N_SOUTHWEST)
sw = "3-f"
else
sw = "3-sw"
else
if(adjacencies & N_SOUTH)
sw = "3-s"
else if(adjacencies & N_WEST)
sw = "3-w"
//SE CORNER
var/se = "4-i"
if((adjacencies & N_SOUTH) && (adjacencies & N_EAST))
if(adjacencies & N_SOUTHEAST)
se = "4-f"
else
se = "4-se"
else
if(adjacencies & N_SOUTH)
se = "4-s"
else if(adjacencies & N_EAST)
se = "4-e"
var/list/New
if(A.top_left_corner != nw)
A.cut_overlay(A.top_left_corner)
A.top_left_corner = nw
LAZYADD(New, nw)
if(A.top_right_corner != ne)
A.cut_overlay(A.top_right_corner)
A.top_right_corner = ne
LAZYADD(New, ne)
if(A.bottom_right_corner != sw)
A.cut_overlay(A.bottom_right_corner)
A.bottom_right_corner = sw
LAZYADD(New, sw)
if(A.bottom_left_corner != se)
A.cut_overlay(A.bottom_left_corner)
A.bottom_left_corner = se
LAZYADD(New, se)
if(New)
A.add_overlay(New)
A.icon_state = ""
/proc/find_type_in_direction(atom/source, direction)
var/turf/target_turf = get_step(source, direction)
if(!target_turf)
return NULLTURF_BORDER
if(source.canSmoothWith)
var/atom/A
if(source.smooth & SMOOTH_MORE)
for(var/a_type in source.canSmoothWith)
if( istype(target_turf, a_type) )
return target_turf
A = locate(a_type) in target_turf
if(A)
return A
return null
for(var/a_type in source.canSmoothWith)
if(a_type == target_turf.type)
return target_turf
A = locate(a_type) in target_turf
if(A && A.type == a_type)
return A
return null
else
if(isturf(source))
return source.type == target_turf.type ? target_turf : null
var/atom/A = locate(source.type) in target_turf
return A && A.type == source.type ? A : null
//Icon smoothing helpers
/proc/smooth_zlevel(var/zlevel, now = FALSE)
var/list/away_turfs = block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel))
for(var/V in away_turfs)
var/turf/T = V
if(T.smooth)
if(now)
smooth_icon(T)
else
queue_smooth(T)
for(var/R in T)
var/atom/A = R
if(A.smooth)
if(now)
smooth_icon(A)
else
queue_smooth(A)
/atom/proc/clear_smooth_overlays()
cut_overlay(top_left_corner)
top_left_corner = null
cut_overlay(top_right_corner)
top_right_corner = null
cut_overlay(bottom_right_corner)
bottom_right_corner = null
cut_overlay(bottom_left_corner)
bottom_left_corner = null
/atom/proc/replace_smooth_overlays(nw, ne, sw, se)
clear_smooth_overlays()
var/list/O = list()
top_left_corner = nw
O += nw
top_right_corner = ne
O += ne
bottom_left_corner = sw
O += sw
bottom_right_corner = se
O += se
add_overlay(O)
/proc/reverse_ndir(ndir)
switch(ndir)
if(N_NORTH)
return NORTH
if(N_SOUTH)
return SOUTH
if(N_WEST)
return WEST
if(N_EAST)
return EAST
if(N_NORTHWEST)
return NORTHWEST
if(N_NORTHEAST)
return NORTHEAST
if(N_SOUTHEAST)
return SOUTHEAST
if(N_SOUTHWEST)
return SOUTHWEST
if(N_NORTH|N_WEST)
return NORTHWEST
if(N_NORTH|N_EAST)
return NORTHEAST
if(N_SOUTH|N_WEST)
return SOUTHWEST
if(N_SOUTH|N_EAST)
return SOUTHEAST
if(N_NORTH|N_WEST|N_NORTHWEST)
return NORTHWEST
if(N_NORTH|N_EAST|N_NORTHEAST)
return NORTHEAST
if(N_SOUTH|N_WEST|N_SOUTHWEST)
return SOUTHWEST
if(N_SOUTH|N_EAST|N_SOUTHEAST)
return SOUTHEAST
else
return 0
//SSicon_smooth
/proc/queue_smooth_neighbors(atom/A)
for(var/V in orange(1,A))
var/atom/T = V
if(T.smooth)
queue_smooth(T)
//SSicon_smooth
/proc/queue_smooth(atom/A)
if(!A.smooth || A.smooth & SMOOTH_QUEUED)
return
SSicon_smooth.smooth_queue += A
SSicon_smooth.wake()
A.smooth |= SMOOTH_QUEUED
+122 -119
View File
@@ -225,119 +225,42 @@ proc/listclearnulls(list/list)
//Mergesort: divides up the list into halves to begin the sort
/proc/sortKey(var/list/client/L, var/order = 1)
if(isnull(L) || L.len < 2)
return L
var/middle = L.len / 2 + 1
return mergeKey(sortKey(L.Copy(0,middle)), sortKey(L.Copy(middle)), order)
//Mergsort: does the actual sorting and returns the results back to sortAtom
/proc/mergeKey(var/list/client/L, var/list/client/R, var/order = 1)
var/Li=1
var/Ri=1
var/list/result = new()
while(Li <= L.len && Ri <= R.len)
var/client/rL = L[Li]
var/client/rR = R[Ri]
if(sorttext(rL.ckey, rR.ckey) == order)
result += L[Li++]
else
result += R[Ri++]
if(Li <= L.len)
return (result + L.Copy(Li, 0))
return (result + R.Copy(Ri, 0))
if (!L)
return
var/list/target = L.Copy()
return sortTim(target, order ? /proc/cmp_ckey_asc : /proc/cmp_ckey_dsc, FALSE)
//Mergesort: divides up the list into halves to begin the sort
/proc/sortAtom(var/list/atom/L, var/order = 1)
if(isnull(L) || L.len < 2)
return L
var/middle = L.len / 2 + 1
return mergeAtoms(sortAtom(L.Copy(0,middle)), sortAtom(L.Copy(middle)), order)
//Mergsort: does the actual sorting and returns the results back to sortAtom
/proc/mergeAtoms(var/list/atom/L, var/list/atom/R, var/order = 1)
var/Li=1
var/Ri=1
var/list/result = new()
while(Li <= L.len && Ri <= R.len)
var/atom/rL = L[Li]
var/atom/rR = R[Ri]
if(sorttext(rL.name, rR.name) == order)
result += L[Li++]
else
result += R[Ri++]
if(Li <= L.len)
return (result + L.Copy(Li, 0))
return (result + R.Copy(Ri, 0))
if (!L)
return
var/list/target = L.Copy()
return sortTim(target, order ? /proc/cmp_name_asc : /proc/cmp_name_dsc, FALSE)
//Mergesort: Specifically for record datums in a list.
/proc/sortRecord(var/list/datum/data/record/L, var/field = "name", var/order = 1)
if(isnull(L))
return list()
if(L.len < 2)
return L
var/middle = L.len / 2 + 1
return mergeRecordLists(sortRecord(L.Copy(0, middle), field, order), sortRecord(L.Copy(middle), field, order), field, order)
//Mergsort: does the actual sorting and returns the results back to sortRecord
/proc/mergeRecordLists(var/list/datum/data/record/L, var/list/datum/data/record/R, var/field = "name", var/order = 1)
var/Li=1
var/Ri=1
var/list/result = new()
if(!isnull(L) && !isnull(R))
while(Li <= L.len && Ri <= R.len)
var/datum/data/record/rL = L[Li]
if(isnull(rL))
L -= rL
continue
var/datum/data/record/rR = R[Ri]
if(isnull(rR))
R -= rR
continue
if(sorttext(rL.fields[field], rR.fields[field]) == order)
result += L[Li++]
else
result += R[Ri++]
if(Li <= L.len)
return (result + L.Copy(Li, 0))
return (result + R.Copy(Ri, 0))
if (!L)
return
var/list/target = L.Copy()
var/old_cmp_field = cmp_field
cmp_field = field
sortTim(target, order ? /proc/cmp_records_asc : /proc/cmp_records_dsc, FALSE)
cmp_field = old_cmp_field
return target
//Mergesort: any value in a list
/proc/sortList(var/list/L)
if(L.len < 2)
return L
var/middle = L.len / 2 + 1 // Copy is first,second-1
return mergeLists(sortList(L.Copy(0,middle)), sortList(L.Copy(middle))) //second parameter null = to end of list
if (!L)
return
var/list/target = L.Copy()
return sortTim(target, /proc/cmp_text_asc)
//Mergsorge: uses sortList() but uses the var's name specifically. This should probably be using mergeAtom() instead
/proc/sortNames(var/list/L)
var/list/Q = new()
for(var/atom/x in L)
Q[x.name] = x
return sortList(Q)
/proc/mergeLists(var/list/L, var/list/R)
var/Li=1
var/Ri=1
var/list/result = new()
while(Li <= L.len && Ri <= R.len)
if(sorttext(L[Li], R[Ri]) < 1)
result += R[Ri++]
else
result += L[Li++]
if(Li <= L.len)
return (result + L.Copy(Li, 0))
return (result + R.Copy(Ri, 0))
if (!L)
return
var/list/target = L.Copy()
return sortTim(target, /proc/cmp_name_asc, FALSE)
// List of lists, sorts by element[key] - for things like crew monitoring computer sorting records by name.
/proc/sortByKey(var/list/L, var/key)
@@ -366,24 +289,9 @@ proc/listclearnulls(list/list)
//Mergesort: any value in a list, preserves key=value structure
/proc/sortAssoc(var/list/L)
if(L.len < 2)
return L
var/middle = L.len / 2 + 1 // Copy is first,second-1
return mergeAssoc(sortAssoc(L.Copy(0,middle)), sortAssoc(L.Copy(middle))) //second parameter null = to end of list
/proc/mergeAssoc(var/list/L, var/list/R)
var/Li=1
var/Ri=1
var/list/result = new()
while(Li <= L.len && Ri <= R.len)
if(sorttext(L[Li], R[Ri]) < 1)
result += R&R[Ri++]
else
result += L&L[Li++]
if(Li <= L.len)
return (result + L.Copy(Li, 0))
return (result + R.Copy(Ri, 0))
var/list/ret = L.Copy()
sortTim(ret, /proc/cmp_text_asc, FALSE)
return ret
// Macros to test for bits in a bitfield. Note, that this is for use with indexes, not bit-masks!
#define BITTEST(bitfield,index) ((bitfield) & (1 << (index)))
@@ -653,6 +561,41 @@ proc/dd_sortedTextList(list/incoming)
L += new path()
return L
//Like typesof() or subtypesof(), but returns a typecache instead of a list
/proc/typecacheof(path, ignore_root_path, only_root_path = FALSE)
if(ispath(path))
var/list/types = list()
if(only_root_path)
types = list(path)
else
types = ignore_root_path ? subtypesof(path) : typesof(path)
var/list/L = list()
for(var/T in types)
L[T] = TRUE
return L
else if(islist(path))
var/list/pathlist = path
var/list/L = list()
if(ignore_root_path)
for(var/P in pathlist)
for(var/T in subtypesof(P))
L[T] = TRUE
else
for(var/P in pathlist)
if(only_root_path)
L[P] = TRUE
else
for(var/T in typesof(P))
L[T] = TRUE
return L
//Checks for specific types in specifically structured (Assoc "type" = TRUE) lists ('typecaches')
/proc/is_type_in_typecache(atom/A, list/L)
if(!L || !L.len || !A)
return 0
return L[A.type]
#define listequal(A, B) (A.len == B.len && !length(A^B))
/proc/Sum(var/list/input)
@@ -661,3 +604,63 @@ proc/dd_sortedTextList(list/incoming)
total += input[i]
return total
//Move a single element from position fromIndex within a list, to position toIndex
//All elements in the range [1,toIndex) before the move will be before the pivot afterwards
//All elements in the range [toIndex, L.len+1) before the move will be after the pivot afterwards
//In other words, it's as if the range [fromIndex,toIndex) have been rotated using a <<< operation common to other languages.
//fromIndex and toIndex must be in the range [1,L.len+1]
//This will preserve associations ~Carnie
/proc/moveElement(list/L, fromIndex, toIndex)
if(fromIndex == toIndex || fromIndex+1 == toIndex) //no need to move
return
if(fromIndex > toIndex)
++fromIndex //since a null will be inserted before fromIndex, the index needs to be nudged right by one
L.Insert(toIndex, null)
L.Swap(fromIndex, toIndex)
L.Cut(fromIndex, fromIndex+1)
//Move elements [fromIndex,fromIndex+len) to [toIndex-len, toIndex)
//Same as moveElement but for ranges of elements
//This will preserve associations ~Carnie
/proc/moveRange(list/L, fromIndex, toIndex, len=1)
var/distance = abs(toIndex - fromIndex)
if(len >= distance) //there are more elements to be moved than the distance to be moved. Therefore the same result can be achieved (with fewer operations) by moving elements between where we are and where we are going. The result being, our range we are moving is shifted left or right by dist elements
if(fromIndex <= toIndex)
return //no need to move
fromIndex += len //we want to shift left instead of right
for(var/i=0, i<distance, ++i)
L.Insert(fromIndex, null)
L.Swap(fromIndex, toIndex)
L.Cut(toIndex, toIndex+1)
else
if(fromIndex > toIndex)
fromIndex += len
for(var/i=0, i<len, ++i)
L.Insert(toIndex, null)
L.Swap(fromIndex, toIndex)
L.Cut(fromIndex, fromIndex+1)
//replaces reverseList ~Carnie
/proc/reverseRange(list/L, start=1, end=0)
if(L.len)
start = start % L.len
end = end % (L.len+1)
if(start <= 0)
start += L.len
if(end <= 0)
end += L.len + 1
--end
while(start < end)
L.Swap(start++,end--)
return L
#define LAZYINITLIST(L) if (!L) L = list()
#define UNSETEMPTY(L) if (L && !L.len) L = null
+80 -30
View File
@@ -5,8 +5,15 @@
// will get logs that are one big line if the system is Linux and they are using notepad. This solves it by adding CR to every line ending
// in the logs. ascii character 13 = CR
/var/global/log_end= world.system_type == UNIX ? ascii2text(13) : ""
#define SEVERITY_ALERT 1
#define SEVERITY_CRITICAL 2
#define SEVERITY_ERROR 3
#define SEVERITY_WARNING 4
#define SEVERITY_NOTICE 5
#define SEVERITY_INFO 6
#define SEVERITY_DEBUG 7
/var/global/log_end = world.system_type == UNIX ? ascii2text(13) : ""
/proc/error(msg)
world.log << "## ERROR: [msg][log_end]"
@@ -29,7 +36,7 @@
game_log("ADMIN", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=level,category="ADMIN",additional_data=list("_ckey"=html_encode(ckey),"_admin_key"=html_encode(admin_key),"_ckey_target"=html_encode(ckey_target)))
/proc/log_debug(text,level=5)
/proc/log_debug(text,level = SEVERITY_DEBUG)
if (config.log_debug)
game_log("DEBUG", text)
@@ -38,83 +45,126 @@
return
if(C.prefs.toggles & CHAT_DEBUGLOGS)
C << "DEBUG: [text]"
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=level,category="DEBUG")
send_gelf_log(short_message = text, long_message = "[time_stamp()]: [text]", level = level, category = "DEBUG")
/proc/log_game(text,level=5,ckey="",admin_key="",ckey_target="")
/proc/log_game(text, level = SEVERITY_NOTICE, ckey = "", admin_key = "", ckey_target = "")
if (config.log_game)
game_log("GAME", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=level,category="GAME",additional_data=list("_ckey"=html_encode(ckey),"_admin_key"=html_encode(admin_key),"_target"=html_encode(target)))
send_gelf_log(
short_message = text,
long_message = "[time_stamp()]: [text]",
level = level,
category = "GAME",
additional_data = list("_ckey" = html_encode(ckey), "_admin_key" = html_encode(admin_key), "_target" = html_encode(target))
)
/proc/log_vote(text)
if (config.log_vote)
game_log("VOTE", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=5,category="VOTE")
/proc/log_access(text,level=5,ckey="")
/proc/log_access(text, level = SEVERITY_NOTICE,ckey="")
if (config.log_access)
game_log("ACCESS", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=level,category="ACCESS",additional_data=list("_ckey"=html_encode(ckey)))
/proc/log_say(text,level=5,ckey="")
/proc/log_say(text, level = SEVERITY_NOTICE, ckey = "")
if (config.log_say)
game_log("SAY", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=level,category="SAY",additional_data=list("_ckey"=html_encode(ckey)))
/proc/log_ooc(text,level=5,ckey="")
/proc/log_ooc(text, level = SEVERITY_NOTICE, ckey = "")
if (config.log_ooc)
game_log("OOC", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=level,category="OOC",additional_data=list("_ckey"=html_encode(ckey)))
send_gelf_log(short_message = text, long_message = "[time_stamp()]: [text]", level = level, category = "OOC", additional_data = list("_ckey" = html_encode(ckey)))
/proc/log_whisper(text,level=5,ckey="")
/proc/log_whisper(text, level = SEVERITY_NOTICE, ckey = "")
if (config.log_whisper)
game_log("WHISPER", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=level,category="WHISPER",additional_data=list("_ckey"=html_encode(ckey)))
send_gelf_log(short_message = text, long_message = "[time_stamp()]: [text]", level = level, category = "WHISPER", additional_data = list("_ckey" = html_encode(ckey)))
/proc/log_emote(text,level=5,ckey="")
/proc/log_emote(text, level = SEVERITY_NOTICE, ckey = "")
if (config.log_emote)
game_log("EMOTE", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=level,category="EMOTE",additional_data=list("_ckey"=html_encode(ckey)))
send_gelf_log(short_message = text, long_message = "[time_stamp()]: [text]",level = level,category = "EMOTE", additional_data = list("_ckey" = html_encode(ckey)))
/proc/log_attack(text,level=5,ckey="",ckey_target="")
/proc/log_attack(text, level = SEVERITY_NOTICE, ckey = "", ckey_target = "")
if (config.log_attack)
game_log("ATTACK", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=level,category="ATTACK",additional_data=list("_ckey"=html_encode(ckey),"_ckey_target"=html_encode(ckey_target)))
send_gelf_log(
short_message = text,
long_message = "[time_stamp()]: [text]",
level = level,
category="ATTACK",
additional_data = list("_ckey" = html_encode(ckey), "_ckey_target" = html_encode(ckey_target))
)
/proc/log_adminsay(text)
if (config.log_adminchat)
game_log("ADMINSAY", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=5,category="ADMINSAY")
send_gelf_log(short_message = text, long_message = "[time_stamp()]: [text]",level = SEVERITY_NOTICE, category = "ADMINSAY")
/proc/log_pda(text,level=5,ckey="",ckey_target="")
/proc/log_pda(text, level = SEVERITY_NOTICE, ckey = "", ckey_target = "")
if (config.log_pda)
game_log("PDA", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=level,category="PDA",additional_data=list("_ckey"=html_encode(ckey),"_ckey_target"=html_encode(ckey_target)))
send_gelf_log(
short_message = text,
long_message = "[time_stamp()]: [text]",
level = level,
category="PDA",
additional_data = list("_ckey" = html_encode(ckey), "_ckey_target" = html_encode(ckey_target))
)
/proc/log_ntirc(text,level=5,ckey="",conversation="")
/proc/log_ntirc(text, level = SEVERITY_NOTICE, ckey = "", conversation = "")
if (config.log_pda)
game_log("NTIRC", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=level,category="NTIRC",additional_data=list("_ckey"=html_encode(ckey),"_ntirc_conversation"=html_encode(conversation)))
send_gelf_log(
short_message = text,
long_message="[time_stamp()]: [text]",
level = level,
category = "NTIRC",
additional_data = list("_ckey" = html_encode(ckey), "_ntirc_conversation" = html_encode(conversation))
)
/proc/log_to_dd(text)
world.log << text //this comes before the config check because it can't possibly runtime
if(config.log_world_output)
game_log("DD_OUTPUT", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=5,category="DD_OUTPUT")
send_gelf_log(short_message = text, long_message = "[time_stamp()]: [text]", level = SEVERITY_NOTICE, category = "DD_OUTPUT")
/proc/log_misc(text)
game_log("MISC", text)
send_gelf_log(short_message=text, long_message="[time_stamp()]: [text]",level=5,category="MISC")
send_gelf_log(short_message = text, long_message = "[time_stamp()]: [text]", level = SEVERITY_NOTICE, category="MISC")
/proc/log_mc(text)
game_log("MASTER", text)
send_gelf_log(text, "[time_stamp()]: [text]", SEVERITY_INFO, "MASTER")
/proc/log_gc(text, type, high_severity = FALSE)
game_log("GC", text)
send_gelf_log(text, "[time_stamp()]: [text]", high_severity ? SEVERITY_WARNING : SEVERITY_DEBUG, "GARBAGE", additional_data = list("_type" = "[type]"))
/proc/log_ss(subsystem, text, log_world = TRUE)
if (!subsystem)
subsystem = "UNKNOWN"
var/msg = "[subsystem]: [text]"
game_log("SS", msg)
send_gelf_log(msg, "[time_stamp()]: [msg]", SEVERITY_DEBUG, "SUBSYSTEM", additional_data = list("_subsystem" = subsystem))
if (log_world)
world.log << "SS[subsystem]: [text]"
/proc/log_ss_init(text)
game_log("SS", "[text]")
send_gelf_log(text, "[time_stamp()]: [text]", SEVERITY_INFO, "SS Init")
// Generally only used when something has gone very wrong.
/proc/log_failsafe(text)
game_log("FAILSAFE", text)
send_gelf_log(text, "[time_stamp()]: [text]", SEVERITY_ALERT, "FAILSAFE")
/proc/log_unit_test(text)
world.log << "## UNIT_TEST ##: [text]"
// Procs for logging into diary_runtime
/proc/log_hard_delete(atom/A)
if (config.log_runtime)
diary_runtime << "hard delete:[log_end]"
diary_runtime << "[A.type][log_end]"
send_gelf_log(short_message="hard delete: [A.type]",level=5,category="HARDDEL")
/proc/log_exception(exception/e)
if (config.log_runtime)
if (config.log_runtime == 2)
@@ -122,7 +172,7 @@
diary_runtime << "runtime error:[e.name][log_end]"
diary_runtime << "[e.desc]"
send_gelf_log(short_message="runtime error:[e.name]",long_message="[e.desc]",level=5,category="HARDDEL")
send_gelf_log(short_message = "runtime error:[e.name]", long_message = "[e.desc]", level = SEVERITY_WARNING, category = "RUNTIME")
//pretty print a direction bitflag, can be useful for debugging.
/proc/print_dir(var/dir)
+10 -1
View File
@@ -129,8 +129,17 @@
/proc/RoundUpToPowerOfTwo(var/val)
return 2 ** -round(-log(2,val))
//"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(world.tick_usage-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 ( rollovercheck_last_timeofday != world.timeofday ? update_midnight_rollover() : midnight_rollovers )
//Written by Lohikar
//Returns the cube root of the input number
/proc/cubert(var/num, var/iterations = 10)
. = num
+8 -5
View File
@@ -15,13 +15,16 @@
return src
/proc/mobs_in_view(var/range, var/source)
var/list/mobs = list()
. = list()
for(var/atom/movable/AM in view(range, source))
var/M = AM.get_mob()
if(M)
mobs += M
if (ismob(AM))
. += AM
continue
return mobs
if (!AM.can_hold_mob)
continue
. += AM.get_mob()
proc/random_hair_style(gender, species = "Human")
var/h_style = "Bald"
+2 -2
View File
@@ -9,7 +9,7 @@
0, 0, 0, 0,
HOLOSCREEN_MULTIPLICATION_FACTOR, HOLOSCREEN_MULTIPLICATION_FACTOR, HOLOSCREEN_MULTIPLICATION_FACTOR, HOLOSCREEN_MULTIPLICATION_OPACITY
)
target.overlays += multiply
target.add_overlay(multiply)
var/image/overlay = make_screen_overlay(icon, icon_state)
overlay.blend_mode = BLEND_ADD
overlay.color = list(
@@ -18,7 +18,7 @@
0, 0, HOLOSCREEN_ADDITION_FACTOR, 0,
0, 0, 0, HOLOSCREEN_ADDITION_OPACITY
)
target.overlays += overlay
target.add_overlay(overlay)
/proc/make_screen_overlay(icon, icon_state, brightness_factor = null)
var/image/overlay = image(icon, icon_state)
+17
View File
@@ -0,0 +1,17 @@
//TimSort interface
/proc/sortTim(list/L, cmp=/proc/cmp_numeric_asc, associative, fromIndex=1, toIndex=0)
if(L && L.len >= 2)
fromIndex = fromIndex % L.len
toIndex = toIndex % (L.len+1)
if(fromIndex <= 0)
fromIndex += L.len
if(toIndex <= 0)
toIndex += L.len + 1
sortInstance.L = L
sortInstance.cmp = cmp
sortInstance.associative = associative
sortInstance.timSort(fromIndex, toIndex)
return L
+656
View File
@@ -0,0 +1,656 @@
//These are macros used to reduce on proc calls
#define fetchElement(L, i) (associative) ? L[L[i]] : L[i]
//Minimum sized sequence that will be merged. Anything smaller than this will use binary-insertion sort.
//Should be a power of 2
#define MIN_MERGE 32
//When we get into galloping mode, we stay there until both runs win less often than MIN_GALLOP consecutive times.
#define MIN_GALLOP 7
//This is a global instance to allow much of this code to be reused. The interfaces are kept seperately
var/datum/sortInstance/sortInstance = new()
/datum/sortInstance
//The array being sorted.
var/list/L
//The comparator proc-reference
var/cmp = /proc/cmp_numeric_asc
//whether we are sorting list keys (0: L[i]) or associated values (1: L[L[i]])
var/associative = 0
//This controls when we get *into* galloping mode. It is initialized to MIN_GALLOP.
//The mergeLo and mergeHi methods nudge it higher for random data, and lower for highly structured data.
var/minGallop = MIN_GALLOP
//Stores information regarding runs yet to be merged.
//Run i starts at runBase[i] and extends for runLen[i] elements.
//runBase[i] + runLen[i] == runBase[i+1]
//var/stackSize
var/list/runBases = list()
var/list/runLens = list()
proc/timSort(start, end)
runBases.Cut()
runLens.Cut()
var/remaining = end - start
//If array is small, do a 'mini-TimSort' with no merges
if(remaining < MIN_MERGE)
var/initRunLen = countRunAndMakeAscending(start, end)
binarySort(start, end, start+initRunLen)
return
//March over the array finding natural runs
//Extend any short natural runs to runs of length minRun
var/minRun = minRunLength(remaining)
do
//identify next run
var/runLen = countRunAndMakeAscending(start, end)
//if run is short, extend to min(minRun, remaining)
if(runLen < minRun)
var/force = (remaining <= minRun) ? remaining : minRun
binarySort(start, start+force, start+runLen)
runLen = force
//add data about run to queue
runBases.Add(start)
runLens.Add(runLen)
//maybe merge
mergeCollapse()
//Advance to find next run
start += runLen
remaining -= runLen
while(remaining > 0)
//Merge all remaining runs to complete sort
//ASSERT(start == end)
mergeForceCollapse();
//ASSERT(runBases.len == 1)
//reset minGallop, for successive calls
minGallop = MIN_GALLOP
return L
/*
Sorts the specified portion of the specified array using a binary
insertion sort. This is the best method for sorting small numbers
of elements. It requires O(n log n) compares, but O(n^2) data
movement (worst case).
If the initial part of the specified range is already sorted,
this method can take advantage of it: the method assumes that the
elements in range [lo,start) are already sorted
lo the index of the first element in the range to be sorted
hi the index after the last element in the range to be sorted
start the index of the first element in the range that is not already known to be sorted
*/
proc/binarySort(lo, hi, start)
//ASSERT(lo <= start && start <= hi)
if(start <= lo)
start = lo + 1
for(,start < hi, ++start)
var/pivot = fetchElement(L,start)
//set left and right to the index where pivot belongs
var/left = lo
var/right = start
//ASSERT(left <= right)
//[lo, left) elements <= pivot < [right, start) elements
//in other words, find where the pivot element should go using bisection search
while(left < right)
var/mid = (left + right) >> 1 //round((left+right)/2)
if(call(cmp)(fetchElement(L,mid), pivot) > 0)
right = mid
else
left = mid+1
//ASSERT(left == right)
moveElement(L, start, left) //move pivot element to correct location in the sorted range
/*
Returns the length of the run beginning at the specified position and reverses the run if it is back-to-front
A run is the longest ascending sequence with:
a[lo] <= a[lo + 1] <= a[lo + 2] <= ...
or the longest descending sequence with:
a[lo] > a[lo + 1] > a[lo + 2] > ...
For its intended use in a stable mergesort, the strictness of the
definition of "descending" is needed so that the call can safely
reverse a descending sequence without violating stability.
*/
proc/countRunAndMakeAscending(lo, hi)
//ASSERT(lo < hi)
var/runHi = lo + 1
if(runHi >= hi)
return 1
var/last = fetchElement(L,lo)
var/current = fetchElement(L,runHi++)
if(call(cmp)(current, last) < 0)
while(runHi < hi)
last = current
current = fetchElement(L,runHi)
if(call(cmp)(current, last) >= 0)
break
++runHi
reverseRange(L, lo, runHi)
else
while(runHi < hi)
last = current
current = fetchElement(L,runHi)
if(call(cmp)(current, last) < 0)
break
++runHi
return runHi - lo
//Returns the minimum acceptable run length for an array of the specified length.
//Natural runs shorter than this will be extended with binarySort
proc/minRunLength(n)
//ASSERT(n >= 0)
var/r = 0 //becomes 1 if any bits are shifted off
while(n >= MIN_MERGE)
r |= (n & 1)
n >>= 1
return n + r
//Examines the stack of runs waiting to be merged and merges adjacent runs until the stack invariants are reestablished:
// runLen[i-3] > runLen[i-2] + runLen[i-1]
// runLen[i-2] > runLen[i-1]
//This method is called each time a new run is pushed onto the stack.
//So the invariants are guaranteed to hold for i<stackSize upon entry to the method
proc/mergeCollapse()
while(runBases.len >= 2)
var/n = runBases.len - 1
if(n > 1 && runLens[n-1] <= runLens[n] + runLens[n+1])
if(runLens[n-1] < runLens[n+1])
--n
mergeAt(n)
else if(runLens[n] <= runLens[n+1])
mergeAt(n)
else
break //Invariant is established
//Merges all runs on the stack until only one remains.
//Called only once, to finalise the sort
proc/mergeForceCollapse()
while(runBases.len >= 2)
var/n = runBases.len - 1
if(n > 1 && runLens[n-1] < runLens[n+1])
--n
mergeAt(n)
//Merges the two consecutive runs at stack indices i and i+1
//Run i must be the penultimate or antepenultimate run on the stack
//In other words, i must be equal to stackSize-2 or stackSize-3
proc/mergeAt(i)
//ASSERT(runBases.len >= 2)
//ASSERT(i >= 1)
//ASSERT(i == runBases.len - 1 || i == runBases.len - 2)
var/base1 = runBases[i]
var/base2 = runBases[i+1]
var/len1 = runLens[i]
var/len2 = runLens[i+1]
//ASSERT(len1 > 0 && len2 > 0)
//ASSERT(base1 + len1 == base2)
//Record the legth of the combined runs. If i is the 3rd last run now, also slide over the last run
//(which isn't involved in this merge). The current run (i+1) goes away in any case.
runLens[i] += runLens[i+1]
runLens.Cut(i+1, i+2)
runBases.Cut(i+1, i+2)
//Find where the first element of run2 goes in run1.
//Prior elements in run1 can be ignored (because they're already in place)
var/k = gallopRight(fetchElement(L,base2), base1, len1, 0)
//ASSERT(k >= 0)
base1 += k
len1 -= k
if(len1 == 0)
return
//Find where the last element of run1 goes in run2.
//Subsequent elements in run2 can be ignored (because they're already in place)
len2 = gallopLeft(fetchElement(L,base1 + len1 - 1), base2, len2, len2-1)
//ASSERT(len2 >= 0)
if(len2 == 0)
return
//Merge remaining runs, using tmp array with min(len1, len2) elements
if(len1 <= len2)
mergeLo(base1, len1, base2, len2)
else
mergeHi(base1, len1, base2, len2)
/*
Locates the position to insert key within the specified sorted range
If the range contains elements equal to key, this will return the index of the LEFTMOST of those elements
key the element to be inserted into the sorted range
base the index of the first element of the sorted range
len the length of the sorted range, must be greater than 0
hint the offset from base at which to begin the search, such that 0 <= hint < len; i.e. base <= hint < base+hint
Returns the index at which to insert element 'key'
*/
proc/gallopLeft(key, base, len, hint)
//ASSERT(len > 0 && hint >= 0 && hint < len)
var/lastOffset = 0
var/offset = 1
if(call(cmp)(key, fetchElement(L,base+hint)) > 0)
var/maxOffset = len - hint
while(offset < maxOffset && call(cmp)(key, fetchElement(L,base+hint+offset)) > 0)
lastOffset = offset
offset = (offset << 1) + 1
if(offset > maxOffset)
offset = maxOffset
lastOffset += hint
offset += hint
else
var/maxOffset = hint + 1
while(offset < maxOffset && call(cmp)(key, fetchElement(L,base+hint-offset)) <= 0)
lastOffset = offset
offset = (offset << 1) + 1
if(offset > maxOffset)
offset = maxOffset
var/temp = lastOffset
lastOffset = hint - offset
offset = hint - temp
//ASSERT(-1 <= lastOffset && lastOffset < offset && offset <= len)
//Now L[base+lastOffset] < key <= L[base+offset], so key belongs somewhere to the right of lastOffset but no farther than
//offset. Do a binary search with invariant L[base+lastOffset-1] < key <= L[base+offset]
++lastOffset
while(lastOffset < offset)
var/m = lastOffset + ((offset - lastOffset) >> 1)
if(call(cmp)(key, fetchElement(L,base+m)) > 0)
lastOffset = m + 1
else
offset = m
//ASSERT(lastOffset == offset)
return offset
/**
* Like gallopLeft, except that if the range contains an element equal to
* key, gallopRight returns the index after the rightmost equal element.
*
* @param key the key whose insertion point to search for
* @param a the array in which to search
* @param base the index of the first element in the range
* @param len the length of the range; must be > 0
* @param hint the index at which to begin the search, 0 <= hint < n.
* The closer hint is to the result, the faster this method will run.
* @param c the comparator used to order the range, and to search
* @return the int k, 0 <= k <= n such that a[b + k - 1] <= key < a[b + k]
*/
proc/gallopRight(key, base, len, hint)
//ASSERT(len > 0 && hint >= 0 && hint < len)
var/offset = 1
var/lastOffset = 0
if(call(cmp)(key, fetchElement(L,base+hint)) < 0) //key <= L[base+hint]
var/maxOffset = hint + 1 //therefore we want to insert somewhere in the range [base,base+hint] = [base+,base+(hint+1))
while(offset < maxOffset && call(cmp)(key, fetchElement(L,base+hint-offset)) < 0) //we are iterating backwards
lastOffset = offset
offset = (offset << 1) + 1 //1 3 7 15
//if(offset <= 0) //int overflow, not an issue here since we are using floats
// offset = maxOffset
if(offset > maxOffset)
offset = maxOffset
var/temp = lastOffset
lastOffset = hint - offset
offset = hint - temp
else //key > L[base+hint]
var/maxOffset = len - hint //therefore we want to insert somewhere in the range (base+hint,base+len) = [base+hint+1, base+hint+(len-hint))
while(offset < maxOffset && call(cmp)(key, fetchElement(L,base+hint+offset)) >= 0)
lastOffset = offset
offset = (offset << 1) + 1
//if(offset <= 0) //int overflow, not an issue here since we are using floats
// offset = maxOffset
if(offset > maxOffset)
offset = maxOffset
lastOffset += hint
offset += hint
//ASSERT(-1 <= lastOffset && lastOffset < offset && offset <= len)
++lastOffset
while(lastOffset < offset)
var/m = lastOffset + ((offset - lastOffset) >> 1)
if(call(cmp)(key, fetchElement(L,base+m)) < 0) //key <= L[base+m]
offset = m
else //key > L[base+m]
lastOffset = m + 1
//ASSERT(lastOffset == offset)
return offset
//Merges two adjacent runs in-place in a stable fashion.
//For performance this method should only be called when len1 <= len2!
proc/mergeLo(base1, len1, base2, len2)
//ASSERT(len1 > 0 && len2 > 0 && base1 + len1 == base2)
var/cursor1 = base1
var/cursor2 = base2
//degenerate cases
if(len2 == 1)
moveElement(L, cursor2, cursor1)
return
if(len1 == 1)
moveElement(L, cursor1, cursor2+len2)
return
//Move first element of second run
moveElement(L, cursor2++, cursor1++)
--len2
outer:
while(1)
var/count1 = 0 //# of times in a row that first run won
var/count2 = 0 // " " " " " " second run won
//do the straightfoward thin until one run starts winning consistently
do
//ASSERT(len1 > 1 && len2 > 0)
if(call(cmp)(fetchElement(L,cursor2), fetchElement(L,cursor1)) < 0)
moveElement(L, cursor2++, cursor1++)
--len2
++count2
count1 = 0
if(len2 == 0)
break outer
else
++cursor1
++count1
count2 = 0
if(--len1 == 1)
break outer
while((count1 | count2) < minGallop)
//one run is winning consistently so galloping may provide huge benifits
//so try galloping, until such time as the run is no longer consistently winning
do
//ASSERT(len1 > 1 && len2 > 0)
count1 = gallopRight(fetchElement(L,cursor2), cursor1, len1, 0)
if(count1)
cursor1 += count1
len1 -= count1
if(len1 <= 1)
break outer
moveElement(L, cursor2, cursor1)
++cursor2
++cursor1
if(--len2 == 0)
break outer
count2 = gallopLeft(fetchElement(L,cursor1), cursor2, len2, 0)
if(count2)
moveRange(L, cursor2, cursor1, count2)
cursor2 += count2
cursor1 += count2
len2 -= count2
if(len2 == 0)
break outer
++cursor1
if(--len1 == 1)
break outer
--minGallop
while((count1|count2) > MIN_GALLOP)
if(minGallop < 0)
minGallop = 0
minGallop += 2; // Penalize for leaving gallop mode
if(len1 == 1)
//ASSERT(len2 > 0)
moveElement(L, cursor1, cursor2+len2)
//else
//ASSERT(len2 == 0)
//ASSERT(len1 > 1)
proc/mergeHi(base1, len1, base2, len2)
//ASSERT(len1 > 0 && len2 > 0 && base1 + len1 == base2)
var/cursor1 = base1 + len1 - 1 //start at end of sublists
var/cursor2 = base2 + len2 - 1
//degenerate cases
if(len2 == 1)
moveElement(L, base2, base1)
return
if(len1 == 1)
moveElement(L, base1, cursor2+1)
return
moveElement(L, cursor1--, cursor2-- + 1)
--len1
outer:
while(1)
var/count1 = 0 //# of times in a row that first run won
var/count2 = 0 // " " " " " " second run won
//do the straightfoward thing until one run starts winning consistently
do
//ASSERT(len1 > 0 && len2 > 1)
if(call(cmp)(fetchElement(L,cursor2), fetchElement(L,cursor1)) < 0)
moveElement(L, cursor1--, cursor2-- + 1)
--len1
++count1
count2 = 0
if(len1 == 0)
break outer
else
--cursor2
--len2
++count2
count1 = 0
if(len2 == 1)
break outer
while((count1 | count2) < minGallop)
//one run is winning consistently so galloping may provide huge benifits
//so try galloping, until such time as the run is no longer consistently winning
do
//ASSERT(len1 > 0 && len2 > 1)
count1 = len1 - gallopRight(fetchElement(L,cursor2), base1, len1, len1-1) //should cursor1 be base1?
if(count1)
cursor1 -= count1
moveRange(L, cursor1+1, cursor2+1, count1) //cursor1+1 == cursor2 by definition
cursor2 -= count1
len1 -= count1
if(len1 == 0)
break outer
--cursor2
if(--len2 == 1)
break outer
count2 = len2 - gallopLeft(fetchElement(L,cursor1), cursor1+1, len2, len2-1)
if(count2)
cursor2 -= count2
len2 -= count2
if(len2 <= 1)
break outer
moveElement(L, cursor1--, cursor2-- + 1)
--len1
if(len1 == 0)
break outer
--minGallop
while((count1|count2) > MIN_GALLOP)
if(minGallop < 0)
minGallop = 0
minGallop += 2 // Penalize for leaving gallop mode
if(len2 == 1)
//ASSERT(len1 > 0)
cursor1 -= len1
moveRange(L, cursor1+1, cursor2+1, len1)
//else
//ASSERT(len1 == 0)
//ASSERT(len2 > 0)
proc/mergeSort(start, end)
var/remaining = end - start
//If array is small, do an insertion sort
if(remaining < MIN_MERGE)
//var/initRunLen = countRunAndMakeAscending(start, end)
binarySort(start, end, start/*+initRunLen*/)
return
var/minRun = minRunLength(remaining)
do
var/runLen = (remaining <= minRun) ? remaining : minRun
binarySort(start, start+runLen, start)
//add data about run to queue
runBases.Add(start)
runLens.Add(runLen)
//Advance to find next run
start += runLen
remaining -= runLen
while(remaining > 0)
while(runBases.len >= 2)
var/n = runBases.len - 1
if(n > 1 && runLens[n-1] <= runLens[n] + runLens[n+1])
if(runLens[n-1] < runLens[n+1])
--n
mergeAt2(n)
else if(runLens[n] <= runLens[n+1])
mergeAt2(n)
else
break //Invariant is established
while(runBases.len >= 2)
var/n = runBases.len - 1
if(n > 1 && runLens[n-1] < runLens[n+1])
--n
mergeAt2(n)
return L
proc/mergeAt2(i)
var/cursor1 = runBases[i]
var/cursor2 = runBases[i+1]
var/end1 = cursor1+runLens[i]
var/end2 = cursor2+runLens[i+1]
var/val1 = fetchElement(L,cursor1)
var/val2 = fetchElement(L,cursor2)
while(1)
if(call(cmp)(val1,val2) < 0)
if(++cursor1 >= end1)
break
val1 = fetchElement(L,cursor1)
else
moveElement(L,cursor2,cursor1)
++cursor2
if(++cursor2 >= end2)
break
++end1
++cursor1
//if(++cursor1 >= end1)
// break
val2 = fetchElement(L,cursor2)
//Record the legth of the combined runs. If i is the 3rd last run now, also slide over the last run
//(which isn't involved in this merge). The current run (i+1) goes away in any case.
runLens[i] += runLens[i+1]
runLens.Cut(i+1, i+2)
runBases.Cut(i+1, i+2)
#undef MIN_GALLOP
#undef MIN_MERGE
#undef fetchElement
+80
View File
@@ -0,0 +1,80 @@
/proc/cmp_numeric_dsc(a,b)
return b - a
/proc/cmp_numeric_asc(a,b)
return a - b
/proc/cmp_text_asc(a,b)
return sorttext(b,a)
/proc/cmp_text_dsc(a,b)
return sorttext(a,b)
/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)
var/cmp_field = "name"
/proc/cmp_records_asc(datum/data/record/a, datum/data/record/b)
return sorttext(b.fields[cmp_field], a.fields[cmp_field])
/proc/cmp_records_dsc(datum/data/record/a, datum/data/record/b)
return sorttext(a.fields[cmp_field], b.fields[cmp_field])
/proc/cmp_ckey_asc(client/a, client/b)
return sorttext(b.ckey, a.ckey)
/proc/cmp_ckey_dsc(client/a, client/b)
return sorttext(a.ckey, b.ckey)
/proc/cmp_subsystem_init(datum/controller/subsystem/a, datum/controller/subsystem/b)
return b.init_order - a.init_order
/proc/cmp_subsystem_display(datum/controller/subsystem/a, datum/controller/subsystem/b)
return sorttext(b.name, a.name)
/proc/cmp_subsystem_priority(datum/controller/subsystem/a, datum/controller/subsystem/b)
return a.priority - b.priority
/proc/cmp_timer(datum/timedevent/a, datum/timedevent/b)
return a.timeToRun - b.timeToRun
/proc/cmp_camera(obj/machinery/camera/a, obj/machinery/camera/b)
if (a.c_tag_order != b.c_tag_order)
return b.c_tag_order - a.c_tag_order
return sorttext(b.c_tag, a.c_tag)
/proc/cmp_alarm(datum/alarm/a, datum/alarm/b)
return sorttext(b.last_name, a.last_name)
/proc/cmp_uplink_item(datum/uplink_item/a, datum/uplink_item/b)
return b.cost(INFINITY) - a.cost(INFINITY)
/proc/cmp_access(datum/access/a, datum/access/b)
return sorttext("[b.access_type][b.desc]", "[a.access_type][a.desc]")
/proc/cmp_player_setup_group(datum/category_group/player_setup_category/a, datum/category_group/player_setup_category/b)
return a.sort_order - b.sort_order
/proc/cmp_cardstate(datum/card_state/a, datum/card_state/b)
return sorttext(b.name, a.name)
/proc/cmp_uplink_category(datum/uplink_category/a, datum/uplink_category/b)
return sorttext(b.name, a.name)
/proc/cmp_admin_secret(datum/admin_secret_item/a, datum/admin_secret_item/b)
return sorttext(b.name, a.name)
/proc/cmp_supply_drop(datum/supply_drop_loot/a, datum/supply_drop_loot/b)
return sorttext(b.name, a.name)
/proc/cmp_rcon_smes(obj/machinery/power/smes/buildable/S1, obj/machinery/power/smes/buildable/S2)
return sorttext(S2.RCon_tag, S1.RCon_tag)
/proc/cmp_rcon_bbox(obj/machinery/power/breakerbox/BR1, obj/machinery/power/breakerbox/BR2)
return sorttext(BR2.RCon_tag, BR1.RCon_tag)
/proc/cmp_surgery(datum/surgery_step/a, datum/surgery_step/b)
return b.priority - a.priority
+1
View File
@@ -440,6 +440,7 @@ proc/TextPreview(var/string,var/len=40)
t = replacetext(t, "\[row\]", "</td><tr>")
t = replacetext(t, "\[cell\]", "<td>")
t = replacetext(t, "\[logo\]", "<img src = ntlogo.png>")
t = replacetext(t, "\[barcode\]", "<img src = barcode[rand(0, 3)].png>")
t = replacetext(t, "\[time\]", "[worldtime2text()]")
t = replacetext(t, "\[date\]", "[worlddate2text()]")
t = replacetext(t, "\[editorbr\]", "<BR>")
+7
View File
@@ -50,3 +50,10 @@ proc/round_duration()
last_round_duration = "[hours]:[mins]"
next_duration_update = world.time + 1 MINUTES
return last_round_duration
/var/midnight_rollovers = 0
/var/rollovercheck_last_timeofday = 0
/proc/update_midnight_rollover()
if (world.timeofday < rollovercheck_last_timeofday) //TIME IS GOING BACKWARDS!
return midnight_rollovers++
return midnight_rollovers
+112 -116
View File
@@ -331,42 +331,42 @@ Turf and target are seperate in case you want to teleport some distance from a t
//Generalised helper proc for letting mobs rename themselves. Used to be clname() and ainame()
//Last modified by Carn
/mob/proc/rename_self(var/role, var/allow_numbers=0)
spawn(0)
var/oldname = real_name
set waitfor = FALSE
var/oldname = real_name
var/time_passed = world.time
var/newname
var/time_passed = world.time
var/newname
for(var/i=1,i<=3,i++) //we get 3 attempts to pick a suitable name.
newname = input(src,"You are \a [role]. Would you like to change your name to something else?", "Name change",oldname) as text
if((world.time-time_passed)>3000)
return //took too long
newname = sanitizeName(newname, ,allow_numbers) //returns null if the name doesn't meet some basic requirements. Tidies up a few other things like bad-characters.
for(var/i=1,i<=3,i++) //we get 3 attempts to pick a suitable name.
newname = input(src,"You are \a [role]. Would you like to change your name to something else?", "Name change",oldname) as text
if((world.time-time_passed)>3000)
return //took too long
newname = sanitizeName(newname, ,allow_numbers) //returns null if the name doesn't meet some basic requirements. Tidies up a few other things like bad-characters.
for(var/mob/living/M in player_list)
if(M == src)
continue
if(!newname || M.real_name == newname)
newname = null
break
if(newname)
break //That's a suitable name!
src << "Sorry, that [role]-name wasn't appropriate, please try another. It's possibly too long/short, has bad characters or is already taken."
for(var/mob/living/M in player_list)
if(M == src)
continue
if(!newname || M.real_name == newname)
newname = null
break
if(newname)
break //That's a suitable name!
src << "Sorry, that [role]-name wasn't appropriate, please try another. It's possibly too long/short, has bad characters or is already taken."
if(!newname) //we'll stick with the oldname then
return
if(!newname) //we'll stick with the oldname then
return
if(cmptext("ai",role))
if(isAI(src))
var/mob/living/silicon/ai/A = src
oldname = null//don't bother with the records update crap
//world << "<b>[newname] is the AI!</b>"
//world << sound('sound/AI/newAI.ogg')
// Set eyeobj name
A.SetName(newname)
if(cmptext("ai",role))
if(isAI(src))
var/mob/living/silicon/ai/A = src
oldname = null//don't bother with the records update crap
//world << "<b>[newname] is the AI!</b>"
//world << sound('sound/AI/newAI.ogg')
// Set eyeobj name
A.SetName(newname)
fully_replace_character_name(oldname,newname)
fully_replace_character_name(oldname,newname)
@@ -856,16 +856,24 @@ proc/GaussRandRound(var/sigma,var/roundto)
var/old_dir1 = T.dir
var/old_icon_state1 = T.icon_state
var/old_icon1 = T.icon
var/old_overlays = T.overlays.Copy()
var/old_underlays = T.underlays.Copy()
// SSoverlays makes this a bit more complex.
var/old_our_overlays = T.our_overlays
T.our_overlays = null
var/old_priority_overlays = T.priority_overlays
T.priority_overlays = null
var/turf/X = B.ChangeTurf(T.type)
X.set_dir(old_dir1)
X.icon_state = old_icon_state1
X.icon = old_icon1 //Shuttle floors are in shuttle.dmi while the defaults are floors.dmi
X.overlays = old_overlays
X.underlays = old_underlays
X.our_overlays = old_our_overlays
X.priority_overlays = old_priority_overlays
X.compile_overlays()
var/turf/simulated/ST = T
if(istype(ST) && ST.zone)
var/turf/simulated/SX = X
@@ -897,21 +905,23 @@ proc/GaussRandRound(var/sigma,var/roundto)
X.icon = nextturf.icon
X.icon_state = nextturf.icon_state
for (var/thing in T)
if (isobj(thing))
var/obj/O = thing
for(var/obj/O in T)
// Reset the shuttle corners
if(O.tag == "delete me")
X.icon = 'icons/turf/shuttle.dmi'
X.icon_state = replacetext(O.icon_state, "_f", "_s") // revert the turf to the old icon_state
X.name = "wall"
qdel(O) // prevents multiple shuttle corners from stacking
continue
if(!istype(O,/obj)) continue
O.loc = X
for(var/mob/M in T)
if(!istype(M,/mob) || istype(M, /mob/eye)) continue // If we need to check for more mobs, I'll add a variable
M.loc = X
// Reset the shuttle corners
if(O.tag == "delete me")
X.icon = 'icons/turf/shuttle.dmi'
X.icon_state = replacetext(O.icon_state, "_f", "_s") // revert the turf to the old icon_state
X.name = "wall"
qdel(O) // prevents multiple shuttle corners from stacking
continue
O.forceMove(X)
else if (ismob(thing) && !istype(thing, /mob/eye) && !istype(thing, /mob/dview))
var/mob/M = thing
M.forceMove(X)
toupdate += X
@@ -1050,24 +1060,15 @@ proc/DuplicateObject(obj/original, var/perfectcopy = 0 , var/sameloc = 0)
copiedobjs += newobjs
copiedobjs += newmobs
// var/area/AR = X.loc
// if(AR.lighting_use_dynamic)
// X.opacity = !X.opacity
// X.sd_SetOpacity(!X.opacity) //TODO: rewrite this code so it's not messed by lighting ~Carn
toupdate += X
refined_src -= T
refined_trg -= B
continue moving
if(toupdate.len)
for(var/turf/simulated/T1 in toupdate)
air_master.mark_for_update(T1)
SSair.mark_for_update(T1)
return copiedobjs
@@ -1210,7 +1211,7 @@ proc/is_hot(obj/item/W as obj)
return 1000
else
return 0
if(/obj/item/weapon/pickaxe/plasmacutter)
if(/obj/item/weapon/gun/energy/plasmacutter)
return 3800
if(/obj/item/weapon/melee/energy)
return 3500
@@ -1357,64 +1358,6 @@ var/list/WALLITEMS = list(
color = origin.color
set_light(origin.light_range, origin.light_power, origin.light_color)
//This is just so you can stop an orbit.
//orbit() can run without it (swap orbiting for A)
//but then you can never stop it and that's just silly.
/atom/movable/var/atom/orbiting = null
//A: atom to orbit
//radius: range to orbit at, radius of the circle formed by orbiting
//clockwise: whether you orbit clockwise or anti clockwise
//rotation_speed: how fast to rotate
//rotation_segments: the resolution of the orbit circle, less = a more block circle, this can be used to produce hexagons (6 segments) triangles (3 segments), and so on, 36 is the best default.
//pre_rotation: Chooses to rotate src 90 degress towards the orbit dir (clockwise/anticlockwise), useful for things to go "head first" like ghosts
//lockinorbit: Forces src to always be on A's turf, otherwise the orbit cancels when src gets too far away (eg: ghosts)
/atom/movable/proc/orbit(atom/A, radius = 10, clockwise = FALSE, rotation_speed = 20, rotation_segments = 36, pre_rotation = TRUE, lockinorbit = FALSE)
if(!istype(A))
return
if(orbiting)
stop_orbit()
orbiting = A
var/matrix/initial_transform = matrix(transform)
var/lastloc = loc
//Head first!
if(pre_rotation)
var/matrix/M = matrix(transform)
var/pre_rot = 90
if(!clockwise)
pre_rot = -90
M.Turn(pre_rot)
transform = M
var/matrix/shift = matrix(transform)
shift.Translate(0,radius)
transform = shift
SpinAnimation(rotation_speed, -1, clockwise, rotation_segments)
//we stack the orbits up client side, so we can assign this back to normal server side without it breaking the orbit
transform = initial_transform
while(orbiting && orbiting == A && A.loc)
var/targetloc = get_turf(A)
if(!lockinorbit && loc != lastloc && loc != targetloc)
break
loc = targetloc
lastloc = loc
sleep(0.6)
if (orbiting == A) //make sure we haven't started orbiting something else.
orbiting = null
SpinAnimation(0,0)
/atom/movable/proc/stop_orbit()
orbiting = null
// call to generate a stack trace and print to runtime logs
/proc/crash_with(msg)
CRASH(msg)
@@ -1439,9 +1382,62 @@ var/list/WALLITEMS = list(
return 0//If we get here, we must be buried many layers deep in nested containers. Shouldn't happen
//similar function to RANGE_TURFS(), but will search spiralling outwards from the center (like the above, but only turfs)
/proc/spiral_range_turfs(dist=0, center=usr, orange=0)
if(!dist)
if(!orange)
return list(center)
else
return list()
var/turf/t_center = get_turf(center)
if(!t_center)
return list()
var/list/L = list()
var/turf/T
var/y
var/x
var/c_dist = 1
if(!orange)
L += t_center
while( c_dist <= dist )
y = t_center.y + c_dist
x = t_center.x - c_dist + 1
for(x in x to t_center.x+c_dist)
T = locate(x,y,t_center.z)
if(T)
L += T
y = t_center.y + c_dist - 1
x = t_center.x + c_dist
for(y in t_center.y-c_dist to y)
T = locate(x,y,t_center.z)
if(T)
L += T
y = t_center.y - c_dist
x = t_center.x + c_dist - 1
for(x in t_center.x-c_dist to x)
T = locate(x,y,t_center.z)
if(T)
L += T
y = t_center.y - c_dist + 1
x = t_center.x - c_dist
for(y in y to t_center.y+c_dist)
T = locate(x,y,t_center.z)
if(T)
L += T
c_dist++
return L
//Increases delay as the server gets more overloaded,
//as sleeps aren't cheap and sleeping only to wake up and sleep again is wasteful
#define DELTA_CALC max((max(world.tick_usage,world.cpu)/100),1)
#define DELTA_CALC max(((max(world.tick_usage, world.cpu) / 100) * max(Master.sleep_delta,1)), 1)
/proc/stoplag()
. = 0
@@ -1450,6 +1446,6 @@ var/list/WALLITEMS = list(
. += round(i*DELTA_CALC)
sleep(i*world.tick_lag*DELTA_CALC)
i *= 2
while (world.tick_usage > TICK_LIMIT)
while (world.tick_usage > min(TICK_LIMIT_TO_RUN, CURRENT_TICKLIMIT))
#undef DELTA_CALC
+2
View File
@@ -43,6 +43,8 @@
#define isslime(A) istype(A, /mob/living/carbon/slime)
#define to_chat(target, message) target << message
#define MAP_IMAGE_PATH "nano/images/"
#define map_image_file_name(z_level) "Aurora-[z_level].png"
#define to_world(message) world << message
#define sound_to(target, sound) target << sound
#define to_file(file_entry, file_content) file_entry << file_content
+2 -2
View File
@@ -102,14 +102,14 @@ Quick adjacency (to turf):
This can be safely removed if border firedoors are ever moved to be on top of doors
so they can be interacted with without opening the door.
*/
/obj/machinery/door/Adjacent(var/atom/neighbor)
/*/obj/machinery/door/Adjacent(var/atom/neighbor)
var/obj/machinery/door/firedoor/border_only/BOD = locate() in loc
if(BOD)
BOD.throwpass = 1 // allow click to pass
. = ..()
BOD.throwpass = 0
return .
return ..()
return ..()*/
/*
+1 -2
View File
@@ -176,8 +176,7 @@
return
/mob/living/UnarmedAttack(var/atom/A, var/proximity_flag)
if(!ticker)
if(!Master.round_started)
src << "You cannot attack people before the game has started."
return 0
+2 -1
View File
@@ -30,6 +30,7 @@
/datum/action/Destroy()
if(owner)
Remove(owner)
return ..()
/datum/action/proc/Grant(mob/living/T)
if(owner)
@@ -220,4 +221,4 @@
#undef AB_WEST_OFFSET
#undef AB_NORTH_OFFSET
#undef AB_MAX_COLUMNS
#undef AB_MAX_COLUMNS
+3 -11
View File
@@ -2,16 +2,8 @@
The global hud:
Uses the same visual objects for all players.
*/
var/datum/global_hud/global_hud = new()
var/list/global_huds = list(
global_hud.druggy,
global_hud.blurry,
global_hud.vimpaired,
global_hud.darkMask,
global_hud.nvg,
global_hud.thermal,
global_hud.meson,
global_hud.science)
var/datum/global_hud/global_hud // Initialized in SSatoms.
var/list/global_huds
/datum/hud/var/obj/screen/grab_intent
/datum/hud/var/obj/screen/hurt_intent
@@ -142,7 +134,7 @@ datum/hud/New(mob/owner)
..()
/datum/hud/Destroy()
..()
. = ..()
grab_intent = null
hurt_intent = null
disarm_intent = null
+22 -31
View File
@@ -1,9 +1,3 @@
// Until we convert to planes.
#define PLANE_SPACE_BACKGROUND -98
#define PLANE_SPACE_PARALLAX (PLANE_SPACE_BACKGROUND + 1) // -97
#define PLANE_SPACE_DUST (PLANE_SPACE_PARALLAX + 1) // -96
#define PLANE_ABOVE_PARALLAX (PLANE_SPACE_BACKGROUND + 3) // -95
/*
* This file handles all parallax-related business once the parallax itself is initialized with the rest of the HUD
*/
@@ -11,11 +5,6 @@
#define PARALLAX_IMAGE_TILES (PARALLAX_IMAGE_WIDTH**2)
#define GRID_WIDTH 3
var/list/parallax_on_clients = list()
var/parallax_initialized = 0
var/space_color = "#050505"
var/list/parallax_icon[(GRID_WIDTH**2)*3]
/obj/screen/parallax
var/base_offset_x = 0
var/base_offset_y = 0
@@ -32,24 +21,26 @@ var/list/parallax_icon[(GRID_WIDTH**2)*3]
/obj/screen/plane_master
appearance_flags = PLANE_MASTER
screen_loc = "CENTER,CENTER"
/obj/screen/plane_master/parallax_master
plane = PLANE_SPACE_PARALLAX
blend_mode = BLEND_MULTIPLY
color = list(
1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,0,
0,0,0,1)
1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,0,
0,0,0,1
)
/obj/screen/plane_master/parallax_spacemaster //Turns space white, causing the parallax to only show in areas with opacity. Somehow
plane = PLANE_SPACE_BACKGROUND
color = list(
0,0,0,0,
0,0,0,0,
0,0,0,0,
1,1,1,1)
0,0,0,0,
0,0,0,0,
0,0,0,0,
1,1,1,1
)
/obj/screen/plane_master/parallax_spacemaster/New()
..()
@@ -62,7 +53,7 @@ var/list/parallax_icon[(GRID_WIDTH**2)*3]
color = list(0,0,0,0)
/datum/hud/proc/update_parallax_existence()
if(!parallax_initialized)
if(!SSparallax.parallax_initialized)
return
initialize_parallax()
update_parallax()
@@ -79,7 +70,7 @@ var/list/parallax_icon[(GRID_WIDTH**2)*3]
C.parallax_dustmaster = new /obj/screen/plane_master/parallax_dustmaster
if(!C.parallax.len)
for(var/obj/screen/parallax/bgobj in parallax_icon)
for(var/obj/screen/parallax/bgobj in SSparallax.parallax_icon)
var/obj/screen/parallax/parallax_layer = new /obj/screen/parallax
parallax_layer.appearance = bgobj.appearance
parallax_layer.base_offset_x = bgobj.base_offset_x
@@ -99,7 +90,7 @@ var/list/parallax_icon[(GRID_WIDTH**2)*3]
/datum/hud/proc/update_parallax()
var/client/C = mymob.client
if(C.prefs.parallax_togs & PARALLAX_SPACE)
parallax_on_clients |= C
SSparallax.parallax_on_clients |= C
for(var/obj/screen/parallax/bgobj in C.parallax)
C.screen |= bgobj
C.screen |= C.parallax_master
@@ -115,17 +106,17 @@ var/list/parallax_icon[(GRID_WIDTH**2)*3]
else
for(var/obj/screen/parallax/bgobj in C.parallax)
C.screen -= bgobj
parallax_on_clients -= C
SSparallax.parallax_on_clients -= C
C.screen -= C.parallax_master
C.screen -= C.parallax_spacemaster
C.parallax_dustmaster.color = list(0,0,0,0)
/datum/hud/proc/update_parallax_values()
var/client/C = mymob.client
if(!parallax_initialized)
if(!SSparallax.parallax_initialized)
return
if(!(locate(/turf/space) in trange(C.view,get_turf(C.eye))))
if(!(locate(/turf/space) in trange(C.view,get_turf(C.eye))) && !(locate(/turf/simulated/open) in trange(C.view,get_turf(C.eye))))
return
//ACTUALLY MOVING THE PARALLAX
@@ -193,7 +184,7 @@ var/list/parallax_icon[(GRID_WIDTH**2)*3]
parallax_layer.overlays = L
parallax_layer.parallax_speed = 0
parallax_layer.calibrate_parallax(i+1)
parallax_icon[index] = parallax_layer
SSparallax.parallax_icon[index] = parallax_layer
index++
for(var/i in 0 to ((GRID_WIDTH**2)-1))
@@ -210,7 +201,7 @@ var/list/parallax_icon[(GRID_WIDTH**2)*3]
parallax_layer.overlays = L
parallax_layer.parallax_speed = 0.5
parallax_layer.calibrate_parallax(i+1)
parallax_icon[index] = parallax_layer
SSparallax.parallax_icon[index] = parallax_layer
index++
for(var/i in 0 to ((GRID_WIDTH**2)-1))
@@ -226,10 +217,10 @@ var/list/parallax_icon[(GRID_WIDTH**2)*3]
parallax_layer.overlays = L
parallax_layer.parallax_speed = 1
parallax_layer.calibrate_parallax(i+1)
parallax_icon[index] = parallax_layer
SSparallax.parallax_icon[index] = parallax_layer
index++
parallax_initialized = 1
SSparallax.parallax_initialized = 1
/obj/screen/parallax/proc/calibrate_parallax(var/i)
if(!i)
+2 -2
View File
@@ -13,7 +13,7 @@
unacidable = 1
var/obj/master = null //A reference to the object in the slot. Grabs or items, generally.
/obj/screen/Destroy()
/obj/screen/Destroy(force = FALSE)
master = null
screen_loc = null
return ..()
@@ -46,7 +46,7 @@
var/obj/item/owner
/obj/screen/item_action/Destroy()
..()
. = ..()
owner = null
/obj/screen/item_action/Click()
+3 -3
View File
@@ -13,7 +13,7 @@
var/mob/spell_holder
/obj/screen/movable/spell_master/Destroy()
..()
. = ..()
for(var/obj/screen/spell/spells in spell_objects)
spells.spellmaster = null
spell_objects.Cut()
@@ -93,7 +93,7 @@
if(spell.spell_flags & NO_BUTTON) //no button to add if we don't get one
return
var/obj/screen/spell/newscreen = getFromPool(/obj/screen/spell)
var/obj/screen/spell/newscreen = new /obj/screen/spell
newscreen.spellmaster = src
newscreen.spell = spell
@@ -161,7 +161,7 @@
var/icon/last_charged_icon
/obj/screen/spell/Destroy()
..()
. = ..()
spell = null
last_charged_icon = null
if(spellmaster)
@@ -1,6 +0,0 @@
/bower_components
/node_modules
/ProcessScheduler.dmb
/ProcessScheduler.int
/ProcessScheduler.rsc
/*.lk
@@ -1,212 +0,0 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based on the Program.
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.
@@ -1 +0,0 @@
This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
@@ -1,86 +0,0 @@
ProcessScheduler
================
A Goonstation release, maintained by Volundr
##SUMMARY
This is a mostly self-contained, fairly well-documented implementation of the main loop process architecture in use in Goonstation.
##LICENSE
This work is released under the following licenses.
[![Creative Commons License](https://licensebuttons.net/l/by-nc/4.0/80x15.png)](http://creativecommons.org/licenses/by-nc/4.0/)
This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. The complete text of this license is included in the file LICENSE-CC-BY-NC.
[![Affero GPL Version 3](http://www.gnu.org/graphics/agplv3-88x31.png)](http://www.gnu.org/licenses/agpl-3.0.html)
This work is licensed under the Affero General Public License 3.0. The complete text of the license is included in the file LICENSE-AGPL.
##INSTALLATION
To integrate the process scheduler to your codebase, you will not need anything except the contents of the core/ folder. The rest of the project is simply for testing and to provide an example for the process scheduler code.
### Test project setup
To compile and run the test project, you will require:
- node.js
- BYOND
Clone the repository to a path of your choosing, then change directory to it and execute:
```
npm install -g
bower install -g
```
Then you can either compile with DM or open the DM environment in DreamMaker and compile/run from there.
##USAGE
###BASICS
To use the process scheduler in your SS13 codebase, you'll need:
- core/_defines.dm
- core/_stubs.dm
- core/process.dm
- core/processScheduler.dm
- core/processScheduler.js
- core/updateQueue.dm
- core/updateQueueWorker.dm
To integrate, you can copy the contents of _defines.dm into your global defines file. Most ss13 codebases already have the code from _stubs.dm.
The processScheduler is intended as a replacement for the old master_controller from r4407 and other fork codebases. To implement it, you need only to add the source files to your DM environment, and add the following code into world.New, above where the old master_controller is initialized.
```
processScheduler = new
processScheduler.setup()
processScheduler.start()
```
The processScheduler will automatically find all subtypes of process, and begin processing them.
The interface code in test/processSchedulerView.dm is simply an example frontend, and can easily be rebuilt to use other styles, and/or render simple html without using javascript for refreshing the panel and killing processes.
###DETAILS
To implement a process, you have two options:
1. Implement a raw loop-style processor
2. Implement an updateQueue processor
There are clear examples of both of these paradigms in the code provided. Both styles are valid, but for processes that are just a loop calling an update proc on a bunch of objects, you should use the updateQueue.
The updateQueue works by spawn(0)'ing your specified update proc, but it only puts one instance in the scheduler at a time. Examine the code for more details. The overall effect of this is that it doesn't block, and it lets update loops work concurrently. It enables a much smoother user experience.
##Contributing
I welcome pull requests and issue reports, and will try to merge/fix them as I have time.
### Licensing for code submitted via PR:
By submitting a pull request, you agree to release all original code submitted in the pull request under the [MIT License](http://opensource.org/licenses/MIT). You also agree that any code submitted is either your own work, or is public domain or under a equally or less restrictive license than the MIT license, or that you have the express written permission of the authors of the submitted code to submit the pull request.
@@ -1,30 +0,0 @@
{
"name": "ProcessScheduler",
"main": "ProcessScheduler.js",
"version": "1.0.0",
"homepage": "https://github.com/goonstation/ProcessScheduler",
"authors": [
"Volundr <spoogemonster@gmail.com>"
],
"description": "BYOND SS13 Process Scheduler",
"keywords": [
"byond",
"ss13",
"process",
"scheduler"
],
"license": "CC-BY-NC",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"private": true,
"dependencies": {
"bootstrap2.3.2": "~2.3.2",
"jquery": "1.11.1",
"json2": "*"
}
}
@@ -1,19 +0,0 @@
/**
* _stubs.dm
*
* This file contains constructs that the process scheduler expects to exist
* in a standard ss13 fork.
*/
/**
* logTheThing
*
* In goonstation, this proc writes a message to either the world log or diary.
*
* Blame Keelin.
*/
/proc/logTheThing(type, source, target, text, diaryType)
if(diaryType)
world << "Diary: \[[diaryType]:[type]] [text]"
else
world << "Log: \[[type]] [text]"
@@ -1,377 +0,0 @@
// Process
/datum/controller/process
/**
* State vars
*/
// Main controller ref
var/tmp/datum/controller/processScheduler/main
// 1 if process is not running or queued
var/tmp/idle = 1
// 1 if process is queued
var/tmp/queued = 0
// 1 if process is running
var/tmp/running = 0
// 1 if process is blocked up
var/tmp/hung = 0
// 1 if process was killed
var/tmp/killed = 0
// Status text var
var/tmp/status
// Previous status text var
var/tmp/previousStatus
// 1 if process is disabled
var/tmp/disabled = 0
/**
* Config vars
*/
// Process name
var/name
// Process schedule interval
// This controls how often the process would run under ideal conditions.
// If the process scheduler sees that the process has finished, it will wait until
// this amount of time has elapsed from the start of the previous run to start the
// process running again.
var/tmp/schedule_interval = PROCESS_DEFAULT_SCHEDULE_INTERVAL // run every 50 ticks
// Process tick allowance
// This controls what percentage a single tick (0 to 100) the process should be.
// allowed to run before sleeping.
var/tmp/tick_allowance = PROCESS_DEFAULT_TICK_ALLOWANCE
// hang_warning_time - this is the time (in 1/10 seconds) after which the server will begin to show "maybe hung" in the context window
var/tmp/hang_warning_time = PROCESS_DEFAULT_HANG_WARNING_TIME
// hang_alert_time - After this much time(in 1/10 seconds), the server will send an admin debug message saying the process may be hung
var/tmp/hang_alert_time = PROCESS_DEFAULT_HANG_ALERT_TIME
// hang_restart_time - After this much time(in 1/10 seconds), the server will automatically kill and restart the process.
var/tmp/hang_restart_time = PROCESS_DEFAULT_HANG_RESTART_TIME
// How many times in the current run has the process deferred work till the next tick?
var/tmp/cpu_defer_count = 0
// How many SCHECKs have been skipped (to limit btime calls)
var/tmp/calls_since_last_scheck = 0
/**
* recordkeeping vars
*/
// Records the time (1/10s timeofday) at which the process last finished sleeping
var/tmp/last_slept = 0
// Records the time (1/10s timeofday) at which the process last began running
var/tmp/run_start = 0
// Records the world.tick_usage (0 to 100) at which the process last began running
var/tmp/tick_start = 0
// Records the number of times this process has been killed and restarted
var/tmp/times_killed
// Tick count
var/tmp/ticks = 0
var/tmp/last_task = ""
var/tmp/last_object
// Counts the number of times an exception has occurred; gets reset after 10
var/tmp/list/exceptions = list()
// Number of deciseconds to delay before starting the process
var/start_delay = 0
/datum/controller/process/New(var/datum/controller/processScheduler/scheduler)
..()
main = scheduler
previousStatus = "idle"
idle()
name = "process"
schedule_interval = 50
last_slept = 0
run_start = 0
tick_start = 0
ticks = 0
last_task = 0
last_object = null
/datum/controller/process/proc/preStart()
/datum/controller/process/proc/started()
var/timeofhour = TimeOfHour
// Initialize last_slept so we can record timing information
last_slept = timeofhour
// Initialize run_start so we can detect hung processes.
run_start = timeofhour
// Initialize tick_start so we can know when to sleep
tick_start = world.tick_usage
// Initialize defer count
cpu_defer_count = 0
running()
main.processStarted(src)
onStart()
/datum/controller/process/proc/finished()
ticks++
idle()
main.processFinished(src)
onFinish()
/datum/controller/process/proc/doWork()
/datum/controller/process/proc/setup()
/datum/controller/process/proc/process()
started()
doWork()
finished()
/datum/controller/process/proc/running()
idle = 0
queued = 0
running = 1
hung = 0
setStatus(PROCESS_STATUS_RUNNING)
/datum/controller/process/proc/idle()
queued = 0
running = 0
idle = 1
hung = 0
setStatus(PROCESS_STATUS_IDLE)
/datum/controller/process/proc/queued()
idle = 0
running = 0
queued = 1
hung = 0
setStatus(PROCESS_STATUS_QUEUED)
/datum/controller/process/proc/hung()
hung = 1
setStatus(PROCESS_STATUS_HUNG)
/datum/controller/process/proc/handleHung()
var/timeofhour = TimeOfHour
var/datum/lastObj = last_object
var/lastObjType = "null"
if(istype(lastObj))
lastObjType = lastObj.type
// If timeofhour has rolled over, then we need to adjust.
if (timeofhour < run_start)
run_start -= 36000
var/msg = "[name] process hung at tick #[ticks]. Process was unresponsive for [(timeofhour - run_start) / 10] seconds and was restarted. Last task: [last_task]. Last Object Type: [lastObjType]"
logTheThing("debug", null, null, msg)
logTheThing("diary", null, null, msg, "debug")
message_admins(msg)
main.restartProcess(src.name)
/datum/controller/process/proc/kill()
if (!killed)
var/msg = "[name] process was killed at tick #[ticks]."
logTheThing("debug", null, null, msg)
logTheThing("diary", null, null, msg, "debug")
//finished()
// Allow inheritors to clean up if needed
onKill()
// This should del
del(src)
// Do not call this directly - use SHECK or SCHECK_EVERY
/datum/controller/process/proc/sleepCheck(var/tickId = 0)
calls_since_last_scheck = 0
if (killed)
// The kill proc is the only place where killed is set.
// The kill proc should have deleted this datum, and all sleeping procs that are
// owned by it.
CRASH("A killed process is still running somehow...")
if (hung)
// This will only really help if the doWork proc ends up in an infinite loop.
handleHung()
CRASH("Process [name] hung and was restarted.")
if (world.tick_usage > 100 || (world.tick_usage - tick_start) > tick_allowance)
sleep(world.tick_lag)
cpu_defer_count++
last_slept = TimeOfHour
tick_start = world.tick_usage
return 1
return 0
/datum/controller/process/proc/update()
// Clear delta
if(previousStatus != status)
setStatus(status)
var/elapsedTime = getElapsedTime()
if (hung)
handleHung()
return
else if (elapsedTime > hang_restart_time)
hung()
else if (elapsedTime > hang_alert_time)
setStatus(PROCESS_STATUS_PROBABLY_HUNG)
else if (elapsedTime > hang_warning_time)
setStatus(PROCESS_STATUS_MAYBE_HUNG)
/datum/controller/process/proc/getElapsedTime()
var/timeofhour = TimeOfHour
if (timeofhour < run_start)
return timeofhour - (run_start - 36000)
return timeofhour - run_start
/datum/controller/process/proc/tickDetail()
return
/datum/controller/process/proc/getContext()
return "<tr><td>[name]</td><td>[main.averageRunTime(src)]</td><td>[main.last_run_time[src]]</td><td>[main.highest_run_time[src]]</td><td>[ticks]</td></tr>\n"
/datum/controller/process/proc/getContextData()
return list(
"name" = name,
"averageRunTime" = main.averageRunTime(src),
"lastRunTime" = main.last_run_time[src],
"highestRunTime" = main.highest_run_time[src],
"ticks" = ticks,
"schedule" = schedule_interval,
"status" = getStatusText(),
"disabled" = disabled
)
/datum/controller/process/proc/getStatus()
return status
/datum/controller/process/proc/getStatusText(var/s = 0)
if(!s)
s = status
switch(s)
if(PROCESS_STATUS_IDLE)
return "idle (-1)"
if(PROCESS_STATUS_QUEUED)
return "queued (0)"
if(PROCESS_STATUS_RUNNING)
return "running (1)"
if(PROCESS_STATUS_MAYBE_HUNG)
return "maybe hung (2)"
if(PROCESS_STATUS_PROBABLY_HUNG)
return "probably hung (3)"
if(PROCESS_STATUS_HUNG)
return "HUNG (4)"
else
return "UNKNOWN (?)"
/datum/controller/process/proc/getPreviousStatus()
return previousStatus
/datum/controller/process/proc/getPreviousStatusText()
return getStatusText(previousStatus)
/datum/controller/process/proc/setStatus(var/newStatus)
previousStatus = status
status = newStatus
/datum/controller/process/proc/setLastTask(var/task, var/object)
last_task = task
last_object = object
/datum/controller/process/proc/_copyStateFrom(var/datum/controller/process/target)
main = target.main
name = target.name
schedule_interval = target.schedule_interval
last_slept = 0
run_start = 0
tick_start = 0
times_killed = target.times_killed
ticks = target.ticks
last_task = target.last_task
last_object = target.last_object
copyStateFrom(target)
/datum/controller/process/proc/copyStateFrom(var/datum/controller/process/target)
/datum/controller/process/proc/onKill()
/datum/controller/process/proc/onStart()
/datum/controller/process/proc/onFinish()
/datum/controller/process/proc/disable()
disabled = 1
/datum/controller/process/proc/enable()
disabled = 0
/datum/controller/process/proc/getAverageRunTime()
return main.averageRunTime(src)
/datum/controller/process/proc/getLastRunTime()
return main.getProcessLastRunTime(src)
/datum/controller/process/proc/getHighestRunTime()
return main.getProcessHighestRunTime(src)
/datum/controller/process/proc/getTicks()
return ticks
/datum/controller/process/proc/statProcess()
var/averageRunTime = round(getAverageRunTime(), 0.1)/10
var/lastRunTime = round(getLastRunTime(), 0.1)/10
var/highestRunTime = round(getHighestRunTime(), 0.1)/10
stat("[name]", "T#[getTicks()] | AR [averageRunTime] | LR [lastRunTime] | HR [highestRunTime] | D [cpu_defer_count]")
/datum/controller/process/proc/catchException(var/exception/e, var/thrower)
var/etext = "[e]"
var/eid = "[e]" // Exception ID, for tracking repeated exceptions
var/ptext = "" // "processing..." text, for what was being processed (if known)
if(istype(e))
etext += " in [e.file], line [e.line]"
eid = "[e.file]:[e.line]"
if(eid in exceptions)
if(exceptions[eid]++ >= 10)
return
else
exceptions[eid] = 1
if(istype(thrower, /datum))
var/datum/D = thrower
ptext = " processing [D.type]"
if(istype(thrower, /atom))
var/atom/A = thrower
ptext += " ([A]) ([A.x],[A.y],[A.z])"
log_to_dd("\[[time_stamp()]\] Process [name] caught exception[ptext]: [etext]")
if(exceptions[eid] >= 10)
log_to_dd("This exception will now be ignored for ten minutes.")
spawn(6000)
exceptions[eid] = 0
e.time_stamp()
log_exception(e)
/datum/controller/process/proc/catchBadType(var/datum/caught)
if(isnull(caught) || !istype(caught) || !isnull(caught.gcDestroyed))
return // Only bother with types we can identify and that don't belong
catchException("Type [caught.type] does not belong in process' queue")
@@ -1,351 +0,0 @@
// Singleton instance of game_controller_new, setup in world.New()
var/global/datum/controller/processScheduler/processScheduler
/datum/controller/processScheduler
// Processes known by the scheduler
var/tmp/datum/controller/process/list/processes = new
// Processes that are currently running
var/tmp/datum/controller/process/list/running = new
// Processes that are idle
var/tmp/datum/controller/process/list/idle = new
// Processes that are queued to run
var/tmp/datum/controller/process/list/queued = new
// Process name -> process object map
var/tmp/datum/controller/process/list/nameToProcessMap = new
// Process last queued times (world time)
var/tmp/datum/controller/process/list/last_queued = new
// Process last start times (real time)
var/tmp/datum/controller/process/list/last_start = new
// Process last run durations
var/tmp/datum/controller/process/list/last_run_time = new
// Per process list of the last 20 durations
var/tmp/datum/controller/process/list/last_twenty_run_times = new
// Process highest run time
var/tmp/datum/controller/process/list/highest_run_time = new
// How long to sleep between runs (set to tick_lag in New)
var/tmp/scheduler_sleep_interval
// Controls whether the scheduler is running or not
var/tmp/isRunning = 0
// Setup for these processes will be deferred until all the other processes are set up.
var/tmp/list/deferredSetupList = new
var/tmp/currentTick = 0
var/tmp/currentTickStart = 0
var/tmp/cpuAverage = 0
/datum/controller/processScheduler/New()
..()
// When the process scheduler is first new'd, tick_lag may be wrong, so these
// get re-initialized when the process scheduler is started.
// (These are kept here for any processes that decide to process before round start)
scheduler_sleep_interval = world.tick_lag
/**
* deferSetupFor
* @param path processPath
* If a process needs to be initialized after everything else, add it to
* the deferred setup list. On goonstation, only the ticker needs to have
* this treatment.
*/
/datum/controller/processScheduler/proc/deferSetupFor(var/processPath)
if (!(processPath in deferredSetupList))
deferredSetupList += processPath
/datum/controller/processScheduler/proc/setup()
// There can be only one
if(processScheduler && (processScheduler != src))
del(src)
return 0
var/process
// Add all the processes we can find, except for the ticker
for (process in subtypesof(/datum/controller/process))
if (!(process in deferredSetupList))
addProcess(new process(src))
for (process in deferredSetupList)
addProcess(new process(src))
/datum/controller/processScheduler/proc/start()
isRunning = 1
// tick_lag will have been set by now, so re-initialize these
scheduler_sleep_interval = world.tick_lag
callPreStart()
updateStartDelays()
spawn(0)
process()
/datum/controller/processScheduler/proc/callPreStart()
for (var/datum/controller/process/P in processes)
if (!P.disabled)
P.preStart()
/datum/controller/processScheduler/proc/process()
while(isRunning)
checkRunningProcesses()
queueProcesses()
runQueuedProcesses()
sleep(scheduler_sleep_interval)
/datum/controller/processScheduler/proc/stop()
isRunning = 0
/datum/controller/processScheduler/proc/checkRunningProcesses()
for(var/datum/controller/process/p in running)
p.update()
if (isnull(p)) // Process was killed
continue
var/status = p.getStatus()
var/previousStatus = p.getPreviousStatus()
// Check status changes
if(status != previousStatus)
//Status changed.
switch(status)
if(PROCESS_STATUS_PROBABLY_HUNG)
message_admins("Process '[p.name]' may be hung.")
if(PROCESS_STATUS_HUNG)
message_admins("Process '[p.name]' is hung and will be restarted.")
/datum/controller/processScheduler/proc/queueProcesses()
for(var/datum/controller/process/p in processes)
// Don't double-queue, don't queue running processes
if (p.disabled || p.running || p.queued || !p.idle)
continue
// If the process should be running by now, go ahead and queue it
if (world.time >= last_queued[p] + p.schedule_interval)
setQueuedProcessState(p)
/datum/controller/processScheduler/proc/runQueuedProcesses()
for(var/datum/controller/process/p in queued)
runProcess(p)
/datum/controller/processScheduler/proc/addProcess(var/datum/controller/process/process)
processes.Add(process)
process.idle()
idle.Add(process)
// init recordkeeping vars
last_start.Add(process)
last_start[process] = 0
last_run_time.Add(process)
last_run_time[process] = 0
last_twenty_run_times.Add(process)
last_twenty_run_times[process] = list()
highest_run_time.Add(process)
highest_run_time[process] = 0
// init starts and stops record starts
recordStart(process, 0)
recordEnd(process, 0)
// Set up process
process.setup()
// Save process in the name -> process map
nameToProcessMap[process.name] = process
/datum/controller/processScheduler/proc/replaceProcess(var/datum/controller/process/oldProcess, var/datum/controller/process/newProcess)
processes.Remove(oldProcess)
processes.Add(newProcess)
newProcess.idle()
idle.Remove(oldProcess)
running.Remove(oldProcess)
queued.Remove(oldProcess)
idle.Add(newProcess)
last_start.Remove(oldProcess)
last_start.Add(newProcess)
last_start[newProcess] = 0
last_run_time.Add(newProcess)
last_run_time[newProcess] = last_run_time[oldProcess]
last_run_time.Remove(oldProcess)
last_twenty_run_times.Add(newProcess)
last_twenty_run_times[newProcess] = last_twenty_run_times[oldProcess]
last_twenty_run_times.Remove(oldProcess)
highest_run_time.Add(newProcess)
highest_run_time[newProcess] = highest_run_time[oldProcess]
highest_run_time.Remove(oldProcess)
recordStart(newProcess, 0)
recordEnd(newProcess, 0)
nameToProcessMap[newProcess.name] = newProcess
/datum/controller/processScheduler/proc/updateStartDelays()
for(var/datum/controller/process/p in processes)
if(p.start_delay)
last_queued[p] = world.time - p.start_delay
/datum/controller/processScheduler/proc/runProcess(var/datum/controller/process/process)
spawn(0)
process.process()
/datum/controller/processScheduler/proc/processStarted(var/datum/controller/process/process)
setRunningProcessState(process)
recordStart(process)
/datum/controller/processScheduler/proc/processFinished(var/datum/controller/process/process)
setIdleProcessState(process)
recordEnd(process)
/datum/controller/processScheduler/proc/setIdleProcessState(var/datum/controller/process/process)
if (process in running)
running -= process
if (process in queued)
queued -= process
if (!(process in idle))
idle += process
/datum/controller/processScheduler/proc/setQueuedProcessState(var/datum/controller/process/process)
if (process in running)
running -= process
if (process in idle)
idle -= process
if (!(process in queued))
queued += process
// The other state transitions are handled internally by the process.
process.queued()
/datum/controller/processScheduler/proc/setRunningProcessState(var/datum/controller/process/process)
if (process in queued)
queued -= process
if (process in idle)
idle -= process
if (!(process in running))
running += process
/datum/controller/processScheduler/proc/recordStart(var/datum/controller/process/process, var/time = null)
if (isnull(time))
time = TimeOfHour
last_queued[process] = world.time
last_start[process] = time
else
last_queued[process] = (time == 0 ? 0 : world.time)
last_start[process] = time
/datum/controller/processScheduler/proc/recordEnd(var/datum/controller/process/process, var/time = null)
if (isnull(time))
time = TimeOfHour
// If world.timeofday has rolled over, then we need to adjust.
if (time < last_start[process])
last_start[process] -= 36000
var/lastRunTime = time - last_start[process]
if(lastRunTime < 0)
lastRunTime = 0
recordRunTime(process, lastRunTime)
/**
* recordRunTime
* Records a run time for a process
*/
/datum/controller/processScheduler/proc/recordRunTime(var/datum/controller/process/process, time)
last_run_time[process] = time
if(time > highest_run_time[process])
highest_run_time[process] = time
var/list/lastTwenty = last_twenty_run_times[process]
if (lastTwenty.len == 20)
lastTwenty.Cut(1, 2)
lastTwenty.len++
lastTwenty[lastTwenty.len] = time
/**
* averageRunTime
* returns the average run time (over the last 20) of the process
*/
/datum/controller/processScheduler/proc/averageRunTime(var/datum/controller/process/process)
var/lastTwenty = last_twenty_run_times[process]
var/t = 0
var/c = 0
for(var/time in lastTwenty)
t += time
c++
if(c > 0)
return t / c
return c
/datum/controller/processScheduler/proc/getProcessLastRunTime(var/datum/controller/process/process)
return last_run_time[process]
/datum/controller/processScheduler/proc/getProcessHighestRunTime(var/datum/controller/process/process)
return highest_run_time[process]
/datum/controller/processScheduler/proc/getStatusData()
var/list/data = new
for (var/datum/controller/process/p in processes)
data.len++
data[data.len] = p.getContextData()
return data
/datum/controller/processScheduler/proc/getProcessCount()
return processes.len
/datum/controller/processScheduler/proc/hasProcess(var/processName as text)
if (nameToProcessMap[processName])
return 1
/datum/controller/processScheduler/proc/killProcess(var/processName as text)
restartProcess(processName)
/datum/controller/processScheduler/proc/restartProcess(var/processName as text)
if (hasProcess(processName))
var/datum/controller/process/oldInstance = nameToProcessMap[processName]
var/datum/controller/process/newInstance = new oldInstance.type(src)
newInstance._copyStateFrom(oldInstance)
replaceProcess(oldInstance, newInstance)
oldInstance.kill()
/datum/controller/processScheduler/proc/enableProcess(var/processName as text)
if (hasProcess(processName))
var/datum/controller/process/process = nameToProcessMap[processName]
process.enable()
/datum/controller/processScheduler/proc/disableProcess(var/processName as text)
if (hasProcess(processName))
var/datum/controller/process/process = nameToProcessMap[processName]
process.disable()
/datum/controller/processScheduler/proc/sign(var/x)
if (x == 0)
return 1
return x / abs(x)
/datum/controller/processScheduler/proc/statProcesses()
if(!isRunning)
stat("Processes", "Scheduler not running")
return
stat("Processes", "[processes.len] (R [running.len] / Q [queued.len] / I [idle.len])")
stat(null, "[round(cpuAverage, 0.1)] CPU")
for(var/datum/controller/process/p in processes)
p.statProcess()
@@ -1,28 +0,0 @@
{
"name": "ProcessScheduler",
"version": "1.0.0",
"description": "BYOND SS13 Process Scheduler",
"main": "processScheduler.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/goonstation/ProcessScheduler.git"
},
"keywords": [
"byond",
"ss13",
"process",
"scheduler"
],
"author": "Volundr",
"license": "CC-BY-NC",
"bugs": {
"url": "https://github.com/goonstation/ProcessScheduler/issues"
},
"homepage": "https://github.com/goonstation/ProcessScheduler",
"dependencies": {
"bower": "*"
}
}
@@ -1,56 +0,0 @@
(function ($) {
function setRef(theRef) {
ref = theRef;
}
function jax(action, data) {
if (typeof data === 'undefined')
data = {};
var params = [];
for (var k in data) {
if (data.hasOwnProperty(k)) {
params.push(encodeURIComponent(k) + '=' + encodeURIComponent(data[k]));
}
}
var newLoc = '?src=' + ref + ';action=' + action + ';' + params.join(';');
window.location = newLoc;
}
function requestRefresh(e) {
jax("refresh", null);
}
function handleRefresh(processTable) {
$('#processTable').html(processTable);
initProcessTableButtons();
}
function requestKill(e) {
var button = $(e.currentTarget);
jax("kill", {name: button.data("process-name")});
}
function requestEnable(e) {
var button = $(e.currentTarget);
jax("enable", {name: button.data("process-name")});
}
function requestDisable(e) {
var button = $(e.currentTarget);
jax("disable", {name: button.data("process-name")});
}
function initProcessTableButtons() {
$(".kill-btn").on("click", requestKill);
$(".enable-btn").on("click", requestEnable);
$(".disable-btn").on("click", requestDisable);
}
window.setRef = setRef;
window.handleRefresh = handleRefresh;
$(function() {
initProcessTableButtons();
$('#btn-refresh').on("click", requestRefresh);
});
}(jQuery));
-9
View File
@@ -1,9 +0,0 @@
/datum/controller/process/Shuttle/setup()
name = "shuttle controller"
schedule_interval = 20 // every 2 seconds
if(!shuttle_controller)
shuttle_controller = new
/datum/controller/process/Shuttle/doWork()
shuttle_controller.process()
-23
View File
@@ -1,23 +0,0 @@
/datum/controller/process/air/setup()
name = "air"
schedule_interval = 20 // every 2 seconds
start_delay = 4
if(!air_master)
air_master = new
air_master.Setup()
/datum/controller/process/air/doWork()
if(!air_processing_killed)
if(!air_master.Tick()) //Runtimed.
air_master.failed_ticks++
if(air_master.failed_ticks > 5)
world << "<SPAN CLASS='danger'>RUNTIMES IN ATMOS TICKER. Killing air simulation!</SPAN>"
world.log << "### ZAS SHUTDOWN"
message_admins("ZASALERT: Shutting down! status: [air_master.tick_progress]")
log_admin("ZASALERT: Shutting down! status: [air_master.tick_progress]",level=1)
air_processing_killed = TRUE
air_master.failed_ticks = 0
-41
View File
@@ -1,41 +0,0 @@
// We manually initialize the alarm handlers instead of looping over all existing types
// to make it possible to write: camera.triggerAlarm() rather than alarm_manager.managers[datum/alarm_handler/camera].triggerAlarm() or a variant thereof.
/var/global/datum/alarm_handler/atmosphere/atmosphere_alarm = new()
/var/global/datum/alarm_handler/camera/camera_alarm = new()
/var/global/datum/alarm_handler/fire/fire_alarm = new()
/var/global/datum/alarm_handler/motion/motion_alarm = new()
/var/global/datum/alarm_handler/power/power_alarm = new()
// Alarm Manager, the manager for alarms.
var/datum/controller/process/alarm/alarm_manager
/datum/controller/process/alarm
var/list/datum/alarm/all_handlers
/datum/controller/process/alarm/setup()
name = "alarm"
schedule_interval = 20 // every 2 seconds
all_handlers = list(atmosphere_alarm, camera_alarm, fire_alarm, motion_alarm, power_alarm)
alarm_manager = src
/datum/controller/process/alarm/doWork()
for(last_object in all_handlers)
var/datum/alarm_handler/AH = last_object
AH.process()
F_SCHECK
/datum/controller/process/alarm/proc/active_alarms()
var/list/all_alarms = new
for(var/datum/alarm_handler/AH in all_handlers)
var/list/alarms = AH.alarms
all_alarms += alarms
return all_alarms
/datum/controller/process/alarm/proc/number_of_active_alarms()
var/list/alarms = active_alarms()
return alarms.len
/datum/controller/process/alarm/statProcess()
..()
stat(null, "[number_of_active_alarms()] alarm\s")
-33
View File
@@ -1,33 +0,0 @@
var/datum/controller/process/chemistry/chemistryProcess
/datum/controller/process/chemistry
var/list/active_holders
var/list/chemical_reactions
var/list/chemical_reagents
/datum/controller/process/chemistry/setup()
name = "chemistry"
schedule_interval = 20 // every 2 seconds
chemistryProcess = src
active_holders = list()
chemical_reactions = chemical_reactions_list
chemical_reagents = chemical_reagents_list
/datum/controller/process/chemistry/statProcess()
..()
stat(null, "[active_holders.len] reagent holder\s")
/datum/controller/process/chemistry/doWork()
for(last_object in active_holders)
var/datum/reagents/holder = last_object
if(!holder.process_reactions())
active_holders -= holder
F_SCHECK
/datum/controller/process/chemistry/proc/mark_for_update(var/datum/reagents/holder)
if(holder in active_holders)
return
//Process once, right away. If we still need to continue then add to the active_holders list and continue later
if(holder.process_reactions())
active_holders += holder
-16
View File
@@ -1,16 +0,0 @@
/datum/controller/process/disease
var/tmp/datum/updateQueue/updateQueueInstance
/datum/controller/process/disease/setup()
name = "disease"
schedule_interval = 20 // every 2 seconds
/datum/controller/process/disease/doWork()
for(last_object in active_diseases)
var/datum/disease/D = last_object
D.process()
F_SCHECK
/datum/controller/process/disease/statProcess()
..()
stat(null, "[active_diseases.len] disease\s")
-92
View File
@@ -1,92 +0,0 @@
#define STAGE_IDLE 0
#define STAGE_EFFECT 1
#define STAGE_SUBEFFECT 2
var/datum/controller/process/effects/effect_master
/var/list/datum/effect_system/effects_objects = list() // The effect-spawning objects. Shouldn't be many of these.
/var/list/obj/visual_effect/effects_visuals = list() // The visible component of an effect. May be created without an effect object.
/datum/controller/process/effects
var/tmp/list/processing_effects = list()
var/tmp/list/processing_visuals = list()
var/tmp/stage = STAGE_IDLE
/datum/controller/process/effects/setup()
effect_master = src
name = "effects"
schedule_interval = 2
tick_allowance = 15
/datum/controller/process/effects/doWork()
if (stage == STAGE_IDLE)
// Start a new work cycle.
processing_effects = effects_objects
effects_objects = list()
stage = STAGE_EFFECT
while (processing_effects.len)
var/datum/effect_system/E = processing_effects[processing_effects.len]
processing_effects.len--
if (!E || E.gcDestroyed)
continue
switch (E.process())
if (EFFECT_CONTINUE)
effects_objects += E
if (EFFECT_DESTROY)
returnToPool(E)
F_SCHECK
if (stage == STAGE_EFFECT)
processing_visuals = effects_visuals
effects_visuals = list()
stage = STAGE_SUBEFFECT
while (processing_visuals.len)
var/obj/visual_effect/V = processing_visuals[processing_visuals.len]
processing_visuals.len--
if (!V || V.gcDestroyed)
effects_visuals -= V
continue
switch (V.tick())
if (EFFECT_CONTINUE)
effects_visuals += V
if (EFFECT_DESTROY)
effects_visuals -= V
V.end()
returnToPool(V)
F_SCHECK
stage = STAGE_IDLE
// We're done.
if (!processing_effects.len && !processing_visuals.len && !effects_objects.len && !effects_visuals.len)
disable()
/datum/controller/process/effects/proc/queue(var/datum/effect_system/E)
if (!E || E.gcDestroyed)
return
effects_objects += E
enable()
/datum/controller/process/effects/proc/queue_simple(var/obj/visual_effect/V)
if (!V || V.gcDestroyed)
return
effects_visuals += V
enable()
/datum/controller/process/effects/statProcess()
..()
stat(null, "Effect process is [disabled ? "sleeping" : "processing"].")
stat(null, "[effects_objects.len] effects queued, [processing_effects.len] processing")
stat(null, "[effects_visuals.len] visuals queued, [processing_visuals.len] processing")
@@ -1,9 +0,0 @@
/datum/controller/process/emergencyShuttle/setup()
name = "emergency shuttle"
schedule_interval = 20 // every 2 seconds
if(!emergency_shuttle)
emergency_shuttle = new
/datum/controller/process/emergencyShuttle/doWork()
emergency_shuttle.process()
-15
View File
@@ -1,15 +0,0 @@
/datum/controller/process/event/setup()
name = "event controller"
schedule_interval = 20 // every 2 seconds
/datum/controller/process/event/doWork()
for(last_object in event_manager.active_events)
var/datum/event/E = last_object
E.process()
F_SCHECK
for(var/i = EVENT_LEVEL_MUNDANE to EVENT_LEVEL_MAJOR)
last_object = event_manager.event_containers[i]
var/list/datum/event_container/EC = last_object
EC.process()
F_SCHECK
-253
View File
@@ -1,253 +0,0 @@
// The time a datum was destroyed by the GC, or null if it hasn't been
/datum/var/gcDestroyed
#define GC_COLLECTIONS_PER_RUN 300
#define GC_COLLECTION_TIMEOUT (30 SECONDS)
#define GC_FORCE_DEL_PER_RUN 30
var/datum/controller/process/garbage_collector/garbage_collector
var/list/delayed_garbage = list()
/datum/controller/process/garbage_collector
var/garbage_collect = 1 // Whether or not to actually do work
var/total_dels = 0 // number of total del()'s
var/tick_dels = 0 // number of del()'s we've done this tick
var/soft_dels = 0
var/hard_dels = 0 // number of hard dels in total
var/list/destroyed = list() // list of refID's of things that should be garbage collected
// refID's are associated with the time at which they time out and need to be manually del()
// we do this so we aren't constantly locating them and preventing them from being gc'd
var/list/logging = list() // list of all types that have failed to GC associated with the number of times that's happened.
// the types are stored as strings
/datum/controller/process/garbage_collector/setup()
name = "garbage"
schedule_interval = 5 SECONDS
start_delay = 3
if(!garbage_collector)
garbage_collector = src
for(var/garbage in delayed_garbage)
qdel(garbage)
delayed_garbage.Cut()
delayed_garbage = null
#ifdef GC_FINDREF
world/loop_checks = 0
#endif
/datum/controller/process/garbage_collector/doWork()
if(!garbage_collect)
return
tick_dels = 0
var/time_to_kill = world.time - GC_COLLECTION_TIMEOUT
var/checkRemain = GC_COLLECTIONS_PER_RUN
var/remaining_force_dels = GC_FORCE_DEL_PER_RUN
while(destroyed.len && --checkRemain >= 0)
if(remaining_force_dels <= 0)
#ifdef GC_DEBUG
testing("GC: Reached max force dels per tick [dels] vs [maxDels]")
#endif
break // Server's already pretty pounded, everything else can wait 2 seconds
var/refID = destroyed[1]
var/GCd_at_time = destroyed[refID]
if(GCd_at_time > time_to_kill)
#ifdef GC_DEBUG
testing("GC: [refID] not old enough, breaking at [world.time] for [GCd_at_time - time_to_kill] deciseconds until [GCd_at_time + collection_timeout]")
#endif
break // Everything else is newer, skip them
var/datum/A = locate(refID)
#ifdef GC_DEBUG
testing("GC: [refID] old enough to test: GCd_at_time: [GCd_at_time] time_to_kill: [time_to_kill] current: [world.time]")
#endif
if(A && A.gcDestroyed == GCd_at_time) // So if something else coincidently gets the same ref, it's not deleted by mistake
// Something's still referring to the qdel'd object. Kill it.
log_hard_delete(A)
logging["[A.type]"]++
del(A)
hard_dels++
remaining_force_dels--
else
#ifdef GC_DEBUG
testing("GC: [refID] properly GC'd at [world.time] with timeout [GCd_at_time]")
#endif
soft_dels++
tick_dels++
total_dels++
destroyed.Cut(1, 2)
F_SCHECK
#undef GC_FORCE_DEL_PER_TICK
#undef GC_COLLECTION_TIMEOUT
#undef GC_COLLECTIONS_PER_TICK
#ifdef GC_FINDREF
/datum/controller/process/garbage_collector/proc/LookForRefs(var/datum/D, var/list/targ)
. = 0
for(var/V in D.vars)
if(V == "contents")
continue
if(istype(D.vars[V], /atom))
var/atom/A = D.vars[V]
if(A in targ)
testing("GC: [A] | [A.type] referenced by [D] | [D.type], var [V]")
. += 1
else if(islist(D.vars[V]))
. += LookForListRefs(D.vars[V], targ, D, V)
/datum/controller/process/garbage_collector/proc/LookForListRefs(var/list/L, var/list/targ, var/datum/D, var/V)
. = 0
for(var/F in L)
if(istype(F, /atom))
var/atom/A = F
if(A in targ)
testing("GC: [A] | [A.type] referenced by [D] | [D.type], list [V]")
. += 1
if(islist(F))
. += LookForListRefs(F, targ, D, "[F] in list [V]")
#endif
/datum/controller/process/garbage_collector/proc/AddTrash(datum/A)
if(!istype(A) || !isnull(A.gcDestroyed))
return
#ifdef GC_DEBUG
testing("GC: AddTrash(\ref[A] - [A.type])")
#endif
A.gcDestroyed = world.time
destroyed -= "\ref[A]" // Removing any previous references that were GC'd so that the current object will be at the end of the list.
destroyed["\ref[A]"] = world.time
/datum/controller/process/garbage_collector/statProcess()
..()
stat(null, "[garbage_collect ? "On" : "Off"], [destroyed.len] queued")
stat(null, "Dels: [total_dels], [soft_dels] soft, [hard_dels] hard, [tick_dels] last run")
// Should be treated as a replacement for the 'del' keyword.
// Datums passed to this will be given a chance to clean up references to allow the GC to collect them.
/proc/qdel(var/datum/A)
if(!A)
return
if(!istype(A))
warning("qdel() passed object of type [A.type]. qdel() can only handle /datum types.")
del(A)
if(garbage_collector)
garbage_collector.total_dels++
garbage_collector.hard_dels++
else if(isnull(A.gcDestroyed))
// Let our friend know they're about to get collected
. = !A.Destroy()
if(. && A)
A.finalize_qdel()
/datum/proc/finalize_qdel()
if(IsPooled(src))
returnToPool(src)
else
del(src)
/atom/finalize_qdel()
if (IsPooled(src))
returnToPool(src)
else
if(garbage_collector)
garbage_collector.AddTrash(src)
else
delayed_garbage |= src
/icon/finalize_qdel()
del(src)
/image/finalize_qdel()
del(src)
/mob/finalize_qdel()
del(src)
/turf/finalize_qdel()
del(src)
// Default implementation of clean-up code.
// This should be overridden to remove all references pointing to the object being destroyed.
// Return true if the the GC controller should allow the object to continue existing. (Useful if pooling objects.)
/datum/proc/Destroy()
nanomanager.close_uis(src)
tag = null
return
#ifdef TESTING
/client/var/running_find_references
/mob/verb/create_thing()
set category = "Debug"
set name = "Create Thing"
var/path = input("Enter path")
var/atom/thing = new path(loc)
thing.find_references()
/atom/verb/find_references()
set category = "Debug"
set name = "Find References"
set background = 1
set src in world
if(!usr || !usr.client)
return
if(usr.client.running_find_references)
testing("CANCELLED search for references to a [usr.client.running_find_references].")
usr.client.running_find_references = null
return
if(alert("Running this will create a lot of lag until it finishes. You can cancel it by running it again. Would you like to begin the search?", "Find References", "Yes", "No") == "No")
return
// Remove this object from the list of things to be auto-deleted.
if(garbage_collector)
garbage_collector.destroyed -= "\ref[src]"
usr.client.running_find_references = type
testing("Beginning search for references to a [type].")
var/list/things = list()
for(var/client/thing)
things += thing
for(var/datum/thing)
things += thing
for(var/atom/thing)
things += thing
testing("Collected list of things in search for references to a [type]. ([things.len] Thing\s)")
for(var/datum/thing in things)
if(!usr.client.running_find_references) return
for(var/varname in thing.vars)
var/variable = thing.vars[varname]
if(variable == src)
testing("Found [src.type] \ref[src] in [thing.type]'s [varname] var.")
else if(islist(variable))
if(src in variable)
testing("Found [src.type] \ref[src] in [thing.type]'s [varname] list var.")
testing("Completed search for references to a [type].")
usr.client.running_find_references = null
/client/verb/purge_all_destroyed_objects()
set category = "Debug"
if(garbage_collector)
while(garbage_collector.destroyed.len)
var/datum/o = locate(garbage_collector.destroyed[1])
if(istype(o) && o.gcDestroyed)
del(o)
garbage_collector.dels++
garbage_collector.destroyed.Cut(1, 2)
#endif
#ifdef GC_DEBUG
#undef GC_DEBUG
#endif
#ifdef GC_FINDREF
#undef GC_FINDREF
#endif
-14
View File
@@ -1,14 +0,0 @@
/datum/controller/process/inactivity/setup()
name = "inactivity"
schedule_interval = 600 // Once every minute (approx.)
/datum/controller/process/inactivity/doWork()
if(config.kick_inactive)
for(last_object in clients)
var/client/C = last_object
if(!C.holder && C.is_afk(config.kick_inactive MINUTES))
if(!istype(C.mob, /mob/dead))
log_access("AFK: [key_name(C)]")
C << "<SPAN CLASS='warning'>You have been inactive for more than [config.kick_inactive] minute\s and have been disconnected.</SPAN>"
del(C) // Don't qdel, cannot override finalize_qdel behaviour for clients.
F_SCHECK

Some files were not shown because too many files have changed in this diff Show More