Skip to content

Commit

Permalink
Fix utils compilation (except xrLC), tweaked some files
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Aug 4, 2017
1 parent c345b9e commit 29ad349
Show file tree
Hide file tree
Showing 20 changed files with 160 additions and 159 deletions.
2 changes: 1 addition & 1 deletion src/utils/ETools/Intersect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bool intersect(const Fobb& box, const Fvector& origin, const Fvector& direction,
kDirection.set(direction.dotproduct(box.m_rotate.i), direction.dotproduct(box.m_rotate.j),
direction.dotproduct(box.m_rotate.k));

float fT0 = 0.0f, fT1 = type_max(float);
float fT0 = 0.0f, fT1 = type_max<float>;
box_axis ax0 = a_none;
box_axis ax1 = a_none;
box_axis ax = a_none;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/ETools/object_sliding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void OptimiseVertexCoherencyTriList(WORD* pwList, int iHowManyTris, u32 optimize
DWORD* remap = xr_alloc<DWORD>(iHowManyTris);
WORD max_idx = 0;
for (int k = 0; k < iHowManyTris * 3; k++)
max_idx = _max(max_idx, pwList[k]);
max_idx = std::max(max_idx, pwList[k]);
HRESULT rhr = D3DXOptimizeFaces(pwList, iHowManyTris, max_idx + 1, FALSE, remap);
R_CHK(rhr);
WORD* tmp = xr_alloc<WORD>(iHowManyTris * 3);
Expand Down Expand Up @@ -368,7 +368,7 @@ BOOL CalculateSW(Object* object, VIPM_Result* result, u32 optimize_vertex_order)
{
R_ASSERT((j + swr->offset) < result->indices.size());
swr->num_verts =
_max(swr->num_verts, *(result->indices.item(j + swr->offset))); // fignya index ne doljen bit bolshe!!!
std::max(swr->num_verts, *(result->indices.item(j + swr->offset))); // fignya index ne doljen bit bolshe!!!
//. R_ASSERT ( *(result->indices.item(j+swr->offset)) < swr->num_verts );
if (*(result->indices.item(j + swr->offset)) >= swr->num_verts)
{
Expand Down
8 changes: 3 additions & 5 deletions src/utils/Shader_xrLC.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

struct Shader_xrLC
{
public:
enum
{
flCollision = 1 << 0,
Expand All @@ -24,7 +23,6 @@ struct Shader_xrLC
u32 bLIGHT_Sharp : 1;
};

public:
char Name[128];
union
{
Expand Down Expand Up @@ -94,14 +92,14 @@ class Shader_xrLC_LIB
void Unload() { library.clear(); }
u32 GetID(LPCSTR name) const
{
for (Shader_xrLCVec::const_iterator it = library.begin(); it != library.end(); it++)
for (auto it = library.begin(); it != library.end(); it++)
if (0 == stricmp(name, it->Name))
return u32(it - library.begin());
return u32(-1);
}
Shader_xrLC* Get(LPCSTR name)
{
for (Shader_xrLCIt it = library.begin(); it != library.end(); it++)
for (auto it = library.begin(); it != library.end(); it++)
if (0 == stricmp(name, it->Name))
return &(*it);
return NULL;
Expand All @@ -115,7 +113,7 @@ class Shader_xrLC_LIB
}
void Remove(LPCSTR name)
{
for (Shader_xrLCIt it = library.begin(); it != library.end(); it++)
for (auto it = library.begin(); it != library.end(); it++)
if (0 == stricmp(name, it->Name))
{
library.erase(it);
Expand Down
1 change: 0 additions & 1 deletion src/utils/ctool/PPMTrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <windows.h>
#pragma hdrstop
#include "PPMT_SA.hpp"
#include "xrCore/_types.h"

const int MAX_O = 8;
const int UP_FREQ = 5, INT_BITS = 7, PERIOD_BITS = 7, TOT_BITS = INT_BITS + PERIOD_BITS, INTERVAL = 1 << INT_BITS,
Expand Down
1 change: 1 addition & 0 deletions src/utils/ctool/ctool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <algorithm>
#include <string>
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>

using namespace std;
Expand Down
30 changes: 15 additions & 15 deletions src/utils/xrAI/compiler_cover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef xr_vector<bool> COVER_NODES;
COVER_NODES g_cover_nodes;

typedef CQuadTree<CCoverPoint> CPointQuadTree;
static CPointQuadTree* g_covers = 0;
static CPointQuadTree* g_covers = nullptr;
typedef xr_vector<CCoverPoint*> COVERS;

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

if (0 == T.pSurface)
T.bHasAlpha = FALSE;
if (T.pSurface == nullptr)
T.bHasAlpha = false;

if (!T.bHasAlpha)
{
// Opaque poly - cache it
Expand All @@ -67,7 +68,7 @@ IC float getLastRP_Scale(CDB::COLLIDER* DB, RayCache& C)
B.set(1.0f - rpinf.u - rpinf.v, rpinf.u, rpinf.v);

// calc UV
Fvector2* cuv = F.t;
auto cuv = F.t;
Fvector2 uv;
uv.x = cuv[0].x * B.x + cuv[1].x * B.y + cuv[2].x * B.z;
uv.y = cuv[0].y * B.x + cuv[1].y * B.y + cuv[2].y * B.z;
Expand Down Expand Up @@ -225,7 +226,7 @@ class Query

IC void Clear()
{
for (Nearest_it it = q_Clear.begin(); it != q_Clear.end(); it++)
for (auto it = q_Clear.begin(); it != q_Clear.end(); ++it)
q_Marks[*it] = false;
}
};
Expand Down Expand Up @@ -264,7 +265,7 @@ class CoverThread : public CThread
Q.Perform(N);

// main cycle: trace rays and compute counts
for (Nearest_it it = Q.q_List.begin(); it != Q.q_List.end(); it++)
for (auto it = Q.q_List.begin(); it != Q.q_List.end(); it++)
{
// calc dir & range
u32 ID = *it;
Expand Down Expand Up @@ -406,8 +407,7 @@ bool vertex_in_direction(const u32& start_vertex_id, const u32& target_vertex_id
start = Fvector2().set(start_position.x, start_position.z);
dest.set(finish_position.x, finish_position.z);
dir.sub(dest, start);
Fvector2 temp;
temp = start;
auto temp = start;

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

Nodes::iterator B = g_nodes.begin(), I = B;
Nodes::iterator E = g_nodes.end();
COVER_NODES::iterator J = g_cover_nodes.begin();
auto B = g_nodes.begin(), I = B;
auto E = g_nodes.end();
auto J = g_cover_nodes.begin();
for (; I != E; ++I, ++J)
{
if (!*J)
Expand All @@ -488,9 +488,9 @@ void compute_non_covers()
typedef xr_vector<COVER_PAIR> COVER_PAIRS;
COVER_PAIRS cover_pairs;

Nodes::iterator B = g_nodes.begin(), I = B;
Nodes::iterator E = g_nodes.end();
COVER_NODES::iterator J = g_cover_nodes.begin();
auto B = g_nodes.begin(), I = B;
auto E = g_nodes.end();
auto J = g_cover_nodes.begin();
for (; I != E; ++I, ++J)
{
if (*J)
Expand Down Expand Up @@ -609,7 +609,7 @@ void xrCover(bool pure_covers)
// Smooth
Logger.Status("Smoothing coverage mask...");
mem_Optimize();
Nodes Old = g_nodes;
auto Old = g_nodes;
for (u32 N = 0; N < g_nodes.size(); N++)
{
vertex& Base = Old[N];
Expand Down
8 changes: 4 additions & 4 deletions src/utils/xrAI/game_graph_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void CGameGraphBuilder::fill_neighbours(const u32& game_vertex_id)
{
level_vertex_id = m_mark_stack.back();
m_mark_stack.resize(m_mark_stack.size() - 1);
CLevelGraph::CVertex* node = level_graph().vertex(level_vertex_id);
auto node = level_graph().vertex(level_vertex_id);
level_graph().begin(level_vertex_id, I, E);
m_marks[level_vertex_id] = true;
for (; I != E; ++I)
Expand Down Expand Up @@ -494,12 +494,12 @@ float CGameGraphBuilder::path_distance(const u32& game_vertex_id0, const u32& ga
Msg("Cannot build path from [%f][%f][%f] to [%f][%f][%f]", VPUSH(vertex0.data().level_point()),
VPUSH(vertex1.data().level_point()));
R_ASSERT2(false, "Cannot build path, check AI map");
return (flt_max);
return flt_max;
}

void CGameGraphBuilder::generate_edges(const u32& game_vertex_id)
{
graph_type::CVertex* vertex = graph().vertex(game_vertex_id);
auto vertex = graph().vertex(game_vertex_id);

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

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

m_tripples.push_back(std::make_pair(_min((*i).weight(), edge ? edge->weight() : (*i).weight()),
m_tripples.push_back(std::make_pair(std::min((*i).weight(), edge ? edge->weight() : (*i).weight()),
std::make_pair((*I).first, (*i).vertex_id())));
}
}
Expand Down
38 changes: 19 additions & 19 deletions src/utils/xrAI/game_spawn_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ void CGameSpawnConstructor::load_spawns(LPCSTR name, bool no_separator_check)

// load levels
GameGraph::SLevel level;
LEVEL_INFO_STORAGE::const_iterator I = m_levels.begin();
LEVEL_INFO_STORAGE::const_iterator E = m_levels.end();
auto I = m_levels.begin();
auto E = m_levels.end();
for (; I != E; ++I)
{
level.m_offset = (*I).m_offset;
Expand All @@ -103,8 +103,8 @@ void CGameSpawnConstructor::load_spawns(LPCSTR name, bool no_separator_check)

void CGameSpawnConstructor::process_spawns()
{
LEVEL_SPAWN_STORAGE::iterator I = m_level_spawns.begin();
LEVEL_SPAWN_STORAGE::iterator E = m_level_spawns.end();
auto I = m_level_spawns.begin();
auto E = m_level_spawns.end();
for (; I != E; ++I)
#ifdef NO_MULTITHREADING
(*I)->Execute();
Expand All @@ -123,14 +123,14 @@ void CGameSpawnConstructor::process_spawns()

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

SPAWN_GRAPH::CVertex* vertex = m_spawn_graph->vertex(spawn_id);
SPAWN_GRAPH::const_iterator I = vertex->edges().begin();
SPAWN_GRAPH::const_iterator E = vertex->edges().end();
auto vertex = m_spawn_graph->vertex(spawn_id);
auto I = vertex->edges().begin();
auto E = vertex->edges().end();
for (; I != E; ++I)
verify_spawns((*I).vertex_id());
}
Expand Down Expand Up @@ -217,7 +217,7 @@ void CGameSpawnConstructor::add_story_object(ALife::_STORY_ID id, CSE_ALifeDynam
if (id == INVALID_STORY_ID)
return;

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

LEVEL_SPAWN_STORAGE::iterator I = m_level_spawns.begin();
LEVEL_SPAWN_STORAGE::iterator E = m_level_spawns.end();
auto I = m_level_spawns.begin();
auto E = m_level_spawns.end();
for (; I != E; ++I)
{
if (!(*I)->actor())
Expand All @@ -263,18 +263,18 @@ void CGameSpawnConstructor::process_actor(LPCSTR start_level_name)
if (!xr_strcmp(*actor_level_name(), start_level_name))
return;

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

bool failed = !graph_engine->search(game_graph(), m_actor->m_tGraphID, GameGraph::_GRAPH_ID(-1), 0, evaluator);
bool failed = !graph_engine->search(game_graph(), m_actor->m_tGraphID, GameGraph::_GRAPH_ID(-1), nullptr, evaluator);
if (failed)
{
Msg("! Cannot build path via game graph from the current level to the level %s!", start_level_name);
float min_dist = flt_max;
Fvector current = game_graph().vertex(m_actor->m_tGraphID)->game_point();
GameGraph::_GRAPH_ID n = game_graph().header().vertex_count();
auto current = game_graph().vertex(m_actor->m_tGraphID)->game_point();
auto n = game_graph().header().vertex_count();
for (GameGraph::_GRAPH_ID i = 0; i < n; ++i)
{
if (game_graph().vertex(i)->level_id() == level.id())
Expand Down Expand Up @@ -308,7 +308,7 @@ void clear_temp_folder()
string_path query;
FS.update_path(query, "$app_data_root$", "temp\\*.*");
_finddata_t file;
intptr_t handle = _findfirst(query, &file);
auto handle = _findfirst(query, &file);
if (handle == intptr_t(-1))
return;

Expand Down
32 changes: 16 additions & 16 deletions src/utils/xrAI/space_restrictor_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ IC Fvector construct_position(CLevelGraph& level_graph, u32 level_vertex_id, flo
CSpaceRestrictorWrapper::CSpaceRestrictorWrapper(CSE_ALifeSpaceRestrictor* object)
{
m_object = object;
m_level_graph = 0;
m_graph_engine = 0;
m_level_graph = nullptr;
m_graph_engine = nullptr;
m_xform.setXYZ(object->o_Angle);
m_xform.c.set(object->o_Position);
}

void CSpaceRestrictorWrapper::clear()
{
m_border.clear();
m_level_graph = 0;
m_graph_engine = 0;
m_level_graph = nullptr;
m_graph_engine = nullptr;
}

bool CSpaceRestrictorWrapper::inside(const Fvector& position, float radius) const
Expand Down Expand Up @@ -160,12 +160,12 @@ void CSpaceRestrictorWrapper::fill_shape(const CShapeData::shape_def& shape)
for (int i = 0; i < 8; ++i)
{
Q.transform_tiny(temp, points[i]);
start.x = _min(start.x, temp.x);
start.y = _min(start.y, temp.y);
start.z = _min(start.z, temp.z);
dest.x = _max(dest.x, temp.x);
dest.y = _max(dest.y, temp.y);
dest.z = _max(dest.z, temp.z);
start.x = std::min(start.x, temp.x);
start.y = std::min(start.y, temp.y);
start.z = std::min(start.z, temp.z);
dest.x = std::max(dest.x, temp.x);
dest.y = std::max(dest.y, temp.y);
dest.z = std::max(dest.z, temp.z);
}
break;
}
Expand All @@ -177,7 +177,7 @@ void CSpaceRestrictorWrapper::fill_shape(const CShapeData::shape_def& shape)

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

{
BORDER::iterator I =
auto I =
std::remove_if(m_border.begin(), m_border.end(), border_merge_predicate(this, m_level_graph));
m_border.erase(I, m_border.end());
}

{
std::sort(m_border.begin(), m_border.end());
BORDER::iterator I = std::unique(m_border.begin(), m_border.end());
auto I = std::unique(m_border.begin(), m_border.end());
m_border.erase(I, m_border.end());
std::sort(m_border.begin(), m_border.end(), sort_by_xz_predicate(m_level_graph));
}
Expand All @@ -245,13 +245,13 @@ void CSpaceRestrictorWrapper::verify_connectivity()
{
{
std::sort(m_internal.begin(), m_internal.end());
BORDER::iterator I = std::unique(m_internal.begin(), m_internal.end());
auto I = std::unique(m_internal.begin(), m_internal.end());
m_internal.erase(I, m_internal.end());
}

u32 start_vertex_id = u32(-1);
CLevelGraph::const_vertex_iterator I = level_graph().begin();
CLevelGraph::const_vertex_iterator E = level_graph().end();
auto I = level_graph().begin();
auto E = level_graph().end();
for (; I != E; ++I)
if (!inside(level_graph().vertex(I), true))
{
Expand Down
Loading

0 comments on commit 29ad349

Please sign in to comment.