PowerCreeps - Sporadic Loss of PowerCreep.memory
-
Randomly, some of my power creeps will lose access to their .memory shortcut point to Memory.powerCreeps[name] and I'll receive errors saying "powercreep.memory is undefined." This is not every tick and when it happens it does not affect every power creep.
-
I added a check to set .memory if it wasn't set and I get this interesting error as a result:
Power Creep Processing error Could not set other player's creep memory Error: Could not set other player's creep memory at Object.set (:40507:23) at Object.processPowerCreeps (main:12431:18) <-- only part of this that is my code at Object.module.exports.loop (main:12935:8) <-- only part of this that is my code at __module (__mainLoop:1:52) at __mainLoop:2:3 at Object.exports.evalCode (:15990:76) at Object.exports.run (:30481:24) at global._init.global._start (:29710:22)
-
Can confirm this error, was just sitting and debugging a similar case.
I'm extending prototypes, and this gives a similar error of memory is undefined at infrequent intervals:
PowerCreep.prototype.getHomeroom = function (): string { return this.memory.homeroom; }
-
So
Memory.powerCreeps[name]
exists, butGame.powerCreeps[name].memory
is undefined?
-
I'll try to setup some tests to check that, tell me if there's anything else you would like me to try to capture about the tick or environment.
I saw it maybe two-three times in total last night, without any obvious system.
-
It appears that if another player's power creep is "visible" to your game instance, it's being added to Game.powerCreeps. The sporadic nature is coming from my observers passively scanning the map...
I don't think other's power creeps should be in my Game.powerCreeps list.
-
agreed. that isnt consistent with the pre-existing API...
-
Nice catch! Thanks, fixed.
-
That explains it, I'm not checking if I'm the owner when I run foreach on all PCs in Game.powerCreeps.