Bugfix : code wasn't comparing the game coordinates

This commit is contained in:
Tissevert 2020-01-30 15:05:12 +01:00
parent c5e5a7c958
commit fb3bb64ff6

View file

@ -40,10 +40,12 @@ function initMessageHandlers() {
Messaging.addEventListener(["Relay", "Sync"], function(o) { Messaging.addEventListener(["Relay", "Sync"], function(o) {
var gameID = o.message.latestKnown.gameID; var gameID = o.message.latestKnown.gameID;
var state = states.get(gameID); var state = states.get(gameID);
switch(state != undefined && compare(state.latest, o.message.latestKnown)) { if(state != undefined) {
case -1: Messaging.send({tag: "Yield", onGameID: gameID}); switch(compare(state.latest.public.coordinates, o.message.latestKnown)) {
case 1: Messaging.send({tag: "Share", gameSave: state.latest}); case -1: Messaging.send({tag: "Yield", onGameID: gameID});
} case 1: Messaging.send({tag: "Share", gameSave: state.latest});
}
}
}); });
Messaging.addEventListener(["Relay", "Yield"], function(o) { Messaging.addEventListener(["Relay", "Yield"], function(o) {