mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-03 14:15:15 +07:00
Clean up redundant stuff found in save files (#2192)
This commit is contained in:
parent
f1968af3e8
commit
497ce2366a
@ -6,6 +6,7 @@ import com.unciv.logic.automation.ConstructionAutomation
|
||||
import com.unciv.logic.civilization.AlertType
|
||||
import com.unciv.logic.civilization.PopupAlert
|
||||
import com.unciv.models.ruleset.Building
|
||||
import com.unciv.models.ruleset.unit.BaseUnit
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.cityscreen.ConstructionInfoTable
|
||||
@ -262,6 +263,23 @@ class CityConstructions {
|
||||
if (getConstruction(construction).isBuildable(this))
|
||||
constructionQueue.add(construction)
|
||||
}
|
||||
// remove obsolete stuff from in progress constructions - happens often and leaves clutter in memory and save files
|
||||
// should have NO visible consequences - any accumulated points that may be reused later should stay (nukes when manhattan project city lost, nat wonder when conquered an empty city...)
|
||||
val inProgressSnapshot = inProgressConstructions.keys.filter { it != currentConstruction }
|
||||
for (constructionName in inProgressSnapshot) {
|
||||
val rejectionReason:String =
|
||||
when (val construction = getConstruction(constructionName)) {
|
||||
is Building -> construction.getRejectionReason(this)
|
||||
is BaseUnit -> construction.getRejectionReason(this)
|
||||
else -> ""
|
||||
}
|
||||
if (!( rejectionReason.endsWith("lready built")
|
||||
|| rejectionReason.startsWith("Cannot be built with")
|
||||
|| rejectionReason.startsWith("Don't need to build any more")
|
||||
|| rejectionReason.startsWith("Obsolete")
|
||||
)) continue
|
||||
inProgressConstructions.remove(constructionName)
|
||||
}
|
||||
}
|
||||
|
||||
private fun constructionComplete(construction: IConstruction) {
|
||||
|
@ -152,6 +152,8 @@ class BaseUnit : INamed, IConstruction {
|
||||
val unit = construction.cityInfo.civInfo.placeUnitNearTile(construction.cityInfo.location, name)
|
||||
if(unit==null) return false // couldn't place the unit, so there's actually no unit =(
|
||||
|
||||
if(this.unitType.isCivilian()) return true // tiny optimization makes save files a few bytes smaller
|
||||
|
||||
var XP = construction.getBuiltBuildings().sumBy { it.xpForNewUnits }
|
||||
if(construction.cityInfo.civInfo.policies.isAdopted("Total War")) XP += 15
|
||||
unit.promotions.XP = XP
|
||||
|
Loading…
Reference in New Issue
Block a user