Fix for empty SPNG/GEL bug

  • camtech56
    24th Jul 2016 Member 0 Permalink

    As of me making this post, I have noticed that if GEL and SPNG are empty(life of SPNG = 0 and tmp of GEL = 0), then a fake WATR is created. The gel takes WATR particle from SPNG, even though it has none. This causes the SPNG to have a life of -1 and the gel to have a tmp of 1. A frame later, the gel will move the fake WATR particle back into the SPNG, and making the SPNG and GEL return to having zeros in their life and tmp values respectively. I have figured out that this is caused in GEL's update code at line 103.

     

    if (parts[i].tmp<100 && ((parts[r>>8].life+1)>parts[i].tmp))


    If I plugged 0 in for both the tmp and life, then this will evaluate as true as 0<100 && 0+1>0 is true. Lines 104 to 107 would execute and cause the fake WATR to be created. A possible fix for this is to see if the SPNG has a life value above 0.

     

    if (parts[i].tmp<100 && ((parts[r>>8].life+1)>parts[i].tmp) && parts[r>>8].life)

     

    This is a possible replacement of line 103. By including "&& parts[r>>8].life" into the if statement, it will check to see if the SPNG's life is a nonzero number. "&& parts[i].tmp" could be used in conjuctiuon or in replacement of using SPNG's life value.

     

    if (parts[i].tmp<100 && ((parts[r>>8].life+1)>parts[i].tmp) && parts[r>>8].life && parts[i].tmp)


    It is also possible to add "if (!(parts[i].tmp) || !(parts[r>>8].life)) break;" between lines 102 and 103 to prevent any transfer of WATR between the SPNG and GEL if there is no WATR in either particle.

     

    if (!(parts[i].tmp) || !(parts[r>>8].life)) break;

    if (parts[i].tmp<100 && ((parts[r>>8].life+1)>parts[i].tmp))

     

  • jacksonmj
    26th Jul 2016 Developer 0 Permalink

    Fixed in https://github.com/simtr/The-Powder-Toy/commit/fdb539064d0f0c0cef7b4c8fc64ddcdccfa910d9

     

    Thanks for reporting this and tracking down the cause :)

    Edited once by jacksonmj. Last: 26th Jul 2016