fix:
战令重置定时器时间计算问题修复
This commit is contained in:
parent
e016e708c4
commit
d91c413603
@ -1,5 +1,5 @@
|
|||||||
import {PublicShared} from '../../shared/public/public';
|
import { PublicShared } from '../../shared/public/public';
|
||||||
import {Scheduler, schedulerType} from './scheduler';
|
import { Scheduler, schedulerType } from './scheduler';
|
||||||
|
|
||||||
|
|
||||||
export class SchedulerZhanLing extends Scheduler {
|
export class SchedulerZhanLing extends Scheduler {
|
||||||
@ -12,12 +12,12 @@ export class SchedulerZhanLing extends Scheduler {
|
|||||||
this.isReady = false;
|
this.isReady = false;
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let data = await this.db.findOne({type: this.id});
|
let data = await this.db.findOne({ type: this.id });
|
||||||
if (!data) {
|
if (!data) {
|
||||||
// 开服时间整除战令周期
|
// 开服时间整除战令周期
|
||||||
let round = Math.floor(PublicShared.getOpenServerDay() / G.gc.zhanling.eventOpen.day)
|
let round = Math.floor((PublicShared.getOpenServerDay() - 1) / G.gc.zhanling.eventOpen.day)
|
||||||
let prev_run_time = PublicShared.getToDayZeroTime(G.openTime) + round * G.gc.zhanling.eventOpen.day * 86400
|
let prev_run_time = PublicShared.getToDayZeroTime(G.openTime) + round * G.gc.zhanling.eventOpen.day * 86400
|
||||||
this.db.updateOne({type: this.id}, {$set: {lastRunTime: prev_run_time, round: round}}, {upsert: true});
|
this.db.updateOne({ type: this.id }, { $set: { lastRunTime: prev_run_time, round: round } }, { upsert: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data || G.time > PublicShared.getToDayZeroTime(data.lastRunTime) + 24 * 3600 * G.gc.zhanling.eventOpen.day) {
|
if (!data || G.time > PublicShared.getToDayZeroTime(data.lastRunTime) + 24 * 3600 * G.gc.zhanling.eventOpen.day) {
|
||||||
@ -33,11 +33,11 @@ export class SchedulerZhanLing extends Scheduler {
|
|||||||
// 开服时间整除战令周期
|
// 开服时间整除战令周期
|
||||||
let round = Math.floor(PublicShared.getOpenServerDay() / G.gc.zhanling.eventOpen.day)
|
let round = Math.floor(PublicShared.getOpenServerDay() / G.gc.zhanling.eventOpen.day)
|
||||||
// lastRunTime仅储存最大值,问题记录: 本地多人启动服务时,有调用此定时器的情况下,时间会混乱。
|
// lastRunTime仅储存最大值,问题记录: 本地多人启动服务时,有调用此定时器的情况下,时间会混乱。
|
||||||
await this.db.updateOne({type: this.id}, {$set: {round: round}, $max: {lastRunTime: G.time}}, {upsert: true});
|
await this.db.updateOne({ type: this.id }, { $set: { round: round }, $max: { lastRunTime: G.time } }, { upsert: true });
|
||||||
|
|
||||||
this.startTime = PublicShared.getToDayZeroTime() + 24 * 3600 * G.gc.zhanling.eventOpen.day;
|
this.startTime = PublicShared.getToDayZeroTime() + 24 * 3600 * G.gc.zhanling.eventOpen.day;
|
||||||
this.isStart = false;
|
this.isStart = false;
|
||||||
|
|
||||||
G.mongodb.collection('zhanling').updateMany({type: 'round'}, {$set: {data: {}}});
|
G.mongodb.collection('zhanling').updateMany({ type: 'round' }, { $set: { data: {} } });
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user