-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix canRepair() not working for ZCOUNIT units #1791
Conversation
moved the conditional from replenishUnit to canRepair, for ease of use
If both types call the same function, there's no chance for mismatches
Allows for overriding a specific building type's canRepair()
game/building.cpp
Outdated
@@ -1164,13 +1164,20 @@ float Building::getTerrainAnimationMoveSpeed() | |||
} | |||
} | |||
|
|||
bool Building::canRepair(Unit* pUnit) | |||
bool Building::canRepair(Unit* pUnit, bool always = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong.
The line in the header building.h should be:
Q_INVOKABLE bool canRepair(Unit* pUnit, bool always = false);
The line in the header building.cpp should be:
bool Building::canRepair(Unit* pUnit, bool always)
I know I can fix after the PR, but I would prefer it the other way around.
You're code wouldn't compile atm.
canRepair()
only usesbuilding.getConstructionList()
so farthe actual
BUILDING.replenishUnit()
uses bothbuilding.getConstructionList()
andbuilding.getRepairTypes()
so there's a mismatch for the units that have a matching type, but aren't in the construction list (the ZCOUNIT units)
BUILDING.replenishUnit()
intoBUILDING.canRepair()
building.canRepair()
to use the js<BUILDING_TYPE>.canRepair()