bug ? : room.energyAvailable counts inactive extensions


  • SUN

    I'm using energyAvailable property to determine if there is an extension that needs filling . However if some extensions are inactive due to RCL being too low, energyAvailable seems to count them anyway


  • Culture

    This goes back to a very annoying function and expensive that decides what is active/inactive.
    They don't store the state of what is active or inactive so those variables, which are decided before the tick begins, can't be modified as such.

    If they did store the active state of structures, they could include the state in that calculation as well.


  • SUN

    yes, that's actually why i was testing energyAvailable before finding active non empty extensions.


  • SUN

    Looks like this has never been fixed, I was checking my rooms after a long inactivity period and I can still see it happen.

    Here is i posted on slack last night, with my findings

    I have a room (W61S45) with disabled structures (extensions). That room reports energyAvailable < energyCapacitAvailable (1750<1800). BUT Game.rooms.W61S45.find(FIND_STRUCTURES, {filter: { structureType: STRUCTURE_EXTENSION }}).filter(s=>s.energy < s.energyCapacity && s.isActive()) reports no extension.

    looks like the extensions counted for energyAvailable are not the active ones, anyone faced this already ? (notable to say that the displayed status of the extensions is off too, extension at 39,14 is shown active , but isActive returns false, meanwhile the one at 43,14 is the opposite [active but showed inactive])

    This should be fixed so that inactive status of structures is consistent across the various APIs ... Due to the highly inefficient way isActive() is implemented, you can't expect players to have to call it every time (especially as the implementation lets me think the order may not be consistent over time either).

    As my code will only spawn creeps when energyAvailable == energyCapacityAvailable the only way out I found is to refill all extensions, including inactive ones which is a shame

    👍🏻👀


  • Still a thing. I ran into this just today. My fix is much like yours: Just go ahead and fill the inactive extensions, and hope for the best.

    Come to think of it, it's pretty odd that we can refill inactive extensions.

    👆


  • I wrote a small constant array that has the "max E amounts" for each RCL.
    Not pretty and doesn't cover a lot of edge cases but works as a cheap workaround for this issue.