Skip to content

Commit

Permalink
Implement ItemManager ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
roblabla committed Nov 24, 2024
1 parent df57869 commit c6bb220
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions config/implemented.csv
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ th06::utils::DebugPrint
th06::utils::DebugPrint2
th06::FileSystem::OpenPath
th06::FileSystem::WriteDataToFile
th06::ItemManager::ItemManager
th06::ItemManager::SpawnItem
th06::ItemManager::OnUpdate
th06::ItemManager::OnDraw
Expand Down
12 changes: 6 additions & 6 deletions src/ItemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ void ItemManager::SpawnItem(D3DXVECTOR3 *position, ItemType itemType, int state)
i32 idx;

item = &this->items[this->nextIndex];
for (idx = 0; idx < ARRAY_SIZE_SIGNED(this->items); idx++)
for (idx = 0; idx < ARRAY_SIZE_SIGNED(this->items) - 1; idx++)
{
this->nextIndex++;
if (item->isInUse)
{
if (this->nextIndex >= ARRAY_SIZE_SIGNED(this->items))
if (this->nextIndex >= ARRAY_SIZE_SIGNED(this->items) - 1)
{
this->nextIndex = 0;
item = &this->items[0];
Expand All @@ -36,7 +36,7 @@ void ItemManager::SpawnItem(D3DXVECTOR3 *position, ItemType itemType, int state)
}
continue;
}
if (this->nextIndex >= ARRAY_SIZE_SIGNED(this->items))
if (this->nextIndex >= ARRAY_SIZE_SIGNED(this->items) - 1)
{
this->nextIndex = 0;
}
Expand Down Expand Up @@ -96,7 +96,7 @@ void ItemManager::OnUpdate()
static D3DXVECTOR3 g_ItemSize(16.0f, 16.0f, 16.0f);
itemAcquired = false;
this->itemCount = 0;
for (idx = 0; idx < ARRAY_SIZE_SIGNED(this->items); idx++, curItem++)
for (idx = 0; idx < ARRAY_SIZE_SIGNED(this->items) - 1; idx++, curItem++)
{
if (!curItem->isInUse)
{
Expand Down Expand Up @@ -338,7 +338,7 @@ void ItemManager::RemoveAllItems()
Item *cursor;
i32 idx;

for (cursor = &this->items[0], idx = 0; idx < ARRAY_SIZE_SIGNED(this->items); idx += 1, cursor += 1)
for (cursor = &this->items[0], idx = 0; idx < ARRAY_SIZE_SIGNED(this->items) - 1; idx += 1, cursor += 1)
{
if (!cursor->isInUse)
{
Expand All @@ -358,7 +358,7 @@ void ItemManager::OnDraw()

curItem = &this->items[0];
idx = 0;
for (; idx < ARRAY_SIZE_SIGNED(this->items); idx++, curItem++)
for (; idx < ARRAY_SIZE_SIGNED(this->items) - 1; idx++, curItem++)
{
if (curItem->isInUse == 0)
{
Expand Down
3 changes: 1 addition & 2 deletions src/ItemManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ struct ItemManager
void OnDraw();
void RemoveAllItems();

Item items[512];
Item dummyItemForFailedSpawns;
Item items[513];
i32 nextIndex;
u32 itemCount;
};
Expand Down

0 comments on commit c6bb220

Please sign in to comment.