From a4bb84fc6d3f9745c0674ce3988e4fc094d8310f Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Wed, 16 Dec 2020 19:05:10 +0000 Subject: [PATCH] SSticker minor refactor (#15089) * SSticker minor refactor * Even the experienced make mistakes * tiny lil bandaid * Oops * Update code/controllers/subsystem/ticker.dm * Adds this --- .github/CODEOWNERS | 1 + _maps/map_files/cyberiad/z2.dmm | 356 ++++++++----------------- code/controllers/subsystem/mapping.dm | 12 + code/controllers/subsystem/ticker.dm | 317 +++++++++++----------- code/game/area/dynamic_areas.dm | 44 --- code/game/world.dm | 6 +- code/modules/economy/Economy.dm | 100 ------- code/modules/economy/Economy_Events.dm | 50 +++- code/modules/spacepods/spacepod.dm | 10 - paradise.dme | 2 - 10 files changed, 335 insertions(+), 563 deletions(-) delete mode 100644 code/game/area/dynamic_areas.dm delete mode 100644 code/modules/economy/Economy.dm diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 34ca716cfb1..3a19bc34edf 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -6,6 +6,7 @@ ### AffectedArc07 # Actual Code /code/controllers/subsystem/mapping.dm @AffectedArc07 +/code/controllers/subsystem/ticker.dm @AffectedArc07 /tgui/ @AffectedArc07 # CI + Tooling diff --git a/_maps/map_files/cyberiad/z2.dmm b/_maps/map_files/cyberiad/z2.dmm index 67b16b42f04..df9c4bfa81c 100644 --- a/_maps/map_files/cyberiad/z2.dmm +++ b/_maps/map_files/cyberiad/z2.dmm @@ -2685,13 +2685,6 @@ }, /turf/simulated/floor/plating/airless, /area/syndicate_mothership) -"hH" = ( -/obj/machinery/vending/sovietsoda, -/obj/machinery/light/small{ - dir = 1 - }, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_russian) "hI" = ( /turf/unsimulated/floor/snow, /turf/unsimulated/floor/snow{ @@ -2700,11 +2693,6 @@ dir = 1 }, /area/syndicate_mothership) -"hJ" = ( -/obj/structure/table/wood, -/obj/item/gun/projectile/revolver/russian, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_russian) "hK" = ( /turf/unsimulated/floor/snow, /turf/unsimulated/floor/snow{ @@ -2713,13 +2701,6 @@ dir = 5 }, /area/syndicate_mothership) -"hL" = ( -/obj/machinery/vending/cigarette, -/obj/machinery/light/small{ - dir = 1 - }, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_russian) "hM" = ( /turf/unsimulated/wall/fakeglass{ dir = 8; @@ -2750,39 +2731,6 @@ dir = 2 }, /area/syndicate_mothership) -"hR" = ( -/obj/structure/reagent_dispensers/beerkeg, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_bar) -"hS" = ( -/obj/structure/table/wood, -/obj/machinery/chem_dispenser/beer, -/obj/machinery/light/small{ - dir = 1 - }, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_bar) -"hT" = ( -/obj/structure/table/wood, -/obj/machinery/chem_dispenser/soda, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_bar) -"hU" = ( -/obj/structure/table/wood, -/obj/item/storage/box/drinkingglasses, -/obj/machinery/light/small{ - dir = 1 - }, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_bar) -"hV" = ( -/obj/structure/table/wood, -/obj/item/reagent_containers/food/drinks/shaker, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_bar) -"hW" = ( -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_russian) "hX" = ( /obj/item/storage/fancy/crayons, /obj/machinery/light{ @@ -2796,27 +2744,6 @@ dir = 2 }, /area/syndicate_mothership) -"hY" = ( -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_disco) -"hZ" = ( -/turf/simulated/floor/light, -/area/dynamic/source/lobby_disco) -"ia" = ( -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_bar) -"ib" = ( -/obj/structure/table/wood, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_russian) -"ic" = ( -/obj/machinery/light/small, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_russian) -"id" = ( -/obj/machinery/light/small, -/turf/simulated/floor/light, -/area/dynamic/source/lobby_disco) "ie" = ( /obj/machinery/washing_machine, /turf/unsimulated/floor{ @@ -2824,17 +2751,6 @@ dir = 2 }, /area/syndicate_mothership) -"if" = ( -/obj/structure/table/wood, -/obj/machinery/light/small, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_bar) -"ig" = ( -/obj/structure/table/wood, -/obj/item/book/manual/barman_recipes, -/obj/machinery/light/small, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_bar) "ih" = ( /turf/unsimulated/wall, /area/wizard_station) @@ -12216,50 +12132,6 @@ icon_state = "blue" }, /area/holodeck/source_knightarena) -"Kc" = ( -/obj/structure/chair/comfy/brown{ - dir = 4 - }, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_russian) -"Kd" = ( -/obj/structure/chair/comfy/brown{ - dir = 8 - }, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_russian) -"Ke" = ( -/obj/structure/chair/sofa/right, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_disco) -"Kf" = ( -/obj/machinery/light/small{ - dir = 1 - }, -/obj/structure/chair/sofa/left, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_disco) -"Kg" = ( -/obj/machinery/light/small{ - dir = 1 - }, -/obj/structure/chair/sofa/right, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_disco) -"Kh" = ( -/obj/structure/chair/sofa/left, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_disco) -"Ki" = ( -/obj/structure/chair/comfy/brown{ - dir = 1 - }, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_russian) -"Kk" = ( -/obj/structure/chair/stool, -/turf/simulated/floor/wood, -/area/dynamic/source/lobby_bar) "Kq" = ( /obj/structure/chair/comfy/red, /obj/effect/landmark{ @@ -73746,12 +73618,12 @@ an an eW aN -bZ -ak -ak -ak -ak -bZ +aN +aN +aN +aN +aN +aN aN aN bZ @@ -74003,12 +73875,12 @@ Zv Yp cc aN -af -hH -hW -hW -ib -cc +aN +aN +aN +aN +aN +aN aN aN bZ @@ -74260,12 +74132,12 @@ Zv Yp cc aN -af -Kc -hW -hW -ic -cc +aN +aN +aN +aN +aN +aN aN aN bZ @@ -74517,12 +74389,12 @@ Zv Yp cc aN -af -hJ -Ki -hW -hW -cc +aN +aN +aN +aN +aN +aN aN aN bZ @@ -74774,12 +74646,12 @@ Zv Yp cc aN -af -Kd -hW -hW -ic -cc +aN +aN +aN +aN +aN +aN aN aN bZ @@ -75031,12 +74903,12 @@ Zv Yp cc aN -af -hL -hW -hW -ib -cc +aN +aN +aN +aN +aN +aN aN aN bZ @@ -75288,12 +75160,12 @@ an an eW aN -bZ -an -an -an -an -bZ +aN +aN +aN +aN +aN +aN aN aN bZ @@ -75545,12 +75417,12 @@ TX FF cc aN -af -Ke -hY -hY -hY -cc +aN +aN +aN +aN +aN +aN aN bZ bZ @@ -75802,12 +75674,12 @@ eN IK cc aN -af -Kf -hZ -hZ -id -cc +aN +aN +aN +aN +aN +aN aN bZ dF @@ -76059,12 +75931,12 @@ eN IK cc aN -af -hY -hZ -hZ -hZ -cc +aN +aN +aN +aN +aN +aN aN bZ dF @@ -76316,12 +76188,12 @@ eN IK cc aN -af -Kg -hZ -hZ -id -cc +aN +aN +aN +aN +aN +aN aN bZ dF @@ -76573,12 +76445,12 @@ fT Uy cc aN -af -Kh -hY -hY -hY -cc +aN +aN +aN +aN +aN +aN aN bZ dF @@ -76830,12 +76702,12 @@ an an eW aN -bZ -an -an -an -an -bZ +aN +aN +aN +aN +aN +aN aN bZ dF @@ -77087,12 +76959,12 @@ CR zi cc aN -af -hR -ia -ia -Kk -cc +aN +aN +aN +aN +aN +aN aN bZ bZ @@ -77344,12 +77216,12 @@ eQ eH cc aN -af -hS -ia -ia -if -cc +aN +aN +aN +aN +aN +aN aN aN aN @@ -77601,12 +77473,12 @@ eQ eH cc aN -af -hT -ia -ia -ia -cc +aN +aN +aN +aN +aN +aN aN aN aN @@ -77858,12 +77730,12 @@ eQ eH cc aN -af -hU -ia -ia -ig -cc +aN +aN +aN +aN +aN +aN aN aN aN @@ -78115,12 +77987,12 @@ dO eM cc aN -af -hV -ia -ia -Kk -cc +aN +aN +aN +aN +aN +aN aN aN aN @@ -78372,12 +78244,12 @@ aE aE eX aN -bZ -aE -aE -aE -aE -bZ +aN +aN +aN +aN +aN +aN aN aN aN diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm index 163b2635d0e..533e3c6c024 100644 --- a/code/controllers/subsystem/mapping.dm +++ b/code/controllers/subsystem/mapping.dm @@ -63,6 +63,18 @@ SUBSYSTEM_DEF(mapping) GLOB.ghostteleportlocs = sortAssoc(GLOB.ghostteleportlocs) + // Map name. Break these down into SSmapping controller vars instaed of GLOBs at some point + if(GLOB.using_map && GLOB.using_map.name) + GLOB.map_name = "[GLOB.using_map.name]" + else + GLOB.map_name = "Unknown" + + // World name + if(config && config.server_name) + world.name = "[config.server_name]: [station_name()]" + else + world.name = station_name() + return ..() diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index 2df69094701..473b4a3625f 100644 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -7,32 +7,54 @@ SUBSYSTEM_DEF(ticker) runlevels = RUNLEVEL_LOBBY | RUNLEVEL_SETUP | RUNLEVEL_GAME offline_implications = "The game is no longer aware of when the round ends. Immediate server restart recommended." + /// Time the world started, relative to world.time var/round_start_time = 0 + /// Default timeout for if world.Reboot() doesnt have a time specified var/const/restart_timeout = 600 + /// Current status of the game. See code\__DEFINES\game.dm var/current_state = GAME_STATE_STARTUP - var/force_start = 0 // Do we want to force-start as soon as we can - var/force_ending = 0 - var/hide_mode = 0 // leave here at 0 ! setup() will take care of it when needed for Secret mode -walter0o + /// Do we want to force-start as soon as we can + var/force_start = FALSE + /// Do we want to force-end as soon as we can + var/force_ending = FALSE + /// Leave here at FALSE ! setup() will take care of it when needed for Secret mode -walter0o + var/hide_mode = FALSE + /// Our current game mode var/datum/game_mode/mode = null - var/event_time = null - var/event = 0 - var/login_music // music played in pregame lobby - var/list/datum/mind/minds = list()//The people in the game. Used for objective tracking. - var/Bible_icon_state // icon_state the chaplain has chosen for his bible - var/Bible_item_state // item_state the chaplain has chosen for his bible - var/Bible_name // name of the bible + /// The current pick of lobby music played in the lobby + var/login_music + /// List of all minds in the game. Used for objective tracking + var/list/datum/mind/minds = list() + /// icon_state the chaplain has chosen for his bible + var/Bible_icon_state + /// item_state the chaplain has chosen for his bible + var/Bible_item_state + /// Name of the bible + var/Bible_name + /// Name of the bible deity var/Bible_deity_name - var/datum/cult_info/cultdat = null //here instead of cult for adminbus purposes - var/random_players = 0 // if set to nonzero, ALL players who latejoin or declare-ready join will have random appearances/genders - var/tipped = FALSE //Did we broadcast the tip of the day yet? - var/selected_tip // What will be the tip of the day? - var/pregame_timeleft // This is used for calculations - var/delay_end = 0 //if set to nonzero, the round will not restart on it's own - var/triai = 0//Global holder for Triumvirate - var/next_autotransfer = 0 //holder for inital autotransfer vote timer - var/obj/screen/cinematic = null //used for station explosion cinematic - var/round_end_announced = 0 // Spam Prevention. Announce round end only once. - var/ticker_going = TRUE // This used to be in the unused globals, but it turns out its actually used in a load of places. Its now a ticker var because its related to round stuff, -aa + /// Cult data. Here instead of cult for adminbus purposes + var/datum/cult_info/cultdat = null + /// If set to nonzero, ALL players who latejoin or declare-ready join will have random appearances/genders + var/random_players = FALSE + /// Did we broadcast the tip of the round yet? + var/tipped = FALSE + /// What will be the tip of the round? + var/selected_tip + /// This is used for calculations for the statpanel + var/pregame_timeleft + /// If set to TRUE, the round will not restart on it's own + var/delay_end = FALSE + /// Global holder for triple AI mode + var/triai = FALSE + /// Holder for inital autotransfer vote timer + var/next_autotransfer = 0 + /// Used for station explosion cinematic + var/obj/screen/cinematic = null + /// Spam Prevention. Announce round end only once. + var/round_end_announced = FALSE + /// Is the ticker currently processing? If FALSE, roundstart is delayed + var/ticker_going = TRUE /datum/controller/subsystem/ticker/Initialize() login_music = pick(\ @@ -41,17 +63,6 @@ SUBSYSTEM_DEF(ticker) 'sound/music/title1.ogg',\ 'sound/music/title2.ogg',\ 'sound/music/title3.ogg',) - // Map name - if(GLOB.using_map && GLOB.using_map.name) - GLOB.map_name = "[GLOB.using_map.name]" - else - GLOB.map_name = "Unknown" - - // World name - if(config && config.server_name) - world.name = "[config.server_name]: [station_name()]" - else - world.name = station_name() return ..() @@ -73,9 +84,9 @@ SUBSYSTEM_DEF(ticker) // This is so we dont have sleeps in controllers, because that is a bad, bad thing if(!delay_end) - pregame_timeleft = max(0,round_start_time - world.time) // Normal lobby countdown when roundstart was not delayed + pregame_timeleft = max(0, round_start_time - world.time) // Normal lobby countdown when roundstart was not delayed else - pregame_timeleft = max(0,pregame_timeleft - 20) // If roundstart was delayed, we should resume the countdown where it left off + pregame_timeleft = max(0, pregame_timeleft - 20) // If roundstart was delayed, we should resume the countdown where it left off if(pregame_timeleft <= 600 && !tipped) // 60 seconds send_tip_of_the_round() @@ -89,7 +100,7 @@ SUBSYSTEM_DEF(ticker) current_state = GAME_STATE_STARTUP Master.SetRunLevel(RUNLEVEL_LOBBY) if(GAME_STATE_PLAYING) - delay_end = 0 // reset this in case round start was delayed + delay_end = FALSE // reset this in case round start was delayed mode.process() mode.process_job_tasks() @@ -107,10 +118,9 @@ SUBSYSTEM_DEF(ticker) if(GAME_STATE_FINISHED) current_state = GAME_STATE_FINISHED Master.SetRunLevel(RUNLEVEL_POSTGAME) // This shouldnt process more than once, but you never know - auto_toggle_ooc(1) // Turn it on + auto_toggle_ooc(TRUE) // Turn it on - spawn(0) - declare_completion() + declare_completion() spawn(50) if(mode.station_was_nuked) @@ -120,43 +130,47 @@ SUBSYSTEM_DEF(ticker) /datum/controller/subsystem/ticker/proc/setup() cultdat = setupcult() - //Create and announce mode - if(GLOB.master_mode=="secret") - src.hide_mode = 1 + + // Create and announce mode + if(GLOB.master_mode == "secret") + hide_mode = TRUE + var/list/datum/game_mode/runnable_modes - if((GLOB.master_mode=="random") || (GLOB.master_mode=="secret")) + + if(GLOB.master_mode == "random" || GLOB.master_mode == "secret") runnable_modes = config.get_runnable_modes() - if(runnable_modes.len==0) + if(!length(runnable_modes)) to_chat(world, "Unable to choose playable game mode. Reverting to pre-game lobby.") force_start = FALSE current_state = GAME_STATE_PREGAME Master.SetRunLevel(RUNLEVEL_LOBBY) - return 0 + return FALSE if(GLOB.secret_force_mode != "secret") var/datum/game_mode/M = config.pick_mode(GLOB.secret_force_mode) if(M.can_start()) - src.mode = config.pick_mode(GLOB.secret_force_mode) + mode = config.pick_mode(GLOB.secret_force_mode) SSjobs.ResetOccupations() - if(!src.mode) - src.mode = pickweight(runnable_modes) - if(src.mode) - var/mtype = src.mode.type - src.mode = new mtype + if(!mode) + mode = pickweight(runnable_modes) + if(mode) + var/mtype = mode.type + mode = new mtype else - src.mode = config.pick_mode(GLOB.master_mode) - if(!src.mode.can_start()) + mode = config.pick_mode(GLOB.master_mode) + + if(!mode.can_start()) to_chat(world, "Unable to start [mode.name]. Not enough players, [mode.required_players] players needed. Reverting to pre-game lobby.") mode = null current_state = GAME_STATE_PREGAME force_start = FALSE SSjobs.ResetOccupations() Master.SetRunLevel(RUNLEVEL_LOBBY) - return 0 + return FALSE //Configure mode and assign player to special mode stuff - src.mode.pre_pre_setup() + mode.pre_pre_setup() var/can_continue - can_continue = src.mode.pre_setup()//Setup special modes + can_continue = mode.pre_setup() //Setup special modes SSjobs.DivideOccupations() //Distribute jobs if(!can_continue) qdel(mode) @@ -165,27 +179,45 @@ SUBSYSTEM_DEF(ticker) force_start = FALSE SSjobs.ResetOccupations() Master.SetRunLevel(RUNLEVEL_LOBBY) - return 0 + return FALSE if(hide_mode) var/list/modes = new for(var/datum/game_mode/M in runnable_modes) - modes+=M.name + modes += M.name modes = sortList(modes) to_chat(world, "The current game mode is - Secret!") to_chat(world, "Possibilities: [english_list(modes)]") else - src.mode.announce() + mode.announce() - create_characters() //Create player characters and transfer them - populate_spawn_points() - collect_minds() - equip_characters() - GLOB.data_core.manifest() + // Behold, a rough way of figuring out what takes 10 years + var/watch = start_watch() + create_characters() // Create player characters and transfer clients + log_debug("Creating characters took [stop_watch(watch)]s") + + watch = start_watch() + populate_spawn_points() // Put mobs in their spawn locations + log_debug("Populating spawn points took [stop_watch(watch)]s") + + // Gather everyones minds + for(var/mob/living/player in GLOB.player_list) + if(player.mind) + minds += player.mind + + watch = start_watch() + equip_characters() // Apply outfits and loadouts to the characters + log_debug("Equipping characters took [stop_watch(watch)]s") + + watch = start_watch() + GLOB.data_core.manifest() // Create the manifest + log_debug("Manifest creation took [stop_watch(watch)]s") + + // Update the MC and state to game playing current_state = GAME_STATE_PLAYING Master.SetRunLevel(RUNLEVEL_GAME) - // Generate the list of playable AI cores in the world + // Generate the list of empty playable AI cores in the world for(var/obj/effect/landmark/start/S in GLOB.landmarks_list) if(S.name != "AI") continue @@ -194,93 +226,34 @@ SUBSYSTEM_DEF(ticker) GLOB.empty_playable_ai_cores += new /obj/structure/AIcore/deactivated(get_turf(S)) - //here to initialize the random events nicely at round start - setup_economy() + // Setup pregenerated newsfeeds + setup_news_feeds() - //shuttle_controller.setup_shuttle_docks() + // Generate code phrases and responses + if(!GLOB.syndicate_code_phrase) + GLOB.syndicate_code_phrase = generate_code_phrase() + if(!GLOB.syndicate_code_response) + GLOB.syndicate_code_response = generate_code_phrase() - spawn(0)//Forking here so we dont have to wait for this to finish - if(!GLOB.syndicate_code_phrase) - GLOB.syndicate_code_phrase = generate_code_phrase() - if(!GLOB.syndicate_code_response) - GLOB.syndicate_code_response = generate_code_phrase() - mode.post_setup() - //Cleanup some stuff - for(var/obj/effect/landmark/start/S in GLOB.landmarks_list) - //Deleting Startpoints but we need the ai point to AI-ize people later - if(S.name != "AI") - qdel(S) + // Run post setup stuff + mode.post_setup() - // take care of random spesspod spawning - var/list/obj/effect/landmark/spacepod/random/L = list() - for(var/obj/effect/landmark/spacepod/random/SS in GLOB.landmarks_list) - if(istype(SS)) - L += SS - if(L.len) - var/obj/effect/landmark/spacepod/random/S = pick(L) - new /obj/spacepod/random(S.loc) - for(var/obj/effect/landmark/spacepod/random/R in L) - qdel(R) + // Delete starting landmarks (not AI ones because we need those for AI-ize) + for(var/obj/effect/landmark/start/S in GLOB.landmarks_list) + if(S.name != "AI") + qdel(S) - to_chat(world, "Enjoy the game!") - world << sound('sound/AI/welcome.ogg')// Skie - - if(SSholiday.holidays) - to_chat(world, "and...") - for(var/holidayname in SSholiday.holidays) - var/datum/holiday/holiday = SSholiday.holidays[holidayname] - to_chat(world, "