@@ -98,11 +98,13 @@ def SelectionTracker(replay):
9898
9999 for person in replay .people :
100100 # TODO: A more robust person interface might be nice
101+ person .selection_errors = 0
101102 person .selection = GameState (PlayerSelection ())
102103 for event in filter (efilter , person .events ):
103104 if replay .opt .debug :
104105 logger .debug ("Event bytes: " + event .bytes .encode ("hex" ))
105106
107+ error = False
106108 selection = person .selection [event .frame ]
107109
108110 if isinstance (event , SetToHotkeyEvent ):
@@ -111,21 +113,25 @@ def SelectionTracker(replay):
111113 logger .info ("[{0}] {1} set hotkey {2} to current selection" .format (Length (seconds = event .second ),person .name ,event .hotkey ))
112114
113115 elif isinstance (event , AddToHotkeyEvent ):
114- selection [event .hotkey ].deselect (* event .deselect )
116+ error = not selection [event .hotkey ].deselect (* event .deselect )
115117 selection [event .hotkey ].select (selection [0x0A ].objects )
116118 logger .info ("[{0}] {1} added current selection to hotkey {2}" .format (Length (seconds = event .second ),person .name ,event .hotkey ))
117119
118120 elif isinstance (event , GetFromHotkeyEvent ):
119121 # For some reason they leave the hotkey buffer unmodified so make a copy
120122 selection [0x0A ] = selection [event .hotkey ].copy ()
121- selection [0x0A ].deselect (* event .deselect )
123+ error = not selection [0x0A ].deselect (* event .deselect )
122124 logger .info ("[{0}] {1} retrieved hotkey {2}, {3} units: {4}" .format (Length (seconds = event .second ),person .name ,event .hotkey ,len (selection [0x0A ].objects ),selection [0x0A ]))
123125
124126 elif isinstance (event , SelectionEvent ):
125- selection [0x0A ].deselect (* event .deselect )
127+ error = not selection [0x0A ].deselect (* event .deselect )
126128 selection [0x0A ].select (event .objects )
127129 logger .info ("[{0}] {1} selected {2} units: {3}" .format (Length (seconds = event .second ),person .name ,len (selection [0x0A ].objects ),selection [0x0A ]))
128130
129131 # TODO: The event level interface here should be improved
130132 # Possibly use 'added' and 'removed' unit lists as well
131133 event .selected = selection [0x0A ].objects
134+ if error :
135+ person .selection_errors += 1
136+ if replay .opt .debug :
137+ logger .warn ("Error detected in deselection mode {}." .format (event .deselect [0 ]))
0 commit comments