#define WORLD_ICON_SIZE 32
#define PIXEL_MULTIPLIER WORLD_ICON_SIZE/32
#define WORLD_MIN_SIZE 32
/*
The initialization of the game happens roughly like this:
1. All global variables are initialized (including the global_init instance).
2. The map is initialized, and map objects are created.
3. world/New() runs, creating & starting the master controller.
4. The master controller initializes the rest of the game.
*/
var/global/datum/global_init/init = new ()
/*
Pre-map initialization stuff should go here.
*/
/datum/global_init/New()
generate_gameid()
makeDatumRefLists()
load_configuration()
qdel(src) //we're done
init = null
/datum/global_init/Destroy()
..()
return 3 // QDEL_HINT_HARDDEL ain't defined here, so magic number it is.
/var/game_id = null
/proc/generate_gameid()
if(game_id != null)
return
game_id = ""
var/list/c = list("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0")
var/l = c.len
var/t = world.timeofday
for(var/_ = 1 to 4)
game_id = "[c[(t % l) + 1]][game_id]"
t = round(t / l)
game_id = "-[game_id]"
t = round(world.realtime / (10 * 60 * 60 * 24))
for(var/_ = 1 to 3)
game_id = "[c[(t % l) + 1]][game_id]"
t = round(t / l)
/world
mob = /mob/abstract/new_player
turf = /turf/space
area = /area/space
view = "15x15"
cache_lifespan = 0 //stops player uploaded stuff from being kept in the rsc past the current session
maxx = WORLD_MIN_SIZE // So that we don't get map-window-popin at boot. DMMS will expand this.
maxy = WORLD_MIN_SIZE
/world/proc/enable_debugger()
var/dll = world.GetConfig("env", "EXTOOLS_DLL")
if (dll)
call(dll, "debug_initialize")()
#define RECOMMENDED_VERSION 510
/world/New()
//logs
diary_date_string = time2text(world.realtime, "YYYY/MM/DD")
href_logfile = file("data/logs/[diary_date_string] hrefs.htm")
diary = "data/logs/[diary_date_string]_[game_id].log"
log_startup()
changelog_hash = md5('html/changelog.html') //used for telling if the changelog has changed recently
if(config.log_runtime)
diary_runtime = file("data/logs/_runtime/[diary_date_string]-runtime.log")
if(byond_version < RECOMMENDED_VERSION)
world.log << "Your server's byond version does not meet the recommended requirements for this server. Please update BYOND to [RECOMMENDED_VERSION]."
world.TgsNew()
config.post_load()
if(config && config.server_name != null && config.server_suffix && world.port > 0)
// dumb and hardcoded but I don't care~
config.server_name += " #[(world.port % 1000) / 100]"
callHook("startup")
enable_debugger()
. = ..()
#ifdef UNIT_TEST
log_unit_test("Unit Tests Enabled. This will destroy the world when testing is complete.")
load_unit_test_changes()
#endif
// Do not add initialization stuff to this file, unless it *must* run before the MC initializes!
// (hint: you generally won't need this)
// To do things on server-start, create a subsystem or shove it into one of the miscellaneous init subsystems.
Master.Initialize(10, FALSE)
#undef RECOMMENDED_VERSION
return
var/list/world_api_rate_limit = list()
/world/Topic(T, addr, master, key)
var/list/response[] = list()
var/list/queryparams[]
if (!SSfail2topic)
response["statuscode"] = 500
response["response"] = "Server not initialized."
return json_encode(response)
else if (SSfail2topic.IsRateLimited(addr))
response["statuscode"] = 429
response["response"] = "Rate limited."
return json_encode(response)
if (length(T) > 2000)
response["statuscode"] = 413
response["response"] = "Payload too large."
return json_encode(response)
try
queryparams = json_decode(T)
catch()
queryparams = list()
log_debug("API: Request Received - from:[addr], master:[master], key:[key]")
log_topic(T, addr, master, key, queryparams)
// TGS topic hook. Returns if successful, expects old-style serialization.
var/tgs_topic_return = TgsTopic(T)
if (tgs_topic_return)
log_debug("API - TGS3 Request.")
return tgs_topic_return
else if (!queryparams.len)
log_debug("API - Bad Request - Invalid/no JSON data sent.")
response["statuscode"] = 400
response["response"] = "Bad Request - Invalid/no JSON data sent."
return json_encode(response)
queryparams["addr"] = addr //Add the IP to the queryparams that are passed to the api functions
var/query = queryparams["query"]
var/auth = queryparams["auth"]
if (isnull(query))
log_debug("API - Bad Request - No query specified")
response["statuscode"] = 400
response["response"] = "Bad Request - No query specified"
return json_encode(response)
var/datum/topic_command/command = topic_commands[query]
//Check if that command exists
if (isnull(command))
log_debug("API: Unknown command called: [query]")
response["statuscode"] = 501
response["response"] = "Not Implemented"
return json_encode(response)
var/unauthed = command.check_auth(addr, auth)
if (unauthed)
if (unauthed == 3)
log_debug("API: Request denied - Auth Service Unavailable")
response["statuscode"] = 503
response["response"] = "Auth Service Unavailable"
return json_encode(response)
else if (unauthed == 2)
log_debug("API: Request denied - Throttled")
response["statuscode"] = 429
response["response"] = "Throttled"
return json_encode(response)
else
log_debug("API: Request denied - Bad Auth")
response["statuscode"] = 401
response["response"] = "Bad Auth"
return json_encode(response)
log_debug("API: Auth valid")
if(command.check_params_missing(queryparams))
log_debug("API: Mising Params - Status: [command.statuscode] - Response: [command.response]")
response["statuscode"] = command.statuscode
response["response"] = command.response
response["data"] = command.data
return json_encode(response)
else
command.run_command(queryparams)
log_debug("API: Command called: [query] - Status: [command.statuscode] - Response: [command.response]")
response["statuscode"] = command.statuscode
response["response"] = command.response
response["data"] = command.data
return json_encode(response)
/world/Reboot(reason, hard_reset = FALSE)
if (!hard_reset && world.TgsAvailable())
switch (config.rounds_until_hard_restart)
if (-1)
hard_reset = FALSE
if (0)
hard_reset = TRUE
else
if (SSpersist_config.rounds_since_hard_restart >= config.rounds_until_hard_restart)
hard_reset = TRUE
SSpersist_config.rounds_since_hard_restart = 0
else
hard_reset = FALSE
SSpersist_config.rounds_since_hard_restart++
else if (!world.TgsAvailable() && hard_reset)
hard_reset = FALSE
SSpersist_config.save_to_file("data/persistent_config.json")
Master.Shutdown()
to_chat_immediate(world, "
The server is restarting.
You should automatically reconnect in a minute or so...