Skip to content

Commit 69f1084

Browse files
committed
Fix the bug that AlphaImage remained after unit entered tunnel
1 parent f060ec9 commit 69f1084

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ This page lists all the individual contributions to the project by their author.
400400
- Original `Arcing` elevation inaccuracy fix
401401
- Fix the bug that uncontrolled scatter when elite techno attacked by aircraft or some unit try crush it
402402
- Exclusive SuperWeapon Sidebar
403+
- Fix the bug that AlphaImage remained after unit entered tunnel.
403404
- **Apollo** - Translucent SHP drawing patches
404405
- **ststl**:
405406
- Customizable `ShowTimer` priority of superweapons

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
247247
- Taking over Ares' AlphaImage respawn logic to make it not recreate in every frame for buildings, static techno and techno without turret, in order to reduce lags from it.
248248
- Fixed an issue where a portion of Ares's trigger event 75/77 was determined unsuccessfully.
249249
- Fixed some units of Ares crashing after deployment conversion.
250+
- Fixed the bug that AlphaImage remained after unit entered tunnel.
250251

251252
## Aircraft
252253

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ Fixes / interactions with other extensions:
415415
- Taking over Ares' AlphaImage respawn logic to reduce lags from it (by NetsuNegi)
416416
- Fixed an issue where a portion of Ares's trigger event 75/77 was determined unsuccessfully (by FlyStar)
417417
- Fixed the issue where some units crashed after the deployment transformation (by ststl, FlyStar)
418+
- Fixed the bug that AlphaImage remained after unit entered tunnel (by NetsuNegi)
418419
419420
```
420421

src/Ext/Techno/Hooks.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <EventClass.h>
55
#include <ScenarioClass.h>
66
#include <TunnelLocomotionClass.h>
7+
#include <AlphaShapeClass.h>
8+
#include <TacticalClass.h>
79

810
#include <Ext/Anim/Body.h>
911
#include <Ext/BuildingType/Body.h>
@@ -13,6 +15,7 @@
1315
#include <Ext/TechnoType/Body.h>
1416
#include <Utilities/EnumFunctions.h>
1517
#include <Utilities/AresHelper.h>
18+
#include <Utilities/AresFunctions.h>
1619

1720
#pragma region Update
1821

@@ -80,6 +83,25 @@ DEFINE_HOOK(0x735A26, FootClass_TunnelAI_Enter, 0x6) // UnitClass_TunnelAI
8083
auto const pExt = TechnoExt::ExtMap.Find(pThis);
8184
pExt->UpdateOnTunnelEnter();
8285

86+
const auto pType = pThis->GetTechnoType();
87+
const auto pImage = pType->AlphaImage;
88+
89+
if (pImage && AresHelper::CanUseAres)
90+
{
91+
auto& alphaExt = *AresFunctions::AlphaExtMap;
92+
93+
if (const auto pAlpha = alphaExt.get_or_default(pThis))
94+
{
95+
GameDelete(pAlpha);
96+
97+
const auto tacticalPos = TacticalClass::Instance->TacticalPos;
98+
Point2D off = { tacticalPos.X - (pImage->Width / 2), tacticalPos.Y - (pImage->Height / 2) };
99+
const auto point = TacticalClass::Instance->CoordsToClient(pThis->GetCoords()).first + off;
100+
RectangleStruct dirty = { point.X - tacticalPos.X, point.Y - tacticalPos.Y, pImage->Width, pImage->Height };
101+
TacticalClass::Instance->RegisterDirtyArea(dirty, true);
102+
}
103+
}
104+
83105
return 0;
84106
}
85107

0 commit comments

Comments
 (0)