improve input packets

This commit is contained in:
Asraelite 2016-03-30 11:15:32 +01:00
parent a2a93882f0
commit d6daed2e9b
5 changed files with 36 additions and 37 deletions

View file

@ -31,7 +31,12 @@ class Player {
}
updateInputs(data) {
this.ship.updateInputs(data);
let input = {};
let sanitize = v => {
return v.length ? v.map(a => sanitize(a)) : +v || 0;
}
data.forEach((v, i) => input[this.inputInterface[i]] = sanitize(v));
this.ship.updateInputs(input);
this.lastAction = Date.now();
}