fix: method refactor error

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2019-07-10 17:28:08 +08:00
parent 87a863a228
commit 812813da8d
21 changed files with 92 additions and 111 deletions

View File

@@ -13,17 +13,6 @@ import * as os from 'os'
import './constant'
import './log'
let {
TO_ERROR_LOG,
TimeStart,
LOAD_CONST,
LoadParams,
CONST_NAME_ARR,
SaveParams,
SAVE_CONST,
GetDeltaCurrentTime,
} = global
Number.prototype.toStringZ = function(count) {
var strnum = this.toString();
if (strnum.length > count)
@@ -144,7 +133,7 @@ global.LoadParams = function(filename, DefaultValue) {
}
}
catch (err) {
TO_ERROR_LOG("MAINLIB", 100, "Error in file:" + filename + "\n" + err);
global.TO_ERROR_LOG("MAINLIB", 100, "Error in file:" + filename + "\n" + err);
}
return DefaultValue;
};
@@ -157,7 +146,7 @@ global.StartTime = function() {
global.FinishTime = function(Str) {
Str = Str || "";
var TimeFinish = global.GetCurrentTime();
var delta = TimeFinish - TimeStart;
var delta = TimeFinish - global.TimeStart;
console.log(Str + " time: " + delta + " ms");
};
global.CompareItemBufFD = function(a, b) {
@@ -229,10 +218,10 @@ global.CompareItemTimePow = function(a, b) {
};
global.LOAD_CONST = function() {
var Count = 0;
var constants = LoadParams(global.GetDataPath("const.lst"), {});
var constants = global.LoadParams(global.GetDataPath("const.lst"), {});
if (constants) {
for (var i = 0; i < CONST_NAME_ARR.length; i++) {
var key = CONST_NAME_ARR[i];
for (var i = 0; i < global.CONST_NAME_ARR.length; i++) {
var key = global.CONST_NAME_ARR[i];
if (constants[key] !== undefined) {
Count++;
global[key] = constants[key];
@@ -245,12 +234,12 @@ var WasStartSaveConst = false;
function SaveConst() {
var constants = {};
for (var i = 0; i < CONST_NAME_ARR.length; i++) {
var key = CONST_NAME_ARR[i];
for (var i = 0; i < global.CONST_NAME_ARR.length; i++) {
var key = global.CONST_NAME_ARR[i];
if (global[key] !== undefined)
constants[key] = global[key];
}
SaveParams(global.GetDataPath("const.lst"), constants);
global.SaveParams(global.GetDataPath("const.lst"), constants);
WasStartSaveConst = false;
};
global.SAVE_CONST = function(bForce) {
@@ -267,7 +256,7 @@ global.SAVE_CONST = function(bForce) {
function CheckGlobalTime() {
global.ntpClient.getNetworkTime("pool.ntp.org", 123, function(err, NetTime) {
if (err) {
TO_ERROR_LOG("MAINLIB", 110, err);
global.TO_ERROR_LOG("MAINLIB", 110, err);
return;
}
var curTime = new Date;
@@ -278,9 +267,9 @@ function CheckGlobalTime() {
if (Math.abs(global.DELTA_CURRENT_TIME) > 24 * 3600 * 1000)
global.DELTA_CURRENT_TIME = 0;
global.ToLog("Get global time: " + NetTime);
SAVE_CONST();
global.SAVE_CONST();
});
SAVE_CONST();
global.SAVE_CONST();
};
global.CheckGlobalTime = CheckGlobalTime;
global.GetDeltaCurrentTime = function() {
@@ -326,7 +315,7 @@ function GetSecFromStrTime(Str) {
global.GetSecFromStrTime = GetSecFromStrTime;
global.GetCurrentTime = function(Delta_Time) {
if (Delta_Time === undefined)
Delta_Time = GetDeltaCurrentTime();
Delta_Time = global.GetDeltaCurrentTime();
var curTime: any = new Date;
var Time = new Date(curTime - (- Delta_Time));
return Time;
@@ -393,7 +382,7 @@ function GrayConnect() {
return 0;
};
global.GrayConnect = GrayConnect;
var ResConst = LOAD_CONST();
var ResConst = global.LOAD_CONST();
if (global.START_SERVER) {
if (!ResConst) {
CheckGlobalTime();