11from dataclasses import dataclass
22
33from genieutils .common import ByteHandler , GenieClass
4+ from genieutils .versions import Version
45
56
67@dataclass
@@ -37,7 +38,7 @@ def from_bytes(cls, content: ByteHandler) -> 'MapUnit':
3738 max_distance_to_players = content .read_int_32 (),
3839 )
3940
40- def to_bytes (self ) -> bytes :
41+ def to_bytes (self , version : Version ) -> bytes :
4142 return b'' .join ([
4243 self .write_int_32 (self .unit ),
4344 self .write_int_32 (self .host_terrain ),
@@ -75,7 +76,7 @@ def from_bytes(cls, content: ByteHandler) -> 'MapTerrain':
7576 clumpiness = content .read_int_32 (),
7677 )
7778
78- def to_bytes (self ) -> bytes :
79+ def to_bytes (self , version : Version ) -> bytes :
7980 return b'' .join ([
8081 self .write_int_32 (self .proportion ),
8182 self .write_int_32 (self .terrain ),
@@ -124,7 +125,7 @@ def from_bytes(cls, content: ByteHandler) -> 'MapLand':
124125 clumpiness = content .read_int_32 (),
125126 )
126127
127- def to_bytes (self ) -> bytes :
128+ def to_bytes (self , version : Version ) -> bytes :
128129 return b'' .join ([
129130 self .write_int_32 (self .land_id ),
130131 self .write_int_32 (self .terrain , signed = False ),
@@ -164,7 +165,7 @@ def from_bytes(cls, content: ByteHandler) -> 'MapElevation':
164165 tile_spacing = content .read_int_32 (),
165166 )
166167
167- def to_bytes (self ) -> bytes :
168+ def to_bytes (self , version : Version ) -> bytes :
168169 return b'' .join ([
169170 self .write_int_32 (self .proportion ),
170171 self .write_int_32 (self .terrain ),
@@ -249,7 +250,7 @@ def from_bytes(cls, content: ByteHandler) -> 'MapInfo':
249250 map_elevations = map_elevations ,
250251 )
251252
252- def to_bytes (self ) -> bytes :
253+ def to_bytes (self , version : Version ) -> bytes :
253254 return b'' .join ([
254255 self .write_int_32 (self .map_id ),
255256 self .write_int_32 (self .border_south_west ),
@@ -263,16 +264,16 @@ def to_bytes(self) -> bytes:
263264 self .write_int_32 (self .unused_id ),
264265 self .write_int_32 (self .map_lands_size , signed = False ),
265266 self .write_int_32 (self .map_lands_ptr ),
266- self .write_class_array (self .map_lands ),
267+ self .write_class_array (self .map_lands , version ),
267268 self .write_int_32 (self .map_terrains_size , signed = False ),
268269 self .write_int_32 (self .map_terrains_ptr ),
269- self .write_class_array (self .map_terrains ),
270+ self .write_class_array (self .map_terrains , version ),
270271 self .write_int_32 (self .map_units_size , signed = False ),
271272 self .write_int_32 (self .map_units_ptr ),
272- self .write_class_array (self .map_units ),
273+ self .write_class_array (self .map_units , version ),
273274 self .write_int_32 (self .map_elevations_size , signed = False ),
274275 self .write_int_32 (self .map_elevations_ptr ),
275- self .write_class_array (self .map_elevations ),
276+ self .write_class_array (self .map_elevations , version ),
276277 ])
277278
278279
@@ -294,11 +295,11 @@ def from_bytes(cls, content: ByteHandler) -> 'RandomMaps':
294295 map_info_2 = map_info_2 ,
295296 )
296297
297- def to_bytes (self ) -> bytes :
298+ def to_bytes (self , version : Version ) -> bytes :
298299 assert len (self .map_info_1 ) == len (self .map_info_2 )
299300 return b'' .join ([
300301 self .write_int_32 (len (self .map_info_1 ), signed = False ),
301302 self .write_int_32 (self .random_maps_ptr ),
302- self .write_class_array (self .map_info_1 ),
303- self .write_class_array (self .map_info_2 ),
303+ self .write_class_array (self .map_info_1 , version ),
304+ self .write_class_array (self .map_info_2 , version ),
304305 ])
0 commit comments