Skip to content

Commit

Permalink
fix: remove clients and their placed things after they leave
Browse files Browse the repository at this point in the history
  • Loading branch information
Picoseconds committed Aug 7, 2020
1 parent 8b3af02 commit 23fbcf7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/moomoo/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,20 @@ export default class Game {
this.state.players.splice(index, 1);
}

this.state.gameObjects.filter(gameObj => gameObj.ownerSID != client.player?.id);
this.state.gameObjects.filter(gameObj => gameObj.ownerSID === client.player?.id).forEach(
gameObj => this.state.removeGameObject(gameObj)
);

let tribeIndex = this.state.tribes.findIndex(
tribe => tribe.ownerSID == client.player?.id
);

if (tribeIndex > -1)
this.state.removeTribe(tribeIndex);

let clientIndex = this.clients.indexOf(client);
if (clientIndex > -1)
this.clients.splice(clientIndex, 1);
}
});

Expand Down

0 comments on commit 23fbcf7

Please sign in to comment.