Skip to content

Commit f0fada0

Browse files
committed
Revert "Let the compiler assume that VERIFY expressions are true in 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.
1 parent 18a546f commit f0fada0

19 files changed

+8
-119
lines changed

src/xrAICore/Navigation/PatrolPath/patrol_point_inline.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,27 @@ inline bool CPatrolPoint::operator==(const CPatrolPoint& rhs) const
1616

1717
IC const Fvector& CPatrolPoint::position() const
1818
{
19-
#ifdef DEBUG
2019
VERIFY(m_initialized);
21-
#endif
2220
return (m_position);
2321
}
2422

2523
IC const u32& CPatrolPoint::flags() const
2624
{
27-
#ifdef DEBUG
2825
VERIFY(m_initialized);
29-
#endif
3026
return (m_flags);
3127
}
3228

3329
IC const shared_str& CPatrolPoint::name() const
3430
{
35-
#ifdef DEBUG
3631
VERIFY(m_initialized);
37-
#endif
3832
return (m_name);
3933
}
4034

4135
IC const u32& CPatrolPoint::level_vertex_id(
4236
const CLevelGraph* level_graph, const CGameLevelCrossTable* cross, const CGameGraph* game_graph) const
4337
{
44-
#ifdef DEBUG
4538
VERIFY(m_initialized);
39+
#ifdef DEBUG
4640
verify_vertex_id(level_graph, cross, game_graph);
4741
#endif
4842
return (m_level_vertex_id);
@@ -51,8 +45,8 @@ IC const u32& CPatrolPoint::level_vertex_id(
5145
IC const GameGraph::_GRAPH_ID& CPatrolPoint::game_vertex_id(
5246
const CLevelGraph* level_graph, const CGameLevelCrossTable* cross, const CGameGraph* game_graph) const
5347
{
54-
#ifdef DEBUG
5548
VERIFY(m_initialized);
49+
#ifdef DEBUG
5650
verify_vertex_id(level_graph, cross, game_graph);
5751
#endif
5852
return (m_game_vertex_id);

src/xrCore/xrDebug_macros.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@
196196
} while (false)
197197

198198
#define NODEFAULT XR_ASSUME(0)
199-
#define VERIFY(expr) XR_ASSUME(expr)
200-
#define VERIFY2(expr, desc) XR_ASSUME(expr)
201-
#define VERIFY3(expr, desc, arg1) XR_ASSUME(expr)
202-
#define VERIFY4(expr, desc, arg1, arg2) XR_ASSUME(expr)
199+
#define VERIFY(expr) do {} while (false)
200+
#define VERIFY2(expr, desc) do {} while (false)
201+
#define VERIFY3(expr, desc, arg1) do {} while (false)
202+
#define VERIFY4(expr, desc, arg1, arg2) do {} while (false)
203203
#define CHK_DX(expr) expr
204204
#define CHK_GL(expr) expr
205205
#endif // DEBUG

src/xrEngine/xr_collide_form.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ void CCF_Skeleton::BuildState()
130130
Fmatrix ME, T, TW;
131131
const Fmatrix& Mbone = K->LL_GetTransform(I->elem_id);
132132

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

138136
switch (I->type)
139137
{

src/xrEngine/xr_object_list.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ void CObjectList::SingleUpdate(IGameObject* O)
143143

144144
O->UpdateCL();
145145

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

588586
void CObjectList::register_object_to_destroy(IGameObject* object_to_destroy)
589587
{
590-
#ifdef DEBUG
591588
VERIFY(!registered_object_to_destroy(object_to_destroy));
592-
#endif
593-
594589
// Msg("CObjectList::register_object_to_destroy [%x]", object_to_destroy);
595590
destroy_queue.push_back(object_to_destroy);
596591

src/xrGame/Actor_Network.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,7 @@ void CActor::net_Import_Physic(NET_Packet& P)
513513
}
514514
else
515515
{
516-
#ifdef DEBUG
517516
VERIFY(valid_pos(N_A.State.position, ph_boundaries()));
518-
#endif
519517
NET_A.push_back(N_A);
520518
if (NET_A.size() > 5)
521519
NET_A.pop_front();

src/xrGame/Car.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ void CCar::reload(LPCSTR section)
125125

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

src/xrGame/CarCameras.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
bool CCar::HUDView() const { return active_camera->tag == ectFirst; }
1919
void CCar::cam_Update(float dt, float fov)
2020
{
21-
#ifdef DEBUG
2221
VERIFY(!physics_world()->Processing());
23-
#endif
2422
Fvector P, Da;
2523
Da.set(0, 0, 0);
2624
// bool owner = !!Owner();

src/xrGame/DestroyablePhysicsObject.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ void CDestroyablePhysicsObject::Hit(SHit* pHDS)
8989
}
9090
void CDestroyablePhysicsObject::Destroy()
9191
{
92-
#ifdef DEBUG
9392
VERIFY(!physics_world()->Processing());
94-
#endif
95-
9693
const CGameObject* who_object = smart_cast<const CGameObject*>(FatalHit().initiator());
9794
callback(GameObject::eDeath)(lua_game_object(), who_object ? who_object->lua_game_object() : 0);
9895
CPHDestroyable::Destroy(ID(), "physic_destroyable_object");

src/xrGame/GameObject.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1039,10 +1039,8 @@ void CGameObject::setDestroy(bool _destroy)
10391039
Msg("cl setDestroy [%d][%d]", ID(), Device.dwFrame);
10401040
#endif //#ifdef MP_LOGGING
10411041
}
1042-
#ifdef DEBUG
10431042
else
10441043
VERIFY(!g_pGameLevel->Objects.registered_object_to_destroy(this));
1045-
#endif
10461044
}
10471045

10481046
Fvector CGameObject::get_new_local_point_on_mesh(u16& bone_id) const

src/xrGame/Level_Bullet_Manager.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ void CBulletManager::AddBullet(const Fvector& position, const Fvector& direction
185185
// Always called in Primary thread
186186
// Uncomment below if you will change the behaviour
187187
// if (!g_mt_config.test(mtBullets))
188-
#ifdef DEBUG
189188
VERIFY(m_thread_id == std::this_thread::get_id());
190-
#endif
191189

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

210-
#ifdef DEBUG
211208
VERIFY(g_mt_config.test(mtBullets) || m_thread_id == std::this_thread::get_id());
212-
#endif
213209

214210
rq_storage.r_clear();
215211

src/xrGame/Level_network.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ void CLevel::remove_objects()
9898
#endif // DEBUG
9999
if (!GEnv.isDedicatedServer)
100100
{
101-
#ifdef DEBUG
102101
VERIFY(client_spawn_manager().registry().empty());
103-
#endif
104102
client_spawn_manager().clear();
105103
}
106104

src/xrGame/PHDestroyable.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,7 @@ void CPHDestroyable::NotificatePart(CPHDestroyableNotificate* dn)
337337
void CPHDestroyable::NotificateDestroy(CPHDestroyableNotificate* dn)
338338
{
339339
VERIFY(m_depended_objects);
340-
#ifdef DEBUG
341340
VERIFY(!physics_world()->Processing());
342-
#endif
343341
m_depended_objects--;
344342
PhysicallyRemovePart(dn);
345343
m_notificate_objects.push_back(dn);

src/xrGame/attachable_item.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,13 @@ bool CAttachableItem::can_be_attached() const
114114

115115
void CAttachableItem::afterAttach()
116116
{
117-
#ifdef DEBUG
118117
VERIFY(m_valid);
119-
#endif
120118
object().processing_activate();
121119
}
122120

123121
void CAttachableItem::afterDetach()
124122
{
125-
#ifdef DEBUG
126123
VERIFY(m_valid);
127-
#endif
128124
object().processing_deactivate();
129125
}
130126

src/xrGame/attachable_item_inline.h

-8
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,25 @@ IC CAttachableItem::CAttachableItem()
2222

2323
IC shared_str CAttachableItem::bone_name() const
2424
{
25-
#ifdef DEBUG
2625
VERIFY(m_valid);
27-
#endif
2826
return (m_bone_name);
2927
}
3028

3129
IC const Fmatrix& CAttachableItem::offset() const
3230
{
33-
#ifdef DEBUG
3431
VERIFY(m_valid);
35-
#endif
3632
return (m_offset);
3733
}
3834

3935
IC u16 CAttachableItem::bone_id() const
4036
{
41-
#ifdef DEBUG
4237
VERIFY(m_valid);
43-
#endif
4438
return (m_bone_id);
4539
}
4640

4741
IC void CAttachableItem::set_bone_id(u16 bone_id)
4842
{
49-
#ifdef DEBUG
5043
VERIFY(m_valid);
51-
#endif
5244
m_bone_id = bone_id;
5345
}
5446

src/xrGame/ik/IKLimb.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,8 @@ void CIKLimb::SetNewGoal(const SIKCollideData& cld, SCalculateData& cd)
494494
cd.state.foot_step =
495495
m_foot.GetFootStepMatrix(cd.state.goal, cd, cld, true, !!ik_allign_free_foot) && cd.state.foot_step;
496496

497-
#ifdef DEBUG
498497
VERIFY2(fsimilar(1.f, DET(cd.state.goal.get()), det_tolerance),
499498
dump_string("cd.state.goal", cd.state.goal.get()).c_str());
500-
#endif
501499

502500
cd.state.blend_to = cd.state.goal;
503501
sv_state.get_calculate_state(cd.state);
@@ -673,36 +671,27 @@ void CIKLimb::Blending(SCalculateData& cd)
673671
{
674672
blend_speed_accel(cd);
675673
ik_goal_matrix m;
676-
677-
#ifdef DEBUG
678674
VERIFY(fsimilar(1.f, DET(sv_state.goal(m).get()), det_tolerance));
679675
VERIFY(fsimilar(1.f, DET(sv_state.blend_to(m).get()), det_tolerance));
680-
#endif
681676

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

685-
#ifdef DEBUG
686680
VERIFY(fsimilar(1.f, DET(diff), det_tolerance));
687-
#endif
688681

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

693-
#ifdef DEBUG
694686
VERIFY(fsimilar(1.f, DET(blend), det_tolerance));
695687
VERIFY(fsimilar(1.f, DET(cd.state.blend_to.get()), det_tolerance));
696-
#endif
697688

698689
Fmatrix fm = Fmatrix().mul_43(cd.state.blend_to.get(), blend);
699690
if (ik_collide_blend)
700691
m_foot.GetFootStepMatrix(cd.state.goal, fm, collide_data, true, true);
701692
else
702693
cd.state.goal.set(fm, cd.state.blend_to.collide_state());
703-
#ifdef DEBUG
704694
VERIFY(fsimilar(DET(cd.state.goal.get()), 1.f, det_tolerance));
705-
#endif
706695
}
707696
else
708697
{

src/xrGame/moving_objects.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ void moving_objects::on_level_load()
2323

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

29+
#ifdef DEBUG
3030
m_objects.insert(moving_object);
3131
#endif // DEBUG
3232

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

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

42+
#ifdef DEBUG
4343
m_objects.erase(m_objects.find(moving_object));
4444
#endif // DEBUG
4545

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

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

5755
#pragma todo("this place can be optimized in case of slowdowns")
5856
VERIFY(m_tree);

0 commit comments

Comments
 (0)