Skip to content

Commit 3dbacd3

Browse files
committed
Reformat: xrAICore
1 parent 521f856 commit 3dbacd3

File tree

97 files changed

+5491
-6256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+5491
-6256
lines changed

src/xrAICore/AISpaceBase.cpp

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#include "PCH.hpp"
21
#include "AISpaceBase.hpp"
2+
#include "Include/xrAPI/xrAPI.h"
3+
#include "Navigation/PatrolPath/patrol_path_storage.h"
34
#include "Navigation/game_graph.h"
4-
#include "Navigation/level_graph.h"
55
#include "Navigation/graph_engine.h"
6-
#include "Navigation/PatrolPath/patrol_path_storage.h"
7-
#include "Include/xrAPI/xrAPI.h"
6+
#include "Navigation/level_graph.h"
7+
#include "PCH.hpp"
88

99
AISpaceBase::AISpaceBase()
1010
{
@@ -19,38 +19,34 @@ AISpaceBase::~AISpaceBase()
1919
GlobalEnv.AISpace = nullptr;
2020
}
2121

22-
void AISpaceBase::Load(const char *levelName)
22+
void AISpaceBase::Load(const char* levelName)
2323
{
24-
const CGameGraph::SLevel &currentLevel = game_graph().header().level(levelName);
24+
const CGameGraph::SLevel& currentLevel = game_graph().header().level(levelName);
2525
m_level_graph = new CLevelGraph();
2626
game_graph().set_current_level(currentLevel.id());
27-
auto &crossHeader = cross_table().header();
28-
auto &levelHeader = level_graph().header();
29-
auto &gameHeader = game_graph().header();
30-
R_ASSERT2(crossHeader.level_guid()==levelHeader.guid(), "cross_table doesn't correspond to the AI-map");
31-
R_ASSERT2(crossHeader.game_guid()==gameHeader.guid(), "graph doesn't correspond to the cross table");
27+
auto& crossHeader = cross_table().header();
28+
auto& levelHeader = level_graph().header();
29+
auto& gameHeader = game_graph().header();
30+
R_ASSERT2(crossHeader.level_guid() == levelHeader.guid(), "cross_table doesn't correspond to the AI-map");
31+
R_ASSERT2(crossHeader.game_guid() == gameHeader.guid(), "graph doesn't correspond to the cross table");
3232
u32 vertexCount = _max(gameHeader.vertex_count(), levelHeader.vertex_count());
3333
m_graph_engine = new CGraphEngine(vertexCount);
34-
R_ASSERT2(currentLevel.guid()==levelHeader.guid(), "graph doesn't correspond to the AI-map");
35-
if (!xr_strcmp(currentLevel.name(), levelName))
36-
Validate(currentLevel.id());
34+
R_ASSERT2(currentLevel.guid() == levelHeader.guid(), "graph doesn't correspond to the AI-map");
35+
if (!xr_strcmp(currentLevel.name(), levelName)) Validate(currentLevel.id());
3736
level_graph().level_id(currentLevel.id());
3837
}
3938

4039
void AISpaceBase::Unload(bool reload)
4140
{
42-
if (g_dedicated_server)
43-
return;
41+
if (g_dedicated_server) return;
4442
xr_delete(m_graph_engine);
4543
xr_delete(m_level_graph);
46-
if (!reload && m_game_graph)
47-
m_graph_engine = new CGraphEngine(game_graph().header().vertex_count());
44+
if (!reload && m_game_graph) m_graph_engine = new CGraphEngine(game_graph().header().vertex_count());
4845
}
4946

5047
void AISpaceBase::Initialize()
5148
{
52-
if (g_dedicated_server)
53-
return;
49+
if (g_dedicated_server) return;
5450
VERIFY(!m_graph_engine);
5551
m_graph_engine = new CGraphEngine(1024);
5652
VERIFY(!m_patrol_path_storage);
@@ -60,58 +56,52 @@ void AISpaceBase::Initialize()
6056
void AISpaceBase::Validate(u32 levelId) const
6157
{
6258
#ifdef DEBUG
63-
VERIFY(level_graph().header().vertex_count()==cross_table().header().level_vertex_count());
64-
for (GameGraph::_GRAPH_ID i = 0, n = game_graph().header().vertex_count(); i<n; i++)
59+
VERIFY(level_graph().header().vertex_count() == cross_table().header().level_vertex_count());
60+
for (GameGraph::_GRAPH_ID i = 0, n = game_graph().header().vertex_count(); i < n; i++)
6561
{
66-
const GameGraph::CVertex &vertex = *game_graph().vertex(i);
67-
if (levelId!=vertex.level_id())
68-
continue;
62+
const GameGraph::CVertex& vertex = *game_graph().vertex(i);
63+
if (levelId != vertex.level_id()) continue;
6964
u32 vid = vertex.level_vertex_id();
70-
if (!level_graph().valid_vertex_id(vid) ||
71-
cross_table().vertex(vid).game_vertex_id()!=i ||
65+
if (!level_graph().valid_vertex_id(vid) || cross_table().vertex(vid).game_vertex_id() != i ||
7266
!level_graph().inside(vid, vertex.level_point()))
7367
{
7468
Msg("! Graph doesn't correspond to the cross table");
7569
R_ASSERT2(false, "Graph doesn't correspond to the cross table");
7670
}
7771
}
78-
//Msg("death graph point id : %d", cross_table().vertex(455236).game_vertex_id());
79-
for (u32 i = 0, n = game_graph().header().vertex_count(); i<n; i++)
72+
// Msg("death graph point id : %d", cross_table().vertex(455236).game_vertex_id());
73+
for (u32 i = 0, n = game_graph().header().vertex_count(); i < n; i++)
8074
{
81-
if (levelId!=game_graph().vertex(i)->level_id())
82-
continue;
75+
if (levelId != game_graph().vertex(i)->level_id()) continue;
8376
CGameGraph::const_spawn_iterator it, end;
8477
game_graph().begin_spawn(i, it, end);
85-
//Msg("vertex [%d] has %d death points", i, game_graph().vertex(i)->death_point_count());
86-
for (; it!=end; it++)
78+
// Msg("vertex [%d] has %d death points", i, game_graph().vertex(i)->death_point_count());
79+
for (; it != end; it++)
8780
VERIFY(cross_table().vertex(it->level_vertex_id()).game_vertex_id() == i);
8881
}
89-
//Msg("* Graph corresponds to the cross table");
82+
// Msg("* Graph corresponds to the cross table");
9083
#endif
9184
}
9285

93-
void AISpaceBase::patrol_path_storage_raw(IReader &stream)
86+
void AISpaceBase::patrol_path_storage_raw(IReader& stream)
9487
{
95-
if (g_dedicated_server)
96-
return;
88+
if (g_dedicated_server) return;
9789
xr_delete(m_patrol_path_storage);
9890
m_patrol_path_storage = new CPatrolPathStorage();
9991
m_patrol_path_storage->load_raw(get_level_graph(), get_cross_table(), get_game_graph(), stream);
10092
}
10193

102-
void AISpaceBase::patrol_path_storage(IReader &stream)
94+
void AISpaceBase::patrol_path_storage(IReader& stream)
10395
{
104-
if (g_dedicated_server)
105-
return;
96+
if (g_dedicated_server) return;
10697
xr_delete(m_patrol_path_storage);
10798
m_patrol_path_storage = new CPatrolPathStorage();
10899
m_patrol_path_storage->load(stream);
109100
}
110101

111-
void AISpaceBase::SetGameGraph(CGameGraph *gameGraph)
102+
void AISpaceBase::SetGameGraph(CGameGraph* gameGraph)
112103
{
113-
if (gameGraph)
114-
{
104+
if (gameGraph) {
115105
VERIFY(!m_game_graph);
116106
m_game_graph = gameGraph;
117107
xr_delete(m_graph_engine);
@@ -125,8 +115,12 @@ void AISpaceBase::SetGameGraph(CGameGraph *gameGraph)
125115
}
126116
}
127117

128-
const CGameLevelCrossTable &AISpaceBase::cross_table() const
129-
{ return game_graph().cross_table(); }
118+
const CGameLevelCrossTable& AISpaceBase::cross_table() const
119+
{
120+
return game_graph().cross_table();
121+
}
130122

131-
const CGameLevelCrossTable *AISpaceBase::get_cross_table() const
132-
{ return &game_graph().cross_table(); }
123+
const CGameLevelCrossTable* AISpaceBase::get_cross_table() const
124+
{
125+
return &game_graph().cross_table();
126+
}

src/xrAICore/AISpaceBase.hpp

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,60 +11,67 @@ class CPatrolPathStorage;
1111
class XRAICORE_API AISpaceBase
1212
{
1313
protected:
14-
CGameGraph *m_game_graph = nullptr; // not owned by AISpaceBase
15-
CLevelGraph *m_level_graph = nullptr;
16-
CGraphEngine *m_graph_engine = nullptr;
17-
CPatrolPathStorage *m_patrol_path_storage = nullptr;
14+
CGameGraph* m_game_graph = nullptr; // not owned by AISpaceBase
15+
CLevelGraph* m_level_graph = nullptr;
16+
CGraphEngine* m_graph_engine = nullptr;
17+
CPatrolPathStorage* m_patrol_path_storage = nullptr;
1818

1919
protected:
2020
AISpaceBase();
21-
void Load(const char *levelName);
21+
void Load(const char* levelName);
2222
void Unload(bool reload);
2323
void Initialize();
2424
void Validate(u32 levelId) const;
25-
void patrol_path_storage_raw(IReader &stream);
26-
void patrol_path_storage(IReader &stream);
27-
void SetGameGraph(CGameGraph *gameGraph);
28-
[[deprecated("This function is deprecated. Use AISpaceBase::SetGameGraph() instead.")]]
29-
void game_graph(CGameGraph *g) { SetGameGraph(g); }
25+
void patrol_path_storage_raw(IReader& stream);
26+
void patrol_path_storage(IReader& stream);
27+
void SetGameGraph(CGameGraph* gameGraph);
28+
[[deprecated("This function is deprecated. Use AISpaceBase::SetGameGraph() instead.")]] void game_graph(
29+
CGameGraph* g)
30+
{
31+
SetGameGraph(g);
32+
}
3033

3134
public:
3235
~AISpaceBase();
33-
inline CGameGraph &game_graph() const;
34-
inline CGameGraph *get_game_graph() const;
35-
inline CLevelGraph &level_graph() const;
36-
inline const CLevelGraph *get_level_graph() const;
37-
const CGameLevelCrossTable &cross_table() const;
38-
const CGameLevelCrossTable *get_cross_table() const;
39-
inline const CPatrolPathStorage &patrol_paths() const;
40-
inline CGraphEngine &graph_engine() const;
36+
inline CGameGraph& game_graph() const;
37+
inline CGameGraph* get_game_graph() const;
38+
inline CLevelGraph& level_graph() const;
39+
inline const CLevelGraph* get_level_graph() const;
40+
const CGameLevelCrossTable& cross_table() const;
41+
const CGameLevelCrossTable* get_cross_table() const;
42+
inline const CPatrolPathStorage& patrol_paths() const;
43+
inline CGraphEngine& graph_engine() const;
4144
};
4245

43-
inline CGameGraph &AISpaceBase::game_graph() const
46+
inline CGameGraph& AISpaceBase::game_graph() const
4447
{
4548
VERIFY(m_game_graph);
4649
return *m_game_graph;
4750
}
4851

49-
inline CGameGraph *AISpaceBase::get_game_graph() const
50-
{ return m_game_graph; }
52+
inline CGameGraph* AISpaceBase::get_game_graph() const
53+
{
54+
return m_game_graph;
55+
}
5156

52-
inline CLevelGraph &AISpaceBase::level_graph() const
57+
inline CLevelGraph& AISpaceBase::level_graph() const
5358
{
5459
VERIFY(m_level_graph);
5560
return *m_level_graph;
5661
}
5762

58-
inline const CLevelGraph *AISpaceBase::get_level_graph() const
59-
{ return m_level_graph; }
63+
inline const CLevelGraph* AISpaceBase::get_level_graph() const
64+
{
65+
return m_level_graph;
66+
}
6067

61-
inline CGraphEngine &AISpaceBase::graph_engine() const
68+
inline CGraphEngine& AISpaceBase::graph_engine() const
6269
{
6370
VERIFY(m_graph_engine);
6471
return *m_graph_engine;
6572
}
6673

67-
inline const CPatrolPathStorage &AISpaceBase::patrol_paths() const
74+
inline const CPatrolPathStorage& AISpaceBase::patrol_paths() const
6875
{
6976
VERIFY(m_patrol_path_storage);
7077
return *m_patrol_path_storage;

src/xrAICore/Components/condition_state.h

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,32 @@
1111
#include "xrAICore/Components/operator_condition.h"
1212

1313
template <typename _world_property>
14-
class CConditionState {
14+
class CConditionState
15+
{
1516
public:
16-
typedef _world_property COperatorCondition;
17+
typedef _world_property COperatorCondition;
1718

1819
protected:
19-
xr_vector<COperatorCondition> m_conditions;
20-
u32 m_hash;
20+
xr_vector<COperatorCondition> m_conditions;
21+
u32 m_hash;
2122

2223
public:
23-
IC CConditionState ();
24-
IC virtual ~CConditionState ();
25-
IC const xr_vector<COperatorCondition> &conditions () const;
26-
IC u8 weight (const CConditionState &condition) const;
27-
IC void add_condition (const COperatorCondition &condition);
28-
IC void remove_condition (const typename COperatorCondition::_condition_type &condition);
29-
IC void add_condition (typename xr_vector<COperatorCondition>::const_iterator &J, const COperatorCondition &condition);
30-
IC void add_condition_back (const COperatorCondition &condition);
31-
IC bool includes (const CConditionState &condition) const;
32-
IC void clear ();
33-
IC bool operator< (const CConditionState &condition) const;
34-
IC CConditionState<_world_property> &operator-= (const CConditionState &condition);
35-
IC bool operator== (const CConditionState &condition) const;
36-
IC u32 hash_value () const;
37-
IC const COperatorCondition *property (const typename COperatorCondition::_condition_type &condition) const;
24+
IC CConditionState();
25+
IC virtual ~CConditionState();
26+
IC const xr_vector<COperatorCondition>& conditions() const;
27+
IC u8 weight(const CConditionState& condition) const;
28+
IC void add_condition(const COperatorCondition& condition);
29+
IC void remove_condition(const typename COperatorCondition::_condition_type& condition);
30+
IC void add_condition(
31+
typename xr_vector<COperatorCondition>::const_iterator& J, const COperatorCondition& condition);
32+
IC void add_condition_back(const COperatorCondition& condition);
33+
IC bool includes(const CConditionState& condition) const;
34+
IC void clear();
35+
IC bool operator<(const CConditionState& condition) const;
36+
IC CConditionState<_world_property>& operator-=(const CConditionState& condition);
37+
IC bool operator==(const CConditionState& condition) const;
38+
IC u32 hash_value() const;
39+
IC const COperatorCondition* property(const typename COperatorCondition::_condition_type& condition) const;
3840
};
3941

4042
#include "xrAICore/Components/condition_state_inline.h"

0 commit comments

Comments
 (0)