Skip to content

Commit

Permalink
Merge pull request #277 from Very-Soft/cooldogstuff
Browse files Browse the repository at this point in the history
Tool
  • Loading branch information
Very-Soft authored May 7, 2024
2 parents a7c2d49 + ef87cf4 commit 33fc0a3
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 53 deletions.
1 change: 1 addition & 0 deletions code/__defines/_RS_defines.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define ADMIN_CUSTOM_MAP_LOAD_PATH "data/persistent/next_round_maps.json"
60 changes: 53 additions & 7 deletions code/controllers/subsystems/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,45 @@ SUBSYSTEM_DEF(mapping)
// VOREStation Edit Start: Enable This
/datum/controller/subsystem/mapping/proc/loadLateMaps()
var/list/deffo_load = using_map.lateload_z_levels
var/list/maybe_load = using_map.lateload_gateway
var/list/also_load = using_map.lateload_overmap
var/list/gateway_load = using_map.lateload_gateway //RS EDIT - renamed for readability
var/list/om_extra_load = using_map.lateload_overmap //RS EDIT - renamed for readability
var/list/redgate_load = using_map.lateload_redgate
var/loaded_redgate //RS ADD START - var for loading a map selected in the previous round
var/loaded_gateway //var for loading a map selected in the previous round
if(fexists(ADMIN_CUSTOM_MAP_LOAD_PATH))
var/file_contents
var/list/load_list
log_debug("ADMIN LOAD CUSTOM: Next_round_maps file located, attempting to load")

try //To load the file's contents
file_contents = file2text(ADMIN_CUSTOM_MAP_LOAD_PATH)
log_debug("ADMIN LOAD CUSTOM: File contents written.")
catch(var/exception/load_exception)
error("ADMIN LOAD CUSTOM: Failed to load file!")
error("ADMIN LOAD CUSTOM catch: [load_exception] on [load_exception.file]:[load_exception.line]")

if(file_contents)
try //To decode the file's contents
load_list = json_decode(file_contents)
log_debug("ADMIN LOAD CUSTOM: File contents decoded.")
catch(var/exception/decode_exception)
error("ADMIN LOAD CUSTOM: Failed to decode json! Contents to follow: [file_contents]")
error("ADMIN LOAD CUSTOM catch: [decode_exception] on [decode_exception.file]:[decode_exception.line]")

try //To remove the file
log_debug("ADMIN LOAD CUSTOM: Removing previous round's custom map load data file.")
fdel(ADMIN_CUSTOM_MAP_LOAD_PATH)
catch(var/exception/remove_exception)
error("ADMIN LOAD CUSTOM: Failed to remove file: [ADMIN_CUSTOM_MAP_LOAD_PATH]")
error("ADMIN LOAD CUSTOM catch: [remove_exception] on [remove_exception.file]:[remove_exception.line]")

if(islist(load_list)) //Let's apply the data!
log_debug("ADMIN LOAD CUSTOM: Loaded data from file.")
loaded_redgate = load_list["Redgate"]
loaded_gateway = load_list["Gateway"]
log_debug("ADMIN LOAD CUSTOM: The file should have been read, data is as follows: RG: [loaded_redgate] GW: [loaded_gateway]")

//RS ADD END

for(var/list/maplist in deffo_load)
if(!islist(maplist))
Expand All @@ -96,8 +132,13 @@ SUBSYSTEM_DEF(mapping)
MT.load_new_z(centered = FALSE)
CHECK_TICK

if(LAZYLEN(maybe_load))
var/picklist = pick(maybe_load)
if(LAZYLEN(gateway_load)) //RS EDIT START
var/picklist
if(loaded_gateway) //Do we have a selection from the previous round?
log_debug("ADMIN LOAD CUSTOM: Gateway selection from previous round detected, using loaded data instead of random selection.")
picklist = gateway_load[loaded_gateway] //Let's try to load it then!
if(!picklist) //If we don't, or it saved nothing, then let's do the default behavior!
picklist = gateway_load[pick(gateway_load)] //RS EDIT END

if(!picklist) //No lateload maps at all
return
Expand All @@ -118,8 +159,8 @@ SUBSYSTEM_DEF(mapping)
admin_notice("Gateway: [MT]", R_DEBUG)
MT.load_new_z(centered = FALSE)

if(LAZYLEN(also_load)) //Just copied from gateway picking, this is so we can have a kind of OM map version of the same concept.
var/picklist = pick(also_load)
if(LAZYLEN(om_extra_load)) //Just copied from gateway picking, this is so we can have a kind of OM map version of the same concept. //RS EDIT
var/picklist = pick(om_extra_load) //RS EDIT

if(!picklist) //No lateload maps at all
return
Expand All @@ -141,7 +182,12 @@ SUBSYSTEM_DEF(mapping)
MT.load_new_z(centered = FALSE)

if(LAZYLEN(redgate_load))
var/picklist = pick(redgate_load)
var/picklist //RS ADD START
if(loaded_redgate) //Do we have a selection from the previous round?
log_debug("ADMIN LOAD CUSTOM: Redgate selection from previous round detected, using loaded data instead of random selection.")
picklist = redgate_load[loaded_redgate] //Let's try to load it then!
if(!picklist) //If we don't, or it saved nothing, then let's do the default behavior!
picklist = redgate_load[pick(redgate_load)] //RS ADD END

if(!picklist) //No lateload maps at all
return
Expand Down
4 changes: 3 additions & 1 deletion code/controllers/subsystems/persistence.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ SUBSYSTEM_DEF(persistence)
var/list/obj/structure/sign/painting/painting_frames = list()
var/list/all_paintings = list()
var/list/unpicked_paintings = list()
var/list/stored_pets = list()
var/list/stored_pets = list() //RS ADD
var/redgate = null //RS ADD
var/gateway = null //RS ADD

/datum/controller/subsystem/persistence/Initialize()
. = ..()
Expand Down
79 changes: 79 additions & 0 deletions code/game/Rogue Star/special_persist.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//PLEASE NOTE, this system will only work correctly if the affected map lists are the same on every map load.
//If you load one map with one set of redgates, and another map with a different set, it won't matter what you saved
//you will just have told the system to load something that may or may not exist in the code at that time
//so keep the lists of anything we save here synced between all maps or it won't work right!

/datum/persistent/next_round_maps
name = "next round maps"

/datum/persistent/next_round_maps/SetFilename()
filename = ADMIN_CUSTOM_MAP_LOAD_PATH

/datum/persistent/next_round_maps/Shutdown()
var/list/to_save = list()

if(SSpersistence.redgate)
to_save["Redgate"] = SSpersistence.redgate //We're saving a string for the kind of thing, and a string for the specific selection as an associated list
if(SSpersistence.gateway) //Your map list needs to have the name you want saved as the index for the actual map names to be compatible
to_save["Gateway"] = SSpersistence.gateway
if(fexists(filename)) //Delete the file so we can save a new one
log_debug("Removing previous round's custom map load data.")
fdel(filename)
if(!to_save.len) //Nothing to save, let's just quit here
log_debug("No custom map load data detected, aborting Shutdown function.")
return

log_debug("Saving custom map load data.")
to_file(file(filename), json_encode(to_save)) //Save it as a json file!
if(fexists(filename)) //Did we do it?
log_debug("Saved custom map load data to [filename].") //Nice
else
log_debug("Tried to save custom map load data to [filename], but something went wrong!") //Don't ask me about this if it doesn't work I won't know why

/client/proc/pick_next_random_map()
set name = "Pick Next Random Map"
set category = "Fun" //:)

if(!check_rights(R_FUN)) return

var/list/kinds = list(
"Redgate",
"Gateway"
)

var/which = tgui_input_list(usr, "Which pool will you pick from?", "Pick", kinds)

switch(which)
if("Redgate")
if(SSpersistence.redgate)
which = tgui_alert(usr, "[SSpersistence.redgate] is already selected to be loaded for next round. What would you like to do?", "Redgate", list("Select","Clear","Nothing"))
switch(which)
if("Nothing")
return
if("Clear")
SSpersistence.redgate = null
log_and_message_admins("has cleared next round's Redgate selection. It will now be randomly selected.")
return
which = tgui_input_list(usr, "Which Redgate map will you pick?", "Pick Redgate Map", using_map.lateload_redgate)
if(!which)
return
SSpersistence.redgate = which
log_and_message_admins("set next round's Redgate to [SSpersistence.redgate].")

if("Gateway")
if(SSpersistence.gateway)
which = tgui_alert(usr, "[SSpersistence.gateway] is already selected to be loaded for next round. What would you like to do?", "Gateway", list("Select","Clear","Nothing"))
switch(which)
if("Nothing")
return
if("Clear")
SSpersistence.gateway = null
log_and_message_admins("has cleared next round's Gateway selection. It will now be randomly selected.")
return
which = tgui_input_list(usr, "Which Gateway map will you pick?", "Pick Gateway Map", using_map.lateload_gateway)
if(!which)
return
SSpersistence.gateway = which
log_and_message_admins("set next round's Gateway to [SSpersistence.gateway].")

feedback_add_details("admin_verb","RS-PNRM") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
3 changes: 2 additions & 1 deletion code/modules/admin/admin_verb_lists_vr.dm
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ var/list/admin_verbs_fun = list(
/client/proc/getPlayerStatus, //VORESTation Add
/client/proc/manage_event_triggers,
/client/proc/toggle_event_verb, //RS ADD
/client/proc/change_station_name //RS ADD
/client/proc/change_station_name, //RS ADD
/client/proc/pick_next_random_map //RS ADD

)

Expand Down
44 changes: 22 additions & 22 deletions maps/groundbase/groundbase_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -195,35 +195,35 @@
list("Fuel Depot - Z1 Space"),
list("Offmap Ship - Talon V2")
)

//List associations used in admin load selection feature
lateload_gateway = list(
list("Gateway - Carp Farm"),
list("Gateway - Snow Field"),
list("Gateway - Listening Post"),
list(list("Gateway - Honleth Highlands A", "Gateway - Honleth Highlands B")),
list("Gateway - Arynthi Lake Underground A","Gateway - Arynthi Lake A"),
list("Gateway - Arynthi Lake Underground B","Gateway - Arynthi Lake B"),
list("Gateway - Wild West")
"Carp Farm" = list("Gateway - Carp Farm"),
"Snow Field" = list("Gateway - Snow Field"),
"Listening Post" = list("Gateway - Listening Post"),
"Honleth Highlands" = list(list("Gateway - Honleth Highlands A", "Gateway - Honleth Highlands B")),
"Arynthi Lake A" = list("Gateway - Arynthi Lake Underground A","Gateway - Arynthi Lake A"),
"Arynthi Lake B" = list("Gateway - Arynthi Lake Underground B","Gateway - Arynthi Lake B"),
"Wild West" = list("Gateway - Wild West")
)

lateload_overmap = list(
list("Grass Cave")
)

//List associations used in admin load selection feature
lateload_redgate = list(
// list("Redgate - Teppi Ranch"),
// list("Redgate - Innland"),
// list("Redgate - Abandoned Island"), //This will come back later
// list("Redgate - Dark Adventure"),
// list("Redgate - Eggnog Town Underground","Redgate - Eggnog Town"),
// list("Redgate - Star Dog"),
// list("Redgate - Hotsprings"),
// list("Redgate - Rain City"),
// list("Redgate - Islands Underwater","Redgate - Islands"),
// list("Redgate - Moving Train", "Redgate - Moving Train Upper Level"),
list("Redgate - Fantasy Dungeon", "Redgate - Fantasy Town")
// list("Redgate - Snowglobe"),
// list("Redgate - Pet Island")
"Teppi Ranch" = list("Redgate - Teppi Ranch"),
"Innland" = list("Redgate - Innland"),
// "Abandoned Island" = list("Redgate - Abandoned Island"), //This will come back later
"Dark Adventure" = list("Redgate - Dark Adventure"),
"Eggnog Town" = list("Redgate - Eggnog Town Underground","Redgate - Eggnog Town"),
"Star Dog" = list("Redgate - Star Dog"),
"Hotsprings" = list("Redgate - Hotsprings"),
"Rain City" = list("Redgate - Rain City"),
"Islands" = list("Redgate - Islands Underwater","Redgate - Islands"),
"Moving Train" = list("Redgate - Moving Train", "Redgate - Moving Train Upper Level"),
"Fantasy Town" = list("Redgate - Fantasy Dungeon", "Redgate - Fantasy Town"),
"Snowglobe" = list("Redgate - Snowglobe"),
"Pet Island" = list("Redgate - Pet Island")
)

lateload_gb_north = list(
Expand Down
44 changes: 22 additions & 22 deletions maps/stellar_delight/stellar_delight_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -148,35 +148,35 @@
list("Overmap"),
list("Offmap Ship - Talon V2")
)

//List associations used in admin load selection feature
lateload_gateway = list(
list("Gateway - Carp Farm"),
list("Gateway - Snow Field"),
list("Gateway - Listening Post"),
list(list("Gateway - Honleth Highlands A", "Gateway - Honleth Highlands B")),
list("Gateway - Arynthi Lake Underground A","Gateway - Arynthi Lake A"),
list("Gateway - Arynthi Lake Underground B","Gateway - Arynthi Lake B"),
list("Gateway - Wild West")
"Carp Farm" = list("Gateway - Carp Farm"),
"Snow Field" = list("Gateway - Snow Field"),
"Listening Post" = list("Gateway - Listening Post"),
"Honleth Highlands" = list(list("Gateway - Honleth Highlands A", "Gateway - Honleth Highlands B")),
"Arynthi Lake A" = list("Gateway - Arynthi Lake Underground A","Gateway - Arynthi Lake A"),
"Arynthi Lake B" = list("Gateway - Arynthi Lake Underground B","Gateway - Arynthi Lake B"),
"Wild West" = list("Gateway - Wild West")
)

lateload_overmap = list(
list("Grass Cave")
)

//List associations used in admin load selection feature
lateload_redgate = list(
list("Redgate - Teppi Ranch"),
list("Redgate - Innland"),
// list("Redgate - Abandoned Island"), //This will come back later
list("Redgate - Dark Adventure"),
list("Redgate - Eggnog Town Underground","Redgate - Eggnog Town"),
list("Redgate - Star Dog"),
list("Redgate - Hotsprings"),
list("Redgate - Rain City"),
list("Redgate - Islands Underwater","Redgate - Islands"),
list("Redgate - Moving Train", "Redgate - Moving Train Upper Level"),
list("Redgate - Fantasy Dungeon", "Redgate - Fantasy Town"),
list("Redgate - Snowglobe"),
list("Redgate - Pet Island")
"Teppi Ranch" = list("Redgate - Teppi Ranch"),
"Innland" = list("Redgate - Innland"),
// "Abandoned Island" = list("Redgate - Abandoned Island"), //This will come back later
"Dark Adventure" = list("Redgate - Dark Adventure"),
"Eggnog Town" = list("Redgate - Eggnog Town Underground","Redgate - Eggnog Town"),
"Star Dog" = list("Redgate - Star Dog"),
"Hotsprings" = list("Redgate - Hotsprings"),
"Rain City" = list("Redgate - Rain City"),
"Islands" = list("Redgate - Islands Underwater","Redgate - Islands"),
"Moving Train" = list("Redgate - Moving Train", "Redgate - Moving Train Upper Level"),
"Fantasy Town" = list("Redgate - Fantasy Dungeon", "Redgate - Fantasy Town"),
"Snowglobe" = list("Redgate - Snowglobe"),
"Pet Island" = list("Redgate - Pet Island")
)

ai_shell_restricted = TRUE
Expand Down
2 changes: 2 additions & 0 deletions vorestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "code\__defines\_planes+layers.dm"
#include "code\__defines\_planes+layers_vr.dm"
#include "code\__defines\_protect.dm"
#include "code\__defines\_RS_defines.dm"
#include "code\__defines\_tick.dm"
#include "code\__defines\admin.dm"
#include "code\__defines\admin_vr.dm"
Expand Down Expand Up @@ -1622,6 +1623,7 @@
#include "code\game\objects\structures\stool_bed_chair_nest\stools_vr.dm"
#include "code\game\objects\structures\stool_bed_chair_nest\wheelchair.dm"
#include "code\game\objects\structures\stool_bed_chair_nest\wheelchair_item.dm"
#include "code\game\Rogue Star\special_persist.dm"
#include "code\game\turfs\simulated.dm"
#include "code\game\turfs\simulated_vr.dm"
#include "code\game\turfs\turf.dm"
Expand Down

0 comments on commit 33fc0a3

Please sign in to comment.