mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 00:29:02 +01:00
Rewrites to fix compiler errors on 516.1670+ (#93801)
## About The Pull Request Fixes all instances of numbers being used as assoc list keys in things that aren't alists, either by turning them into alists or changing the keys to something else. Also adds new macros to support creating global alists, as a few global lists became alists. Most of these are pretty simple and self-explanatory but - The GLOB.huds one necessitated rewriting because code depended on it being a non-assoc list, which it technically was because the defines it used as keys were numbers so BYOND turned it into a regular list, most of this was for loops through all the subtypes of `/datum/atom_hud/data/diagnostic` of which there's only one, so I just changed it to get that type directly by key - NT Frontier used number indexes which it looped through for some reason and also passed to TGUI, changed these to strings and adjusted the TGUI to match, I tested this and it works fine ## Why It's Good For The Game Makes the code compile, I couldn't test everything but I tried to check all usages of affected vars to make sure they wouldn't break from being switched to alists, a TM might be in order just to be sure nothing's fucked ## Changelog 🆑 refactor: rewrote all cases of numbers being used as keys in non-alist associative lists /🆑
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
* Or
|
||||
* - A single weight for all tiers.
|
||||
*/
|
||||
var/list/weight = 0
|
||||
var/alist/weight = 0
|
||||
/**
|
||||
* The min population for which this ruleset is available.
|
||||
*
|
||||
@@ -43,7 +43,7 @@
|
||||
* Or
|
||||
* - A single min population for all tiers.
|
||||
*/
|
||||
var/list/min_pop = 0
|
||||
var/alist/min_pop = 0
|
||||
/// List of roles that are blacklisted from this ruleset
|
||||
/// For roundstart rulesets, it will prevent players from being selected for this ruleset if they have one of these roles
|
||||
/// For latejoin or midround rulesets, it will prevent players from being assigned to this ruleset if they have one of these roles
|
||||
@@ -121,47 +121,15 @@
|
||||
return FALSE
|
||||
return ..()
|
||||
|
||||
/// Used to create tier lists for weights and min_pop values
|
||||
/// Used to create tier alists for weights and min_pop values
|
||||
/datum/dynamic_ruleset/proc/load_tier_list(list/incoming_list)
|
||||
PRIVATE_PROC(TRUE)
|
||||
|
||||
var/list/tier_list = new /list(4)
|
||||
// loads a list of list("2" = 1, "3" = 3) into a list(null, 1, 3, null)
|
||||
var/alist/tier_list = alist()
|
||||
// loads a list of list("2" = 1, "3" = 3) into an alist(2 = 1, 3 = 3)
|
||||
for(var/tier in incoming_list)
|
||||
tier_list[text2num(tier)] = incoming_list[tier]
|
||||
|
||||
// turn list(null, 1, 3, null) into list(1, 1, 3, null)
|
||||
for(var/i in 1 to length(tier_list))
|
||||
var/val = tier_list[i]
|
||||
if(isnum(val))
|
||||
break
|
||||
for(var/j in i to length(tier_list))
|
||||
var/other_val = tier_list[j]
|
||||
if(!isnum(other_val))
|
||||
continue
|
||||
tier_list[i] = other_val
|
||||
break
|
||||
|
||||
// turn list(1, 1, 3, null) into list(1, 1, 3, 3)
|
||||
for(var/i in length(tier_list) to 1 step -1)
|
||||
var/val = tier_list[i]
|
||||
if(isnum(val))
|
||||
break
|
||||
for(var/j in i to 1 step -1)
|
||||
var/other_val = tier_list[j]
|
||||
if(!isnum(other_val))
|
||||
continue
|
||||
tier_list[i] = other_val
|
||||
break
|
||||
|
||||
// we can assert that tier[1] and tier[4] are not null, but we cannot say the same for tier[2] and tier[3]
|
||||
// this can be happen due to the following setup: list(1, null, null, 4)
|
||||
// (which is an invalid config, and should be fixed by the operator)
|
||||
if(isnull(tier_list[2]))
|
||||
tier_list[2] = tier_list[1]
|
||||
if(isnull(tier_list[3]))
|
||||
tier_list[3] = tier_list[4]
|
||||
|
||||
return tier_list
|
||||
|
||||
/**
|
||||
@@ -170,6 +138,25 @@
|
||||
/datum/dynamic_ruleset/proc/can_be_selected()
|
||||
return TRUE
|
||||
|
||||
/// Gets the list value for the given tier, otherwise use next highest tier,
|
||||
/// or failing that, next lowest
|
||||
/datum/dynamic_ruleset/proc/get_tier_specific_value(alist/values, tier)
|
||||
PRIVATE_PROC(TRUE)
|
||||
if(isnum(values[tier]))
|
||||
return values[tier]
|
||||
|
||||
// search higher tiers
|
||||
for(var/i in tier to 4)
|
||||
if(isnum(values[i]))
|
||||
return values[i]
|
||||
|
||||
// no dice, lower tiers?
|
||||
for(var/i in tier to 1 step -1)
|
||||
if(isnum(values[i]))
|
||||
return values[i]
|
||||
|
||||
return 0
|
||||
|
||||
/**
|
||||
* Calculates the weight of this ruleset for the given tier.
|
||||
*
|
||||
@@ -183,11 +170,11 @@
|
||||
return 0
|
||||
if(!can_be_selected())
|
||||
return 0
|
||||
var/final_minpop = islist(min_pop) ? min_pop[tier] : min_pop
|
||||
var/final_minpop = islist(min_pop) ? get_tier_specific_value(min_pop, tier) : min_pop
|
||||
if(final_minpop > population_size)
|
||||
return 0
|
||||
|
||||
var/final_weight = islist(weight) ? weight[tier] : weight
|
||||
var/final_weight = islist(weight) ? get_tier_specific_value(weight, tier) : weight
|
||||
for(var/datum/dynamic_ruleset/other_ruleset as anything in SSdynamic.executed_rulesets)
|
||||
if(other_ruleset == src)
|
||||
continue
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
midround_type = HEAVY_MIDROUND
|
||||
false_alarm_able = TRUE
|
||||
ruleset_flags = RULESET_INVADER
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 0,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 1,
|
||||
@@ -271,7 +271,7 @@
|
||||
pref_flag = ROLE_WIZARD_MIDROUND
|
||||
jobban_flag = ROLE_WIZARD
|
||||
ruleset_flags = RULESET_INVADER|RULESET_HIGH_IMPACT
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 0,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 1,
|
||||
@@ -294,7 +294,7 @@
|
||||
pref_flag = ROLE_OPERATIVE_MIDROUND
|
||||
jobban_flag = ROLE_OPERATIVE
|
||||
ruleset_flags = RULESET_INVADER|RULESET_HIGH_IMPACT
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 1,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 3,
|
||||
@@ -378,7 +378,7 @@
|
||||
false_alarm_able = TRUE
|
||||
pref_flag = ROLE_BLOB
|
||||
ruleset_flags = RULESET_INVADER
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 1,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 3,
|
||||
@@ -418,7 +418,7 @@
|
||||
false_alarm_able = TRUE
|
||||
pref_flag = ROLE_ALIEN
|
||||
ruleset_flags = RULESET_INVADER
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 1,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 5,
|
||||
@@ -505,7 +505,7 @@
|
||||
false_alarm_able = TRUE
|
||||
pref_flag = ROLE_SPACE_DRAGON
|
||||
ruleset_flags = RULESET_INVADER
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 3,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 5,
|
||||
@@ -575,7 +575,7 @@
|
||||
midround_type = HEAVY_MIDROUND
|
||||
pref_flag = ROLE_NINJA
|
||||
ruleset_flags = RULESET_INVADER
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 0,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 1,
|
||||
@@ -678,7 +678,7 @@
|
||||
min_antag_cap = 2
|
||||
max_antag_cap = 3
|
||||
repeatable_weight_decrease = 4
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 3,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 4,
|
||||
@@ -1104,7 +1104,7 @@
|
||||
max_antag_cap = 4
|
||||
repeatable_weight_decrease = 8
|
||||
blacklisted_roles = list()
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 3,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 8,
|
||||
@@ -1119,7 +1119,7 @@
|
||||
pref_flag = ROLE_MALF_MIDROUND
|
||||
jobban_flag = ROLE_MALF
|
||||
ruleset_flags = RULESET_HIGH_IMPACT
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 1,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 3,
|
||||
@@ -1147,7 +1147,7 @@
|
||||
midround_type = HEAVY_MIDROUND
|
||||
pref_flag = ROLE_BLOB_INFECTION
|
||||
jobban_flag = ROLE_BLOB
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 1,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 3,
|
||||
@@ -1171,7 +1171,7 @@
|
||||
midround_type = LIGHT_MIDROUND
|
||||
pref_flag = ROLE_OBSESSED
|
||||
blacklisted_roles = list()
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 5,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 5,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 3,
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
pref_flag = ROLE_MALF
|
||||
preview_antag_datum = /datum/antagonist/malf_ai
|
||||
ruleset_flags = RULESET_HIGH_IMPACT
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 1,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 3,
|
||||
@@ -116,7 +116,7 @@
|
||||
preview_antag_datum = /datum/antagonist/wizard
|
||||
pref_flag = ROLE_WIZARD
|
||||
ruleset_flags = RULESET_INVADER|RULESET_HIGH_IMPACT
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 0,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 1,
|
||||
@@ -147,7 +147,7 @@
|
||||
preview_antag_datum = /datum/antagonist/cult
|
||||
pref_flag = ROLE_CULTIST
|
||||
ruleset_flags = RULESET_HIGH_IMPACT
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 1,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 3,
|
||||
@@ -208,7 +208,7 @@
|
||||
preview_antag_datum = /datum/antagonist/nukeop
|
||||
pref_flag = ROLE_OPERATIVE
|
||||
ruleset_flags = RULESET_INVADER|RULESET_HIGH_IMPACT
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 1,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 3,
|
||||
@@ -292,7 +292,7 @@
|
||||
preview_antag_datum = /datum/antagonist/rev/head
|
||||
pref_flag = ROLE_REV_HEAD
|
||||
ruleset_flags = RULESET_HIGH_IMPACT
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 1,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 3,
|
||||
@@ -367,7 +367,7 @@
|
||||
config_tag = "Roundstart Spies"
|
||||
preview_antag_datum = /datum/antagonist/spy
|
||||
pref_flag = ROLE_SPY
|
||||
weight = list(
|
||||
weight = alist(
|
||||
DYNAMIC_TIER_LOW = 0,
|
||||
DYNAMIC_TIER_LOWMEDIUM = 1,
|
||||
DYNAMIC_TIER_MEDIUMHIGH = 3,
|
||||
|
||||
Reference in New Issue
Block a user