Skip to content

Commit a934e66

Browse files
author
nitrocaster
committed
xrAI: Fix conformance in For loop scope (#104).
1 parent b282c63 commit a934e66

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/utils/xrAI/xr_graph_merge.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ class CLevelGameGraph {
194194
IReader *F = FS.r_open(fName);
195195
u32 id;
196196
IReader *O = F->open_chunk_iterator(id);
197-
for (int i=0; O; O = F->open_chunk_iterator(id,O)) {
197+
int vertexId = 0;
198+
for (; O; O = F->open_chunk_iterator(id, O))
199+
{
198200
NET_Packet P;
199201
P.B.count = O->length();
200202
O->r (P.B.data,P.B.count);
@@ -233,9 +235,9 @@ class CLevelGameGraph {
233235
S = xr_strdup(tpGraphPoint->name_replace());
234236
T.caConnectName = xr_strdup(*tpGraphPoint->m_caConnectionPointName);
235237
T.dwLevelID = dwfGetIDByLevelName(Ini,*tpGraphPoint->m_caConnectionLevelName);
236-
// T.tGraphID = (GameGraph::_GRAPH_ID)i;
238+
// T.tGraphID = (GameGraph::_GRAPH_ID)vertexId;
237239
// T.tOldGraphID = tGraphID;
238-
T.tOldGraphID = (GameGraph::_GRAPH_ID)i;
240+
T.tOldGraphID = (GameGraph::_GRAPH_ID)vertexId;
239241
T.tGraphID = tGraphID;
240242

241243
bool ok = true;
@@ -250,22 +252,23 @@ class CLevelGameGraph {
250252

251253
if (ok) {
252254
m_tVertexMap.insert (mk_pair(S,T));
253-
i++;
255+
vertexId++;
254256
}
255257
}
256258
}
257259
F_entity_Destroy (E);
258260
}
259-
if (i != m_tpGraph->header().vertex_count())
260-
Msg ("Graph for the level %s doesn't correspond to the graph points from Level Editor! (%d : %d)",*m_tLevel.name(),i,m_tpGraph->header().vertex_count());
261+
if (vertexId!=m_tpGraph->header().vertex_count())
262+
Msg("Graph for the level %s doesn't correspond to the graph points from Level Editor! (%d : %d)",
263+
*m_tLevel.name(), vertexId, m_tpGraph->header().vertex_count());
261264

262265
VERTEX_MAP::const_iterator I = m_tVertexMap.begin();
263266
VERTEX_MAP::const_iterator E = m_tVertexMap.end();
264267
for ( ; I != E; ++I) {
265268
R_ASSERT3 (!xr_strlen((*I).second.caConnectName) || ((*I).second.tGraphID < m_tpVertices.size()),"Rebuild graph for the level",*m_tLevel.name());
266269
}
267270

268-
// VERIFY3 (i == m_tpGraph->header().vertex_count(), "Rebuild graph for the level ",m_tLevel.name());
271+
// VERIFY3(vertexId==m_tpGraph->header().vertex_count(), "Rebuild graph for the level ",m_tLevel.name());
269272
O->close ();
270273
FS.r_close (F);
271274
}

src/xrAICore/Navigation/vertex_path_inline.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ TEMPLATE_SPECIALIZATION
4343
inline void CVertexPathBuilder::get_node_path(xr_vector<Index> &path, Vertex *best)
4444
{
4545
Vertex *t1 = best, *t2 = best->back();
46+
u32 i;
4647
for (u32 i = 1; t2; t1 = t2, t2 = t2->back(), i++);
4748
path.resize(i);
4849
t1 = best;

0 commit comments

Comments
 (0)