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

Move sourcing of SQUAD_CREATED event to RCON #243

Merged
merged 5 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 8 additions & 9 deletions squad-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ export default class SquadServer extends EventEmitter {

this.emit('PLAYER_BANNED', data);
});

this.rcon.on('SQUAD_CREATED', async (data) => {
data.player = await this.getPlayerBySteamID(data.playerSteamID, true);
delete data.playerName;
delete data.playerSteamID;

this.emit('SQUAD_CREATED', data);
});
}

async restartRCON() {
Expand Down Expand Up @@ -297,15 +305,6 @@ export default class SquadServer extends EventEmitter {
this.logParser.on('TICK_RATE', (data) => {
this.emit('TICK_RATE', data);
});

this.logParser.on('SQUAD_CREATED', async (data) => {
data.player = await this.getPlayerBySteamID(data.playerSteamID, true);
delete data.playerName;
delete data.playerSteamID;
delete data.squadID;

this.emit('SQUAD_CREATED', data);
});
}

async restartLogParser() {
Expand Down
4 changes: 1 addition & 3 deletions squad-server/log-parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import RoundTickets from './round-tickets.js';
import RoundWinner from './round-winner.js';
import ServerTickRate from './server-tick-rate.js';
import SteamIDConnected from './steamid-connected.js';
import SquadCreated from './squad-created.js';

export default class SquadLogParser extends LogParser {
constructor(options) {
Expand All @@ -40,8 +39,7 @@ export default class SquadLogParser extends LogParser {
RoundTickets,
RoundWinner,
ServerTickRate,
SteamIDConnected,
SquadCreated
SteamIDConnected
];
}
}
2 changes: 1 addition & 1 deletion squad-server/log-parser/player-damaged.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
regex:
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogSquad: Player:(.+) ActualDamage=([0-9.]+) from (.+) caused by ([A-z_0-9\-]+)_C/,
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogSquad: Player:(.+) ActualDamage=([0-9.]+) from (.+) caused by ([A-z_0-9-]+)_C/,
onMatch: (args, logParser) => {
const data = {
raw: args[0],
Expand Down
2 changes: 1 addition & 1 deletion squad-server/log-parser/player-died.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
regex:
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogSquadTrace: \[DedicatedServer](?:ASQSoldier::)?Die\(\): Player:(.+) KillingDamage=(?:-)*([0-9.]+) from ([A-z_0-9]+) caused by ([A-z_0-9\-]+)_C/,
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogSquadTrace: \[DedicatedServer](?:ASQSoldier::)?Die\(\): Player:(.+) KillingDamage=(?:-)*([0-9.]+) from ([A-z_0-9]+) caused by ([A-z_0-9-]+)_C/,
onMatch: (args, logParser) => {
const data = {
...logParser.eventStore[args[3]],
Expand Down
2 changes: 1 addition & 1 deletion squad-server/log-parser/player-wounded.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
regex:
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogSquadTrace: \[DedicatedServer](?:ASQSoldier::)?Wound\(\): Player:(.+) KillingDamage=(?:-)*([0-9.]+) from ([A-z_0-9]+) caused by ([A-z_0-9\-]+)_C/,
/^\[([0-9.:-]+)]\[([ 0-9]*)]LogSquadTrace: \[DedicatedServer](?:ASQSoldier::)?Wound\(\): Player:(.+) KillingDamage=(?:-)*([0-9.]+) from ([A-z_0-9]+) caused by ([A-z_0-9-]+)_C/,
onMatch: (args, logParser) => {
const data = {
...logParser.eventStore[args[3]],
Expand Down
18 changes: 0 additions & 18 deletions squad-server/log-parser/squad-created.js

This file was deleted.

18 changes: 18 additions & 0 deletions squad-server/rcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ export default class SquadRcon extends Rcon {
return;
}

const matchSqCreated = decodedPacket.body.match(
/(.+) \(Steam ID: ([0-9]{17})\) has created Squad (\d+) \(Squad Name: (.+)\) on (.+)/
);
if (matchSqCreated) {
Logger.verbose('SquadRcon', 2, `Matched Squad Created: ${decodedPacket.body}`);

this.emit('SQUAD_CREATED', {
time: new Date(),
playerName: matchSqCreated[1],
playerSteamID: matchSqCreated[2],
squadID: matchSqCreated[3],
squadName: matchSqCreated[4],
teamName: matchSqCreated[5]
});

return;
}

const matchBan = decodedPacket.body.match(
/Banned player ([0-9]+)\. \[steamid=(.*?)\] (.*) for interval (.*)/
);
Expand Down