Skip to content

Commit

Permalink
Clear item inventory when respawning
Browse files Browse the repository at this point in the history
  • Loading branch information
malleoz authored and vabold committed Jan 26, 2025
1 parent cf026ce commit ca852f8
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/game/item/ItemDirector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ void ItemDirector::calc() {
}
}

KartItem &ItemDirector::kartItem(size_t idx) {
ASSERT(idx < m_karts.size());
return m_karts[idx];
}

/// @addr{0x80799138}
ItemDirector *ItemDirector::CreateInstance() {
ASSERT(!s_instance);
Expand Down
2 changes: 2 additions & 0 deletions source/game/item/ItemDirector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public:
void init();
void calc();

KartItem &kartItem(size_t idx);

static ItemDirector *CreateInstance();
static void DestroyInstance();
[[nodiscard]] static ItemDirector *Instance();
Expand Down
5 changes: 5 additions & 0 deletions source/game/item/ItemInventory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ void ItemInventory::useItem(int count) {
return;
}

clear();
}

/// @addr{0x807BC9C0}
void ItemInventory::clear() {
m_currentId = ItemId::NONE;
m_currentCount = 0;
}
Expand Down
1 change: 1 addition & 0 deletions source/game/item/ItemInventory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public:
/// @beginSetters
void setItem(ItemId id);
void useItem(int count);
void clear();
/// @endSetters

/// @beginGetters
Expand Down
7 changes: 7 additions & 0 deletions source/game/item/KartItem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ void KartItem::calc() {
}
}

/// @addr{0x80798848}
void KartItem::clear() {
if (m_inventory.id() != ItemId::NONE) {
m_inventory.clear();
}
}

/// @addr{0x8079864C}
void KartItem::activateMushroom() {
move()->activateMushroom();
Expand Down
1 change: 1 addition & 0 deletions source/game/item/KartItem.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public:

void init(size_t playerIdx);
void calc();
void clear();

void activateMushroom();
void useMushroom();
Expand Down
6 changes: 6 additions & 0 deletions source/game/kart/KartMove.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include "game/field/CollisionDirector.hh"
#include "game/field/KCollisionTypes.hh"

#include "game/item/ItemDirector.hh"
#include "game/item/KartItem.hh"

#include "game/system/CourseMap.hh"
#include "game/system/RaceManager.hh"
#include "game/system/map/MapdataCannonPoint.hh"
Expand Down Expand Up @@ -308,6 +311,9 @@ void KartMove::calcRespawnStart() {
EGG::Vector3f respawnRot = EGG::Vector3f(0.0f, jugemRot.y, 0.0f);

setInitialPhysicsValues(respawnPos, respawnRot);

Item::ItemDirector::Instance()->kartItem(0).clear();

state()->setTriggerRespawn(false);
state()->setInRespawn(true);
}
Expand Down

0 comments on commit ca852f8

Please sign in to comment.