summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/d/actor/d_a_alink.cpp2
-rw-r--r--src/d/actor/d_a_b_bq.cpp2
-rw-r--r--src/d/actor/d_a_b_mgn.cpp1
-rw-r--r--src/d/actor/d_a_bg_obj.cpp2
-rw-r--r--src/d/actor/d_a_door_boss.cpp2
-rw-r--r--src/d/actor/d_a_door_bossL1.cpp2
-rw-r--r--src/d/actor/d_a_door_bossL5.cpp2
-rw-r--r--src/d/actor/d_a_door_mbossL1.cpp2
-rw-r--r--src/d/actor/d_a_e_hz.cpp6
-rw-r--r--src/d/actor/d_a_e_kr.cpp1
-rw-r--r--src/d/actor/d_a_e_mm_mt.cpp2
-rw-r--r--src/d/actor/d_a_e_oc.cpp36
-rw-r--r--src/d/actor/d_a_e_rdy.cpp4
-rw-r--r--src/d/actor/d_a_e_wb.cpp2
-rw-r--r--src/d/actor/d_a_e_yg.cpp2
-rw-r--r--src/d/actor/d_a_e_yh.cpp2
-rw-r--r--src/d/actor/d_a_e_ymb.cpp2
-rw-r--r--src/d/actor/d_a_e_zh.cpp2
-rw-r--r--src/d/actor/d_a_horse.cpp7
-rw-r--r--src/d/actor/d_a_mg_rod.cpp4
-rw-r--r--src/d/actor/d_a_nbomb.cpp2
-rw-r--r--src/d/actor/d_a_npc2.cpp2
-rw-r--r--src/d/actor/d_a_npc_bou.cpp2
-rw-r--r--src/d/actor/d_a_npc_chat.cpp2
-rw-r--r--src/d/actor/d_a_npc_coach.cpp6
-rw-r--r--src/d/actor/d_a_npc_gra.cpp15
-rw-r--r--src/d/actor/d_a_npc_grc.cpp3
-rw-r--r--src/d/actor/d_a_npc_grd.cpp3
-rw-r--r--src/d/actor/d_a_npc_gro.cpp3
-rw-r--r--src/d/actor/d_a_npc_grr.cpp3
-rw-r--r--src/d/actor/d_a_npc_grs.cpp13
-rw-r--r--src/d/actor/d_a_npc_grz.cpp3
-rw-r--r--src/d/actor/d_a_npc_gwolf.cpp9
-rw-r--r--src/d/actor/d_a_npc_kn.cpp14
-rw-r--r--src/d/actor/d_a_npc_ks.cpp6
-rw-r--r--src/d/actor/d_a_npc_myna2.cpp19
-rw-r--r--src/d/actor/d_a_npc_ne.cpp70
-rw-r--r--src/d/actor/d_a_npc_pachi_maro.cpp2
-rw-r--r--src/d/actor/d_a_npc_pachi_taro.cpp2
-rw-r--r--src/d/actor/d_a_npc_post.cpp2
-rw-r--r--src/d/actor/d_a_npc_soldierA.cpp3
-rw-r--r--src/d/actor/d_a_npc_soldierB.cpp3
-rw-r--r--src/d/actor/d_a_npc_theB.cpp3
-rw-r--r--src/d/actor/d_a_npc_wrestler.cpp4
-rw-r--r--src/d/actor/d_a_npc_zra.cpp3
-rw-r--r--src/d/actor/d_a_npc_zrc.cpp3
-rw-r--r--src/d/actor/d_a_npc_zrz.cpp3
-rw-r--r--src/d/actor/d_a_obj_brg.cpp14
-rw-r--r--src/d/actor/d_a_obj_cwall.cpp4
-rw-r--r--src/d/actor/d_a_obj_gra2.cpp9
-rw-r--r--src/d/actor/d_a_obj_gra2_soldier.inc4
-rw-r--r--src/d/actor/d_a_obj_magne_arm.cpp2
-rw-r--r--src/d/actor/d_a_obj_pumpkin.cpp5
-rw-r--r--src/d/actor/d_a_obj_sekidoor.cpp4
-rw-r--r--src/d/actor/d_a_obj_sekizoa.cpp20
-rw-r--r--src/d/actor/d_a_obj_ss_drink.cpp1
-rw-r--r--src/d/actor/d_a_tag_evt.cpp1
-rw-r--r--src/d/actor/d_a_tag_evtmsg.cpp3
-rw-r--r--src/d/actor/d_a_tag_lantern.cpp3
-rw-r--r--src/d/actor/d_a_tag_setrestart.cpp2
-rw-r--r--src/d/actor/d_a_tag_ss_drink.cpp2
-rw-r--r--src/d/actor/d_a_tag_theB_hint.cpp1
-rw-r--r--src/d/d_debug_camera.cpp2
-rw-r--r--src/d/d_demo.cpp20
-rw-r--r--src/d/d_drawlist.cpp2
-rw-r--r--src/d/d_ev_camera.cpp2
-rw-r--r--src/d/d_kankyo.cpp24
-rw-r--r--src/d/d_lib.cpp2
-rw-r--r--src/d/d_map_path_dmap.cpp8
-rw-r--r--src/d/d_menu_letter.cpp17
-rw-r--r--src/d/d_menu_ring.cpp2
-rw-r--r--src/d/d_msg_object.cpp11
-rw-r--r--src/d/d_msg_scrn_howl.cpp10
-rw-r--r--src/d/d_particle.cpp14
-rw-r--r--src/d/d_save.cpp14
-rw-r--r--src/d/d_shop_system.cpp5
-rw-r--r--src/f_pc/f_pc_priority.cpp2
-rw-r--r--src/m_Do/m_Do_dvd_thread.cpp2
-rw-r--r--src/m_Do/m_Do_ext.cpp4
79 files changed, 357 insertions, 147 deletions
diff --git a/src/d/actor/d_a_alink.cpp b/src/d/actor/d_a_alink.cpp
index 8d2cb7b635..12d1cd397a 100644
--- a/src/d/actor/d_a_alink.cpp
+++ b/src/d/actor/d_a_alink.cpp
@@ -15712,7 +15712,7 @@ int daAlink_c::procMoveTurnInit(int param_0) {
dComIfGp_setPlayerStatus0(0, 0x800);
if (param_0 != 0) {
- mProcVar3.field_0x300e = (mpHIO->mMove.m.mMaxTurnAngle * 4) + 19030;
+ mProcVar3.field_0x300e = (s16)((mpHIO->mMove.m.mMaxTurnAngle * 4) + 19030);
mProcVar4.field_0x3010 = mpHIO->mMove.m.mMaxTurnAngle * 2;
mProcVar1.field_0x300a = 2;
current.angle.y = mMoveAngle;
diff --git a/src/d/actor/d_a_b_bq.cpp b/src/d/actor/d_a_b_bq.cpp
index 96155f18a2..83a811a59c 100644
--- a/src/d/actor/d_a_b_bq.cpp
+++ b/src/d/actor/d_a_b_bq.cpp
@@ -1872,7 +1872,7 @@ static void demo_camera(b_bq_class* i_this) {
spFC.set(BREG_F(5) + -30.0f, 0.0f, BREG_F(6) + 1938.0f);
}
- daPy_getPlayerActorClass()->setPlayerPosAndAngle(&spFC, BREG_S(5) + 0x8000, 0);
+ daPy_getPlayerActorClass()->setPlayerPosAndAngle(&spFC, (s16)(BREG_S(5) + 0x8000), 0);
if (i_this->field_0x5c8 != 0) {
i_this->field_0x5cc.y += i_this->field_0x5d8;
diff --git a/src/d/actor/d_a_b_mgn.cpp b/src/d/actor/d_a_b_mgn.cpp
index 2fac141f1f..396bc44327 100644
--- a/src/d/actor/d_a_b_mgn.cpp
+++ b/src/d/actor/d_a_b_mgn.cpp
@@ -1325,6 +1325,7 @@ void daB_MGN_c::executeDash() {
}
if (mMoveMode == 11) {
+ // @bug - parenthesis should not be on the condition
if (abs((s16)(angle - field_0xa90) < 0x1800) != 0) {
if ((s16)(angle - field_0xa90) < 0) {
angle = field_0xa90 - 0x1800;
diff --git a/src/d/actor/d_a_bg_obj.cpp b/src/d/actor/d_a_bg_obj.cpp
index dbab04fa6e..21716cb33d 100644
--- a/src/d/actor/d_a_bg_obj.cpp
+++ b/src/d/actor/d_a_bg_obj.cpp
@@ -881,7 +881,7 @@ void daBgObj_c::setParticle() {
for (; partNum != 0; partNum--) {
u32 flags = *partBlockItems++;
u16 res_id = *partBlockItems;
- *partBlockItems++;
+ partBlockItems++;
GXColor prmColor = { 0xFF, 0xFF, 0xFF, 0xFF };
GXColor envColor = { 0xFF, 0xFF, 0xFF, 0xFF };
diff --git a/src/d/actor/d_a_door_boss.cpp b/src/d/actor/d_a_door_boss.cpp
index ce6e662229..c68d882236 100644
--- a/src/d/actor/d_a_door_boss.cpp
+++ b/src/d/actor/d_a_door_boss.cpp
@@ -254,7 +254,7 @@ BOOL daBdoor_c::checkArea() {
if (fabsf(vec.z) > 100.0f) {
return false;
}
- return (s16)fabs(current.angle.y - 0x7fff - player->current.angle.y) <= 0x4000 ? 1 : 0;
+ return (s16)fabs((f64)(current.angle.y - 0x7fff - player->current.angle.y)) <= 0x4000 ? 1 : 0;
}
BOOL daBdoor_c::checkFront() {
diff --git a/src/d/actor/d_a_door_bossL1.cpp b/src/d/actor/d_a_door_bossL1.cpp
index 5f64e88534..7b7f2ab6ff 100644
--- a/src/d/actor/d_a_door_bossL1.cpp
+++ b/src/d/actor/d_a_door_bossL1.cpp
@@ -825,7 +825,7 @@ int daBdoorL1_c::checkArea() {
if (fabsf(local_48.z) > 100.0f) {
return 0;
}
- if ((s16)fabs(current.angle.y - 0x7fff - player->current.angle.y) <= 0x4000) {
+ if ((s16)fabs((f64)(current.angle.y - 0x7fff - player->current.angle.y)) <= 0x4000) {
return 1;
} else {
return 0;
diff --git a/src/d/actor/d_a_door_bossL5.cpp b/src/d/actor/d_a_door_bossL5.cpp
index 864a5052e9..1d54749ebb 100644
--- a/src/d/actor/d_a_door_bossL5.cpp
+++ b/src/d/actor/d_a_door_bossL5.cpp
@@ -348,7 +348,7 @@ int daBdoorL5_c::checkArea() {
if (fabsf(local_48.z) > 100.0f) {
return 0;
}
- if ((s16)fabs(current.angle.y - 0x7fff - player->current.angle.y) <= 0x4000) {
+ if ((s16)fabs((f64)(current.angle.y - 0x7fff - player->current.angle.y)) <= 0x4000) {
return 1;
} else {
return 0;
diff --git a/src/d/actor/d_a_door_mbossL1.cpp b/src/d/actor/d_a_door_mbossL1.cpp
index 027677f7ec..35bb2d56ef 100644
--- a/src/d/actor/d_a_door_mbossL1.cpp
+++ b/src/d/actor/d_a_door_mbossL1.cpp
@@ -1318,7 +1318,7 @@ int daMBdoorL1_c::checkArea() {
return 0;
}
- if ((s16)fabs(angle - 0x7fff - player->current.angle.y) > 0x4000) {
+ if ((s16)fabs((f64)(angle - 0x7fff - player->current.angle.y)) > 0x4000) {
return 0;
} else {
return 1;
diff --git a/src/d/actor/d_a_e_hz.cpp b/src/d/actor/d_a_e_hz.cpp
index df760a4f7d..789d882305 100644
--- a/src/d/actor/d_a_e_hz.cpp
+++ b/src/d/actor/d_a_e_hz.cpp
@@ -1934,7 +1934,13 @@ int daE_HZ_c::CreateHeap() {
return 0;
}
+ // This happens to work with MWCC since the member will only ever be initialized a pointer to a
+ // string in this TU's .data section, but comparing against a string literal is still UB.
+#if AVOID_UB
+ if (strcmp(mpName, "E_hzp") == 0) {
+#else
if (mpName == "E_hzp") {
+#endif
modelData = (J3DModelData*)dComIfG_getObjectRes(mpName, 3);
} else {
modelData = (J3DModelData*)dComIfG_getObjectRes(mpName, 3);
diff --git a/src/d/actor/d_a_e_kr.cpp b/src/d/actor/d_a_e_kr.cpp
index 5b6e472f0d..d58b926ecc 100644
--- a/src/d/actor/d_a_e_kr.cpp
+++ b/src/d/actor/d_a_e_kr.cpp
@@ -496,6 +496,7 @@ static s8 e_kr_path_move(e_kr_class* i_this) {
if (totalDiff < 10.0f * TREG_F(10) + 300.0f) {
point = &i_this->field_0x6e4->m_points[i_this->field_0x6e2];
u8 pointArg1 = point->mArg1;
+ // !@bug Comparison of u8 with -1 will always evaluate to false
if (pointArg1 == -1) {
i_this->field_0x684 = 50.0f * 1.2f;
} else {
diff --git a/src/d/actor/d_a_e_mm_mt.cpp b/src/d/actor/d_a_e_mm_mt.cpp
index b745fa31c9..205cebab78 100644
--- a/src/d/actor/d_a_e_mm_mt.cpp
+++ b/src/d/actor/d_a_e_mm_mt.cpp
@@ -370,7 +370,7 @@ static void e_mm_mt_drop(e_mm_mt_class* i_this) {
i_this->enemy.speed.y += -5.0f;
i_this->enemy.eyePos = i_this->enemy.current.pos;
i_this->enemy.attention_info.position = i_this->enemy.current.pos;
- cLib_addCalcAngleS2(&i_this->m_rotation.z, (TREG_S(6)+0x10000)-0x8000, 1, 0x1000);
+ cLib_addCalcAngleS2(&i_this->m_rotation.z, (s16)((TREG_S(6) + 0x10000) - 0x8000), 1, 0x1000);
cLib_onBit<u32>(i_this->enemy.attention_info.flags, fopAc_AttnFlag_CARRY_e);
i_this->enemy.attention_info.distances[fopAc_attn_CARRY_e] = 7;
i_this->m_rotation.y += i_this->m_spin;
diff --git a/src/d/actor/d_a_e_oc.cpp b/src/d/actor/d_a_e_oc.cpp
index 4bd6dd3353..bac4901f68 100644
--- a/src/d/actor/d_a_e_oc.cpp
+++ b/src/d/actor/d_a_e_oc.cpp
@@ -724,7 +724,13 @@ void daE_OC_c::damage_check() {
} else if (mAtInfo.mpCollider->ChkAtType(AT_TYPE_40)) {
S16_ADD(health, 10);
} else if (mAtInfo.mpCollider->ChkAtType(AT_TYPE_SLINGSHOT)) {
+ // This happens to work with MWCC since the member will only ever be initialized a pointer to a
+ // string in this TU's .data section, but comparing against a string literal is still UB.
+#if AVOID_UB
+ if (strcmp(mName, "E_OC") == 0) {
+#else
if (mName == "E_OC") {
+#endif
S16_SUB(health, 5);
if (health < 0) {
health = 0;
@@ -855,7 +861,12 @@ void daE_OC_c::setDashSound() {
} else if (mpMorf->checkFrame(8.5f)) {
mSound.startCreatureSound(Z2SE_EN_OC_FOOTNOTE_R, 0, -1);
}
+ // See comment in damage_check
+#if AVOID_UB
+ if (strcmp(mName, "E_OC") == 0) {
+#else
if (mName == "E_OC") {
+#endif
mSound.startCreatureSoundLevel(Z2SE_EN_OC_CLUB_DAGGLE, 0, -1);
} else {
mSound.startCreatureSoundLevel(Z2SE_EN_OC_NATA_DAGGLE, 0, -1);
@@ -1421,7 +1432,12 @@ void daE_OC_c::executeAttack() {
} else if (mpMorf->checkFrame(12.5f)) {
mSound.startCreatureSound(Z2SE_EN_OC_ATTACK_B, 0, -1);
} else if (mpMorf->checkFrame(19.0f)) {
+ // See comment in damage_check
+#if AVOID_UB
+ if (strcmp(mName, "E_OC") == 0) {
+#else
if (mName == "E_OC") {
+#endif
mSound.startCreatureSound(Z2SE_EN_OC_CLUB_HIT, 0, -1);
} else {
mSound.startCreatureSound(Z2SE_EN_OC_NATA_HIT, 0, -1);
@@ -1843,7 +1859,12 @@ void daE_OC_c::executeDeath() {
case 2:
cLib_chaseF(&speedF, 0.0f, 1.0f);
if (field_0x6c0 == 0) {
+ // See comment in damage_check
+#if AVOID_UB
+ if (strcmp(mName, "E_OC") == 0) {
+#else
if (mName == "E_OC") {
+#endif
fopAcM_createDisappear(this, &current.pos, 10, 0, 4);
} else {
fopAcM_createDisappear(this, &current.pos, 10, 0, 0x34);
@@ -1917,7 +1938,12 @@ void daE_OC_c::executeWaterDeath() {
}
if (mpMorf->isStop()) {
+ // See comment in damage_check
+#if AVOID_UB
+ if (strcmp(mName, "E_OC") == 0) {
+#else
if (mName == "E_OC") {
+#endif
fopAcM_createDisappear(this, &current.pos, 10, 0, 4);
} else {
fopAcM_createDisappear(this, &current.pos, 10, 0, 0x34);
@@ -2741,7 +2767,12 @@ cPhs_Step daE_OC_c::create() {
mAcchCir.SetWallH(70.0f);
}
mAcchCir.SetWallR(100.0f);
+ // See comment in damage_check
+#if AVOID_UB
+ if (strcmp(mName, "E_OC") == 0) {
+#else
if (mName == "E_OC") {
+#endif
field_0x560 = health = 40;
} else {
field_0x560 = health = 220;
@@ -2756,7 +2787,12 @@ cPhs_Step daE_OC_c::create() {
mSphs_at[0].SetStts(&mStts);
mSphs_at[1].Set(E_OC_n::at_sph_src);
mSphs_at[1].SetStts(&mStts);
+ // See comment in damage_check
+#if AVOID_UB
+ if (strcmp(mName, "E_OC") == 0) {
+#else
if (mName == "E_OC") {
+#endif
mSphs_at[0].SetAtAtp(1);
mSphs_at[1].SetAtAtp(1);
fopAcM_OnStatus(this, fopAcStts_UNK_0x10000_e);
diff --git a/src/d/actor/d_a_e_rdy.cpp b/src/d/actor/d_a_e_rdy.cpp
index 17708bdf30..6488313150 100644
--- a/src/d/actor/d_a_e_rdy.cpp
+++ b/src/d/actor/d_a_e_rdy.cpp
@@ -2155,7 +2155,7 @@ static void e_rdy_damage(e_rdy_class* i_this) {
case 1:
if (i_this->mAcch.ChkWallHit() && i_this->mTimer[0] == 0) {
- if (check = kado_check(i_this)) {
+ if ((check = kado_check(i_this))) {
OS_REPORT(" ..KADO KABE ..%x\n", check);
if (check == 2) {
i_this->field_0xac6 = 0x1000;
@@ -4721,7 +4721,7 @@ static int daE_RDY_Execute(e_rdy_class* i_this) {
}
MTXCopy(i_this->mpMorf->getModel()->getAnmMtx(JNT_HAND_R), *calc_mtx);
MtxTrans(20.0f + NREG_F(0), 5.0f + NREG_F(1), -10.0f + NREG_F(2), 1);
- cMtx_XrotM(*calc_mtx, NREG_S(0) + 0x8000);
+ cMtx_XrotM(*calc_mtx, (s16)(NREG_S(0) + 0x8000));
cMtx_YrotM(*calc_mtx, NREG_S(1) + ang_y + -0x15cd);
cMtx_ZrotM(*calc_mtx, NREG_S(2) + 0x28cd);
i_this->mpHawkGrassModel->setBaseTRMtx(*calc_mtx);
diff --git a/src/d/actor/d_a_e_wb.cpp b/src/d/actor/d_a_e_wb.cpp
index 399542abe5..d6806dbb01 100644
--- a/src/d/actor/d_a_e_wb.cpp
+++ b/src/d/actor/d_a_e_wb.cpp
@@ -1100,7 +1100,7 @@ static void e_wb_f_run(e_wb_class* i_this) {
} else {
e_rd_class* local_90 = (e_rd_class*)fopAcM_SearchByID(i_this->rd_id);
int saku;
- if (saku = e_wb_saku_check(i_this)) {
+ if ((saku = e_wb_saku_check(i_this))) {
i_this->field_0x6d4 = 60;
if ((saku & 2) != 0) {
i_this->field_0x6d6 = 0x3000;
diff --git a/src/d/actor/d_a_e_yg.cpp b/src/d/actor/d_a_e_yg.cpp
index 92133d2ce9..3a22859386 100644
--- a/src/d/actor/d_a_e_yg.cpp
+++ b/src/d/actor/d_a_e_yg.cpp
@@ -1235,7 +1235,7 @@ static int daE_YG_Execute(e_yg_class* i_this) {
MTXCopy(daPy_getLinkPlayerActorClass()->getWolfMouthMatrix(), mDoMtx_stack_c::get());
mDoMtx_stack_c::multVecZero(&actor->current.pos);
mDoMtx_stack_c::YrotM(KREG_S(0));
- mDoMtx_stack_c::XrotM(KREG_S(1) + 0x8000);
+ mDoMtx_stack_c::XrotM((s16)(KREG_S(1) + 0x8000));
mDoMtx_stack_c::ZrotM(KREG_S(2) + 2500);
mDoMtx_stack_c::transM(KREG_F(0) + 10.0f, KREG_F(1) + -60.0f, KREG_F(2) + -20.0f);
model->setBaseTRMtx(mDoMtx_stack_c::get());
diff --git a/src/d/actor/d_a_e_yh.cpp b/src/d/actor/d_a_e_yh.cpp
index 6f462b2cdc..cbc0a4ea34 100644
--- a/src/d/actor/d_a_e_yh.cpp
+++ b/src/d/actor/d_a_e_yh.cpp
@@ -1930,7 +1930,7 @@ static void eff_set(e_yh_class* i_this) {
dComIfGp_particle_set(i_this->mParticleIds2[2], dPa_RM(ID_ZI_S_YD_YODAHIT_A),
&a_this->current.pos, 0, NULL);
{
- JPABaseEmitter* emitter = dComIfGp_particle_getEmitter(i_this->mParticleIds[5]);
+ JPABaseEmitter* emitter = dComIfGp_particle_getEmitter(i_this->mParticleIds2[2]);
if (emitter != NULL) {
MTXCopy(model->getAnmMtx(1), *calc_mtx);
emitter->setGlobalRTMatrix(*calc_mtx);
diff --git a/src/d/actor/d_a_e_ymb.cpp b/src/d/actor/d_a_e_ymb.cpp
index c4015e3f2a..a7441b8b19 100644
--- a/src/d/actor/d_a_e_ymb.cpp
+++ b/src/d/actor/d_a_e_ymb.cpp
@@ -516,7 +516,7 @@ void daE_YMB_c::checkWaterPos() {
field_0x6cc = wtr_pos;
field_0x69c.y = wtr_pos + 1000.0f + l_HIO.fly_height_adjust;
- std::fabsf(field_0x6cc - current.pos.y);
+ UNUSED(std::fabsf(field_0x6cc - current.pos.y));
if (current.pos.y < (200.0f + field_0x6cc)) {
if (field_0x715 == 0) {
setWaterEffect1();
diff --git a/src/d/actor/d_a_e_zh.cpp b/src/d/actor/d_a_e_zh.cpp
index 5bba783e04..63c60b06c4 100644
--- a/src/d/actor/d_a_e_zh.cpp
+++ b/src/d/actor/d_a_e_zh.cpp
@@ -542,7 +542,7 @@ bool daE_ZH_c::mBallBgLineCheck() {
bool daE_ZH_c::mSearchMove(u8 param_1) {
if (mS_Ball == NULL) {
setActionMode(ACTION_EXECUTE_FLY_DELETE, 0);
- return NULL;
+ return false;
}
cXyz sp50, sp5c;
diff --git a/src/d/actor/d_a_horse.cpp b/src/d/actor/d_a_horse.cpp
index 6edd60a620..6f621fa650 100644
--- a/src/d/actor/d_a_horse.cpp
+++ b/src/d/actor/d_a_horse.cpp
@@ -51,9 +51,10 @@
#define ANM_HS_WALK_FAST 34
#define ANM_HS_WALK_SLOW 35
-static f32* strippedFunc() {
- f32 v[3] = {};
- return v;
+static void strippedFunc() {
+ extern void F(f32*);
+ f32 v[3] = {0.0f};
+ F(v);
}
static char const l_arcName[] = "Horse";
diff --git a/src/d/actor/d_a_mg_rod.cpp b/src/d/actor/d_a_mg_rod.cpp
index 816deb528e..c7d9bdfb4e 100644
--- a/src/d/actor/d_a_mg_rod.cpp
+++ b/src/d/actor/d_a_mg_rod.cpp
@@ -2977,8 +2977,8 @@ static void hook_set(dmg_rod_class* i_this, cXyz* param_1, int param_2) {
mDoMtx_stack_c::XrotM(-0x4000);
if (param_2 == 1 && (i_this->action <= ACTION_LURE_STANDBY || (i_this->lure_type != MG_LURE_SP && i_this->action == ACTION_LURE_CATCH))) {
- sp38.x = fabsf(hook->field_0x18.y);
- sp38.z = fabsf(hook->field_0x18.x - 0x4000);
+ sp38.x = fabsf((f32)hook->field_0x18.y);
+ sp38.z = fabsf((f32)(hook->field_0x18.x - 0x4000));
f32 var_f31 = JMAFastSqrt(SQUARE(sp38.x) + SQUARE(sp38.z));
if (var_f31 > 7000.0f) {
diff --git a/src/d/actor/d_a_nbomb.cpp b/src/d/actor/d_a_nbomb.cpp
index 1d09b39bfd..6728205040 100644
--- a/src/d/actor/d_a_nbomb.cpp
+++ b/src/d/actor/d_a_nbomb.cpp
@@ -986,7 +986,7 @@ BOOL daNbomb_c::procWait() {
speedF *= player->getBombBoundRate();
current.angle.y = (mAcchCir.GetWallAngleY() * 2) - (current.angle.y + 0x8000);
} else if (mAcch.ChkGroundLanding() && speedF > 5.0f && cM_deg2s(50.0f) <= field_0xb5a) {
- if ((f32)fabs(var_r28) >= (f32)0x4000) {
+ if ((f32)fabs((f64)var_r28) >= (f32)0x4000) {
speedF *= player->getBombBoundRate();
current.angle.y = (var_r27 * 2) - (current.angle.y + 0x8000);
mAcch.ClrGroundLanding();
diff --git a/src/d/actor/d_a_npc2.cpp b/src/d/actor/d_a_npc2.cpp
index 2558f4c092..3b3a22f66f 100644
--- a/src/d/actor/d_a_npc2.cpp
+++ b/src/d/actor/d_a_npc2.cpp
@@ -544,7 +544,7 @@ void daBaseNpc_c::orderEvent(int param_0, char* i_evtName) {
if (i_evtName != NULL) {
mEvtIdx = dComIfGp_getEventManager().getEventIdx(this, i_evtName, -1);
fopAcM_orderOtherEventId(this, mEvtIdx, 0xFF, 0xFFFF, 0, 1);
- } else if (field_0x848 >= 0 && attention_info.flags == (fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e)) {
+ } else if (mFlowID >= 0 && attention_info.flags == (fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e)) {
eventInfo.onCondition(1);
if (param_0 != 0) {
fopAcM_orderSpeakEvent(this, 0, 0);
diff --git a/src/d/actor/d_a_npc_bou.cpp b/src/d/actor/d_a_npc_bou.cpp
index 10139191f3..9c36dfb506 100644
--- a/src/d/actor/d_a_npc_bou.cpp
+++ b/src/d/actor/d_a_npc_bou.cpp
@@ -635,7 +635,7 @@ void daNpc_Bou_c::action() {
hit_actor = field_0xba0.getActorP();
if (hit_actor != NULL) {
- abs( (s16)(fopAcM_searchPlayerAngleY(this) - mCurAngle.y) );
+ UNUSED(abs((s16)(fopAcM_searchPlayerAngleY(this) - mCurAngle.y)));
switch (((daTag_Push_c*) hit_actor)->getId()) {
case 7: {
mEvtNo = 8;
diff --git a/src/d/actor/d_a_npc_chat.cpp b/src/d/actor/d_a_npc_chat.cpp
index 3b6ac5279f..345a33ab00 100644
--- a/src/d/actor/d_a_npc_chat.cpp
+++ b/src/d/actor/d_a_npc_chat.cpp
@@ -2628,7 +2628,7 @@ BOOL daNpcChat_c::setAttention(int param_1) {
cXyz(0.0f, 10.0f, 0.0f),
};
- int jointNo = isM_() ? JNTM_HEAD : JNTW_HEAD;
+ int jointNo = isM_() ? (int)JNTM_HEAD : (int)JNTW_HEAD;
mDoMtx_stack_c::copy(mAnm_p->getModel()->getAnmMtx(jointNo));
mDoMtx_stack_c::multVec(&a_eyeOfsTbl[param_1], &eyePos);
mBaseAttnPos.set(current.pos.x, current.pos.y + AtnOfs(param_1), current.pos.z);
diff --git a/src/d/actor/d_a_npc_coach.cpp b/src/d/actor/d_a_npc_coach.cpp
index 1c315d6332..4d69e63716 100644
--- a/src/d/actor/d_a_npc_coach.cpp
+++ b/src/d/actor/d_a_npc_coach.cpp
@@ -517,8 +517,7 @@ BOOL daNpcChPath_c::setPath(int path_index, int room_no, cXyz& i_vec, bool param
mCurrentID = path_index;
mPntIndex = 0;
- // Is this really what the Nintendo devs wrote?? The debug ROM suggests as such.
- if (param_4 && &i_vec) {
+ if (param_4 && IS_REF_NONNULL(i_vec)) {
f32 fVar1 = G_CM3D_F_INF;
for (int pnt_index = 0; pnt_index < mpPath->m_num; pnt_index++) {
dPnt* pnt = dPath_GetPnt(mpPath, pnt_index);
@@ -534,8 +533,7 @@ BOOL daNpcChPath_c::setPath(int path_index, int room_no, cXyz& i_vec, bool param
field_0x8 = G_CM3D_F_INF;
- // ditto.
- if (&i_vec) {
+ if (IS_REF_NONNULL(i_vec)) {
field_0x4 = &i_vec;
cXyz targetPoint;
getTargetPoint(targetPoint);
diff --git a/src/d/actor/d_a_npc_gra.cpp b/src/d/actor/d_a_npc_gra.cpp
index 9f303d8f3f..364b4b0fc6 100644
--- a/src/d/actor/d_a_npc_gra.cpp
+++ b/src/d/actor/d_a_npc_gra.cpp
@@ -343,10 +343,13 @@ BOOL daNpc_grA_c::create() {
mType = getTypeFromParam();
mMode = getMode();
mSwBit = getSwBit();
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xffff) {
- field_0x146C = home.angle.x;
+ mFlowID = home.angle.x;
} else{
- field_0x146C = -1;
+ mFlowID = -1;
}
if (isDelete()) {
return cPhs_ERROR_e;
@@ -2146,7 +2149,7 @@ BOOL daNpc_grA_c::ECut_talkSpa(int i_staffID) {
setLookMode(5);
break;
case 1:
- initTalk(field_0x146C, arr);
+ initTalk(mFlowID, arr);
break;
case 2:
if (daNpcF_chkEvtBit(6) && daNpcF_chkEvtBit(0x3e) == FALSE) {
@@ -3020,7 +3023,7 @@ BOOL daNpc_grA_c::ECut_rollRockCrash(int i_staffID) {
break;
case 0x14: {
setLookMode(0);
- initTalk(field_0x146C, NULL);
+ initTalk(mFlowID, NULL);
cXyz c(200.0f, 100.0f, 0.0f);
mDoMtx_stack_c::YrotS(home.angle.y);
mDoMtx_stack_c::multVec(&c, &c);
@@ -3588,7 +3591,7 @@ BOOL daNpc_grA_c::waitSpaWater(void*) {
}
setLookMode(0);
mTurnMode = 0;
- field_0x146C = 0x28;
+ mFlowID = 0x28;
field_0x1472 = 2;
field_0x9ea = 1;
// fallthrough
@@ -3968,7 +3971,7 @@ BOOL daNpc_grA_c::talk(void*) {
setGateWalk();
}
} else {
- r27 = field_0x146C;
+ r27 = mFlowID;
}
initTalk(r27, NULL);
field_0x1484 = fopAcM_searchPlayerAngleY(this);
diff --git a/src/d/actor/d_a_npc_grc.cpp b/src/d/actor/d_a_npc_grc.cpp
index e3f3949a55..a5828bad91 100644
--- a/src/d/actor/d_a_npc_grc.cpp
+++ b/src/d/actor/d_a_npc_grc.cpp
@@ -308,6 +308,9 @@ cPhs_Step daNpc_grC_c::create() {
mTwilight = dKy_darkworld_check();
mType = getTypeFromParam();
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xFFFF) {
mFlowID = home.angle.x;
} else {
diff --git a/src/d/actor/d_a_npc_grd.cpp b/src/d/actor/d_a_npc_grd.cpp
index a5630c17df..ffbb71286b 100644
--- a/src/d/actor/d_a_npc_grd.cpp
+++ b/src/d/actor/d_a_npc_grd.cpp
@@ -172,6 +172,9 @@ int daNpc_Grd_c::create() {
mType = getTypeFromParam();
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xffff) {
mFlowID = home.angle.x;
} else {
diff --git a/src/d/actor/d_a_npc_gro.cpp b/src/d/actor/d_a_npc_gro.cpp
index 20b432c1b0..317e043ff8 100644
--- a/src/d/actor/d_a_npc_gro.cpp
+++ b/src/d/actor/d_a_npc_gro.cpp
@@ -396,6 +396,9 @@ cPhs_Step daNpc_grO_c::create() {
mType = getTypeFromParam();
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xFFFF) {
mMsgNo = home.angle.x;
} else {
diff --git a/src/d/actor/d_a_npc_grr.cpp b/src/d/actor/d_a_npc_grr.cpp
index 0ba9b44d64..0c50e0e5a2 100644
--- a/src/d/actor/d_a_npc_grr.cpp
+++ b/src/d/actor/d_a_npc_grr.cpp
@@ -264,6 +264,9 @@ cPhs_Step daNpc_grR_c::create() {
mType = getTypeFromParam();
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xFFFF) {
mFlowID = home.angle.x;
} else {
diff --git a/src/d/actor/d_a_npc_grs.cpp b/src/d/actor/d_a_npc_grs.cpp
index 05d1356a47..f9ef95fbec 100644
--- a/src/d/actor/d_a_npc_grs.cpp
+++ b/src/d/actor/d_a_npc_grs.cpp
@@ -138,10 +138,13 @@ int daNpc_grS_c::create() {
mType = getTypeFromParam();
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xffff) {
- field_0xe0c = home.angle.x;
+ mFlowID = home.angle.x;
} else {
- field_0xe0c = -1;
+ mFlowID = -1;
}
if (isDelete()) {
@@ -856,7 +859,7 @@ int daNpc_grS_c::selectAction() {
mpNextActionFn = &daNpc_grS_c::test;
}
else {
- (int)mType;
+ UNUSED((int)mType);
mpNextActionFn = &daNpc_grS_c::wait;
}
@@ -936,7 +939,7 @@ int daNpc_grS_c::doEvent() {
if (eventInfo.checkCommandDemoAccrpt() && mEventIdx != -1 &&
eventManager->endCheck(mEventIdx))
{
- (int)mOrderEvtNo;
+ UNUSED((int)mOrderEvtNo);
dComIfGp_event_reset();
mOrderEvtNo = 0;
mEventIdx = -1;
@@ -1157,7 +1160,7 @@ int daNpc_grS_c::talk(void* param_0) {
daNpcF_offTmpBit(11);
}
- unkInt1 = field_0xe0c;
+ unkInt1 = mFlowID;
mIsSpeaking = false;
initTalk(unkInt1, NULL);
mTurnMode = 0;
diff --git a/src/d/actor/d_a_npc_grz.cpp b/src/d/actor/d_a_npc_grz.cpp
index 40558fee1b..a38e499c9d 100644
--- a/src/d/actor/d_a_npc_grz.cpp
+++ b/src/d/actor/d_a_npc_grz.cpp
@@ -455,6 +455,9 @@ cPhs_Step daNpc_Grz_c::create() {
mType = getTypeFromParam();
mSwNo = fopAcM_GetParam(this) >> 16;
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xFFFF) {
mMsgNo = home.angle.x;
} else {
diff --git a/src/d/actor/d_a_npc_gwolf.cpp b/src/d/actor/d_a_npc_gwolf.cpp
index 64d376705d..746f4766c9 100644
--- a/src/d/actor/d_a_npc_gwolf.cpp
+++ b/src/d/actor/d_a_npc_gwolf.cpp
@@ -291,10 +291,13 @@ cPhs_Step daNpc_GWolf_c::create() {
mExitId = fopAcM_GetParam(this) >> 24;
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xFFFF) {
- field_0xe08 = home.angle.x;
+ mFlowID = home.angle.x;
} else {
- field_0xe08 = -1;
+ mFlowID = -1;
}
swBit = getSwBitFromParam();
@@ -1817,7 +1820,7 @@ BOOL daNpc_GWolf_c::talk(void* param_1) {
break;
}
- int msgNo = field_0xe08;
+ int msgNo = mFlowID;
mOrderSpeakEvt = false;
initTalk(msgNo, NULL);
mTurnMode = 0;
diff --git a/src/d/actor/d_a_npc_kn.cpp b/src/d/actor/d_a_npc_kn.cpp
index c8b374a3b1..e76338b537 100644
--- a/src/d/actor/d_a_npc_kn.cpp
+++ b/src/d/actor/d_a_npc_kn.cpp
@@ -4961,11 +4961,11 @@ int daNpc_Kn_c::setPrtcl() {
// cXyz* pos = mParticleMngr[i].mpModel == true ? &mParticleMngr[i].mPos : NULL;
mParticleMngr[i].mManager.setEffectCenter(&tevStr, &mParticleMngr[i].mPos, check, sp_0x18,
- mParticleMngr[i].mpModel == true ? &mParticleMngr[i].mPos : NULL,
- mParticleMngr[i].mpModel == true ? &mParticleMngr[i].mAngle : NULL,
+ mParticleMngr[i].field_0x00 == true ? &mParticleMngr[i].mPos : NULL,
+ mParticleMngr[i].field_0x00 == true ? &mParticleMngr[i].mAngle : NULL,
0, fopAcM_GetRoomNo(this), 0.0f, speedF);
- if (mParticleMngr[i].mpModel != false) {
+ if (mParticleMngr[i].field_0x00 != false) {
emitter = mParticleMngr[i].mManager.getCenterEmitter(0, 0);
if (emitter != NULL) {
switch (i) {
@@ -4984,7 +4984,7 @@ int daNpc_Kn_c::setPrtcl() {
}
}
- mParticleMngr[i].mpModel = NULL;
+ mParticleMngr[i].field_0x00 = false;
}
return 1;
@@ -4996,21 +4996,21 @@ int daNpc_Kn_c::setSlipPrtcl() {
mParticleMngr[0].mPos.y -= 20.0f;
mParticleMngr[0].mAngle = current.angle;
ANGLE_SUB_2(mParticleMngr[0].mAngle.y, 0x8000);
- mParticleMngr[0].mpModel = true;
+ mParticleMngr[0].field_0x00 = true;
mDoMtx_stack_c::copy(mpModelMorf[0]->getModel()->getAnmMtx(0x1b));
mDoMtx_stack_c::multVecZero(&mParticleMngr[1].mPos);
mParticleMngr[1].mPos.y -= 20.0f;
mParticleMngr[1].mAngle = current.angle;
ANGLE_SUB_2(mParticleMngr[1].mAngle.y, 0x8000);
- mParticleMngr[1].mpModel = true;
+ mParticleMngr[1].field_0x00 = true;
return 1;
}
int daNpc_Kn_c::setLandingPrtcl() {
mParticleMngr[2].mPos = current.pos;
mParticleMngr[2].mAngle = mCurAngle;
- mParticleMngr[2].mpModel = true;
+ mParticleMngr[2].field_0x00 = true;
return 1;
}
diff --git a/src/d/actor/d_a_npc_ks.cpp b/src/d/actor/d_a_npc_ks.cpp
index 8b0abd9fb7..e2b312a22a 100644
--- a/src/d/actor/d_a_npc_ks.cpp
+++ b/src/d/actor/d_a_npc_ks.cpp
@@ -250,7 +250,13 @@ static int daNpc_Ks_Draw(npc_ks_class* i_this) {
fopAc_ac_c* actor = &i_this->actor;
J3DModel* model = i_this->model->getModel();
+ // This happens to work with MWCC since the member will only ever be initialized a pointer to a
+ // string in this TU's .data section, but comparing against a string literal is still UB.
+#if AVOID_UB
+ if (strcmp(i_this->res_name, "Npc_kst") == 0) {
+#else
if (i_this->res_name == "Npc_kst") {
+#endif
g_env_light.settingTevStruct(4, &actor->current.pos, &actor->tevStr);
} else {
g_env_light.settingTevStruct(0, &actor->current.pos, &actor->tevStr);
diff --git a/src/d/actor/d_a_npc_myna2.cpp b/src/d/actor/d_a_npc_myna2.cpp
index 2d55cbf836..a251a2518f 100644
--- a/src/d/actor/d_a_npc_myna2.cpp
+++ b/src/d/actor/d_a_npc_myna2.cpp
@@ -189,10 +189,13 @@ int daNpc_myna2_c::create() {
mType = getTypeFromParam();
field_0xe0d = (fopAcM_GetParam(this) & 0xFF00) >> 8;
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xFFFF) {
- field_0xe04 = home.angle.x;
+ mFlowID = home.angle.x;
} else {
- field_0xe04 = -1;
+ mFlowID = -1;
}
if (isDelete()) {
@@ -928,7 +931,7 @@ int daNpc_myna2_c::talk(void* param_0) {
switch (mMode) {
case 0:
if (!mIsDamaged) {
- initTalk(field_0xe04, NULL);
+ initTalk(mFlowID, NULL);
mTurnMode = 0;
mAnm_p->setPlaySpeed(1.0f);
mMode = 2;
@@ -1014,7 +1017,7 @@ int daNpc_myna2_c::ECut_firstTalk(int i_staffId) {
case 10:
break;
case 20:
- initTalk(field_0xe04, NULL);
+ initTalk(mFlowID, NULL);
break;
}
}
@@ -1063,7 +1066,7 @@ int daNpc_myna2_c::ECut_gameFailure(int i_staffId) {
case 20:
break;
case 10:
- initTalk(field_0xe04, NULL);
+ initTalk(mFlowID, NULL);
break;
}
}
@@ -1121,7 +1124,7 @@ int daNpc_myna2_c::ECut_gameGoal(int i_staffId) {
}
break;
case 10:
- initTalk(field_0xe04, NULL);
+ initTalk(mFlowID, NULL);
break;
case 20:
break;
@@ -1183,7 +1186,7 @@ int daNpc_myna2_c::ECut_gameGoalSuccess(int i_staffId) {
}
break;
case 10:
- initTalk(field_0xe04, NULL);
+ initTalk(mFlowID, NULL);
break;
case 20: {
int itemNo = 0;
@@ -1193,7 +1196,7 @@ int daNpc_myna2_c::ECut_gameGoalSuccess(int i_staffId) {
break;
}
case 25:
- initTalk(field_0xe04, NULL);
+ initTalk(mFlowID, NULL);
break;
case 30:
break;
diff --git a/src/d/actor/d_a_npc_ne.cpp b/src/d/actor/d_a_npc_ne.cpp
index 7144e77fe8..f74baadab3 100644
--- a/src/d/actor/d_a_npc_ne.cpp
+++ b/src/d/actor/d_a_npc_ne.cpp
@@ -135,7 +135,13 @@ static int daNpc_Ne_Draw(npc_ne_class* i_this) {
}
J3DModel* model = i_this->mpMorf->getModel();
+ // This happens to work with MWCC since the member will only ever be initialized a pointer to a
+ // string in this TU's .data section, but comparing against a string literal is still UB.
+#if AVOID_UB
+ if (strcmp(i_this->mResName, "Npc_net") == 0) {
+#else
if (i_this->mResName == "Npc_net") {
+#endif
if (!dComIfGs_wolfeye_effect_check()) {
return 1;
}
@@ -426,7 +432,12 @@ static void npc_ne_wait(npc_ne_class* i_this) {
daPy_py_c* player = static_cast<daPy_py_c*>(dComIfGp_getPlayer(0));
cLib_addCalc0(&_this->speedF, 1.0f, 1.3f);
+ // See comment in daNpc_Ne_Draw
+#if AVOID_UB
+ if (strcmp(i_this->mResName, "Npc_net") == 0) {
+#else
if (i_this->mResName == "Npc_net") {
+#endif
switch (i_this->mMode) {
case 0:
i_this->mTargetAngleY = cM_rndF(0x10000);
@@ -2173,7 +2184,12 @@ static void action(npc_ne_class* i_this) {
_this->gravity = -7.0f;
+ // See comment in daNpc_Ne_Draw
+#if AVOID_UB
+ if (strcmp(i_this->mResName, "Npc_net") == 0) {
+#else
if (i_this->mResName == "Npc_net") {
+#endif
i_this->mDistToTarget = 10000.0f;
} else {
i_this->mDistToTarget = i_this->mDistScale * fopAcM_searchPlayerDistance(_this);
@@ -2298,9 +2314,15 @@ static void action(npc_ne_class* i_this) {
break;
}
+ // See comment in daNpc_Ne_Draw
+#if AVOID_UB
+ if (strcmp(i_this->mResName, "Npc_net") != 0) {
+#else
if (i_this->mResName != "Npc_net") {
- if (i_this->mMessageState == 1 && daPy_py_c::checkNowWolf()
- && i_this->mDistToTarget < 300.0f) {
+#endif
+ if (i_this->mMessageState == 1 &&
+ daPy_py_c::checkNowWolf() &&
+ i_this->mDistToTarget < 300.0f) {
i_this->mAction = npc_ne_class::ACT_MESSAGE;
i_this->mMode = 0;
bird_check = false;
@@ -2846,8 +2868,15 @@ static void demo_camera(npc_ne_class* i_this) {
}
static int message(npc_ne_class* i_this) {
- if (i_this->mResName == "Npc_net" && !dComIfGs_wolfeye_effect_check()) {
- i_this->mMessageState = 0;
+ // See comment in daNpc_Ne_Draw
+#if AVOID_UB
+ if (strcmp(i_this->mResName, "Npc_net") == 0) {
+#else
+ if (i_this->mResName == "Npc_net") {
+#endif
+ if (!dComIfGs_wolfeye_effect_check()) {
+ i_this->mMessageState = 0;
+ }
}
if (i_this->mIsTalking) {
@@ -2872,7 +2901,12 @@ static int message(npc_ne_class* i_this) {
!fopAcM_otherBgCheck(daPy_getLinkPlayerActorClass(), i_this)) {
fopAcM_OnStatus(i_this, 0);
cLib_onBit<u32>(i_this->attention_info.flags, fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e);
+ // See comment in daNpc_Ne_Draw
+#if AVOID_UB
+ if (strcmp(i_this->mResName, "Npc_net") == 0) {
+#else
if (i_this->mResName == "Npc_net") {
+#endif
cLib_onBit<u32>(i_this->attention_info.flags, fopAc_AttnFlag_UNK_0x800000 | fopAc_AttnFlag_UNK_0x400000);
}
i_this->eventInfo.onCondition(dEvtCnd_CANTALK_e);
@@ -2978,14 +3012,21 @@ static int daNpc_Ne_Execute(npc_ne_class* i_this) {
message(i_this);
demo_camera(i_this);
- if (i_this->mResName == "Npc_net" && !dComIfGs_wolfeye_effect_check()) {
- static u16 e_name[2] = {0x8497, 0x8498};
- for (int i = 0; i < 2; i++) {
- i_this->mParticle[i] = dComIfGp_particle_set(i_this->mParticle[i], e_name[i],
- &i_this->eyePos, NULL, NULL);
- JPABaseEmitter* emitter = dComIfGp_particle_getEmitter(i_this->mParticle[i]);
- if (emitter != NULL) {
- emitter->setGlobalAlpha(!dComIfGs_wolfeye_effect_check() ? 0xff : 0);
+ // See comment in daNpc_Ne_Draw
+#if AVOID_UB
+ if (strcmp(i_this->mResName, "Npc_net") == 0) {
+#else
+ if (i_this->mResName == "Npc_net") {
+#endif
+ if (!dComIfGs_wolfeye_effect_check()) {
+ static u16 e_name[2] = {0x8497, 0x8498};
+ for (int i = 0; i < 2; i++) {
+ i_this->mParticle[i] = dComIfGp_particle_set(i_this->mParticle[i], e_name[i],
+ &i_this->eyePos, NULL, NULL);
+ JPABaseEmitter* emitter = dComIfGp_particle_getEmitter(i_this->mParticle[i]);
+ if (emitter != NULL) {
+ emitter->setGlobalAlpha(!dComIfGs_wolfeye_effect_check() ? 0xff : 0);
+ }
}
}
}
@@ -3231,7 +3272,12 @@ static cPhs_Step daNpc_Ne_Create(fopAc_ac_c* i_this) {
_this->mAcchCir.SetWall(_this->mBaseScale.y * 30.0f, _this->mBaseScale.z * 35.0f);
_this->mDistScale = cM_rndFX(0.2f) + 1.0f;
_this->mGroundY = i_this->current.pos.y;
+ // See comment in daNpc_Ne_Draw
+#if AVOID_UB
+ if (strcmp(_this->mResName, "Npc_net") == 0) {
+#else
if (_this->mResName == "Npc_net") {
+#endif
_this->mAction = npc_ne_class::ACT_WAIT;
_this->mMode = 0;
}
diff --git a/src/d/actor/d_a_npc_pachi_maro.cpp b/src/d/actor/d_a_npc_pachi_maro.cpp
index 6c9b34d5c7..6f29d62006 100644
--- a/src/d/actor/d_a_npc_pachi_maro.cpp
+++ b/src/d/actor/d_a_npc_pachi_maro.cpp
@@ -1098,7 +1098,7 @@ int daNpc_Pachi_Maro_c::wait(void* param_1) {
}
if (mJntAnm.getMode() == 0) {
- (s32)mType;
+ UNUSED((int)mType);
}
}
break;
diff --git a/src/d/actor/d_a_npc_pachi_taro.cpp b/src/d/actor/d_a_npc_pachi_taro.cpp
index e54dba6fec..99d47bc5b5 100644
--- a/src/d/actor/d_a_npc_pachi_taro.cpp
+++ b/src/d/actor/d_a_npc_pachi_taro.cpp
@@ -1464,7 +1464,7 @@ int daNpc_Pachi_Taro_c::wait(void* param_1) {
// ???
if (mJntAnm.getMode() == 0) {
- (int)mType;
+ UNUSED((int)mType);
}
if (field_0x1004 == 0) {
diff --git a/src/d/actor/d_a_npc_post.cpp b/src/d/actor/d_a_npc_post.cpp
index 52a392bafd..7880a64b91 100644
--- a/src/d/actor/d_a_npc_post.cpp
+++ b/src/d/actor/d_a_npc_post.cpp
@@ -696,7 +696,7 @@ BOOL daNpc_Post_c::checkChangeEvt() {
return TRUE;
}
- (int)mType;
+ UNUSED((int)mType);
}
return FALSE;
diff --git a/src/d/actor/d_a_npc_soldierA.cpp b/src/d/actor/d_a_npc_soldierA.cpp
index 1d5d1ecfe5..618407d4ef 100644
--- a/src/d/actor/d_a_npc_soldierA.cpp
+++ b/src/d/actor/d_a_npc_soldierA.cpp
@@ -206,6 +206,9 @@ cPhs_Step daNpc_SoldierA_c::create() {
mType = getTypeFromParam();
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xFFFF) {
mMsgNo = home.angle.x;
} else {
diff --git a/src/d/actor/d_a_npc_soldierB.cpp b/src/d/actor/d_a_npc_soldierB.cpp
index 7d42e522ab..83f9ef4ba0 100644
--- a/src/d/actor/d_a_npc_soldierB.cpp
+++ b/src/d/actor/d_a_npc_soldierB.cpp
@@ -171,6 +171,9 @@ cPhs_Step daNpc_SoldierB_c::create() {
mType = getTypeFromParam();
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xFFFF) {
mMsgNo = home.angle.x;
} else {
diff --git a/src/d/actor/d_a_npc_theB.cpp b/src/d/actor/d_a_npc_theB.cpp
index d01063d3d4..5c535ad1da 100644
--- a/src/d/actor/d_a_npc_theB.cpp
+++ b/src/d/actor/d_a_npc_theB.cpp
@@ -244,6 +244,9 @@ cPhs_Step daNpcTheB_c::create() {
return cPhs_ERROR_e;
}
+ // !@bug The return value (an s16) is promoted to a 32-bit signed
+ // integer prior to being compared, so the compared value can
+ // never exceed SHORT_MAX and the condition always passes.
if (getMessageNo() != 0xFFFF) {
mMsgNo = getMessageNo();
} else {
diff --git a/src/d/actor/d_a_npc_wrestler.cpp b/src/d/actor/d_a_npc_wrestler.cpp
index 1d3ae76404..a36774a099 100644
--- a/src/d/actor/d_a_npc_wrestler.cpp
+++ b/src/d/actor/d_a_npc_wrestler.cpp
@@ -2219,8 +2219,8 @@ bool daNpcWrestler_c::sumouReady(void* param_1) {
// fallthrough
case 2:
field_0xe5e += field_0xbd8->field_0xac;
- field_0xe54 -= fabsf(field_0xbd8->field_0xac);
- if (field_0xe54 < fabsf(field_0xbd8->field_0xac)) {
+ field_0xe54 -= fabsf((f32)field_0xbd8->field_0xac);
+ if (field_0xe54 < fabsf((f32)field_0xbd8->field_0xac)) {
field_0xe80 = 1;
field_0xe84++;
}
diff --git a/src/d/actor/d_a_npc_zra.cpp b/src/d/actor/d_a_npc_zra.cpp
index 8e0ec2415f..cf630eda05 100644
--- a/src/d/actor/d_a_npc_zra.cpp
+++ b/src/d/actor/d_a_npc_zra.cpp
@@ -493,6 +493,9 @@ cPhs_Step daNpc_zrA_c::create() {
fopAcM_ct(this, daNpc_zrA_c);
mType = getTypeFromArgument();
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xffff) {
mFlowID = home.angle.x;
} else {
diff --git a/src/d/actor/d_a_npc_zrc.cpp b/src/d/actor/d_a_npc_zrc.cpp
index 8334525901..b050a9f9bb 100644
--- a/src/d/actor/d_a_npc_zrc.cpp
+++ b/src/d/actor/d_a_npc_zrc.cpp
@@ -222,6 +222,9 @@ cPhs_Step daNpc_zrC_c::create() {
fopAcM_ct(this, daNpc_zrC_c);
mType = getTypeFromParam();
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xffff) {
mFlowID = home.angle.x;
} else {
diff --git a/src/d/actor/d_a_npc_zrz.cpp b/src/d/actor/d_a_npc_zrz.cpp
index b0c9c204dc..ece2931be9 100644
--- a/src/d/actor/d_a_npc_zrz.cpp
+++ b/src/d/actor/d_a_npc_zrz.cpp
@@ -203,6 +203,9 @@ cPhs_Step daNpc_zrZ_c::create() {
mSwitch1 = home.angle.z & 0xff;
mSwitch2 = (home.angle.z >> 8) & 0xff;
mSwitch3 = fopAcM_GetParam(this) >> 0x18;
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.x != 0xffff) {
mFlowID = home.angle.x;
} else {
diff --git a/src/d/actor/d_a_obj_brg.cpp b/src/d/actor/d_a_obj_brg.cpp
index cd0c504b7d..865ff625e2 100644
--- a/src/d/actor/d_a_obj_brg.cpp
+++ b/src/d/actor/d_a_obj_brg.cpp
@@ -666,8 +666,8 @@ static void obj_brg_move(obj_brg_class* i_this) {
if ((i_this->mType & 1) == 1) {
i_this->mBr[i].field_0x0e0 = 1.0f;
} else {
- var_f27 = ( f32(i) / (i_this->field_0xb1ea - 1)) * M_PI;
- i_this->mBr[i].field_0x0e0 = fabsf(sin(var_f27));
+ var_f27 = ((f32)i / (i_this->field_0xb1ea - 1)) * M_PI;
+ i_this->mBr[i].field_0x0e0 = fabsf(sinf(var_f27));
}
i_this->mBr[i].field_0x704 = i_this->mBr[i].field_0x705 = 3;
@@ -994,11 +994,11 @@ static int daObj_Brg_Execute(obj_brg_class* i_this) {
f32 dbg_0x5c;
for (int i = 0; i < i_this->field_0xb1ea; i++, part++) {
if (i_this->field_0xb1ed == 2) {
- dbg_0x5c = f32(i) / f32(i_this->field_0xb1ea - 1) * M_PI;
- var_f26 = (-300.0f + WREG_F(15)) * f32(sin(dbg_0x5c));
+ dbg_0x5c = (f32)i / (f32)(i_this->field_0xb1ea - 1) * M_PI;
+ var_f26 = (-300.0f + WREG_F(15)) * (f32)sin(dbg_0x5c);
} else if (i_this->field_0xb1ed == 1) {
- dbg_0x5c = f32(i) / f32(i_this->field_0xb1ea - 1) * M_PI;
- var_f26 = (-100.0f + WREG_F(13)) * f32(sin(dbg_0x5c));
+ dbg_0x5c = (f32)i / (f32)(i_this->field_0xb1ea - 1) * M_PI;
+ var_f26 = (-100.0f + WREG_F(13)) * (f32)sin(dbg_0x5c);
}
MtxTrans(part->field_0x0bc.x, part->field_0x0bc.y, part->field_0x0bc.z, 0);
@@ -1795,7 +1795,7 @@ static int daObj_Brg_Create(fopAc_ac_c* i_this) {
};
for (brno = 0; brno < a_this->field_0xb1ea; brno++) {
- a_this->mBr[brno].field_0x098[2] = brg_init_pos[brno];
+ a_this->mBr[brno].field_0x0b0 = brg_init_pos[brno];
}
}
diff --git a/src/d/actor/d_a_obj_cwall.cpp b/src/d/actor/d_a_obj_cwall.cpp
index 600f433c1a..9d48a90c3e 100644
--- a/src/d/actor/d_a_obj_cwall.cpp
+++ b/src/d/actor/d_a_obj_cwall.cpp
@@ -333,6 +333,10 @@ void daObjCwall_c::getChainBasePos(cXyz* pBasePos) {
void daObjCwall_c::setChainMtx() {
chain_s* pChain = mChains;
s16 sVar7 = home.angle.y;
+
+ // !@bug The variable is promoted to a 32-bit signed integer prior
+ // to being compared to 0xC000, so the compared value can never
+ // exceed SHORT_MAX and the subcondition fails.
if (sVar7 == 0x4000 || sVar7 == 0xc000) {
sVar7 += 0x4000;
}
diff --git a/src/d/actor/d_a_obj_gra2.cpp b/src/d/actor/d_a_obj_gra2.cpp
index a5d3c5fb69..58802a63ea 100644
--- a/src/d/actor/d_a_obj_gra2.cpp
+++ b/src/d/actor/d_a_obj_gra2.cpp
@@ -277,7 +277,10 @@ cPhs_Step daObj_GrA_c::create() {
}
}
- field_0x848 = ((int)home.angle.x == 0xFFFF) ? -1 : home.angle.x;
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always fails.
+ mFlowID = home.angle.x == 0xFFFF ? -1 : home.angle.x;
field_0x1fe8 = (fopAcM_GetParam(this) & 0xC0000000) >> 30;
field_0xa7f = home.angle.z & 0xFF;
@@ -1435,7 +1438,7 @@ int daObj_GrA_c::talk(void* param_1) {
int iVar1, iVar2;
int rv = 0;
int iVar3;
- int iVar4 = field_0x848;
+ int iVar4 = mFlowID;
s16 sVar1;
switch (field_0xa7c) {
case 0:
@@ -2013,7 +2016,7 @@ int daObj_GrA_c::face999(int param_1) {
}
int daObj_GrA_c::evtcutTalk(int param_1, int param_2) {
- s32 sVar1 = field_0x848;
+ s32 sVar1 = mFlowID;
if (param_2 != 0) {
mMsgFlow.init(this, sVar1, 0, NULL);
field_0xaa0 = 0;
diff --git a/src/d/actor/d_a_obj_gra2_soldier.inc b/src/d/actor/d_a_obj_gra2_soldier.inc
index 5bb137c167..32274435db 100644
--- a/src/d/actor/d_a_obj_gra2_soldier.inc
+++ b/src/d/actor/d_a_obj_gra2_soldier.inc
@@ -768,7 +768,7 @@ int daObj_GrA_c::rollDemo(void* param_1) {
field_0x91a.y = current.angle.y;
if (mDemoCamMode >= 5) {
- field_0x848 = 4;
+ mFlowID = 4;
evtcutTalk(-1, 1);
field_0x2000 = 0;
}
@@ -1169,7 +1169,7 @@ int daObj_GrA_c::rollAttacked(void* param_1) {
case 2:
if (mDemoCamMode >= 5) {
- field_0x848 = 5;
+ mFlowID = 5;
evtcutTalk(-1, 1);
field_0x2018 = 3;
}
diff --git a/src/d/actor/d_a_obj_magne_arm.cpp b/src/d/actor/d_a_obj_magne_arm.cpp
index 422ee5d6a4..af0567c209 100644
--- a/src/d/actor/d_a_obj_magne_arm.cpp
+++ b/src/d/actor/d_a_obj_magne_arm.cpp
@@ -947,7 +947,7 @@ void daObjMarm_c::calcHimo() {
getRopeStartPos(&offset1);
getFpartsOffset(&offset2);
- fabs(offset1.y - offset2.y);
+ UNUSED(fabs(offset1.y - offset2.y));
cXyz* line_mat1_pos = mpRope1->getPos(0);
*line_mat1_pos = offset1;
diff --git a/src/d/actor/d_a_obj_pumpkin.cpp b/src/d/actor/d_a_obj_pumpkin.cpp
index ff90ed6a74..6dcd0988f7 100644
--- a/src/d/actor/d_a_obj_pumpkin.cpp
+++ b/src/d/actor/d_a_obj_pumpkin.cpp
@@ -288,8 +288,9 @@ int daObj_Pumpkin_c::Execute() {
if (field_0xBAE) {
int item_table_no = getItemTableNo();
if (item_table_no >= 0 && mItemProcId == fpcM_ERROR_PROCESS_ID_e) {
- mItemProcId = fopAcM_createItemFromTable(&current.pos, item_table_no, -1, fopAcM_GetRoomNo(this),
- NULL, 0, NULL, NULL, NULL, NULL);
+ mItemProcId = fopAcM_createItemFromTable(&current.pos, item_table_no, -1,
+ fopAcM_GetRoomNo(this), NULL, 0, NULL, NULL,
+ NULL, false);
}
if (mItemProcId == fpcM_ERROR_PROCESS_ID_e || fopAcM_IsExecuting(mItemProcId)) {
diff --git a/src/d/actor/d_a_obj_sekidoor.cpp b/src/d/actor/d_a_obj_sekidoor.cpp
index 7be65ab45b..498282f4b4 100644
--- a/src/d/actor/d_a_obj_sekidoor.cpp
+++ b/src/d/actor/d_a_obj_sekidoor.cpp
@@ -112,7 +112,9 @@ int daObj_SekiDoor_c::Execute(Mtx** i_mtx) {
if (mOpening != 0) {
if (mDestroyed != 0) {
- if(!dComIfGp_event_runCheck){
+ // !@bug Missing parentheses - the function is not callled and
+ // this always evaluates to false.
+ if (!dComIfGp_event_runCheck) {
fopAcM_delete(this);
}
}
diff --git a/src/d/actor/d_a_obj_sekizoa.cpp b/src/d/actor/d_a_obj_sekizoa.cpp
index 57be8845a9..baba4a7fb2 100644
--- a/src/d/actor/d_a_obj_sekizoa.cpp
+++ b/src/d/actor/d_a_obj_sekizoa.cpp
@@ -1008,9 +1008,14 @@ bool daObj_Sekizoa_c::afterSetMotionAnm(int i_frame, int i_mode, f32 i_morf, int
if (mBtkAnm.getBtkAnm() == anm_text) {
mAnmFlags |= ANM_PLAY_BTK;
} else {
- if (setBtkAnm(anm_text, mpMorf[0]->getModel()->getModelData(), 1.0f,
- btkAnmData[4].field_0x4))
- {
+#if AVOID_UB
+ // negative attribute values are ignored in favor of the animation's default value
+ if (setBtkAnm(anm_text, mpMorf[0]->getModel()->getModelData(), 1.0f, -1)) {
+#else
+ // !@bug Out-of-bounds array read, in practice this ends up reading from a jump table
+ // positioned immediately after btkAnmData in .data.
+ if (setBtkAnm(anm_text, mpMorf[0]->getModel()->getModelData(), 1.0f, btkAnmData[4].field_0x4)) {
+#endif
if (frame_1 == 3) {
mBtkAnm.setPlaySpeed(0.0f);
}
@@ -1032,8 +1037,15 @@ bool daObj_Sekizoa_c::afterSetMotionAnm(int i_frame, int i_mode, f32 i_morf, int
if (mBrkAnm.getBrkAnm() == anm_tev) {
mAnmFlags |= ANM_PLAY_BRK;
} else {
- frame_1 = setBrkAnm(anm_tev, mpMorf[0]->getModel()->getModelData(), 1.0,
+ // !@bug OoB index into brkAnmData ends up indexing into btkAnmData instead.
+ // This was probably supposed to use brkAnmData[5] instead.
+#if AVOID_UB
+ frame_1 = setBrkAnm(anm_tev, mpMorf[0]->getModel()->getModelData(), 1.0f,
+ btkAnmData[0].field_0x4);
+#else
+ frame_1 = setBrkAnm(anm_tev, mpMorf[0]->getModel()->getModelData(), 1.0f,
brkAnmData[6].field_0x4);
+#endif
if (frame_1 != 0) {
if (frame_2 == 5) {
mBrkAnm.setPlaySpeed(0.0f);
diff --git a/src/d/actor/d_a_obj_ss_drink.cpp b/src/d/actor/d_a_obj_ss_drink.cpp
index 50d4fcd4cb..846eb56124 100644
--- a/src/d/actor/d_a_obj_ss_drink.cpp
+++ b/src/d/actor/d_a_obj_ss_drink.cpp
@@ -384,6 +384,7 @@ int daObj_SSDrink_c::chkEvent() {
}
int daObj_SSDrink_c::orderEvent() {
+ // !@bug Comparison of u16 (getFlowNodeNum()) with -1 always evaluates to false
if (!daPy_py_c::checkNowWolf() && field_0xb0c != 0x60 && getFlowNodeNum() != -1) {
attention_info.flags = fopAc_AttnFlag_TALKREAD_e | fopAc_AttnFlag_SPEAK_e;
} else {
diff --git a/src/d/actor/d_a_tag_evt.cpp b/src/d/actor/d_a_tag_evt.cpp
index 2552f59e24..8dc5954ef0 100644
--- a/src/d/actor/d_a_tag_evt.cpp
+++ b/src/d/actor/d_a_tag_evt.cpp
@@ -168,6 +168,7 @@ int daTag_Evt_c::isDelete() {
if (field_0x5DD == 0xFF ||
(field_0x5DD != 0xFF && dComIfGs_isSwitch(field_0x5DD, fopAcM_GetRoomNo(this)) != 0))
{
+ // !@bug Comparison of u8 field with 0xFFF will always evaluate to false
if (field_0x5DE != 0xFFF) {
return dComIfGs_isSwitch(field_0x5DE, fopAcM_GetRoomNo(this));
} else {
diff --git a/src/d/actor/d_a_tag_evtmsg.cpp b/src/d/actor/d_a_tag_evtmsg.cpp
index 8a2035f147..b5e71f00e3 100644
--- a/src/d/actor/d_a_tag_evtmsg.cpp
+++ b/src/d/actor/d_a_tag_evtmsg.cpp
@@ -36,6 +36,9 @@ int daTag_EvtMsg_c::create() {
scale.y *= 100.0f;
scale.z = scale.x;
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.z != 0xFFFF) {
mFlowID = home.angle.z;
} else {
diff --git a/src/d/actor/d_a_tag_lantern.cpp b/src/d/actor/d_a_tag_lantern.cpp
index 264a0c1987..88660a029d 100644
--- a/src/d/actor/d_a_tag_lantern.cpp
+++ b/src/d/actor/d_a_tag_lantern.cpp
@@ -126,6 +126,9 @@ void daTag_Lantern_c::initialize() {
mpHIO->entryHIO("カンテラチェックタグ");
#endif
+ // !@bug home.angle.x is promoted to a 32-bit signed integer prior
+ // to being compared, so the compared value can never exceed
+ // SHORT_MAX and the condition always passes.
if (home.angle.z != 0xFFFF) {
mFlowIndex = home.angle.z;
} else {
diff --git a/src/d/actor/d_a_tag_setrestart.cpp b/src/d/actor/d_a_tag_setrestart.cpp
index c7134fbae4..4230abb920 100644
--- a/src/d/actor/d_a_tag_setrestart.cpp
+++ b/src/d/actor/d_a_tag_setrestart.cpp
@@ -163,7 +163,7 @@ static int daTagRestart_Execute(daTagRestart_c* i_this) {
}
static int daTagRestart_Delete(daTagRestart_c* i_this) {
- ("Delete -> TagRestart( =%d)\n", fopAcM_GetID(i_this));
+ fopAcM_RegisterDeleteID(i_this, "TagRestart");
return i_this->_delete();
}
diff --git a/src/d/actor/d_a_tag_ss_drink.cpp b/src/d/actor/d_a_tag_ss_drink.cpp
index 645fc16a50..f4f8b5fbe2 100644
--- a/src/d/actor/d_a_tag_ss_drink.cpp
+++ b/src/d/actor/d_a_tag_ss_drink.cpp
@@ -136,7 +136,7 @@ int daTag_SSDrink_c::chkEvent() {
if (!dComIfGp_getEvent()->isOrderOK()) {
retVal = 0;
if (eventInfo.checkCommandTalk()) {
- if (!checkProcess(&daTag_SSDrink_c::talk) == 0) {
+ if (checkProcess(&daTag_SSDrink_c::talk) != 0) {
retVal = (this->*mProcessFunc)(0);
} else {
if (dComIfGp_event_chkTalkXY() == 0 || dComIfGp_evmng_ChkPresentEnd() != 0) {
diff --git a/src/d/actor/d_a_tag_theB_hint.cpp b/src/d/actor/d_a_tag_theB_hint.cpp
index d368d726df..58887f976e 100644
--- a/src/d/actor/d_a_tag_theB_hint.cpp
+++ b/src/d/actor/d_a_tag_theB_hint.cpp
@@ -23,6 +23,7 @@ int daTagTheBHint_c::execute() {
if (fopAcM_searchPlayerDistanceXZ2(this) < field_0x568) {
daNpcTheB_c* the_b = (daNpcTheB_c*)fpcM_SearchByName(fpcNm_NPC_THEB_e);
if (the_b) {
+ // !@bug Comparison of s8 (getRoomNo) with 0xFF always evaluates to false
int roomNo = getRoomNo() == 0xff ? fopAcM_GetRoomNo(this) : getRoomNo();
the_b->setHintEvent(getMessageNo(), getLinkID(), roomNo);
diff --git a/src/d/d_debug_camera.cpp b/src/d/d_debug_camera.cpp
index 10c5edd71f..ca41c517d6 100644
--- a/src/d/d_debug_camera.cpp
+++ b/src/d/d_debug_camera.cpp
@@ -1719,7 +1719,7 @@ JUtility::TColor get_color(JUtility::TColor color) {
JUtility::TColor(0x80, 0x80, 0xFF, 0xFF),
};
- (void)(u32)color;
+ UNUSED((u32)color);
int var_r30 = 1;
if (var_r30 && (u32)color < 9) {
diff --git a/src/d/d_demo.cpp b/src/d/d_demo.cpp
index 2af725c162..651d89e126 100644
--- a/src/d/d_demo.cpp
+++ b/src/d/d_demo.cpp
@@ -14,6 +14,24 @@
s16 dDemo_c::m_branchId = -1;
namespace {
+class jstudio_tAdaptor_message : public JStudio::TAdaptor_message {
+public:
+ typedef JStudio::TObject_message ObjectType;
+
+ jstudio_tAdaptor_message() {}
+
+ virtual ~jstudio_tAdaptor_message();
+ virtual void adaptor_do_MESSAGE(JStudio::data::TEOperationData, const void*, u32);
+};
+
+class jstudio_tCreateObject_message : public JStudio::TCreateObject {
+public:
+ jstudio_tCreateObject_message() {}
+
+ virtual ~jstudio_tCreateObject_message();
+ virtual bool create(JStudio::TObject**, const JStudio::stb::data::TParse_TBlock_object&);
+};
+
jstudio_tAdaptor_message::~jstudio_tAdaptor_message() {}
void jstudio_tAdaptor_message::adaptor_do_MESSAGE(JStudio::data::TEOperationData iType,
@@ -168,7 +186,7 @@ JStudio_JAudio2::TCreateObject* dDemo_c::m_audio;
dDemo_particle_c* dDemo_c::m_particle;
-jstudio_tCreateObject_message* dDemo_c::m_message;
+JStudio::TCreateObject* dDemo_c::m_message;
JStudio::TFactory* dDemo_c::m_factory;
diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp
index b79a594eff..bea73d76c6 100644
--- a/src/d/d_drawlist.cpp
+++ b/src/d/d_drawlist.cpp
@@ -1820,7 +1820,7 @@ int dDlst_list_c::set(dDlst_base_c**& p_start, dDlst_base_c**& p_end, dDlst_base
return 0;
}
*p_start = p_newDlst;
- *p_start++;
+ UNUSED(*p_start++);
return 1;
}
diff --git a/src/d/d_ev_camera.cpp b/src/d/d_ev_camera.cpp
index f737d35dda..593d723b35 100644
--- a/src/d/d_ev_camera.cpp
+++ b/src/d/d_ev_camera.cpp
@@ -2160,7 +2160,7 @@ bool dCamera_c::gameOverEvCamera() {
mViewCache.mEye = sp230;
gover_p->field_0x0++;
mViewCache.mFovy = 75.0f;
- bVar9 = 75.0f;
+ bVar9 = true;
}
// fallthrough intentional.
case 4: {
diff --git a/src/d/d_kankyo.cpp b/src/d/d_kankyo.cpp
index 624a30b7b0..2490209efd 100644
--- a/src/d/d_kankyo.cpp
+++ b/src/d/d_kankyo.cpp
@@ -10483,7 +10483,7 @@ BOOL dKy_camera_water_in_status_check() {
u8 dKy_pol_efftype_get(const cBgS_PolyInfo* polyinfo_p) {
dScnKy_env_light_c* kankyo = dKy_getEnvlight();
- if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) {
+ if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) {
return 0xFF;
}
@@ -10513,7 +10513,7 @@ u8 dKy_pol_efftype_get(const cBgS_PolyInfo* polyinfo_p) {
u8 dKy_pol_efftype2_get(const cBgS_PolyInfo* polyinfo_p) {
dScnKy_env_light_c* kankyo = dKy_getEnvlight();
- if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) {
+ if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) {
return 0xFF;
}
@@ -10543,7 +10543,7 @@ u8 dKy_pol_efftype2_get(const cBgS_PolyInfo* polyinfo_p) {
u8 dKy_pol_sound_get(const cBgS_PolyInfo* polyinfo_p) {
dScnKy_env_light_c* kankyo = dKy_getEnvlight();
- if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) {
+ if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) {
return 0;
}
@@ -10574,7 +10574,7 @@ u8 dKy_pol_sound_get(const cBgS_PolyInfo* polyinfo_p) {
u8 dKy_pol_argument_get(const cBgS_PolyInfo* polyinfo_p) {
dScnKy_env_light_c* kankyo = dKy_getEnvlight();
- if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) {
+ if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) {
return 0;
}
@@ -10599,7 +10599,7 @@ u8 dKy_pol_argument_get(const cBgS_PolyInfo* polyinfo_p) {
u8 dKy_pol_eff_prim_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) {
dScnKy_env_light_c* kankyo = dKy_getEnvlight();
u8 eff_id = 0;
- if (polyinfo_p == NULL || out_color_p == NULL || &dComIfG_Bgsp() == NULL) {
+ if (polyinfo_p == NULL || out_color_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) {
return 0xFF;
}
@@ -10636,7 +10636,7 @@ u8 dKy_pol_eff_prim_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) {
u8 dKy_pol_eff_env_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) {
dScnKy_env_light_c* kankyo = dKy_getEnvlight();
u8 eff_id = 0;
- if (polyinfo_p == NULL || out_color_p == NULL || &dComIfG_Bgsp() == NULL) {
+ if (polyinfo_p == NULL || out_color_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) {
return 0xFF;
}
@@ -10673,7 +10673,7 @@ u8 dKy_pol_eff_env_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) {
u8 dKy_pol_eff2_prim_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) {
dScnKy_env_light_c* kankyo = dKy_getEnvlight();
u8 eff_id = 0;
- if (polyinfo_p == NULL || out_color_p == NULL || &dComIfG_Bgsp() == NULL) {
+ if (polyinfo_p == NULL || out_color_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) {
return 0xFF;
}
@@ -10710,7 +10710,7 @@ u8 dKy_pol_eff2_prim_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p)
u8 dKy_pol_eff2_env_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) {
dScnKy_env_light_c* kankyo = dKy_getEnvlight();
u8 eff_id = 0;
- if (polyinfo_p == NULL || out_color_p == NULL || &dComIfG_Bgsp() == NULL) {
+ if (polyinfo_p == NULL || out_color_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) {
return 0xFF;
}
@@ -10748,7 +10748,7 @@ u8 dKy_pol_eff_alpha_get(const cBgS_PolyInfo* polyinfo_p) {
dScnKy_env_light_c* kankyo = dKy_getEnvlight();
int z0;
u8 eff_id = 0;
- if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) {
+ if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) {
return 0xFF;
}
@@ -10785,7 +10785,7 @@ f32 dKy_pol_eff_ratio_get(const cBgS_PolyInfo* polyinfo_p) {
u8 eff_id;
f32 ratio = 0.0f;
- if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) {
+ if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) {
return 0.0f;
}
@@ -10822,7 +10822,7 @@ u8 dKy_pol_eff2_alpha_get(const cBgS_PolyInfo* polyinfo_p) {
dScnKy_env_light_c* kankyo = dKy_getEnvlight();
int z0;
u8 retval = 0;
- if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) {
+ if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) {
return 0xFF;
}
@@ -10858,7 +10858,7 @@ f32 dKy_pol_eff2_ratio_get(const cBgS_PolyInfo* polyinfo_p) {
dScnKy_env_light_c* kankyo = dKy_getEnvlight();
f32 ratio = 0.0f;
- if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) {
+ if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) {
return 0.0f;
}
diff --git a/src/d/d_lib.cpp b/src/d/d_lib.cpp
index 8f3597a55b..34c626ea75 100644
--- a/src/d/d_lib.cpp
+++ b/src/d/d_lib.cpp
@@ -108,7 +108,7 @@ u8 STControl::checkTrigger() {
f32 stickValue = getValueStick();
s16 stickAngle = getAngleStick();
u8 var_r6 = 0;
- s16 temp_r7 = 0x2000 - field_0x26 >> 1;
+ s16 temp_r7 = (0x2000 - field_0x26) >> 1;
if (!cM3d_IsZero(stickValue)) {
if (stickAngle < field_0x22 - 0x7000 + temp_r7) {
diff --git a/src/d/d_map_path_dmap.cpp b/src/d/d_map_path_dmap.cpp
index 4f45717806..8652462434 100644
--- a/src/d/d_map_path_dmap.cpp
+++ b/src/d/d_map_path_dmap.cpp
@@ -199,10 +199,10 @@ void dMapInfo_n::getRoomMinMaxXZ(int i_roomNo, f32* i_roomLeftX, f32* i_roomInne
void dMapInfo_n::getFloorParameter(f32 param_0, s8* i_floorNo, f32* param_2, f32* param_3,
f32* param_4, f32* param_5) {
- f32 gap_level = dStage_stagInfo_GetGapLevel(dComIfGp_getStageStagInfo());
- f32 range_up = fabsf(dStage_stagInfo_GetRangeUp(dComIfGp_getStageStagInfo()));
- f32 range_down = fabsf(dStage_stagInfo_GetRangeDown(dComIfGp_getStageStagInfo()));
- s8 floorNo = (f32)floor(param_0 / gap_level);
+ f32 gap_level = (f32)dStage_stagInfo_GetGapLevel(dComIfGp_getStageStagInfo());
+ f32 range_up = fabsf((f32)dStage_stagInfo_GetRangeUp(dComIfGp_getStageStagInfo()));
+ f32 range_down = fabsf((f32)dStage_stagInfo_GetRangeDown(dComIfGp_getStageStagInfo()));
+ s8 floorNo = (s8)(f32)floor(param_0 / gap_level);
if (i_floorNo != NULL) {
*i_floorNo = floorNo;
diff --git a/src/d/d_menu_letter.cpp b/src/d/d_menu_letter.cpp
index efb35e6d50..7cb78f8bd5 100644
--- a/src/d/d_menu_letter.cpp
+++ b/src/d/d_menu_letter.cpp
@@ -18,9 +18,9 @@
#include "d/d_lib.h"
#if VERSION == VERSION_GCN_JPN
-#define LINE_MAX 9
+#define D_MENU_LETTER_LINE_MAX 9
#else
-#define LINE_MAX 12
+#define D_MENU_LETTER_LINE_MAX 12
#endif
typedef void (dMenu_Letter_c::*initFunc)();
@@ -258,8 +258,8 @@ void dMenu_Letter_c::_draw() {
uVar10 = (J2DTextBox*)field_0x2f4[i]->getPanePtr();
}
J2DTextBox* uVar18 = (J2DTextBox*)field_0x2ec[i]->getPanePtr();
- mpString->getStringPage(dMenu_Letter::getLetterText(dVar1), field_0x3e3 - 1, LINE_MAX,
- uVar18, uVar10, NULL, NULL, 0);
+ mpString->getStringPage(dMenu_Letter::getLetterText(dVar1), field_0x3e3 - 1,
+ D_MENU_LETTER_LINE_MAX, uVar18, uVar10, NULL, NULL, 0);
}
mpString->drawOutFont((J2DTextBox*)field_0x2ec[1]->getPanePtr(), -1.0f);
if (mProcess == 4) {
@@ -491,10 +491,10 @@ void dMenu_Letter_c::read_open_init() {
text1 = (J2DTextBox*)field_0x2f4[i]->getPanePtr();
}
J2DTextBox* text2 = (J2DTextBox*)field_0x2ec[i]->getPanePtr();
- mpString->getStringPage(dMenu_Letter::getLetterText(idx), field_0x3e3 - 1, LINE_MAX, text2, text1,
- 0, NULL, NULL);
+ mpString->getStringPage(dMenu_Letter::getLetterText(idx), field_0x3e3 - 1,
+ D_MENU_LETTER_LINE_MAX, text2, text1, NULL, NULL, 0);
}
- field_0x3e2 = mpString->getPageMax(LINE_MAX);
+ field_0x3e2 = mpString->getPageMax(D_MENU_LETTER_LINE_MAX);
if (field_0x3e2 > 1) {
char acStack_30[20];
sprintf(acStack_30, "%d/%d", field_0x3e3, field_0x3e2);
@@ -642,7 +642,8 @@ void dMenu_Letter_c::read_next_fadein_init() {
text1 = (J2DTextBox*)field_0x2f4[i]->getPanePtr();
}
J2DTextBox* text2 = (J2DTextBox*)field_0x2ec[i]->getPanePtr();
- mpString->getStringPage(dMenu_Letter::getLetterText(idx), field_0x3e3 - 1, LINE_MAX, text2, text1, 0, NULL, NULL);
+ mpString->getStringPage(dMenu_Letter::getLetterText(idx), field_0x3e3 - 1,
+ D_MENU_LETTER_LINE_MAX, text2, text1, NULL, NULL, 0);
}
char acStack_30[10];
sprintf(acStack_30, "%d/%d", field_0x3e3, field_0x3e2);
diff --git a/src/d/d_menu_ring.cpp b/src/d/d_menu_ring.cpp
index 878c534220..4374dd1826 100644
--- a/src/d/d_menu_ring.cpp
+++ b/src/d/d_menu_ring.cpp
@@ -1503,6 +1503,8 @@ void dMenu_Ring_c::setSelectItem(int i_idx, u8 i_itemNo) {
} else {
field_0x6be[i_idx] = 0;
}
+ // !@bug Out-of-bounds access into mpSelectItemTexBuf
+ // (innermost dimension is 2, we take index 2 which is invalid)
field_0x686[i_idx] = dMeter2Info_readItemTexture(
i_itemNo, mpSelectItemTexBuf[i_idx][field_0x6be[i_idx]][0], mpSelectItemTex[i_idx][0],
mpSelectItemTexBuf[i_idx][field_0x6be[i_idx]][1], mpSelectItemTex[i_idx][1],
diff --git a/src/d/d_msg_object.cpp b/src/d/d_msg_object.cpp
index 0cb515113c..29b8cbdd41 100644
--- a/src/d/d_msg_object.cpp
+++ b/src/d/d_msg_object.cpp
@@ -1602,7 +1602,16 @@ u8 dMsgObject_c::isSend() {
}
void dMsgObject_c::readMessageGroupLocal(mDoDvdThd_mountXArchive_c** p_arcMount) {
+#if AVOID_UB
+ // largest possible value msgGroup appears to be 99, but just in case
+ // we leave enough space to fit INT_MAX
+ static char arcName[32];
+#else
+ // We write at least 23 bytes into this which causes an overflow,
+ // but in practice arcName is followed by two bytes of padding
+ // at the end of .bss which mitigates the problem.
static char arcName[22];
+#endif
int msgGroup = dStage_stagInfo_GetMsgGroup(dComIfGp_getStage()->getStagInfo());
#if REGION_PAL
@@ -2133,7 +2142,7 @@ u16 dMsgObject_c::getSmellTypeMessageIDLocal() {
if (smell < dItemNo_SMELL_MEDICINE_e + 1 && smell >= dItemNo_SMELL_YELIA_POUCH_e) {
msgId = smell + 0x165;
} else {
- if (dComIfGs_getCollectSmell() != -1) {
+ if (dComIfGs_getCollectSmell() != 0xFF) {
OS_REPORT("smell type ====> %d\n", dComIfGs_getCollectSmell());
JUT_WARN(4858, "smell type no entry!");
}
diff --git a/src/d/d_msg_scrn_howl.cpp b/src/d/d_msg_scrn_howl.cpp
index 473de9c350..102a5d95e0 100644
--- a/src/d/d_msg_scrn_howl.cpp
+++ b/src/d/d_msg_scrn_howl.cpp
@@ -19,6 +19,16 @@
#include "JSystem/J2DGraph/J2DScreen.h"
#include "Z2AudioLib/Z2WolfHowlMgr.h"
+// POSIX already defines a macro with this name, but we know that this specific name is
+// used in TP based on assertion messages. This redefinition is scoped to this TU which
+// is unlikely to ever actually need the POSIX define, so we can just redefine it.
+#if defined(LINE_MAX)
+#undef LINE_MAX
+#endif
+#define LINE_MAX 30
+//TODO: This is likely an enum value based on its name
+#define PLOT_BUFFER_MAX_e 0x300
+
typedef void (dMsgScrnHowl_c::*dMsgScrnHowl_cFunc)();
static dMsgScrnHowl_cFunc init_proc[5] = {
diff --git a/src/d/d_particle.cpp b/src/d/d_particle.cpp
index 8b171047aa..54f24549dd 100644
--- a/src/d/d_particle.cpp
+++ b/src/d/d_particle.cpp
@@ -506,7 +506,7 @@ bool dPa_modelEcallBack::model_c::set(J3DModelData* i_modelData, dKy_tevstr_c co
field_0x8.field_0x344 = param_1.field_0x344;
typedef struct Arr{
int field_0x0[2];
- };
+ } Arr;
*(Arr*)&field_0x8.AmbCol = *(Arr*)&param_1.AmbCol;
*(Arr*)&field_0x8.FogCol = *(Arr*)&param_1.FogCol;
*(Arr*)&field_0x8.TevColor = *(Arr*)&param_1.TevColor;
@@ -838,11 +838,11 @@ u32 dPa_simpleEcallBack::set(cXyz const* i_pos, dKy_tevstr_c const* param_2, u8
GXColor local_60;
GXColor local_64 = {0xff, 0xff, 0xff, 0xff};
GXColor local_68 = {0xff, 0xff, 0xff, 0xff};
- if (&param_5 != NULL) {
+ if (IS_REF_NONNULL(param_5)) {
local_64 = param_5;
}
- if (&param_4 != NULL) {
+ if (IS_REF_NONNULL(param_4)) {
local_68 = param_4;
}
@@ -859,11 +859,11 @@ u32 dPa_simpleEcallBack::set(cXyz const* i_pos, dKy_tevstr_c const* param_2, u8
GXColor local_70;
GXColor local_74 = {0xff, 0xff, 0xff, 0xff};
GXColor local_78 = {0xff, 0xff, 0xff, 0xff};
- if (&param_5 != NULL) {
+ if (IS_REF_NONNULL(param_5)) {
local_74 = param_5;
}
- if (&param_4 != NULL) {
+ if (IS_REF_NONNULL(param_4)) {
local_78 = param_4;
}
@@ -881,13 +881,13 @@ u32 dPa_simpleEcallBack::set(cXyz const* i_pos, dKy_tevstr_c const* param_2, u8
pData->field_0x10.g = local_6c.g;
pData->field_0x10.b = local_6c.b;
} else {
- if (&param_4 != NULL) {
+ if (IS_REF_NONNULL(param_4)) {
pData->field_0x0c.r = param_4.r;
pData->field_0x0c.g = param_4.g;
pData->field_0x0c.b = param_4.b;
}
- if (&param_5 != NULL) {
+ if (IS_REF_NONNULL(param_5)) {
pData->field_0x10.r = param_5.r;
pData->field_0x10.g = param_5.g;
pData->field_0x10.b = param_5.b;
diff --git a/src/d/d_save.cpp b/src/d/d_save.cpp
index 52daf21404..aaa59edcf1 100644
--- a/src/d/d_save.cpp
+++ b/src/d/d_save.cpp
@@ -1790,7 +1790,7 @@ int dSv_info_c::memory_to_card(char* card_ptr, int dataNum) {
OS_REPORT("(dSv_reserve_c) size %d\n", sizeof(dSv_reserve_c));
OS_REPORT("(dSv_MiniGame_c) size %d\n", sizeof(dSv_MiniGame_c));
OS_REPORT("セーブ全体情報(dSv_save_c) size %d\n", sizeof(dSv_save_c));
- printf("Write size:%d\n", card_ptr - var_r29);
+ printf("Write size:%d\n", (int)(card_ptr - var_r29));
// Now that we've saved, reset events if needed
if (lantern_not_recovered == true) {
@@ -1809,11 +1809,11 @@ int dSv_info_c::memory_to_card(char* card_ptr, int dataNum) {
}
if (card_ptr - var_r29 > (QUEST_LOG_SIZE - 8)) {
- printf("SAVE size over(%d/%d)\n", (QUEST_LOG_SIZE - 8), card_ptr - var_r29);
+ printf("SAVE size over(%d/%d)\n", (QUEST_LOG_SIZE - 8), (int)(card_ptr - var_r29));
return -1;
}
- printf("SAVE size:%d\n", card_ptr - var_r29);
+ printf("SAVE size:%d\n", (int)(card_ptr - var_r29));
return 0;
}
@@ -1859,11 +1859,11 @@ int dSv_info_c::card_to_memory(char* i_cardPtr, int i_dataNum) {
OS_REPORT("########### save stage ====> %s\n", dMeter2Info_getSaveStageName());
if (i_cardPtr - var_r30 > (QUEST_LOG_SIZE - 8)) {
- printf("LOAD size over(%d/%d)\n", (QUEST_LOG_SIZE - 8), i_cardPtr - var_r30);
+ printf("LOAD size over(%d/%d)\n", (QUEST_LOG_SIZE - 8), (int)(i_cardPtr - var_r30));
return -1;
}
- printf("LOAD size:%d\n", i_cardPtr - var_r30);
+ printf("LOAD size:%d\n", (int)(i_cardPtr - var_r30));
return 0;
}
@@ -1880,11 +1880,11 @@ int dSv_info_c::initdata_to_card(char* i_cardPtr, int i_dataNum) {
i_cardPtr += sizeof(dSv_save_c);
if (i_cardPtr - var_r30 > (QUEST_LOG_SIZE - 8)) {
- printf("INIT size over %d/%d\n", (QUEST_LOG_SIZE - 8), i_cardPtr - var_r30);
+ printf("INIT size over %d/%d\n", (QUEST_LOG_SIZE - 8), (int)(i_cardPtr - var_r30));
return -1;
}
- printf("INIT size:%d\n", i_cardPtr - var_r30);
+ printf("INIT size:%d\n", (int)(i_cardPtr - var_r30));
return 0;
}
diff --git a/src/d/d_shop_system.cpp b/src/d/d_shop_system.cpp
index 1c955f0076..52941ebd0c 100644
--- a/src/d/d_shop_system.cpp
+++ b/src/d/d_shop_system.cpp
@@ -1459,9 +1459,8 @@ bool dShopSystem_c::searchItemActor() {
for (int i = 0; i < dShopSystem_sellItemMax; i++) {
u32 processId = dShopSystem_itemActor[i]->getProcessID();
mItemCtrl.setItemIndex(i, processId);
- mItemCtrl.setMessageIndex(i, (u16)dShopSystem_itemActor[i]->home.angle.x != 0xFFFF ?
- (u16)dShopSystem_itemActor[i]->home.angle.x :
- -1);
+ int itemFlowId = dShopSystem_itemActor[i]->getFlowNodeNum();
+ mItemCtrl.setMessageIndex(i, itemFlowId);
if (processId + 0x10000 == 0xFFFF) {
onFlag(i);
diff --git a/src/f_pc/f_pc_priority.cpp b/src/f_pc/f_pc_priority.cpp
index cbd62a4053..35f331d687 100644
--- a/src/f_pc/f_pc_priority.cpp
+++ b/src/f_pc/f_pc_priority.cpp
@@ -110,7 +110,7 @@ int fpcPi_Change(process_priority_class* i_procPriority, fpc_ProcID i_layerID, u
int fpcPi_Handler() {
process_priority_class* i_procPriority;
- while (i_procPriority = fpcPi_GetFromQueue()) {
+ while ((i_procPriority = fpcPi_GetFromQueue())) {
base_process_class* process = (base_process_class*)i_procPriority->base.mpTagData;
layer_management_tag_class* pLayerTag = &process->layer_tag;
line_tag* pLineTag = &process->line_tag_;
diff --git a/src/m_Do/m_Do_dvd_thread.cpp b/src/m_Do/m_Do_dvd_thread.cpp
index 0d9eabfad9..550cb9b587 100644
--- a/src/m_Do/m_Do_dvd_thread.cpp
+++ b/src/m_Do/m_Do_dvd_thread.cpp
@@ -155,7 +155,7 @@ static void cb(void* param_0) {
void mDoDvdThd_param_c::mainLoop() {
mDoDvdThd_command_c* command;
while (this->waitForKick() != 0) {
- while (command = this->getFirstCommand()) {
+ while ((command = this->getFirstCommand())) {
this->cut(command);
if (mDoDvdThd::SyncWidthSound) {
JASDvd::getThreadPointer()->sendCmdMsg(cb, &command, 4);
diff --git a/src/m_Do/m_Do_ext.cpp b/src/m_Do/m_Do_ext.cpp
index b0d2a8a821..735c8684e7 100644
--- a/src/m_Do/m_Do_ext.cpp
+++ b/src/m_Do/m_Do_ext.cpp
@@ -71,11 +71,11 @@ static void mDoExt_setJ3DData(Mtx mtx, const J3DTransformInfo* transformInfo, u1
*mtx_p++ *= sp0C.x;
*mtx_p++ *= sp0C.x;
*mtx_p++ *= sp0C.x;
- *mtx_p++;
+ UNUSED(*mtx_p++);
*mtx_p++ *= sp0C.y;
*mtx_p++ *= sp0C.y;
*mtx_p++ *= sp0C.y;
- *mtx_p++;
+ UNUSED(*mtx_p++);
*mtx_p++ *= sp0C.z;
*mtx_p++ *= sp0C.z;
*mtx_p++ *= sp0C.z;