mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-31 00:58:26 +01:00
Runtime Dynamic Station Loading (#24171)
* Dynamic map loading prototype * Get the title screen working * Fixes the random pod bugs * map configs * Add back the asteroid * Ignore the rotate file * Fix some shit * More shit fixes * Babby's first json * Cyberboss confirmed shitcoder * Makes map rotation great again * Moves the map defines * Delete tgstation2.dm * Convert runtimestation * Convert PubbyStation * Convert OmegaStation * Convert Metastation * Convert Delta Station * Lol file extensions * Reee line endings * Take out the trash * Fix loadallmaps.dm * Deltaassssssstation? * Fix travis * Did I ASK you to change the line endings? * Remove votable maps * Cleanup * Previous config. Load configs in New. Fix splash * Fix this * More generic minetype * STOP TOUCHING THE LINE ENDINGS!!! * Add some flexibility to /obj/screen/splash * Fix the shit * Update gitignore * Smooth transition from last map * Better check * Missed this map rotate check * Remove these checks too * Prep for a future request by @kevinz000 * Fix z2 line endings * Solution for custom .dms * Rename some things, trim some fat * Fixes default map_config * Remove stale comment * Delete the previous config after loading * Don't try to open a non-existent file * Delete the old rotator script * And references to it * Line endings * More line endings * Del checks from when m-config may have not existed * LINE ENDINGS * Update the default map config * Map load error checking for what it's worth * Small cleanup * For case sensitive * File systems * Strip maprotate stuff from build script * Spruce up the _maps tree. Compile some empty space * Make travis simpler * LINEARU ENDARU!!! * tgstation TWO!!! * Lowercase mine type * Dummy dm's for testmerging * Fixes job ordering * If ghosts wanna watch the map load so be it * Let them know what's going on * Fixes z-transitions * Optimize z expansion further * Remove this old var * Fix wiznerd teleportation * Rmove butt * Does the thing * Moved temp configs to the data dir * Un-touch gitignore * Forgot templates.dm * Forgot to include the includer * Fair enough * SILENCE IMBECILE! * @Cyberboss still a fuckboi * Speed things up a bit * Fix a potential bug with the error message * Whatever
This commit is contained in:
@@ -31,7 +31,6 @@ var/global/datum/getrev/revdata = new()
|
||||
log_world("Based off master commit [parentcommit]")
|
||||
else
|
||||
log_world(parentcommit)
|
||||
log_world("Current map - [MAP_NAME]") //can't think of anywhere better to put it
|
||||
|
||||
/datum/getrev/proc/DownloadPRDetails()
|
||||
if(!config.githubrepoid)
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
//used for holding information about unique properties of maps
|
||||
//feed it json files that match the datum layout
|
||||
//defaults to box
|
||||
// -Cyberboss
|
||||
|
||||
/datum/map_config
|
||||
var/config_filename = "_maps/tgstation2.json"
|
||||
var/map_name = "Box Station"
|
||||
var/map_path = "map_files/TgStation"
|
||||
var/map_file = "tgstation.2.1.3.dmm"
|
||||
|
||||
var/minetype = "lavaland"
|
||||
|
||||
var/list/transition_config = list(MAIN_STATION = CROSSLINKED,
|
||||
CENTCOMM = SELFLOOPING,
|
||||
EMPTY_AREA_1 = CROSSLINKED,
|
||||
EMPTY_AREA_2 = CROSSLINKED,
|
||||
MINING = SELFLOOPING,
|
||||
EMPTY_AREA_3 = CROSSLINKED,
|
||||
EMPTY_AREA_4 = CROSSLINKED,
|
||||
EMPTY_AREA_5 = CROSSLINKED,
|
||||
EMPTY_AREA_6 = CROSSLINKED,
|
||||
EMPTY_AREA_7 = CROSSLINKED,
|
||||
EMPTY_AREA_8 = CROSSLINKED)
|
||||
var/defaulted = TRUE //if New failed
|
||||
|
||||
var/config_max_users = 0
|
||||
var/config_min_users = 0
|
||||
var/voteweight = 1
|
||||
|
||||
/datum/map_config/New(filename = "data/next_map.json", default_to_box, delete_after)
|
||||
if(default_to_box)
|
||||
return
|
||||
LoadConfig(filename)
|
||||
if(delete_after)
|
||||
fdel(filename)
|
||||
|
||||
/datum/map_config/proc/LoadConfig(filename)
|
||||
if(!fexists(filename))
|
||||
log_world("map_config not found: [filename]")
|
||||
return
|
||||
|
||||
var/json = file(filename)
|
||||
if(!json)
|
||||
log_world("Could not open map_config: [filename]")
|
||||
return
|
||||
|
||||
json = file2text(json)
|
||||
if(!json)
|
||||
log_world("map_config is not text: [filename]")
|
||||
return
|
||||
|
||||
json = json_decode(json)
|
||||
if(!json)
|
||||
log_world("map_config is not json: [filename]")
|
||||
return
|
||||
|
||||
if(!ValidateJSON(json))
|
||||
log_world("map_config failed to validate for above reason: [filename]")
|
||||
return
|
||||
|
||||
config_filename = filename
|
||||
|
||||
map_name = json["map_name"]
|
||||
map_path = json["map_path"]
|
||||
map_file = json["map_file"]
|
||||
|
||||
minetype = json["minetype"]
|
||||
|
||||
var/list/jtcl = json["transition_config"]
|
||||
|
||||
if(jtcl != "default")
|
||||
transition_config.Cut()
|
||||
|
||||
for(var/I in jtcl)
|
||||
transition_config[TransitionStringToEnum(I)] = TransitionStringToEnum(jtcl[I])
|
||||
|
||||
defaulted = FALSE
|
||||
|
||||
#define CHECK_EXISTS(X) if(!istext(json[X])) log_world(X + "missing from json!")
|
||||
/datum/map_config/proc/ValidateJSON(list/json)
|
||||
CHECK_EXISTS("map_name")
|
||||
CHECK_EXISTS("map_path")
|
||||
CHECK_EXISTS("map_file")
|
||||
CHECK_EXISTS("minetype")
|
||||
CHECK_EXISTS("transition_config")
|
||||
|
||||
var/path = GetFullMapPath(json["map_path"], json["map_file"])
|
||||
if(!fexists(path))
|
||||
log_world("Map file ([path]) does not exist!")
|
||||
return
|
||||
|
||||
if(json["transition_config"] != "default")
|
||||
if(!islist(json["transition_config"]))
|
||||
log_world("transition_config is not a list!")
|
||||
return
|
||||
|
||||
var/list/jtcl = json["transition_config"]
|
||||
for(var/I in jtcl)
|
||||
if(isnull(TransitionStringToEnum(I)))
|
||||
log_world("Invalid transition_config option: [I]!")
|
||||
if(isnull(TransitionStringToEnum(jtcl[I])))
|
||||
log_world("Invalid transition_config option: [I]!")
|
||||
|
||||
return TRUE
|
||||
#undef CHECK_EXISTS
|
||||
|
||||
/datum/map_config/proc/TransitionStringToEnum(string)
|
||||
switch(string)
|
||||
if("CROSSLINKED")
|
||||
return CROSSLINKED
|
||||
if("SELFLOOPING")
|
||||
return SELFLOOPING
|
||||
if("UNAFFECTED")
|
||||
return UNAFFECTED
|
||||
if("MAIN_STATION")
|
||||
return MAIN_STATION
|
||||
if("CENTCOMM")
|
||||
return CENTCOMM
|
||||
if("MINING")
|
||||
return MINING
|
||||
if("EMPTY_AREA_1")
|
||||
return EMPTY_AREA_1
|
||||
if("EMPTY_AREA_2")
|
||||
return EMPTY_AREA_2
|
||||
if("EMPTY_AREA_3")
|
||||
return EMPTY_AREA_3
|
||||
if("EMPTY_AREA_4")
|
||||
return EMPTY_AREA_4
|
||||
if("EMPTY_AREA_5")
|
||||
return EMPTY_AREA_5
|
||||
if("EMPTY_AREA_6")
|
||||
return EMPTY_AREA_6
|
||||
if("EMPTY_AREA_7")
|
||||
return EMPTY_AREA_7
|
||||
if("EMPTY_AREA_8")
|
||||
return EMPTY_AREA_8
|
||||
|
||||
/datum/map_config/proc/GetFullMapPath(mp = map_path, mf = map_file)
|
||||
return "_maps/[mp]/[mf]"
|
||||
|
||||
/datum/map_config/proc/MakeNextMap()
|
||||
return config_filename == "data/next_map.json" || fcopy(config_filename, "data/next_map.json")
|
||||
|
||||
/datum/map_config/proc/MakePreviousMap()
|
||||
return config_filename == "data/previous_map.json" || fcopy(config_filename, "data/previous_map.json")
|
||||
@@ -1,10 +0,0 @@
|
||||
/datum/votablemap
|
||||
var/name = ""
|
||||
var/friendlyname = ""
|
||||
var/minusers = 0
|
||||
var/maxusers = 0
|
||||
var/voteweight = 1
|
||||
|
||||
/datum/votablemap/New(name)
|
||||
src.name = name
|
||||
src.friendlyname = name
|
||||
Reference in New Issue
Block a user