-
Notifications
You must be signed in to change notification settings - Fork 79
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
"Show enemy productivity overlay" cheat #1738
base: master
Are you sure you want to change the base?
Changes from all commits
9659bd5
503f766
ce9e1d9
35a55bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,12 +48,16 @@ BOOST_FIXTURE_TEST_CASE(TurningCheatModeOffDisablesAllCheats, CheatsFixture) | |
{ | ||
cheats.toggleCheatMode(); | ||
cheats.toggleAllVisible(); | ||
BOOST_TEST_REQUIRE(cheats.isAllVisible() == true); | ||
cheats.toggleAllBuildingsEnabled(); | ||
cheats.toggleShowEnemyProductivityOverlay(); | ||
BOOST_TEST_REQUIRE(cheats.isAllVisible() == true); | ||
BOOST_TEST_REQUIRE(cheats.areAllBuildingsEnabled() == true); | ||
BOOST_TEST_REQUIRE(cheats.shouldShowEnemyProductivityOverlay() == true); | ||
|
||
cheats.toggleCheatMode(); | ||
BOOST_TEST_REQUIRE(cheats.isAllVisible() == false); | ||
BOOST_TEST_REQUIRE(cheats.areAllBuildingsEnabled() == false); | ||
BOOST_TEST_REQUIRE(cheats.shouldShowEnemyProductivityOverlay() == false); | ||
// testing toggleHumanAIPlayer would require GameClient::state==Loaded, which is guaranteed in code (because Cheats | ||
// only exist after the game is loaded) but is not the case in tests - skipping | ||
} | ||
|
@@ -107,18 +111,31 @@ BOOST_FIXTURE_TEST_CASE(CanToggleAllVisible_IfCheatModeIsOn, CheatsFixture) | |
BOOST_TEST_REQUIRE((viewer.GetVisibility(farawayPos) == Visibility::Visible) == true); | ||
} | ||
|
||
BOOST_FIXTURE_TEST_CASE(CanToggleAllBuildingsEnabled_IfCheatModeIsOn, CheatsFixture) | ||
BOOST_FIXTURE_TEST_CASE(CanToggleAllBuildingsEnabled_AndShowEnemyProductivityOverlay_IfCheatModeIsOn, CheatsFixture) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the increasing length in name and that the first 6 lines seem to test the opposite I'd suggest to name this something like |
||
{ | ||
BOOST_TEST_REQUIRE(cheats.areAllBuildingsEnabled() == false); | ||
BOOST_TEST_REQUIRE(cheats.shouldShowEnemyProductivityOverlay() == false); | ||
|
||
cheats.toggleAllBuildingsEnabled(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test should be exactly after the call to make sure that e.g.
|
||
cheats.toggleShowEnemyProductivityOverlay(); | ||
BOOST_TEST_REQUIRE(cheats.areAllBuildingsEnabled() == false); | ||
BOOST_TEST_REQUIRE(cheats.shouldShowEnemyProductivityOverlay() == false); | ||
|
||
cheats.toggleCheatMode(); | ||
cheats.toggleAllBuildingsEnabled(); | ||
cheats.toggleShowEnemyProductivityOverlay(); | ||
BOOST_TEST_REQUIRE(cheats.areAllBuildingsEnabled() == true); | ||
BOOST_TEST_REQUIRE(cheats.shouldShowEnemyProductivityOverlay() == true); | ||
|
||
cheats.toggleAllBuildingsEnabled(); | ||
cheats.toggleShowEnemyProductivityOverlay(); | ||
BOOST_TEST_REQUIRE(cheats.areAllBuildingsEnabled() == false); | ||
BOOST_TEST_REQUIRE(cheats.shouldShowEnemyProductivityOverlay() == false); | ||
|
||
cheats.toggleAllBuildingsEnabled(); | ||
cheats.toggleShowEnemyProductivityOverlay(); | ||
BOOST_TEST_REQUIRE(cheats.areAllBuildingsEnabled() == true); | ||
BOOST_TEST_REQUIRE(cheats.shouldShowEnemyProductivityOverlay() == true); | ||
} | ||
|
||
BOOST_AUTO_TEST_SUITE_END() |
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.
I'd rather put that at the top of both to make it clearer:
Although the first check isn't exactly there it is there implicitly as you cannot attack when you don't see the building. So !visible implies numSoldiers=0
This avoids the
if(!(conditions))
which is (slightly) more complex.And while touching this code: Can you move the checks for the addon and cheat, and loading the image out of the loop please? This is a hot loop that is run very often (in times and iterations) so we can move those constants, that might not be obvious constants to the compiler, to a single place as const variables.
Speaking of those: The visibility check has a few constant conditions Maybe we split that into 2 functions
IsAllVisible
andCalcVisibility
(both called from the current function) but move a call to the first out of the loop to a constant and use the 2nd here asif (!isAllVisible && !gwv.CalcVisibility(pt))
Although I don't expect that there are too many enemy buildings in the current view that there is a huge impact. So impact is low.But moving the 2 "constants" used here out of the loop is trivial enough to be worth it without measuring.
And possibly also the 2 lines at the top for coordinate transform below the no check directly on top of
curPos =
.This isn't exactly part of the PR topic but I like to do such small cleanups when touching code ("Boy Scout Rule")