I have two instances of global right now. As I use generators a lot in my latest codebase it had a bad consequences. Creeps were moving back and forth because different global instances had different targets for them. I made a fix for now, it detects if current globalId is different from lastGlobalId and restarts the threads. But I can imagine how other players code that relies on global or generators can suffer.
Maybe you can add global detection on server side. Simply adding id to global (maybe name that property _id
) and storing lastGlobalId per player in some storage will allow you to monitor how often it happends and restart runner containers for that players.
Here is the method I used to detect multiple globals:
let globalIndex = Memory.globalIndex = (Memory.globalIndex || 0) + 1;
Memory.lastGlobalIndex = globalIndex;
function checkGlobal() {
if (globalIndex !== Memory.lastGlobalIndex) {
console.log('2 globals!', 'globalIndex:', globalIndex, 'lastGlobalIndex:', Memory.lastGlobalIndex);
Memory.lastGlobalIndex = globalIndex;
fixGlobals(); // some logic to fix
} else {
console.log('globalIndex:', globalIndex);
}
};
module.exports.loop = function() {
checkGlobal();
// ... other code
};
You can use similar method but instead of memory save this 2 variables (globalIndex
and lastGlobalIndex
) in some database per each player (maybe per shard also).