@@ -254,29 +254,29 @@ def load_context(self, replay):
254254 if not replay .datapack :
255255 return
256256
257- objects = list ()
258- data = replay .datapack
259- for (obj_id , obj_type , obj_flags ) in self .raw_objects :
257+ units = list ()
258+ for (unit_id , unit_type , unit_flags ) in self .raw_objects :
260259 # Hack that defaults viking selection to fighter mode instead of assault
261- if replay .versions [1 ] == 2 and replay .build >= 23925 and obj_type == 71 :
262- obj_type = 72
260+ if replay .versions [1 ] == 2 and replay .build >= 23925 and unit_type == 71 :
261+ unit_type = 72
263262
264- if (obj_id , obj_type ) in replay .objects :
265- obj = replay .objects [(obj_id ,obj_type )]
263+ if unit_id in replay .objects :
264+ unit = replay .objects [unit_id ]
265+ if not unit .is_type (unit_type ):
266+ replay .datapack .change_type (unit , unit_type , self .frame )
266267 else :
267- if obj_type in data .units :
268- obj = data . units [ obj_type ]( obj_id , obj_flags )
268+ if unit_type in replay . datapack .units :
269+ unit = replay . datapack . create_unit ( unit_id , unit_type , unit_flags , self . frame )
269270 else :
270271 msg = "Unit Type {0} not found in {1}"
271- self .logger .error (msg .format (hex (obj_type ), data .__class__ .__name__ ))
272- obj = Unit (obj_id , obj_flags )
272+ self .logger .error (msg .format (hex (unit_type ), replay . datapack .__class__ .__name__ ))
273+ unit = Unit (unit_id , unit_flags )
273274
274- replay .objects [( obj_id , obj_type ) ] = obj
275+ replay .objects [unit_id ] = unit
275276
276- objects .append (obj )
277+ units .append (unit )
277278
278-
279- self .objects = objects
279+ self .units = self .objects = units
280280
281281 def __str__ (self ):
282- return GameEvent .__str__ (self )+ str ([str (u ) for u in self .objects ])
282+ return GameEvent .__str__ (self )+ str ([str (u ) for u in self .objects ])
0 commit comments