@@ -232,13 +232,15 @@ def load_context(self, replay):
232232
233233 else :
234234 if self .target_type not in replay .datapack .units :
235- self .target = None
236- print [ hex ( key ) for key in replay . datapack . units ]
237- print "{0} \t {1} \t Missing unit {2} from {3}" . format ( self . frame , self . player . name , hex ( self . target_type ), replay . datapack . id )
235+ self .logger . error ( "{0} \t {1} \t Missing unit {2} from {3}" . format ( self . frame , self . player . name , hex ( self . target_type ), replay . datapack . id ))
236+ unit = Unit ( self . target_id )
237+
238238 else :
239239 unit_class = replay .datapack .units [self .target_type ]
240- self .target = unit_class (self .target_id )
241- replay .objects [uid ] = self .target
240+ unit = unit_class (self .target_id )
241+
242+ self .target = unit
243+ replay .objects [uid ] = unit
242244
243245 def __str__ (self ):
244246 if self .target :
@@ -307,19 +309,19 @@ def load_context(self, replay):
307309 objects = list ()
308310 data = replay .datapack
309311 for (obj_id , obj_type ) in self .objects :
310- if obj_type not in data .units :
311- msg = "Unit Type {0} not found in {1}"
312- self .logger .error (msg .format (hex (obj_type ), data .__class__ .__name__ ))
313- print msg .format (hex (obj_type ), data .__class__ .__name__ )
314- objects .append (Unit (obj_id ))
315-
312+ if (obj_id , obj_type ) in replay .objects :
313+ obj = replay .objects [(obj_id ,obj_type )]
316314 else :
317- if ( obj_id , obj_type ) not in replay . objects :
315+ if obj_type in data . units :
318316 obj = data .units [obj_type ](obj_id )
319- replay .objects [(obj_id ,obj_type )] = obj
320317 else :
321- obj = replay .objects [(obj_id ,obj_type )]
318+ msg = "Unit Type {0} not found in {1}"
319+ self .logger .error (msg .format (hex (obj_type ), data .__class__ .__name__ ))
320+ obj = Unit (obj_id )
321+
322+ replay .objects [(obj_id ,obj_type )] = obj
323+
324+ objects .append (obj )
322325
323- objects .append (obj )
324326
325327 self .objects = objects
0 commit comments