summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2013-05-27 22:26:44 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2013-05-27 22:29:42 +0200
commitb22d852b4c4aa89e0394397a703ecfa442b0a928 (patch)
treea1e29142aabf11393eb3e0604deb4b89a6124fe7
parent12313fecf5a0ccad45f88575a24582b8363bd5a7 (diff)
downloadcolobot-b22d852b4c4aa89e0394397a703ecfa442b0a928.tar.gz
colobot-b22d852b4c4aa89e0394397a703ecfa442b0a928.tar.bz2
colobot-b22d852b4c4aa89e0394397a703ecfa442b0a928.zip
Fixed variable shadowing warnings
* fixed -Wshadow warnings * refactored some constructors
-rw-r--r--src/common/event.h19
-rw-r--r--src/graphics/core/color.h8
-rw-r--r--src/graphics/engine/engine.h47
-rw-r--r--src/graphics/engine/modelmanager.h6
-rw-r--r--src/graphics/engine/particle.cpp6
-rw-r--r--src/graphics/engine/pyro.cpp12
-rw-r--r--src/graphics/engine/text.cpp2
-rw-r--r--src/math/matrix.h8
-rw-r--r--src/math/point.h15
-rw-r--r--src/math/vector.h18
-rw-r--r--src/object/motion/motionhuman.cpp8
-rw-r--r--src/object/robotmain.cpp19
-rw-r--r--src/ui/maindialog.cpp6
-rw-r--r--src/ui/shortcut.cpp2
14 files changed, 93 insertions, 83 deletions
diff --git a/src/common/event.h b/src/common/event.h
index 97b798a..8aef603 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -730,16 +730,15 @@ struct Event
ActiveEventData active;
};
- Event(EventType type = EVENT_NULL)
- {
- this->type = type;
-
- systemEvent = false;
- rTime = 0.0f;
- mouseButtonsState = 0;
- trackedKeysState = 0;
- customParam = 0;
- }
+ explicit Event(EventType _type = EVENT_NULL)
+ : type(_type)
+ , systemEvent(false)
+ , rTime(0.0f)
+ , kmodState(0)
+ , trackedKeysState(0)
+ , mouseButtonsState(0)
+ , customParam(0)
+ {}
};
diff --git a/src/graphics/core/color.h b/src/graphics/core/color.h
index 3546611..87a50f4 100644
--- a/src/graphics/core/color.h
+++ b/src/graphics/core/color.h
@@ -139,10 +139,10 @@ struct ColorHSV
//! Returns a string "(h, s, v)"
inline std::string ToString() const
{
- std::stringstream s;
- s.precision(3);
- s << "(" << h << ", " << s << ", " << v << ")";
- return s.str();
+ std::stringstream str;
+ str.precision(3);
+ str << "(" << h << ", " << s << ", " << v << ")";
+ return str.str();
}
};
diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h
index 8763a4e..27aa5dc 100644
--- a/src/graphics/engine/engine.h
+++ b/src/graphics/engine/engine.h
@@ -194,10 +194,15 @@ struct EngineBaseObjDataTier
unsigned int staticBufferId;
bool updateStaticBuffer;
- inline EngineBaseObjDataTier(EngineTriangleType type = ENG_TRIANGLE_TYPE_TRIANGLES,
- const Material& material = Material(),
- int state = ENG_RSTATE_NORMAL)
- : type(type), material(material), state(state), staticBufferId(0), updateStaticBuffer(false) {}
+ inline EngineBaseObjDataTier(EngineTriangleType _type = ENG_TRIANGLE_TYPE_TRIANGLES,
+ const Material& _material = Material(),
+ int _state = ENG_RSTATE_NORMAL)
+ : type(_type)
+ , material(_material)
+ , state(_state)
+ , staticBufferId(0)
+ , updateStaticBuffer(false)
+ {}
};
/**
@@ -209,8 +214,9 @@ struct EngineBaseObjLODTier
LODLevel lodLevel;
std::vector<EngineBaseObjDataTier> next;
- inline EngineBaseObjLODTier(LODLevel lodLevel = LOD_Constant)
- : lodLevel(lodLevel) {}
+ inline EngineBaseObjLODTier(LODLevel _lodLevel = LOD_Constant)
+ : lodLevel(_lodLevel)
+ {}
};
/**
@@ -225,8 +231,10 @@ struct EngineBaseObjTexTier
Texture tex2;
std::vector<EngineBaseObjLODTier> next;
- inline EngineBaseObjTexTier(const std::string& tex1Name = "", const std::string& tex2Name = "")
- : tex1Name(tex1Name), tex2Name(tex2Name) {}
+ inline EngineBaseObjTexTier(const std::string& _tex1Name = "", const std::string& _tex2Name = "")
+ : tex1Name(_tex1Name)
+ , tex2Name(_tex2Name)
+ {}
};
/**
@@ -556,18 +564,17 @@ struct EngineMouse
//! Hot point
Math::Point hotPoint;
- inline EngineMouse(int icon1 = -1, int icon2 = -1, int iconShadow = -1,
- EngineRenderState mode1 = ENG_RSTATE_NORMAL,
- EngineRenderState mode2 = ENG_RSTATE_NORMAL,
- Math::Point hotPoint = Math::Point())
- {
- this->icon1 = icon1;
- this->icon2 = icon2;
- this->iconShadow = iconShadow;
- this->mode1 = mode1;
- this->mode2 = mode2;
- this->hotPoint = hotPoint;
- }
+ inline EngineMouse(int _icon1 = -1, int _icon2 = -1, int _iconShadow = -1,
+ EngineRenderState _mode1 = ENG_RSTATE_NORMAL,
+ EngineRenderState _mode2 = ENG_RSTATE_NORMAL,
+ Math::Point _hotPoint = Math::Point())
+ : icon1(_icon1)
+ , icon2(_icon2)
+ , iconShadow(_iconShadow)
+ , mode1(_mode1)
+ , mode2(_mode2)
+ , hotPoint(_hotPoint)
+ {}
};
diff --git a/src/graphics/engine/modelmanager.h b/src/graphics/engine/modelmanager.h
index 26ee130..9d50b97 100644
--- a/src/graphics/engine/modelmanager.h
+++ b/src/graphics/engine/modelmanager.h
@@ -79,8 +79,10 @@ private:
std::string fileName;
bool mirrored;
- inline FileInfo(const std::string& fileName, bool mirrored)
- : fileName(fileName), mirrored(mirrored) {}
+ inline FileInfo(const std::string& _fileName, bool _mirrored)
+ : fileName(_fileName)
+ , mirrored(_mirrored)
+ {}
inline bool operator<(const FileInfo& other) const
{
diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp
index 10b945e..abee2e2 100644
--- a/src/graphics/engine/particle.cpp
+++ b/src/graphics/engine/particle.cpp
@@ -3553,9 +3553,9 @@ void CParticle::DrawParticle(int sheet)
{
m_engine->SetTexture("text.png");
m_engine->SetState(ENG_RSTATE_TTEXTURE_WHITE);
- Math::Matrix mat;
- mat.LoadIdentity();
- m_device->SetTransform(TRANSFORM_WORLD, mat);
+ Math::Matrix matrix;
+ matrix.LoadIdentity();
+ m_device->SetTransform(TRANSFORM_WORLD, matrix);
for (int i = 0; i < m_wheelTraceTotal; i++)
DrawParticleWheel(i);
diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp
index 975a211..0a85beb 100644
--- a/src/graphics/engine/pyro.cpp
+++ b/src/graphics/engine/pyro.cpp
@@ -89,13 +89,15 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
DisplayError(type, obj); // displays eventual messages
- int i = 0;
- // Copies all spheres of the object.
- for (; i < 50; i++)
{
- if ( !obj->GetCrashSphere(i, m_crashSpherePos[i], m_crashSphereRadius[i]) ) break;
+ int i = 0;
+ // Copies all spheres of the object.
+ for (; i < 50; i++)
+ {
+ if ( !obj->GetCrashSphere(i, m_crashSpherePos[i], m_crashSphereRadius[i]) ) break;
+ }
+ m_crashSphereUsed = i;
}
- m_crashSphereUsed = i;
// Calculates the size of the effect.
if ( oType == OBJECT_ANT ||
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index 9bc8bd0..610bfcf 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -613,7 +613,7 @@ void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::itera
float cw = GetCharWidth(ch, font, size, offset);
if (offset + cw > width) // exceeds the maximum width?
{
- UTF8Char ch = TranslateSpecialChar(CHAR_SKIP_RIGHT);
+ ch = TranslateSpecialChar(CHAR_SKIP_RIGHT);
cw = GetCharWidth(ch, font, size, offset);
pos.x = start + width - cw;
color = Color(1.0f, 0.0f, 0.0f);
diff --git a/src/math/matrix.h b/src/math/matrix.h
index 67ccb48..a13f823 100644
--- a/src/math/matrix.h
+++ b/src/math/matrix.h
@@ -73,10 +73,10 @@ struct Matrix
//! Creates the matrix from 1D array
/** \a m matrix values in column-major order */
- inline explicit Matrix(const float (&m)[16])
+ inline explicit Matrix(const float (&_m)[16])
{
for (int i = 0; i < 16; ++i)
- this->m[i] = m[i];
+ m[i] = _m[i];
}
//! Creates the matrix from 2D array
@@ -84,13 +84,13 @@ struct Matrix
* The array's first index is row, second is column.
* \param m array with values
*/
- inline explicit Matrix(const float (&m)[4][4])
+ inline explicit Matrix(const float (&_m)[4][4])
{
for (int c = 0; c < 4; ++c)
{
for (int r = 0; r < 4; ++r)
{
- this->m[4*c+r] = m[r][c];
+ m[4*c+r] = _m[r][c];
}
}
}
diff --git a/src/math/point.h b/src/math/point.h
index 65de94c..edb902b 100644
--- a/src/math/point.h
+++ b/src/math/point.h
@@ -52,16 +52,15 @@ struct Point
//! Constructs a zero point: (0,0)
inline Point()
- {
- LoadZero();
- }
+ : x(0.0f)
+ , y(0.0f)
+ {}
//! Constructs a point from given coords: (x,y)
- inline explicit Point(float x, float y)
- {
- this->x = x;
- this->y = y;
- }
+ inline explicit Point(float _x, float _y)
+ : x(_x)
+ , y(_y)
+ {}
//! Sets the zero point: (0,0)
inline void LoadZero()
diff --git a/src/math/vector.h b/src/math/vector.h
index 38886d0..6827785 100644
--- a/src/math/vector.h
+++ b/src/math/vector.h
@@ -57,17 +57,17 @@ struct Vector
//! Creates a zero vector (0, 0, 0)
inline Vector()
- {
- LoadZero();
- }
+ : x(0.0f)
+ , y(0.0f)
+ , z(0.0f)
+ {}
//! Creates a vector from given values
- inline explicit Vector(float x, float y, float z)
- {
- this->x = x;
- this->y = y;
- this->z = z;
- }
+ inline explicit Vector(float _x, float _y, float _z)
+ : x(_x)
+ , y(_y)
+ , z(_z)
+ {}
//! Loads the zero vector (0, 0, 0)
inline void LoadZero()
diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp
index b1de44e..edee260 100644
--- a/src/object/motion/motionhuman.cpp
+++ b/src/object/motion/motionhuman.cpp
@@ -1617,18 +1617,18 @@ bool CMotionHuman::EventFrame(const Event &event)
legAction == MH_MARCHTAKE )
{
Sound sound[2];
- float speed, synchro, volume[2], freq[2], hard, level;
+ float synchro, volume[2], freq[2], hard;
- speed = m_physics->GetLinMotionX(MO_REASPEED);
+ float speedX = m_physics->GetLinMotionX(MO_REASPEED);
if ( m_object->GetFret() == 0 )
{
- if ( speed > 0.0f ) synchro = 0.21f; // synchro forward
+ if ( speedX > 0.0f ) synchro = 0.21f; // synchro forward
else synchro = 0.29f; // synchro backward
}
else
{
- if ( speed > 0.0f ) synchro = 0.15f; // synchro forward
+ if ( speedX > 0.0f ) synchro = 0.15f; // synchro forward
else synchro = 0.35f; // synchro backward
}
time = rTime[1]+synchro;
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 34f13f6..27492f3 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -4082,7 +4082,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "CacheAudio") && !resetObject && m_version >= 2)
{
- char filename[100];
OpString(line, "filename", filename);
m_sound->CacheMusic(filename);
continue;
@@ -4116,9 +4115,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
int trackid = OpInt(line, "track", 0);
if (trackid != 0)
{
- std::stringstream filename;
- filename << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg";
- m_audioTrack = filename.str();
+ std::stringstream filenameStr;
+ filenameStr << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg";
+ m_audioTrack = filenameStr.str();
}
}
else
@@ -4392,10 +4391,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
AddExt(name, ".png");
int dx = OpInt(line, "dx", 1);
int dy = OpInt(line, "dy", 1);
- char* op = SearchOp(line, "table");
+ char* opTable = SearchOp(line, "table");
int tt[100];
for (int i = 0; i < dx*dy; i++)
- tt[i] = GetInt(op, i, 0);
+ tt[i] = GetInt(opTable, i, 0);
if (strstr(name, "%user%") != 0)
CopyFileListToTemp(name, tt, dx*dy);
@@ -4484,12 +4483,12 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
continue;
}
- char* op = SearchOp(line, "id");
+ char* opId = SearchOp(line, "id");
int id[50];
int i = 0;
while (i < 50)
{
- id[i] = GetInt(op, i, 0);
+ id[i] = GetInt(opId, i, 0);
if (id[i++] == 0) break;
}
@@ -4589,9 +4588,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
}
Math::Vector pos = OpPos(line, "pos")*g_unit;
- float dir = OpFloat(line, "dir", 0.0f)*Math::PI;
+ float dirAngle = OpFloat(line, "dir", 0.0f)*Math::PI;
bool trainer = OpInt(line, "trainer", 0);
- CObject* obj = CreateObject(pos, dir,
+ CObject* obj = CreateObject(pos, dirAngle,
OpFloat(line, "z", 1.0f),
OpFloat(line, "h", 0.0f),
type,
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index dfc2d52..8f5b936 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -3677,8 +3677,9 @@ void CMainDialog::ReadNameList()
{
fs::directory_iterator dirIt(m_savegameDir), dirEndIt;
- BOOST_FOREACH (const fs::path & p, std::make_pair(dirIt, dirEndIt))
+ for (; dirIt != dirEndIt; ++dirIt)
{
+ const fs::path& p = *dirIt;
if (fs::is_directory(p))
{
fileNames.push_back(p.leaf().string());
@@ -4745,8 +4746,9 @@ void CMainDialog::UpdateSceneChap(int &chap)
fs::directory_iterator dirIt(m_savegameDir), dirEndIt;
m_userList.clear();
- BOOST_FOREACH (const fs::path & p, std::make_pair(dirIt, dirEndIt))
+ for (; dirIt != dirEndIt; ++dirIt)
{
+ const fs::path& p = *dirIt;
if (fs::is_directory(p))
{
m_userList.push_back(p.leaf().string());
diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp
index 7231d5d..a01864a 100644
--- a/src/ui/shortcut.cpp
+++ b/src/ui/shortcut.cpp
@@ -128,7 +128,7 @@ void CShortcut::Draw()
if ( m_state & STATE_FRAME )
{
Math::Point p1, p2, c, uv1, uv2;
- float zoom, dp;
+ float dp;
m_engine->SetTexture("button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);