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
99AISpaceBase::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
4039void 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
5047void 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()
6056void 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+ }
0 commit comments