Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve player connection and disconnection logic #258

Merged
merged 6 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/log-parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class LogParser extends EventEmitter {
delete this.eventStore.disconnected[player.steamID];
}
}
this.eventStore.matchData = {};
this.eventStore.session = {};
Thomas-Smyth marked this conversation as resolved.
Show resolved Hide resolved
}

getRules() {
Expand Down
19 changes: 19 additions & 0 deletions squad-server/log-parser/client-connected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export default {
regex:
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogNet: AddClientConnection: Added client connection: \[UNetConnection\] RemoteAddr: ([0-9]{17}):[0-9]+, Name: (SteamNetConnection_[0-9]+), Driver: GameNetDriver (SteamNetDriver_[0-9]+), IsServer: YES, PC: NULL, Owner: NULL, UniqueId: INVALID/,
onMatch: (args, logParser) => {
const data = {
raw: args[0],
time: args[1],
chainID: args[2],
steamID: args[3],
connection: args[4],
driver: args[5]
};
/* This is Called when unreal engine adds a client connection
First Step in Adding a Player to server
*/
logParser.eventStore.clients[args[4]] = args[3];
logParser.emit('CLIENT_CONNECTED', data);
}
};
20 changes: 20 additions & 0 deletions squad-server/log-parser/client-login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
regex:
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogSquad: Login: NewPlayer: SteamNetConnection \/Engine\/Transient\.(SteamNetConnection_[0-9]+)/,
onMatch: (args, logParser) => {
const data = {
raw: args[0],
time: args[1],
chainID: args[2],
connection: args[3]
};
/* This is Called when a player begins the Login process
We use this to get a SteamID into playerConnected.
2nd Step in player connected path
*/

logParser.eventStore['steamid-connected'] = logParser.eventStore.clients[args[3]];
ect0s marked this conversation as resolved.
Show resolved Hide resolved
delete logParser.eventStore.clients[args[3]];
logParser.emit('CLIENT_LOGIN', data);
}
};
10 changes: 8 additions & 2 deletions squad-server/log-parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import AdminBroadcast from './admin-broadcast.js';
import DeployableDamaged from './deployable-damaged.js';
import NewGame from './new-game.js';
import PlayerConnected from './player-connected.js';
import PlayerControllerConnected from './playercontroller-connected.js';
import PlayerDisconnected from './player-disconnected.js';
import PlayerDamaged from './player-damaged.js';
import PlayerDied from './player-died.js';
Expand All @@ -13,7 +14,9 @@ import PlayerUnPossess from './player-un-possess.js';
import PlayerWounded from './player-wounded.js';
import RoundWinner from './round-winner.js';
import ServerTickRate from './server-tick-rate.js';
import SteamIDConnected from './steamid-connected.js';
import ClientConnected from './client-connected.js';
import ClientLogin from './client-login.js';
import PendingConnectionDestroyed from './pending-connection-destroyed.js';
import SquadCreated from './squad-created.js';

export default class SquadLogParser extends LogParser {
Expand All @@ -27,6 +30,7 @@ export default class SquadLogParser extends LogParser {
DeployableDamaged,
NewGame,
PlayerConnected,
PlayerControllerConnected,
PlayerDisconnected,
PlayerDamaged,
PlayerDied,
Expand All @@ -36,7 +40,9 @@ export default class SquadLogParser extends LogParser {
PlayerWounded,
RoundWinner,
ServerTickRate,
SteamIDConnected,
ClientConnected,
ClientLogin,
PendingConnectionDestroyed,
SquadCreated
];
}
Expand Down
1 change: 1 addition & 0 deletions squad-server/log-parser/new-game.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export default {
delete logParser.eventStore.WON;

logParser.emit('NEW_GAME', data);
logParser.clearEventStore();
}
};
20 changes: 20 additions & 0 deletions squad-server/log-parser/pending-connection-destroyed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
regex:
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogNet: UNetConnection::PendingConnectionLost\. \[UNetConnection\] RemoteAddr: ([0-9]{17}):[0-9]+, Name: (SteamNetConnection_[0-9]+), Driver: GameNetDriver (SteamNetDriver_[0-9]+), IsServer: YES, PC: NULL, Owner: NULL, UniqueId: (?:Steam:UNKNOWN \[.+\]|INVALID) bPendingDestroy=0/,
onMatch: (args, logParser) => {
const data = {
raw: args[0],
time: args[1],
chainID: args[2],
steamID: args[3],
connection: args[4],
driver: args[5]
};
/* This is Called when a pending client fails
Only used to cleanup clients in eventstore
*/

delete logParser.eventStore.clients[args[4]];
logParser.emit('PENDING_CONNECTION_DESTROYED', data);
}
};
15 changes: 14 additions & 1 deletion squad-server/log-parser/player-connected.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,22 @@ export default {
time: args[1],
chainID: args[2],
playerSuffix: args[3],
steamID: logParser.eventStore['steamid-connected']
steamID: logParser.eventStore['steamid-connected'], // player connected
werewolfboy13 marked this conversation as resolved.
Show resolved Hide resolved
controller: logParser.eventStore['player-controller'] // playercontroller connected
};

delete logParser.eventStore['steamid-connected'];
werewolfboy13 marked this conversation as resolved.
Show resolved Hide resolved
delete logParser.eventStore['player-controller'];

// Handle Reconnecting players
if (logParser.eventStore.disconnected[data.steamID]) {
delete logParser.eventStore.disconnected[data.steamID];
}
logParser.emit('PLAYER_CONNECTED', data);
logParser.eventStore.players[data.steamID] = {
steamID: data.steamID,
suffix: data.playerSuffix,
controller: data.controller
};
}
};
6 changes: 4 additions & 2 deletions squad-server/log-parser/player-disconnected.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
export default {
regex:
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogEasyAntiCheatServer: \[[0-9:]+] \[[A-z]+] \[EAC Server] \[Info] \[UnregisterClient] Client: ([A-z0-9]+) PlayerGUID: ([0-9]{17})/,
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogNet: UNetConnection::Close: \[UNetConnection\] RemoteAddr: ([0-9]{17}):[0-9]+, Name: SteamNetConnection_[0-9]+, Driver: GameNetDriver SteamNetDriver_[0-9]+, IsServer: YES, PC: (BP_PlayerController_C_[0-9]+), Owner: BP_PlayerController_C_[0-9]+, UniqueId: Steam:UNKNOWN \[.*\], Channels: [0-9]+, Time: [0-9.:-]+/,
onMatch: (args, logParser) => {
const data = {
raw: args[0],
time: args[1],
chainID: args[2],
steamID: args[4]
steamID: args[3],
playerController: args[4]
};

logParser.eventStore.disconnected[data.steamID] = true;
logParser.emit('PLAYER_DISCONNECTED', data);
}
};
16 changes: 16 additions & 0 deletions squad-server/log-parser/playercontroller-connected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default {
regex:
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogSquad: PostLogin: NewPlayer: BP_PlayerController_C .+(BP_PlayerController_C_[0-9]+)/,
onMatch: (args, logParser) => {
const data = {
raw: args[0],
time: args[1],
chainID: args[2],
controller: args[3]
};

logParser.eventStore['player-controller'] = args[3];

logParser.emit('PLAYER_CONTROLLER_CONNECTED', data);
}
};
7 changes: 0 additions & 7 deletions squad-server/log-parser/steamid-connected.js

This file was deleted.