mirror of
https://github.com/pret/pmd-red.git
synced 2024-11-23 13:09:56 +00:00
remove DUMMY_TEAM_ITEMS_ASM_MATCH
This commit is contained in:
parent
da198b95ca
commit
a0e68c46e9
@ -83,14 +83,6 @@ s32 SaveTeamInventory(u8 *, u32 size);
|
|||||||
s32 WriteHighDecimal(s32, u8 *strbuf, u8);
|
s32 WriteHighDecimal(s32, u8 *strbuf, u8);
|
||||||
u32 sub_80913E0(Item *slot, u32, struct subStruct_203B240 **);
|
u32 sub_80913E0(Item *slot, u32, struct subStruct_203B240 **);
|
||||||
|
|
||||||
// This macro doesn't do anything, it creates unused variables for the purpose of tricking the compiler and matching the asm.
|
|
||||||
// It's possible there was some unknown macro, or the structure of TeamInventory/Item is not 100% how it was originally written.
|
|
||||||
#define DUMMY_TEAM_ITEMS_ASM_MATCH(id) \
|
|
||||||
{ \
|
|
||||||
UNUSED size_t offs = id * sizeof(Item); \
|
|
||||||
UNUSED Item *item = &gTeamInventoryRef->teamItems[id]; \
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void ZeroOutItem(Item *item)
|
static inline void ZeroOutItem(Item *item)
|
||||||
{
|
{
|
||||||
item->id = 0;
|
item->id = 0;
|
||||||
|
@ -2731,11 +2731,7 @@ void CreateFieldItemMenu(s32 a0, Entity *a1, bool8 a2, bool8 a3, UnkTextStruct3
|
|||||||
case 0:
|
case 0:
|
||||||
PrintFormatStringOnWindow(x, 0, gTeamToolboxAPtr, 0, 0);
|
PrintFormatStringOnWindow(x, 0, gTeamToolboxAPtr, 0, 0);
|
||||||
for (i = 0; i < 10; i++) {
|
for (i = 0; i < 10; i++) {
|
||||||
Item *items;
|
if (ItemExists(&gTeamInventoryRef->teamItems[i])) {
|
||||||
DUMMY_TEAM_ITEMS_ASM_MATCH(i);
|
|
||||||
|
|
||||||
items = gTeamInventoryRef->teamItems;
|
|
||||||
if (items[i].flags & ITEM_FLAG_EXISTS) {
|
|
||||||
gUnknown_202EE10.unk1A++;
|
gUnknown_202EE10.unk1A++;
|
||||||
sub_8090E14(txtBuff, &gTeamInventoryRef->teamItems[i], &gUnknown_8106B60);
|
sub_8090E14(txtBuff, &gTeamInventoryRef->teamItems[i], &gUnknown_8106B60);
|
||||||
y = sub_8013800(&gUnknown_202EE10, i);
|
y = sub_8013800(&gUnknown_202EE10, i);
|
||||||
@ -2749,11 +2745,7 @@ void CreateFieldItemMenu(s32 a0, Entity *a1, bool8 a2, bool8 a3, UnkTextStruct3
|
|||||||
case 1:
|
case 1:
|
||||||
PrintFormatStringOnWindow(x, 0, gTeamToolboxBPtr, 0, 0);
|
PrintFormatStringOnWindow(x, 0, gTeamToolboxBPtr, 0, 0);
|
||||||
for (i = 0; i < 10; i++) {
|
for (i = 0; i < 10; i++) {
|
||||||
Item *items;
|
if (ItemExists(&gTeamInventoryRef->teamItems[i + 10])) {
|
||||||
DUMMY_TEAM_ITEMS_ASM_MATCH(i);
|
|
||||||
|
|
||||||
items = gTeamInventoryRef->teamItems;
|
|
||||||
if (items[i + 10].flags & 1) {
|
|
||||||
gUnknown_202EE10.unk1A++;
|
gUnknown_202EE10.unk1A++;
|
||||||
sub_8090E14(txtBuff, &gTeamInventoryRef->teamItems[i + 10], &gUnknown_8106B60);
|
sub_8090E14(txtBuff, &gTeamInventoryRef->teamItems[i + 10], &gUnknown_8106B60);
|
||||||
y = sub_8013800(&gUnknown_202EE10, i);
|
y = sub_8013800(&gUnknown_202EE10, i);
|
||||||
@ -2912,10 +2904,9 @@ void sub_8060900(Entity *a0)
|
|||||||
sub_8044FF0(9);
|
sub_8044FF0(9);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Why is it checking actionUseIndex again?
|
}
|
||||||
if (gUnknown_202F238.actionUseIndex == 128 && gDungeon->unk65B != 0) {
|
if (gUnknown_202F238.actionUseIndex == 128 && gDungeon->unk65B != 0) {
|
||||||
sub_8044F5C(10, item->id);
|
sub_8044F5C(10, item->id);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val_sub8044DC8 = sub_8044DC8(item);
|
val_sub8044DC8 = sub_8044DC8(item);
|
||||||
if (val_sub8044DC8 != 0) {
|
if (val_sub8044DC8 != 0) {
|
||||||
@ -2933,7 +2924,7 @@ void sub_8060900(Entity *a0)
|
|||||||
{
|
{
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
if (item->flags & ITEM_FLAG_SET) {
|
if (ItemSet(item)) {
|
||||||
sub_8044F5C(0x3D, item->id);
|
sub_8044F5C(0x3D, item->id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2941,13 +2932,9 @@ void sub_8060900(Entity *a0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < INVENTORY_SIZE; i++) {
|
for (i = 0; i < INVENTORY_SIZE; i++) {
|
||||||
// Compiler uses r5 without the fakematch trick. It's gTeamInventoryRef causing matching issues again...
|
if (ItemExists(&gTeamInventoryRef->teamItems[i])
|
||||||
#ifndef NONMATCHING
|
&& ItemSet(&gTeamInventoryRef->teamItems[i])
|
||||||
item++;item--;
|
&& ItemSticky(&gTeamInventoryRef->teamItems[i]))
|
||||||
#endif // NONMATCHING
|
|
||||||
if (gTeamInventoryRef->teamItems[i].flags & ITEM_FLAG_EXISTS
|
|
||||||
&& gTeamInventoryRef->teamItems[i].flags & ITEM_FLAG_SET
|
|
||||||
&& gTeamInventoryRef->teamItems[i].flags & ITEM_FLAG_STICKY)
|
|
||||||
{
|
{
|
||||||
sub_8044FF0(0x3C);
|
sub_8044FF0(0x3C);
|
||||||
sub_8044FF0(0x3D);
|
sub_8044FF0(0x3D);
|
||||||
|
22
src/items.c
22
src/items.c
@ -484,14 +484,7 @@ void FillInventoryGaps()
|
|||||||
|
|
||||||
// clear out the rest of the slots
|
// clear out the rest of the slots
|
||||||
for (; last_filled < INVENTORY_SIZE; last_filled++) {
|
for (; last_filled < INVENTORY_SIZE; last_filled++) {
|
||||||
struct Item *items;
|
ZeroOutItem(&gTeamInventoryRef->teamItems[last_filled]);
|
||||||
|
|
||||||
DUMMY_TEAM_ITEMS_ASM_MATCH(last_filled);
|
|
||||||
items = gTeamInventoryRef->teamItems;
|
|
||||||
|
|
||||||
items[last_filled].id = ITEM_NOTHING;
|
|
||||||
items[last_filled].quantity = 0;
|
|
||||||
items[last_filled].flags = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,12 +568,8 @@ bool8 AddItemToInventory(const Item* slot)
|
|||||||
|
|
||||||
// try to add item to inventory, return 1 if failed
|
// try to add item to inventory, return 1 if failed
|
||||||
for (i = 0; i < INVENTORY_SIZE; i++) {
|
for (i = 0; i < INVENTORY_SIZE; i++) {
|
||||||
Item *items;
|
if (!ItemExists(&gTeamInventoryRef->teamItems[i])) {
|
||||||
DUMMY_TEAM_ITEMS_ASM_MATCH(i);
|
gTeamInventoryRef->teamItems[i] = *slot;
|
||||||
|
|
||||||
items = gTeamInventoryRef->teamItems;
|
|
||||||
if (!(items[i].flags & ITEM_FLAG_EXISTS)) {
|
|
||||||
items[i] = *slot;
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -908,12 +897,9 @@ bool8 IsGummiItem(u8 id)
|
|||||||
|
|
||||||
bool8 HasGummiItem(void)
|
bool8 HasGummiItem(void)
|
||||||
{
|
{
|
||||||
Item *items;
|
|
||||||
s32 i;
|
s32 i;
|
||||||
for (i = 0; i < INVENTORY_SIZE; i++) {
|
for (i = 0; i < INVENTORY_SIZE; i++) {
|
||||||
DUMMY_TEAM_ITEMS_ASM_MATCH(i);
|
if (ItemExists(&gTeamInventoryRef->teamItems[i]) && IsGummiItem(gTeamInventoryRef->teamItems[i].id)) {
|
||||||
items = gTeamInventoryRef->teamItems;
|
|
||||||
if ((items[i].flags & ITEM_FLAG_EXISTS) && IsGummiItem(items[i].id)) {
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
31
src/trap.c
31
src/trap.c
@ -407,7 +407,7 @@ void HandleStickyTrap(Entity *pokemon,Entity *target)
|
|||||||
int newIndex;
|
int newIndex;
|
||||||
Item *itemStack[21];
|
Item *itemStack[21];
|
||||||
|
|
||||||
info = target->info;
|
info = GetEntInfo(target);
|
||||||
if (HasHeldItem(target,0xe)) {
|
if (HasHeldItem(target,0xe)) {
|
||||||
sub_80522F4(pokemon,target,*gUnknown_80FDC7C);
|
sub_80522F4(pokemon,target,*gUnknown_80FDC7C);
|
||||||
}
|
}
|
||||||
@ -416,32 +416,29 @@ void HandleStickyTrap(Entity *pokemon,Entity *target)
|
|||||||
itemCount = 0;
|
itemCount = 0;
|
||||||
if (info->isTeamLeader) {
|
if (info->isTeamLeader) {
|
||||||
for (index = 0; index < INVENTORY_SIZE; index++) {
|
for (index = 0; index < INVENTORY_SIZE; index++) {
|
||||||
struct Item *items;
|
if (ItemExists(&gTeamInventoryRef->teamItems[index]) && IsNotSpecialItem(gTeamInventoryRef->teamItems[index].id)) {
|
||||||
DUMMY_TEAM_ITEMS_ASM_MATCH(index);
|
Item *item = &gTeamInventoryRef->teamItems[index];
|
||||||
|
if (!ItemSticky(item)) {
|
||||||
items = gTeamInventoryRef->teamItems;
|
itemStack[itemCount] = item;
|
||||||
if ((items[index].flags & ITEM_FLAG_EXISTS)
|
|
||||||
&& IsNotSpecialItem(items[index].id)
|
|
||||||
&& !(gTeamInventoryRef->teamItems[index].flags & ITEM_FLAG_STICKY)) {
|
|
||||||
itemStack[itemCount] = &gTeamInventoryRef->teamItems[index];
|
|
||||||
itemCount++;
|
itemCount++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((info->heldItem.flags & ITEM_FLAG_EXISTS) && IsNotSpecialItem((info->heldItem).id) && !(info->heldItem.flags & ITEM_FLAG_STICKY)) {
|
if (ItemExists(&info->heldItem) && IsNotSpecialItem((info->heldItem).id) && !ItemSticky(&info->heldItem)) {
|
||||||
itemStack[itemCount] = &info->heldItem;
|
itemStack[itemCount] = &info->heldItem;
|
||||||
itemCount++;
|
itemCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemCount == 0) {
|
if (itemCount == 0) {
|
||||||
sub_80522F4(pokemon,target,*gUnknown_80FDC40);
|
sub_80522F4(pokemon,target,*gUnknown_80FDC40);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newIndex = DungeonRandInt(itemCount);
|
newIndex = DungeonRandInt(itemCount);
|
||||||
sub_8045BF8(gFormatItems, itemStack[newIndex]);
|
sub_8045BF8(gFormatItems, itemStack[newIndex]);
|
||||||
itemStack[newIndex]->flags |= ITEM_FLAG_STICKY;
|
itemStack[newIndex]->flags |= ITEM_FLAG_STICKY;
|
||||||
sub_80421C0(target, 0x192);
|
sub_80421C0(target, 0x192);
|
||||||
sub_80522F4(pokemon,target,*gUnknown_80FDC18);
|
sub_80522F4(pokemon,target,*gUnknown_80FDC18);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user