Empty tombstones not having RESOURCE_ENERGY initialized to 0



  • Originally discovered on Slack by user Haxxeris, but I did more digging on it.

    Which shard is affected?

    shard1 here, but likely present on others too.

    What happened?

    Tombstone.store.energy returns undefined

    What should have happened?

    Returned 0, as per the specification.

    How can we reproduce this?

    Just check the Tombstone.store property on any empty tombstone in game.

    Piece of code which shows the bug in action

    5ba55c9e77a81a081d628d39 is an ID to a tombstone of a freshly expired creep. It's empty. The following were a series of console commands executed to illustrate the issue.

    > Game.getObjectById('5ba55c9e77a81a081d628d39').store
    < [object Object]
    
    > Game.getObjectById('5ba55c9e77a81a081d628d39').store.energy
    < undefined
    
    > Game.getObjectById('5ba55c9e77a81a081d628d39').store[RESOURCE_ENERGY]
    < undefined
    
    > _.sum(Game.getObjectById('5ba55c9e77a81a081d628d39').store)
    < 0
    
    > JSON.stringify(Game.getObjectById('5ba55c9e77a81a081d628d39').store)
    < {}
    

    For comparison, Creep.carry always returns RESOURCE_ENERGY set to 0, even when empty:

    > JSON.stringify(Game.getObjectById('5ba55cdb1c9b012b543460f9').carry)
    < {"energy":0}
    

    edit: yay, actually made the post have a proper title now. sorry about that.


  • Dev Team

    Thanks for your report, we'll fix that.


  • Dev Team

    Hi Orlet,

    Any idea how do I reproduce the issue?

    I checked fresh empty tombstones at public the private server, both returns {"energy":0} object for empty tombstones, as expected.



  • Issue still persists. Reproduction steps are as I stated earlier: grab a fresh empty tombstone's id, and plug it into console:

    > JSON.stringify(Game.getObjectById('5ba66b3c3ac6f939b19757b1').store)
    < {}
    

    This is fresh from live server, shard1.


  • Dev Team

    @orlet Could you please check if the issue in place at the very beginning of the main loop before a single line of your code executes? Or, which is better, with empty main loop?



  • I also see this. eg.

    > JSON.stringify(Game.rooms.W5S28.find(FIND_TOMBSTONES)[0].store)
    < {}
    

    Could there be a difference between tombstones that have been withdrawn from and those that are fresh?



  • @o4kapuk okay, i think i may have gotten another clue for you:

    For tombstone out in the open, after my hauler has emptied it (it spawned with 38 energy the creep's been carrying):

    > JSON.stringify(Game.getObjectById('5ba6921dd517936b12501ee6').store)
    [10:05:04 PM] [shard1]{"energy":0} // this is from first line in the main loop
    < {"energy":0}
    

    But when my miner dies on a container, it produces a bugged tumbstone (when a creep dies on a container, all the resources it had go into the container directly):

    > JSON.stringify(Game.getObjectById('5ba692c4e985a57c13ba2444').store)
    < {}
    [10:07:24 PM][shard1]{} // first line in the main loop
    

    Some more dead miner tombstones:

    > JSON.stringify(Game.getObjectById('5ba693a7f967a625513fed24').store)
    < {}
    > JSON.stringify(Game.getObjectById('5ba692c4e985a57c13ba2444').store)
    < {}
    

    And here's one for a creep that expired naturally without anything in its CARRY:

    > JSON.stringify(Game.getObjectById('5ba6974514436118b485ca51').store)
    < {}
    [10:25:22 PM] [shard1]{} // from main loop's first line
    

    So I think @Tigga is correct. This seems to be a bug with tombstones that naturally spawn empty.


  • Dev Team

    Should be solved now (can't longer reproduce this)



  • Confirm, it appears to be solved now. All the cases where I've seen it manifest are no longer empty objects.