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;
};
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)
{}
};

View File

@ -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();
}
};

View File

@ -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)
{}
};

View File

@ -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
{

View File

@ -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);

View File

@ -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 ||

View File

@ -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);

View File

@ -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];
}
}
}

View File

@ -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()

View File

@ -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()

View File

@ -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;

View File

@ -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,

View File

@ -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());

View File

@ -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);