Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Ext/WeaponType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <Ext/Techno/Body.h>

WeaponTypeExt::ExtContainer WeaponTypeExt::ExtMap;
int WeaponTypeExt::LaserTrackingWeaponCount = 0;

bool WeaponTypeExt::HasRequiredAttachedEffects(TechnoClass* pTarget, TechnoClass* pFirer) const
{
Expand Down Expand Up @@ -118,6 +119,8 @@ void WeaponTypeExt::LoadFromINIFile(CCINIClass* const pINI)
this->FeedbackWeapon.Read<true>(exINI, pSection, "FeedbackWeapon");
this->Laser_IsSingleColor.Read(exINI, pSection, "IsSingleColor");
this->LaserPositionUpdate.Read(exINI, pSection, "LaserPositionUpdate");
if (this->LaserPositionUpdate != PositionFollow::None)
++WeaponTypeExt::LaserTrackingWeaponCount;
this->LaserPositionUpdate_StopOnFirerConvert.Read(exINI, pSection, "LaserPositionUpdate.StopOnFirerConvert");
this->LaserZAdjust.Read(exINI, pSection, "LaserZAdjust");
this->EBoltZAdjust.Read(exINI, pSection, "EBoltZAdjust");
Expand Down Expand Up @@ -506,6 +509,10 @@ DEFINE_HOOK(0x77311D, WeaponTypeClass_SDDTOR, 0x6)
{
GET(WeaponTypeClass*, pItem, ESI);

auto pExt = WeaponTypeExt::TryFetch(pItem);
if (pExt && pExt->LaserPositionUpdate != PositionFollow::None)
Comment thread
Coronia marked this conversation as resolved.
Outdated
--WeaponTypeExt::LaserTrackingWeaponCount;

WeaponTypeExt::ExtMap.Remove(pItem);

return 0;
Expand Down
1 change: 1 addition & 0 deletions src/Ext/WeaponType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,5 +259,6 @@ class WeaponTypeExt final : public AbstractTypeExt

// Misc/Hooks.LaserDraw.cpp
static void OnObjectRemoved(ObjectClass* pObject);
static int LaserTrackingWeaponCount;
};

10 changes: 6 additions & 4 deletions src/Misc/Hooks.LaserDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,11 @@ namespace LaserRT
// IsLaser this is no longer necessary, but the handling of DiskLaser is more complex, and keeping the CTOR is currently the most cost-effective solution.
DEFINE_HOOK(0x54FE60, LaserDrawClass_CTOR_Update, 0x5)
{
GET(LaserDrawClass*, pLaser, ECX);
LaserRT::TrackingMap[pLaser] = LaserRT::TrackingData {};
if (WeaponTypeExt::LaserTrackingWeaponCount > 0)
{
GET(LaserDrawClass*, pLaser, ECX);
LaserRT::TrackingMap[pLaser] = LaserRT::TrackingData {};
}
return 0;
}

Expand Down Expand Up @@ -305,8 +308,7 @@ DEFINE_HOOK(0x6FD446, TechnoClass_LaserZap_Tracking, 0x7)
return 0;
}

static LaserDrawClass* __fastcall Shrapnel_CreateLaser_Wrapper(TechnoClass* pShooter, void*, ObjectClass* pTarget
, int weaponIdx, WeaponTypeClass* pWeapon, const CoordStruct& sourceCoords)
static LaserDrawClass* __fastcall Shrapnel_CreateLaser_Wrapper(TechnoClass* pShooter, void*, ObjectClass* pTarget, int weaponIdx, WeaponTypeClass* pWeapon, const CoordStruct& sourceCoords)
{
const auto mode = WeaponTypeExt::Fetch(pWeapon)->LaserPositionUpdate.Get();

Expand Down