Skip to content

Commit 85eb522

Browse files
committed
Fixed some PVS-Studio warnings and minor editions
1 parent ebefabc commit 85eb522

File tree

7 files changed

+25
-30
lines changed

7 files changed

+25
-30
lines changed

src/xrGame/CarCameras.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,9 @@ void CCar::OnCameraChange(int type)
4747
if (Owner())
4848
{
4949
if (type == ectFirst)
50-
{
5150
Owner()->setVisible(FALSE);
52-
}
53-
else if (active_camera->tag == ectFirst)
54-
{
51+
else if (active_camera && active_camera->tag == ectFirst)
5552
Owner()->setVisible(TRUE);
56-
}
5753
}
5854

5955
if (!active_camera || active_camera->tag != type)

src/xrGame/ai/monsters/basemonster/base_monster_script.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,6 @@ void CBaseMonster::ProcessScripts()
455455
m_script_state_must_execute = false;
456456
inherited::ProcessScripts();
457457

458-
Device.dwTimeGlobal = Device.dwTimeGlobal;
459-
460458
// обновить мир (память, враги, объекты)
461459
UpdateMemory();
462460

src/xrGame/ai/monsters/monster_enemy_memory.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ void CMonsterEnemyMemory::update()
3232
VERIFY(monster->g_Alive());
3333

3434
CMonsterHitMemory& monster_hit_memory = monster->HitMemory;
35-
36-
typedef CObjectManager<const CEntityAlive>::OBJECTS objects_list;
37-
38-
objects_list const& objects = monster->memory().enemy().objects();
35+
36+
auto const& objects = monster->memory().enemy().objects();
3937

4038
if (monster_hit_memory.is_hit() && time() < monster_hit_memory.get_last_hit_time() + 1000)
4139
{
@@ -86,17 +84,18 @@ void CMonsterEnemyMemory::update()
8684
}
8785
}
8886

89-
for (objects_list::const_iterator I = objects.begin(); I != objects.end(); ++I)
87+
float const feel_enemy_max_distance = monster->get_feel_enemy_max_distance();
88+
89+
for (auto I = objects.cbegin(); I != objects.cend(); ++I)
9090
{
9191
const CEntityAlive* enemy = *I;
9292
const bool feel_enemy =
93-
monster->Position().distance_to(enemy->Position()) < monster->get_feel_enemy_max_distance();
93+
monster->Position().distance_to(enemy->Position()) < feel_enemy_max_distance;
9494

9595
if (feel_enemy || monster->memory().visual().visible_now(*I))
9696
add_enemy(*I);
9797
}
9898

99-
float const feel_enemy_max_distance = monster->get_feel_enemy_max_distance();
10099
if (g_actor)
101100
{
102101
float const xz_dist = monster->Position().distance_to_xz(g_actor->Position());
@@ -129,6 +128,7 @@ void CMonsterEnemyMemory::add_enemy(const CEntityAlive* enemy)
129128
enemy_info.time = Device.dwTimeGlobal;
130129
enemy_info.danger = 0.f;
131130

131+
// XXX: review
132132
ENEMIES_MAP_IT it = m_objects.find(enemy);
133133
if (it != m_objects.end())
134134
{
@@ -185,18 +185,18 @@ void CMonsterEnemyMemory::remove_non_actual()
185185

186186
const CEntityAlive* CMonsterEnemyMemory::get_enemy()
187187
{
188-
ENEMIES_MAP_IT it = find_best_enemy();
188+
const auto it = find_best_enemy();
189189
if (it != m_objects.end())
190190
return it->first;
191-
return (0);
191+
return nullptr;
192192
}
193193

194194
SMonsterEnemy CMonsterEnemyMemory::get_enemy_info()
195195
{
196196
SMonsterEnemy ret_val;
197197
ret_val.time = 0;
198198

199-
ENEMIES_MAP_IT it = find_best_enemy();
199+
const auto it = find_best_enemy();
200200
if (it != m_objects.end())
201201
ret_val = it->second;
202202

@@ -241,9 +241,7 @@ ENEMIES_MAP_IT CMonsterEnemyMemory::find_best_enemy()
241241
void CMonsterEnemyMemory::remove_links(IGameObject* O)
242242
{
243243
if (monster)
244-
{
245244
monster->EnemyMan.remove_links(O);
246-
}
247245

248246
for (ENEMIES_MAP_IT I = m_objects.begin(); I != m_objects.end(); ++I)
249247
{

src/xrGame/detail_path_manager_smooth.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,8 @@ void CDetailPathManager::postprocess_key_points(const xr_vector<u32>& level_path
752752
compute_better_key_point(m_key_points[i - 1], m_key_points[i], m_key_points[i + 1], false);
753753
STravelPoint key_point1 =
754754
compute_better_key_point(m_key_points[i + 1], m_key_points[i], m_key_points[i - 1], true);
755+
756+
// XXX: check out what is this
755757
{
756758
u32 vertex_id = ai().level_graph().check_position_in_direction(
757759
m_key_points[i - 1].vertex_id, m_key_points[i - 1].position, key_point0.position);

src/xrGame/ui/UIGameTutorialSimpleItem.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ void CUISequenceSimpleItem::Start()
250250
bool bShowPda = false;
251251
CUIGameSP* ui_game_sp = smart_cast<CUIGameSP*>(CurrentGameUI());
252252

253+
if (!ui_game_sp)
254+
{
255+
Msg("!%s:: failed to get ui_game_sp", __FUNCTION__);
256+
return;
257+
}
258+
253259
if (!xr_stricmp(m_pda_section, "pda_tasks"))
254260
{
255261
ui_game_sp->GetPdaMenu().SetActiveSubdialog("eptTasks");
@@ -271,13 +277,8 @@ void CUISequenceSimpleItem::Start()
271277
bShowPda = true;
272278
}
273279

274-
if (ui_game_sp)
275-
{
276-
if ((!ui_game_sp->GetPdaMenu().IsShown() && bShowPda) || (ui_game_sp->GetPdaMenu().IsShown() && !bShowPda))
277-
{
278-
ui_game_sp->GetPdaMenu().HideDialog();
279-
}
280-
}
280+
if ((!ui_game_sp->GetPdaMenu().IsShown() && bShowPda) || (ui_game_sp->GetPdaMenu().IsShown() && !bShowPda))
281+
ui_game_sp->GetPdaMenu().HideDialog();
281282
}
282283
}
283284

src/xrGame/ui/UILines.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,9 @@ u32 CUILines::GetColorFromText(const xr_string& str) const
454454
}
455455

456456
// try parse values separated by commas
457-
comma1_pos = str.find(",", begin);
458-
comma2_pos = str.find(",", comma1_pos + 1);
459-
comma3_pos = str.find(",", comma2_pos + 1);
457+
comma1_pos = str.find(',', begin);
458+
comma2_pos = str.find(',', comma1_pos + 1);
459+
comma3_pos = str.find(',', comma2_pos + 1);
460460
if (comma1_pos == npos || comma2_pos == npos || comma3_pos == npos)
461461
return m_dwTextColor;
462462

src/xrGame/ui/UIMessageBox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ LPCSTR CUIMessageBox::GetHost()
390390
{
391391
m_ret_val.clear();
392392
xr_string tmp = m_UIEditHost->GetText();
393-
xr_string::size_type pos = tmp.find(":");
393+
xr_string::size_type pos = tmp.find(':');
394394

395395
if (xr_string::npos != pos)
396396
{

0 commit comments

Comments
 (0)