Link doesn't fill up target link, stuck at 799



  • As you can see in replay link: https://screeps.com/a/#!/history/E36S32?t=14525440 despite the near-sources links transferring to the near-controller link, it doesn't fill up to 800. Instead it seems stuck at 799.

    I wanted to see what's going on there; maybe some decimal value snuck in there somehow but no luck:

    ```Game.getObjectById('5797e8674596861a413fe9aa').energy
    799```

    I also checked with Laszlo, owner, and his code doesn't specify amount in transferEnergy, so it must be somewhere in game code.

    Thanks for looking into it!



  • The cost of the transfer is taken from the energy sent. You can't send more than the link can carry, so that cost will always be missing at the other end.



  • And that sounds like a bug because this means you are never able to send one energy. In which case, a better response would be for transferEnergy to either throw an appropriate error or take the cost of 2nd energy from the link if available (seems convoluted).



  • The cost should be taken from the sender's leftover energy, if it's not sending its full contents. That would resolve this problem.



  • So if I have a link with 800 energy and I want to send it to an empty link, I should have to do the math to work out how much I'm allowed to send with the 3% tax? How is that any different from you just adding a check to make sure you don't send to links that are above a specific threshold?

    I can't think of any possible circumstance in which I would want to send 1 energy via link.

    I don't really see how this is a problem



  • You shouldn't have to do any extra math if you don't want to. If you have enough energy to fill up the target and pay the fee, you should be able to do so without even specifying an amount to send.



  • No one is suggesting sending just 1 energy, that was just a degenerate case example. What we want is to be able to send the amount of energy that will fill the target, whether that's 1 or 100 or 700.



  • But if you don't want the cost coming from the energy your sending, then how will I transfer 800 energy to an empty link? The 3% has to come from somewhere and from the energy being transfered is the simplest solution. Otherwise they need to add in more checks to work out where the tax is coming from when the majority of players probably don't really care.



  • No one would have to add more checks. If necessary, the current behavior could be kept completely for any transaction that currently works, and no one would have to change anything about existing code that isn't already attempting invalid transactions.



  • Say I have two links with 600 energy in them, and I would like for one of them to have 800 in it.

    Currently I can send 200, and 194 gets there, 6 eaten by the fee, so now I've got 400 and 794. That could still work exactly as it does now.

    If I try to send 207 now, I get an error, because 207 is more than will fit in the target. But that's silly, because not all 207 is going to make it to the target. Instead, an attempt to send 207 should work, and I should end up with 393 and 800 in the links.