diff --git a/Phobos.vcxproj b/Phobos.vcxproj index 222d879ffa..4bc4af4382 100644 --- a/Phobos.vcxproj +++ b/Phobos.vcxproj @@ -85,6 +85,7 @@ + @@ -379,4 +380,4 @@ - \ No newline at end of file + diff --git a/README.md b/README.md index 2397ca1c5b..57e59c80d1 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Credits - **wiktorderelf** - overhauled Unicode font - **Uranusian (Thrifinesma)** - Mind Control enhancement, custom warhead splash list, harvesters counter, promoted spawns, shields, death after dead fix, customizeable missing cameo, cameo sorting priority, placement mode responding of tab hotkeys fix, producing progress, custom ore gathering anim, NoManualMove, weapon target house filtering, DeathWeapon fix, re-enable obsolete `JumpjetControls`, AITrigger Building Upgrades recognition, Wall-Gate links, overhauled Unicode font, docs maintenance, CN docs translation - **secsome (SEC-SOME)** - debug info dump hotkey, refactoring & porting of Ares helper code, introducing more Ares-derived stuff, disguise removal warhead, Mind Control removal warhead, Mind Control enhancement, shields, AnimList.PickRandom, MoveToCell fix, unlimited waypoints, Build At trigger action buildup anim fix, Undeploy building into a unit plays `EVA_NewRallyPointEstablished` fix, custom ore gathering anim, TemporaryClass related crash, Retry dialog on mission failure, Default disguise for individual InfantryTypes, PowerPlant Enhancer, SaveGame Trigger Action, QuickSave command, Numeric variables, Custom gravity for projectiles, Retint map actions bugfix -- **Otamaa (Fahroni, BoredEXE)** - help with CellSpread, ported and fixed custom RadType code, togglable ElectricBolt bolts, customizable Chrono Locomotor properties per TechnoClass, DebrisMaximums fixes, Anim-to-Unit, NotHuman anim sequences improvements, Customizable OpenTopped Properties, hooks for ScriptType Actions 92 & 93, ore stage threshold for `HideIfNoOre` +- **Otamaa (Fahroni, BoredEXE)** - help with CellSpread, ported and fixed custom RadType code, togglable ElectricBolt bolts, customizable Chrono Locomotor properties per TechnoClass, DebrisMaximums fixes, Anim-to-Unit, NotHuman anim sequences improvements, Customizable OpenTopped Properties, hooks for ScriptType Actions 92 & 93, ore stage threshold for `HideIfNoOre`, occupied building `MuzzleFlashX` bugfix - **E1 Elite** - TileSet 255 and above bridge repair fix - **FS-21** - Dump Object Info enhancements, Powered.KillSpawns, Spawner.LimitRange, ScriptType Actions 71, 72, 73, 74 to 81, 92, 93, 94, 95 to 98, 111, 112, MC deployer fixes, help with docs, Automatic Passenger Deletion - **AutoGavy** - interceptor logic, warhead critical damage system diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 8fee7d195a..fe7339d080 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -42,6 +42,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho - `IsSimpleDeployer` units now only play `DeploySound` and `UndeploySound` once, when done with (un)deploying instead of repeating it over duration of turning and/or `DeployingAnim`. - AITrigger can now recognize Building Upgrades as legal condition. - `EWGates` and `NSGates` now will link walls like `xxGateOne` and `xxGateTwo` do. +- Fixed the bug when occupied building's `MuzzleFlashX` is drawn on the center of the building when `X` goes past 10. ## Animations diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 49f613d702..d12cc9c547 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -265,6 +265,7 @@ Vanilla fixes: - Fixed temporal weapon crash under certain conditions where stack dump starts with 0051BB7D (by secsome) - Fixed the bug when retinting map lighting with a map action corrupted light sources (by secsome) - Fixed the bug that AITriggerTypes do not recognize building upgrades (by Uranusian) +- Fixed the bug when occupied building's `MuzzleFlashX` is drawn on the center of the building when `X` goes past 10 (by Otamaa) Phobos fixes: - Fixed shields being able to take damage when the parent TechnoType was under effects of a `Temporal` Warhead (by Starkku) diff --git a/src/Ext/BuildingType/Body.cpp b/src/Ext/BuildingType/Body.cpp index 23d1d4bf1f..454d145d47 100644 --- a/src/Ext/BuildingType/Body.cpp +++ b/src/Ext/BuildingType/Body.cpp @@ -75,11 +75,14 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) { auto pThis = this->OwnerObject(); const char* pSection = pThis->ID; + const char* pArtSection = pThis->ImageFile; + auto pArtINI = &CCINIClass::INI_Art(); if (!pINI->GetSection(pSection)) return; INI_EX exINI(pINI); + INI_EX exArtINI(pArtINI); this->PowersUp_Owner.Read(exINI, pSection, "PowersUp.Owner"); this->PowersUp_Buildings.Read(exINI, pSection, "PowersUp.Buildings"); @@ -113,6 +116,22 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) } } } + + if (pThis->MaxNumberOccupants > 10) + { + char tempBuffer[32]; + this->OccupierMuzzleFlashes.Clear(); + this->OccupierMuzzleFlashes.Reserve(pThis->MaxNumberOccupants); + + for (int i = 0; i < pThis->MaxNumberOccupants; ++i) + { + Nullable nMuzzleLocation; + _snprintf_s(tempBuffer, sizeof(tempBuffer), "MuzzleFlash%d", i); + nMuzzleLocation.Read(exArtINI, pArtSection, tempBuffer); + this->OccupierMuzzleFlashes[i] = nMuzzleLocation.Get(Point2D::Empty); + } + } + } void BuildingTypeExt::ExtData::CompleteInitialization() @@ -131,6 +150,7 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm) .Process(this->PowerPlantEnhancer_Amount) .Process(this->PowerPlantEnhancer_Factor) .Process(this->SuperWeapons) + .Process(this->OccupierMuzzleFlashes) ; } diff --git a/src/Ext/BuildingType/Body.h b/src/Ext/BuildingType/Body.h index 0d67038494..74d16edf1d 100644 --- a/src/Ext/BuildingType/Body.h +++ b/src/Ext/BuildingType/Body.h @@ -22,12 +22,15 @@ class BuildingTypeExt Nullable PowerPlantEnhancer_Amount; Nullable PowerPlantEnhancer_Factor; + DynamicVectorClass OccupierMuzzleFlashes; + ExtData(BuildingTypeClass* OwnerObject) : Extension(OwnerObject) , PowersUp_Owner { AffectedHouse::Owner } , PowersUp_Buildings {} , PowerPlantEnhancer_Buildings {} , PowerPlantEnhancer_Amount {} , PowerPlantEnhancer_Factor {} + , OccupierMuzzleFlashes() { } virtual ~ExtData() = default; diff --git a/src/Ext/BuildingType/Hooks.cpp b/src/Ext/BuildingType/Hooks.cpp new file mode 100644 index 0000000000..5f96ac547c --- /dev/null +++ b/src/Ext/BuildingType/Hooks.cpp @@ -0,0 +1,62 @@ +#include "Body.h" + +#include + +DEFINE_HOOK(0x460285, BuildingTypeClass_LoadFromINI_Muzzle, 0x6) +{ + enum { Skip = 0x460388, Read = 0x460299 }; + + GET(BuildingTypeClass*, pThis, EBP); + + // Restore overriden instructions + R->Stack(STACK_OFFS(0x368, 0x358), 0); + R->EDX(0); + + // Disable Vanilla Muzzle flash when MaxNumberOccupants is 0 or more than 10 + return !pThis->MaxNumberOccupants || pThis->MaxNumberOccupants > 10 + ? Skip : Read; +} + +DEFINE_HOOK(0x44043D, BuildingClass_AI_Temporaled_Chronosparkle_MuzzleFix, 0x8) +{ + GET(BuildingClass*, pThis, ESI); + + auto pType = pThis->Type; + if (pType->MaxNumberOccupants > 10) + { + GET(int, nFiringIndex, EBX); + auto pTypeExt = BuildingTypeExt::ExtMap.Find(pType); + R->EAX(&pTypeExt->OccupierMuzzleFlashes[nFiringIndex]); + } + + return 0; +} + +DEFINE_HOOK(0x45387A, BuildingClass_FireOffset_Replace_MuzzleFix, 0xA) +{ + GET(BuildingClass*, pThis, ESI); + + auto pType = pThis->Type; + if (pType->MaxNumberOccupants > 10) + { + auto pTypeExt = BuildingTypeExt::ExtMap.Find(pType); + R->EDX(&pTypeExt->OccupierMuzzleFlashes[pThis->FiringOccupantIndex]); + } + + return 0; +} + +DEFINE_HOOK(0x458623, BuildingClass_KillOccupiers_Replace_MuzzleFix, 0x7) +{ + GET(BuildingClass*, pThis, ESI); + + auto pType = pThis->Type; + if (pType->MaxNumberOccupants > 10) + { + GET(int, nFiringIndex, EDI); + auto pTypeExt = BuildingTypeExt::ExtMap.Find(pType); + R->ECX(&pTypeExt->OccupierMuzzleFlashes[nFiringIndex]); + } + + return 0; +} \ No newline at end of file