I have seen at least 3 reports about weird bugs in Bladeburner. All of them are caused by wrong sleeveSize.
sleeveSize is the number of Sleeves doing SleeveSupportWork. It's used in 2 places:
resolveTeamCasualties: Only run when the action is complete.
getSuccessChance of Recruitment action.
When a sleeve is assigned this task, sleeveSize is increased by 1. When that sleeve is assigned another task, sleeveSize is decreased by 1. At any moment, sleeveSize is just Player.sleevesSupportingBladeburner().length. In those reports, sleeveSize value is always wrong. There is even a report with 2-digit sleeveSize.
I have not found the root cause of this bug. When it happens, the player usually cannot recruit team members anymore. This PR mitigates this problem by calculating sleeveSize when it's needed. Reasons:
This bug is subtle. I'm not sure when we can fix it.
After we fix it, we still need to add code to recalculate sleeveSize after loading to fix the potentially wrong save data.
I don't know why this variable was added in the past. Maybe it was added to avoid checking Player.sleeves every time it was used. IMO, the performance gain is within margin error.
How to test:
Load the attached save file from Discord.
Check the success chance of Recruitment. It's 0% without this change. With this change, it's 100%.
I have seen at least 3 reports about weird bugs in Bladeburner. All of them are caused by wrong
sleeveSize
.sleeveSize
is the number of Sleeves doingSleeveSupportWork
. It's used in 2 places:resolveTeamCasualties
: Only run when the action is complete.getSuccessChance
of Recruitment action.When a sleeve is assigned this task,
sleeveSize
is increased by 1. When that sleeve is assigned another task,sleeveSize
is decreased by 1. At any moment,sleeveSize
is justPlayer.sleevesSupportingBladeburner().length
. In those reports,sleeveSize
value is always wrong. There is even a report with 2-digitsleeveSize
.I have not found the root cause of this bug. When it happens, the player usually cannot recruit team members anymore. This PR mitigates this problem by calculating
sleeveSize
when it's needed. Reasons:sleeveSize
after loading to fix the potentially wrong save data.Player.sleeves
every time it was used. IMO, the performance gain is within margin error.How to test:
Attached save file: bitburnerSave_1730536908_BN10x3.json.gz