Skip to content

Commit

Permalink
Code style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed Feb 23, 2024
1 parent 6ed161f commit 96b5686
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Ext/WarheadType/Detonate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void WarheadTypeExt::ExtData::ApplyCrit(HouseClass* pHouse, TechnoClass* pTarget
else
dice = this->Crit_RandomBuffer;

if (GetCritChance(pOwner) < dice)
if (this->GetCritChance(pOwner) < dice)
return;

if (!pTargetExt)
Expand Down
44 changes: 25 additions & 19 deletions src/New/Entity/AttachEffectClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@

std::vector<AttachEffectClass*> AttachEffectClass::Array;

AttachEffectClass::AttachEffectClass() : Type { nullptr }, Techno { nullptr }, InvokerHouse { nullptr }, Invoker { nullptr }, Source { nullptr }, DurationOverride { 0 }, Delay { 0 }, InitialDelay { 0 }, RecreationDelay { -1 }
, Duration { 0 }
, CurrentDelay { 0 }
, NeedsDurationRefresh { false }
AttachEffectClass::AttachEffectClass()
: Type { nullptr }, Techno { nullptr }, InvokerHouse { nullptr }, Invoker { nullptr },
Source { nullptr }, DurationOverride { 0 }, Delay { 0 }, InitialDelay { 0 }, RecreationDelay { -1 }
, Duration { 0 }
, CurrentDelay { 0 }
, NeedsDurationRefresh { false }
{
this->HasInitialized = false;
AttachEffectClass::Array.emplace_back(this);
}

AttachEffectClass::AttachEffectClass(AttachEffectTypeClass* pType, TechnoClass* pTechno,
HouseClass* pInvokerHouse, TechnoClass* pInvoker, AbstractClass* pSource, int durationOverride, int delay, int initialDelay, int recreationDelay) :
Type { pType }, Techno { pTechno }, InvokerHouse { pInvokerHouse }, Invoker { pInvoker }, Source { pSource },
AttachEffectClass::AttachEffectClass(AttachEffectTypeClass* pType, TechnoClass* pTechno, HouseClass* pInvokerHouse,
TechnoClass* pInvoker, AbstractClass* pSource, int durationOverride, int delay, int initialDelay, int recreationDelay)
: Type { pType }, Techno { pTechno }, InvokerHouse { pInvokerHouse }, Invoker { pInvoker }, Source { pSource },
DurationOverride { durationOverride }, Delay { delay }, InitialDelay { initialDelay }, RecreationDelay { recreationDelay }
, Duration { 0 }
, CurrentDelay { 0 }
Expand Down Expand Up @@ -135,10 +137,10 @@ void AttachEffectClass::AI()
if (!this->IsSelfOwned() || this->Delay < 0)
return;

this->CurrentDelay = this->Delay;
this->CurrentDelay = this->Delay;

if (this->Delay > 0)
KillAnim();
this->KillAnim();
else if (AllowedToBeActive())
this->RefreshDuration();
else
Expand All @@ -154,7 +156,7 @@ void AttachEffectClass::AI()
this->OnlineCheck();

if (!this->Animation && !this->IsUnderTemporal && this->IsOnline && !this->IsCloaked && !this->IsAnimHidden)
CreateAnim();
this->CreateAnim();
}

void AttachEffectClass::AI_Temporal()
Expand All @@ -166,7 +168,7 @@ void AttachEffectClass::AI_Temporal()
this->CloakCheck();

if (!this->Animation && this->Type->Animation_TemporalAction != AttachedAnimFlag::Hides && this->IsOnline && !this->IsCloaked && !this->IsAnimHidden)
CreateAnim();
this->CreateAnim();

if (this->Animation)
{
Expand Down Expand Up @@ -247,7 +249,7 @@ void AttachEffectClass::CloakCheck()
if (cloakState == CloakState::Cloaked || cloakState == CloakState::Cloaking)
{
this->IsCloaked = true;
KillAnim();
this->KillAnim();
}
else
{
Expand Down Expand Up @@ -330,7 +332,7 @@ bool AttachEffectClass::IsSelfOwned() const

bool AttachEffectClass::HasExpired() const
{
return IsSelfOwned() && this->Delay >= 0 ? false : !this->Duration;
return this->IsSelfOwned() && this->Delay >= 0 ? false : !this->Duration;
}

bool AttachEffectClass::AllowedToBeActive() const
Expand Down Expand Up @@ -367,9 +369,11 @@ bool AttachEffectClass::IsFromSource(TechnoClass* pInvoker, AbstractClass* pSour

AttachEffectTypeClass* AttachEffectClass::GetType() const
{
return Type;
return this->Type;
}

#pragma region StaticFunctions_AttachDetachTransfer

bool AttachEffectClass::Attach(AttachEffectTypeClass* pType, TechnoClass* pTarget, HouseClass* pInvokerHouse, TechnoClass* pInvoker,
AbstractClass* pSource, int durationOverride, int delay, int initialDelay, int recreationDelay)
{
Expand All @@ -378,7 +382,7 @@ bool AttachEffectClass::Attach(AttachEffectTypeClass* pType, TechnoClass* pTarge

auto const pTargetExt = TechnoExt::ExtMap.Find(pTarget);

if (auto const pAE = CreateAndAttach(pType, pTarget, pTargetExt->AttachedEffects, pInvokerHouse, pInvoker, pSource, durationOverride, delay, initialDelay, recreationDelay))
if (auto const pAE = AttachEffectClass::CreateAndAttach(pType, pTarget, pTargetExt->AttachedEffects, pInvokerHouse, pInvoker, pSource, durationOverride, delay, initialDelay, recreationDelay))
{
if (initialDelay <= 0)
{
Expand Down Expand Up @@ -432,7 +436,7 @@ bool AttachEffectClass::Attach(std::vector<AttachEffectTypeClass*> const& types,
if (recreationDelays.size() > 0)
recreationDelay = recreationDelays[recreationDelays.size() > i ? i : recreationDelays.size() - 1];

if (auto const pAE = CreateAndAttach(pType, pTarget, pTargetExt->AttachedEffects, pInvokerHouse, pInvoker, pSource, durationOverride, delay, initialDelay, recreationDelay))
if (auto const pAE = AttachEffectClass::CreateAndAttach(pType, pTarget, pTargetExt->AttachedEffects, pInvokerHouse, pInvoker, pSource, durationOverride, delay, initialDelay, recreationDelay))
{
attachedCount++;

Expand Down Expand Up @@ -514,7 +518,7 @@ int AttachEffectClass::Detach(AttachEffectTypeClass* pType, TechnoClass* pTarget
return 0;

auto const pTargetExt = TechnoExt::ExtMap.Find(pTarget);
int detachedCount = RemoveAllOfType(pType, pTargetExt->AttachedEffects);
int detachedCount = AttachEffectClass::RemoveAllOfType(pType, pTargetExt->AttachedEffects);

if (detachedCount > 0)
{
Expand All @@ -538,7 +542,7 @@ int AttachEffectClass::Detach(std::vector<AttachEffectTypeClass*> const& types,

for (auto const pType : types)
{
int count = RemoveAllOfType(pType, pTargetExt->AttachedEffects);
int count = AttachEffectClass::RemoveAllOfType(pType, pTargetExt->AttachedEffects);

if (count && pType->HasTint())
markForRedraw = true;
Expand Down Expand Up @@ -633,14 +637,16 @@ void AttachEffectClass::TransferAttachedEffects(TechnoClass* pSource, TechnoClas
}
else
{
if (auto const pAE = CreateAndAttach(type, pTarget, pTargetExt->AttachedEffects, attachEffect->InvokerHouse, attachEffect->Invoker, attachEffect->Source, attachEffect->DurationOverride))
if (auto const pAE = AttachEffectClass::CreateAndAttach(type, pTarget, pTargetExt->AttachedEffects, attachEffect->InvokerHouse, attachEffect->Invoker, attachEffect->Source, attachEffect->DurationOverride))
pAE->Duration = attachEffect->Duration;
}

it = pSourceExt->AttachedEffects.erase(it);
}
}

#pragma endregion

// =============================
// load / save

Expand Down
13 changes: 7 additions & 6 deletions src/New/Entity/ShieldClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ void ShieldClass::AI()
return;

this->TemporalCheck();

if (this->Temporal)
return;

Expand Down Expand Up @@ -450,7 +451,7 @@ void ShieldClass::OnlineCheck()
if (!isActive)
{
if (this->Online)
UpdateTint();
this->UpdateTint();

this->Online = false;
timer->Pause();
Expand Down Expand Up @@ -481,7 +482,7 @@ void ShieldClass::OnlineCheck()
else
{
if (!this->Online)
UpdateTint();
this->UpdateTint();

this->Online = true;
timer->Resume();
Expand Down Expand Up @@ -530,7 +531,7 @@ bool ShieldClass::ConvertCheck()
this->KillAnim();
pTechnoExt->CurrentShieldType = ShieldTypeClass::FindOrAllocate(NONE_STR);
pTechnoExt->Shield = nullptr;
UpdateTint();
this->UpdateTint();

return true;
}
Expand Down Expand Up @@ -573,7 +574,7 @@ bool ShieldClass::ConvertCheck()
}

this->TechnoID = newID;
UpdateTint();
this->UpdateTint();

return false;
}
Expand Down Expand Up @@ -670,7 +671,7 @@ void ShieldClass::BreakShield(AnimTypeClass* pBreakAnim, WeaponTypeClass* pBreak

this->LastBreakFrame = Unsorted::CurrentFrame;

UpdateTint();
this->UpdateTint();

if (pWeaponType)
TechnoExt::FireWeaponAtSelf(this->Techno, pWeaponType);
Expand All @@ -686,7 +687,7 @@ void ShieldClass::RespawnShield()
timer->Stop();
double amount = timerWHModifier->InProgress() ? Respawn_Warhead : this->Type->Respawn;
this->HP = this->GetPercentageAmount(amount);
UpdateTint();
this->UpdateTint();
}
else if (timerWHModifier->Completed() && timer->InProgress())
{
Expand Down

0 comments on commit 96b5686

Please sign in to comment.