@@ -271,22 +271,23 @@ def apply(self):
271271 pass
272272 else :
273273 obj_type = obj_type << 8 | 0x01
274-
275- type_class = GameObject .get_type (obj_type )
276- # Could this be hallucinated?
277- create_obj = not GameObject .has_type (obj_type & 0xfffffc | 0x2 )
278-
279- obj = None
280- if obj_id in self .player .replay .objects :
281- obj = self .player .replay .objects [obj_id ]
282- elif create_obj :
283- obj = type_class (obj_id , self .frame )
284- self .player .replay .objects [obj_id ] = obj
285-
286- if obj :
287- obj .visit (self .frame , self .player , type_class )
288- self .target = obj
289-
274+ try :
275+ type_class = GameObject .get_type (obj_type )
276+ # Could this be hallucinated?
277+ create_obj = not GameObject .has_type (obj_type & 0xfffffc | 0x2 )
278+
279+ obj = None
280+ if obj_id in self .player .replay .objects :
281+ obj = self .player .replay .objects [obj_id ]
282+ elif create_obj :
283+ obj = type_class (obj_id , self .frame )
284+ self .player .replay .objects [obj_id ] = obj
285+
286+ if obj :
287+ obj .visit (self .frame , self .player , type_class )
288+ self .target = obj
289+ except KeyError :
290+ print "Unknown object type (%s) at frame %s" % (hex (obj_type ),self .frame )
290291 super (TargetAbilityEvent , self ).apply ()
291292
292293class LocationAbilityEvent (AbilityEvent ):
@@ -368,13 +369,16 @@ def apply(self):
368369
369370 # Add new selection
370371 for (obj_id , obj_type ) in self .objects :
371- type_class = GameObject .get_type (obj_type )
372- if obj_id not in self .player .replay .objects :
373- obj = type_class (obj_id , self .frame )
374- self .player .replay .objects [obj_id ] = obj
375- else :
376- obj = self .player .replay .objects [obj_id ]
377- obj .visit (self .frame , self .player , type_class )
378- selected .append (obj )
372+ try :
373+ type_class = GameObject .get_type (obj_type )
374+ if obj_id not in self .player .replay .objects :
375+ obj = type_class (obj_id , self .frame )
376+ self .player .replay .objects [obj_id ] = obj
377+ else :
378+ obj = self .player .replay .objects [obj_id ]
379+ obj .visit (self .frame , self .player , type_class )
380+ selected .append (obj )
381+ except KeyError :
382+ print "Unknown object type (%s) at frame %s" % (hex (obj_type ),self .frame )
379383
380384 selection [self .frame ] = selected
0 commit comments