Skip to content

Commit

Permalink
fix: crashes in inventory and projectile systems
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed May 1, 2022
1 parent 7d5b60a commit 6a0ef9c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Code/client/Games/Skyrim/Projectiles/Projectile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,21 @@ BSPointerHandle<Projectile>* Projectile::Launch(BSPointerHandle<Projectile>* apR
BSPointerHandle<Projectile>* result = ThisCall(RealLaunch, apResult, apLaunchData);

TP_ASSERT(result, "No projectile handle returned.");
if (!result)
{
spdlog::error("No projectile handle returned.");
return nullptr;
}

TESObjectREFR* pObject = TESObjectREFR::GetByHandle(result->handle.iBits);
Projectile* pProjectile = Cast<Projectile>(pObject);

TP_ASSERT(pProjectile, "No projectile found.");
if (!pProjectile)
{
spdlog::error("No projectile found.");
return nullptr;
}

pProjectile->fPower = apLaunchData.fPower;

Expand Down
6 changes: 6 additions & 0 deletions Code/client/Services/Generic/InventoryService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ void InventoryService::OnNotifyEquipmentChanges(const NotifyEquipmentChanges& ac
uint32_t itemId = modSystem.GetGameId(acMessage.ItemId);
TESForm* pItem = TESForm::GetById(itemId);

if (!pItem)
{
spdlog::error("Could not find inventory item {:X}:{:X}", acMessage.ItemId.ModId, acMessage.ItemId.BaseId);
return;
}

uint32_t equipSlotId = modSystem.GetGameId(acMessage.EquipSlotId);
TESForm* pEquipSlot = TESForm::GetById(equipSlotId);

Expand Down

0 comments on commit 6a0ef9c

Please sign in to comment.