Fix a lot of pointer comparisons to 0 (or nothing) to explicitly use NULL

This commit is contained in:
Elliptic Ellipsis 2022-03-25 05:34:53 +00:00
parent 481079092c
commit 2d37348cb6
42 changed files with 117 additions and 109 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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();

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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];
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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));
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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];

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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]));
}

View File

@ -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);

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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));
}

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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) {

View File

@ -349,7 +349,7 @@ void ExecuteScriptForEntity(Entity* entity, void (*postScriptCallback)(Entity*,
} else {
HandlePostScriptActions(entity, *piVar1);
}
if (!entity->next) {
if (entity->next == NULL) {
DeleteThisEntity();
}
}