An interesting side note about this bug, it wouldn't affect battles where you zeroed out the defender. Which is how the bug stayed pretty well hidden, because so many people were getting zeroed out.
I couldn't have tracked it down without super detailed battle reports too, which has the raw attack stats. TheKeeper just made a tool for us that is recording everyone's battles with the raw data, and that was just done like yesterday, so before that wouldn't have been able to dig in to such detail.
It took like 4 hours to figure out. The only really sucky part was I fed the massive raw data dump to AI hoping it could parse the important parts for me, but it failed massively. Once I finally (desperately) hand-sorted through the data dump the issue became apparent real quick. It was literally something like defender started with 1000 of unit1, casualties of 850 on unit1, survivors of 850 on unit1.
In close battles where attack/defense losses were pretty equal, the bug wouldn't really matter = defender has 500 units, 250 die, 250 survive (but the 250 that survived are actually the dead ones lol). In battles where you should have won by a fair margin would likely be the worst result, where the defender starts with 1000 units, 900 units die, 900 units survive, defender wins.
The other interesting aspect of this bug is that it also affected the final battle summary for the attacker as well. Meaning if you had sent 100 units and 90 died, the summary would report that 90 survived the battle. Conversely, if you sent 100 units and only 10 died, the summary would report that you had 10 survivors.
This is likely why we saw many battles where people got clapped with really low survivors. Instead of only having 10% of your force survive, you probably should have had 90% survive, but you got the bug.
I think this bug is the cause of 90% of battle problems we've had so far. It's crazy... I was in a rush making the fix, so I'm only 99% sure it's good - which is fine, because now that we know that bug exists we can easily look for it and adjust my fix as needed, if needed.