Skip to content

Commit

Permalink
xrGame: Fix conformance in For loop scope (#104).
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocaster committed Jan 15, 2016
1 parent 9a0b01c commit 9855d87
Show file tree
Hide file tree
Showing 25 changed files with 68 additions and 51 deletions.
4 changes: 3 additions & 1 deletion src/xrAICore/Navigation/data_storage_binary_heap_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ TEMPLATE_SPECIALIZATION
inline void CBinaryHeap::decrease_opened(Vertex &vertex, const Distance value)
{
VERIFY(!is_opened_empty());
for (Vertex **i = m_heap_head; *i!=&vertex; i++);
Vertex **i = m_heap_head;
while (*i!=&vertex)
i++;
std::push_heap(m_heap_head, i+1, VertexPredicate());
}

Expand Down
3 changes: 2 additions & 1 deletion src/xrAICore/Navigation/edge_path_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ TEMPLATE_SPECIALIZATION
inline void CEdgePathBuilder::get_edge_path(xr_vector<TEdge> &path, Vertex *best, bool reverse_order)
{
Vertex *t1 = best, *t2 = best->back();
for (u32 i=1; t2; t1 = t2, t2 = t2->back(), i++);
u32 i;
for (i=1; t2; t1 = t2, t2 = t2->back(), i++);
u32 n = (u32)path.size();
i--;
path.resize(n+i);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/AI_PhraseDialogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void CAI_PhraseDialogManager::AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog)
}
}

for(i=0; i<phrase_dialog->PhraseList().size(); i++)
for(u32 i=0; i<phrase_dialog->PhraseList().size(); i++)
{
if(phrase_goodwill == phrase_dialog->PhraseList()[phrase_num]->GoodwillLevel())
phrases.push_back(i);
Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/ActorCameras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ void CActor::cam_Lookout ( const Fmatrix &xform, float camera_height )
da = PI/1000.f;
if (!fis_zero(r_torso.roll))
da *= r_torso.roll/_abs(r_torso.roll);
for (float angle=0.f; _abs(angle)<_abs(alpha); angle+=da)
float angle;
for (angle=0.f; _abs(angle)<_abs(alpha); angle+=da)
{
Fvector pt;
calc_gl_point( pt, xform, radius, angle );
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Actor_Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ void CActor::OnRender_Network()
};

//drawing speed vectors
for (i=0; i<2; i++)
for (int i=0; i<2; i++)
{
c = float(i);
for (u32 k=0; k<3; k++)
Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ void CInventory::UpdateDropTasks()
UpdateDropItem (itm);
}

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

if(!inventory_item->CanTake()) return false;

for(TIItemContainer::const_iterator it = m_all.begin(); it != m_all.end(); it++)
TIItemContainer::const_iterator it;
for(it = m_all.begin(); it != m_all.end(); it++)
if((*it)->object().ID() == inventory_item->object().ID()) break;
VERIFY3(it == m_all.end(), "item already exists in inventory",*inventory_item->object().cName());

Expand Down
6 changes: 4 additions & 2 deletions src/xrGame/LevelGraphDebugRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,8 @@ void LevelGraphDebugRender::DrawCovers()
CLevelGraph::CVertex *v = levelGraph->vertex(coverPoint->level_vertex_id());
Fvector dir;
float bestValue = -1;
for (u32 i = 0, j = 0; i<36; ++i)
u32 j = 0;
for (u32 i = 0; i<36; ++i)
{
float value = levelGraph->high_cover_in_direction(float(10*i)/180*PI, v);
dir.setHP(float(10*i)/180*PI, 0);
Expand Down Expand Up @@ -785,7 +786,8 @@ void LevelGraphDebugRender::DrawCovers()
debugRenderer.draw_aabb(pos, halfSize-0.01f, 1.f, halfSize-0.01f, color_xrgb(0, 255, 0));
v = levelGraph->vertex(coverPoint->level_vertex_id());
bestValue = -1;
for (u32 i = 0, j = 0; i<36; ++i)
j = 0;
for (u32 i = 0; i<36; ++i)
{
float value = levelGraph->low_cover_in_direction(float(10*i)/180*PI, v);
dir.setHP(float(10*i)/180.f*PI, 0);
Expand Down
11 changes: 6 additions & 5 deletions src/xrGame/PHMovementControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ void CPHMovementControl::PathNearestPoint(const xr_vector<DetailPathManager::STr

Fvector path_point,vtemp;
float temp;

for(int i=0;i<m_path_size-1;++i)
int i;
for(i=0;i<m_path_size-1;++i)
{
const Fvector &first=path[i].position, &second=path[i+1].position;
from_first.sub(new_position,first);
Expand Down Expand Up @@ -612,8 +612,8 @@ void CPHMovementControl::PathNearestPointFindUp(const xr_vector<DetailPathManage
Fvector path_point,vtemp;
float temp;
dir.set (0,0,1);

for(int i=m_start_index;i<m_path_size-1;++i)
int i;
for(i=m_start_index;i<m_path_size-1;++i)
{
const Fvector &first=path[i].position, &second=path[i+1].position;
from_first.sub(new_position,first);
Expand Down Expand Up @@ -701,7 +701,8 @@ void CPHMovementControl::PathNearestPointFindDown(const xr_vector<DetailPathMana
float temp;
//(going down)
dir.set(0,0,1);
for(int i=m_start_index;i>1;--i)
int i;
for(i=m_start_index;i>1;--i)
{
const Fvector &first=path[i-1].position, &second=path[i].position;
from_first.sub(new_position,first);
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/PhraseScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool CDialogScriptHelper::CheckInfo(const CInventoryOwner* pOwner) const
}
}

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

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

Expand Down
8 changes: 6 additions & 2 deletions src/xrGame/ai/ai_monsters_anims.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ template <LPCSTR caBaseNames[]> class CAniFVector {
{
A.clear ();
string256 S;
for (int j=0; caBaseNames[j]; ++j);
int j = 0;
while (caBaseNames[j])
j++;
A.resize (j);
for (int i=0; i<j; ++i)
{
Expand All @@ -50,7 +52,9 @@ template <class TYPE_NAME, LPCSTR caBaseNames[]> class CAniCollection {
{
A.clear ();
string256 S;
for (int j=0; caBaseNames[j]; ++j);
int j = 0;
while (caBaseNames[j])
j++;
A.resize (j);
for (int i=0; i<j; ++i)
A[i].Load (tpKinematics,strconcat(sizeof(S),S,caBaseName,caBaseNames[i]));
Expand Down
6 changes: 2 additions & 4 deletions src/xrGame/ai/monsters/chimera/chimera_attack_state_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,8 @@ bool ChimeraAttackState<Object>::select_target_for_move ()

float const move_scan_points = 8;
float const move_scan_angle = deg2rad(360.f) / move_scan_points;

for ( u32 index = 0;
index < move_scan_points;
++index )
u32 index = 0;
for (; index<move_scan_points; index++)
{
float const angle = move_scan_angle *
(index+1) *
Expand Down
9 changes: 5 additions & 4 deletions src/xrGame/ai/stalker/ai_stalker_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1743,8 +1743,8 @@ void CAI_Stalker::OnRender ()
// high
Fvector direction;
float best_value = -1.f;

for (u32 i=0, j = 0; i<36; ++i) {
u32 j = 0;
for (u32 i=0; i<36; ++i) {
float value = ai().level_graph().high_cover_in_direction(float(10*i)/180.f*PI,v);
direction.setHP (float(10*i)/180.f*PI,0);
direction.normalize ();
Expand Down Expand Up @@ -1783,8 +1783,9 @@ void CAI_Stalker::OnRender ()
{
Fvector direction;
float best_value = -1.f;

for (u32 i=0, j = 0; i<36; ++i) {
j = 0;
for (u32 i = 0; i < 36; ++i)
{
float value = ai().level_graph().low_cover_in_direction(float(10*i)/180.f*PI,v);
direction.setHP (float(10*i)/180.f*PI,0);
direction.normalize ();
Expand Down
8 changes: 5 additions & 3 deletions src/xrGame/alife_group_abstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ void CSE_ALifeGroupAbstract::try_switch_offline ()
VERIFY (I);

// iterating on group members
for (u32 i=0, N = (u32)m_tpMembers.size(); i<N; ++i) {
u32 memberCount = (u32)m_tpMembers.size();
u32 i;
for (i=0; i<memberCount; ++i) {
// casting group member to the abstract monster to get access to the Health property
CSE_ALifeMonsterAbstract *tpGroupMember = smart_cast<CSE_ALifeMonsterAbstract*>(ai().alife().objects().object(m_tpMembers[i]));
if (!tpGroupMember)
Expand Down Expand Up @@ -181,7 +183,7 @@ void CSE_ALifeGroupAbstract::try_switch_offline ()
tpGroupMember->m_bOnline = true;
--m_wCount;
--i;
--N;
--memberCount;
}

// checking if group is not empty
Expand All @@ -191,7 +193,7 @@ void CSE_ALifeGroupAbstract::try_switch_offline ()
if (!I->can_switch_offline())
return;

if (I->can_switch_online() || (i == N))
if (I->can_switch_online() || (i == memberCount))
I->alife().switch_offline (I);
}

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/console_commands_mp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class CCC_Dbg_NumObjects : public IConsole_Command {

u32 CLObjNum = Level().Objects.o_count();
xr_vector<u16> CObjID;
for (i=0; i<CLObjNum; i++)
for (u32 i=0; i<CLObjNum; i++)
{
CObjID.push_back(Level().Objects.o_get_by_iterator(i)->ID());
};
Expand Down
5 changes: 3 additions & 2 deletions src/xrGame/cover_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ void CCoverManager::compute_static_cover ()
m_temp.resize (ai().level_graph().header().vertex_count());

CLevelGraph const &graph = ai().level_graph();
for (u32 i=0, n = ai().level_graph().header().vertex_count(); i<n; ++i) {
u32 levelVertexCount = ai().level_graph().header().vertex_count();
for (u32 i=0; i<levelVertexCount; ++i) {
CLevelGraph::CVertex const &vertex = *graph.vertex(i);
if (vertex.high_cover(0) + vertex.high_cover(1) + vertex.high_cover(2) + vertex.high_cover(3)) {
m_temp[i] = edge_vertex(i);
Expand All @@ -104,7 +105,7 @@ void CCoverManager::compute_static_cover ()
m_temp[i] = false;
}

for (u32 i=0; i<n; ++i)
for (u32 i=0; i<levelVertexCount; ++i)
if (m_temp[i] && critical_cover(i))
m_covers->insert(xr_new<CCoverPoint>(ai().level_graph().vertex_position(ai().level_graph().vertex(i)),i));

Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/ef_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void CPatternFunction::vfLoadEF(LPCSTR caFileName)
m_dwaPatternIndexes = xr_alloc<u32>(m_dwPatternCount);
ZeroMemory (m_dwaPatternIndexes,m_dwPatternCount*sizeof(u32));
m_dwParameterCount = 0;
for ( i=0; i<m_dwPatternCount; ++i) {
for (u32 i=0; i<m_dwPatternCount; ++i) {
if (i)
m_dwaPatternIndexes[i] = m_dwParameterCount;
F->r (&(m_tpPatterns[i].dwCardinality),sizeof(m_tpPatterns[i].dwCardinality));
Expand Down Expand Up @@ -132,7 +132,7 @@ float CPatternFunction::ffGetValue()

int j = xr_sprintf(caString,sizeof(caString),"%32s (",m_caName);

for ( i=0; i<m_dwVariableCount; ++i)
for (u32 i=0; i<m_dwVariableCount; ++i)
j += xr_sprintf(caString + j, sizeof(caString)-j, " %3d",m_dwaVariableValues[i] + 1);

xr_sprintf (caString + j,sizeof(caString)-j, ") = %7.2f",value);
Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/ef_pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class CPatternFunction : public CBaseFunction {
IC u32 dwfGetPatternIndex(u32 *dwpTest, int iPatternIndex)
{
SPattern &tPattern = m_tpPatterns[iPatternIndex];
for (u32 i=1, dwIndex = dwpTest[tPattern.dwaVariableIndexes[0]]; i<(int)tPattern.dwCardinality; ++i)
u32 dwIndex = dwpTest[tPattern.dwaVariableIndexes[0]];
for (u32 i=1; i<(int)tPattern.dwCardinality; ++i)
dwIndex = dwIndex*m_dwaAtomicFeatureRange[tPattern.dwaVariableIndexes[i]] + dwpTest[tPattern.dwaVariableIndexes[i]];
return(dwIndex + m_dwaPatternIndexes[iPatternIndex]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/game_cl_base_weapon_usage_statistic_save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void Weapon_Statistic::Write(FILE* pFile)
if (Hit.Completed) NumHits++;
};
fwrite(&NumHits, 4, 1, pFile);
for (i=0; i<m_Hits.size(); i++)
for (u32 i=0; i<m_Hits.size(); i++)
{
HitData& Hit = m_Hits[i];
if (!Hit.Completed) continue;
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/ik/limb.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -990,9 +990,9 @@ void dump_file(char *file, int euler_type, float min[], float max[],
fprintf(fp, "%f %f %f \n", max[2], max[1], max[0]);
for (int i = 0; i < 4; i++)
fprintf(fp, "%f %f %f %f\n", c[i][0],c[i][1],c[i][2],c[i][3]);
for (i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
fprintf(fp, "%f %f %f %f\n", s[i][0],s[i][1],s[i][2],s[i][3]);
for (i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
fprintf(fp, "%f %f %f %f\n", o[i][0],o[i][1],o[i][2],o[i][3]);

fclose(fp);
Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/ini_id_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ CSINI_IdToIndex::~CIni_IdToIndex()
TEMPLATE_SPECIALIZATION
const typename ITEM_DATA* CSINI_IdToIndex::GetById (const T_ID& str_id, bool no_assert)
{
for(T_VECTOR::iterator it = m_pItemDataVector->begin();
T_VECTOR::iterator it;
for(it = m_pItemDataVector->begin();
m_pItemDataVector->end() != it; it++)
{
if(!xr_strcmp((*it).id, str_id))
Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/purchase_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ void CPurchaseList::process (const CGameObject &owner, const shared_str &name, c
const u32 &level_vertex_id = owner.ai_location().level_vertex_id();
const ALife::_OBJECT_ID &id = owner.ID();
CRandom random((u32)(CPU::QPC() & u32(-1)));
for (u32 i=0, j=0; i<count; ++i) {
u32 j = 0;
for (u32 i=0; i<count; ++i) {
if (random.randF() > probability)
continue;

Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/relation_registry_fights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ void RELATION_REGISTRY::FightRegister (u16 attacker, u16 defender, ALife::ERelat
UpdateFightRegister();

FIGHT_VECTOR& fights = fight_registry();
for(FIGHT_VECTOR_IT it = fights.begin(); it != fights.end(); it++)
FIGHT_VECTOR_IT it;
for(it = fights.begin(); it != fights.end(); it++)
{
FIGHT_DATA& fight_data = *it;
if(attacker == fight_data.attacker && defender == fight_data.defender)
Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/safe_map_iterator_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ IC u32 CSSafeMapIterator::update (const _update_predicate &predicate, bool co
++m_cycle_count;
_iterator I = next();
VERIFY (I != m_objects.end());
for (u32 i=0; (I != m_objects.end()) && !time_over() && predicate(I,m_cycle_count,true); ++i) {
u32 i;
for (i=0; (I != m_objects.end()) && !time_over() && predicate(I,m_cycle_count,true); ++i) {
update_next ();
predicate (I,m_cycle_count);
I = next();
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ui_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ sPoly2D* C2DFrustum::ClipPoly (sPoly2D& S, sPoly2D& D) const
cls[src->size()] = cls[0] ;
src->push_back((*src)[0]) ;
Fvector2 dir_pt,dir_uv; float denum,t;
for (j=0; j<src->size()-1; j++) {
for (u32 j=0; j<src->size()-1; j++) {
if ((*src)[j].pt.similar((*src)[j+1].pt,EPS_S)) continue;
if (negative(cls[j])) {
dest->push_back((*src)[j]) ;
Expand Down
13 changes: 6 additions & 7 deletions src/xrServerEntities/xml_str_id_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,17 @@ TEMPLATE_SPECIALIZATION
const typename ITEM_DATA* CSXML_IdToIndex::GetById (const shared_str& str_id, bool no_assert)
{
T_INIT::InitXmlIdToIndex();

for(T_VECTOR::iterator it = m_pItemDataVector->begin();
m_pItemDataVector->end() != it; it++)
T_VECTOR::iterator it;
for (it = m_pItemDataVector->begin(); m_pItemDataVector->end()!=it; it++)
{
if( (*it).id == str_id)
break;
if ((*it).id == str_id)
break;
}

if(m_pItemDataVector->end() == it)
if (it==m_pItemDataVector->end())
{
int i=0;
for(T_VECTOR::iterator it = m_pItemDataVector->begin(); m_pItemDataVector->end() != it; it++,i++)
for (it = m_pItemDataVector->begin(); m_pItemDataVector->end()!=it; it++, i++)
Msg("[%d]=[%s]",i,*(*it).id );

R_ASSERT3(no_assert, "item not found, id", *str_id);
Expand Down

0 comments on commit 9855d87

Please sign in to comment.