summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZaba999 <zaba.marcin@gmail.com>2012-09-18 00:01:00 +0200
committerZaba999 <zaba.marcin@gmail.com>2012-09-18 00:01:00 +0200
commita397922e8d53c6f7ff469d38e5139fd003c705b5 (patch)
tree8f6e92a0ac59d655e5fcc48bd198aa1bae25f0db
parent844e11db4f394004258cdca8f8fd8bc95c41a985 (diff)
downloadcolobot-a397922e8d53c6f7ff469d38e5139fd003c705b5.tar.gz
colobot-a397922e8d53c6f7ff469d38e5139fd003c705b5.tar.bz2
colobot-a397922e8d53c6f7ff469d38e5139fd003c705b5.zip
warnings fight in progress.
-rw-r--r--lib/simpleini/SimpleIni.h46
-rw-r--r--src/CBot/CBotString.cpp21
-rw-r--r--src/app/app.h8
-rw-r--r--src/app/system_windows.h8
-rw-r--r--src/common/event.cpp4
-rw-r--r--src/common/global.h4
-rw-r--r--src/common/metafile.cpp4
-rw-r--r--src/common/misc.cpp4
-rw-r--r--src/common/misc.h2
-rw-r--r--src/graphics/engine/particle.cpp2
-rw-r--r--src/graphics/engine/particle.h2
-rw-r--r--src/object/auto/autosafe.cpp4
-rw-r--r--src/object/brain.cpp10
-rw-r--r--src/object/motion/motionhuman.cpp3
-rw-r--r--src/object/robotmain.cpp100
-rw-r--r--src/object/robotmain.h10
-rw-r--r--src/script/cbottoken.cpp10
-rw-r--r--src/script/cbottoken.h10
-rw-r--r--src/script/script.cpp1
-rw-r--r--src/ui/displayinfo.cpp10
-rw-r--r--src/ui/displaytext.cpp6
-rw-r--r--src/ui/edit.cpp36
-rw-r--r--src/ui/list.cpp8
-rw-r--r--src/ui/maindialog.cpp6
-rw-r--r--src/ui/maindialog.h6
-rw-r--r--src/ui/mainmap.cpp70
-rw-r--r--src/ui/mainshort.cpp2
27 files changed, 190 insertions, 207 deletions
diff --git a/lib/simpleini/SimpleIni.h b/lib/simpleini/SimpleIni.h
index f9f36bb..c75408e 100644
--- a/lib/simpleini/SimpleIni.h
+++ b/lib/simpleini/SimpleIni.h
@@ -422,7 +422,7 @@ public:
}
bool ConvertToStore(const SI_CHAR * a_pszString) {
size_t uLen = SizeToStore(a_pszString);
- if (uLen == (size_t)(-1)) {
+ if (uLen == static_cast<size_t>(-1)) {
return false;
}
while (uLen > m_scratch.size()) {
@@ -1360,7 +1360,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::LoadFile(
}
fseek(a_fpFile, 0, SEEK_SET);
size_t uRead = fread(pData, sizeof(char), lSize, a_fpFile);
- if (uRead != (size_t) lSize) {
+ if (uRead != static_cast<size_t>(lSize)) {
delete[] pData;
return SI_FILE;
}
@@ -1394,7 +1394,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::LoadData(
// determine the length of the converted data
size_t uLen = converter.SizeFromStore(a_pData, a_uDataLen);
- if (uLen == (size_t)(-1)) {
+ if (uLen == static_cast<size_t>(-1)) {
return SI_FAIL;
}
@@ -1753,7 +1753,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::LoadMultiLineText(
// move this line down to the location that it should be if necessary
if (pDataLine < pCurrLine) {
- size_t nLen = (size_t) (a_pData - pCurrLine);
+ size_t nLen = static_cast<size_t> (a_pData - pCurrLine);
memmove(pDataLine, pCurrLine, nLen * sizeof(SI_CHAR));
pDataLine[nLen] = '\0';
}
@@ -1816,10 +1816,10 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::CopyString(
{
size_t uLen = 0;
if (sizeof(SI_CHAR) == sizeof(char)) {
- uLen = strlen((const char *)a_pString);
+ uLen = strlen(static_cast<const char *>(a_pString));
}
else if (sizeof(SI_CHAR) == sizeof(wchar_t)) {
- uLen = wcslen((const wchar_t *)a_pString);
+ uLen = wcslen(reinterpret_cast<const wchar_t *>(a_pString));
}
else {
for ( ; a_pString[uLen]; ++uLen) /*loop*/ ;
@@ -2225,7 +2225,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::GetSectionSize(
// if multi-key isn't permitted then the section size is
// the number of keys that we have.
if (!m_bAllowMultiKey || section.empty()) {
- return (int) section.size();
+ return static_cast<int> (section.size());
}
// otherwise we need to count them
@@ -2626,7 +2626,7 @@ struct SI_GenericCase {
bool operator()(const SI_CHAR * pLeft, const SI_CHAR * pRight) const {
long cmp;
for ( ;*pLeft && *pRight; ++pLeft, ++pRight) {
- cmp = (long) *pLeft - (long) *pRight;
+ cmp = static_cast<long> (*pLeft) - static_cast<long> (*pRight);
if (cmp != 0) {
return cmp < 0;
}
@@ -2649,7 +2649,7 @@ struct SI_GenericNoCase {
bool operator()(const SI_CHAR * pLeft, const SI_CHAR * pRight) const {
long cmp;
for ( ;*pLeft && *pRight; ++pLeft, ++pRight) {
- cmp = (long) locase(*pLeft) - (long) locase(*pRight);
+ cmp = static_cast<long> (locase(*pLeft)) - static_cast<long> (locase(*pRight));
if (cmp != 0) {
return cmp < 0;
}
@@ -2741,7 +2741,7 @@ public:
const SI_CHAR * a_pInputData)
{
// ASCII/MBCS/UTF-8 needs no conversion
- return strlen((const char *)a_pInputData) + 1;
+ return strlen(static_cast<const char *>(a_pInputData)) + 1;
}
/** Convert the input string to the storage format of this data.
@@ -2763,7 +2763,7 @@ public:
size_t a_uOutputDataSize)
{
// calc input string length (SI_CHAR type and size independent)
- size_t uInputLen = strlen((const char *)a_pInputData) + 1;
+ size_t uInputLen = strlen(static_cast<const char *>(a_pInputData)) + 1;
if (uInputLen > a_uOutputDataSize) {
return false;
}
@@ -3195,12 +3195,12 @@ template<class SI_CHAR>
struct SI_NoCase {
bool operator()(const SI_CHAR * pLeft, const SI_CHAR * pRight) const {
if (sizeof(SI_CHAR) == sizeof(char)) {
- return _mbsicmp((const unsigned char *)pLeft,
- (const unsigned char *)pRight) < 0;
+ return _mbsicmp(reinterpret_cast<const unsigned char *>(pLeft),
+ reinterpret_cast<const unsigned char *>(pRight)) < 0;
}
if (sizeof(SI_CHAR) == sizeof(wchar_t)) {
- return _wcsicmp((const wchar_t *)pLeft,
- (const wchar_t *)pRight) < 0;
+ return _wcsicmp(reinterpret_cast<const wchar_t *>(pLeft),
+ reinterpret_cast<const wchar_t *>(pRight)) < 0;
}
return SI_GenericNoCase<SI_CHAR>()(pLeft, pRight);
}
@@ -3251,9 +3251,9 @@ public:
int retval = MultiByteToWideChar(
m_uCodePage, 0,
- a_pInputData, (int) a_uInputDataLen,
+ a_pInputData, static_cast<int> (a_uInputDataLen),
0, 0);
- return (size_t)(retval > 0 ? retval : -1);
+ return static_cast<size_t>(retval > 0 ? retval : -1);
}
/** Convert the input string from the storage format to SI_CHAR.
@@ -3277,8 +3277,8 @@ public:
{
int nSize = MultiByteToWideChar(
m_uCodePage, 0,
- a_pInputData, (int) a_uInputDataLen,
- (wchar_t *) a_pOutputData, (int) a_uOutputDataSize);
+ a_pInputData, static_cast<int> (a_uInputDataLen),
+ static_cast<wchar_t *> (a_pOutputData), static_cast<int> (a_uOutputDataSize));
return (nSize > 0);
}
@@ -3297,9 +3297,9 @@ public:
{
int retval = WideCharToMultiByte(
m_uCodePage, 0,
- (const wchar_t *) a_pInputData, -1,
+ static_cast<const wchar_t *> (a_pInputData), -1,
0, 0, 0, 0);
- return (size_t) (retval > 0 ? retval : -1);
+ return static_cast<size_t> (retval > 0 ? retval : -1);
}
/** Convert the input string to the storage format of this data.
@@ -3322,8 +3322,8 @@ public:
{
int retval = WideCharToMultiByte(
m_uCodePage, 0,
- (const wchar_t *) a_pInputData, -1,
- a_pOutputData, (int) a_uOutputDataSize, 0, 0);
+ static_cast<const wchar_t *> (a_pInputData), -1,
+ a_pOutputData, static_cast<int> (a_uOutputDataSize), 0, 0);
return retval > 0;
}
};
diff --git a/src/CBot/CBotString.cpp b/src/CBot/CBotString.cpp
index 7223e6f..84f9ca2 100644
--- a/src/CBot/CBotString.cpp
+++ b/src/CBot/CBotString.cpp
@@ -597,18 +597,6 @@ static void DestructElements(CBotString* pOldData, int nCount)
}
}
-static void CopyElements(CBotString* pDest, CBotString* pSrc, int nCount)
-{
- while (nCount--)
- {
- *pDest = *pSrc;
- ++pDest;
- ++pSrc;
- }
-}
-
-
-
// set the array size
void CBotStringArray::SetSize(int nNewSize)
@@ -618,15 +606,14 @@ void CBotStringArray::SetSize(int nNewSize)
// shrink to nothing
DestructElements(m_pData, m_nSize);
-// delete[] static_cast<unsigned char *>(m_pData);
- delete[] (unsigned char *)m_pData;
+ delete[] reinterpret_cast<unsigned char *>(m_pData);
m_pData = NULL;
m_nSize = m_nMaxSize = 0;
}
else if (m_pData == NULL)
{
// create one with exact size
- m_pData = (CBotString*) new unsigned char[nNewSize * sizeof(CBotString)];
+ m_pData = reinterpret_cast<CBotString*> (new unsigned char[nNewSize * sizeof(CBotString)]);
ConstructElements(m_pData, nNewSize);
@@ -663,7 +650,7 @@ void CBotStringArray::SetSize(int nNewSize)
else
nNewMax = nNewSize; // no slush
- CBotString* pNewData = (CBotString*) new unsigned char[nNewMax * sizeof(CBotString)];
+ CBotString* pNewData = reinterpret_cast<CBotString*> (new unsigned char[nNewMax * sizeof(CBotString)]);
// copy new data from old
memcpy(pNewData, m_pData, m_nSize * sizeof(CBotString));
@@ -673,7 +660,7 @@ void CBotStringArray::SetSize(int nNewSize)
// Get rid of old stuff (note: no destructors called)
- delete[] (unsigned char *)m_pData;
+ delete[] reinterpret_cast<unsigned char *>(m_pData);
m_pData = pNewData;
m_nSize = nNewSize;
m_nMaxSize = nNewMax;
diff --git a/src/app/app.h b/src/app/app.h
index 1834a67..849f441 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -129,11 +129,11 @@ enum InputSlot
struct InputBinding
{
//! Key
- int key;
+ unsigned int key;
//! Key modifier (e.g. shift, control)
- int kmod;
+ unsigned int kmod;
//! Joystick button
- int joy;
+ unsigned int joy;
inline InputBinding()
{
@@ -142,7 +142,7 @@ struct InputBinding
inline void Reset()
{
- key = kmod = joy = -1;
+ key = kmod = joy = static_cast<unsigned int>(-1);
}
};
diff --git a/src/app/system_windows.h b/src/app/system_windows.h
index 72d9f88..c9743e6 100644
--- a/src/app/system_windows.h
+++ b/src/app/system_windows.h
@@ -48,18 +48,18 @@ struct SystemTimeStamp
// Convert a wide Unicode string to an UTF8 string
std::string UTF8_Encode_Windows(const std::wstring &wstr)
{
- int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
+ int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast<int>(wstr.size()), NULL, 0, NULL, NULL);
std::string strTo(size_needed, 0);
- WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
+ WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast<int>(wstr.size()), &strTo[0], size_needed, NULL, NULL);
return strTo;
}
// Convert an UTF8 string to a wide Unicode String
std::wstring UTF8_Decode_Windows(const std::string &str)
{
- int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
+ int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast<int>(str.size()), NULL, 0);
std::wstring wstrTo(size_needed, 0);
- MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
+ MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast<int>(str.size()), &wstrTo[0], size_needed);
return wstrTo;
}
diff --git a/src/common/event.cpp b/src/common/event.cpp
index d082ba9..87c8a5c 100644
--- a/src/common/event.cpp
+++ b/src/common/event.cpp
@@ -24,8 +24,8 @@ static EventType g_uniqueEventType = EVENT_USER;
EventType GetUniqueEventType()
{
- int i = (int)g_uniqueEventType+1;
- g_uniqueEventType = (EventType)i;
+ int i = static_cast<int>(g_uniqueEventType+1);
+ g_uniqueEventType = static_cast<EventType>(i);
return g_uniqueEventType;
}
diff --git a/src/common/global.h b/src/common/global.h
index 88f753e..9cb3dd9 100644
--- a/src/common/global.h
+++ b/src/common/global.h
@@ -118,7 +118,7 @@ enum KeyRank
// TODO: move to CRobotMain
extern long g_id; // unique identifier
-extern long g_build; // constructible buildings
-extern long g_researchDone; // research done
+extern int g_build; // constructible buildings
+extern int g_researchDone; // research done
extern long g_researchEnable; // research available
extern float g_unit; // conversion factor
diff --git a/src/common/metafile.cpp b/src/common/metafile.cpp
index d1692ce..4e7e916 100644
--- a/src/common/metafile.cpp
+++ b/src/common/metafile.cpp
@@ -34,7 +34,7 @@ static unsigned char table_codec[23] =
void Codec(void* buffer, int len, int start)
{
- unsigned char *b = (unsigned char*)buffer;
+ unsigned char *b = static_cast<unsigned char*>(buffer);
int i;
for ( i=0 ; i<len ; i++ )
@@ -350,7 +350,7 @@ int CMetaFile::MetaOpen(char *metaname)
strcpy(m_list[i].name, metaname); // memorized the name
fread(&m_list[i].total, sizeof(int), 1, m_list[i].stream);
- m_list[i].headers = (MetaHeader*)malloc(sizeof(MetaHeader)*m_list[i].total);
+ m_list[i].headers = static_cast<MetaHeader*>(malloc(sizeof(MetaHeader)*m_list[i].total));
offset = 4;
for ( j=0 ; j<m_list[i].total ; j++ )
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index 11f60ae..5344e0b 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -258,7 +258,7 @@ bool Xfer(char* src, char* dst)
return false;
}
- buffer = (char*)malloc(10000);
+ buffer = static_cast<char*>(malloc(10000));
while ( true )
{
@@ -338,7 +338,7 @@ bool CopyFileListToTemp(char* filename, int* list, int total)
// Adds an extension to file, if doesn't already one.
-void AddExt(char* filename, char* ext)
+void AddExt(char* filename, const char* ext)
{
if ( strchr(filename, '.') != 0 ) return; // already an extension?
strcat(filename, ext);
diff --git a/src/common/misc.h b/src/common/misc.h
index 002c910..dd559e4 100644
--- a/src/common/misc.h
+++ b/src/common/misc.h
@@ -46,6 +46,6 @@ extern void TimeToAscii(time_t time, char *buffer);
extern bool CopyFileToTemp(char* filename);
extern bool CopyFileListToTemp(char* filename, int* list, int total);
-extern void AddExt(char* filename, char* ext);
+extern void AddExt(char* filename, const char* ext);
extern void UserDir(bool bUser, char* dir);
extern void UserDir(char* buffer, const char* dir, const char* def);
diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp
index 37a3975..c177deb 100644
--- a/src/graphics/engine/particle.cpp
+++ b/src/graphics/engine/particle.cpp
@@ -200,7 +200,7 @@ void Gfx::CParticle::DrawParticle(int sheet)
// TODO!
}
-bool Gfx::CParticle::WriteWheelTrace(char *filename, int width, int height, Math::Vector dl, Math::Vector ur)
+bool Gfx::CParticle::WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur)
{
GetLogger()->Trace("CParticle::WriteWheelTrace() stub!\n");
// TODO!
diff --git a/src/graphics/engine/particle.h b/src/graphics/engine/particle.h
index c53aea5..f78e242 100644
--- a/src/graphics/engine/particle.h
+++ b/src/graphics/engine/particle.h
@@ -306,7 +306,7 @@ public:
void FrameParticle(float rTime);
void DrawParticle(int sheet);
- bool WriteWheelTrace(char *filename, int width, int height, Math::Vector dl, Math::Vector ur);
+ bool WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur);
protected:
void DeleteRank(int rank);
diff --git a/src/object/auto/autosafe.cpp b/src/object/auto/autosafe.cpp
index 82b1c12..ea0c183 100644
--- a/src/object/auto/autosafe.cpp
+++ b/src/object/auto/autosafe.cpp
@@ -414,9 +414,9 @@ int CAutoSafe::CountKeys()
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- oType = pObj->GetType();
if ( pObj->GetTruck() != 0 ) continue;
+ oType = pObj->GetType();
if ( oType != OBJECT_KEYa &&
oType != OBJECT_KEYb &&
oType != OBJECT_KEYc &&
@@ -588,7 +588,6 @@ CObject* CAutoSafe::SearchVehicle()
{
CObject* pObj;
Math::Vector cPos, oPos;
- ObjectType oType;
float dist;
int i;
@@ -599,7 +598,6 @@ CObject* CAutoSafe::SearchVehicle()
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- oType = pObj->GetType();
if ( pObj == m_object ) continue;
if ( pObj->GetTruck() != 0 ) continue;
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index d047185..3f2dcb2 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -2789,7 +2789,7 @@ void CBrain::TraceRecordStart()
}
delete m_traceRecordBuffer;
- m_traceRecordBuffer = (TraceRecord*)malloc(sizeof(TraceRecord)*MAXTRACERECORD);
+ m_traceRecordBuffer = static_cast<TraceRecord*>(malloc(sizeof(TraceRecord)*MAXTRACERECORD));
m_traceRecordIndex = 0;
}
@@ -2836,7 +2836,7 @@ void CBrain::TraceRecordFrame()
if ( color != m_traceColor )
{
- TraceRecordOper(TO_PEN, (float)color);
+ TraceRecordOper(TO_PEN, static_cast<float>(color));
}
m_traceOper = oper;
@@ -2858,7 +2858,7 @@ void CBrain::TraceRecordStop()
if ( m_traceRecordBuffer == 0 ) return;
max = 10000;
- buffer = (char*)malloc(max);
+ buffer = static_cast<char*>(malloc(max));
*buffer = 0;
strncat(buffer, "extern void object::AutoDraw()\n{\n", max-1);
@@ -2944,14 +2944,14 @@ bool CBrain::TraceRecordPut(char *buffer, int max, TraceOper oper, float param)
if ( oper == TO_TURN )
{
param = -param*180.0f/Math::PI;
- sprintf(line, "\tturn(%d);\n", (int)param);
+ sprintf(line, "\tturn(%d);\n", static_cast<int>(param));
//? sprintf(line, "\tturn(%.1f);\n", param);
strncat(buffer, line, max-1);
}
if ( oper == TO_PEN )
{
- color = (int)param;
+ color = static_cast<int>(param);
if ( color == -1 ) strncat(buffer, "\tpenup();\n", max-1);
if ( color == 1 ) strncat(buffer, "\tpendown(Black);\n", max-1);
if ( color == 8 ) strncat(buffer, "\tpendown(Yellow);\n", max-1);
diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp
index 2349e1e..560a0de 100644
--- a/src/object/motion/motionhuman.cpp
+++ b/src/object/motion/motionhuman.cpp
@@ -710,7 +710,7 @@ bool CMotionHuman::EventFrame(const Event &event)
float tSt[9], tNd[9];
float aa, bb, shield, deadFactor, level;
int i, ii, st, nd, action, legAction, armAction;
- bool bOnBoard, bSwim, bStop;
+ bool bOnBoard, bSwim;
if ( m_engine->GetPause() )
{
@@ -837,7 +837,6 @@ bool CMotionHuman::EventFrame(const Event &event)
m_armTimeSwim += Math::Min(Math::Max(s,a,3.0f),15.0f)*event.rTime*0.05f;
}
- bStop = ( s == 0.0f ); // stop?
prog = 0.0f;
if ( m_physics->GetLand() ) // on the ground?
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index fb683ae..c4da53d 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -87,8 +87,8 @@ const float UNIT = 4.0f;
// Global variables.
long g_id; // unique identifier
-long g_build; // constructible buildings
-long g_researchDone; // research done
+int g_build; // constructible buildings
+int g_researchDone; // research done
long g_researchEnable; // research available
float g_unit; // conversion factor
@@ -172,7 +172,7 @@ bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exceptio
// save the channel file
pVar = pThis->GetItem("handle");
- pVar->SetValInt((long)pFile);
+ pVar->SetValInt(reinterpret_cast<long>(pFile));
}
return true;
@@ -215,7 +215,7 @@ bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception
// don't open? no problem :)
if ( pVar->GetInit() != IS_DEF) return true;
- FILE* pFile= (FILE*)pVar->GetValInt();
+ FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
fclose(pFile);
m_CompteurFileOpen --;
@@ -282,7 +282,7 @@ bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
// Registered the channel file
pVar = pThis->GetItem("handle");
- pVar->SetValInt((long)pFile);
+ pVar->SetValInt(reinterpret_cast<long>(pFile));
pResult->SetValInt(true);
return true;
@@ -328,7 +328,7 @@ bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
- FILE* pFile= (FILE*)pVar->GetValInt();
+ FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
fclose(pFile);
m_CompteurFileOpen --;
@@ -365,7 +365,7 @@ bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
- FILE* pFile= (FILE*)pVar->GetValInt();
+ FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
int res = fputs(param+CBotString("\n"), pFile);
@@ -404,7 +404,7 @@ bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
- FILE* pFile= (FILE*)pVar->GetValInt();
+ FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
char chaine[2000];
int i;
@@ -445,7 +445,7 @@ bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
- FILE* pFile= (FILE*)pVar->GetValInt();
+ FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
pResult->SetValInt( feof( pFile ) );
@@ -604,15 +604,15 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app)
m_app = app;
- m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
- m_cloud = static_cast<Gfx::CCloud*>(m_iMan->SearchInstance(CLASS_CLOUD));
- m_lightning = static_cast<Gfx::CLightning*>(m_iMan->SearchInstance(CLASS_BLITZ));
- m_planet = static_cast<Gfx::CPlanet*>(m_iMan->SearchInstance(CLASS_PLANET));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
+ m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
+ m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
+ m_cloud = static_cast<Gfx::CCloud*>(m_iMan->SearchInstance(CLASS_CLOUD));
+ m_lightning = static_cast<Gfx::CLightning*>(m_iMan->SearchInstance(CLASS_BLITZ));
+ m_planet = static_cast<Gfx::CPlanet*>(m_iMan->SearchInstance(CLASS_PLANET));
+ m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
m_interface = new Ui::CInterface();
m_terrain = new Gfx::CTerrain(m_iMan);
@@ -682,15 +682,15 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app)
m_windowPos = Math::Point(0.15f, 0.17f);
m_windowDim = Math::Point(0.70f, 0.66f);
- float fValue;
- int iValue;
+ // TODO: profile
+ // float fValue;
+ // int iValue;
- /* TODO: profile
- if (GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue;
- if (GetLocalProfileFloat("Edit", "WindowPos.x", fValue)) m_windowPos.x = fValue;
- if (GetLocalProfileFloat("Edit", "WindowPos.y", fValue)) m_windowPos.y = fValue;
- if (GetLocalProfileFloat("Edit", "WindowDim.x", fValue)) m_windowDim.x = fValue;
- if (GetLocalProfileFloat("Edit", "WindowDim.y", fValue)) m_windowDim.y = fValue; */
+ // if (GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue;
+ // if (GetLocalProfileFloat("Edit", "WindowPos.x", fValue)) m_windowPos.x = fValue;
+ // if (GetLocalProfileFloat("Edit", "WindowPos.y", fValue)) m_windowPos.y = fValue;
+ // if (GetLocalProfileFloat("Edit", "WindowDim.x", fValue)) m_windowDim.x = fValue;
+ // if (GetLocalProfileFloat("Edit", "WindowDim.y", fValue)) m_windowDim.y = fValue;
m_IOPublic = false;
m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f);
@@ -737,7 +737,7 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app)
for (int i = 0; i < OBJECT_MAX; i++)
{
- ObjectType type = (ObjectType)i;
+ ObjectType type = static_cast<ObjectType>(i);
const char* token = GetObjectName(type);
if (token[0] != 0)
CBotProgram::DefineNum(token, type);
@@ -943,7 +943,7 @@ void CRobotMain::ChangePhase(Phase phase)
dim.y = 18.0f/480.0f;
pos.x = 50.0f/640.0f;
pos.y = 452.0f/480.0f;
- Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->CreateEdit(pos, dim, 0, EVENT_CMD));
+ Ui::CEdit* pe = dynamic_cast<Ui::CEdit*>(m_interface->CreateEdit(pos, dim, 0, EVENT_CMD));
if (pe == nullptr) return;
pe->ClearState(Ui::STATE_VISIBLE);
m_cmdEdit = false; // hidden for now
@@ -1145,7 +1145,7 @@ bool CRobotMain::EventProcess(const Event &event)
event.type == EVENT_KEY_DOWN &&
event.key.key == KEY(PAUSE)) // Pause ?
{
- Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
+ Ui::CEdit* pe = dynamic_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
if (pe == nullptr) return false;
pe->SetState(Ui::STATE_VISIBLE);
pe->SetFocus(true);
@@ -1157,7 +1157,7 @@ bool CRobotMain::EventProcess(const Event &event)
event.key.key == KEY(RETURN) && m_cmdEdit)
{
char cmd[50];
- Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
+ Ui::CEdit* pe = dynamic_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
if (pe == nullptr) return false;
pe->GetText(cmd, 50);
pe->SetText("");
@@ -1843,7 +1843,7 @@ void CRobotMain::StartDisplayInfo(int index, bool movie)
}
//! Beginning of the displaying of instructions
-void CRobotMain::StartDisplayInfo(char *filename, int index)
+void CRobotMain::StartDisplayInfo(const char *filename, int index)
{
if (m_cmdEdit) return;
@@ -1857,7 +1857,7 @@ void CRobotMain::StartDisplayInfo(char *filename, int index)
m_sound->MuteAll(true);
}
- Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
+ Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
if (pb != nullptr)
{
pb->ClearState(Ui::STATE_VISIBLE);
@@ -1889,7 +1889,7 @@ void CRobotMain::StopDisplayInfo()
if (!m_editLock)
{
- Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
+ Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
if (pb != nullptr)
pb->SetState(Ui::STATE_VISIBLE);
@@ -1930,7 +1930,7 @@ void CRobotMain::StartSuspend()
m_infoObject = DeselectAll(); // removes the control buttons
m_displayText->HideText(true);
- Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
+ Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
if (pb != nullptr)
pb->ClearState(Ui::STATE_VISIBLE);
@@ -1940,7 +1940,7 @@ void CRobotMain::StartSuspend()
//! End of dialogue during the game
void CRobotMain::StopSuspend()
{
- Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
+ Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
if (pb != nullptr)
pb->SetState(Ui::STATE_VISIBLE);
@@ -2047,7 +2047,7 @@ void CRobotMain::StartDisplayVisit(EventType event)
{
if (m_editLock) return;
- Ui::CWindow* pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
+ Ui::CWindow* pw = dynamic_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if (pw == nullptr) return;
if (event == EVENT_NULL) // visit by keyboard shortcut?
@@ -2064,10 +2064,10 @@ void CRobotMain::StartDisplayVisit(EventType event)
i --;
if (i < 0) i = Ui::MAXDTLINE-1;
- Ui::CButton* button = static_cast<Ui::CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_VISIT0+i)));
+ Ui::CButton* button = dynamic_cast<Ui::CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_VISIT0+i)));
if (button == nullptr || !button->TestState(Ui::STATE_ENABLE)) continue;
- Ui::CGroup* group = static_cast<Ui::CGroup*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_GROUP0+i)));
+ Ui::CGroup* group = dynamic_cast<Ui::CGroup*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_GROUP0+i)));
if (group != nullptr)
{
event = static_cast<EventType>(EVENT_DT_VISIT0+i);
@@ -2819,7 +2819,7 @@ void CRobotMain::CreateTooltip(Math::Point pos, const char* text)
m_interface->CreateWindows(pos, dim, 1, EVENT_TOOLTIP);
- Ui::CWindow* pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_TOOLTIP));
+ Ui::CWindow* pw = dynamic_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_TOOLTIP));
if (pw != nullptr)
{
pw->SetState(Ui::STATE_SHADOW);
@@ -2843,7 +2843,7 @@ void CRobotMain::HelpObject()
CObject* obj = GetSelect();
if (obj == nullptr) return;
- char* filename = GetHelpFilename(obj->GetType());
+ const char* filename = GetHelpFilename(obj->GetType());
if (filename[0] == 0) return;
StartDisplayInfo(filename, -1);
@@ -2919,7 +2919,7 @@ void CRobotMain::ChangeCamera()
}
//! Remote control the camera using the arrow keys
-void CRobotMain::KeyCamera(EventType type, long key)
+void CRobotMain::KeyCamera(EventType type, unsigned int key)
{
// TODO: rewrite key handling to input bindings
@@ -3068,14 +3068,14 @@ bool CRobotMain::EventFrame(const Event &event)
m_planet->EventProcess(event);
Ui::CMap* pm = nullptr;
- Ui::CWindow* pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ Ui::CWindow* pw = dynamic_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
{
pm = nullptr;
}
else
{
- pm = static_cast<Ui::CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ pm = dynamic_cast<Ui::CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm != nullptr) pm->FlushObject();
}
@@ -3510,7 +3510,7 @@ void CRobotMain::ScenePerso()
{
obj->SetDrawFront(true); // draws the interface
- CMotionHuman* mh = (CMotionHuman*)obj->GetMotion();
+ CMotionHuman* mh = static_cast<CMotionHuman*>(obj->GetMotion());
if (mh != nullptr)
mh->StartDisplayPerso();
}
@@ -5137,7 +5137,7 @@ void CRobotMain::SetShowLimit(int i, Gfx::ParticleType parti, CObject *obj,
m_showLimit[i].pos = pos;
m_showLimit[i].radius = radius;
m_showLimit[i].duration = duration;
- m_showLimit[i].total = (int)((radius*2.0f*Math::PI)/dist);
+ m_showLimit[i].total = static_cast<int>((radius*2.0f*Math::PI)/dist);
if (m_showLimit[i].total > MAXSHOWPARTI) m_showLimit[i].total = MAXSHOWPARTI;
m_showLimit[i].time = 0.0f;
@@ -5350,8 +5350,6 @@ void CRobotMain::LoadFileScript(CObject *obj, char* filename, int objRank,
ObjectType type = obj->GetType();
if (type == OBJECT_HUMAN) return;
- char* name = m_dialog->GetSceneName();
- int rank = m_dialog->GetSceneRank();
char fn[MAX_FNAME];
strcpy(fn, filename);
@@ -5523,7 +5521,7 @@ bool CRobotMain::IsBusy()
}
//! Writes an object into the backup file
-void CRobotMain::IOWriteObject(FILE *file, CObject* obj, char *cmd)
+void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd)
{
if (obj->GetType() == OBJECT_FIX) return;
@@ -5643,7 +5641,7 @@ bool CRobotMain::IOWriteScene(char *filename, char *filecbot, char *info)
sprintf(line, "Map zoom=%.2f\n", m_map->GetZoomMap());
fputs(line, file);
- sprintf(line, "DoneResearch bits=%d\n", g_researchDone);
+ sprintf(line, "DoneResearch bits=%d\n", static_cast<int>(g_researchDone));
fputs(line, file);
float sleep, delay, magnetic, progress;
@@ -5981,7 +5979,7 @@ void CRobotMain::ResetObject()
// Removes all pyrotechnic effects in progress.
while ( true )
{
- pyro = (CPyro*)m_iMan->SearchInstance(CLASS_PYRO, 0);
+ pyro = static_cast<CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, 0));
if ( pyro == 0 ) break;
pyro->DeleteObject();
@@ -6420,7 +6418,7 @@ void CRobotMain::SetSpeed(float speed)
{
// TODO: m_app->SetSimulationSpeed(speed);
- Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_SPEED));
+ Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_SPEED));
if (pb != nullptr)
{
if (speed == 1.0f)
diff --git a/src/object/robotmain.h b/src/object/robotmain.h
index db96016..96fdc51 100644
--- a/src/object/robotmain.h
+++ b/src/object/robotmain.h
@@ -201,7 +201,7 @@ public:
void FlushDisplayInfo();
void StartDisplayInfo(int index, bool movie);
- void StartDisplayInfo(char *filename, int index);
+ void StartDisplayInfo(const char *filename, int index);
void StopDisplayInfo();
char* GetDisplayInfoName(int index);
int GetDisplayInfoPosition(int index);
@@ -287,7 +287,7 @@ public:
bool IsBusy();
bool IOWriteScene(char *filename, char *filecbot, char *info);
CObject* IOReadScene(char *filename, char *filecbot);
- void IOWriteObject(FILE *file, CObject* pObj, char *cmd);
+ void IOWriteObject(FILE *file, CObject* pObj, const char *cmd);
CObject* IOReadObject(char *line, char* filename, int objRank);
int CreateSpot(Math::Vector pos, Gfx::Color color);
@@ -314,7 +314,7 @@ protected:
CObject* DetectObject(Math::Point pos);
void ChangeCamera();
void RemoteCamera(float pan, float zoom, float rTime);
- void KeyCamera(EventType event, long key);
+ void KeyCamera(EventType event, unsigned int key);
void AbortMovie();
bool IsSelectable(CObject* pObj);
void SelectOneObject(CObject* pObj, bool displayError=true);
@@ -446,8 +446,8 @@ protected:
char m_gamerName[100];
- long m_freeBuild; // constructible buildings
- long m_freeResearch; // researches possible
+ int m_freeBuild; // constructible buildings
+ int m_freeResearch; // researches possible
ShowLimit m_showLimit[MAXSHOWLIMIT];
diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp
index a9cc599..0bb368c 100644
--- a/src/script/cbottoken.cpp
+++ b/src/script/cbottoken.cpp
@@ -24,7 +24,7 @@
// Seeking the name of an object.
-char* GetObjectName(ObjectType type)
+const char* GetObjectName(ObjectType type)
{
if ( type == OBJECT_PORTICO ) return "Portico";
if ( type == OBJECT_BASE ) return "SpaceShip";
@@ -117,7 +117,7 @@ char* GetObjectName(ObjectType type)
// Seeking the name of a secondary object.
// (because Otto thinks that Germans do not like nuclear power)
-char* GetObjectAlias(ObjectType type)
+const char* GetObjectAlias(ObjectType type)
{
if ( type == OBJECT_NUCLEAR ) return "FuelCellPlant";
if ( type == OBJECT_URANIUM ) return "PlatinumOre";
@@ -130,7 +130,7 @@ char* GetObjectAlias(ObjectType type)
// Returns the help file to use for the object.
-char* GetHelpFilename(ObjectType type)
+const char* GetHelpFilename(ObjectType type)
{
if ( type == OBJECT_BASE ) return "help\\object\\base.txt";
if ( type == OBJECT_DERRICK ) return "help\\object\\derrick.txt";
@@ -215,7 +215,7 @@ char* GetHelpFilename(ObjectType type)
// Returns the help file to use for instruction.
-char* GetHelpFilename(const char *token)
+const char* GetHelpFilename(const char *token)
{
if ( strcmp(token, "if" ) == 0 ) return "help\\cbot\\if.txt";
if ( strcmp(token, "else" ) == 0 ) return "help\\cbot\\if.txt";
@@ -427,7 +427,7 @@ bool IsFunction(const char *token)
// Returns using a compact instruction.
-char* GetHelpText(const char *token)
+const char* GetHelpText(const char *token)
{
if ( strcmp(token, "if" ) == 0 ) return "if ( condition ) { bloc }";
if ( strcmp(token, "else" ) == 0 ) return "else { bloc }";
diff --git a/src/script/cbottoken.h b/src/script/cbottoken.h
index 4be5f03..1f2d6e7 100644
--- a/src/script/cbottoken.h
+++ b/src/script/cbottoken.h
@@ -25,12 +25,12 @@
// Procedures.
-extern char* GetObjectName(ObjectType type);
-extern char* GetObjectAlias(ObjectType type);
-extern char* GetHelpFilename(ObjectType type);
-extern char* GetHelpFilename(const char *token);
+extern const char* GetObjectName(ObjectType type);
+extern const char* GetObjectAlias(ObjectType type);
+extern const char* GetHelpFilename(ObjectType type);
+extern const char* GetHelpFilename(const char *token);
extern bool IsType(const char *token);
extern bool IsFunction(const char *token);
-extern char* GetHelpText(const char *token);
+extern const char* GetHelpText(const char *token);
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 4f7f1ee..bcf0bda 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -661,6 +661,7 @@ bool CScript::rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
}
a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ //TODO uninitialized variable
if ( Math::TestAngle(a, iAngle-focus/2.0f, iAngle+focus/2.0f) )
{
if ( (sens >= 0.0f && d < best) ||
diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp
index 43909b2..e6e95a2 100644
--- a/src/ui/displayinfo.cpp
+++ b/src/ui/displayinfo.cpp
@@ -232,7 +232,7 @@ bool CDisplayInfo::EventProcess(const Event &event)
m_bInfoMaximized = false;
}
//? m_main->SetEditFull(m_bInfoMaximized);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = dynamic_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw != 0 )
{
pw->SetMaximized(m_bInfoMaximized);
@@ -834,7 +834,7 @@ void CDisplayInfo::StopDisplayInfo()
if ( m_bEditLock ) // editing running program?
{
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
+ pw = dynamic_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW3));
if ( pw != 0 )
{
pw->SetState(STATE_ENABLE); // CStudio operating
@@ -929,7 +929,7 @@ CObject* CDisplayInfo::SearchToto()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -991,7 +991,7 @@ void ObjectWrite(FILE* file, ObjectList list[], int i)
strcat(line, res);
strcat(line, "\\u ");
- p = GetHelpFilename(list[i].type);
+ p = const_cast<char*>(GetHelpFilename(list[i].type));
if ( p[0] == 0 ) return;
strcat(line, p+5); // skip "help\"
p = strstr(line, ".txt");
@@ -1019,7 +1019,7 @@ void CDisplayInfo::CreateObjectsFile()
bRadar = false;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue;
diff --git a/src/ui/displaytext.cpp b/src/ui/displaytext.cpp
index 63075ee..8578655 100644
--- a/src/ui/displaytext.cpp
+++ b/src/ui/displaytext.cpp
@@ -55,9 +55,9 @@ CDisplayText::CDisplayText()
m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_DISPLAYTEXT, this);
- m_engine = (Gfx::CEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_sound = (CSoundInterface*)m_iMan->SearchInstance(CLASS_SOUND);
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
+ m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
for ( i=0 ; i<MAXDTLINE ; i++ )
{
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index a4d5961..f25a77f 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -466,7 +466,7 @@ bool CEdit::EventProcess(const Event &event)
{
if ( event.param >= ' ' && event.param <= 255 )
{
- Insert((char)event.param);
+ Insert(static_cast<char>(event.param));
SendModifEvent();
return true;
}
@@ -581,7 +581,7 @@ void CEdit::MouseDoubleClick(Math::Point mouse)
while ( i > 0 )
{
- character = (unsigned char)m_text[i-1];
+ character = static_cast<unsigned char>(m_text[i-1]);
if ( !IsWord(character) ) break;
i --;
}
@@ -589,7 +589,7 @@ void CEdit::MouseDoubleClick(Math::Point mouse)
while ( i < m_len )
{
- character = (unsigned char)m_text[i];
+ character = static_cast<unsigned char>(m_text[i]);
if ( !IsWord(character) ) break;
i ++;
}
@@ -1651,12 +1651,12 @@ bool CEdit::ReadText(const char *filename, int addSize)
for ( iCount=0 ; iCount<iLines ; iCount++ )
{
strcpy(m_image[iIndex].name, iName);
- m_image[iIndex].offset = (float)iCount/iLines;
+ m_image[iIndex].offset = static_cast<float>(iCount/iLines);
m_image[iIndex].height = 1.0f/iLines;
m_image[iIndex].width = iWidth*0.75f;
- m_text[j] = (char)(iIndex++); // as an index into m_image
- m_format[j] = (unsigned char)Gfx::FONT_MASK_IMAGE;
+ m_text[j] = static_cast<char>(iIndex++); // as an index into m_image
+ m_format[j] = static_cast<unsigned char>(Gfx::FONT_MASK_IMAGE);
j ++;
}
}
@@ -2179,7 +2179,7 @@ void CEdit::Scroll()
{
value = m_scroll->GetVisibleValue();
value *= m_lineTotal-m_lineVisible;
- Scroll((int)(value+0.5f), true);
+ Scroll(static_cast<int>(value+0.5f), true);
}
}
@@ -2293,19 +2293,19 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{
while ( m_cursor1 > 0 )
{
- character = (unsigned char)m_text[m_cursor1-1];
+ character = static_cast<unsigned char>(m_text[m_cursor1-1]);
if ( !IsSpace(character) ) break;
m_cursor1 --;
}
if ( m_cursor1 > 0 )
{
- character = (unsigned char)m_text[m_cursor1-1];
+ character = static_cast<unsigned char>(m_text[m_cursor1-1]);
if ( IsSpace(character) )
{
while ( m_cursor1 > 0 )
{
- character = (unsigned char)m_text[m_cursor1-1];
+ character = static_cast<unsigned char>(m_text[m_cursor1-1]);
if ( !IsSpace(character) ) break;
m_cursor1 --;
}
@@ -2314,7 +2314,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{
while ( m_cursor1 > 0 )
{
- character = (unsigned char)m_text[m_cursor1-1];
+ character = static_cast<unsigned char>(m_text[m_cursor1-1]);
if ( !IsWord(character) ) break;
m_cursor1 --;
}
@@ -2323,7 +2323,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{
while ( m_cursor1 > 0 )
{
- character = (unsigned char)m_text[m_cursor1-1];
+ character = static_cast<unsigned char>(m_text[m_cursor1-1]);
if ( !IsSep(character) ) break;
m_cursor1 --;
}
@@ -2343,12 +2343,12 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{
if ( m_cursor1 < m_len )
{
- character = (unsigned char)m_text[m_cursor1];
+ character = static_cast<unsigned char>(m_text[m_cursor1]);
if ( IsSpace(character) )
{
while ( m_cursor1 < m_len )
{
- character = (unsigned char)m_text[m_cursor1];
+ character = static_cast<unsigned char>(m_text[m_cursor1]);
if ( !IsSpace(character) ) break;
m_cursor1 ++;
}
@@ -2357,7 +2357,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{
while ( m_cursor1 < m_len )
{
- character = (unsigned char)m_text[m_cursor1];
+ character = static_cast<unsigned char>(m_text[m_cursor1]);
if ( !IsWord(character) ) break;
m_cursor1 ++;
}
@@ -2366,7 +2366,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{
while ( m_cursor1 < m_len )
{
- character = (unsigned char)m_text[m_cursor1];
+ character = static_cast<unsigned char>(m_text[m_cursor1]);
if ( !IsSep(character) ) break;
m_cursor1 ++;
}
@@ -2375,7 +2375,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
while ( m_cursor1 < m_len )
{
- character = (unsigned char)m_text[m_cursor1];
+ character = static_cast<unsigned char>(m_text[m_cursor1]);
if ( !IsSpace(character) ) break;
m_cursor1 ++;
}
@@ -3034,7 +3034,7 @@ bool CEdit::MinMaj(bool bMaj)
for ( i=c1 ; i<c2 ; i++ )
{
- character = (unsigned char)m_text[i];
+ character = static_cast<unsigned char>(m_text[i]);
if ( bMaj ) character = GetToUpper(character);
else character = GetToLower(character);
m_text[i] = character;
diff --git a/src/ui/list.cpp b/src/ui/list.cpp
index 80609d7..2aeb240 100644
--- a/src/ui/list.cpp
+++ b/src/ui/list.cpp
@@ -759,16 +759,16 @@ void CList::UpdateScroll()
value = 0.0f;
step = 0.0f;
} else {
- ratio = (float)m_displayLine / m_totalLine;
+ ratio = static_cast<float>m_displayLine / m_totalLine;
if ( ratio > 1.0f ) ratio = 1.0f;
- value = (float)m_firstLine / (m_totalLine - m_displayLine);
+ value = static_cast<float>m_firstLine / (m_totalLine - m_displayLine);
if ( value < 0.0f )
value = 0.0f;
if ( value > 1.0f )
value = 1.0f;
- step = (float)1.0f/ (m_totalLine - m_displayLine);
+ step = static_cast<float>1.0f/ (m_totalLine - m_displayLine);
if ( step < 0.0f )
step = 0.0f;
}
@@ -791,7 +791,7 @@ void CList::MoveScroll()
n = m_totalLine - m_displayLine;
pos = m_scroll->GetVisibleValue();
pos += m_scroll->GetArrowStep() / 2.0f; // it's magic!
- m_firstLine = (int)(pos * n);
+ m_firstLine = static_cast<int>(pos * n);
if ( m_firstLine < 0 )
m_firstLine = 0;
if ( m_firstLine > n )
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 4523b2c..96a1a4c 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -6575,7 +6575,7 @@ bool CMainDialog::IsDialog()
// Specifies the name of the scene to read.
-void CMainDialog::SetSceneRead(char* name)
+void CMainDialog::SetSceneRead(const char* name)
{
strcpy(m_sceneRead, name);
}
@@ -6589,7 +6589,7 @@ char* CMainDialog::GetSceneRead()
// Specifies the name of the scene to read.
-void CMainDialog::SetStackRead(char* name)
+void CMainDialog::SetStackRead(const char* name)
{
strcpy(m_stackRead, name);
}
@@ -6603,7 +6603,7 @@ char* CMainDialog::GetStackRead()
// Specifies the name of the chosen to play scene.
-void CMainDialog::SetSceneName(char* name)
+void CMainDialog::SetSceneName(const char* name)
{
strcpy(m_sceneName, name);
}
diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h
index df36a4d..8b0ef81 100644
--- a/src/ui/maindialog.h
+++ b/src/ui/maindialog.h
@@ -71,9 +71,9 @@ public:
bool EventProcess(const Event &event);
void ChangePhase(Phase phase);
- void SetSceneRead(char* name);
- void SetStackRead(char* name);
- void SetSceneName(char* name);
+ void SetSceneRead(const char* name);
+ void SetStackRead(const char* name);
+ void SetSceneName(const char* name);
void SetSceneRank(int rank);
char* GetSceneRead();
char* GetStackRead();
diff --git a/src/ui/mainmap.cpp b/src/ui/mainmap.cpp
index 601c035..f853178 100644
--- a/src/ui/mainmap.cpp
+++ b/src/ui/mainmap.cpp
@@ -35,8 +35,8 @@ CMainMap::CMainMap()
m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_MAP, this);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_event = (CEventQueue*)m_iMan->SearchInstance(CLASS_EVENT);
+ m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
+ m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
m_engine = (Gfx::CEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
m_mapMode = 1;
@@ -57,7 +57,7 @@ void CMainMap::CreateMap()
CWindow* pw;
Math::Point pos, dim;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) {
pos.x = 0.0f;
pos.y = 0.0f;
@@ -83,11 +83,11 @@ void CMainMap::SetFixImage(const char *filename)
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr)
return;
@@ -104,11 +104,11 @@ void CMainMap::FloorColorMap(Gfx::Color floor, Gfx::Color water)
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm != nullptr) {
pm->SetFloorColor(floor);
pm->SetWaterColor(water);
@@ -123,18 +123,18 @@ void CMainMap::ShowMap(bool bShow)
CMap* pm;
CSlider* ps;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return;
if (bShow) {
DimMap();
} else {
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm != nullptr)
pm->ClearState(STATE_VISIBLE);
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
if (ps != nullptr)
ps->ClearState(STATE_VISIBLE);
}
@@ -150,10 +150,10 @@ void CMainMap::DimMap()
Math::Point pos, dim;
float value;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr)
return;
@@ -166,7 +166,7 @@ void CMainMap::DimMap()
pm->SetPos(pos);
pm->SetDim(dim);
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
if (ps != nullptr) {
ps->SetState(STATE_VISIBLE, (m_mapMode != 0));
@@ -193,15 +193,15 @@ float CMainMap::GetZoomMap()
CMap* pm;
CSlider* ps;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return ZOOM_MIN;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr)
return ZOOM_MIN;
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
if (ps == nullptr)
return ZOOM_MIN;
@@ -216,14 +216,14 @@ void CMainMap::ZoomMap(float zoom)
CMap* pm;
CSlider* ps;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr)
return;
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
if (ps == nullptr)
return;
@@ -245,14 +245,14 @@ void CMainMap::ZoomMap()
CSlider* ps;
float zoom;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr)
return;
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
if (ps == nullptr)
return;
@@ -273,15 +273,15 @@ void CMainMap::MapEnable(bool bEnable)
CMap* pm;
CSlider* ps;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm != nullptr)
pm->SetEnable(bEnable);
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
if (ps != nullptr)
ps->SetState(STATE_ENABLE, bEnable);
}
@@ -293,11 +293,11 @@ void CMainMap::SetToy(bool bToy)
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr)
return;
@@ -312,11 +312,11 @@ void CMainMap::SetFixParam(float zoom, float ox, float oy, float angle,
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr)
return;
@@ -334,11 +334,11 @@ void CMainMap::UpdateMap()
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm != nullptr)
pm->UpdateTerrain();
}
@@ -365,12 +365,12 @@ CObject* CMainMap::DetectMap(Math::Point pos, bool &bInMap)
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return 0;
bInMap = false;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr)
return 0;
return pm->DetectObject(pos, bInMap);
@@ -384,11 +384,11 @@ void CMainMap::SetHighlight(CObject* pObj)
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm != nullptr)
pm->SetHighlight(pObj);
}
diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp
index f51ee9b..5b1271f 100644
--- a/src/ui/mainshort.cpp
+++ b/src/ui/mainshort.cpp
@@ -139,7 +139,7 @@ bool CMainShort::CreateShortcuts()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == nullptr ) break;
if ( !pObj->GetActif() ) continue;