summaryrefslogtreecommitdiff
path: root/src/object
diff options
context:
space:
mode:
authornotyourav <65437533+notyourav@users.noreply.github.com>2022-03-25 11:37:47 -0700
committerGitHub <noreply@github.com>2022-03-25 11:37:47 -0700
commit74f88fe5eeaf14ed3f6e8d6344aca88a36d7a697 (patch)
treec23006fd1b5804757c535d52b53748fd6fdf04a2 /src/object
parentd806dff71372ded8654a790d7085fda1c2331a3d (diff)
parent29ef1953f0e05468e1df84bc4944af98c158cd33 (diff)
Merge pull request #467 from EllipticEllipsis/pointers
Diffstat (limited to 'src/object')
-rw-r--r--src/object/bakerOven.c2
-rw-r--r--src/object/bigBarrel.c6
-rw-r--r--src/object/book.c46
-rw-r--r--src/object/button.c2
-rw-r--r--src/object/fileScreenObjects.c4
-rw-r--r--src/object/floatingPlatform.c7
-rw-r--r--src/object/gyorgBossObject.c1
-rw-r--r--src/object/houseDoorExterior.c4
-rw-r--r--src/object/lilypadSmall.c20
-rw-r--r--src/object/object49.c8
-rw-r--r--src/object/pot.c2
-rw-r--r--src/object/specialFx.c10
12 files changed, 55 insertions, 57 deletions
diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c
index fd2b80aa..d4b26c28 100644
--- a/src/object/bakerOven.c
+++ b/src/object/bakerOven.c
@@ -22,7 +22,7 @@ void sub_0809CC74(Entity* this) {
/* Create steam clouds */
for (i = 0; i < 3; i++) {
ent = CreateObject(BAKER_OVEN, 1, i);
- if (ent) {
+ if (ent != NULL) {
ent->parent = this;
PositionRelative(this, ent, 16 * Q_16_16((i + 1) / 2) - Q_16_16(8.0), Q_16_16(-14.0));
}
diff --git a/src/object/bigBarrel.c b/src/object/bigBarrel.c
index af09b0f4..77e6ff6a 100644
--- a/src/object/bigBarrel.c
+++ b/src/object/bigBarrel.c
@@ -105,7 +105,7 @@ void sub_08088BE0(BigBarrelEntity* this) {
if (CheckLocalFlag(0x15) == 0) {
sub_08088C78(this, 2, 0, 0xffffff88);
ent = sub_08088C78(this, 4, 0x15, 0);
- if (ent) {
+ if (ent != NULL) {
ent->x.HALF.HI = gRoomControls.origin_x + 0x48;
ent->y.HALF.HI = gRoomControls.origin_y + 200;
}
@@ -114,7 +114,7 @@ void sub_08088BE0(BigBarrelEntity* this) {
if (CheckLocalFlag(0x16) == 0) {
sub_08088C78(this, 2, 1, 0x78);
ent = sub_08088C78(this, 4, 0x16, 0);
- if (ent) {
+ if (ent != NULL) {
ent->x.HALF.HI = gRoomControls.origin_x + 0x188;
ent->y.HALF.HI = gRoomControls.origin_y + 200;
}
@@ -249,7 +249,7 @@ void sub_08088E74(BigBarrelEntity* this) {
} else {
if ((gRoomTransition.frameCount & 7U) == 0) {
ent = CreateObjectWithParent(super, OBJECT_2A, 0, 0x1e);
- if (ent) {
+ if (ent != NULL) {
ent->updatePriority = 3;
ent->spriteRendering.b3 = 0;
ent->spritePriority.b0 = 0;
diff --git a/src/object/book.c b/src/object/book.c
index f42b2f1d..3c9e12b5 100644
--- a/src/object/book.c
+++ b/src/object/book.c
@@ -15,11 +15,9 @@ void Book(Entity* this) {
}
void sub_0809B3C4(Entity* this) {
- u32 obtained;
-
- obtained = GetInventoryValue(this->type + ITEM_QST_BOOK1);
+ u32 obtained = GetInventoryValue(this->type + ITEM_QST_BOOK1);
if (this->type2 != 3) {
- if (obtained) {
+ if (obtained != 0) {
DeleteThisEntity();
}
} else {
@@ -42,7 +40,7 @@ void sub_0809B3C4(Entity* this) {
}
UpdateSpriteForCollisionLayer(this);
- InitAnimationForceUpdate(this, this->type + 0x39);
+ InitAnimationForceUpdate(this, this->type + ITEM_QST_BOOK1);
switch (this->type2) {
case 0:
@@ -55,22 +53,23 @@ void sub_0809B3C4(Entity* this) {
case 1: {
u32 scroll;
u32 height;
+
this->action = 3;
scroll = (u16)gRoomControls.scroll_y - 0x10;
height = (u16)this->y.HALF.HI - scroll;
this->z.HALF.HI -= height;
- return;
+ break;
}
case 2:
this->action = 4;
- return;
+ break;
case 3:
this->action = 5;
this->subAction = 0;
this->spritePriority.b0 = 3;
break;
default:
- return;
+ break;
}
}
@@ -89,10 +88,10 @@ void sub_0809B4A8(Entity* this) {
this->action = 2;
this->actionDelay = 30;
- this->speed = 64;
- this->direction = 16;
+ this->speed = 0x40;
+ this->direction = 0x10;
- gPlayerState.pushedObject = 0x9e;
+ gPlayerState.pushedObject = TREE_THORNS;
gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= PL_BUSY;
@@ -101,7 +100,7 @@ void sub_0809B4A8(Entity* this) {
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
EnqueueSFX(SFX_10F);
} else {
- this->actionDelay = 0x16;
+ this->actionDelay = 22;
}
}
@@ -109,12 +108,12 @@ void sub_0809B524(Entity* this) {
if (--this->actionDelay == 0) {
if (--this->field_0xf == 0) {
this->action = 3;
- this->y.HALF.HI += 32;
- this->z.HALF.HI -= 32;
+ this->y.HALF.HI += 0x20;
+ this->z.HALF.HI -= 0x20;
} else {
this->action = 1;
this->actionDelay = 22;
- this->field_0x80.HALF.LO = 24;
+ this->field_0x80.HALF.LO = 0x18;
}
}
@@ -134,7 +133,7 @@ void sub_0809B56C(Entity* this) {
SetFlag(this->field_0x86.HWORD);
fx = CreateFx(this, FX_DEATH, 0);
- if (fx) {
+ if (fx != NULL) {
SortEntityAbove(this, fx);
}
}
@@ -143,7 +142,7 @@ void sub_0809B5B4(Entity* this) {
if (gPlayerState.flags & PL_MINISH) {
sub_0800445C(this);
} else if (IsCollidingPlayer(this)) {
- CreateItemEntity(this->type + 0x39, 0, 0);
+ CreateItemEntity(this->type + ITEM_QST_BOOK1, 0, 0);
DeleteThisEntity();
}
}
@@ -152,9 +151,8 @@ void sub_0809B5EC(Entity* this) {
if (this->spriteSettings.draw == 1) {
switch (this->subAction) {
case 0: {
- Entity* parent;
- parent = FindEntityByID(NPC, STURGEON, 7);
- if (!parent) {
+ Entity* parent = FindEntityByID(NPC, STURGEON, 7);
+ if (parent == NULL) {
return;
}
if (parent->x.HALF.HI < this->x.HALF.HI) {
@@ -170,7 +168,7 @@ void sub_0809B5EC(Entity* this) {
break;
}
case 1: {
- if (!this->parent || !this->parent->next) {
+ if ((this->parent == NULL) || (this->parent->next == NULL)) {
DeleteThisEntity();
return;
}
@@ -206,9 +204,8 @@ void sub_0809B5EC(Entity* this) {
}
u32 sub_0809B688(Entity* this) {
- u32 ret;
+ u32 ret = EntityInRectRadius(this, &gPlayerEntity, 6, 12);
- ret = EntityInRectRadius(this, &gPlayerEntity, 6, 12);
if (ret == 1 && gPlayerState.field_0xd != 16) {
ret = 0;
}
@@ -217,8 +214,7 @@ u32 sub_0809B688(Entity* this) {
}
void sub_0809B6B0(Entity* parent, Entity* this) {
- s32 offset;
- offset = (s32)gUnk_08123D94[parent->animationState >> 1] << 16;
+ s32 offset = (s32)gUnk_08123D94[parent->animationState >> 1] << 16;
PositionRelative(parent, this, 0, offset);
diff --git a/src/object/button.c b/src/object/button.c
index 5a29e636..d4f602ba 100644
--- a/src/object/button.c
+++ b/src/object/button.c
@@ -242,7 +242,7 @@ u32 sub_08081F7C(Entity* this, u32 r7) {
if (this->actionDelay == 0)
return 1;
if (--this->actionDelay > 6) {
- if (this->child)
+ if (this->child != NULL)
this->child->spriteOffsetY = -4;
} else {
if (this->actionDelay == 6) {
diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c
index 7d2a295f..c7cac4e7 100644
--- a/src/object/fileScreenObjects.c
+++ b/src/object/fileScreenObjects.c
@@ -252,7 +252,7 @@ void sub_0808EABC(Entity* this) {
void sub_0808EB74(Entity* this) {
Entity* entity = sub_0808EC80(gMapDataBottomSpecial.unk6);
- if (entity) {
+ if (entity != NULL) {
this->x.WORD = entity->x.WORD;
this->y.WORD = entity->y.WORD;
this->spriteRendering.b3 = entity->spriteRendering.b3;
@@ -305,7 +305,7 @@ void sub_0808EBB8(Entity* this) {
// Fall through
default:
entity = sub_0808EC80(var0);
- if (entity) {
+ if (entity != NULL) {
SortEntityBelow(entity, this);
this->spriteRendering.b3 = entity->spriteRendering.b3;
x = entity->x.HALF.HI;
diff --git a/src/object/floatingPlatform.c b/src/object/floatingPlatform.c
index d62d7603..9701ba66 100644
--- a/src/object/floatingPlatform.c
+++ b/src/object/floatingPlatform.c
@@ -33,12 +33,11 @@ void sub_080860D8(FloatingPlatformEntity* this) {
}
void sub_0808611C(FloatingPlatformEntity* this) {
- int iVar2;
+ bool32 iVar2 = sub_08086168(this);
- iVar2 = sub_08086168(this);
if (super->actionDelay != 0 && super->parent->actionDelay == 0) {
- if (iVar2 != 0) {
+ if (iVar2) {
super->parent->actionDelay++;
}
@@ -46,7 +45,7 @@ void sub_0808611C(FloatingPlatformEntity* this) {
} else if (super->actionDelay == 0) {
sub_080A2BE4(super, iVar2);
} else {
- sub_080A2BE4(super, 0);
+ sub_080A2BE4(super, FALSE);
}
if (--this->unk70 == 0) {
diff --git a/src/object/gyorgBossObject.c b/src/object/gyorgBossObject.c
index b63b8d81..ebbec424 100644
--- a/src/object/gyorgBossObject.c
+++ b/src/object/gyorgBossObject.c
@@ -10,7 +10,6 @@
extern const ScreenTransitionData gUnk_0813ABD0;
-extern u32 sub_08079F8C(void);
struct GyorgChildSpawns {
s16 offsetX;
s16 offsetY;
diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c
index 1627c7e8..baadd362 100644
--- a/src/object/houseDoorExterior.c
+++ b/src/object/houseDoorExterior.c
@@ -53,7 +53,7 @@ void sub_080866D8(Entity* this) {
if ((*((u32*)(&this->field_0x68)) & mask) == 0 && sub_080867CC(prop->unk5) &&
CheckRegionOnScreen(prop->unk0, prop->unk2, 32, 32)) {
entity = CreateObject(HOUSE_DOOR_EXT, prop->unk7, prop->unk6);
- if (entity) {
+ if (entity != NULL) {
entity->field_0x6c.HALF.LO = i;
entity->x.HALF.HI = gRoomControls.origin_x + prop->unk0 + 16;
entity->y.HALF.HI = gRoomControls.origin_y + prop->unk2 + 32;
@@ -157,7 +157,7 @@ static void sub_080868EC(Entity* entity, unk_80868EC* arg1) {
void sub_0808692C(Entity* this) {
this->flags &= ~ENT_SCRIPTED;
this->type2 = 2;
- this->action = this->frameIndex == 0 ? 1 : 2;
+ this->action = (this->frameIndex == 0) ? 1 : 2;
this->subAction = 0;
this->actionDelay = 8;
}
diff --git a/src/object/lilypadSmall.c b/src/object/lilypadSmall.c
index ce03ff99..eed1578f 100644
--- a/src/object/lilypadSmall.c
+++ b/src/object/lilypadSmall.c
@@ -4,7 +4,7 @@
extern u16 gUnk_08123318[];
static void sub_08097B24(Entity* this);
-static u32 sub_08097ADC(Entity* this);
+static bool32 sub_08097ADC(Entity* this);
void LilypadSmall(Entity* this) {
u32 rand;
@@ -29,19 +29,19 @@ void LilypadSmall(Entity* this) {
}
}
-static u32 sub_08097ADC(Entity* this) {
- if ((gPlayerState.flags & PL_MINISH) == 0) {
- return 0;
+static bool32 sub_08097ADC(Entity* this) {
+ if (!(gPlayerState.flags & PL_MINISH)) {
+ return FALSE;
} else if (EntityInRectRadius(this, &gPlayerEntity, 8, 8) == 0) {
- return 0;
- } else if (sub_08079F8C() == 0) {
- return 0;
+ return FALSE;
+ } else if (!sub_08079F8C()) {
+ return FALSE;
} else {
gPlayerState.field_0x14 = 1;
if (gPlayerEntity.z.HALF.HI != 0) {
- return 0;
+ return FALSE;
} else {
- return 1;
+ return TRUE;
}
}
}
@@ -52,7 +52,7 @@ static void sub_08097B24(Entity* this) {
u16* temp3;
if (--this->actionDelay == 0) {
- this->actionDelay = 0x5a;
+ this->actionDelay = 90;
this->frameIndex = (this->frameIndex + 1) & 3;
}
temp3 = gUnk_08123318;
diff --git a/src/object/object49.c b/src/object/object49.c
index 1b74b298..4eca5e6e 100644
--- a/src/object/object49.c
+++ b/src/object/object49.c
@@ -195,7 +195,7 @@ void sub_0808F3DC(Entity* this) {
if (this->type == 5 && (this->frame & 1)) {
Entity* entity = CreateObjectWithParent(this->child, 0x49, 8, 0);
- if (entity) {
+ if (entity != NULL) {
entity->parent = this->parent;
entity->child = this->parent->parent;
}
@@ -262,19 +262,19 @@ void sub_0808F554(Entity* this) {
void sub_0808F5EC(Entity* this) {
Entity* entity = CreateObjectWithParent(this->child, 0x49, 5, 0);
- if (entity) {
+ if (entity != NULL) {
entity->parent = this;
entity->child = this->child;
}
entity = CreateObjectWithParent(this->child, 0x49, 6, 0);
- if (entity) {
+ if (entity != NULL) {
entity->parent = this;
entity->child = this->child;
}
entity = CreateObjectWithParent(this->child, 0x49, 7, 0);
- if (entity) {
+ if (entity != NULL) {
entity->parent = this;
entity->child = this->child;
}
diff --git a/src/object/pot.c b/src/object/pot.c
index 22ee8ce0..a11c6d4d 100644
--- a/src/object/pot.c
+++ b/src/object/pot.c
@@ -283,7 +283,7 @@ u32 sub_0808288C(Entity* this, u32 form, u32 arg2, u32 arg3) {
break;
default:
entity = CreateObjectWithParent(this, GROUND_ITEM, form, arg2);
- if (entity) {
+ if (entity != NULL) {
if (arg3 == 2) {
entity->actionDelay = 5;
entity->field_0x86.HWORD = this->field_0x86.HWORD;
diff --git a/src/object/specialFx.c b/src/object/specialFx.c
index c5262d9c..dc51b4c4 100644
--- a/src/object/specialFx.c
+++ b/src/object/specialFx.c
@@ -144,6 +144,7 @@ void sub_080844E0(SpecialFxObject* this) {
static const u8 gUnk_0811FAC8[] = { 0x03, 0x37, 0x38, 0x39 };
static const u8 gUnk_0811FACC[] = { 0x17, 0x3e, 0x3f, 0x40 };
const struct_0811F960* ptr;
+
super->action = 1;
super->flags &= ~0x80;
super->spriteSettings.draw = 1;
@@ -219,7 +220,7 @@ void sub_08084680(SpecialFxObject* this) {
}
void sub_08084694(SpecialFxObject* this) {
- if (!super->parent || !super->parent->next) {
+ if ((super->parent == NULL) || (super->parent->next == NULL)) {
DeleteThisEntity();
}
GetNextFrame(super);
@@ -253,12 +254,15 @@ void sub_080846B0(SpecialFxObject* this) {
void sub_0808471C(SpecialFxObject* this) {
static const s8 gUnk_0811FB08[] = { -8, -8, 8, -8, -8, 8, 8, 8 };
+
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
u32 i;
+
for (i = 0; i < 4; i++) {
Entity* fx = CreateFx(super, 0x24, 0);
- if (fx) {
+
+ if (fx != NULL) {
const s8* ptr = &gUnk_0811FB08[2 * i];
fx->x.HALF.HI += ptr[0];
fx->y.HALF.HI += ptr[1];
@@ -280,7 +284,7 @@ void sub_08084784(SpecialFxObject* this) {
void sub_08084798(SpecialFxObject* this) {
GetNextFrame(super);
- if ((super->frame & ANIM_DONE) || !super->child->next) {
+ if ((super->frame & ANIM_DONE) || (super->child->next == NULL)) {
DeleteThisEntity();
}
}