Skip to content

Commit 6f19e74

Browse files
committed
Revert 7cda0f8 and project the shadow
I know it's ugly, just stay in consistency with others for the moment
1 parent 9c8d2e8 commit 6f19e74

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

docs/Whats-New.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,6 @@ Vanilla fixes:
522522
- Fixed disguised units not using the correct palette if target has custom palette (by NetsuNegi)
523523
- Building upgrades now consistently use building's `PowerUpN` animation settings corresponding to the upgrade's `PowersUpToLevel` where possible (by Starkku)
524524
- Subterranean units are no longer allowed to perform deploy functions like firing weapons or `IsSimpleDeployer` while burrowed or burrowing, they will instead emerge first like they do for transport unloading (by Starkku)
525-
- Subterranean units no longer draw an incorrectly positioned shadow when burrowing etc. (by Starkku)
526525
- Fixed `Temporal=true` Warheads potentially crashing game if used to attack `Slaved=true` infantry (by Starkku)
527526
528527
Phobos fixes:

src/Ext/Techno/Hooks.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,6 @@ DEFINE_HOOK(0x6F9FA9, TechnoClass_AI_PromoteAnim, 0x6)
596596
return aresProcess();
597597
}
598598

599-
// TunnelLocomotionClass_IsToHaveShadow, skip shadow on all but idle.
600-
// TODO: Investigate if it is possible to fix the shadows not tilting on the burrowing etc. states.
601-
DEFINE_JUMP(LJMP, 0x72A070, 0x72A07F);
602-
603-
604599
DEFINE_HOOK(0x51B20E, InfantryClass_AssignTarget_FireOnce, 0x6)
605600
{
606601
enum { SkipGameCode = 0x51B255 };

src/Ext/TechnoType/Hooks.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <JumpjetLocomotionClass.h>
2222
#include <FlyLocomotionClass.h>
2323
#include <RocketLocomotionClass.h>
24+
#include <TunnelLocomotionClass.h>
2425

2526
DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_Hide, 0x5)
2627
{
@@ -312,6 +313,49 @@ struct DummyExtHere // TODO: move it
312313
VoxelStruct NoSpawnAltVXL;
313314
};
314315

316+
Matrix3D* __stdcall TunnelLocomotionClass_ShadowMatrix(ILocomotion* iloco, Matrix3D* ret,VoxelIndexKey* key)
317+
{
318+
__assume(iloco != nullptr);
319+
auto tLoco = static_cast<TunnelLocomotionClass*>(iloco);
320+
*ret = tLoco->LocomotionClass::Shadow_Matrix(key);
321+
if (tLoco->State != TunnelLocomotionClass::State::Idle)
322+
{
323+
double theta = 0.;
324+
switch (tLoco->State)
325+
{
326+
case TunnelLocomotionClass::State::DiggingIn:
327+
if (key)key->Invalidate();
328+
theta = Math::HalfPi;
329+
if (auto total = tLoco->DigTimer.Rate)
330+
theta *= 1.0 - double(tLoco->DigTimer.GetTimeLeft()) / double(total);
331+
break;
332+
case TunnelLocomotionClass::State::DugIn:
333+
theta = Math::HalfPi;
334+
break;
335+
case TunnelLocomotionClass::State::PreDigOut:
336+
theta = -Math::HalfPi;
337+
break;
338+
case TunnelLocomotionClass::State::DiggingOut:
339+
if (key)key->Invalidate();
340+
theta = -Math::HalfPi;
341+
if (auto total = tLoco->DigTimer.Rate)
342+
theta *= double(tLoco->DigTimer.GetTimeLeft()) / double(total);
343+
break;
344+
case TunnelLocomotionClass::State::DugOut:
345+
if (key)key->Invalidate();
346+
theta = Math::HalfPi;
347+
if (auto total = tLoco->DigTimer.Rate)
348+
theta *= double(tLoco->DigTimer.GetTimeLeft()) / double(total);
349+
break;
350+
default:break;
351+
}
352+
ret->ScaleX((float)Math::cos(theta));// I know it's ugly
353+
}
354+
return ret;
355+
}
356+
357+
DEFINE_JUMP(VTABLE, 0x7F5A4C, GET_OFFSET(TunnelLocomotionClass_ShadowMatrix));
358+
315359
DEFINE_HOOK(0x73C47A, UnitClass_DrawAsVXL_Shadow, 0x5)
316360
{
317361
GET(UnitClass*, pThis, EBP);

0 commit comments

Comments
 (0)