summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorElliptic Ellipsis <elliptic.ellipsis@gmail.com>2022-03-25 05:34:53 +0000
committerElliptic Ellipsis <elliptic.ellipsis@gmail.com>2022-03-25 05:35:12 +0000
commit2d37348cb6994f6fe20a0ffbc2ee2d87bd7447a2 (patch)
treec43ce69da5d2e1fe8744d0a54a3a9650de6f20d1 /src
parent481079092ce272558c887c9563948af0f0fa9d58 (diff)
Fix a lot of pointer comparisons to 0 (or nothing) to explicitly use NULL
Diffstat (limited to 'src')
-rw-r--r--src/enemy/acroBandits.c6
-rw-r--r--src/enemy/beetle.c2
-rw-r--r--src/enemy/bobomb.c2
-rw-r--r--src/enemy/bombPeahat.c25
-rw-r--r--src/enemy/bombarossa.c2
-rw-r--r--src/enemy/bowMoblin.c4
-rw-r--r--src/enemy/businessScrubPrologue.c12
-rw-r--r--src/enemy/chuchu.c2
-rw-r--r--src/enemy/cuccoAggr.c4
-rw-r--r--src/enemy/darkNut.c8
-rw-r--r--src/enemy/fallingBoulder.c2
-rw-r--r--src/enemy/fireballGuy.c2
-rw-r--r--src/enemy/flyingSkull.c2
-rw-r--r--src/enemy/gleerok.c10
-rw-r--r--src/enemy/helmasaur.c4
-rw-r--r--src/enemy/moldorm.c2
-rw-r--r--src/enemy/moldworm.c12
-rw-r--r--src/enemy/octorok.c2
-rw-r--r--src/enemy/octorokBoss.c2
-rw-r--r--src/enemy/peahat.c2
-rw-r--r--src/enemy/pesto.c10
-rw-r--r--src/enemy/puffstool.c8
-rw-r--r--src/enemy/rockChuchu.c4
-rw-r--r--src/enemy/scissorsBeetle.c2
-rw-r--r--src/enemy/slime.c2
-rw-r--r--src/enemy/sluggula.c4
-rw-r--r--src/enemy/spark.c4
-rw-r--r--src/enemy/takkuri.c4
-rw-r--r--src/enemy/waterDrop.c2
-rw-r--r--src/entity.c4
-rw-r--r--src/manager/managerB.c37
-rw-r--r--src/npc/castorWildsStatue.c4
-rw-r--r--src/npcUtils.c2
-rw-r--r--src/object/bakerOven.c2
-rw-r--r--src/object/bigBarrel.c6
-rw-r--r--src/object/button.c2
-rw-r--r--src/object/fileScreenObjects.c4
-rw-r--r--src/object/houseDoorExterior.c4
-rw-r--r--src/object/object49.c8
-rw-r--r--src/object/pot.c2
-rw-r--r--src/room.c2
-rw-r--r--src/script.c2
42 files changed, 117 insertions, 109 deletions
diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c
index 9ac33af9..463693f2 100644
--- a/src/enemy/acroBandits.c
+++ b/src/enemy/acroBandits.c
@@ -84,10 +84,10 @@ void AcroBandit_OnCollision(Entity* this) {
brother->iframes = -12;
} while (brother = brother->child, brother != NULL);
}
- if (this->parent) {
+ if (this->parent != NULL) {
this->parent->child = this->child;
} else {
- if (this->child)
+ if (this->child != NULL)
this->parent = this;
}
@@ -403,7 +403,7 @@ void AcroBandit_Type1Action3(Entity* this) {
this->action = 4;
this->direction = sub_08049F84(this, 1);
*(u8*)&this->field_0x76 = 0;
- if (this->child) {
+ if (this->child != NULL) {
InitializeAnimation(this, 9);
} else {
InitializeAnimation(this, 8);
diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c
index 25e104c8..dc15be53 100644
--- a/src/enemy/beetle.c
+++ b/src/enemy/beetle.c
@@ -60,7 +60,7 @@ void Beetle_OnDeath(Entity* this) {
GenericDeath(this);
} else {
Entity* ent = this->parent;
- if (ent) {
+ if (ent != NULL) {
ent->field_0xf--;
this->parent = NULL;
}
diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c
index 5ff23ab7..e47bf4e4 100644
--- a/src/enemy/bobomb.c
+++ b/src/enemy/bobomb.c
@@ -290,7 +290,7 @@ void sub_0802CBC4(Entity* this) {
FreeCarryEntity(this);
ent = CreateObjectWithParent(this, OBJECT_20, 0, 0);
- if (ent) {
+ if (ent != NULL) {
ent->collisionLayer = this->collisionLayer;
}
}
diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c
index 5c327b91..5cb6e1db 100644
--- a/src/enemy/bombPeahat.c
+++ b/src/enemy/bombPeahat.c
@@ -92,7 +92,6 @@ void sub_0802A8FC(Entity* this) {
}
void nullsub_143(Entity* this) {
- /* ... */
}
void sub_0802A91C(Entity* this) {
@@ -167,7 +166,7 @@ void sub_0802AA40(Entity* this) {
this->actionDelay--;
} else {
Entity* ent = this->child;
- if (ent) {
+ if (ent != NULL) {
if (ent->next == NULL) {
this->child = NULL;
} else {
@@ -212,7 +211,7 @@ void sub_0802AAC0(Entity* this) {
}
}
#else
- } else if (ent->actionDelay == 0 && ent->field_0xf < 0x51) {
+ } else if ((ent->actionDelay == 0) && (ent->field_0xf <= 0x50)) {
this->field_0x80.HALF.HI = 0;
}
#endif
@@ -304,7 +303,7 @@ void sub_0802AC40(Entity* this) {
GetNextFrame(this);
LinearMoveUpdate(this);
if (this->field_0x7a.HALF.LO) {
- if (sub_0802B234(this) == 0) {
+ if (!sub_0802B234(this)) {
this->field_0x7a.HALF.LO = 0;
this->spritePriority.b1 = 0;
#ifndef EU
@@ -349,7 +348,7 @@ void sub_0802ACDC(Entity* this, u32 param_2) {
void sub_0802AD1C(Entity* this, u32 param_2) {
Entity* ent = sub_08049DF4(1);
- if (ent) {
+ if (ent != NULL) {
u32 y = ent->y.HALF.HI - 0x18;
u32 x = ent->x.HALF.HI;
sub_08004596(this, sub_080045B4(this, x, y));
@@ -416,7 +415,7 @@ void sub_0802AE24(Entity* this) {
#ifdef EU
void sub_0802AE68(Entity* this) {
Entity* ent = this->parent;
- if (ent == 0) {
+ if (ent == NULL) {
this->action = 3;
this->spriteSettings.draw = 1;
this->field_0x80.HALF.LO = 1;
@@ -441,7 +440,7 @@ void sub_0802AE68(Entity* this) {
#else
void sub_0802AE68(Entity* this) {
Entity* ent = sub_0802B250(this);
- if (ent == 0) {
+ if (ent == NULL) {
this->action = 3;
this->field_0x80.HALF.LO = 1;
sub_0802B264(this);
@@ -559,7 +558,7 @@ void sub_0802B048(Entity* this) {
}
ent = this->parent;
- if (ent && this->action == 1) {
+ if ((ent != NULL) && this->action == 1) {
this->spriteRendering.b3 = ent->spriteRendering.b3;
this->spritePriority.b0 = ent->spritePriority.b0;
this->spriteOrientation.flipY = ent->spriteOrientation.flipY;
@@ -588,7 +587,7 @@ void sub_0802B048(Entity* this) {
COLLISION_ON(this);
this->field_0x7a.HALF.HI = 0;
FreeCarryEntity(this);
- if (this->parent->next) {
+ if (this->parent->next != NULL) {
this->parent->field_0x80.HALF.HI = 0;
}
ent = CreateObjectWithParent(this, OBJECT_20, 0, 0);
@@ -622,7 +621,7 @@ void sub_0802B1BC(Entity* this) {
}
ent = this->parent;
- if (ent == 0) {
+ if (ent == NULL) {
this->action = 2;
this->spriteSettings.draw = 1;
}
@@ -651,7 +650,7 @@ void sub_0802B1BC(Entity* this) {
}
ent = sub_0802B250(this);
- if (ent == 0) {
+ if (ent == NULL) {
this->action = 2;
sub_0802B264(this);
} else {
@@ -668,7 +667,7 @@ void sub_0802B1BC(Entity* this) {
void sub_0802B204(Entity* this) {
if (sub_080044EC(this, 0x2800) == 1) {
Entity* ent = CreateEnemy(BOBOMB, 1);
- if (ent) {
+ if (ent != NULL) {
CopyPosition(this, ent);
ent->parent = this->parent;
}
@@ -686,7 +685,7 @@ bool32 sub_0802B234(Entity* this) {
#ifndef EU
Entity* sub_0802B250(Entity* this) {
Entity* parent = this->parent;
- if (parent && parent->next == NULL) {
+ if ((parent != NULL) && (parent->next == NULL)) {
parent = NULL;
}
return parent;
diff --git a/src/enemy/bombarossa.c b/src/enemy/bombarossa.c
index 4004edb5..2119c5e0 100644
--- a/src/enemy/bombarossa.c
+++ b/src/enemy/bombarossa.c
@@ -44,7 +44,7 @@ void Bombarossa_OnCollision(BombarossaEntity* this) {
switch (super->bitfield & 0x7f) {
default:
ent = CreateObject(OBJECT_20, 0, 0);
- if (ent) {
+ if (ent != NULL) {
CopyPosition(super, ent);
}
DeleteThisEntity();
diff --git a/src/enemy/bowMoblin.c b/src/enemy/bowMoblin.c
index b65f1ea3..35d3b011 100644
--- a/src/enemy/bowMoblin.c
+++ b/src/enemy/bowMoblin.c
@@ -230,7 +230,7 @@ void sub_0803C400(BowMoblinEntity* this) {
}
sub_0803C6DC(this);
- if (super->child) {
+ if (super->child != NULL) {
sub_0803C714(this);
}
}
@@ -271,7 +271,7 @@ void sub_0803C4B0(BowMoblinEntity* this) {
u32 sub_0803C568(BowMoblinEntity* this) {
if (this->unk_0x81 == 0) {
Entity* ent = sub_08049DF4(1);
- if (ent) {
+ if (ent != NULL) {
if (this->unk_0x82 == 2) {
if (sub_0806FC80(super, ent, 0x30)) {
return 1;
diff --git a/src/enemy/businessScrubPrologue.c b/src/enemy/businessScrubPrologue.c
index f87040f3..f9701c9b 100644
--- a/src/enemy/businessScrubPrologue.c
+++ b/src/enemy/businessScrubPrologue.c
@@ -48,7 +48,7 @@ void BusinessScrubPrologue_OnCollision(BusinessScrubPrologueEntity* this) {
super->flags &= ~ENT_COLLIDE;
sub_08046030(this, 4);
ent = CreateFx(super, FX_BUSH, 0);
- if (ent) {
+ if (ent != NULL) {
ent->z.HALF.HI -= 8;
}
@@ -123,7 +123,7 @@ void sub_08045CE0(BusinessScrubPrologueEntity* this) {
sub_0804604C(this);
if (super->frame & 1) {
ent = CreateProjectileWithParent(super, DEKU_SEED_PROJECTILE, 0);
- if (ent) {
+ if (ent != NULL) {
ent->parent = super;
ent->direction = super->direction;
super->frame &= 0xfe;
@@ -186,7 +186,7 @@ void sub_08045E14(BusinessScrubPrologueEntity* this) {
super->subAction = 0;
sub_08046030(this, 0);
ent = Create0x68FX(super, FX_STARS);
- if (ent) {
+ if (ent != NULL) {
ent->spritePriority.b0 = 3;
ent->z.HALF.HI -= 0xc;
SetDefaultPriority(ent, PRIO_MESSAGE);
@@ -299,7 +299,7 @@ void sub_08046078(BusinessScrubPrologueEntity* this) {
for (index = 0; index <= 4; index++) {
ent = CreateFx(super, FX_DEATH, 0x40);
- if (ent) {
+ if (ent != NULL) {
ent->x.HALF.HI = gRoomControls.origin_x + *ptr;
ptr++;
ent->y.HALF.HI = gRoomControls.origin_y + *ptr;
@@ -315,12 +315,12 @@ void sub_08046078(BusinessScrubPrologueEntity* this) {
sub_0807BA8C(0x7a7, 1);
ent = CreateFx(super, FX_BIG_EXPLOSION2, 0x40);
- if (ent) {
+ if (ent != NULL) {
CopyPosition(super, ent);
EnqueueSFX(SFX_184);
}
- if (super->child) {
+ if (super->child != NULL) {
super->child->action = 0xff;
}
diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c
index 34094ef5..856acda5 100644
--- a/src/enemy/chuchu.c
+++ b/src/enemy/chuchu.c
@@ -552,7 +552,7 @@ void sub_0801F884(Entity* this) {
this->field_0xf--;
} else {
Entity* ent = Create0x68FX(this, FX_LIGHTNING_STRIKE);
- if (ent) {
+ if (ent != NULL) {
ent->type2 = 64;
this->action = 4;
this->hitType = 165;
diff --git a/src/enemy/cuccoAggr.c b/src/enemy/cuccoAggr.c
index 28b32be5..5d2631df 100644
--- a/src/enemy/cuccoAggr.c
+++ b/src/enemy/cuccoAggr.c
@@ -295,7 +295,7 @@ void sub_080391B4(CuccoAggrEntity* this) {
if (this->unk_7a) {
if ((this->unk_7b++ & 0x1f) == 0) {
Entity* ent = CreateEnemy(CUCCO_AGGR, 2);
- if (ent) {
+ if (ent != NULL) {
u32 rand = (Random() & 0x17);
const PosOffset* ptr = &gCuccoAggrSpawnPoints[rand];
ent->x.HALF.HI = gRoomControls.scroll_x + ptr->x;
@@ -321,7 +321,7 @@ void sub_08039218(CuccoAggrEntity* this) {
void CuccoAggr_CreateFx(CuccoAggrEntity* this) {
Entity* ent = CreateFx(super, gCuccoAggrFx[super->type], 0);
- if (ent) {
+ if (ent != NULL) {
ent->x.HALF.HI += gCuccoAggrFxHorizontalOffsets[super->spriteSettings.flipX];
}
}
diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c
index c3e84e19..3d91e7f4 100644
--- a/src/enemy/darkNut.c
+++ b/src/enemy/darkNut.c
@@ -312,7 +312,7 @@ void sub_080210E4(Entity* this) {
this->frame &= ~1;
ent = CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 2);
- if (ent) {
+ if (ent != NULL) {
ent->parent = this;
this->child = ent;
}
@@ -558,7 +558,7 @@ void sub_08021540(Entity* this) {
}
void sub_08021588(Entity* this) {
- if (this->child) {
+ if (this->child != NULL) {
this->child->parent = NULL;
this->child = NULL;
}
@@ -571,7 +571,7 @@ void sub_0802159C(Entity* this) {
this->frame = 0;
this->hitType = 0x51;
ent = CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 3);
- if (ent) {
+ if (ent != NULL) {
ent->parent = this;
this->child = ent;
}
@@ -592,7 +592,7 @@ void sub_08021600(Entity* this) {
this->frame = 0;
this->hitType = 0x51;
ent = CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 4);
- if (ent) {
+ if (ent != NULL) {
ent->parent = this;
this->child = ent;
}
diff --git a/src/enemy/fallingBoulder.c b/src/enemy/fallingBoulder.c
index 4928bf84..828b3670 100644
--- a/src/enemy/fallingBoulder.c
+++ b/src/enemy/fallingBoulder.c
@@ -97,7 +97,7 @@ NONMATCH("asm/non_matching/fallingBoulder/sub_0802C334.inc", void sub_0802C334(E
s32 i;
for (i = 1; i > -1; i--) {
Entity* ent = CreateFx(this, FX_ROCK2, 0);
- if (ent) {
+ if (ent != NULL) {
ent->x.HALF.HI += 12;
ent->x.HALF.HI -= diff;
}
diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c
index 43ceb90c..6e140df5 100644
--- a/src/enemy/fireballGuy.c
+++ b/src/enemy/fireballGuy.c
@@ -91,7 +91,7 @@ void sub_08045454(Entity* this) {
}
ent = CreateFx(this, FX_DEATH, 0);
- if (ent)
+ if (ent != NULL)
CopyPosition(this, ent);
DeleteEntity(this);
diff --git a/src/enemy/flyingSkull.c b/src/enemy/flyingSkull.c
index 85ebe162..0374b579 100644
--- a/src/enemy/flyingSkull.c
+++ b/src/enemy/flyingSkull.c
@@ -141,7 +141,7 @@ void sub_08039DD8(FlyingSkullEntity* this) {
super->actionDelay = 0x1e;
} else {
ent = CreateEnemy(STALFOS, super->type - 2);
- if (ent) {
+ if (ent != NULL) {
ent->type2 = 1;
CopyPosition(super, ent);
SetTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer);
diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c
index 50ae9126..a97628e6 100644
--- a/src/enemy/gleerok.c
+++ b/src/enemy/gleerok.c
@@ -283,7 +283,7 @@ NONMATCH("asm/non_matching/gleerok/sub_0802D3B8.inc", void sub_0802D3B8(GleerokE
do {
ent = CreateEnemy(GLEEROK, 1);
super->child = ent;
- if (ent) {
+ if (ent != NULL) {
ent->type2 = uvar1 + 1;
super->child->collisionLayer = super->collisionLayer;
super->child->x.HALF.HI = super->x.HALF.HI;
@@ -301,7 +301,7 @@ NONMATCH("asm/non_matching/gleerok/sub_0802D3B8.inc", void sub_0802D3B8(GleerokE
ent = CreateEnemy(GLEEROK, 2);
super->child = ent;
- if (ent) {
+ if (ent != NULL) {
super->child->collisionLayer = super->collisionLayer;
super->child->x.HALF.HI = super->x.HALF.HI;
super->child->y.HALF.HI = super->y.HALF.HI + ((uvar1 + 1) * 12);
@@ -760,7 +760,7 @@ void sub_0802DCE0(GleerokEntity* this) {
if (this->unk_84->ent2->field_0xf == 0) {
super->child = CreateProjectileWithParent(super, GLEEROK_PROJECTILE, 0);
- if (super->child) {
+ if (super->child != NULL) {
super->child->direction = this->unk_84->filler[0x15];
super->child->type2 = this->unk_84->ent2->frame & 0xf;
super->child->parent = this->unk_84->ent2;
@@ -827,7 +827,7 @@ void sub_0802DDD8(GleerokEntity* this) {
if (this->unk_84->ent2->field_0xf == 1) {
super->child = CreateProjectileWithParent(super, GLEEROK_PROJECTILE, r2);
- if (super->child) {
+ if (super->child != NULL) {
super->child->direction = this->unk_84->filler[0x15];
super->child->type2 = this->unk_84->ent2->frame & 0xf;
super->child->parent = this->unk_84->ent2;
@@ -1094,7 +1094,7 @@ void sub_0802E300(GleerokEntity* this) {
InitializeAnimation(super, 0x4d);
ent = CreateEnemy(GLEEROK, 5);
super->child = ent;
- if (super->child) {
+ if (super->child != NULL) {
super->child->parent = super;
heap->ent = super->child;
((GleerokEntity*)super->child)->unk_84 = heap;
diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c
index 5d34065a..731e24bb 100644
--- a/src/enemy/helmasaur.c
+++ b/src/enemy/helmasaur.c
@@ -98,7 +98,7 @@ void sub_0802BCA8(Entity* this) {
this->field_0x3a = this->field_0x3a & 0xfb;
this->field_0x1c = 0x12;
ent = CreateEnemy(HELMASAUR, 1);
- if (ent) {
+ if (ent != NULL) {
ent->animationState = this->animationState;
CopyPosition(this, ent);
}
@@ -356,7 +356,7 @@ void sub_0802C18C(Entity* this) {
this->field_0x78.HALF.LO--;
if ((this->field_0x78.HALF.LO & 7) == 0) {
Entity* ent = CreateObject(SPECIAL_FX, 0x11, 0x40);
- if (ent) {
+ if (ent != NULL) {
PositionRelative(this, ent, 0, Q_16_16(1.0));
}
}
diff --git a/src/enemy/moldorm.c b/src/enemy/moldorm.c
index a73135cd..2e7597ee 100644
--- a/src/enemy/moldorm.c
+++ b/src/enemy/moldorm.c
@@ -113,7 +113,7 @@ void sub_08022D40(Entity* this) {
}
void sub_08022D90(Entity* this) {
- if (this->parent->next) {
+ if (this->parent->next != NULL) {
Entity* parent;
gUnk_080CBBBC[this->action](this);
diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c
index 03f29e2a..96a3ada3 100644
--- a/src/enemy/moldworm.c
+++ b/src/enemy/moldworm.c
@@ -42,7 +42,7 @@ NONMATCH("asm/non_matching/moldworm/Moldworm.inc", void Moldworm(Entity* this))
this->field_0x7c.BYTES.byte1 = this->field_0x7c.BYTES.byte0;
EnemyFunctionHandler(this, Moldworm_Functions);
} else {
- if (this->parent->next) {
+ if (this->parent->next != NULL) {
if (this->type != 8) {
sub_080235BC(this);
} else {
@@ -191,7 +191,7 @@ void sub_08023AB0(Entity*);
void sub_08023398(Entity* this) {
this->field_0x7c.BYTES.byte0++;
- if (this->field_0x7c.BYTES.byte3 && sub_08049FDC(this, 1) == 0) {
+ if (this->field_0x7c.BYTES.byte3 && !sub_08049FDC(this, 1)) {
this->field_0x78.HWORD = 1;
}
@@ -258,7 +258,7 @@ void sub_080234D8(Entity* this) {
}
void sub_0802351C(Entity* this) {
- if (this->actionDelay != 0 && (this->type2 == 1 || gPlayerEntity.frameIndex == 0xff)) {
+ if ((this->actionDelay != 0) && ((this->type2 == 1) || (gPlayerEntity.frameIndex == 0xff))) {
this->actionDelay = 0;
this->child->action = 3;
this->child->field_0xf = this->field_0x80.HALF.LO;
@@ -377,8 +377,8 @@ void sub_0802376C(Entity* this) {
void sub_080237D8(Entity* this) {
Entity* parent = this->parent;
- if (parent->animIndex == 0x17 && this->actionDelay != 0 && this->x.HALF.HI == parent->x.HALF.HI &&
- this->y.HALF.HI == parent->y.HALF.HI) {
+ if ((parent->animIndex == 0x17) && (this->actionDelay != 0) && (this->x.HALF.HI == parent->x.HALF.HI) &&
+ (this->y.HALF.HI == parent->y.HALF.HI)) {
this->action = 1;
COLLISION_OFF(this);
this->spriteSettings.draw = 0;
@@ -501,7 +501,7 @@ void sub_08023AB0(Entity* this) {
if (this->field_0x7a.HALF.HI == 8) {
if (this->field_0x7c.BYTES.byte2) {
this->field_0x7c.BYTES.byte2--;
- } else if (!sub_08023B38(this) || 0x1d >= this->field_0x78.HWORD) {
+ } else if (!sub_08023B38(this) || (this->field_0x78.HWORD <= 0x1D)) {
this->hitType = 0x85;
this->field_0x7a.HALF.HI = 0;
this->field_0x7c.BYTES.byte2 = 30;
diff --git a/src/enemy/octorok.c b/src/enemy/octorok.c
index a205d1d6..85ed9aaa 100644
--- a/src/enemy/octorok.c
+++ b/src/enemy/octorok.c
@@ -129,7 +129,7 @@ void Octorok_ShootNut(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
Entity* ent = CreateProjectileWithParent(this, ROCK_PROJECTILE, 0);
- if (ent) {
+ if (ent != NULL) {
const s8* off;
ent->direction = this->direction;
off = &gOctorokNutOffset[this->direction / 4];
diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c
index c5b944f7..d69fefd0 100644
--- a/src/enemy/octorokBoss.c
+++ b/src/enemy/octorokBoss.c
@@ -495,7 +495,7 @@ void OctorokBoss_Action1(OctorokBossEntity* this) {
sub_08036914(super, angle, radius);
this->angle.HALF.HI = -((OctorokBossEntity*)super->parent)->angle.HALF.HI;
}
- if (IS_FROZEN((OctorokBossEntity*)super->parent) == 0) {
+ if (!IS_FROZEN((OctorokBossEntity*)super->parent)) {
super->spriteSettings.draw |= 1;
}
break;
diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c
index dc15dbb6..93452e64 100644
--- a/src/enemy/peahat.c
+++ b/src/enemy/peahat.c
@@ -54,7 +54,7 @@ void Peahat_OnCollision(Entity* this) {
if (this->field_0x82.HALF.LO) {
if (this->bitfield == 0x94) {
Entity* ent = CreateEnemy(PEAHAT, PeahatForm_Propeller);
- if (ent) {
+ if (ent != NULL) {
CopyPosition(this, ent);
ent->z.HALF.HI -= 8;
}
diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c
index 7882e8e8..210d8b41 100644
--- a/src/enemy/pesto.c
+++ b/src/enemy/pesto.c
@@ -171,7 +171,7 @@ void sub_080240B8(Entity* this) {
this->field_0x82.HALF.HI = 0;
ent = CreateProjectileWithParent(this, DIRT_BALL_PROJECTILE, this->field_0x82.HALF.HI);
- if (ent) {
+ if (ent != NULL) {
this->child = ent;
ent->parent = this;
ent->y.HALF.HI += 0x10;
@@ -414,7 +414,7 @@ void sub_080244E8(Entity* this) {
this->field_0x78.HWORD -= 0xe;
ent = CreateProjectileWithParent(this, DIRT_BALL_PROJECTILE, this->field_0x82.HALF.HI);
- if (ent) {
+ if (ent != NULL) {
ent->parent = this;
ent->z.HALF.HI += 0xe;
ent->child = this->child;
@@ -437,7 +437,7 @@ void sub_080244E8(Entity* this) {
this->field_0x78.HWORD -= 0xe;
ent = CreateProjectileWithParent(this, DIRT_BALL_PROJECTILE, this->field_0x82.HALF.HI);
- if (ent) {
+ if (ent != NULL) {
ent->parent = this;
ent->z.HALF.HI += 0xe;
this->child = ent;
@@ -662,7 +662,7 @@ bool32 sub_08024B38(Entity* this) {
}
ent = FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_BOMB, 2);
- if (ent) {
+ if (ent != NULL) {
do {
if (ent->action != 2 && ent->z.HALF.HI == 0 && sub_08049F1C(this, ent, 0xa0)) {
iVar4 = 1;
@@ -679,7 +679,7 @@ bool32 sub_08024B38(Entity* this) {
}
ent = FindEntityByID(OBJECT, POT, 6);
- if (ent) {
+ if (ent != NULL) {
do {
if (ent->action == 1 && sub_08049F1C(this, ent, 0xa0)) {
iVar4 = 1;
diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c
index 76f4858b..3b080dd8 100644
--- a/src/enemy/puffstool.c
+++ b/src/enemy/puffstool.c
@@ -529,12 +529,12 @@ void sub_08025AE8(Entity* this) {
Entity* ent;
ent = CreateFx(this, FX_BROWN_SMOKE, 0);
- if (ent) {
+ if (ent != NULL) {
ent->y.WORD--;
}
ent = CreateFx(this, FX_BROWN_SMOKE_LARGE, 0);
- if (ent) {
+ if (ent != NULL) {
ent->y.WORD++;
}
}
@@ -553,7 +553,7 @@ void sub_08025B18(Entity* this) {
sub_08025AB8((((x + offset[0]) >> 4) & 0x3fU) | ((((y + offset[1]) >> 4) & 0x3fU) << 6), layer);
ent = CreateObject(OBJECT_21, 2, 0);
- if (ent) {
+ if (ent != NULL) {
PositionRelative(this, ent, Q_16_16(offset[0]), Q_16_16(offset[1]));
ent->x.HALF.HI &= -0x10;
ent->x.HALF.HI += 8;
@@ -567,7 +567,7 @@ void sub_08025B18(Entity* this) {
void sub_08025BD4(Entity* this) {
if (this->field_0x82.HALF.LO && (this->frame & 1) == 0) {
Entity* ent = CreateObject(OBJECT_21, 0, 0);
- if (ent) {
+ if (ent != NULL) {
PositionRelative(this, ent, Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 0]),
Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 1]));
ent->z.HALF.HI = -10;
diff --git a/src/enemy/rockChuchu.c b/src/enemy/rockChuchu.c
index 22746a16..9f118b2b 100644
--- a/src/enemy/rockChuchu.c
+++ b/src/enemy/rockChuchu.c
@@ -45,7 +45,7 @@ void RockChuchu_OnCollision(Entity* this) {
case 0x1c:
CreateFx(this, FX_ROCK, 0);
ent = CreateEnemy(CHUCHU, 1);
- if (ent) {
+ if (ent != NULL) {
ent->type2 = 1;
#ifndef EU
ent->iframes = -8;
@@ -100,7 +100,7 @@ void sub_080223E4(Entity* this) {
Entity* ent;
ent = this->child;
- if (ent) {
+ if (ent != NULL) {
ent->bitfield = 0x94;
ent->iframes = 0x10;
#ifndef EU
diff --git a/src/enemy/scissorsBeetle.c b/src/enemy/scissorsBeetle.c
index 29fddd38..66914591 100644
--- a/src/enemy/scissorsBeetle.c
+++ b/src/enemy/scissorsBeetle.c
@@ -64,7 +64,7 @@ void ScissorsBeetle_OnGrabbed(ScissorsBeetleEntity* this) {
void ScissorsBeetle_Init(ScissorsBeetleEntity* this) {
Entity* ent = CreateProjectile(MANDIBLES_PROJECTILE);
- if (!ent)
+ if (ent == NULL)
return;
sub_0804A720(super);
diff --git a/src/enemy/slime.c b/src/enemy/slime.c
index 1cf982a0..ddae5cb9 100644
--- a/src/enemy/slime.c
+++ b/src/enemy/slime.c
@@ -114,7 +114,7 @@ void sub_080450A8(Entity* this) {
}
ent = CreateFx(this, FX_DEATH, 0);
- if (ent)
+ if (ent != NULL)
CopyPosition(this, ent);
DeleteEntity(this);
diff --git a/src/enemy/sluggula.c b/src/enemy/sluggula.c
index 06d27af1..759a3c5c 100644
--- a/src/enemy/sluggula.c
+++ b/src/enemy/sluggula.c
@@ -132,7 +132,7 @@ void sub_08023CE0(Entity* this) {
if (this->frame) {
if (this->frame & ANIM_DONE) {
Entity* ent = CreateEnemy(SLUGGULA, 1);
- if (ent) {
+ if (ent != NULL) {
sub_0804A4E4(this, ent);
DeleteThisEntity();
}
@@ -163,7 +163,7 @@ void sub_08023E54(Entity* this) {
if (this->field_0xf++ > 27) {
this->field_0xf = 0;
ent = CreateEnemy(SLUGGULA, 2);
- if (ent) {
+ if (ent != NULL) {
const s8* ptr = &gUnk_080CBDF7[this->animationState * 2];
PositionRelative(this, ent, Q_16_16(ptr[0]), Q_16_16(ptr[1]));
}
diff --git a/src/enemy/spark.c b/src/enemy/spark.c
index 7a977440..32cb9345 100644
--- a/src/enemy/spark.c
+++ b/src/enemy/spark.c
@@ -31,7 +31,7 @@ void Spark_OnCollision(Entity* this) {
this->spriteSettings.draw = 0;
this->action = 2;
ent = CreateFx(this, FX_DEATH, 0);
- if (ent) {
+ if (ent != NULL) {
this->child = ent;
this->actionDelay = 14;
CopyPosition(this, ent);
@@ -122,7 +122,7 @@ void sub_0802B35C(Entity* this) {
void sub_0802B4A8(Entity* this) {
if (--this->actionDelay == 0) {
Entity* ent = CreateObjectWithParent(this, GROUND_ITEM, 0x60, 0);
- if (ent) {
+ if (ent != NULL) {
ent->y.HALF.HI -= 4;
}
DeleteEntity(this);
diff --git a/src/enemy/takkuri.c b/src/enemy/takkuri.c
index a07b8330..64c61158 100644
--- a/src/enemy/takkuri.c
+++ b/src/enemy/takkuri.c
@@ -132,7 +132,7 @@ void sub_0803BD08(TakkuriEntity* this) {
sub_0803BEE8(this);
GetNextFrame(super);
ent = sub_08049DF4(1);
- if (ent) {
+ if (ent != NULL) {
if (EntityInRectRadius(super, gUnk_020000B0, 0x88, 0x50)) {
if (gUnk_020000B0->y.HALF.HI > super->y.HALF.HI + 8) {
super->action = 2;
@@ -306,7 +306,7 @@ void sub_0803C0AC(Entity* this) {
u32 index, rupeeType, rupees;
Entity* ent;
ent = sub_08049DF4(1);
- if (!ent)
+ if (ent == NULL)
return;
rupees = gSave.stats.rupees;
diff --git a/src/enemy/waterDrop.c b/src/enemy/waterDrop.c
index 629c54cd..2b390879 100644
--- a/src/enemy/waterDrop.c
+++ b/src/enemy/waterDrop.c
@@ -34,7 +34,7 @@ void sub_0802A250(Entity* this) {
UpdateSpriteForCollisionLayer(this);
ent = CreateObject(OBJECT_66, 0, 0);
- if (ent) {
+ if (ent != NULL) {
ent->parent = this;
}
}
diff --git a/src/entity.c b/src/entity.c
index d696050c..7345650f 100644
--- a/src/entity.c
+++ b/src/entity.c
@@ -339,7 +339,7 @@ void DeleteEntityAny(Entity* ent) {
}
void DeleteEntity(Entity* ent) {
- if (ent->next) {
+ if (ent->next != NULL) {
UnloadGFXSlots(ent);
UnloadOBJPalette(ent);
UnloadOBJPalette2(ent);
@@ -418,7 +418,7 @@ Manager* GetEmptyManager(void) {
void DeleteManager(void* ent) {
Manager* manager = (Manager*)ent;
- if (!manager->next)
+ if (manager->next == NULL)
return;
ReleaseTransitionManager(manager);
diff --git a/src/manager/managerB.c b/src/manager/managerB.c
index a54ae310..1e49669f 100644
--- a/src/manager/managerB.c
+++ b/src/manager/managerB.c
@@ -62,8 +62,9 @@ void ManagerB_WaitForFlag(ManagerB* this) {
void ManagerB_WaitForDone(ManagerB* this) {
// check if all helpers are done
- if (this->manager.unk_0e)
+ if (this->manager.unk_0e) {
return;
+ }
// set the completion flag for the fight
SetFlag(this->unk_3e);
// restore music (if it was set, which apparently is only possible if there's a flag the fight waited for)
@@ -87,25 +88,28 @@ void ManagerB_LoadFight(Manager* this) {
EntityData* prop;
Entity* ent;
u32 counter;
+
this->action = 2;
this->unk_0e = 0;
counter = 0;
// Create a helper to keep track of the created entities.
monitor = CreateHelper(this);
- if (!monitor)
+ if (monitor == NULL) {
DeleteThisEntity();
+ }
+
prop = (EntityData*)GetCurrentRoomProperty(this->unk_0b);
- if (prop) {
- while (*((u8*)prop) != 0xFF) {
+ if (prop != NULL) {
+ while (prop->kind != 0xFF) {
ent = LoadRoomEntity(prop++);
- if (ent && (ent->kind == ENEMY)) {
+ if ((ent != NULL) && (ent->kind == ENEMY)) {
ent->field_0x6c.HALF.HI |= 0x40;
ManagerBHelper_Monitor(monitor, ent, counter++);
}
if (counter >= 7) {
counter = 0;
monitor = CreateHelper(this);
- if (!monitor)
+ if (monitor == NULL)
return;
}
}
@@ -139,27 +143,31 @@ void ManagerBHelper_Monitor(ManagerBHelper* this, Entity* ent, u32 index) {
// case volumeMasterTarget is 1: The manager is a helper
void ManagerBHelper_Main(Manager* this) {
- u8 i, anyRemaining;
+ u8 i;
+ bool32 anyRemaining;
Entity* current;
+
if (this->action == 0) {
this->action = 1;
SetDefaultPriority((Entity*)this, PRIO_NO_BLOCK);
}
// go through and check all monitored enemies.
- anyRemaining = 0;
+ anyRemaining = FALSE;
for (i = 0; i < 8; i++) {
- if ((current = ((ManagerBHelper*)this)->enemies[i])) {
- if (!current->next) {
+ current = ((ManagerBHelper*)this)->enemies[i];
+ if (current != NULL) {
+ if (current->next == NULL) {
((ManagerBHelper*)this)->enemies[i] = 0;
} else {
- anyRemaining = 1;
+ anyRemaining = TRUE;
}
}
}
if (!anyRemaining) {
// inform the parent that we're done
- if (((ManagerB*)this->parent)->manager.unk_0e) {
- ((ManagerB*)this->parent)->manager.unk_0e--;
+ ManagerB* parent = (ManagerB*)this->parent;
+ if (parent->manager.unk_0e != 0) {
+ parent->manager.unk_0e--;
}
DeleteThisEntity();
}
@@ -174,8 +182,9 @@ void ReplaceMonitoredEntity(Entity* old, Entity* new) {
u32 i;
for (current = (ManagerBHelper*)end->next; (Manager*)current != end;
current = (ManagerBHelper*)current->manager.next) {
- if (current->manager.type != 0x9 || current->manager.subtype != 0xB)
+ if (current->manager.type != 0x9 || current->manager.subtype != 0xB) {
continue;
+ }
for (i = 0; i < 8; i++) {
if (old == current->enemies[i]) {
current->enemies[i] = new;
diff --git a/src/npc/castorWildsStatue.c b/src/npc/castorWildsStatue.c
index 9d5e8567..5c853371 100644
--- a/src/npc/castorWildsStatue.c
+++ b/src/npc/castorWildsStatue.c
@@ -127,7 +127,7 @@ void sub_080675D4(Entity* this) {
for (i = 0; i < 9; i++, gUnk++) {
Entity* ent = CreateFx(this, FX_DEATH, 0);
- if (ent) {
+ if (ent != NULL) {
ent->x.HALF.HI += gUnk->x;
ent->y.HALF.HI += gUnk->y;
ent->z.HALF.HI = subAction;
@@ -140,7 +140,7 @@ void sub_080675D4(Entity* this) {
gUnk = gUnk_08110E8A;
for (i = 0; i < 4; i++, gUnk++) {
Entity* ent = CreateFx(this, FX_ROCK, 0);
- if (ent) {
+ if (ent != NULL) {
ent->x.HALF.HI = gUnk->x + ent->x.HALF.HI;
ent->y.HALF.HI = gUnk->y + ent->y.HALF.HI;
ent->z.HALF.HI = subAction;
diff --git a/src/npcUtils.c b/src/npcUtils.c
index 2bd9564a..09906e44 100644
--- a/src/npcUtils.c
+++ b/src/npcUtils.c
@@ -138,7 +138,7 @@ u32 sub_0806EE20(Entity* ent) {
u32 v3;
if (!ent->interactType) {
- if (ent->child)
+ if (ent->child != NULL)
return gUnk_08114EFC[ent->field_0x16](ent);
} else {
ent->knockbackSpeed = 8;
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/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/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/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/room.c b/src/room.c
index b12dbea4..babc3f02 100644
--- a/src/room.c
+++ b/src/room.c
@@ -68,7 +68,7 @@ NONMATCH("asm/non_matching/LoadRoomEntity.inc", Entity* LoadRoomEntity(EntityDat
if (kind == 9)
return v5;
sub_0804AF0C(v5, dat);
- if (!v5->next)
+ if (v5->next == NULL)
return v5;
if ((dat->kind & 0x10) == 0) {
if ((dat->kind & 0x20) != 0) {
diff --git a/src/script.c b/src/script.c
index 8fb780b8..1bdf1468 100644
--- a/src/script.c
+++ b/src/script.c
@@ -349,7 +349,7 @@ void ExecuteScriptForEntity(Entity* entity, void (*postScriptCallback)(Entity*,
} else {
HandlePostScriptActions(entity, *piVar1);
}
- if (!entity->next) {
+ if (entity->next == NULL) {
DeleteThisEntity();
}
}