@@ -232,13 +232,15 @@ def load_context(self, replay):
232
232
233
233
else :
234
234
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
+
238
238
else :
239
239
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
242
244
243
245
def __str__ (self ):
244
246
if self .target :
@@ -307,19 +309,19 @@ def load_context(self, replay):
307
309
objects = list ()
308
310
data = replay .datapack
309
311
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 )]
316
314
else :
317
- if ( obj_id , obj_type ) not in replay . objects :
315
+ if obj_type in data . units :
318
316
obj = data .units [obj_type ](obj_id )
319
- replay .objects [(obj_id ,obj_type )] = obj
320
317
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 )
322
325
323
- objects .append (obj )
324
326
325
327
self .objects = objects
0 commit comments