@@ -4594,63 +4594,59 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, {
45944594
45954595
45964596 tick : function ( ) {
4597- /**
4598- * Even if the game is paused, scheduler should still be able to obtain a focus to handle cases like save/load/reset
4599- */
4597+ // Even if the game is paused, scheduler should still be able to obtain a focus
4598+ // to handle cases like save/load/reset
46004599 this . timer . updateScheduledEvents ( ) ;
4601- var fpsElement ;
46024600
4603- if ( this . undoChange ) {
4604- //"Undo button" countdown should still tick while pawsed
4601+ if ( this . undoChange ) {
4602+ // "Undo button" countdown should still tick while pawsed
46054603 this . undoChange . ttl -- ;
4606- if ( this . undoChange . ttl <= 0 ) {
4604+ if ( this . undoChange . ttl <= 0 ) {
46074605 this . undoChange = null ;
46084606 this . _publish ( "server/undoStateChanged" ) ;
46094607 }
46104608 }
4611- if ( this . isPaused ) {
4612- this . ui . update ( ) ; //Still update UI if the player gathers catnip while pawsed or something
4609+ if ( this . isPaused ) {
4610+ // Still update UI if the player gathers catnip while pawsed or something
4611+ this . ui . update ( ) ;
46134612 return ;
46144613 }
46154614
4616-
4617-
4618- var timestampStart = new Date ( ) . getTime ( ) ;
4615+ var timestampStart = Date . now ;
46194616
46204617 this . update ( ) ;
46214618 this . calendar . tick ( ) ;
46224619 this . ticks ++ ;
46234620
4624- var timestampEnd = new Date ( ) . getTime ( ) ;
4625- //if (this.isLocalhost) { //always collect fps metrics
4626- this . totalUpdateTimeTicks ++ ;
4627-
4628- var tsDiff = timestampEnd - timestampStart ;
4629- this . totalUpdateTime [ this . totalUpdateTimeCurrent ] += tsDiff ;
4630- this . totalUpdateTimeCurrent = this . totalUpdateTimeCurrent == 4 ? 0 : this . totalUpdateTimeCurrent + 1 ;
4631-
4632- var avg = ( this . totalUpdateTime [ 0 ] + this . totalUpdateTime [ 1 ] + this . totalUpdateTime [ 2 ] + this . totalUpdateTime [ 3 ] + this . totalUpdateTime [ 4 ] ) / this . totalUpdateTimeTicks ;
4633- var avg0 = this . totalUpdateTime [ 0 ] / Math . floor ( ( this . totalUpdateTimeTicks - 1 ) / 5 ) ;
4634- var avg1 = this . totalUpdateTime [ 1 ] / Math . floor ( ( this . totalUpdateTimeTicks - 2 ) / 5 ) ;
4635- var avg2 = this . totalUpdateTime [ 2 ] / Math . floor ( ( this . totalUpdateTimeTicks - 3 ) / 5 ) ;
4636- var avg3 = this . totalUpdateTime [ 3 ] / Math . floor ( ( this . totalUpdateTimeTicks - 4 ) / 5 ) ;
4637- var avg4 = this . totalUpdateTime [ 4 ] / Math . floor ( ( this . totalUpdateTimeTicks - 5 ) / 5 ) ;
4638-
4639- if ( tsDiff < 10 ) {
4640- tsDiff = 10 ;
4641- }
4642- this . fps = {
4643- ms : tsDiff ,
4644- avg : avg ,
4645- avg0 : avg0 ,
4646- avg1 : avg1 ,
4647- avg2 : avg2 ,
4648- avg3 : avg3 ,
4649- avg4 : avg4
4650- } ;
4651- //}
4621+ var timestampEnd = Date . now ;
4622+
4623+ this . totalUpdateTimeTicks ++ ;
4624+
4625+ var tsDiff = timestampEnd - timestampStart ;
4626+ this . totalUpdateTime [ this . totalUpdateTimeCurrent ] += tsDiff ;
4627+ this . totalUpdateTimeCurrent = this . totalUpdateTimeCurrent == 4 ? 0 : this . totalUpdateTimeCurrent + 1 ;
4628+
4629+ var avg = ( this . totalUpdateTime [ 0 ] + this . totalUpdateTime [ 1 ] + this . totalUpdateTime [ 2 ] + this . totalUpdateTime [ 3 ] + this . totalUpdateTime [ 4 ] ) / this . totalUpdateTimeTicks ;
4630+ var avg0 = this . totalUpdateTime [ 0 ] / Math . floor ( ( this . totalUpdateTimeTicks - 1 ) / 5 ) ;
4631+ var avg1 = this . totalUpdateTime [ 1 ] / Math . floor ( ( this . totalUpdateTimeTicks - 2 ) / 5 ) ;
4632+ var avg2 = this . totalUpdateTime [ 2 ] / Math . floor ( ( this . totalUpdateTimeTicks - 3 ) / 5 ) ;
4633+ var avg3 = this . totalUpdateTime [ 3 ] / Math . floor ( ( this . totalUpdateTimeTicks - 4 ) / 5 ) ;
4634+ var avg4 = this . totalUpdateTime [ 4 ] / Math . floor ( ( this . totalUpdateTimeTicks - 5 ) / 5 ) ;
4635+
4636+ if ( tsDiff < 10 ) {
4637+ tsDiff = 10 ;
4638+ }
4639+ this . fps = {
4640+ ms : tsDiff ,
4641+ avg : avg ,
4642+ avg0 : avg0 ,
4643+ avg1 : avg1 ,
4644+ avg2 : avg2 ,
4645+ avg3 : avg3 ,
4646+ avg4 : avg4
4647+ } ;
46524648
4653- //collect fps info every minute or so
4649+ // Collect fps info every minute or so
46544650 if ( this . ticks % ( this . ticksPerSecond * 60 ) == 0 && this . telemetry ) {
46554651 var memory = null ;
46564652 if ( window . performance && window . performance . memory ) {
0 commit comments