[Flags] createFlag call fails multiple times before succeeding if vision is lost next tick


  • Culture

    Issue:

    http://i.imgur.com/8Ws0Pi4.png

    Code:

    var flagResult = theRoom.createFlag(pb.pos, theRoom.name + '_pb_' + pb.id, COLOR_GREY, COLOR_PURPLE);
    log("Found minable powerbank in " + padRoomName(theRoom.name) + ' distance from spawn: [' + range + '] - ' + pb.ticksToDecay + ' - Power:' + pb.power + " flag: " + flagResult, "pb");

     

    It has to run multiple times before the location gets marked.

     



  • I did some testing and found the same.

    on my first test i used an observer to get visibility on the following tick if there was none on this tick, so it attempted to create the flag every 2nd tick and finally succeeded on the 3rd try(6 ticks). Each try would appear to succeed ie. returns the name of the flag.

    My 2nd test i set the observer to gain visibility every tick and attempted to place the flag, i left it trying for about 20 ticks, each tick it appeared to succeed (returning the flag name) but never showed up in game. I canceled the test and went into one of my rooms to do some stuff, when i placed a flag in my owned room manually the one the test was trying to create suddenly appeared at the same time.

    A further test when i had the code only attempt to place the flag once came back as successful but no flag appeared, i left it and after about 20 minutes i closed and reopened the game and the flag was there. It was not there when i closed the game and was not visible in the Game.flags either until the restart.

     

    All the test flags i did were all named similar to Dissi's and if the flag was created properly i should have got a return code of -3 on the next attempt

    My flag name was:

    theRoom.name + '_pb_'

  • Culture

    Artem, can you check what's wrong or confirm this indeed a bug? Maybe give a workaround on how to deal with it.



  • OCS has been bitten by this bug very badly. It appears that the majority of the time flags created programmatically are only eventually consistent.


  • Culture

    Still happening, can the devs please look into this issue?



  • I keep teaching new OCS contributors about this issue. Flag cloaking and pre-populating the memory are the only workarounds. This also means we should set the color and secondary color in memory before the flag shows up. The extra complexity is no fun 😉