Skip to content

Commit

Permalink
feat: load idle timeout duration from game json for t0 servers
Browse files Browse the repository at this point in the history
  • Loading branch information
NishantDesai1306 committed Feb 9, 2021
1 parent f8b5f40 commit 9937686
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions engine/core/IgeEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ var IgeEngine = IgeEntity.extend({
return lifeSpan;
},

getIdleTimeoutMs: function () {
var defaultValue = 5;
var idleTimeoutHours = ige.server.tier == '0' ? ige.game.data.defaultData.privateServerIdleTimeout : 0;
var timeoutMins = idleTimeoutHours ? idleTimeoutHours * 60 : defaultValue;

return timeoutMins * 60 * 1000;
},

/**
* Returns an object from the engine's object register by
* the object's id. If the item passed is not a string id
Expand Down Expand Up @@ -959,6 +967,7 @@ var IgeEngine = IgeEntity.extend({
}

if (ige.isServer) {
this.emptyTimeLimit = this.getIdleTimeoutMs();
requestAnimFrame(ige.engineStep);
}

Expand Down Expand Up @@ -2098,6 +2107,7 @@ var IgeEngine = IgeEntity.extend({
var playerCount = ige.$$('player').filter(function (player) { return player._stats.controlledBy == 'human' }).length;

if (playerCount <= 0) {
console.log('self.emptyTimeLimit', self.emptyTimeLimit);
if (!self.serverEmptySince) {
self.serverEmptySince = self.now;
}
Expand Down

0 comments on commit 9937686

Please sign in to comment.