Skip to content
This repository was archived by the owner on Feb 9, 2020. It is now read-only.

Commit f26ecec

Browse files
committed
what i hope to be, more accurate tick calculation
1 parent b5cafa7 commit f26ecec

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/pocketnode/Server.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class Server {
151151
this.getLogger().info("Done ("+(Date.now() - this.PocketNode.START_TIME)+"ms)!");
152152

153153
this.tickProcessor();
154+
//this.forceShutdown();
154155
}
155156

156157
registerDefaultCommands(){
@@ -486,14 +487,15 @@ class Server {
486487
}
487488

488489
tickProcessor(){
489-
let int = setInterval(() => {
490+
let int = createInterval(() => {
490491
if(this.isRunning()){
491492
this.tick();
492493
}else{
493494
//this.forceShutdown();
494-
clearInterval(int);
495+
int.stop();
495496
}
496497
}, 1000 / 20);
498+
int.run();
497499
}
498500

499501
getRakNetAdapter(){
@@ -513,8 +515,8 @@ class Server {
513515
}
514516

515517
let now = Date.now();
516-
this._currentTPS = Math.min(20, 1 / Math.max(0.001, now - time));
517-
this._currentUse = Math.min(1, (now - time) / 0.05);
518+
this._currentTPS = Math.min(20, 1000 / Math.max(1, now - time));
519+
this._currentUse = Math.min(1, (now - time) / 50);
518520

519521
this._tickAverage.shift();
520522
this._tickAverage.push(this._currentTPS);

0 commit comments

Comments
 (0)