From bc334ccc9f5255079754da0e15dbe3ee0ea5a570 Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Thu, 2 Jun 2016 19:19:50 +0200 Subject: [PATCH] Avoid creating the targeter layers if the inventory item isn't attached to its owner yet --- src/g_shared/a_artifacts.cpp | 15 +++++++++++++-- src/g_shared/a_artifacts.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 6afae78f8..55496a7f1 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1294,6 +1294,11 @@ void APowerTargeter::Travelled () void APowerTargeter::InitEffect () { + // Why is this called when the inventory isn't even attached yet + // in APowerup::CreateCopy? + if (!Owner->FindInventory(GetClass(), true)) + return; + player_t *player; Super::InitEffect(); @@ -1317,6 +1322,14 @@ void APowerTargeter::InitEffect () PositionAccuracy (); } +void APowerTargeter::AttachToOwner(AActor *other) +{ + Super::AttachToOwner(other); + + // Let's actually properly call this for the targeters. + InitEffect(); +} + bool APowerTargeter::HandlePickup(AInventory *item) { if (Super::HandlePickup(item)) @@ -1327,8 +1340,6 @@ bool APowerTargeter::HandlePickup(AInventory *item) return false; } - - void APowerTargeter::DoEffect () { Super::DoEffect (); diff --git a/src/g_shared/a_artifacts.h b/src/g_shared/a_artifacts.h index 9ed285ca5..2a52756ab 100644 --- a/src/g_shared/a_artifacts.h +++ b/src/g_shared/a_artifacts.h @@ -182,6 +182,7 @@ protected: void EndEffect (); void PositionAccuracy (); void Travelled (); + void AttachToOwner(AActor *other); bool HandlePickup(AInventory *item); };