mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Stats unique can no longer crash badly defined mods
This commit is contained in:
parent
88ac6330dc
commit
da5935e5c8
@ -11,7 +11,11 @@ class Unique(val text:String){
|
||||
val params = text.getPlaceholderParameters()
|
||||
/** This is so the heavy regex-based parsing is only activated once per unique, instead of every time it's called
|
||||
* - for instance, in the city screen, we call every tile unique for every tile, which can lead to ANRs */
|
||||
val stats = params.firstOrNull { Stats.isStats(it) }?.let { Stats.parse(it) }
|
||||
val stats: Stats by lazy {
|
||||
val firstStatParam = params.firstOrNull { Stats.isStats(it) }
|
||||
if (firstStatParam == null) Stats() // So badly-defined stats don't crash the entire game
|
||||
else Stats.parse(firstStatParam)
|
||||
}
|
||||
}
|
||||
|
||||
class UniqueMap:HashMap<String, ArrayList<Unique>>() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user