Skip to content

Commit ae5144e

Browse files
committed
codestyle
1 parent 33c8c43 commit ae5144e

File tree

3 files changed

+32
-28
lines changed

3 files changed

+32
-28
lines changed

src/Ext/Bullet/Hooks.DetonateLogics.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ DEFINE_HOOK(0x469C46, BulletClass_Logics_DamageAnimSelected, 0x8)
260260
if (pAnimType)
261261
{
262262
auto const pWHExt = WarheadTypeExt::ExtMap.Find(pThis->WH);
263-
int cellHeight = MapClass::Instance.GetCellFloorHeight(*coords);
264-
auto newCrds = pWHExt->PlayAnimAboveSurface ? CoordStruct{ coords->X, coords->Y, Math::max(cellHeight, coords->Z) } : *coords;
263+
const int cellHeight = MapClass::Instance.GetCellFloorHeight(*coords);
264+
auto const newCrds = pWHExt->PlayAnimAboveSurface ? CoordStruct{ coords->X, coords->Y, Math::max(cellHeight, coords->Z) } : *coords;
265265

266266
if (cellHeight > newCrds.Z && !pWHExt->PlayAnimUnderground)
267267
{
@@ -795,31 +795,32 @@ DEFINE_HOOK(0x469453, BulletClass_Logics_TemporalUnderGround, 0x6)
795795

796796
GET(FootClass*, pTarget, EAX);
797797

798-
Layer layer = pTarget->InWhichLayer();
799-
800-
if (layer != Layer::None)
798+
if (pTarget->InWhichLayer() != Layer::None)
801799
return OK;
802800

803801
return NotOK;
804802
}
805803

806804
DEFINE_HOOK(0x4899DA, MapClass_DamageArea_DamageUnderGround, 0x7)
807805
{
808-
GET_STACK(bool, isNullified, STACK_OFFSET(0xE0, -0xC9));
806+
GET_STACK(const bool, isNullified, STACK_OFFSET(0xE0, -0xC9));
809807
GET_STACK(int, damage, STACK_OFFSET(0xE0, -0xBC));
810808
GET_STACK(CoordStruct*, pCrd, STACK_OFFSET(0xE0, -0xB8));
811809
GET_BASE(WarheadTypeClass*, pWH, 0xC);
812810
GET_BASE(TechnoClass*, pSrcTechno, 0x8);
813811
GET_BASE(HouseClass*, pSrcHouse, 0x14);
814812
GET_STACK(bool, hitted, STACK_OFFSET(0xE0, -0xC1)); // bHitted = true
815813

814+
if (isNullified)
815+
return 0;
816+
816817
auto const pWHExt = WarheadTypeExt::ExtMap.Find(pWH);
817818

818-
if (isNullified || !pWHExt || !pWHExt->AffectsUnderground)
819+
if (!pWHExt || !pWHExt->AffectsUnderground)
819820
return 0;
820821

821822
// bool cylinder = pWHExt->CellSpread_Cylinder;
822-
float spread = pWH->CellSpread;
823+
const float spread = pWH->CellSpread;
823824

824825
for (auto const& pTechno : ScenarioExt::Global()->UndergroundTracker)
825826
{
@@ -829,14 +830,14 @@ DEFINE_HOOK(0x4899DA, MapClass_DamageArea_DamageUnderGround, 0x7)
829830
&& !pTechno->InLimbo)
830831
{
831832
double dist = 0.0;
832-
auto technoCoords = pTechno->GetCoords();
833+
auto const technoCoords = pTechno->GetCoords();
833834

834835
//if (cylinder)
835836
// dist = CoordStruct{ technoCoords.X - pCrd->X, technoCoords.Y - pCrd->Y, 0 }.Magnitude();
836837
//else
837838
dist = technoCoords.DistanceFrom(*pCrd);
838839

839-
if (dist <= spread * 256)
840+
if (dist <= spread * Unsorted::LeptonsPerCell)
840841
{
841842
pTechno->ReceiveDamage(&damage, (int)dist, pWH, pSrcTechno, false, false, pSrcHouse);
842843
hitted = true;
@@ -848,6 +849,4 @@ DEFINE_HOOK(0x4899DA, MapClass_DamageArea_DamageUnderGround, 0x7)
848849
return 0;
849850
}
850851

851-
852-
853-
#pragma endregion
852+
#pragma endregion

src/Ext/Techno/Hooks.Firing.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -453,18 +453,23 @@ DEFINE_HOOK(0x6FC749, TechnoClass_GetFireError_AntiUnderground, 0x5)
453453
{
454454
enum { Illegal = 0x6FC86A, GoOtherChecks = 0x6FC762 };
455455

456-
GET(Layer, layer, EAX);
457-
//GET(TechnoClass*, pThis, EBX);
456+
GET(const Layer, layer, EAX);
458457
GET(WeaponTypeClass*, pWeapon, EDI);
459458

460-
auto const pProj = pWeapon->Projectile;
461-
auto const pProjExt = BulletTypeExt::ExtMap.Find(pProj);
462-
463-
if (layer == Layer::Underground && !pProjExt->AU)
464-
return Illegal;
465-
466-
if ((layer == Layer::Air || layer == Layer::Top) && !pProj->AA)
467-
return Illegal;
459+
switch (layer)
460+
{
461+
case Layer::Air:
462+
case Layer::Top:
463+
if (!pWeapon->Projectile->AA)
464+
return Illegal;
465+
break;
466+
case Layer::Underground:
467+
if (!BulletTypeExt::ExtMap.Find(pWeapon->Projectile)->AU)
468+
return Illegal;
469+
break;
470+
default:
471+
break;
472+
}
468473

469474
return GoOtherChecks;
470475
}

src/Ext/Techno/Hooks.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ DEFINE_HOOK(0x70023B, TechnoClass_MouseOverObject_AttackUnderGround, 0x5)
13091309

13101310
GET(ObjectClass*, pObject, EDI);
13111311
GET(TechnoClass*, pThis, ESI);
1312-
GET(int, wpIdx, EAX);
1312+
GET(const int, wpIdx, EAX);
13131313

13141314
if (pObject->IsSurfaced())
13151315
return FireIsOK;
@@ -1326,7 +1326,7 @@ DEFINE_HOOK(0x728F9A, TunnelLocomotionClass_Process_Track, 0x7)
13261326
GET(ILocomotion*, pThis, ESI);
13271327

13281328
const auto pLoco = static_cast<TunnelLocomotionClass*>(pThis);
1329-
auto pTechno = pLoco->LinkedTo;
1329+
const auto pTechno = pLoco->LinkedTo;
13301330
ScenarioExt::Global()->UndergroundTracker.AddUnique(pTechno);
13311331
TechnoExt::ExtMap.Find(pTechno)->UndergroundTracked = true;
13321332

@@ -1346,7 +1346,7 @@ DEFINE_HOOK(0x7297F6, TunnelLocomotionClass_ProcessDigging_Track, 0x7)
13461346
DEFINE_HOOK(0x772AB3, WeaponTypeClass_AllowedThreats_AU, 0x5)
13471347
{
13481348
GET(BulletTypeClass* const, pType, ECX);
1349-
GET(ThreatType, flags, EAX);
1349+
GET(const ThreatType, flags, EAX);
13501350

13511351
if (BulletTypeExt::ExtMap.Find(pType)->AU)
13521352
R->EAX(static_cast<unsigned int>(flags) | 0x20000u);
@@ -1361,7 +1361,7 @@ namespace SelectAutoTarget_Context
13611361

13621362
DEFINE_HOOK(0x6F8DF0, TechnoClass_SelectAutoTarget_Start_AU, 0x9)
13631363
{
1364-
GET_STACK(unsigned int, flags, 0x4);
1364+
GET_STACK(const unsigned int, flags, 0x4);
13651365
SelectAutoTarget_Context::AU = (flags & 0x20000u) != 0;
13661366
return 0;
13671367
}
@@ -1453,7 +1453,7 @@ DEFINE_HOOK(0x6F7E1E, TechnoClass_CanAutoTargetObject_AU, 0x6)
14531453
enum { Continue = 0x6F7E24, ReturnFalse = 0x6F894F };
14541454

14551455
GET(TechnoClass*, pTarget, ESI);
1456-
GET(int, height, EAX);
1456+
GET(const int, height, EAX);
14571457

14581458
return height >= -20 || SelectAutoTarget_Context::AU || TechnoExt::ExtMap.Find(pTarget)->SpecialTracked ? Continue : ReturnFalse;
14591459
}

0 commit comments

Comments
 (0)