- Save file formatting less verbose in selected cases (functionally same, no performance gain or loss, smaller file size, easier to read by humans)
I really like the recent change of making .sav files more compact. So I'd like to suggest a few more ideas to achieve better formatting in the .sav files.
There are two types of ideas here.
The first is to not save properties that have default values. If the game knows what the default value of an object property is, then there's no need to save this property in a file.
The second is to increase readability by formatting certain very common objects/arrays into single lines.
There can be thousands of
items in a battlescape game, so it would be a good idea to both format these into a single line and remove default value properties
- id: 961
type: STR_SMG_CLIP
owner: 1000043
inventoryslot: STR_QD_SLOT
inventoryX: 0 # default value
inventoryY: 0 # default value
ammoqty: 36
ammoItemSlots: ~ # default value
tags: ~ # default value
can be reduced to:
- { id: 961, type: STR_SMG_CLIP, owner: 1000043, inventoryslot: STR_QD_SLOT, ammoqty: 36 }
Reducing 187 to 94 bytes.
Battlescape
units have a lot of default values saved and could also use some compacting
- id: 1000043
#create a new object "genUnit", add the next 2 properties to it, and format it to a single line
genUnitType: STR_BANDIT_RATMAN_LEADER
genUnitArmor: BANDIT_ARMOR_P5
faction: 1
status: 0
wantsToSurrender: false #default value
isSurrendering: false #default value
position: [24, 13, 0]
direction: 3
directionTurret: 3 #default value - should only be saved if it differs from direction
#create a new object "battleStats", add the next 6 properties to it, and format it to a single line
tu: 74
health: 36
mana: 145
stunlevel: 0
energy: 70
morale: 100
kneeled: false #default value
floating: false #default value
armor: [6, 6, 6, 6, 6]
fatalWounds: [0, 0, 0, 0, 0, 0] #default value
fire: 0 #default value
#create a new object "experience" with the next 8 properties and format it to single line. If all the property values are 0, then we probably don't need to save this object either
expBravery: 0
expReactions: 0
expFiring: 0
expThrowing: 0
expPsiSkill: 0
expPsiStrength: 0
expMana: 0
expMelee: 0
currStats: #format to single line
tu: 74
stamina: 70
health: 36
bravery: 80
reactions: 109
firing: 79
throwing: 55
strength: 33
psiStrength: 67
psiSkill: 0
melee: 72
mana: 145
turretType: -1 #default value
visible: false #default value
turnsSinceSpotted: 255 #default value
turnsLeftSpottedForSnipers: 0 #default value
turnsSinceStunned: 255 #default value
rankInt: 7
moraleRestored: 0 #default value
AI: #format to single line
fromNode: 16
toNode: -1
AIMode: 0
wasHitBy:
[]
motionPoints: 0 #default value
alreadyRespawned: false #default value
activeHand: STR_RIGHT_HAND #default value?
tempUnitStatistics:
wasUnconcious: false #default value
#create new object "murderer" with the next 7 properties and format it to single line.
killedBy: 1 #default value
murdererId: 0 #default value
fatalShotSide: 0 #default value
fatalShotBodyPart: 0 #default value
murdererWeapon: "" #default value
murdererWeaponAmmo: "" #default value
mindControllerID: 0 #default value
summonedPlayerUnit: false #default value
pickUpWeaponsMoreActively: true #default value -> it's default if it matches ai.pickUpWeaponsMoreActively
tags:
UNIT_RECOLOR_DESYNC: 25
to
- id: 1000043
genUnit: { type: STR_BANDIT_RATMAN_LEADER, armor: BANDIT_ARMOR_P5 }
faction: 1
status: 0
position: [24, 13, 0]
direction: 3
battleStats: { tu: 74, health: 36, mana: 145, stunlevel: 0, energy: 70, morale: 100 }
armor: [6, 6, 6, 6, 6]
experience: { bravery: 0, reactions: 0, firing: 0, throwing: 0, psiSkill: 0, psiStrength: 0, mana: 0, melee: 0 }
currStats: { tu: 74, stamina: 70, health: 36, bravery: 80, reactions: 109, firing: 79, throwing: 55, strength: 33, psiStrength: 67, psiSkill: 0, melee: 72, mana: 145 }
rankInt: 7
AI: { fromNode: 16, toNode: -1, AIMode: 0, wasHitBy: [] }
tempUnitStatistics: {}
murderer: {}
tags:
UNIT_RECOLOR_DESYNC: 25
Reducing 1595 to 758 bytes and making it a lot more readable.
Next, after playing the game for a while, the
missionStatistics section of the .sav file can grow to be quite large, so object entries in this list should be formatted to a single line each.
Only slightly effective, but base facilities, transfers, research, and production list entry objects could also be formatted to a single line.
Similarly for graph data numbers of funds, maintenance, researchScores, incomes, expenditures, country funding and country/region activityXcom, activityAlien.
I think most of the .sav files will grow large due to soldier diary killLists. The list object entries are already formatted to a single line there, but I have a couple of questions regarding these entries.
killList:
- {type: STR_ZOMBIE_STERILE_TERRORIST, rank: STR_LIVE_TERRORIST, race: STR_ZOMBIE, weapon: STR_SHOTGUN_LT, weaponAmmo: STR_SHOTGUN_SHELLS, status: 7, faction: 1, mission: 9, turn: 2703, side: 0, bodypart: 1, id: 1000004}
Could the property "race" be removed? It seems to me that in most cases, race can be obtained from the unit type itself and there's no need to save it.
Could the properties "side" and "bodypart" be removed? I don't know of any mods using these for commendations. There's an idea that, oh, a soldier could get commended for how many headshots they've made, but then you realize that aiming in the game isn't possible, so any such commendation would be based on random luck.