mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 12:41:09 +01:00
Removes 509 support.
This commit is contained in:
@@ -368,10 +368,7 @@ var/global/list/ghost_others_options = list(GHOST_OTHERS_SIMPLE, GHOST_OTHERS_DE
|
||||
/////////////////////////////////////
|
||||
//this was added midway thru 510, so it might not exist in some versions, but we can't check by minor verison
|
||||
#ifndef TILE_BOUND
|
||||
#if DM_VERSION >= 510
|
||||
#warn this version of 510 is too old, You should use byond 510.1332 or later when using 510.
|
||||
#endif
|
||||
#define TILE_BOUND 256
|
||||
#error this version of 510 is too old, You must use byond 510.1332 or later. (TILE_BOUND is not defined)
|
||||
#endif
|
||||
|
||||
// Disabling certain features
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
#define TICK_LIMIT_TO_RUN 85
|
||||
#define TICK_LIMIT_MC 80
|
||||
|
||||
#if DM_VERSION >= 510
|
||||
#define TICK_CHECK ( world.tick_usage > TICK_LIMIT_RUNNING ? stoplag() : 0 )
|
||||
#define CHECK_TICK if (world.tick_usage > TICK_LIMIT_RUNNING) stoplag()
|
||||
#define MC_TICK_CHECK ( world.tick_usage > TICK_LIMIT_RUNNING ? pause() : 0 )
|
||||
#else
|
||||
#define TICK_CHECK ( 0 )
|
||||
#define CHECK_TICK
|
||||
#define MC_TICK_CHECK ( 0 )
|
||||
#endif
|
||||
#define MC_TICK_CHECK ( world.tick_usage > TICK_LIMIT_RUNNING ? pause() : 0 )
|
||||
@@ -1,455 +0,0 @@
|
||||
// Helpers for running 510 code on older versions of BYOND.
|
||||
// list of places with #if DM_VERSION defines for when we remove 509 support:
|
||||
// master controller and subsystems.dm
|
||||
// map loader (reader.dm)
|
||||
// defines/tick.dm
|
||||
// defines/misc.dm
|
||||
// unsorted.dm (bottom, in stoplag())
|
||||
// gas_mixture.dm (parse_gas_string())
|
||||
#if DM_VERSION < 510
|
||||
|
||||
#define BYGEX "code/__HELPERS/bygex"
|
||||
/proc/replacetext(text, replace, replacement)
|
||||
if(istype(replace, /regex))
|
||||
var/regex/R = replace
|
||||
return R.Replace(text, replacement)
|
||||
else
|
||||
return call(BYGEX, "regex_replaceallliteral")(text, replace, replacement)
|
||||
|
||||
/proc/replacetextEx(text, replace, replacement)
|
||||
return call(BYGEX, "regEx_replaceallliteral")(text, replace, replacement)
|
||||
|
||||
/proc/regex(pattern, flags)
|
||||
return new /regex(pattern, flags)
|
||||
|
||||
/regex
|
||||
var/pattern
|
||||
var/list/flags
|
||||
var/list/group
|
||||
|
||||
/regex/New(pattern, flags)
|
||||
src.pattern = pattern
|
||||
src.flags = splittext(flags, "")
|
||||
group = list()
|
||||
|
||||
/regex/proc/Find(text) // Does not support Start/End.
|
||||
var/method
|
||||
if("i" in flags)
|
||||
method = "regex_find"
|
||||
else
|
||||
method = "regEx_find"
|
||||
|
||||
var/results = call(BYGEX, method)(text, pattern)
|
||||
var/list/L = params2list(results)
|
||||
var/list/M
|
||||
var/i
|
||||
var/j
|
||||
|
||||
for(i in L)
|
||||
M = L[i]
|
||||
for(j = 2, j <= M.len, j += 2)
|
||||
var/pos = text2num(M[j-1])
|
||||
var/len = text2num(M[j])
|
||||
group += copytext(text, pos, pos + len)
|
||||
|
||||
/regex/proc/Replace(text, replacement)
|
||||
var/method
|
||||
if("g" in flags)
|
||||
if("i" in flags)
|
||||
method = "regex_replaceall"
|
||||
else
|
||||
method = "regEx_replaceall"
|
||||
else
|
||||
if("i" in flags)
|
||||
method = "regex_replace"
|
||||
else
|
||||
method = "regEx_replace"
|
||||
return call(BYGEX, method)(text, pattern, replacement)
|
||||
#undef BYGEX
|
||||
|
||||
// Formerly list2text
|
||||
/proc/jointext(list/ls, sep)
|
||||
if(ls.len <= 1) // Early-out code for empty or singleton lists.
|
||||
return ls.len ? ls[1] : ""
|
||||
|
||||
var/l = ls.len // Made local for sanic speed.
|
||||
var/i = 0 // Incremented every time a list index is accessed.
|
||||
|
||||
if(sep != null)
|
||||
// Macros expand to long argument lists like so: sep, ls[++i], sep, ls[++i], sep, ls[++i], etc...
|
||||
#define S1 sep, ls[++i]
|
||||
#define S4 S1, S1, S1, S1
|
||||
#define S16 S4, S4, S4, S4
|
||||
#define S64 S16, S16, S16, S16
|
||||
|
||||
. = "[ls[++i]]" // Make sure the initial element is converted to text.
|
||||
|
||||
// Having the small concatenations come before the large ones boosted speed by an average of at least 5%.
|
||||
if(l-1 & 0x01) // 'i' will always be 1 here.
|
||||
. = text("[][][]", ., S1) // Append 1 element if the remaining elements are not a multiple of 2.
|
||||
if(l-i & 0x02)
|
||||
. = text("[][][][][]", ., S1, S1) // Append 2 elements if the remaining elements are not a multiple of 4.
|
||||
if(l-i & 0x04)
|
||||
. = text("[][][][][][][][][]", ., S4) // And so on....
|
||||
if(l-i & 0x08)
|
||||
. = text("[][][][][][][][][][][][][][][][][]", ., S4, S4)
|
||||
if(l-i & 0x10)
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16)
|
||||
if(l-i & 0x20)
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16, S16)
|
||||
if(l-i & 0x40)
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64)
|
||||
while(l > i) // Chomp through the rest of the list, 128 elements at a time.
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64, S64)
|
||||
|
||||
#undef S64
|
||||
#undef S16
|
||||
#undef S4
|
||||
#undef S1
|
||||
|
||||
else
|
||||
// Macros expand to long argument lists like so: ls[++i], ls[++i], ls[++i], etc...
|
||||
#define S1 ls[++i]
|
||||
#define S4 S1, S1, S1, S1
|
||||
#define S16 S4, S4, S4, S4
|
||||
#define S64 S16, S16, S16, S16
|
||||
|
||||
. = "[ls[++i]]" // Make sure the initial element is converted to text.
|
||||
|
||||
if(l-1 & 0x01) // 'i' will always be 1 here.
|
||||
. += "[S1]" // Append 1 element if the remaining elements are not a multiple of 2.
|
||||
if(l-i & 0x02)
|
||||
. = text("[][][]", ., S1, S1) // Append 2 elements if the remaining elements are not a multiple of 4.
|
||||
if(l-i & 0x04)
|
||||
. = text("[][][][][]", ., S4) // And so on...
|
||||
if(l-i & 0x08)
|
||||
. = text("[][][][][][][][][]", ., S4, S4)
|
||||
if(l-i & 0x10)
|
||||
. = text("[][][][][][][][][][][][][][][][][]", ., S16)
|
||||
if(l-i & 0x20)
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16, S16)
|
||||
if(l-i & 0x40)
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64)
|
||||
while(l > i) // Chomp through the rest of the list, 128 elements at a time.
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64, S64)
|
||||
|
||||
#undef S64
|
||||
#undef S16
|
||||
#undef S4
|
||||
#undef S1
|
||||
|
||||
// Formerly text2list
|
||||
/proc/splittext(text, delim = "\n")
|
||||
var/delim_len = length(delim)
|
||||
. = list()
|
||||
var/last_found = 1
|
||||
var/found = 1
|
||||
if(delim_len < 1)
|
||||
var/text_len = length(text)
|
||||
while(found++ <= text_len)
|
||||
. += copytext(text,found-1, found)
|
||||
else
|
||||
do
|
||||
found = findtext(text, delim, last_found, 0)
|
||||
. += copytext(text, last_found, found)
|
||||
last_found = found + delim_len
|
||||
while(found)
|
||||
|
||||
/proc/json_encode(value)
|
||||
return JSON.stringify(value)
|
||||
|
||||
/proc/json_decode(value)
|
||||
return JSON.parse(value)
|
||||
|
||||
//JSON PROCS
|
||||
|
||||
/var/datum/jsonHelper/JSON = new // A namespace for procs.
|
||||
|
||||
// ************************************ WRITER ************************************
|
||||
/datum/jsonHelper/proc/stringify(value)
|
||||
return jointext(WriteValue(list(), value))
|
||||
|
||||
/datum/jsonHelper/proc/WriteValue(list/json, value)
|
||||
. = json
|
||||
if(isnum(value))
|
||||
json += value // Consider num2text(value, 20) for maximum accuracy.
|
||||
else if(isnull(value))
|
||||
json += "null"
|
||||
else if(istext(value))
|
||||
WriteString(json, value)
|
||||
else if(istype(value, /list))
|
||||
WriteList(json, value)
|
||||
else
|
||||
throw EXCEPTION("Datums cannot be converted to JSON.")
|
||||
|
||||
/datum/jsonHelper/proc/WriteString(list/json, str)
|
||||
. = json
|
||||
var/quotePos = findtextEx(str, "\"")
|
||||
var/bsPos = findtextEx(str, "\\")
|
||||
if (quotePos == 0 && bsPos == 0)
|
||||
json.Add("\"", str, "\"")
|
||||
else
|
||||
json += "\""
|
||||
var/lastStop = 1
|
||||
while(quotePos != 0 || bsPos != 0)
|
||||
var/escPos
|
||||
if(quotePos < bsPos && quotePos != 0 || bsPos == 0)
|
||||
escPos = quotePos
|
||||
else
|
||||
escPos = bsPos
|
||||
json.Add(copytext(str, lastStop, escPos), "\\")
|
||||
lastStop = escPos
|
||||
if(escPos == quotePos)
|
||||
quotePos = findtextEx(str, "\"", escPos + 1)
|
||||
else if(escPos == bsPos)
|
||||
bsPos = findtextEx(str, "\\", escPos + 1)
|
||||
json.Add(copytext(str, lastStop), "\"")
|
||||
|
||||
/datum/jsonHelper/proc/WriteList(list/json, list/listVal)
|
||||
. = json
|
||||
#define Either 0
|
||||
#define CannotBeArray 1
|
||||
#define CannotBeObject 2
|
||||
#define BadList (CannotBeArray | CannotBeObject)
|
||||
var/listType = Either
|
||||
for(var/key in listVal)
|
||||
if(istext(key))
|
||||
if(!isnull(listVal[key]))
|
||||
listType |= CannotBeArray
|
||||
else
|
||||
if(!isnum(key) && !isnull(listVal[key]))
|
||||
listType = BadList
|
||||
else
|
||||
listType |= CannotBeObject
|
||||
|
||||
if(listType == BadList)
|
||||
throw EXCEPTION("The given list cannot be converted to JSON.")
|
||||
|
||||
if(listType == CannotBeArray)
|
||||
json += "{"
|
||||
var/addComma
|
||||
for(var/key in listVal)
|
||||
if(addComma)
|
||||
json += ","
|
||||
else
|
||||
addComma = TRUE
|
||||
WriteString(json, key)
|
||||
json += ":"
|
||||
WriteValue(json, listVal[key])
|
||||
json += "}"
|
||||
else
|
||||
json += "\["
|
||||
var/addComma
|
||||
for(var/key in listVal)
|
||||
if(addComma)
|
||||
json += ","
|
||||
else
|
||||
addComma = TRUE
|
||||
WriteValue(json, key)
|
||||
json += "]"
|
||||
#undef Either
|
||||
#undef CannotBeFlat
|
||||
#undef CannotBeAssoc
|
||||
#undef BadList
|
||||
// ************************************ READER ************************************
|
||||
#define aBackspace 0x08
|
||||
#define aTab 0x09
|
||||
#define aLineBreak 0x0A
|
||||
#define aVertTab 0x0B
|
||||
#define aFormFeed 0x0C
|
||||
#define aCarriageReturn 0x0D
|
||||
#define aSpace 0x20
|
||||
#define aZero 0x30
|
||||
#define aNonBreakSpace 0xA0
|
||||
#define Advance if(++readPos > jsonLen) { curAscii = 0; curChar = "" } else { curAscii = text2ascii(json, readPos); curChar = ascii2text(curAscii) } // Deal with it.
|
||||
#define SkipWhitespace while(curAscii in whitespace) Advance
|
||||
#define AdvanceWS Advance; SkipWhitespace
|
||||
/datum/jsonHelper/var
|
||||
readPos
|
||||
jsonLen
|
||||
json
|
||||
curAscii
|
||||
curChar
|
||||
static/list/whitespace = list(aTab, aLineBreak, aVertTab, aFormFeed, aCarriageReturn, aSpace, aNonBreakSpace)
|
||||
/datum/jsonHelper/proc/parse(json)
|
||||
readPos = 0
|
||||
jsonLen = length(json)
|
||||
src.json = json
|
||||
curAscii = 0
|
||||
curChar = ""
|
||||
AdvanceWS
|
||||
var/value = ParseValue()
|
||||
if(readPos < jsonLen)
|
||||
throw EXCEPTION("Expected: End of JSON")
|
||||
return value
|
||||
/datum/jsonHelper/proc/ParseValue()
|
||||
if(curChar == "\"")
|
||||
return ParseString()
|
||||
else if(curChar == "-" || (curAscii >= aZero && curAscii <= aZero + 9))
|
||||
return ParseNumber()
|
||||
else if(curChar == "{")
|
||||
return ParseObject()
|
||||
else if(curChar == "\[")
|
||||
return ParseArray()
|
||||
else if(curChar == "t")
|
||||
if(copytext(json, readPos, readPos+4) == "true")
|
||||
readPos += 3
|
||||
AdvanceWS
|
||||
return TRUE
|
||||
else
|
||||
throw EXCEPTION("Expected: 'true'")
|
||||
else if(curChar == "f")
|
||||
if(copytext(json, readPos, readPos+5) == "false")
|
||||
readPos += 4
|
||||
AdvanceWS
|
||||
return FALSE
|
||||
else
|
||||
throw EXCEPTION("Expected: 'false'")
|
||||
else if(curChar == "n")
|
||||
if(copytext(json, readPos, readPos+4) == "null")
|
||||
readPos += 3
|
||||
AdvanceWS
|
||||
return null
|
||||
else
|
||||
throw EXCEPTION("Expected: 'null'")
|
||||
else if(curChar == "")
|
||||
throw EXCEPTION("Unexpected: End of JSON")
|
||||
else
|
||||
throw EXCEPTION("Unexpected: '[curChar]'")
|
||||
|
||||
|
||||
|
||||
/datum/jsonHelper/proc/ParseString()
|
||||
ASSERT(curChar == "\"")
|
||||
Advance
|
||||
var/list/chars = list()
|
||||
while(readPos <= jsonLen)
|
||||
if(curChar == "\"")
|
||||
AdvanceWS
|
||||
return jointext(chars)
|
||||
else if(curChar == "\\")
|
||||
Advance
|
||||
switch(curChar)
|
||||
if("\"", "\\", "/")
|
||||
chars += ascii2text(curAscii)
|
||||
if("b")
|
||||
chars += ascii2text(aBackspace)
|
||||
if("f")
|
||||
chars += ascii2text(aFormFeed)
|
||||
if("n")
|
||||
chars += "\n"
|
||||
if("r")
|
||||
chars += ascii2text(aCarriageReturn) // Should we ignore these?
|
||||
if("t")
|
||||
chars += "\t"
|
||||
if("u")
|
||||
throw EXCEPTION("JSON \\uXXXX escape sequence not supported")
|
||||
else
|
||||
throw EXCEPTION("Invalid escape sequence")
|
||||
Advance
|
||||
else
|
||||
chars += ascii2text(curAscii)
|
||||
Advance
|
||||
throw EXCEPTION("Unterminated string")
|
||||
|
||||
/datum/jsonHelper/proc/ParseNumber()
|
||||
var/firstPos = readPos
|
||||
if(curChar == "-")
|
||||
Advance
|
||||
if(curAscii >= aZero + 1 && curAscii <= aZero + 9)
|
||||
do
|
||||
Advance
|
||||
while(curAscii >= aZero && curAscii <= aZero + 9)
|
||||
else if(curAscii == aZero)
|
||||
Advance
|
||||
else
|
||||
throw EXCEPTION("Expected: digit")
|
||||
|
||||
if(curChar == ".")
|
||||
Advance
|
||||
var/found = FALSE
|
||||
while(curAscii >= aZero && curAscii <= aZero + 9)
|
||||
found = TRUE
|
||||
Advance
|
||||
if(!found)
|
||||
throw EXCEPTION("Expected: digit")
|
||||
|
||||
if(curChar == "E" || curChar == "e")
|
||||
Advance
|
||||
var/found = FALSE
|
||||
if(curChar == "-")
|
||||
Advance
|
||||
else if(curChar == "+")
|
||||
Advance
|
||||
while(curAscii >= aZero && curAscii <= aZero + 9)
|
||||
found = TRUE
|
||||
Advance
|
||||
if(!found)
|
||||
throw EXCEPTION("Expected: digit")
|
||||
|
||||
SkipWhitespace
|
||||
return text2num(copytext(json, firstPos, readPos))
|
||||
|
||||
/datum/jsonHelper/proc/ParseObject()
|
||||
ASSERT(curChar == "{")
|
||||
var/list/object = list()
|
||||
AdvanceWS
|
||||
while(curChar == "\"")
|
||||
var/key = ParseString()
|
||||
if(curChar != ":")
|
||||
throw EXCEPTION("Expected: ':'")
|
||||
AdvanceWS
|
||||
object[key] = ParseValue()
|
||||
if(curChar == ",")
|
||||
AdvanceWS
|
||||
else
|
||||
break
|
||||
if(curChar != "}")
|
||||
throw EXCEPTION("Expected: string or '}'")
|
||||
AdvanceWS
|
||||
return object
|
||||
|
||||
/datum/jsonHelper/proc/ParseArray()
|
||||
ASSERT(curChar == "\[")
|
||||
var/list/array = list()
|
||||
AdvanceWS
|
||||
while(curChar != "]")
|
||||
array += list(ParseValue()) // Wrapped in a list in case ParseValue() returns a list.
|
||||
if(curChar == ",")
|
||||
AdvanceWS
|
||||
else
|
||||
break
|
||||
if(curChar != "]")
|
||||
throw EXCEPTION("Expected: ']'")
|
||||
AdvanceWS
|
||||
return array
|
||||
|
||||
#undef aBackspace
|
||||
#undef aTab
|
||||
#undef aLineBreak
|
||||
#undef aVertTab
|
||||
#undef aFormFeed
|
||||
#undef aCarriageReturn
|
||||
#undef aSpace
|
||||
#undef aZero
|
||||
#undef aNonBreakSpace
|
||||
|
||||
#undef Advance
|
||||
#undef SkipWhitespace
|
||||
#undef AdvanceWS
|
||||
#endif
|
||||
Binary file not shown.
@@ -1349,7 +1349,6 @@ proc/pick_closest_path(value)
|
||||
/proc/stoplag()
|
||||
. = 1
|
||||
sleep(world.tick_lag)
|
||||
#if DM_VERSION >= 510
|
||||
if (world.tick_usage > TICK_LIMIT_TO_RUN) //woke up, still not enough tick, sleep for more.
|
||||
. += 2
|
||||
sleep(world.tick_lag*2)
|
||||
@@ -1358,4 +1357,3 @@ proc/pick_closest_path(value)
|
||||
sleep(world.tick_lag*4)
|
||||
//you might be thinking of adding more steps to this, or making it use a loop and a counter var
|
||||
// not worth it.
|
||||
#endif
|
||||
|
||||
@@ -49,9 +49,12 @@
|
||||
#warn compiling in TESTING mode. testing() debug messages will be visible.
|
||||
#endif
|
||||
|
||||
#define MIN_COMPILER_VERSION 509
|
||||
#if DM_VERSION < MIN_COMPILER_VERSION //Update this whenever you need to take advantage of more recent byond features
|
||||
//Update this whenever you need to take advantage of more recent byond features
|
||||
#define MIN_COMPILER_VERSION 510
|
||||
#if DM_VERSION < MIN_COMPILER_VERSION
|
||||
//Don't forget to update this part
|
||||
#error Your version of BYOND is too out-of-date to compile this project. Go to byond.com/download and update.
|
||||
#error You need version 510 or higher
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -19,19 +19,14 @@ var/global/datum/controller/master/Master = new()
|
||||
var/iteration = 0
|
||||
// The cost (in deciseconds) of the MC loop.
|
||||
var/cost = 0
|
||||
#if DM_VERSION < 510
|
||||
// The old fps when we slow it down to prevent lag.
|
||||
var/old_fps
|
||||
#endif
|
||||
// A list of subsystems to process().
|
||||
var/list/subsystems = list()
|
||||
// The cost of running the subsystems (in deciseconds).
|
||||
var/subsystem_cost = 0
|
||||
// The type of the last subsystem to be process()'d.
|
||||
var/last_type_processed
|
||||
#if DM_VERSION >= 510
|
||||
|
||||
var/list/priority_queue = list() //any time we pause or skip a ss for tick reasons, we run it first next tick
|
||||
#endif
|
||||
|
||||
/datum/controller/master/New()
|
||||
// Highlander-style: there can only be one! Kill off the old and replace it with the new.
|
||||
@@ -149,37 +144,29 @@ var/global/datum/controller/master/Master = new()
|
||||
if (!subsystemstorun.len)
|
||||
subsystemstorun = subsystems.Copy()
|
||||
var/priorityrunning = 0 //so we know if there are priority queue items
|
||||
#if DM_VERSION >= 510
|
||||
//this is a queue for any SS skipped or paused for tick reasons, to be ran first next tick
|
||||
if (priority_queue.len)
|
||||
priorityrunning = priority_queue.len
|
||||
subsystemstorun = priority_queue | subsystemstorun
|
||||
#endif
|
||||
|
||||
var/ran_subsystems = 0
|
||||
while(subsystemstorun.len)
|
||||
var/datum/subsystem/SS = subsystemstorun[1]
|
||||
subsystemstorun.Cut(1, 2)
|
||||
#if DM_VERSION >= 510
|
||||
|
||||
if (world.tick_usage > TICK_LIMIT_MC)
|
||||
#else
|
||||
if(world.cpu >= 100)
|
||||
#endif
|
||||
break
|
||||
#if DM_VERSION >= 510
|
||||
if(priorityrunning)
|
||||
if(!priority_queue.len || !(SS in priority_queue))
|
||||
priorityrunning = 0 //end of priority queue items
|
||||
else
|
||||
priority_queue -= SS
|
||||
#endif
|
||||
if(SS.can_fire > 0)
|
||||
if(priorityrunning || ((SS.next_fire <= world.time) && (SS.last_fire + (SS.wait * 0.75) <= world.time)))
|
||||
#if DM_VERSION >= 510
|
||||
if(!priorityrunning && (world.tick_usage + SS.tick_usage > TICK_LIMIT_TO_RUN) && (SS.last_fire + (SS.wait*1.25) > world.time))
|
||||
if(!SS.dynamic_wait)
|
||||
priority_queue += SS
|
||||
continue
|
||||
#endif
|
||||
//we can't reset SS.paused after we fire, incase it pauses again, so we cache it and
|
||||
// send it to SS.fire()
|
||||
var/paused = SS.paused
|
||||
@@ -188,11 +175,9 @@ var/global/datum/controller/master/Master = new()
|
||||
timer = world.timeofday
|
||||
last_type_processed = SS.type
|
||||
SS.last_fire = world.time
|
||||
#if DM_VERSION >= 510
|
||||
var/tick_usage = world.tick_usage
|
||||
#endif
|
||||
SS.fire(paused) // Fire the subsystem
|
||||
#if DM_VERSION >= 510
|
||||
|
||||
if(priorityrunning)
|
||||
priorityrunning--
|
||||
var/newusage = max(world.tick_usage - tick_usage, 0)
|
||||
@@ -200,7 +185,6 @@ var/global/datum/controller/master/Master = new()
|
||||
SS.tick_usage = MC_AVERAGE_SLOW(SS.tick_usage,world.tick_usage - tick_usage)
|
||||
else
|
||||
SS.tick_usage = MC_AVERAGE_FAST(SS.tick_usage,world.tick_usage - tick_usage)
|
||||
#endif
|
||||
SS.cost = max(MC_AVERAGE(SS.cost, world.timeofday - timer), 0)
|
||||
if(SS.dynamic_wait) // Adjust wait depending on lag.
|
||||
var/oldwait = SS.wait
|
||||
@@ -220,9 +204,6 @@ var/global/datum/controller/master/Master = new()
|
||||
SS.next_fire += SS.wait
|
||||
if(!SS.paused)
|
||||
SS.times_fired++
|
||||
#if DM_VERSION < 510
|
||||
sleep(0)
|
||||
#endif
|
||||
|
||||
cost = max(MC_AVERAGE(cost, world.timeofday - start_time), 0)
|
||||
if(ran_subsystems)
|
||||
@@ -238,16 +219,6 @@ var/global/datum/controller/master/Master = new()
|
||||
// If we are loading the server too much, sleep a bit extra...
|
||||
if(world.cpu >= 75)
|
||||
extrasleep += (extrasleep + world.tick_lag) * ((world.cpu-50)/10)
|
||||
#if DM_VERSION < 510
|
||||
if(world.cpu >= 100)
|
||||
if(!old_fps)
|
||||
old_fps = world.fps
|
||||
//byond bug, if we go over 120 fps and world.fps is higher then 10, the bad things that happen are made worst.
|
||||
world.fps = 10
|
||||
else if(old_fps && world.cpu < 50)
|
||||
world.fps = old_fps
|
||||
old_fps = null
|
||||
#endif
|
||||
sleep(world.tick_lag*processing+extrasleep)
|
||||
|
||||
else
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
var/last_fire = 0 //last world.time we called fire()
|
||||
var/next_fire = 0 //scheduled world.time for next fire()
|
||||
var/cost = 0 //average time to execute
|
||||
#if DM_VERSION >= 510
|
||||
var/tick_usage = 0 //average tick usage
|
||||
#endif
|
||||
var/paused =0 //was this subsystem paused mid fire.
|
||||
var/times_fired = 0 //number of times we have called fire()
|
||||
|
||||
@@ -45,13 +43,11 @@
|
||||
set waitfor = 0 //this should not be depended upon, this is just to solve issues with sleeps messing up tick tracking
|
||||
can_fire = 0
|
||||
|
||||
#if DM_VERSION >= 510
|
||||
/datum/subsystem/proc/pause()
|
||||
. = 1
|
||||
if (!dynamic_wait)
|
||||
Master.priority_queue += src
|
||||
paused = 1
|
||||
#endif
|
||||
|
||||
//used to initialize the subsystem AFTER the map has loaded
|
||||
/datum/subsystem/proc/Initialize(start_timeofday, zlevel)
|
||||
@@ -73,11 +69,7 @@
|
||||
dwait = "DWait:[round(wait,0.1)]ds "
|
||||
|
||||
if(can_fire)
|
||||
#if DM_VERSION >= 510
|
||||
msg = "[round(cost,0.01)]ds|[round(tick_usage,1)]%\t[dwait][msg]"
|
||||
#else
|
||||
msg = "[round(cost,0.01)]ds\t[dwait][msg]"
|
||||
#endif
|
||||
else
|
||||
msg = "OFFLINE\t[msg]"
|
||||
|
||||
|
||||
@@ -94,20 +94,15 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
break
|
||||
|
||||
ycrd--
|
||||
#if DM_VERSION < 510
|
||||
sleep(-1)
|
||||
#else
|
||||
CHECK_TICK
|
||||
#endif
|
||||
|
||||
|
||||
//reached End Of File
|
||||
if(findtext(tfile,quote+"}",zpos,0)+2==tfile_len)
|
||||
break
|
||||
#if DM_VERSION < 510
|
||||
sleep(-1)
|
||||
#else
|
||||
|
||||
CHECK_TICK
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Fill a given tile with its area/turf/objects/mobs
|
||||
@@ -164,12 +159,8 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
//then fill the members_attributes list with the corresponding variables
|
||||
members_attributes.len++
|
||||
members_attributes[index++] = fields
|
||||
|
||||
#if DM_VERSION < 510
|
||||
sleep(-1)
|
||||
#else
|
||||
CHECK_TICK
|
||||
#endif
|
||||
|
||||
while(dpos != 0)
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include "code\__DEFINES\tgui.dm"
|
||||
#include "code\__DEFINES\tick.dm"
|
||||
#include "code\__DEFINES\wires.dm"
|
||||
#include "code\__HELPERS\510.dm"
|
||||
#include "code\__HELPERS\_logging.dm"
|
||||
#include "code\__HELPERS\_string_lists.dm"
|
||||
#include "code\__HELPERS\bandetect.dm"
|
||||
|
||||
Reference in New Issue
Block a user