Steamhammer reserved resource bug
Today I fixed the Steamhammer bug that sometimes had the building manager reserve minerals and gas and not release them. When I put in debugging code, the error turned out to be much more common than I suspected. In the first test game after fixing the bug, late game macro went from sometimes spotty to smooth and strong, and Steamhammer scored a win over McRave from a situation where it never had before. The bug deserved earlier attention than it got.
The error was that one caller of undoBuildings()
skipped out on its responsibility to release resources when buildings were canceled or unable to be started. (undoBuildings()
is a Steamhammer addition, so the bug does not affect UAlbertaBot or early Steamhammer forks, at least not in the same form.) I fixed it by moving the responsibility of releasing resources from the caller into undoBuildings()
itself, adding these lines:
// If the building is not yet under construction, release its resources. if (b.status == BuildingStatus::Unassigned || b.status == BuildingStatus::Assigned) { _reservedMinerals -= b.type.mineralPrice(); _reservedGas -= b.type.gasPrice(); }
Of course those callers that release resources have to be changed so they don’t. Not all of them are supposed to—sometimes the building is under construction and the resources are already released.
Don’t trust this bug fix too much. There could be more bugs. I left the debugging code in for now, so if there are more building resource issues, or mistakes in the fix, then I should find them before the 1.4 release.
Comments
Tully Elliston on :
Jay Scott on :