Skip to content

Commit

Permalink
πŸš‘ fix potential cpu leak
Browse files Browse the repository at this point in the history
  • Loading branch information
o4kapuk committed Nov 18, 2023
1 parent 595ed96 commit 32c36a4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/game/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
C = driver.constants,
map = require('./map'),
market = require('./market'),
customPrototypes = require('./custom-prototypes');
customPrototypes = require('./custom-prototypes'),
system = { Function: { bind: Function.bind } };

var findCacheFn = {
[C.FIND_CREEPS]: (i) => !i.spawning,
Expand Down Expand Up @@ -505,7 +506,7 @@
!_.isObject(runCodeCache[userId].globals.require.cache.main) || !_.isFunction(
runCodeCache[userId].globals.require.cache.main.loop)) {

runCodeCache[userId].globals.require = requireFn.bind(runCodeCache[userId]);
runCodeCache[userId].globals.require = system.Function.bind.call(requireFn, runCodeCache[userId]);
runCodeCache[userId].globals.require.cache = {lodash: runCodeCache[userId].globals._};
runCodeCache[userId].globals.require.timestamp = runCodeCache[userId].runtimeData.userCodeTimestamp;
}
Expand Down

0 comments on commit 32c36a4

Please sign in to comment.