Skip to content

Commit

Permalink
Initialized unitialized variables in the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Jun 3, 2018
1 parent b7797f8 commit 6868992
Show file tree
Hide file tree
Showing 84 changed files with 190 additions and 138 deletions.
7 changes: 4 additions & 3 deletions src/xrCDB/ISpatial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,13 @@ void ISpatial_NODE::_remove(ISpatial* S)

ISpatial_DB::ISpatial_DB(const char* name) :
#ifdef CONFIG_PROFILE_LOCKS
pcs(new Lock(MUTEX_PROFILE_ID(ISpatial_DB)))
pcs(new Lock(MUTEX_PROFILE_ID(ISpatial_DB))),
#else
pcs(new Lock)
pcs(new Lock),
#endif // CONFIG_PROFILE_LOCKS
rt_insert_object(nullptr), m_root(nullptr),
m_bounds(0), q_result(nullptr)
{
m_root = NULL;
xr_strcpy(Name, name);
}

Expand Down
2 changes: 1 addition & 1 deletion src/xrEngine/EffectorPP.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ENGINE_API CEffectorPP : public SBaseEffector

public:
CEffectorPP(EEffectorPPType type, f32 lifeTime, bool free_on_remove = true);
CEffectorPP() : bFreeOnRemove(true), fLifeTime(0.0f), bOverlap(true){};
CEffectorPP() : bFreeOnRemove(true), fLifeTime(0.0f), bOverlap(true) {};
virtual ~CEffectorPP();
BENCH_SEC_SCRAMBLEVTBL1
virtual BOOL Process(SPPInfo& PPInfo);
Expand Down
1 change: 1 addition & 0 deletions src/xrEngine/Stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ void CStats::Show()
{
font.SetColor(color_rgba(255, 16, 16, 191));
font.OutSet(400, 0);

for (u32 it = (u32)_max(int(0), (int)errors.size() - g_ErrorLineCount); it < errors.size(); it++)
font.OutNext("%s", errors[it].c_str());
}
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/ActorEffector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,12 @@ CCameraEffectorControlled::~CCameraEffectorControlled() { m_controller->SetCam(N
BOOL CCameraEffectorControlled::Valid() { return m_controller->Valid(); }
#define SND_MIN_VOLUME_FACTOR (0.1f)

SndShockEffector::SndShockEffector()
SndShockEffector::SndShockEffector() : m_end_time(0), m_life_time(0)
{
m_snd_length = 0.0f;
m_cur_length = 0.0f;
m_stored_volume = -1.0f;
m_actor = NULL;
m_actor = nullptr;
}

SndShockEffector::~SndShockEffector()
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/BastArtifact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
#include "xrPhysics/extendedgeom.h"
#include "ParticlesObject.h"

CBastArtefact::CBastArtefact(void)
CBastArtefact::CBastArtefact(void) : m_pHitedEntity(nullptr)
{
m_fImpulseThreshold = 10.f;

m_fRadius = 10.f;
m_fStrikeImpulse = 15.f;

m_bStrike = false;
m_AttakingEntity = NULL;
m_AttakingEntity = nullptr;

m_fEnergy = 0.f;
m_fEnergyMax = m_fStrikeImpulse * 100.f;
Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/BoneProtections.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ struct SBoneProtections
float m_fHitFracActor;
typedef xr_map<s16, BoneProtection> storage_type;
typedef storage_type::iterator storage_it;
SBoneProtections()
SBoneProtections() : m_fHitFracNpc(0)

This comment has been minimized.

Copy link
@revolucas

revolucas Jun 16, 2018

Contributor

May as well initialize m_default.BonePassBullet to 0, also

{
m_default.koeff = 1.0f;
m_default.armor = 0;
m_fHitFracActor = 0.1f;
}

BoneProtection m_default;
storage_type m_bones_koeff;
void reload(const shared_str& outfit_section, IKinematics* kinematics);
Expand Down
5 changes: 4 additions & 1 deletion src/xrGame/Car.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class CCar : public CEntity,
void SetSteerLimits(float hi, float lo);

virtual void ApplyDamage(u16 level);
SWheel(CCar* acar)
SWheel(CCar* acar) : radius(0)
{
bone_id = BI_NONE;
car = acar;
Expand Down Expand Up @@ -321,6 +321,9 @@ class CCar : public CEntity,
};
eState state;
SDoor(CCar* acar)
: update(false), pos_open(0),
opened_angle(0), closed_angle(0),
open_time(0)
{
bone_id = BI_NONE;
pcar = acar;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/CarSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// extern CPHWorld* ph_world;
#include "xrPhysics/IPHWorld.h"
CCar::SCarSound::SCarSound(CCar* car)
CCar::SCarSound::SCarSound(CCar* car) : eCarSound(), engine_start_delay(0), time_state_start(0)
{
volume = 1.f;
pcar = car;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ClimableObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ IC void OrientToNorm(const Fvector& normal, Fmatrix& form, Fobb& box)
}
}

CClimableObject::CClimableObject() : m_pStaticShell(NULL), m_material(u16(-1)) {}
CClimableObject::CClimableObject() : m_pStaticShell(nullptr), m_radius(0), m_material(u16(-1)) {}
CClimableObject::~CClimableObject() {}
void CClimableObject::Load(LPCSTR section) { inherited::Load(section); }
BOOL CClimableObject::net_Spawn(CSE_Abstract* DC)
Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/CustomDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include "player_hud.h"
#include "weapon.h"

ITEM_INFO::ITEM_INFO()
ITEM_INFO::ITEM_INFO() : snd_time(0), cur_period(0)
{
pParticle = NULL;
curr_ref = NULL;
pParticle = nullptr;
curr_ref = nullptr;
}

ITEM_INFO::~ITEM_INFO()
Expand All @@ -25,7 +25,7 @@ ITEM_INFO::~ITEM_INFO()

bool CCustomDetector::CheckCompatibilityInt(CHudItem* itm, u16* slot_to_activate)
{
if (itm == NULL)
if (itm == nullptr)
return true;

CInventoryItem& iitm = itm->item();
Expand Down
4 changes: 3 additions & 1 deletion src/xrGame/EffectorBobbing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CEffectorBobbing::CEffectorBobbing() : CEffectorCam(eCEBobbing, 10000.f)
CEffectorBobbing::CEffectorBobbing()
: CEffectorCam(eCEBobbing, 10000.f), fYAmplitude(0),
fSpeed(0), dwMState(0), m_bZoomMode(false)
{
fTime = 0;
fReminderFactor = 0;
Expand Down
9 changes: 5 additions & 4 deletions src/xrGame/GameTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
#include "ui/uitexturemaster.h"

CGameTask::CGameTask()
: m_map_object_id(0), m_TimeToComplete(0), m_priority(0)
{
m_ReceiveTime = 0;
m_FinishTime = 0;
m_timer_finish = 0;
m_Title = NULL;
m_Description = NULL;
m_ID = NULL;
m_Title = nullptr;
m_Description = nullptr;
m_ID = nullptr;
m_task_type = eTaskTypeDummy;
m_task_state = eTaskStateDummy;
m_linked_map_location = NULL;
m_linked_map_location = nullptr;
m_read = false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/HUDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void CFontManager::Render()
}
void CFontManager::OnDeviceReset() { InitializeFonts(); }
//--------------------------------------------------------------------
CHUDManager::CHUDManager() : pUIGame(NULL), m_pHUDTarget(new CHUDTarget()) {}
CHUDManager::CHUDManager() : pUIGame(nullptr), m_pHUDTarget(new CHUDTarget()), b_online(false) {}
//--------------------------------------------------------------------
CHUDManager::~CHUDManager()
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Hit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "xrEngine/xr_object.h"

SHit::SHit(float powerA, Fvector& dirA, IGameObject* whoA, u16 elementA, Fvector p_in_bone_spaceA, float impulseA,
ALife::EHitType hit_typeA, float armor_piercingA, bool AimBullet)
ALife::EHitType hit_typeA, float armor_piercingA, bool AimBullet) : Time(0), DestID(0), weaponID(0)
{
power = powerA;
dir.set(dirA);
Expand Down
5 changes: 2 additions & 3 deletions src/xrGame/IKFoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
#endif

CIKFoot::CIKFoot()
: m_bind_b2_to_b3(Fidentity), m_ref_bone(u16(-1)), m_foot_bone_id(BI_NONE), m_toe_bone_id(BI_NONE), m_K(0)
{
}
: m_K(nullptr), m_bind_b2_to_b3(Fidentity), m_foot_width(0),
m_ref_bone(u16(-1)), m_foot_bone_id(BI_NONE), m_toe_bone_id(BI_NONE) {}

void CIKFoot::Create(IKinematics* K, LPCSTR section, u16 bones[4])
{
Expand Down
4 changes: 3 additions & 1 deletion src/xrGame/IKLimbsController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#include "PHDebug.h"
#endif // DEBUG

CIKLimbsController::CIKLimbsController() : m_object(0), m_legs_blend(0) {}
CIKLimbsController::CIKLimbsController()
: m_legs_blend(0), m_object(nullptr), anim_name(nullptr), anim_set_name(nullptr) {}

void CIKLimbsController::Create(CGameObject* O)
{
VERIFY(O);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/LevelGraphDebugRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "debug_renderer.h"
#include "xrEngine/GameFont.h"

LevelGraphDebugRender::LevelGraphDebugRender()
LevelGraphDebugRender::LevelGraphDebugRender() : gameGraph(nullptr), levelGraph(nullptr)
{
debugShader->create("debug\\ai_nodes", "$null");
currentLevelId = -1;
Expand Down
4 changes: 1 addition & 3 deletions src/xrGame/Message_Filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class message_filter
struct msg_type_subtype_t
{
msg_type_subtype_t(u16 const type = 0, u32 const subtype = 0, u32 const recv_time = 0)
: msg_type(type), msg_subtype(subtype), msg_receive_time(recv_time)
{
}
: msg_type(type), dest_obj_id(0), msg_subtype(subtype), msg_receive_time(recv_time) {}

u16 msg_type;
u16 dest_obj_id;
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/PHScriptCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ bool CPHScriptObjectCondition::is_true() { return luabind::call_member<bool>(*m_
bool CPHScriptObjectCondition::obsolete() const { return false; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CPHScriptObjectActionN::CPHScriptObjectActionN(const luabind::object& object, const luabind::functor<void>& functor)
: b_obsolete(false)
{
m_callback.set(functor, object);
}
Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/PhraseDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ SPhraseDialogData::SPhraseDialogData()
}

SPhraseDialogData::~SPhraseDialogData() {}
CPhraseDialog::CPhraseDialog()
CPhraseDialog::CPhraseDialog() : m_bFirstIsSpeaking(false)
{
m_SaidPhraseID = "";
m_bFinished = false;
m_pSpeakerFirst = NULL;
m_pSpeakerSecond = NULL;
m_DialogId = NULL;
m_pSpeakerFirst = nullptr;
m_pSpeakerSecond = nullptr;
m_DialogId = nullptr;
}

CPhraseDialog::~CPhraseDialog() {}
Expand Down
6 changes: 2 additions & 4 deletions src/xrGame/PhysicObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
#endif
BOOL dbg_draw_doors = false;
CPhysicObject::CPhysicObject(void)
: m_anim_blend(0), m_type(epotBox), m_mass(10.f), m_collision_hit_callback(0), bones_snd_player(0),
m_net_updateData(0)
{
}
: m_type(epotBox), m_mass(10.f), m_collision_hit_callback(nullptr), m_anim_blend(nullptr),
bones_snd_player(nullptr), m_net_updateData(nullptr), m_just_after_spawn(false), m_activated(false) {}

CPhysicObject::~CPhysicObject(void) { xr_delete(m_net_updateData); }
BOOL CPhysicObject::net_Spawn(CSE_Abstract* DC)
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/action_planner_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
_condition_evaluator_ptr>

TEMPLATE_SPECIALIZATION
IC CPlanner::CActionPlanner() : m_initialized(false), m_solving(false)
IC CPlanner::CActionPlanner() : m_initialized(false), m_loaded(false), m_solving(false)
{
#ifdef LOG_ACTION
m_use_log = false;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/actor_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct net_update
float fHealth;
// float fArmor;

net_update()
net_update() : o_model(0), mstate(0), weapon(0), fHealth(0)
{
dwTimeStamp = 0;
p_pos.set(0, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ai/monsters/ai_monster_squad.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct SMemberGoal
Fvector position;
u32 node;

SMemberGoal()
SMemberGoal() : node(0)
{
type = MG_None;
entity = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ai/monsters/burer/burer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CBurer : public CBaseMonster, public CTelekinesis

const CEntityAlive* enemy;

GraviObject()
GraviObject() : time_last_update(0)
{
active = false;
enemy = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

template <typename Object>
CStateBurerAttackGravi<Object>::CStateBurerAttackGravi(Object* obj) : inherited(obj)
CStateBurerAttackGravi<Object>::CStateBurerAttackGravi(Object* obj)
: inherited(obj), m_action(), m_time_gravi_started(0)
{
m_next_gravi_allowed_tick = 0;
m_anim_end_tick = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#define DIST_QUANT 10.f

TEMPLATE_SPECIALIZATION
CStateBurerAttackRunAroundAbstract::CStateBurerAttackRunAround(_Object* obj) : inherited(obj) {}
CStateBurerAttackRunAroundAbstract::CStateBurerAttackRunAround(_Object* obj) : inherited(obj), time_started(0) {}

TEMPLATE_SPECIALIZATION
void CStateBurerAttackRunAroundAbstract::initialize()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

template <class Object>
CStateBurerShield<Object>::CStateBurerShield(Object* obj) : inherited(obj)
CStateBurerShield<Object>::CStateBurerShield(Object* obj) : inherited(obj), m_started(false)
{
m_last_shield_started = 0;
m_shield_start_anim_length_sec = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#define MAX_TIME_CHECK_FAILURE 6000

template <typename Object>
CStateBurerAttackTele<Object>::CStateBurerAttackTele(Object* obj) : inherited(obj)
CStateBurerAttackTele<Object>::CStateBurerAttackTele(Object* obj)
: inherited(obj), selected_object(nullptr), time_started(0),
m_action(), m_end_tick(0), m_initial_health(0)
{
m_anim_end_tick = 0;
m_last_grenade_scan = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#define CStateChimeraThreatenAbstract CStateChimeraThreaten<_Object>

TEMPLATE_SPECIALIZATION
CStateChimeraThreatenAbstract::CStateChimeraThreaten(_Object* obj) : inherited(obj)
CStateChimeraThreatenAbstract::CStateChimeraThreaten(_Object* obj)
: inherited(obj), m_last_time_threaten(0)
{
add_state(eStateWalk, new CStateChimeraThreatenWalk<_Object>(obj));
add_state(eStateThreaten, new CStateChimeraThreatenRoar<_Object>(obj));
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/ai/monsters/control_manager_custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "control_critical_wound.h"

CControlManagerCustom::CControlManagerCustom()
: m_critical_wound(nullptr), m_threaten_anim(nullptr), m_threaten_time(0)
{
m_sequencer = 0;
m_triple_anim = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#define TIME_TO_EAT 20000

TEMPLATE_SPECIALIZATION
CStateGroupEatingAbstract::CStateGroupEating(_Object* obj) : inherited(obj) {}
CStateGroupEatingAbstract::CStateGroupEating(_Object* obj)
: inherited(obj), corpse(nullptr), time_last_eat(0) {}

TEMPLATE_SPECIALIZATION
CStateGroupEatingAbstract::~CStateGroupEating() {}
TEMPLATE_SPECIALIZATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const float scare_distance2enemy = 20.f; // distance on which dog can be scared
//////////////////////////////////////////////////////////////////////////

TEMPLATE_SPECIALIZATION
CStateGroupAttackMoveToHomePointAbstract::CStateGroupAttackMoveToHomePoint(_Object* obj) : inherited(obj)
CStateGroupAttackMoveToHomePointAbstract::CStateGroupAttackMoveToHomePoint(_Object* obj)
: inherited(obj), m_target_node(0), m_skip_camp(false), m_state_started(0)
{
add_state(eStateAttack_HomePoint_Hide, new CStateMonsterMoveToPointEx<_Object>(obj));
add_state(eStateAttack_HomePoint_LookOpenPlace, new CStateMonsterLookToPoint<_Object>(obj));
Expand Down
Loading

0 comments on commit 6868992

Please sign in to comment.