Skip to content

Commit 9855d87

Browse files
author
nitrocaster
committed
xrGame: Fix conformance in For loop scope (#104).
1 parent 9a0b01c commit 9855d87

25 files changed

+68
-51
lines changed

src/xrAICore/Navigation/data_storage_binary_heap_inline.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ TEMPLATE_SPECIALIZATION
5959
inline void CBinaryHeap::decrease_opened(Vertex &vertex, const Distance value)
6060
{
6161
VERIFY(!is_opened_empty());
62-
for (Vertex **i = m_heap_head; *i!=&vertex; i++);
62+
Vertex **i = m_heap_head;
63+
while (*i!=&vertex)
64+
i++;
6365
std::push_heap(m_heap_head, i+1, VertexPredicate());
6466
}
6567

src/xrAICore/Navigation/edge_path_inline.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ TEMPLATE_SPECIALIZATION
3838
inline void CEdgePathBuilder::get_edge_path(xr_vector<TEdge> &path, Vertex *best, bool reverse_order)
3939
{
4040
Vertex *t1 = best, *t2 = best->back();
41-
for (u32 i=1; t2; t1 = t2, t2 = t2->back(), i++);
41+
u32 i;
42+
for (i=1; t2; t1 = t2, t2 = t2->back(), i++);
4243
u32 n = (u32)path.size();
4344
i--;
4445
path.resize(n+i);

src/xrGame/AI_PhraseDialogManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void CAI_PhraseDialogManager::AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog)
5959
}
6060
}
6161

62-
for(i=0; i<phrase_dialog->PhraseList().size(); i++)
62+
for(u32 i=0; i<phrase_dialog->PhraseList().size(); i++)
6363
{
6464
if(phrase_goodwill == phrase_dialog->PhraseList()[phrase_num]->GoodwillLevel())
6565
phrases.push_back(i);

src/xrGame/ActorCameras.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ void CActor::cam_Lookout ( const Fmatrix &xform, float camera_height )
254254
da = PI/1000.f;
255255
if (!fis_zero(r_torso.roll))
256256
da *= r_torso.roll/_abs(r_torso.roll);
257-
for (float angle=0.f; _abs(angle)<_abs(alpha); angle+=da)
257+
float angle;
258+
for (angle=0.f; _abs(angle)<_abs(alpha); angle+=da)
258259
{
259260
Fvector pt;
260261
calc_gl_point( pt, xform, radius, angle );

src/xrGame/Actor_Network.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ void CActor::OnRender_Network()
15621562
};
15631563

15641564
//drawing speed vectors
1565-
for (i=0; i<2; i++)
1565+
for (int i=0; i<2; i++)
15661566
{
15671567
c = float(i);
15681568
for (u32 k=0; k<3; k++)

src/xrGame/Inventory.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ void CInventory::UpdateDropTasks()
825825
UpdateDropItem (itm);
826826
}
827827

828-
for(i = 0; i < 2; ++i)
828+
for(u16 i = 0; i < 2; ++i)
829829
{
830830
TIItemContainer &list = i?m_ruck:m_belt;
831831
TIItemContainer::iterator it = list.begin();
@@ -1197,8 +1197,8 @@ bool CInventory::CanTakeItem(CInventoryItem *inventory_item) const
11971197
if (inventory_item->object().getDestroy()) return false;
11981198

11991199
if(!inventory_item->CanTake()) return false;
1200-
1201-
for(TIItemContainer::const_iterator it = m_all.begin(); it != m_all.end(); it++)
1200+
TIItemContainer::const_iterator it;
1201+
for(it = m_all.begin(); it != m_all.end(); it++)
12021202
if((*it)->object().ID() == inventory_item->object().ID()) break;
12031203
VERIFY3(it == m_all.end(), "item already exists in inventory",*inventory_item->object().cName());
12041204

src/xrGame/LevelGraphDebugRender.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,8 @@ void LevelGraphDebugRender::DrawCovers()
749749
CLevelGraph::CVertex *v = levelGraph->vertex(coverPoint->level_vertex_id());
750750
Fvector dir;
751751
float bestValue = -1;
752-
for (u32 i = 0, j = 0; i<36; ++i)
752+
u32 j = 0;
753+
for (u32 i = 0; i<36; ++i)
753754
{
754755
float value = levelGraph->high_cover_in_direction(float(10*i)/180*PI, v);
755756
dir.setHP(float(10*i)/180*PI, 0);
@@ -785,7 +786,8 @@ void LevelGraphDebugRender::DrawCovers()
785786
debugRenderer.draw_aabb(pos, halfSize-0.01f, 1.f, halfSize-0.01f, color_xrgb(0, 255, 0));
786787
v = levelGraph->vertex(coverPoint->level_vertex_id());
787788
bestValue = -1;
788-
for (u32 i = 0, j = 0; i<36; ++i)
789+
j = 0;
790+
for (u32 i = 0; i<36; ++i)
789791
{
790792
float value = levelGraph->low_cover_in_direction(float(10*i)/180*PI, v);
791793
dir.setHP(float(10*i)/180.f*PI, 0);

src/xrGame/PHMovementControl.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,8 @@ void CPHMovementControl::PathNearestPoint(const xr_vector<DetailPathManager::STr
520520

521521
Fvector path_point,vtemp;
522522
float temp;
523-
524-
for(int i=0;i<m_path_size-1;++i)
523+
int i;
524+
for(i=0;i<m_path_size-1;++i)
525525
{
526526
const Fvector &first=path[i].position, &second=path[i+1].position;
527527
from_first.sub(new_position,first);
@@ -612,8 +612,8 @@ void CPHMovementControl::PathNearestPointFindUp(const xr_vector<DetailPathManage
612612
Fvector path_point,vtemp;
613613
float temp;
614614
dir.set (0,0,1);
615-
616-
for(int i=m_start_index;i<m_path_size-1;++i)
615+
int i;
616+
for(i=m_start_index;i<m_path_size-1;++i)
617617
{
618618
const Fvector &first=path[i].position, &second=path[i+1].position;
619619
from_first.sub(new_position,first);
@@ -701,7 +701,8 @@ void CPHMovementControl::PathNearestPointFindDown(const xr_vector<DetailPathMana
701701
float temp;
702702
//(going down)
703703
dir.set(0,0,1);
704-
for(int i=m_start_index;i>1;--i)
704+
int i;
705+
for(i=m_start_index;i>1;--i)
705706
{
706707
const Fvector &first=path[i-1].position, &second=path[i].position;
707708
from_first.sub(new_position,first);

src/xrGame/PhraseScript.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bool CDialogScriptHelper::CheckInfo(const CInventoryOwner* pOwner) const
5252
}
5353
}
5454

55-
for(i=0; i<m_DontHasInfo.size(); i++) {
55+
for(u32 i=0; i<m_DontHasInfo.size(); i++) {
5656
if (Actor()->HasInfo(m_DontHasInfo[i])) {
5757
#ifdef DEBUG
5858
if(psAI_Flags.test(aiDialogs) )
@@ -72,7 +72,7 @@ void CDialogScriptHelper::TransferInfo (const CInventoryOwner* pOwner) const
7272
for(u32 i=0; i<m_GiveInfo.size(); ++i)
7373
Actor()->TransferInfo(m_GiveInfo[i], true);
7474

75-
for(i=0; i<m_DisableInfo.size(); ++i)
75+
for(u32 i=0; i<m_DisableInfo.size(); ++i)
7676
Actor()->TransferInfo(m_DisableInfo[i], false);
7777
}
7878

src/xrGame/ai/ai_monsters_anims.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ template <LPCSTR caBaseNames[]> class CAniFVector {
2828
{
2929
A.clear ();
3030
string256 S;
31-
for (int j=0; caBaseNames[j]; ++j);
31+
int j = 0;
32+
while (caBaseNames[j])
33+
j++;
3234
A.resize (j);
3335
for (int i=0; i<j; ++i)
3436
{
@@ -50,7 +52,9 @@ template <class TYPE_NAME, LPCSTR caBaseNames[]> class CAniCollection {
5052
{
5153
A.clear ();
5254
string256 S;
53-
for (int j=0; caBaseNames[j]; ++j);
55+
int j = 0;
56+
while (caBaseNames[j])
57+
j++;
5458
A.resize (j);
5559
for (int i=0; i<j; ++i)
5660
A[i].Load (tpKinematics,strconcat(sizeof(S),S,caBaseName,caBaseNames[i]));

0 commit comments

Comments
 (0)