Skip to content

Commit 29ad349

Browse files
committed
Fix utils compilation (except xrLC), tweaked some files
Based on Im-dex/xray-162@00d1502
1 parent c345b9e commit 29ad349

20 files changed

+160
-159
lines changed

src/utils/ETools/Intersect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ bool intersect(const Fobb& box, const Fvector& origin, const Fvector& direction,
9292
kDirection.set(direction.dotproduct(box.m_rotate.i), direction.dotproduct(box.m_rotate.j),
9393
direction.dotproduct(box.m_rotate.k));
9494

95-
float fT0 = 0.0f, fT1 = type_max(float);
95+
float fT0 = 0.0f, fT1 = type_max<float>;
9696
box_axis ax0 = a_none;
9797
box_axis ax1 = a_none;
9898
box_axis ax = a_none;

src/utils/ETools/object_sliding.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void OptimiseVertexCoherencyTriList(WORD* pwList, int iHowManyTris, u32 optimize
2525
DWORD* remap = xr_alloc<DWORD>(iHowManyTris);
2626
WORD max_idx = 0;
2727
for (int k = 0; k < iHowManyTris * 3; k++)
28-
max_idx = _max(max_idx, pwList[k]);
28+
max_idx = std::max(max_idx, pwList[k]);
2929
HRESULT rhr = D3DXOptimizeFaces(pwList, iHowManyTris, max_idx + 1, FALSE, remap);
3030
R_CHK(rhr);
3131
WORD* tmp = xr_alloc<WORD>(iHowManyTris * 3);
@@ -368,7 +368,7 @@ BOOL CalculateSW(Object* object, VIPM_Result* result, u32 optimize_vertex_order)
368368
{
369369
R_ASSERT((j + swr->offset) < result->indices.size());
370370
swr->num_verts =
371-
_max(swr->num_verts, *(result->indices.item(j + swr->offset))); // fignya index ne doljen bit bolshe!!!
371+
std::max(swr->num_verts, *(result->indices.item(j + swr->offset))); // fignya index ne doljen bit bolshe!!!
372372
//. R_ASSERT ( *(result->indices.item(j+swr->offset)) < swr->num_verts );
373373
if (*(result->indices.item(j + swr->offset)) >= swr->num_verts)
374374
{

src/utils/Shader_xrLC.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
struct Shader_xrLC
66
{
7-
public:
87
enum
98
{
109
flCollision = 1 << 0,
@@ -24,7 +23,6 @@ struct Shader_xrLC
2423
u32 bLIGHT_Sharp : 1;
2524
};
2625

27-
public:
2826
char Name[128];
2927
union
3028
{
@@ -94,14 +92,14 @@ class Shader_xrLC_LIB
9492
void Unload() { library.clear(); }
9593
u32 GetID(LPCSTR name) const
9694
{
97-
for (Shader_xrLCVec::const_iterator it = library.begin(); it != library.end(); it++)
95+
for (auto it = library.begin(); it != library.end(); it++)
9896
if (0 == stricmp(name, it->Name))
9997
return u32(it - library.begin());
10098
return u32(-1);
10199
}
102100
Shader_xrLC* Get(LPCSTR name)
103101
{
104-
for (Shader_xrLCIt it = library.begin(); it != library.end(); it++)
102+
for (auto it = library.begin(); it != library.end(); it++)
105103
if (0 == stricmp(name, it->Name))
106104
return &(*it);
107105
return NULL;
@@ -115,7 +113,7 @@ class Shader_xrLC_LIB
115113
}
116114
void Remove(LPCSTR name)
117115
{
118-
for (Shader_xrLCIt it = library.begin(); it != library.end(); it++)
116+
for (auto it = library.begin(); it != library.end(); it++)
119117
if (0 == stricmp(name, it->Name))
120118
{
121119
library.erase(it);

src/utils/ctool/PPMTrain.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <windows.h>
1111
#pragma hdrstop
1212
#include "PPMT_SA.hpp"
13-
#include "xrCore/_types.h"
1413

1514
const int MAX_O = 8;
1615
const int UP_FREQ = 5, INT_BITS = 7, PERIOD_BITS = 7, TOT_BITS = INT_BITS + PERIOD_BITS, INTERVAL = 1 << INT_BITS,

src/utils/ctool/ctool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <algorithm>
1010
#include <string>
1111
#define WIN32_LEAN_AND_MEAN
12+
#define NOMINMAX
1213
#include <windows.h>
1314

1415
using namespace std;

src/utils/xrAI/compiler_cover.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef xr_vector<bool> COVER_NODES;
1919
COVER_NODES g_cover_nodes;
2020

2121
typedef CQuadTree<CCoverPoint> CPointQuadTree;
22-
static CPointQuadTree* g_covers = 0;
22+
static CPointQuadTree* g_covers = nullptr;
2323
typedef xr_vector<CCoverPoint*> COVERS;
2424

2525
// -------------------------------- Ray pick
@@ -51,8 +51,9 @@ IC float getLastRP_Scale(CDB::COLLIDER* DB, RayCache& C)
5151
if (!SH.flags.bLIGHT_CastShadow)
5252
continue;
5353

54-
if (0 == T.pSurface)
55-
T.bHasAlpha = FALSE;
54+
if (T.pSurface == nullptr)
55+
T.bHasAlpha = false;
56+
5657
if (!T.bHasAlpha)
5758
{
5859
// Opaque poly - cache it
@@ -67,7 +68,7 @@ IC float getLastRP_Scale(CDB::COLLIDER* DB, RayCache& C)
6768
B.set(1.0f - rpinf.u - rpinf.v, rpinf.u, rpinf.v);
6869

6970
// calc UV
70-
Fvector2* cuv = F.t;
71+
auto cuv = F.t;
7172
Fvector2 uv;
7273
uv.x = cuv[0].x * B.x + cuv[1].x * B.y + cuv[2].x * B.z;
7374
uv.y = cuv[0].y * B.x + cuv[1].y * B.y + cuv[2].y * B.z;
@@ -225,7 +226,7 @@ class Query
225226

226227
IC void Clear()
227228
{
228-
for (Nearest_it it = q_Clear.begin(); it != q_Clear.end(); it++)
229+
for (auto it = q_Clear.begin(); it != q_Clear.end(); ++it)
229230
q_Marks[*it] = false;
230231
}
231232
};
@@ -264,7 +265,7 @@ class CoverThread : public CThread
264265
Q.Perform(N);
265266

266267
// main cycle: trace rays and compute counts
267-
for (Nearest_it it = Q.q_List.begin(); it != Q.q_List.end(); it++)
268+
for (auto it = Q.q_List.begin(); it != Q.q_List.end(); it++)
268269
{
269270
// calc dir & range
270271
u32 ID = *it;
@@ -406,8 +407,7 @@ bool vertex_in_direction(const u32& start_vertex_id, const u32& target_vertex_id
406407
start = Fvector2().set(start_position.x, start_position.z);
407408
dest.set(finish_position.x, finish_position.z);
408409
dir.sub(dest, start);
409-
Fvector2 temp;
410-
temp = start;
410+
auto temp = start;
411411

412412
float cur_sqr = _sqr(temp.x - dest.x) + _sqr(temp.y - dest.y);
413413
for (;;)
@@ -464,9 +464,9 @@ void compute_non_covers()
464464
VERIFY(!g_covers);
465465
g_covers = new CPointQuadTree(aabb, g_params.fPatchSize * .5f, 8 * 65536, 4 * 65536);
466466

467-
Nodes::iterator B = g_nodes.begin(), I = B;
468-
Nodes::iterator E = g_nodes.end();
469-
COVER_NODES::iterator J = g_cover_nodes.begin();
467+
auto B = g_nodes.begin(), I = B;
468+
auto E = g_nodes.end();
469+
auto J = g_cover_nodes.begin();
470470
for (; I != E; ++I, ++J)
471471
{
472472
if (!*J)
@@ -488,9 +488,9 @@ void compute_non_covers()
488488
typedef xr_vector<COVER_PAIR> COVER_PAIRS;
489489
COVER_PAIRS cover_pairs;
490490

491-
Nodes::iterator B = g_nodes.begin(), I = B;
492-
Nodes::iterator E = g_nodes.end();
493-
COVER_NODES::iterator J = g_cover_nodes.begin();
491+
auto B = g_nodes.begin(), I = B;
492+
auto E = g_nodes.end();
493+
auto J = g_cover_nodes.begin();
494494
for (; I != E; ++I, ++J)
495495
{
496496
if (*J)
@@ -609,7 +609,7 @@ void xrCover(bool pure_covers)
609609
// Smooth
610610
Logger.Status("Smoothing coverage mask...");
611611
mem_Optimize();
612-
Nodes Old = g_nodes;
612+
auto Old = g_nodes;
613613
for (u32 N = 0; N < g_nodes.size(); N++)
614614
{
615615
vertex& Base = Old[N];

src/utils/xrAI/game_graph_builder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ void CGameGraphBuilder::fill_neighbours(const u32& game_vertex_id)
435435
{
436436
level_vertex_id = m_mark_stack.back();
437437
m_mark_stack.resize(m_mark_stack.size() - 1);
438-
CLevelGraph::CVertex* node = level_graph().vertex(level_vertex_id);
438+
auto node = level_graph().vertex(level_vertex_id);
439439
level_graph().begin(level_vertex_id, I, E);
440440
m_marks[level_vertex_id] = true;
441441
for (; I != E; ++I)
@@ -494,12 +494,12 @@ float CGameGraphBuilder::path_distance(const u32& game_vertex_id0, const u32& ga
494494
Msg("Cannot build path from [%f][%f][%f] to [%f][%f][%f]", VPUSH(vertex0.data().level_point()),
495495
VPUSH(vertex1.data().level_point()));
496496
R_ASSERT2(false, "Cannot build path, check AI map");
497-
return (flt_max);
497+
return flt_max;
498498
}
499499

500500
void CGameGraphBuilder::generate_edges(const u32& game_vertex_id)
501501
{
502-
graph_type::CVertex* vertex = graph().vertex(game_vertex_id);
502+
auto vertex = graph().vertex(game_vertex_id);
503503

504504
xr_vector<u32>::const_iterator I = m_current_fringe.begin();
505505
xr_vector<u32>::const_iterator E = m_current_fringe.end();
@@ -554,7 +554,7 @@ void CGameGraphBuilder::create_tripples(const float& start, const float& amount)
554554

555555
const graph_type::CEdge* edge = graph().vertex((*i).vertex_id())->edge((*I).first);
556556

557-
m_tripples.push_back(std::make_pair(_min((*i).weight(), edge ? edge->weight() : (*i).weight()),
557+
m_tripples.push_back(std::make_pair(std::min((*i).weight(), edge ? edge->weight() : (*i).weight()),
558558
std::make_pair((*I).first, (*i).vertex_id())));
559559
}
560560
}

src/utils/xrAI/game_spawn_constructor.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ void CGameSpawnConstructor::load_spawns(LPCSTR name, bool no_separator_check)
8282

8383
// load levels
8484
GameGraph::SLevel level;
85-
LEVEL_INFO_STORAGE::const_iterator I = m_levels.begin();
86-
LEVEL_INFO_STORAGE::const_iterator E = m_levels.end();
85+
auto I = m_levels.begin();
86+
auto E = m_levels.end();
8787
for (; I != E; ++I)
8888
{
8989
level.m_offset = (*I).m_offset;
@@ -103,8 +103,8 @@ void CGameSpawnConstructor::load_spawns(LPCSTR name, bool no_separator_check)
103103

104104
void CGameSpawnConstructor::process_spawns()
105105
{
106-
LEVEL_SPAWN_STORAGE::iterator I = m_level_spawns.begin();
107-
LEVEL_SPAWN_STORAGE::iterator E = m_level_spawns.end();
106+
auto I = m_level_spawns.begin();
107+
auto E = m_level_spawns.end();
108108
for (; I != E; ++I)
109109
#ifdef NO_MULTITHREADING
110110
(*I)->Execute();
@@ -123,14 +123,14 @@ void CGameSpawnConstructor::process_spawns()
123123

124124
void CGameSpawnConstructor::verify_spawns(ALife::_SPAWN_ID spawn_id)
125125
{
126-
xr_vector<ALife::_SPAWN_ID>::iterator J = std::find(m_temp0.begin(), m_temp0.end(), spawn_id);
126+
auto J = std::find(m_temp0.begin(), m_temp0.end(), spawn_id);
127127
R_ASSERT3(J == m_temp0.end(), "RECURSIVE Spawn group chain found in spawn",
128128
m_spawn_graph->vertex(spawn_id)->data()->object().name_replace());
129129
m_temp0.push_back(spawn_id);
130130

131-
SPAWN_GRAPH::CVertex* vertex = m_spawn_graph->vertex(spawn_id);
132-
SPAWN_GRAPH::const_iterator I = vertex->edges().begin();
133-
SPAWN_GRAPH::const_iterator E = vertex->edges().end();
131+
auto vertex = m_spawn_graph->vertex(spawn_id);
132+
auto I = vertex->edges().begin();
133+
auto E = vertex->edges().end();
134134
for (; I != E; ++I)
135135
verify_spawns((*I).vertex_id());
136136
}
@@ -217,7 +217,7 @@ void CGameSpawnConstructor::add_story_object(ALife::_STORY_ID id, CSE_ALifeDynam
217217
if (id == INVALID_STORY_ID)
218218
return;
219219

220-
ALife::STORY_P_PAIR_IT I = m_story_objects.find(id);
220+
auto I = m_story_objects.find(id);
221221
if (I != m_story_objects.end())
222222
{
223223
Msg("Object %s, story id %d", object->name_replace(), object->m_story_id);
@@ -240,10 +240,10 @@ void CGameSpawnConstructor::add_object(CSE_Abstract* object)
240240
void CGameSpawnConstructor::remove_object(CSE_Abstract* object) { spawn_graph().remove_vertex(object->m_tSpawnID); }
241241
void CGameSpawnConstructor::process_actor(LPCSTR start_level_name)
242242
{
243-
m_actor = 0;
243+
m_actor = nullptr;
244244

245-
LEVEL_SPAWN_STORAGE::iterator I = m_level_spawns.begin();
246-
LEVEL_SPAWN_STORAGE::iterator E = m_level_spawns.end();
245+
auto I = m_level_spawns.begin();
246+
auto E = m_level_spawns.end();
247247
for (; I != E; ++I)
248248
{
249249
if (!(*I)->actor())
@@ -263,18 +263,18 @@ void CGameSpawnConstructor::process_actor(LPCSTR start_level_name)
263263
if (!xr_strcmp(*actor_level_name(), start_level_name))
264264
return;
265265

266-
const CGameGraph::SLevel& level = game_graph().header().level(start_level_name);
267-
GameGraph::_GRAPH_ID dest = GameGraph::_GRAPH_ID(-1);
266+
const auto& level = game_graph().header().level(start_level_name);
267+
auto dest = GameGraph::_GRAPH_ID(-1);
268268
GraphEngineSpace::CGameLevelParams evaluator(level.id());
269-
CGraphEngine* graph_engine = new CGraphEngine(game_graph().header().vertex_count());
269+
auto graph_engine = new CGraphEngine(game_graph().header().vertex_count());
270270

271-
bool failed = !graph_engine->search(game_graph(), m_actor->m_tGraphID, GameGraph::_GRAPH_ID(-1), 0, evaluator);
271+
bool failed = !graph_engine->search(game_graph(), m_actor->m_tGraphID, GameGraph::_GRAPH_ID(-1), nullptr, evaluator);
272272
if (failed)
273273
{
274274
Msg("! Cannot build path via game graph from the current level to the level %s!", start_level_name);
275275
float min_dist = flt_max;
276-
Fvector current = game_graph().vertex(m_actor->m_tGraphID)->game_point();
277-
GameGraph::_GRAPH_ID n = game_graph().header().vertex_count();
276+
auto current = game_graph().vertex(m_actor->m_tGraphID)->game_point();
277+
auto n = game_graph().header().vertex_count();
278278
for (GameGraph::_GRAPH_ID i = 0; i < n; ++i)
279279
{
280280
if (game_graph().vertex(i)->level_id() == level.id())
@@ -308,7 +308,7 @@ void clear_temp_folder()
308308
string_path query;
309309
FS.update_path(query, "$app_data_root$", "temp\\*.*");
310310
_finddata_t file;
311-
intptr_t handle = _findfirst(query, &file);
311+
auto handle = _findfirst(query, &file);
312312
if (handle == intptr_t(-1))
313313
return;
314314

src/utils/xrAI/space_restrictor_wrapper.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ IC Fvector construct_position(CLevelGraph& level_graph, u32 level_vertex_id, flo
2020
CSpaceRestrictorWrapper::CSpaceRestrictorWrapper(CSE_ALifeSpaceRestrictor* object)
2121
{
2222
m_object = object;
23-
m_level_graph = 0;
24-
m_graph_engine = 0;
23+
m_level_graph = nullptr;
24+
m_graph_engine = nullptr;
2525
m_xform.setXYZ(object->o_Angle);
2626
m_xform.c.set(object->o_Position);
2727
}
2828

2929
void CSpaceRestrictorWrapper::clear()
3030
{
3131
m_border.clear();
32-
m_level_graph = 0;
33-
m_graph_engine = 0;
32+
m_level_graph = nullptr;
33+
m_graph_engine = nullptr;
3434
}
3535

3636
bool CSpaceRestrictorWrapper::inside(const Fvector& position, float radius) const
@@ -160,12 +160,12 @@ void CSpaceRestrictorWrapper::fill_shape(const CShapeData::shape_def& shape)
160160
for (int i = 0; i < 8; ++i)
161161
{
162162
Q.transform_tiny(temp, points[i]);
163-
start.x = _min(start.x, temp.x);
164-
start.y = _min(start.y, temp.y);
165-
start.z = _min(start.z, temp.z);
166-
dest.x = _max(dest.x, temp.x);
167-
dest.y = _max(dest.y, temp.y);
168-
dest.z = _max(dest.z, temp.z);
163+
start.x = std::min(start.x, temp.x);
164+
start.y = std::min(start.y, temp.y);
165+
start.z = std::min(start.z, temp.z);
166+
dest.x = std::max(dest.x, temp.x);
167+
dest.y = std::max(dest.y, temp.y);
168+
dest.z = std::max(dest.z, temp.z);
169169
}
170170
break;
171171
}
@@ -177,7 +177,7 @@ void CSpaceRestrictorWrapper::fill_shape(const CShapeData::shape_def& shape)
177177

178178
bool CSpaceRestrictorWrapper::inside(u32 level_vertex_id, bool partially_inside, float radius) const
179179
{
180-
const Fvector& position = level_graph().vertex_position(level_vertex_id);
180+
const auto& position = level_graph().vertex_position(level_vertex_id);
181181
float offset = level_graph().header().cell_size() * .5f - EPS_L;
182182
if (partially_inside)
183183
return (inside(construct_position(level_graph(), level_vertex_id, position.x + offset, position.z + offset),
@@ -226,14 +226,14 @@ void CSpaceRestrictorWrapper::build_border()
226226
fill_shape(*I);
227227

228228
{
229-
BORDER::iterator I =
229+
auto I =
230230
std::remove_if(m_border.begin(), m_border.end(), border_merge_predicate(this, m_level_graph));
231231
m_border.erase(I, m_border.end());
232232
}
233233

234234
{
235235
std::sort(m_border.begin(), m_border.end());
236-
BORDER::iterator I = std::unique(m_border.begin(), m_border.end());
236+
auto I = std::unique(m_border.begin(), m_border.end());
237237
m_border.erase(I, m_border.end());
238238
std::sort(m_border.begin(), m_border.end(), sort_by_xz_predicate(m_level_graph));
239239
}
@@ -245,13 +245,13 @@ void CSpaceRestrictorWrapper::verify_connectivity()
245245
{
246246
{
247247
std::sort(m_internal.begin(), m_internal.end());
248-
BORDER::iterator I = std::unique(m_internal.begin(), m_internal.end());
248+
auto I = std::unique(m_internal.begin(), m_internal.end());
249249
m_internal.erase(I, m_internal.end());
250250
}
251251

252252
u32 start_vertex_id = u32(-1);
253-
CLevelGraph::const_vertex_iterator I = level_graph().begin();
254-
CLevelGraph::const_vertex_iterator E = level_graph().end();
253+
auto I = level_graph().begin();
254+
auto E = level_graph().end();
255255
for (; I != E; ++I)
256256
if (!inside(level_graph().vertex(I), true))
257257
{

0 commit comments

Comments
 (0)