Fixed variable shadowing warnings

* fixed -Wshadow warnings
 * refactored some constructors
dev-ui
Piotr Dziwinski 2013-05-27 22:26:44 +02:00
parent 12313fecf5
commit b22d852b4c
14 changed files with 93 additions and 83 deletions

View File

@ -730,16 +730,15 @@ struct Event
ActiveEventData active; ActiveEventData active;
}; };
Event(EventType type = EVENT_NULL) explicit Event(EventType _type = EVENT_NULL)
{ : type(_type)
this->type = type; , systemEvent(false)
, rTime(0.0f)
systemEvent = false; , kmodState(0)
rTime = 0.0f; , trackedKeysState(0)
mouseButtonsState = 0; , mouseButtonsState(0)
trackedKeysState = 0; , customParam(0)
customParam = 0; {}
}
}; };

View File

@ -139,10 +139,10 @@ struct ColorHSV
//! Returns a string "(h, s, v)" //! Returns a string "(h, s, v)"
inline std::string ToString() const inline std::string ToString() const
{ {
std::stringstream s; std::stringstream str;
s.precision(3); str.precision(3);
s << "(" << h << ", " << s << ", " << v << ")"; str << "(" << h << ", " << s << ", " << v << ")";
return s.str(); return str.str();
} }
}; };

View File

@ -194,10 +194,15 @@ struct EngineBaseObjDataTier
unsigned int staticBufferId; unsigned int staticBufferId;
bool updateStaticBuffer; bool updateStaticBuffer;
inline EngineBaseObjDataTier(EngineTriangleType type = ENG_TRIANGLE_TYPE_TRIANGLES, inline EngineBaseObjDataTier(EngineTriangleType _type = ENG_TRIANGLE_TYPE_TRIANGLES,
const Material& material = Material(), const Material& _material = Material(),
int state = ENG_RSTATE_NORMAL) int _state = ENG_RSTATE_NORMAL)
: type(type), material(material), state(state), staticBufferId(0), updateStaticBuffer(false) {} : type(_type)
, material(_material)
, state(_state)
, staticBufferId(0)
, updateStaticBuffer(false)
{}
}; };
/** /**
@ -209,8 +214,9 @@ struct EngineBaseObjLODTier
LODLevel lodLevel; LODLevel lodLevel;
std::vector<EngineBaseObjDataTier> next; std::vector<EngineBaseObjDataTier> next;
inline EngineBaseObjLODTier(LODLevel lodLevel = LOD_Constant) inline EngineBaseObjLODTier(LODLevel _lodLevel = LOD_Constant)
: lodLevel(lodLevel) {} : lodLevel(_lodLevel)
{}
}; };
/** /**
@ -225,8 +231,10 @@ struct EngineBaseObjTexTier
Texture tex2; Texture tex2;
std::vector<EngineBaseObjLODTier> next; std::vector<EngineBaseObjLODTier> next;
inline EngineBaseObjTexTier(const std::string& tex1Name = "", const std::string& tex2Name = "") inline EngineBaseObjTexTier(const std::string& _tex1Name = "", const std::string& _tex2Name = "")
: tex1Name(tex1Name), tex2Name(tex2Name) {} : tex1Name(_tex1Name)
, tex2Name(_tex2Name)
{}
}; };
/** /**
@ -556,18 +564,17 @@ struct EngineMouse
//! Hot point //! Hot point
Math::Point hotPoint; Math::Point hotPoint;
inline EngineMouse(int icon1 = -1, int icon2 = -1, int iconShadow = -1, inline EngineMouse(int _icon1 = -1, int _icon2 = -1, int _iconShadow = -1,
EngineRenderState mode1 = ENG_RSTATE_NORMAL, EngineRenderState _mode1 = ENG_RSTATE_NORMAL,
EngineRenderState mode2 = ENG_RSTATE_NORMAL, EngineRenderState _mode2 = ENG_RSTATE_NORMAL,
Math::Point hotPoint = Math::Point()) Math::Point _hotPoint = Math::Point())
{ : icon1(_icon1)
this->icon1 = icon1; , icon2(_icon2)
this->icon2 = icon2; , iconShadow(_iconShadow)
this->iconShadow = iconShadow; , mode1(_mode1)
this->mode1 = mode1; , mode2(_mode2)
this->mode2 = mode2; , hotPoint(_hotPoint)
this->hotPoint = hotPoint; {}
}
}; };

View File

@ -79,8 +79,10 @@ private:
std::string fileName; std::string fileName;
bool mirrored; bool mirrored;
inline FileInfo(const std::string& fileName, bool mirrored) inline FileInfo(const std::string& _fileName, bool _mirrored)
: fileName(fileName), mirrored(mirrored) {} : fileName(_fileName)
, mirrored(_mirrored)
{}
inline bool operator<(const FileInfo& other) const inline bool operator<(const FileInfo& other) const
{ {

View File

@ -3553,9 +3553,9 @@ void CParticle::DrawParticle(int sheet)
{ {
m_engine->SetTexture("text.png"); m_engine->SetTexture("text.png");
m_engine->SetState(ENG_RSTATE_TTEXTURE_WHITE); m_engine->SetState(ENG_RSTATE_TTEXTURE_WHITE);
Math::Matrix mat; Math::Matrix matrix;
mat.LoadIdentity(); matrix.LoadIdentity();
m_device->SetTransform(TRANSFORM_WORLD, mat); m_device->SetTransform(TRANSFORM_WORLD, matrix);
for (int i = 0; i < m_wheelTraceTotal; i++) for (int i = 0; i < m_wheelTraceTotal; i++)
DrawParticleWheel(i); DrawParticleWheel(i);

View File

@ -89,13 +89,15 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
DisplayError(type, obj); // displays eventual messages 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. // Calculates the size of the effect.
if ( oType == OBJECT_ANT || if ( oType == OBJECT_ANT ||

View File

@ -613,7 +613,7 @@ void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::itera
float cw = GetCharWidth(ch, font, size, offset); float cw = GetCharWidth(ch, font, size, offset);
if (offset + cw > width) // exceeds the maximum width? 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); cw = GetCharWidth(ch, font, size, offset);
pos.x = start + width - cw; pos.x = start + width - cw;
color = Color(1.0f, 0.0f, 0.0f); color = Color(1.0f, 0.0f, 0.0f);

View File

@ -73,10 +73,10 @@ struct Matrix
//! Creates the matrix from 1D array //! Creates the matrix from 1D array
/** \a m matrix values in column-major order */ /** \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) for (int i = 0; i < 16; ++i)
this->m[i] = m[i]; m[i] = _m[i];
} }
//! Creates the matrix from 2D array //! Creates the matrix from 2D array
@ -84,13 +84,13 @@ struct Matrix
* The array's first index is row, second is column. * The array's first index is row, second is column.
* \param m array with values * \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 c = 0; c < 4; ++c)
{ {
for (int r = 0; r < 4; ++r) for (int r = 0; r < 4; ++r)
{ {
this->m[4*c+r] = m[r][c]; m[4*c+r] = _m[r][c];
} }
} }
} }

View File

@ -52,16 +52,15 @@ struct Point
//! Constructs a zero point: (0,0) //! Constructs a zero point: (0,0)
inline Point() inline Point()
{ : x(0.0f)
LoadZero(); , y(0.0f)
} {}
//! Constructs a point from given coords: (x,y) //! Constructs a point from given coords: (x,y)
inline explicit Point(float x, float y) inline explicit Point(float _x, float _y)
{ : x(_x)
this->x = x; , y(_y)
this->y = y; {}
}
//! Sets the zero point: (0,0) //! Sets the zero point: (0,0)
inline void LoadZero() inline void LoadZero()

View File

@ -57,17 +57,17 @@ struct Vector
//! Creates a zero vector (0, 0, 0) //! Creates a zero vector (0, 0, 0)
inline Vector() inline Vector()
{ : x(0.0f)
LoadZero(); , y(0.0f)
} , z(0.0f)
{}
//! Creates a vector from given values //! Creates a vector from given values
inline explicit Vector(float x, float y, float z) inline explicit Vector(float _x, float _y, float _z)
{ : x(_x)
this->x = x; , y(_y)
this->y = y; , z(_z)
this->z = z; {}
}
//! Loads the zero vector (0, 0, 0) //! Loads the zero vector (0, 0, 0)
inline void LoadZero() inline void LoadZero()

View File

@ -1617,18 +1617,18 @@ bool CMotionHuman::EventFrame(const Event &event)
legAction == MH_MARCHTAKE ) legAction == MH_MARCHTAKE )
{ {
Sound sound[2]; 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 ( 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 synchro = 0.29f; // synchro backward
} }
else 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 else synchro = 0.35f; // synchro backward
} }
time = rTime[1]+synchro; time = rTime[1]+synchro;

View File

@ -4082,7 +4082,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "CacheAudio") && !resetObject && m_version >= 2) if (Cmd(line, "CacheAudio") && !resetObject && m_version >= 2)
{ {
char filename[100];
OpString(line, "filename", filename); OpString(line, "filename", filename);
m_sound->CacheMusic(filename); m_sound->CacheMusic(filename);
continue; continue;
@ -4116,9 +4115,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
int trackid = OpInt(line, "track", 0); int trackid = OpInt(line, "track", 0);
if (trackid != 0) if (trackid != 0)
{ {
std::stringstream filename; std::stringstream filenameStr;
filename << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg"; filenameStr << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg";
m_audioTrack = filename.str(); m_audioTrack = filenameStr.str();
} }
} }
else else
@ -4392,10 +4391,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
AddExt(name, ".png"); AddExt(name, ".png");
int dx = OpInt(line, "dx", 1); int dx = OpInt(line, "dx", 1);
int dy = OpInt(line, "dy", 1); int dy = OpInt(line, "dy", 1);
char* op = SearchOp(line, "table"); char* opTable = SearchOp(line, "table");
int tt[100]; int tt[100];
for (int i = 0; i < dx*dy; i++) 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) if (strstr(name, "%user%") != 0)
CopyFileListToTemp(name, tt, dx*dy); CopyFileListToTemp(name, tt, dx*dy);
@ -4484,12 +4483,12 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
continue; continue;
} }
char* op = SearchOp(line, "id"); char* opId = SearchOp(line, "id");
int id[50]; int id[50];
int i = 0; int i = 0;
while (i < 50) while (i < 50)
{ {
id[i] = GetInt(op, i, 0); id[i] = GetInt(opId, i, 0);
if (id[i++] == 0) break; 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; 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); bool trainer = OpInt(line, "trainer", 0);
CObject* obj = CreateObject(pos, dir, CObject* obj = CreateObject(pos, dirAngle,
OpFloat(line, "z", 1.0f), OpFloat(line, "z", 1.0f),
OpFloat(line, "h", 0.0f), OpFloat(line, "h", 0.0f),
type, type,

View File

@ -3677,8 +3677,9 @@ void CMainDialog::ReadNameList()
{ {
fs::directory_iterator dirIt(m_savegameDir), dirEndIt; 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)) if (fs::is_directory(p))
{ {
fileNames.push_back(p.leaf().string()); fileNames.push_back(p.leaf().string());
@ -4745,8 +4746,9 @@ void CMainDialog::UpdateSceneChap(int &chap)
fs::directory_iterator dirIt(m_savegameDir), dirEndIt; fs::directory_iterator dirIt(m_savegameDir), dirEndIt;
m_userList.clear(); 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)) if (fs::is_directory(p))
{ {
m_userList.push_back(p.leaf().string()); m_userList.push_back(p.leaf().string());

View File

@ -128,7 +128,7 @@ void CShortcut::Draw()
if ( m_state & STATE_FRAME ) if ( m_state & STATE_FRAME )
{ {
Math::Point p1, p2, c, uv1, uv2; Math::Point p1, p2, c, uv1, uv2;
float zoom, dp; float dp;
m_engine->SetTexture("button2.png"); m_engine->SetTexture("button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);