Skip to content

Commit

Permalink
bug fix: double join check
Browse files Browse the repository at this point in the history
  • Loading branch information
dapucita committed Jan 23, 2021
1 parent 9da3d18 commit d6b7b01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/controller/RoomTools.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PlayerObject } from "../model/GameObject/PlayerObject";
import { convertTeamID2Name, TeamID } from "../model/GameObject/TeamID";
import * as Tst from "./Translator";
import * as LangRes from "../resources/strings";
import { PlayerObject } from "../model/GameObject/PlayerObject";
import { convertTeamID2Name, TeamID } from "../model/GameObject/TeamID";

export function setDefaultStadiums(): void {
// set stadium maps as default setting
Expand Down
10 changes: 5 additions & 5 deletions core/controller/events/onPlayerJoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ export async function onPlayerJoinListener(player: PlayerObject): Promise<void>
// window.room.clearBan(player.id); //useless cuz banned player in haxball couldn't make join-event.
}
}

// if this player has already joinned by other connection
window.playerList.forEach((eachPlayer: Player) => {
if (eachPlayer.conn == player.conn) {
for (let eachPlayer of window.playerList.values()) {
if(eachPlayer.conn === player.conn) {
window.logger.i(`${player.name}#${player.id} was joined but kicked for double joinning. (origin:${eachPlayer.name}#${eachPlayer.id},conn:${player.conn})`);
window.room.kickPlayer(player.id, Tst.maketext(LangRes.onJoin.doubleJoinningKick, placeholderJoin), false); // kick
window.room.sendAnnouncement(Tst.maketext(LangRes.onJoin.doubleJoinningMsg, placeholderJoin), null, 0xFF0000, "normal", 0); // notify
//window.room.sendAnnouncement(Tst.maketext(LangRes.onJoin.doubleJoinningMsg, placeholderJoin), null, 0xFF0000, "normal", 0); // notify
return; // exit from this join event
}
});
}

// add the player who joined into playerList by creating class instance
let existPlayerData = await getPlayerDataFromDB(player.auth);
Expand Down

0 comments on commit d6b7b01

Please sign in to comment.