Skip to content

Commit

Permalink
Revert "Let the compiler assume that VERIFY expressions are true in…
Browse files Browse the repository at this point in the history
… release builds (#1492)"

Fixes #1759, reverts c76215a and #1492.

Using XR_ASSUME makes the compiler to refuse some checks where they are crucial.
We can't always assume and VERIFY wasn't made for that.
  • Loading branch information
Xottab-DUTY committed Jan 2, 2025
1 parent 18a546f commit ec58eaa
Show file tree
Hide file tree
Showing 21 changed files with 10 additions and 121 deletions.
10 changes: 2 additions & 8 deletions src/xrAICore/Navigation/PatrolPath/patrol_point_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,27 @@ inline bool CPatrolPoint::operator==(const CPatrolPoint& rhs) const

IC const Fvector& CPatrolPoint::position() const
{
#ifdef DEBUG
VERIFY(m_initialized);
#endif
return (m_position);
}

IC const u32& CPatrolPoint::flags() const
{
#ifdef DEBUG
VERIFY(m_initialized);
#endif
return (m_flags);
}

IC const shared_str& CPatrolPoint::name() const
{
#ifdef DEBUG
VERIFY(m_initialized);
#endif
return (m_name);
}

IC const u32& CPatrolPoint::level_vertex_id(
const CLevelGraph* level_graph, const CGameLevelCrossTable* cross, const CGameGraph* game_graph) const
{
#ifdef DEBUG
VERIFY(m_initialized);
#ifdef DEBUG
verify_vertex_id(level_graph, cross, game_graph);
#endif
return (m_level_vertex_id);
Expand All @@ -51,8 +45,8 @@ IC const u32& CPatrolPoint::level_vertex_id(
IC const GameGraph::_GRAPH_ID& CPatrolPoint::game_vertex_id(
const CLevelGraph* level_graph, const CGameLevelCrossTable* cross, const CGameGraph* game_graph) const
{
#ifdef DEBUG
VERIFY(m_initialized);
#ifdef DEBUG
verify_vertex_id(level_graph, cross, game_graph);
#endif
return (m_game_vertex_id);
Expand Down
8 changes: 4 additions & 4 deletions src/xrCore/xrDebug_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@
} while (false)

#define NODEFAULT XR_ASSUME(0)
#define VERIFY(expr) XR_ASSUME(expr)
#define VERIFY2(expr, desc) XR_ASSUME(expr)
#define VERIFY3(expr, desc, arg1) XR_ASSUME(expr)
#define VERIFY4(expr, desc, arg1, arg2) XR_ASSUME(expr)
#define VERIFY(expr) do {} while (false)
#define VERIFY2(expr, desc) do {} while (false)
#define VERIFY3(expr, desc, arg1) do {} while (false)
#define VERIFY4(expr, desc, arg1, arg2) do {} while (false)
#define CHK_DX(expr) expr
#define CHK_GL(expr) expr
#endif // DEBUG
Expand Down
2 changes: 0 additions & 2 deletions src/xrEngine/xr_collide_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,8 @@ void CCF_Skeleton::BuildState()
Fmatrix ME, T, TW;
const Fmatrix& Mbone = K->LL_GetTransform(I->elem_id);

#ifdef DEBUG
VERIFY2(DET(Mbone) > EPS,
(make_string("0 scale bone matrix, %d \n", I->elem_id) + dbg_object_full_dump_string(owner)).c_str());
#endif

switch (I->type)
{
Expand Down
5 changes: 0 additions & 5 deletions src/xrEngine/xr_object_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ void CObjectList::SingleUpdate(IGameObject* O)

O->UpdateCL();

#ifdef DEBUG
VERIFY3(O->GetDbgUpdateFrame() == Device.dwFrame, "Broken sequence of calls to 'UpdateCL'", *O->cName());
#endif
#if 0 // ndef DEBUG
__try
{
Expand Down Expand Up @@ -587,10 +585,7 @@ bool CObjectList::dump_all_objects()

void CObjectList::register_object_to_destroy(IGameObject* object_to_destroy)
{
#ifdef DEBUG
VERIFY(!registered_object_to_destroy(object_to_destroy));
#endif

// Msg("CObjectList::register_object_to_destroy [%x]", object_to_destroy);
destroy_queue.push_back(object_to_destroy);

Expand Down
2 changes: 0 additions & 2 deletions src/xrGame/Actor_Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,7 @@ void CActor::net_Import_Physic(NET_Packet& P)
}
else
{
#ifdef DEBUG
VERIFY(valid_pos(N_A.State.position, ph_boundaries()));
#endif
NET_A.push_back(N_A);
if (NET_A.size() > 5)
NET_A.pop_front();
Expand Down
2 changes: 0 additions & 2 deletions src/xrGame/Car.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ void CCar::reload(LPCSTR section)

void CCar::cb_Steer(CBoneInstance* B)
{
#ifdef DEBUG
VERIFY2(fsimilar(DET(B->mTransform), 1.f, DET_CHECK_EPS), "Bones receive returns 0 matrix");
#endif
CCar* C = static_cast<CCar*>(B->callback_param());
Fmatrix m;

Expand Down
2 changes: 0 additions & 2 deletions src/xrGame/CarCameras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
bool CCar::HUDView() const { return active_camera->tag == ectFirst; }
void CCar::cam_Update(float dt, float fov)
{
#ifdef DEBUG
VERIFY(!physics_world()->Processing());
#endif
Fvector P, Da;
Da.set(0, 0, 0);
// bool owner = !!Owner();
Expand Down
3 changes: 0 additions & 3 deletions src/xrGame/DestroyablePhysicsObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ void CDestroyablePhysicsObject::Hit(SHit* pHDS)
}
void CDestroyablePhysicsObject::Destroy()
{
#ifdef DEBUG
VERIFY(!physics_world()->Processing());
#endif

const CGameObject* who_object = smart_cast<const CGameObject*>(FatalHit().initiator());
callback(GameObject::eDeath)(lua_game_object(), who_object ? who_object->lua_game_object() : 0);
CPHDestroyable::Destroy(ID(), "physic_destroyable_object");
Expand Down
2 changes: 0 additions & 2 deletions src/xrGame/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,10 +1039,8 @@ void CGameObject::setDestroy(bool _destroy)
Msg("cl setDestroy [%d][%d]", ID(), Device.dwFrame);
#endif //#ifdef MP_LOGGING
}
#ifdef DEBUG
else
VERIFY(!g_pGameLevel->Objects.registered_object_to_destroy(this));
#endif
}

Fvector CGameObject::get_new_local_point_on_mesh(u16& bone_id) const
Expand Down
4 changes: 0 additions & 4 deletions src/xrGame/Level_Bullet_Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,7 @@ void CBulletManager::AddBullet(const Fvector& position, const Fvector& direction
// Always called in Primary thread
// Uncomment below if you will change the behaviour
// if (!g_mt_config.test(mtBullets))
#ifdef DEBUG
VERIFY(m_thread_id == std::this_thread::get_id());
#endif

VERIFY(u16(-1) != cartridge.bullet_material_idx);
// u32 CurID = Level().CurrentControlEntity()->ID();
Expand All @@ -207,9 +205,7 @@ void CBulletManager::UpdateWorkload()
{
ZoneScoped;

#ifdef DEBUG
VERIFY(g_mt_config.test(mtBullets) || m_thread_id == std::this_thread::get_id());
#endif

rq_storage.r_clear();

Expand Down
2 changes: 0 additions & 2 deletions src/xrGame/Level_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ void CLevel::remove_objects()
#endif // DEBUG
if (!GEnv.isDedicatedServer)
{
#ifdef DEBUG
VERIFY(client_spawn_manager().registry().empty());
#endif
client_spawn_manager().clear();
}

Expand Down
2 changes: 0 additions & 2 deletions src/xrGame/PHDestroyable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,7 @@ void CPHDestroyable::NotificatePart(CPHDestroyableNotificate* dn)
void CPHDestroyable::NotificateDestroy(CPHDestroyableNotificate* dn)
{
VERIFY(m_depended_objects);
#ifdef DEBUG
VERIFY(!physics_world()->Processing());
#endif
m_depended_objects--;
PhysicallyRemovePart(dn);
m_notificate_objects.push_back(dn);
Expand Down
4 changes: 0 additions & 4 deletions src/xrGame/attachable_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,13 @@ bool CAttachableItem::can_be_attached() const

void CAttachableItem::afterAttach()
{
#ifdef DEBUG
VERIFY(m_valid);
#endif
object().processing_activate();
}

void CAttachableItem::afterDetach()
{
#ifdef DEBUG
VERIFY(m_valid);
#endif
object().processing_deactivate();
}

Expand Down
8 changes: 0 additions & 8 deletions src/xrGame/attachable_item_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,25 @@ IC CAttachableItem::CAttachableItem()

IC shared_str CAttachableItem::bone_name() const
{
#ifdef DEBUG
VERIFY(m_valid);
#endif
return (m_bone_name);
}

IC const Fmatrix& CAttachableItem::offset() const
{
#ifdef DEBUG
VERIFY(m_valid);
#endif
return (m_offset);
}

IC u16 CAttachableItem::bone_id() const
{
#ifdef DEBUG
VERIFY(m_valid);
#endif
return (m_bone_id);
}

IC void CAttachableItem::set_bone_id(u16 bone_id)
{
#ifdef DEBUG
VERIFY(m_valid);
#endif
m_bone_id = bone_id;
}

Expand Down
11 changes: 0 additions & 11 deletions src/xrGame/ik/IKLimb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,8 @@ void CIKLimb::SetNewGoal(const SIKCollideData& cld, SCalculateData& cd)
cd.state.foot_step =
m_foot.GetFootStepMatrix(cd.state.goal, cd, cld, true, !!ik_allign_free_foot) && cd.state.foot_step;

#ifdef DEBUG
VERIFY2(fsimilar(1.f, DET(cd.state.goal.get()), det_tolerance),
dump_string("cd.state.goal", cd.state.goal.get()).c_str());
#endif

cd.state.blend_to = cd.state.goal;
sv_state.get_calculate_state(cd.state);
Expand Down Expand Up @@ -673,36 +671,27 @@ void CIKLimb::Blending(SCalculateData& cd)
{
blend_speed_accel(cd);
ik_goal_matrix m;

#ifdef DEBUG
VERIFY(fsimilar(1.f, DET(sv_state.goal(m).get()), det_tolerance));
VERIFY(fsimilar(1.f, DET(sv_state.blend_to(m).get()), det_tolerance));
#endif

Fmatrix diff;
diff.mul_43(Fmatrix().invert(sv_state.blend_to(m).get()), Fmatrix(sv_state.goal(m).get()));

#ifdef DEBUG
VERIFY(fsimilar(1.f, DET(diff), det_tolerance));
#endif

Fmatrix blend = Fidentity; // cd.state.blend_to;
cd.state.blending =
!clamp_change(blend, diff, cd.l, cd.a, linear_tolerance, angualar_tolerance); // 0.01f //0.005f

#ifdef DEBUG
VERIFY(fsimilar(1.f, DET(blend), det_tolerance));
VERIFY(fsimilar(1.f, DET(cd.state.blend_to.get()), det_tolerance));
#endif

Fmatrix fm = Fmatrix().mul_43(cd.state.blend_to.get(), blend);
if (ik_collide_blend)
m_foot.GetFootStepMatrix(cd.state.goal, fm, collide_data, true, true);
else
cd.state.goal.set(fm, cd.state.blend_to.collide_state());
#ifdef DEBUG
VERIFY(fsimilar(DET(cd.state.goal.get()), 1.f, det_tolerance));
#endif
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/level_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ IC static void CLevel_Export(lua_State* luaState)
def("ray_pick", &ray_pick)
];

if (ClearSkyMode)
if (true || ClearSkyMode)
{
module(luaState, "level")
[
Expand Down
6 changes: 2 additions & 4 deletions src/xrGame/moving_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ void moving_objects::on_level_load()

void moving_objects::register_object(moving_object* moving_object)
{
#ifdef DEBUG
VERIFY2(m_objects.find(moving_object) == m_objects.end(),
make_string("moving object %s is registers twice", *moving_object->id()));

#ifdef DEBUG
m_objects.insert(moving_object);
#endif // DEBUG

Expand All @@ -36,10 +36,10 @@ void moving_objects::register_object(moving_object* moving_object)

void moving_objects::unregister_object(moving_object* moving_object)
{
#ifdef DEBUG
VERIFY2(m_objects.find(moving_object) != m_objects.end(),
make_string("moving object %s is not yet registered or unregisters twice", *moving_object->id()));

#ifdef DEBUG
m_objects.erase(m_objects.find(moving_object));
#endif // DEBUG

Expand All @@ -49,10 +49,8 @@ void moving_objects::unregister_object(moving_object* moving_object)

void moving_objects::on_object_move(moving_object* moving_object)
{
#ifdef DEBUG
VERIFY2(m_objects.find(moving_object) != m_objects.end(),
make_string("moving object %s is not yet registered", *moving_object->id()));
#endif

#pragma todo("this place can be optimized in case of slowdowns")
VERIFY(m_tree);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/script_binder_object_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SCRIPT_EXPORT(CScriptBinderObject, (),
module(luaState)
[
class_<CScriptBinderObject, no_bases, default_holder, CScriptBinderObjectWrapper>("object_binder")
.def_readonly("object", &CScriptBinderObject::m_object)
.def_readwrite("object", &CScriptBinderObject::m_object)
.def(constructor<CScriptGameObject*>())
.def("reinit", &CScriptBinderObject::reinit, &CScriptBinderObjectWrapper::reinit_static)
.def("reload", &CScriptBinderObject::reload, &CScriptBinderObjectWrapper::reload_static)
Expand Down
Loading

0 comments on commit ec58eaa

Please sign in to comment.