diff --git a/game-server/app/services/timeTaskService.ts b/game-server/app/services/timeTaskService.ts index 59beb0aac..e3578afcd 100644 --- a/game-server/app/services/timeTaskService.ts +++ b/game-server/app/services/timeTaskService.ts @@ -645,10 +645,15 @@ export async function stopMaintenance(batchCode: string, serverIds: number[]) { // —————————————— 自动开服 —————————————— // export async function initAutoCreateServer(region?: RegionType) { if(!region) region = await RegionModel.findRegionByEnv(pinus.app.get('env')); - if(region && region.stategy) { - for(let timer of region.stategy.timers) { - setStategyTimer(timer, region) - } + if(region && region.stategy && region.stategy.isOpen) { + for(let timer of region.stategy.timers) { + setStategyTimer(timer, region) + } + } else { + if(scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`]) scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`].cancel(); + if(scheduledJobs[`autoServer${SERVER_TIMER.TEN_HALF}`]) scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`].cancel(); + if(scheduledJobs[`autoServer${SERVER_TIMER.FIFTEEN_HALF}`]) scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`].cancel(); + if(scheduledJobs[`autoServer${SERVER_TIMER.NINETEEN_HALF}`]) scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`].cancel(); } } diff --git a/shared/db/ServerStategy.ts b/shared/db/ServerStategy.ts index 92a58fc35..36dc58c10 100644 --- a/shared/db/ServerStategy.ts +++ b/shared/db/ServerStategy.ts @@ -53,6 +53,9 @@ export class GMMail { export default class ServerStategy { + @prop({ required: true, default: false }) + isOpen: boolean; // 是否开启 + @prop({ required: true, default: 0 }) maxPlayerCnt: number; // 人数上限 @@ -72,6 +75,7 @@ export default class ServerStategy { stopRegisterTime: number; // 关闭注册时间 constructor(stategy: ServerStategyUpdate & { hasOpenMail: boolean, hasCircleMail: boolean}) { + this.isOpen = stategy.isOpen; this.maxPlayerCnt = stategy.maxPlayerCnt; this.timers = stategy.timers; this.activityGroupId = stategy.activityGroupId; diff --git a/shared/domain/backEndField/params.ts b/shared/domain/backEndField/params.ts index 9d53d4b13..c1ccf3006 100644 --- a/shared/domain/backEndField/params.ts +++ b/shared/domain/backEndField/params.ts @@ -84,6 +84,7 @@ export class UpdateRegionParams { openMail?: GMMail; circleMail?: GMMail; stopRegisterTime: number = 0; + isOpen: boolean = false; hasOpenMail: boolean = false; hasCircleMail: boolean = false; @@ -95,9 +96,14 @@ export class UpdateRegionParams { } checkParams() { - if(!this.id || !this.name || !this.prefix || !this.maxPlayerCnt || !isArray(this.timers) || this.timers.length <= 0 || !isArray(this.activityGroupId) || this.activityGroupId.length <= 0 || !isString(this.versionCode) || !isString(this.curVersion) || !isString(this.updateResUrl)) { + if(!this.id || !this.name || !this.prefix || !isString(this.versionCode) || !isString(this.curVersion) || !isString(this.updateResUrl)) { + console.log('1111', !this.id, !this.name, !this.prefix, !isString(this.versionCode),!isString(this.curVersion), !isString(this.updateResUrl)) return false } + if(this.isOpen && (!this.maxPlayerCnt || !isArray(this.timers) || this.timers.length <= 0 || !isArray(this.activityGroupId) || this.activityGroupId.length <= 0 )) { + console.log('2222') + return false + } return true; }