minepool add and remove

This commit is contained in:
Niko 2022-08-30 12:22:20 -04:00
parent b21d1438c0
commit 3d49d7dc7c
3 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,27 @@
#include <common.h>
void DECOMP_RB_MinePool_Add(struct MineWeapon* mw)
{
struct WeaponSlot231* ws;
// if no more items on free list
// (800b2ea8 + 8 = 800b2eb0)
if (*(int*)0x800b2ea8 == 0)
{
// remove oldest mine
// RB_MinePool_Remove
// (800b2e9c + 4 = 800b2ea0) (taken->last)
// (*(int*)800b2ea0 + 8) (taken->last->mineWeapon)
RB_MinePool_Remove(*(int*)(*(int*)0x800b2ea0 + 8)
}
// LIST_RemoveBack free list, AddFront to taken list
ws = LIST_RemoveBack(0x800b2ea8);
LIST_AddFront(0x800b2e9c, ws);
// link together
ws->mineWeapon = mw;
mw->weaponSlot231 = ws;
}

View File

@ -0,0 +1,16 @@
#include <common.h>
void DECOMP_RB_MinePool_Remove(struct MineWeapon* mw)
{
struct WeaponSlot231* ws = mw->weaponSlot231;
// useless check?
if(ws == 0) return;
// remove from taken, add to free
LIST_RemoveMember(0x800b2e9c, ws);
LIST_AddFront(0x800b2ea8, ws);
mw->boolDestroyed = 1;
mw->weaponSlot231 = 0;
}

View File

@ -461,6 +461,8 @@ void FUN_800ac13c(int param_1)
// remove oldest mine
// RB_MinePool_Remove
// (800b2e9c + 4 = 800b2ea0) (taken->last)
// (*(int*)800b2ea0 + 8) (taken->last->mineWeapon)
FUN_800ac0e4(*(undefined4 *)(DAT_800b2ea0 + 8));
}