From 08efe130f7618f5515efb3510caf931518c2932c Mon Sep 17 00:00:00 2001 From: Skillet Date: Mon, 6 Mar 2023 17:25:10 -0500 Subject: [PATCH 01/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 374 +++++++++++++++++++-------------- 1 file changed, 212 insertions(+), 162 deletions(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index a59804b..0f80470 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -2,191 +2,241 @@ import Sequelize from 'sequelize'; import DBLog from './db-log.js'; -const { DataTypes } = Sequelize; +const {DataTypes} = Sequelize; +const ServerState = { + init: 0, + seeding: 1, + live: 2 +}; export default class DBLogPlayerTime extends DBLog { - static get description() { - return ( - 'replacement add-on to dblog for player join/seeding times' - ); - } + static get description() { + return ( + 'replacement add-on to dblog for player join/seeding times' + ); + } - static get defaultEnabled() { - return false; - } + static get defaultEnabled() { + return false; + } - static get optionsSpecification() { - return { - ...DBLog.optionsSpecification, - seedingThreshold: { + static get optionsSpecification() { + return { + ...DBLog.optionsSpecification, + seedingThreshold: { required: false, description: 'seeding Threshold.', default: 50 - } - }; - } + } + }; + } - constructor(server, options, connectors) { - super(server, options, connectors); + constructor(server, options, connectors) { + super(server, options, connectors); - this.seeding = false; - this.repairSessions = true; - this.lastTickTime = null; + this.seeding = ServerState.init; this.createModel( - 'PlayerTime', - { - id: { - type: DataTypes.INTEGER, - primaryKey: true, - autoIncrement: true - }, - joinTime: { - type: DataTypes.DATE - }, - leaveTime: { - type: DataTypes.DATE - }, - seedTime: { - type: DataTypes.DATE - }, - joinedSeeding: { - type: DataTypes.BOOLEAN - } + 'PlayerTimeNew', + { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + autoIncrement: true }, - { - charset: 'utf8mb4', - collate: 'utf8mb4_unicode_ci' + startTime: { + type: DataTypes.DATE + }, + endTime: { + type: DataTypes.DATE + }, + serverState: { + type: DataTypes.INTEGER + }, + session: { + type: DataTypes.INTEGER, + autoIncrement: true } + }, + { + charset: 'utf8mb4', + collate: 'utf8mb4_unicode_ci' + } ); - this.models.Server.hasMany(this.models.PlayerTime, { - foreignKey: { name: 'server', allowNull: false }, - onDelete: 'CASCADE' + this.models.Server.hasMany(this.models.PlayerTimeNew, { + foreignKey: {name: 'server', allowNull: false}, + onDelete: 'CASCADE' }); - this.models.SteamUser.hasMany(this.models.PlayerTime, { - foreignKey: {name: 'player' }, - onDelete: 'CASCADE' + this.models.SteamUser.hasMany(this.models.PlayerTimeNew, { + foreignKey: {name: 'player'}, + onDelete: 'CASCADE' }); this.onPlayerConnected = this.onPlayerConnected.bind(this); this.onPlayerDisconnected = this.onPlayerDisconnected.bind(this); - } - - async prepareToMount() { - await super.prepareToMount(); - await this.models.PlayerTime.sync(); - - } - - async mount() { - console.log('Mounting db-log'); - await super.mount(); - console.log('finished mounting db-log'); - this.server.on('PLAYER_CONNECTED', this.onPlayerConnected); - this.server.on('PLAYER_DISCONNECTED', this.onPlayerDisconnected); - console.log('finished mounting db-log-addOn'); - } - - async repairDB() { - console.log('starting DB repair'); - await super.repairDB(); - console.log('starting DB repair for addOn'); - let lastTickTime = await this.models.TickRate.findOne({ - where: { server: this.options.overrideServerID || this.server.id}, - order: [['id', 'DESC']], - logging: console.log - } - ); - console.log('last tick found:', lastTickTime); - let lastServerDate = lastTickTime.time; - let lastServerTime = lastServerDate.getFullYear() + '-' + (lastServerDate.getMonth() + 1) + '-' + lastServerDate.getDate()+' '+lastServerDate.getHours()+':'+lastServerDate.getMinutes()+':'+lastServerDate.getSeconds(); - console.log('last time found:', lastServerTime); - let playerOnlineID = []; - playerOnlineID.push(0); - for (const player of this.server.players){ - playerOnlineID.push(player.steamID); } - console.log('players online:', playerOnlineID); - const {ne, not, notIn, is} = Sequelize.Op; - let updateVals = { leaveTime: lastServerTime }; - let whereStuff = { - leaveTime: {[is]: null}, - server: this.options.overrideServerID || this.server.id, - player: {[notIn]: playerOnlineID} - }; - console.log(updateVals); - console.log(whereStuff); - let rowUpdate = await this.models.PlayerTime.update( - updateVals, { - where: whereStuff, - logging: console.log - } - ); - console.log('updated playerTimes row count: %i', rowUpdate[0]); - console.log('finish DB repair'); - } - async unmount() { - this.models.PlayerTime.update( - { leaveTime: 0 }, - { where: { leaveTime: null , server: this.options.overrideServerID || this.server.id } } - ); - await super.unmount(); - this.server.removeEventListener('PLAYER_CONNECTED', this.onPlayerConnected); - this.server.removeEventListener('PLAYER_DISCONNECTED', this.onPlayerDisconnected); - } + async prepareToMount() { + await super.prepareToMount(); + await this.models.PlayerTimeNew.sync(); - async onUpdatedA2SInformation(info) { - await super.onUpdatedA2SInformation(info); - - if((this.seeding == true) && (info.a2sPlayerCount >= this.options.seedingThreshold)){ - console.log('switching to Live'); - this.seeding = false; - let curDateTime = new Date(); - let timeNow = curDateTime.getFullYear() + '-' + (curDateTime.getMonth() + 1) + '-' + curDateTime.getDate()+' '+curDateTime.getHours()+':'+curDateTime.getMinutes()+':'+curDateTime.getSeconds(); - console.log(timeNow); - await this.models.PlayerTime.update( - { seedTime: timeNow }, - { where: { seedTime: null, joinedSeeding: 1, leaveTime: null, server: this.options.overrideServerID || this.server.id } } - ); - }else if(this.seeding == false && (info.a2sPlayerCount-20) < this.options.seedingThreshold){ - console.log('switching to seeding'); - this.seeding = true; - } - } - - async onPlayerConnected(info) { - console.log(info); - if(info.player){ - await this.models.SteamUser.upsert({ - steamID: info.player.steamID, - lastName: info.player.name - }); - await this.models.PlayerTime.create({ - server: this.options.overrideServerID || this.server.id, - player: info.steamID, - joinTime: info.time, - joinedSeeding: this.seeding - }); - console.log('player connect complete'); - } else console.log('player is null'); - } - - async onPlayerDisconnected(info) { - await sleep (500); - console.log(info); - if(info.player){ - await this.models.SteamUser.upsert({ - steamID: info.player.steamID, - lastName: info.player.name - }); } - let rowAffect = await this.models.PlayerTime.update( - { leaveTime: info.time }, - { where: { player: info.steamID, leaveTime: null, server: this.options.overrideServerID || this.server.id } } - ); - console.log('player disconnect rows update: %i', rowAffect[0]); - } + + async mount() { + console.log('Mounting db-log'); + await super.mount(); + console.log('finished mounting db-log'); + this.server.on('PLAYER_CONNECTED', this.onPlayerConnected); + this.server.on('PLAYER_DISCONNECTED', this.onPlayerDisconnected); + console.log('finished mounting db-log-addOn'); + } + + async repairDB() { + console.log('starting DB repair'); + await super.repairDB(); + + console.log('starting DB repair for addOn'); + + const lastTickTime = await this.models.TickRate.findOne({ + where: {server: this.options.overrideServerID || this.server.id}, + order: [['id', 'DESC']], + logging: console.log + } + ); + console.log('last tick found:', lastTickTime); + + const lastServerDate = lastTickTime.time; + const lastServerTime = lastServerDate.getFullYear() + '-' + (lastServerDate.getMonth() + 1) + '-' + lastServerDate.getDate() + ' ' + lastServerDate.getHours() + ':' + lastServerDate.getMinutes() + ':' + lastServerDate.getSeconds(); + console.log('last time found:', lastServerTime); + + const playerOnlineID = []; + playerOnlineID.push(0); + for (const player of this.server.players) { + playerOnlineID.push(player.steamID); + } + console.log('players online:', playerOnlineID); + + const {notIn, is} = Sequelize.Op; + const updateVals = {endTime: lastServerTime}; + const whereStuff = { + endTime: {[is]: null}, + server: this.options.overrideServerID || this.server.id, + player: {[notIn]: playerOnlineID} + }; + console.log(updateVals); + console.log(whereStuff); + + const rowUpdate = await this.models.PlayerTimeNew.update( + updateVals, { + where: whereStuff, + logging: console.log + } + ); + + console.log('updated playerTimes row count: %i', rowUpdate[0]); + console.log('finish DB repair'); + this.seeding = ServerState.live; + } + + async unmount() { + this.models.PlayerTimeNew.update( + {leaveTime: 0}, + {where: {leaveTime: null, server: this.options.overrideServerID || this.server.id}} + ); + await super.unmount(); + this.server.removeEventListener('PLAYER_CONNECTED', this.onPlayerConnected); + this.server.removeEventListener('PLAYER_DISCONNECTED', this.onPlayerDisconnected); + } + + async updateCurrentTimeState(date, oldState, newState){ + const timeNow = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds(); + console.log(timeNow); + const curPlayer = await this.models.PlayerTimeNew.findAll({ + where: { + leaveTime: null, + serverState: oldState, + server: this.options.overrideServerID || this.server.id + } + }); + await this.models.PlayerTimeNew.update( + { endTime: timeNow }, + { + where: { + endTime: null, + serverState: oldState, + server: this.options.overrideServerID || this.server.id + } + } + ); + await this.models.PlayerTimeNew.bulkCreate(curPlayer,{ + fields: ['startTime', 'endTime','serverState','session','server','player'] + }); + await this.models.PlayerTimeNew.update( + { + serverState: newState, + startTime: timeNow + }, + { + where: { + endTime: null, + serverState: oldState, + server: this.options.overrideServerID || this.server.id + } + } + ); + this.seeding = newState; + } + + async onUpdatedA2SInformation(info) { + await super.onUpdatedA2SInformation(info); + + const curDateTime = new Date(); + if ((this.seeding !== ServerState.live) && (info.a2sPlayerCount >= this.options.seedingThreshold)) { + console.log('switching to Live'); + await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.live); + } else if (this.seeding === false && (info.a2sPlayerCount - 20) < this.options.seedingThreshold) { + console.log('switching to seeding'); + await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.seeding); + } + } + + async onPlayerConnected(info) { + console.log(info); + if (info.player) { + await this.models.SteamUser.upsert({ + steamID: info.player.steamID, + lastName: info.player.name + }); + await this.models.PlayerTimeNew.create({ + server: this.options.overrideServerID || this.server.id, + player: info.steamID, + startTime: info.time, + serverState: this.seeding + }); + console.log('player connect complete'); + } else console.log('player is null'); + } + + async onPlayerDisconnected(info) { + await sleep(500); + console.log(info); + if (info.player) { + await this.models.SteamUser.upsert({ + steamID: info.player.steamID, + lastName: info.player.name + }); + } + const rowAffect = await this.models.PlayerTimeNew.update( + {endTime: info.time}, + {where: + { + player: info.steamID, + endTime: null, + server: this.options.overrideServerID || this.server.id + }} + ); + console.log('player disconnect rows update: %i', rowAffect[0]); + } } From 61f3ebcee5ba3cad820755532ae22e475065e7b2 Mon Sep 17 00:00:00 2001 From: Skillet Date: Mon, 6 Mar 2023 17:27:25 -0500 Subject: [PATCH 02/20] Update main.yml --- .github/workflows/main.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7b7cf86..843a153 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,11 +2,6 @@ name: Docker Image CI on: workflow_dispatch: - schedule: - - cron: '45 18 * * *' - push: - branches: - - Development jobs: @@ -33,4 +28,4 @@ jobs: context: . file: ./Dockerfile push: true - tags: "${{ vars.DOCKER_REGISTRY_URL }}/squadjs:latest" + tags: "${{ vars.DOCKER_REGISTRY_URL }}/squadjs:testing" From 3827ea16fdd68195442fe5aa54065f9f72179011 Mon Sep 17 00:00:00 2001 From: Skillet Date: Mon, 6 Mar 2023 18:21:32 -0500 Subject: [PATCH 03/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index 0f80470..e41dade 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -54,8 +54,7 @@ export default class DBLogPlayerTime extends DBLog { type: DataTypes.INTEGER }, session: { - type: DataTypes.INTEGER, - autoIncrement: true + type: DataTypes.INTEGER } }, { From 0d6766e804593b47c72741d14a40217257358cdd Mon Sep 17 00:00:00 2001 From: Skillet Date: Mon, 6 Mar 2023 21:16:09 -0500 Subject: [PATCH 04/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index e41dade..b90be0f 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -219,7 +219,7 @@ export default class DBLogPlayerTime extends DBLog { } async onPlayerDisconnected(info) { - await sleep(500); + await new Promise(r => setTimeout(r, 500)); console.log(info); if (info.player) { await this.models.SteamUser.upsert({ From 3cc5ec57b8e77eda233cc7baf3408d3c63092621 Mon Sep 17 00:00:00 2001 From: Skillet Date: Wed, 8 Mar 2023 17:14:41 -0500 Subject: [PATCH 05/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index b90be0f..8fbbe49 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -200,6 +200,12 @@ export default class DBLogPlayerTime extends DBLog { await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.seeding); } } + + async onNewGame(info){ + await super.onNewGame(info); + + console.log(info); + } async onPlayerConnected(info) { console.log(info); From a6c503c624be240310ef4e214eead7a7a9dc9f13 Mon Sep 17 00:00:00 2001 From: Skillet Date: Wed, 8 Mar 2023 17:26:36 -0500 Subject: [PATCH 06/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index 8fbbe49..1529829 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -191,20 +191,28 @@ export default class DBLogPlayerTime extends DBLog { async onUpdatedA2SInformation(info) { await super.onUpdatedA2SInformation(info); - const curDateTime = new Date(); - if ((this.seeding !== ServerState.live) && (info.a2sPlayerCount >= this.options.seedingThreshold)) { - console.log('switching to Live'); - await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.live); - } else if (this.seeding === false && (info.a2sPlayerCount - 20) < this.options.seedingThreshold) { - console.log('switching to seeding'); - await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.seeding); - } +// const curDateTime = new Date(); +// if ((this.seeding !== ServerState.live) && (info.a2sPlayerCount >= this.options.seedingThreshold)) { +// console.log('switching to Live'); +// await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.live); +// } else if (this.seeding === false && (info.a2sPlayerCount - 20) < this.options.seedingThreshold) { +// console.log('switching to seeding'); +// await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.seeding); +// } } async onNewGame(info){ await super.onNewGame(info); console.log(info); + const curDateTime = info.time; + if(info.layer.gamemode === 'Seed'){ + console.log('switching to seeding'); + await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.seeding); + } else { + console.log('switching to Live'); + await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.live); + } } async onPlayerConnected(info) { From 0b34ecb0b57b9209baa7694fc5cf9fbcca8c8fd1 Mon Sep 17 00:00:00 2001 From: Skillet Date: Wed, 8 Mar 2023 17:42:40 -0500 Subject: [PATCH 07/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index 1529829..1bd1ac9 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -85,6 +85,13 @@ export default class DBLogPlayerTime extends DBLog { async mount() { console.log('Mounting db-log'); + if(this.server.currentLayer.gamemode === "Seed"){ + console.log('switching to seeding'); + this.seeding = ServerState.seeding; + } else { + console.log('switching to Live'); + this.seeding = ServerState.live; + } await super.mount(); console.log('finished mounting db-log'); this.server.on('PLAYER_CONNECTED', this.onPlayerConnected); @@ -150,6 +157,7 @@ export default class DBLogPlayerTime extends DBLog { } async updateCurrentTimeState(date, oldState, newState){ + if(oldState === newState) return; const timeNow = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds(); console.log(timeNow); const curPlayer = await this.models.PlayerTimeNew.findAll({ From 616120c0bb6f59374f843d11c633cdd38ca10139 Mon Sep 17 00:00:00 2001 From: Skillet Date: Wed, 8 Mar 2023 17:50:45 -0500 Subject: [PATCH 08/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index 1bd1ac9..985e6b6 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -33,6 +33,8 @@ export default class DBLogPlayerTime extends DBLog { constructor(server, options, connectors) { super(server, options, connectors); + + console.log('WARNING: USING TESTING BRANCH for dblogAddon'); this.seeding = ServerState.init; From 2f3165fc1ee6ada581a6f425c21157da9967b5cb Mon Sep 17 00:00:00 2001 From: Skillet Date: Wed, 8 Mar 2023 18:00:25 -0500 Subject: [PATCH 09/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 1 - 1 file changed, 1 deletion(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index 985e6b6..5102937 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -145,7 +145,6 @@ export default class DBLogPlayerTime extends DBLog { console.log('updated playerTimes row count: %i', rowUpdate[0]); console.log('finish DB repair'); - this.seeding = ServerState.live; } async unmount() { From fb0d48f7cd47c173b3b72a3c4f99d9470e98ed38 Mon Sep 17 00:00:00 2001 From: Skillet Date: Thu, 9 Mar 2023 16:38:56 -0500 Subject: [PATCH 10/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index 5102937..f792f75 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -87,12 +87,14 @@ export default class DBLogPlayerTime extends DBLog { async mount() { console.log('Mounting db-log'); - if(this.server.currentLayer.gamemode === "Seed"){ - console.log('switching to seeding'); - this.seeding = ServerState.seeding; - } else { - console.log('switching to Live'); - this.seeding = ServerState.live; + if(this.server.currentLayer){ + if(this.server.currentLayer.gamemode === "Seed"){ + console.log('switching to seeding'); + this.seeding = ServerState.seeding; + } else { + console.log('switching to Live'); + this.seeding = ServerState.live; + } } await super.mount(); console.log('finished mounting db-log'); From b91d66f5b8f43920f3d155a5875d13210325ba06 Mon Sep 17 00:00:00 2001 From: Skillet Date: Sat, 11 Mar 2023 17:14:08 -0500 Subject: [PATCH 11/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index f792f75..aef6d6d 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -217,12 +217,14 @@ export default class DBLogPlayerTime extends DBLog { console.log(info); const curDateTime = info.time; - if(info.layer.gamemode === 'Seed'){ - console.log('switching to seeding'); - await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.seeding); - } else { - console.log('switching to Live'); - await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.live); + if(info.layer){ + if(info.layer.gamemode === 'Seed'){ + console.log('switching to seeding'); + await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.seeding); + } else { + console.log('switching to Live'); + await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.live); + } } } From 94cdb37e63fb87319513f5c8ee93f1d18ba2c207 Mon Sep 17 00:00:00 2001 From: Skillet Date: Sat, 11 Mar 2023 18:52:27 -0500 Subject: [PATCH 12/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index aef6d6d..c900cb3 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -165,7 +165,7 @@ export default class DBLogPlayerTime extends DBLog { console.log(timeNow); const curPlayer = await this.models.PlayerTimeNew.findAll({ where: { - leaveTime: null, + endTime: null, serverState: oldState, server: this.options.overrideServerID || this.server.id } From b18ea8b223857336bfa290f82f446a0b56058d96 Mon Sep 17 00:00:00 2001 From: Skillet Date: Sat, 11 Mar 2023 21:47:57 -0500 Subject: [PATCH 13/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 1 + 1 file changed, 1 insertion(+) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index c900cb3..0f8042c 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -170,6 +170,7 @@ export default class DBLogPlayerTime extends DBLog { server: this.options.overrideServerID || this.server.id } }); + console.log(curPlayer); await this.models.PlayerTimeNew.update( { endTime: timeNow }, { From 0538f6facef364113003ccb55c9ea384da4b3419 Mon Sep 17 00:00:00 2001 From: Skillet Date: Sun, 12 Mar 2023 19:20:39 -0400 Subject: [PATCH 14/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index 0f8042c..304a9a5 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -171,6 +171,17 @@ export default class DBLogPlayerTime extends DBLog { } }); console.log(curPlayer); + let curplayerarr = []; + for (const oneplayer in curPlayer){ + curplayerarr.push({ + startTime: timeNow, + endTime: null, + serverState: newState, + session: oneplayer.session, + server: oneplayer.server, + player: oneplayer.player + }); + } await this.models.PlayerTimeNew.update( { endTime: timeNow }, { @@ -181,22 +192,9 @@ export default class DBLogPlayerTime extends DBLog { } } ); - await this.models.PlayerTimeNew.bulkCreate(curPlayer,{ + await this.models.PlayerTimeNew.bulkCreate(curplayerarr,{ fields: ['startTime', 'endTime','serverState','session','server','player'] }); - await this.models.PlayerTimeNew.update( - { - serverState: newState, - startTime: timeNow - }, - { - where: { - endTime: null, - serverState: oldState, - server: this.options.overrideServerID || this.server.id - } - } - ); this.seeding = newState; } From f3a31e2d951fddc7ad53417da48d61fc9acf2fc2 Mon Sep 17 00:00:00 2001 From: Skillet Date: Mon, 13 Mar 2023 16:29:01 -0400 Subject: [PATCH 15/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 1 + 1 file changed, 1 insertion(+) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index 304a9a5..0480137 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -182,6 +182,7 @@ export default class DBLogPlayerTime extends DBLog { player: oneplayer.player }); } + console.log(curplayerarr); await this.models.PlayerTimeNew.update( { endTime: timeNow }, { From 329751f8311ddb358760dbc35a61e40988921113 Mon Sep 17 00:00:00 2001 From: Skillet Date: Mon, 13 Mar 2023 16:56:10 -0400 Subject: [PATCH 16/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index 0480137..c00044d 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -172,7 +172,8 @@ export default class DBLogPlayerTime extends DBLog { }); console.log(curPlayer); let curplayerarr = []; - for (const oneplayer in curPlayer){ + for (const oneplayer of curPlayer){ + console.log(oneplayer); curplayerarr.push({ startTime: timeNow, endTime: null, From fc8a7d69f60bdae6b04f06803f813a203a5fcc06 Mon Sep 17 00:00:00 2001 From: Skillet Date: Mon, 20 Mar 2023 12:11:20 -0400 Subject: [PATCH 17/20] use fallback for seeding --- squadjsPlugins/db-log-addOn.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index c00044d..51d1718 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -89,12 +89,19 @@ export default class DBLogPlayerTime extends DBLog { console.log('Mounting db-log'); if(this.server.currentLayer){ if(this.server.currentLayer.gamemode === "Seed"){ - console.log('switching to seeding'); + console.log('starting to seeding'); this.seeding = ServerState.seeding; } else { - console.log('switching to Live'); + console.log('starting to Live'); this.seeding = ServerState.live; } + } else { + if(this.currentLayerRcon.level.includes("Seed")){ + console.log('starting to seeding'); + this.seeding = ServerState.seeding; + } else { + console.log('starting to Live'); + this.seeding = ServerState.live; } await super.mount(); console.log('finished mounting db-log'); @@ -226,6 +233,14 @@ export default class DBLogPlayerTime extends DBLog { console.log('switching to Live'); await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.live); } + } else { + if(this.currentLayerRcon.level.includes("Seed")){ + console.log('switching to seeding'); + await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.seeding); + } else { + console.log('switching to Live'); + await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.live); + } } } From b2a7c7c7a21e21c299caf771220670ee90c8fae5 Mon Sep 17 00:00:00 2001 From: Skillet Date: Mon, 20 Mar 2023 12:17:36 -0400 Subject: [PATCH 18/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 1 + 1 file changed, 1 insertion(+) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index 51d1718..7cb4ac5 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -102,6 +102,7 @@ export default class DBLogPlayerTime extends DBLog { } else { console.log('starting to Live'); this.seeding = ServerState.live; + } } await super.mount(); console.log('finished mounting db-log'); From a1fd20138bf131f61251bc3447d606940187c1b1 Mon Sep 17 00:00:00 2001 From: Skillet Date: Mon, 20 Mar 2023 12:39:53 -0400 Subject: [PATCH 19/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index 7cb4ac5..83b1c96 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -96,7 +96,7 @@ export default class DBLogPlayerTime extends DBLog { this.seeding = ServerState.live; } } else { - if(this.currentLayerRcon.level.includes("Seed")){ + if(this.server.currentLayerRcon.layer.includes("Seed")){ console.log('starting to seeding'); this.seeding = ServerState.seeding; } else { @@ -235,7 +235,7 @@ export default class DBLogPlayerTime extends DBLog { await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.live); } } else { - if(this.currentLayerRcon.level.includes("Seed")){ + if(this.server.currentLayerRcon.layer.includes("Seed")){ console.log('switching to seeding'); await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.seeding); } else { From 9b32103aa16f535d708679884905b7f9af42fe84 Mon Sep 17 00:00:00 2001 From: Skillet Date: Mon, 20 Mar 2023 12:51:13 -0400 Subject: [PATCH 20/20] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index 83b1c96..9309846 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -235,7 +235,7 @@ export default class DBLogPlayerTime extends DBLog { await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.live); } } else { - if(this.server.currentLayerRcon.layer.includes("Seed")){ + if(info.layerClassname.includes("Seed")){ console.log('switching to seeding'); await this.updateCurrentTimeState(curDateTime, this.seeding, ServerState.seeding); } else {