Fix oob panic in combo melee which can happen during desyncs.

This commit is contained in:
Sam 2021-07-04 20:54:08 -05:00
parent 5da8c70f48
commit 4bc54e0287

View File

@ -131,7 +131,14 @@ impl CharacterBehavior for Data {
handle_move(data, &mut update, 0.4);
let stage_index = (self.stage - 1) as usize;
// Index should be `self.stage - 1`, however in cases of client-server desync
// this can cause panics. This ensures that `self.stage - 1` is valid, and if it
// isn't, index of 0 is used, which is always safe.
let stage_index = self
.static_data
.stage_data
.get(self.stage as usize - 1)
.map_or(0, |_| self.stage as usize - 1);
let speed_modifer = 1.0
+ self.static_data.max_speed_increase