Skip to content

Commit

Permalink
Use XRAI_VERSION_PRIQUEL to determine if we should load SOC or CS/COP…
Browse files Browse the repository at this point in the history
… game graph and level cross table (#392)

This improves old 6b30ac3 commit using correct versioning introduced in 7a1f0c1
  • Loading branch information
Xottab-DUTY committed Jan 25, 2023
1 parent cea2c94 commit 5f8e041
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/xrAICore/Navigation/game_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class CGameGraph
_GRAPH_ID m_current_level_some_vertex_id;

private:
u32* m_cross_tables;
CGameLevelCrossTable* m_current_level_cross_table;
u32* m_cross_tables{};
CGameLevelCrossTable* m_current_level_cross_table{};

inline void Initialize(IReader& stream, bool own);

Expand Down
16 changes: 6 additions & 10 deletions src/xrAICore/Navigation/game_graph_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ inline void CGameGraph::Initialize(IReader& stream, bool own)
m_current_level_some_vertex_id = _GRAPH_ID(-1);
m_enabled.assign(header().vertex_count(), true);

if (header().version() <= XRAI_VERSION_SOC)
if (header().version() >= XRAI_VERSION_PRIQUEL)
{
m_cross_tables = nullptr;
u8* temp = (u8*)(m_nodes + header().vertex_count());
temp += header().edge_count() * sizeof(CGameGraph::CEdge);
m_cross_tables = (u32*)(((CLevelPoint*)temp) + header().death_point_count());
m_current_level_cross_table = nullptr;
return;
}

u8* temp = (u8*)(m_nodes + header().vertex_count());
temp += header().edge_count() * sizeof(CGameGraph::CEdge);
m_cross_tables = (u32*)(((CLevelPoint*)temp) + header().death_point_count());
m_current_level_cross_table = nullptr;
}

IC CGameGraph::CGameGraph(LPCSTR file_name, u32 current_version)
Expand Down Expand Up @@ -258,7 +254,7 @@ IC void GameGraph::CHeader::save(IWriter* writer)
IC void CGameGraph::set_current_level(u32 const level_id)
{
xr_delete(m_current_level_cross_table);
if (m_cross_tables)
if (header().version() >= XRAI_VERSION_PRIQUEL)
{
u32* current_cross_table = m_cross_tables;
GameGraph::LEVEL_MAP::const_iterator I = header().levels().begin();
Expand All @@ -275,7 +271,7 @@ IC void CGameGraph::set_current_level(u32 const level_id)
break;
}
}
else
else // XRAI_VERSION_SOC and below
{
string_path fName;
FS.update_path(fName, "$level$", CROSS_TABLE_NAME);
Expand Down
5 changes: 3 additions & 2 deletions src/xrGame/alife_spawn_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ void CALifeSpawnRegistry::load(IReader& file_stream, xrGUID* save_guid)
chunk->close();

VERIFY(!m_chunk);
m_chunk = file_stream.open_chunk(4);
if (!m_chunk) // Shadow of Chernobyl
if (header().version() >= XRAI_VERSION_PRIQUEL)
m_chunk = file_stream.open_chunk(4);
else // XRAI_VERSION_SOC and below
{
string_path file_name;
FS.update_path(file_name, "$game_data$", GRAPH_NAME);
Expand Down

0 comments on commit 5f8e041

Please sign in to comment.