mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
[MIRROR] Reduced memory usage of gene conflicts (#11092)
Co-authored-by: Will <7099514+Willburd@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
48e4d45c83
commit
d89c682ffb
@@ -94,40 +94,29 @@
|
|||||||
if(P == path)
|
if(P == path)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
// check if cached first...
|
// Quickscan time
|
||||||
if(!isnull(conflict_traits[P]))
|
if(quick_scan)
|
||||||
if(quick_scan && conflict_traits[P])
|
if(P in conflict_traits)
|
||||||
return TRUE
|
return TRUE
|
||||||
continue
|
continue
|
||||||
|
|
||||||
// check trait if not. CONFLICT-O-TRON ENGAGE
|
// check trait if not. CONFLICT-O-TRON ENGAGE
|
||||||
conflict_traits[P] = FALSE
|
|
||||||
|
|
||||||
var/datum/trait/instance_test = GLOB.all_traits[P]
|
var/datum/trait/instance_test = GLOB.all_traits[P]
|
||||||
if(path in instance_test.excludes)
|
if(path in instance_test.excludes)
|
||||||
conflict_traits[P] = TRUE
|
conflict_traits.Add(P)
|
||||||
has_conflict = TRUE
|
has_conflict = TRUE
|
||||||
// depending on scan mode we want to scan all, or only the first failure
|
|
||||||
if(quick_scan)
|
|
||||||
return TRUE
|
|
||||||
continue
|
continue
|
||||||
for(var/V in linked_trait.var_changes)
|
for(var/V in linked_trait.var_changes)
|
||||||
if(V == "flags")
|
if(V == "flags")
|
||||||
continue
|
continue
|
||||||
if(V in instance_test.var_changes)
|
if(V in instance_test.var_changes)
|
||||||
conflict_traits[P] = TRUE
|
conflict_traits.Add(P)
|
||||||
has_conflict = TRUE
|
has_conflict = TRUE
|
||||||
// depending on scan mode we want to scan all, or only the first failure
|
|
||||||
if(quick_scan)
|
|
||||||
return TRUE
|
|
||||||
continue
|
continue
|
||||||
for(var/V in linked_trait.var_changes_pref)
|
for(var/V in linked_trait.var_changes_pref)
|
||||||
if(V in instance_test.var_changes_pref)
|
if(V in instance_test.var_changes_pref)
|
||||||
conflict_traits[P] = TRUE
|
conflict_traits.Add(P)
|
||||||
has_conflict = TRUE
|
has_conflict = TRUE
|
||||||
// depending on scan mode we want to scan all, or only the first failure
|
|
||||||
if(quick_scan)
|
|
||||||
return TRUE
|
|
||||||
continue
|
continue
|
||||||
return has_conflict
|
return has_conflict
|
||||||
|
|
||||||
|
|||||||
@@ -41,24 +41,17 @@
|
|||||||
if(blocks_remaining.len < 10)
|
if(blocks_remaining.len < 10)
|
||||||
warning("DNA2: Blocks remaining is less than 10. The DNA_SE_LENGTH should be raised in dna.dm.")
|
warning("DNA2: Blocks remaining is less than 10. The DNA_SE_LENGTH should be raised in dna.dm.")
|
||||||
// Run conflict-o-tron on each traitgene all other traits... Lets setup an initial database of conflicts.
|
// Run conflict-o-tron on each traitgene all other traits... Lets setup an initial database of conflicts.
|
||||||
// Any remaining conflicts will be handled by the conflict-o-tron midround using a quicker scan flag
|
|
||||||
log_world("DNA2: Checking trait gene conflicts")
|
log_world("DNA2: Checking trait gene conflicts")
|
||||||
var/list/compare_list = list()
|
|
||||||
for(var/datum/gene/trait/gene in GLOB.dna_genes) // was orginally all_traits, but having 300 entry lists for 50 genes at launch was pointless. the caches will fill as characters spawn with traits instead... A small tradeoff
|
|
||||||
if(gene.linked_trait)
|
|
||||||
compare_list.Add(gene.linked_trait.type)
|
|
||||||
for(var/datum/gene/trait/gene in GLOB.dna_genes)
|
for(var/datum/gene/trait/gene in GLOB.dna_genes)
|
||||||
gene.has_conflict( compare_list, FALSE )
|
gene.has_conflict( GLOB.all_traits, FALSE) // Check all traits beforehand to build the conflict list, so all future checks can be done with a quick contents check
|
||||||
log_world("DNA2: Initial Conflict summary")
|
log_world("DNA2: Initial Conflict summary")
|
||||||
// Future coders: Don't worry, has_conflict() is run whenever a traitgene tries to enable itself as well, and adds to the trait conflict lists in each gene...
|
|
||||||
// This is to setup the initial segments for the gene editing machines to sort gene segments with.
|
// This is to setup the initial segments for the gene editing machines to sort gene segments with.
|
||||||
for(var/datum/gene/trait/gene in GLOB.dna_genes)
|
for(var/datum/gene/trait/gene in GLOB.dna_genes)
|
||||||
if(gene.conflict_traits.len)
|
if(gene.conflict_traits.len)
|
||||||
var/summery = ""
|
var/summery = ""
|
||||||
for(var/path in gene.conflict_traits)
|
for(var/path in gene.conflict_traits)
|
||||||
if(gene.conflict_traits[path]) // check if it actually conflicts
|
var/datum/trait/T = GLOB.all_traits[path]
|
||||||
var/datum/trait/T = GLOB.all_traits[path]
|
if(summery != "")
|
||||||
if(summery != "")
|
summery += ", "
|
||||||
summery += ", "
|
summery += "[T.name]"
|
||||||
summery += "[T.name]"
|
|
||||||
log_world("DNA2: [gene.get_name()] - ([summery])")
|
log_world("DNA2: [gene.get_name()] - ([summery])")
|
||||||
|
|||||||
Reference in New Issue
Block a user