Skip to content

Commit bdd2443

Browse files
committed
complement missing parts in 87be720
fix aircraft shadow's flightlevel getter and rotation condition
1 parent 7b244db commit bdd2443

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

src/Ext/Aircraft/Body.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ DirType AircraftExt::GetLandingDir(AircraftClass* pThis, BuildingClass* pDock)
8888
return pLink->PrimaryFacing.Current().GetDir();
8989
}
9090

91-
int landingDir = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->LandingDir.Get((int)poseDir);
91+
int landingDir = TechnoTypeExt::ExtMap.Find(pThis->Type)->LandingDir.Get((int)poseDir);
9292

9393
if (!pThis->Type->AirportBound && landingDir < 0)
9494
return pThis->PrimaryFacing.Current().GetDir();

src/Ext/Aircraft/Hooks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ DEFINE_HOOK(0x44402E, BuildingClass_ExitObject_PoseDir2, 0x5)
159159
GET(AircraftClass*, pAircraft, EBP);
160160

161161
auto dir = DirStruct(AircraftExt::GetLandingDir(pAircraft, pThis));
162-
pAircraft->PrimaryFacing.SetCurrent(dir);
162+
// pAircraft->PrimaryFacing.SetCurrent(dir);
163163
pAircraft->SecondaryFacing.SetCurrent(dir);
164164

165165
return 0;

src/Ext/TechnoType/Hooks.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ DEFINE_HOOK(0x73C47A, UnitClass_DrawAsVXL_Shadow, 0x5)
386386
{
387387
const float cHeight = (float)uTypeExt->ShadowSizeCharacteristicHeight.Get(RulesClass::Instance->CruiseHeight);
388388

389-
if (cHeight > 0)
389+
if (cHeight > 0 && height > 208)
390390
{
391-
shadow_matrix.Scale((float)std::max(Pade2_2(baseScale_log * height / cHeight), minScale));
391+
shadow_matrix.Scale((float)std::max(Pade2_2(baseScale_log * (height - 208) / cHeight), minScale));
392392
vxl_index_key.Invalidate();
393393
}
394394
}
@@ -589,27 +589,29 @@ DEFINE_HOOK(0x4147F9, AircraftClass_Draw_Shadow, 0x6)
589589
if (RulesExt::Global()->HeightShadowScaling)
590590
{
591591
const double minScale = RulesExt::Global()->HeightShadowScaling_MinScale;
592-
const float cHeight = (float)aTypeExt->ShadowSizeCharacteristicHeight.Get(flyLoco->FlightLevel);
592+
const float cHeight = (float)aTypeExt->ShadowSizeCharacteristicHeight.Get(pThis->Type->GetFlightLevel());
593593

594594
if (cHeight > 0)
595595
{
596596
shadow_mtx.Scale((float)std::max(Pade2_2(baseScale_log * height / cHeight), minScale));
597-
key.Invalidate(); // I'm sorry
597+
if (flyLoco->FlightLevel > 0 || height > 0)
598+
key.Invalidate();
598599
}
599600
}
600601
else if (pThis->Type->ConsideredAircraft)
601602
{
602603
shadow_mtx.Scale((float)Pade2_2(baseScale_log));
603604
}
604605

605-
if (pThis->IsCrashing)
606-
{
607-
double arf = pThis->AngleRotatedForwards;
608-
if (flyLoco->CurrentSpeed > pThis->Type->PitchSpeed)
609-
arf += pThis->Type->PitchAngle;
610-
shadow_mtx.ScaleY((float)Math::cos(pThis->AngleRotatedSideways));
611-
shadow_mtx.ScaleX((float)Math::cos(arf));
612-
}
606+
double arf = pThis->AngleRotatedForwards;
607+
if (flyLoco->CurrentSpeed > pThis->Type->PitchSpeed)
608+
arf += pThis->Type->PitchAngle;
609+
double ars = pThis->AngleRotatedSideways;
610+
if (key.Is_Valid_Key() && (std::abs(arf) > 0.005 || std::abs(ars) > 0.005))
611+
key.Invalidate();
612+
613+
shadow_mtx.ScaleY((float)Math::cos(ars));
614+
shadow_mtx.ScaleX((float)Math::cos(arf));
613615
}
614616
else if (height > 0)
615617
{
@@ -659,6 +661,12 @@ DEFINE_HOOK(0x4147F9, AircraftClass_Draw_Shadow, 0x6)
659661

660662
// Shadow_Point of RocketLoco was forgotten to be set to {0,0}. It was an oversight.
661663
DEFINE_JUMP(VTABLE, 0x7F0B4C, 0x4CF940);
664+
/*
665+
//TO TEST AND EXPLAIN: why resetting height when drawing aircrafts?
666+
DEFINE_JUMP(CALL6, 0x4147D5, 0x5F4300);
667+
DEFINE_JUMP(CALL6, 0x4148AB, 0x5F4300);
668+
DEFINE_JUMP(CALL6, 0x4147F3, 0x5F4300);
669+
*/
662670

663671
DEFINE_HOOK(0x7072A1, suka707280_ChooseTheGoddamnMatrix, 0x7)
664672
{

src/Ext/Unit/Hooks.Jumpjet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ Matrix3D* __stdcall TeleportLocomotionClass_Draw_Matrix(ILocomotion* iloco, Matr
246246

247247
if (std::abs(ars) >= 0.005 || std::abs(arf) >= 0.005)
248248
{
249-
if (pIndex)// just forget it bro, no one cares
250-
*(int*)pIndex = -1;
249+
if (pIndex)
250+
pIndex->Invalidate();
251251

252252
double scalex = linked->GetTechnoType()->VoxelScaleX;
253253
double scaley = linked->GetTechnoType()->VoxelScaleY;

0 commit comments

Comments
 (0)