-
-
Notifications
You must be signed in to change notification settings - Fork 157
Allow Ares Academy add country-level filters #2421
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
Open
dh381-1
wants to merge
9
commits into
Phobos-developers:develop
Choose a base branch
from
dh381-1:extra/Academy
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+280
−3
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9ace942
initial
dh381-1 bf54aed
Merge branch 'develop' into extra/Academy
dh381-1 e1c37c7
update
dh381-1 017c0cf
Merge branch 'extra/Academy' of https://github.com/dh381-1/Phobos int…
dh381-1 15727e3
fix TERRIBLE codestyle
NetsuNegi 0b8d648
Merge branch 'extra/Academy' of https://github.com/dh381-1/Phobos int…
NetsuNegi cfc8678
why not serialize this ?
NetsuNegi a3f856a
Update Hooks.Academy.cpp
NetsuNegi efcf1f9
Update Whats-New.md
DeathFishAtEase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| #include "Body.h" | ||
|
|
||
| #include <Ext/House/Body.h> | ||
| #include <Ext/Building/Body.h> | ||
| #include <Ext/BuildingType/Body.h> | ||
| #include <Ext/Techno/Body.h> | ||
|
|
||
| static void UpdateAcademy(HouseExt* pHouseExt, BuildingClass* pAcademy, bool added) | ||
| { | ||
| const auto it = std::find(pHouseExt->Academies.cbegin(), pHouseExt->Academies.cend(), pAcademy); | ||
|
|
||
| if (added == (it != pHouseExt->Academies.cend())) | ||
| return; | ||
|
|
||
| if (added) | ||
| pHouseExt->Academies.push_back(pAcademy); | ||
| else | ||
| pHouseExt->Academies.erase(it); | ||
| } | ||
|
|
||
| static void ApplyAcademy(TechnoClass* const pTechno, AbstractType const considerAs) | ||
| { | ||
| if (Unsorted::ScenarioInit) | ||
| return; | ||
|
|
||
| const auto pType = pTechno->GetTechnoType(); | ||
|
|
||
| if (!pType->Trainable) | ||
| return; | ||
|
|
||
| const auto pHouseExt = HouseExt::Fetch(pTechno->Owner); | ||
| const auto pHouseTypeExt = HouseTypeExt::Fetch(pTechno->Owner->Type); | ||
| const int countryIdx = pTechno->Owner->Type->ArrayIndex; | ||
|
|
||
| if (!pHouseTypeExt->Academy_AllowCountryFilter) | ||
| return; | ||
|
|
||
| double maximumBonus = 0.0; | ||
|
|
||
| for (const auto pBuilding : pHouseExt->Academies) | ||
| { | ||
| const auto pBuildingType = pBuilding->Type; | ||
| const auto pBuildingTypeExt = BuildingTypeExt::Fetch(pBuildingType); | ||
|
|
||
| const auto& academyWhiteList = pBuildingTypeExt->Academy_Country_Types[countryIdx]; | ||
| const auto& academyBlackList = pBuildingTypeExt->Academy_Country_Ignore[countryIdx]; | ||
|
|
||
| const bool canAffect = (academyWhiteList.empty() || academyWhiteList.Contains(pType)) | ||
| && !academyBlackList.Contains(pType); | ||
|
|
||
| if (!canAffect) | ||
| continue; | ||
|
|
||
| double veterancyBonus = 0.0; | ||
|
|
||
| switch (considerAs) | ||
| { | ||
| case AbstractType::Infantry: | ||
| veterancyBonus = pBuildingTypeExt->Academy_Infantry_Veterancy; | ||
| break; | ||
|
|
||
| case AbstractType::Unit: | ||
| veterancyBonus = pBuildingTypeExt->Academy_Vehicle_Veterancy; | ||
| break; | ||
|
|
||
| case AbstractType::Aircraft: | ||
| veterancyBonus = pBuildingTypeExt->Academy_Aircraft_Veterancy; | ||
| break; | ||
|
|
||
| case AbstractType::Building: | ||
| veterancyBonus = pBuildingTypeExt->Academy_Building_Veterancy; | ||
| break; | ||
|
|
||
| default: | ||
| break; | ||
| } | ||
|
|
||
| if (maximumBonus < veterancyBonus) | ||
| maximumBonus = veterancyBonus; | ||
| } | ||
|
|
||
| auto& value = pTechno->Veterancy.Veterancy; | ||
| value = static_cast<float>(TechnoExt::Fetch(pTechno)->OriginVeterancy); | ||
|
|
||
| if (maximumBonus > value) | ||
| value = static_cast<float>(std::min(maximumBonus, RulesClass::Instance->VeteranCap)); | ||
| } | ||
|
|
||
| static void SetOriginVeterancy(TechnoClass* pTechno) | ||
| { | ||
| const auto pHouse = pTechno->Owner; | ||
|
|
||
| switch (pTechno->WhatAmI()) | ||
| { | ||
| case AbstractType::Infantry: | ||
| if (pHouse->BarracksInfiltrated) | ||
| TechnoExt::Fetch(pTechno)->OriginVeterancy = 1.0; | ||
|
|
||
| break; | ||
|
|
||
| case AbstractType::Unit: | ||
| if (pHouse->WarFactoryInfiltrated) | ||
| TechnoExt::Fetch(pTechno)->OriginVeterancy = 1.0; | ||
|
|
||
| break; | ||
|
|
||
| default: | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| DEFINE_HOOK(0x446366, BuildingClass_Place_Academy, 0x6) | ||
| { | ||
| GET(BuildingClass*, pThis, EBP); | ||
|
|
||
| if (BuildingTypeExt::Fetch(pThis->Type)->Academy) | ||
| UpdateAcademy(HouseExt::Fetch(pThis->Owner), pThis, true); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| DEFINE_HOOK(0x445905, BuildingClass_Remove_Academy, 0x6) | ||
| { | ||
| GET(BuildingClass*, pThis, ESI); | ||
|
|
||
| if (pThis->IsOnMap && BuildingTypeExt::Fetch(pThis->Type)->Academy) | ||
| UpdateAcademy(HouseExt::Fetch(pThis->Owner), pThis, false); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| DEFINE_HOOK(0x448AB2, BuildingClass_SetOwningHouse_Remove_Academy, 0x6) | ||
| { | ||
| GET(BuildingClass*, pThis, ESI); | ||
|
|
||
| if (pThis->IsOnMap && BuildingTypeExt::Fetch(pThis->Type)->Academy) | ||
| UpdateAcademy(HouseExt::Fetch(pThis->Owner), pThis, false); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| DEFINE_HOOK(0x4491D5, BuildingClass_SetOwningHouse_Add_Academy, 0x6) | ||
| { | ||
| GET(BuildingClass*, pThis, ESI); | ||
|
|
||
| if (pThis->IsOnMap && BuildingTypeExt::Fetch(pThis->Type)->Academy) | ||
| UpdateAcademy(HouseExt::Fetch(pThis->Owner), pThis, true); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| DEFINE_HOOK(0x517D57, InfantryClass_Init_Academy, 0x6) | ||
| { | ||
| GET(InfantryClass*, pThis, ESI); | ||
|
|
||
| SetOriginVeterancy(pThis); | ||
| ApplyAcademy(pThis, AbstractType::Infantry); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| DEFINE_HOOK_AGAIN(0x735678, UnitClass_Init_Academy, 0x6) // CTOR | ||
| DEFINE_HOOK(0x74689B, UnitClass_Init_Academy, 0x6) | ||
| { | ||
| GET(UnitClass*, pThis, ESI); | ||
|
|
||
| SetOriginVeterancy(pThis); | ||
|
|
||
| if (pThis->Type->ConsideredAircraft) | ||
| ApplyAcademy(pThis, AbstractType::Aircraft); | ||
| else if (pThis->Type->Organic) | ||
| ApplyAcademy(pThis, AbstractType::Infantry); | ||
| else | ||
| ApplyAcademy(pThis, AbstractType::Unit); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| DEFINE_HOOK(0x413FD2, AircraftClass_Init_Academy, 0x6) | ||
| { | ||
| GET(AircraftClass*, pThis, ESI); | ||
|
|
||
| SetOriginVeterancy(pThis); | ||
| ApplyAcademy(pThis, AbstractType::Aircraft); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| DEFINE_HOOK(0x442D34, BuildingClass_Init_Academy, 0x6) | ||
| { | ||
| GET(BuildingClass*, pThis, ESI); | ||
|
|
||
| SetOriginVeterancy(pThis); | ||
| ApplyAcademy(pThis, AbstractType::Building); | ||
|
|
||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If the flag in country sections merely serves as a global enabling statement for building flags, then its documentation paragraph only needs to be placed in the Buildings section, just as a techno flag is not regarded as a global feature simply because a toggle in
[General]is also added at the same time.