diff --git a/include/SSystem/SComponent/c_lib.h b/include/SSystem/SComponent/c_lib.h index 8f6bb36f2..20f531cd1 100644 --- a/include/SSystem/SComponent/c_lib.h +++ b/include/SSystem/SComponent/c_lib.h @@ -58,22 +58,7 @@ inline void cLib_setBit(T& value, T bit) { template inline T cLib_minMaxLimit(T val, T min, T max) { - T ret; - T var_r30; - - if (val < min) { - ret = min; - } else { - if (val > max) { - var_r30 = max; - } else { - var_r30 = val; - } - - ret = var_r30; - } - - return (T)ret; + return (T)((T)val < (T)min ? (T)min : ((T)val > (T)max ? (T)max : (T)val)); } template diff --git a/src/d/actor/d_a_bomb2.cpp b/src/d/actor/d_a_bomb2.cpp index 023e02257..b6725ed96 100644 --- a/src/d/actor/d_a_bomb2.cpp +++ b/src/d/actor/d_a_bomb2.cpp @@ -1293,10 +1293,10 @@ namespace daBomb2 { }; if(fopAcM_GetModel(this) == 0) { - f32 frame = mBck0.getFrame(); - frame = mult[cLib_minMaxLimit(mBck0.getEndFrame() - frame, 0, 9)] * 25.0f; + int framesLeft = mBck0.getEndFrame() - mBck0.getFrame(); + f32 scale = mult[cLib_minMaxLimit(framesLeft, 0, 9)] * 25.0f; - dComIfGd_setSimpleShadow2(¤t.pos, mAcch.GetGroundH(), frame, mAcch.m_gnd, 0, 1.0f, dDlst_shadowControl_c::getSimpleTex()); + dComIfGd_setSimpleShadow2(¤t.pos, mAcch.GetGroundH(), scale, mAcch.m_gnd, 0, 1.0f, dDlst_shadowControl_c::getSimpleTex()); } } diff --git a/src/d/actor/d_a_npc_bs1.cpp b/src/d/actor/d_a_npc_bs1.cpp index 44cc9e30d..7f83e054f 100644 --- a/src/d/actor/d_a_npc_bs1.cpp +++ b/src/d/actor/d_a_npc_bs1.cpp @@ -1596,7 +1596,7 @@ BOOL daNpc_Bs1_c::CreateInit() { mShopIndex = 6; } - mShopIndex = cLib_minMaxLimit(mShopIndex, 0, 7); + mShopIndex = cLib_minMaxLimit(mShopIndex, 0, 7); mShopCamAction.setCamDataIdx(mShopIndex); mShopItems.setItemDataIdx(mShopIndex); diff --git a/src/d/actor/d_a_obj_roten.cpp b/src/d/actor/d_a_obj_roten.cpp index ab3656b55..7a1f0c452 100644 --- a/src/d/actor/d_a_obj_roten.cpp +++ b/src/d/actor/d_a_obj_roten.cpp @@ -100,7 +100,7 @@ s32 daObj_Roten_c::_create() { fopAcM_SetupActor(this, daObj_Roten_c); mType = fopAcM_GetParam(this) >> 0x18; - mType = cLib_minMaxLimit((int)mType, 0, 2); // fakematch? debug says this is templated to u8 + mType = cLib_minMaxLimit(mType, 0, 2); if(Roten_create_check(mType)) { field_0x2D1 = 0;