Skip to content
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

Merged
merged 11 commits into from
Apr 28, 2024

Conversation

MrDuck557
Copy link
Contributor

canRepair() only uses building.getConstructionList() so far
the actual BUILDING.replenishUnit() uses both building.getConstructionList() and building.getRepairTypes()
so there's a mismatch for the units that have a matching type, but aren't in the construction list (the ZCOUNIT units)

  • Moved the conditional in BUILDING.replenishUnit() into BUILDING.canRepair()
  • Changed building.canRepair() to use the js <BUILDING_TYPE>.canRepair()

@@ -1164,13 +1164,20 @@ float Building::getTerrainAnimationMoveSpeed()
}
}

bool Building::canRepair(Unit* pUnit)
bool Building::canRepair(Unit* pUnit, bool always = false)
Copy link
Owner

@Robosturm Robosturm Apr 27, 2024

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.

@Robosturm Robosturm merged commit 1e9043f into Robosturm:master Apr 28, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants