Skip to content

Commit

Permalink
Fix lint errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
wight-airmash committed Oct 18, 2020
1 parent 9f96b65 commit f74bb4a
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 47 deletions.
17 changes: 11 additions & 6 deletions src/core/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,23 @@ export default class GameServerBootstrap implements GameServerBootstrapInterface

this.config.bots.ipList.forEach(ip => {
// allow subnet blocks to be provided and expanded
// this allows for a subnet like 192.168.100.0/26 to be expanded to 64 ip addresses,
// this allows for a subnet like 192.168.100.0/26 to be expanded to 64 ip addresses,
// without requiring the 64 ips to be provided as an enumerated list in an env variable.
// This should perform fine even if a large subnet is provided. If that use case were
// relevant the Netmask library could be used to combine subnets and perform efficient
// lookups.
var block = new Netmask(ip)
block.forEach((ip, long, index) => {
this.storage.ipBotList.add(ip);
})
const block = new Netmask(ip);

block.forEach(botIP => {
this.storage.ipBotList.add(botIP);
});
});

if (this.storage.ipBotList.size > 1048576) {
this.log.warn('Bot IP list is getting long. %o records. This may impact performance!', this.storage.ipBotList.size)
this.log.warn(
'Bot IP list is getting long. %o records. This may impact performance!',
this.storage.ipBotList.size
);
}

this.helpers = new Helpers({ app: this });
Expand Down
16 changes: 6 additions & 10 deletions src/server/commands/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export default class ServerCommandHandler extends System {
private responseServerSync(playerId: PlayerId): void {
if (this.config.sync.enabled) {
const { sync } = this.storage;

this.emit(
BROADCAST_CHAT_SERVER_WHISPER,
playerId,
Expand All @@ -336,18 +337,13 @@ export default class ServerCommandHandler extends System {
`Next sequence id: ${sync.nextSequenceId}. `,
`Subscribed objects: ${sync.subscribedObjects.size}. `,
`Update queues: ${sync.updatesAwaitingSequenceId.length}`,
`/${sync.updatesAwaitingSend.size}`,
`/${sync.updatesAwaitingAck.size}`,
`/${sync.updatesAwaitingResend.size}. `,
`/${sync.updatesAwaitingSend.size}`,
`/${sync.updatesAwaitingAck.size}`,
`/${sync.updatesAwaitingResend.size}. `,
].join('')
);
}
else {
this.emit(
BROADCAST_CHAT_SERVER_WHISPER,
playerId,
'Sync feature not configured.'
);
} else {
this.emit(BROADCAST_CHAT_SERVER_WHISPER, playerId, 'Sync feature not configured.');
}
}

Expand Down
12 changes: 4 additions & 8 deletions src/server/maintenance/players/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,10 @@ export default class GamePlayersConnect extends System {

const eventDetail = { name, flag };

this.emit(
SYNC_ENQUEUE_UPDATE,
'user',
player.user.id,
{},
Date.now(),
['login', eventDetail]
);
this.emit(SYNC_ENQUEUE_UPDATE, 'user', player.user.id, {}, Date.now(), [
'login',
eventDetail,
]);
}

player.level.current = convertEarningsToLevel(user.lifetimestats.earnings);
Expand Down
12 changes: 4 additions & 8 deletions src/server/maintenance/players/disconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,10 @@ export default class GamePlayersDisconnect extends System {
if (this.config.sync.enabled) {
const eventDetail = { flag: player.flag.current };

this.emit(
SYNC_ENQUEUE_UPDATE,
'user',
player.user.id,
{},
Date.now(),
['logout', eventDetail]
);
this.emit(SYNC_ENQUEUE_UPDATE, 'user', player.user.id, {}, Date.now(), [
'logout',
eventDetail,
]);

this.emit(SYNC_UNSUBSCRIBE, 'user', player.user.id);
}
Expand Down
12 changes: 4 additions & 8 deletions src/server/maintenance/players/kill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,10 @@ export default class GamePlayersKill extends System {
flag: victim.flag.current,
};

this.emit(
SYNC_ENQUEUE_UPDATE,
'user',
victim.user.id,
{ totaldeaths: 1 },
killTime,
['victim', eventDetail]
);
this.emit(SYNC_ENQUEUE_UPDATE, 'user', victim.user.id, { totaldeaths: 1 }, killTime, [
'victim',
eventDetail,
]);
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/server/periodic/sync.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { SERVER_PACKETS } from '@airbattle/protocol';
import { CONNECTIONS_SEND_PACKETS, TIMELINE_LOOP_TICK, TIMELINE_CLOCK_SECOND, SYNC_CONNECTION_INACTIVE } from '../../events';
import { System } from '../system';
import { SYNC_ACK_TIMEOUT_MS, SYNC_RESEND_TIMEOUT_MS } from '../../constants';
import {
CONNECTIONS_SEND_PACKETS,
SYNC_CONNECTION_INACTIVE,
TIMELINE_CLOCK_SECOND,
TIMELINE_LOOP_TICK,
} from '../../events';
import { System } from '../system';

export default class SyncUpdatePeriodic extends System {
constructor({ app }) {
Expand Down
10 changes: 5 additions & 5 deletions src/server/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {
ROUTE_PONG,
ROUTE_SAY,
ROUTE_SCOREDETAILED,
ROUTE_SYNC_START,
ROUTE_SYNC_ACK,
ROUTE_SYNC_AUTH,
ROUTE_SYNC_INIT,
ROUTE_SYNC_START,
ROUTE_SYNC_UPDATE,
ROUTE_SYNC_ACK,
ROUTE_TEAMCHAT,
ROUTE_VOTEMUTE,
ROUTE_WHISPER,
Expand Down Expand Up @@ -113,12 +113,12 @@ export default class PacketRouter extends System {
});

this.validPackets = Object.freeze(Object.keys(this.routes).map(packetId => ~~packetId));

this.validBackupPackets = Object.freeze(
Object.keys(this.backupRoutes).map(packetId => ~~packetId)
);
this.validSyncPackets = Object.freeze(
Object.keys(this.syncRoutes).map(packetId => ~~packetId)
);

this.validSyncPackets = Object.freeze(Object.keys(this.syncRoutes).map(packetId => ~~packetId));
}

onRouteMessage(msg: ProtocolPacket, connectionId: ConnectionId): void {
Expand Down

0 comments on commit f74bb4a

Please sign in to comment.