1# Copyright 2014-2015 the openage authors. See copying.md for legal info. 2 3""" modernizes/patches the gamespec. """ 4 5 6def fix_data(data): 7 """ 8 updates given input with modifications. 9 10 input: empiresdat object, vanilla, fully read. 11 output: empiresdat object, fixed. 12 """ 13 14 ### 15 # Terrain fixes 16 ### 17 18 # remove terrains with slp_id == -1 19 # we'll need them again in the future, with fixed slp ids 20 data.terrains = [val for val in data.terrains if val.slp_id >= 0] 21 22 # assign correct blending modes 23 # key: dat file stored mode 24 # value: corrected mode 25 # resulting values are also priorities! 26 # -> higher => gets selected as mask for two partners 27 blendmode_map = { 28 # identical modes: [0,1,7,8], [4,6] 29 0: 1, # dirt, grass, palm_desert 30 1: 3, # farms 31 2: 2, # beach 32 3: 0, # water 33 4: 1, # shallows 34 5: 4, # roads 35 6: 5, # ice 36 7: 6, # snow 37 8: 4, # no terrain has it, but the mode exists.. 38 } 39 for terrain in data.terrains: 40 terrain.blend_mode = blendmode_map[terrain.blend_mode] 41 42 # set correct terrain ids 43 for idx, terrain in enumerate(data.terrains): 44 terrain.terrain_id = idx 45 46 return data 47