warnings fight in progress.

dev-ui
Zaba999 2012-09-18 00:01:00 +02:00
parent 844e11db4f
commit a397922e8d
27 changed files with 190 additions and 207 deletions

View File

@ -422,7 +422,7 @@ public:
} }
bool ConvertToStore(const SI_CHAR * a_pszString) { bool ConvertToStore(const SI_CHAR * a_pszString) {
size_t uLen = SizeToStore(a_pszString); size_t uLen = SizeToStore(a_pszString);
if (uLen == (size_t)(-1)) { if (uLen == static_cast<size_t>(-1)) {
return false; return false;
} }
while (uLen > m_scratch.size()) { while (uLen > m_scratch.size()) {
@ -1360,7 +1360,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::LoadFile(
} }
fseek(a_fpFile, 0, SEEK_SET); fseek(a_fpFile, 0, SEEK_SET);
size_t uRead = fread(pData, sizeof(char), lSize, a_fpFile); size_t uRead = fread(pData, sizeof(char), lSize, a_fpFile);
if (uRead != (size_t) lSize) { if (uRead != static_cast<size_t>(lSize)) {
delete[] pData; delete[] pData;
return SI_FILE; return SI_FILE;
} }
@ -1394,7 +1394,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::LoadData(
// determine the length of the converted data // determine the length of the converted data
size_t uLen = converter.SizeFromStore(a_pData, a_uDataLen); size_t uLen = converter.SizeFromStore(a_pData, a_uDataLen);
if (uLen == (size_t)(-1)) { if (uLen == static_cast<size_t>(-1)) {
return SI_FAIL; 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 // move this line down to the location that it should be if necessary
if (pDataLine < pCurrLine) { 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)); memmove(pDataLine, pCurrLine, nLen * sizeof(SI_CHAR));
pDataLine[nLen] = '\0'; pDataLine[nLen] = '\0';
} }
@ -1816,10 +1816,10 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::CopyString(
{ {
size_t uLen = 0; size_t uLen = 0;
if (sizeof(SI_CHAR) == sizeof(char)) { 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)) { 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 { else {
for ( ; a_pString[uLen]; ++uLen) /*loop*/ ; 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 // if multi-key isn't permitted then the section size is
// the number of keys that we have. // the number of keys that we have.
if (!m_bAllowMultiKey || section.empty()) { if (!m_bAllowMultiKey || section.empty()) {
return (int) section.size(); return static_cast<int> (section.size());
} }
// otherwise we need to count them // otherwise we need to count them
@ -2626,7 +2626,7 @@ struct SI_GenericCase {
bool operator()(const SI_CHAR * pLeft, const SI_CHAR * pRight) const { bool operator()(const SI_CHAR * pLeft, const SI_CHAR * pRight) const {
long cmp; long cmp;
for ( ;*pLeft && *pRight; ++pLeft, ++pRight) { for ( ;*pLeft && *pRight; ++pLeft, ++pRight) {
cmp = (long) *pLeft - (long) *pRight; cmp = static_cast<long> (*pLeft) - static_cast<long> (*pRight);
if (cmp != 0) { if (cmp != 0) {
return cmp < 0; return cmp < 0;
} }
@ -2649,7 +2649,7 @@ struct SI_GenericNoCase {
bool operator()(const SI_CHAR * pLeft, const SI_CHAR * pRight) const { bool operator()(const SI_CHAR * pLeft, const SI_CHAR * pRight) const {
long cmp; long cmp;
for ( ;*pLeft && *pRight; ++pLeft, ++pRight) { 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) { if (cmp != 0) {
return cmp < 0; return cmp < 0;
} }
@ -2741,7 +2741,7 @@ public:
const SI_CHAR * a_pInputData) const SI_CHAR * a_pInputData)
{ {
// ASCII/MBCS/UTF-8 needs no conversion // 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. /** Convert the input string to the storage format of this data.
@ -2763,7 +2763,7 @@ public:
size_t a_uOutputDataSize) size_t a_uOutputDataSize)
{ {
// calc input string length (SI_CHAR type and size independent) // 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) { if (uInputLen > a_uOutputDataSize) {
return false; return false;
} }
@ -3195,12 +3195,12 @@ template<class SI_CHAR>
struct SI_NoCase { struct SI_NoCase {
bool operator()(const SI_CHAR * pLeft, const SI_CHAR * pRight) const { bool operator()(const SI_CHAR * pLeft, const SI_CHAR * pRight) const {
if (sizeof(SI_CHAR) == sizeof(char)) { if (sizeof(SI_CHAR) == sizeof(char)) {
return _mbsicmp((const unsigned char *)pLeft, return _mbsicmp(reinterpret_cast<const unsigned char *>(pLeft),
(const unsigned char *)pRight) < 0; reinterpret_cast<const unsigned char *>(pRight)) < 0;
} }
if (sizeof(SI_CHAR) == sizeof(wchar_t)) { if (sizeof(SI_CHAR) == sizeof(wchar_t)) {
return _wcsicmp((const wchar_t *)pLeft, return _wcsicmp(reinterpret_cast<const wchar_t *>(pLeft),
(const wchar_t *)pRight) < 0; reinterpret_cast<const wchar_t *>(pRight)) < 0;
} }
return SI_GenericNoCase<SI_CHAR>()(pLeft, pRight); return SI_GenericNoCase<SI_CHAR>()(pLeft, pRight);
} }
@ -3251,9 +3251,9 @@ public:
int retval = MultiByteToWideChar( int retval = MultiByteToWideChar(
m_uCodePage, 0, m_uCodePage, 0,
a_pInputData, (int) a_uInputDataLen, a_pInputData, static_cast<int> (a_uInputDataLen),
0, 0); 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. /** Convert the input string from the storage format to SI_CHAR.
@ -3277,8 +3277,8 @@ public:
{ {
int nSize = MultiByteToWideChar( int nSize = MultiByteToWideChar(
m_uCodePage, 0, m_uCodePage, 0,
a_pInputData, (int) a_uInputDataLen, a_pInputData, static_cast<int> (a_uInputDataLen),
(wchar_t *) a_pOutputData, (int) a_uOutputDataSize); static_cast<wchar_t *> (a_pOutputData), static_cast<int> (a_uOutputDataSize));
return (nSize > 0); return (nSize > 0);
} }
@ -3297,9 +3297,9 @@ public:
{ {
int retval = WideCharToMultiByte( int retval = WideCharToMultiByte(
m_uCodePage, 0, m_uCodePage, 0,
(const wchar_t *) a_pInputData, -1, static_cast<const wchar_t *> (a_pInputData), -1,
0, 0, 0, 0); 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. /** Convert the input string to the storage format of this data.
@ -3322,8 +3322,8 @@ public:
{ {
int retval = WideCharToMultiByte( int retval = WideCharToMultiByte(
m_uCodePage, 0, m_uCodePage, 0,
(const wchar_t *) a_pInputData, -1, static_cast<const wchar_t *> (a_pInputData), -1,
a_pOutputData, (int) a_uOutputDataSize, 0, 0); a_pOutputData, static_cast<int> (a_uOutputDataSize), 0, 0);
return retval > 0; return retval > 0;
} }
}; };

View File

@ -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 // set the array size
void CBotStringArray::SetSize(int nNewSize) void CBotStringArray::SetSize(int nNewSize)
@ -618,15 +606,14 @@ void CBotStringArray::SetSize(int nNewSize)
// shrink to nothing // shrink to nothing
DestructElements(m_pData, m_nSize); DestructElements(m_pData, m_nSize);
// delete[] static_cast<unsigned char *>(m_pData); delete[] reinterpret_cast<unsigned char *>(m_pData);
delete[] (unsigned char *)m_pData;
m_pData = NULL; m_pData = NULL;
m_nSize = m_nMaxSize = 0; m_nSize = m_nMaxSize = 0;
} }
else if (m_pData == NULL) else if (m_pData == NULL)
{ {
// create one with exact size // 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); ConstructElements(m_pData, nNewSize);
@ -663,7 +650,7 @@ void CBotStringArray::SetSize(int nNewSize)
else else
nNewMax = nNewSize; // no slush 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 // copy new data from old
memcpy(pNewData, m_pData, m_nSize * sizeof(CBotString)); 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) // 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_pData = pNewData;
m_nSize = nNewSize; m_nSize = nNewSize;
m_nMaxSize = nNewMax; m_nMaxSize = nNewMax;

View File

@ -129,11 +129,11 @@ enum InputSlot
struct InputBinding struct InputBinding
{ {
//! Key //! Key
int key; unsigned int key;
//! Key modifier (e.g. shift, control) //! Key modifier (e.g. shift, control)
int kmod; unsigned int kmod;
//! Joystick button //! Joystick button
int joy; unsigned int joy;
inline InputBinding() inline InputBinding()
{ {
@ -142,7 +142,7 @@ struct InputBinding
inline void Reset() inline void Reset()
{ {
key = kmod = joy = -1; key = kmod = joy = static_cast<unsigned int>(-1);
} }
}; };

View File

@ -48,18 +48,18 @@ struct SystemTimeStamp
// Convert a wide Unicode string to an UTF8 string // Convert a wide Unicode string to an UTF8 string
std::string UTF8_Encode_Windows(const std::wstring &wstr) 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); 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; return strTo;
} }
// Convert an UTF8 string to a wide Unicode String // Convert an UTF8 string to a wide Unicode String
std::wstring UTF8_Decode_Windows(const std::string &str) 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); 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; return wstrTo;
} }

View File

@ -24,8 +24,8 @@ static EventType g_uniqueEventType = EVENT_USER;
EventType GetUniqueEventType() EventType GetUniqueEventType()
{ {
int i = (int)g_uniqueEventType+1; int i = static_cast<int>(g_uniqueEventType+1);
g_uniqueEventType = (EventType)i; g_uniqueEventType = static_cast<EventType>(i);
return g_uniqueEventType; return g_uniqueEventType;
} }

View File

@ -118,7 +118,7 @@ enum KeyRank
// TODO: move to CRobotMain // TODO: move to CRobotMain
extern long g_id; // unique identifier extern long g_id; // unique identifier
extern long g_build; // constructible buildings extern int g_build; // constructible buildings
extern long g_researchDone; // research done extern int g_researchDone; // research done
extern long g_researchEnable; // research available extern long g_researchEnable; // research available
extern float g_unit; // conversion factor extern float g_unit; // conversion factor

View File

@ -34,7 +34,7 @@ static unsigned char table_codec[23] =
void Codec(void* buffer, int len, int start) void Codec(void* buffer, int len, int start)
{ {
unsigned char *b = (unsigned char*)buffer; unsigned char *b = static_cast<unsigned char*>(buffer);
int i; int i;
for ( i=0 ; i<len ; 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 strcpy(m_list[i].name, metaname); // memorized the name
fread(&m_list[i].total, sizeof(int), 1, m_list[i].stream); 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; offset = 4;
for ( j=0 ; j<m_list[i].total ; j++ ) for ( j=0 ; j<m_list[i].total ; j++ )

View File

@ -258,7 +258,7 @@ bool Xfer(char* src, char* dst)
return false; return false;
} }
buffer = (char*)malloc(10000); buffer = static_cast<char*>(malloc(10000));
while ( true ) while ( true )
{ {
@ -338,7 +338,7 @@ bool CopyFileListToTemp(char* filename, int* list, int total)
// Adds an extension to file, if doesn't already one. // 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? if ( strchr(filename, '.') != 0 ) return; // already an extension?
strcat(filename, ext); strcat(filename, ext);

View File

@ -46,6 +46,6 @@ extern void TimeToAscii(time_t time, char *buffer);
extern bool CopyFileToTemp(char* filename); extern bool CopyFileToTemp(char* filename);
extern bool CopyFileListToTemp(char* filename, int* list, int total); 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(bool bUser, char* dir);
extern void UserDir(char* buffer, const char* dir, const char* def); extern void UserDir(char* buffer, const char* dir, const char* def);

View File

@ -200,7 +200,7 @@ void Gfx::CParticle::DrawParticle(int sheet)
// TODO! // 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"); GetLogger()->Trace("CParticle::WriteWheelTrace() stub!\n");
// TODO! // TODO!

View File

@ -306,7 +306,7 @@ public:
void FrameParticle(float rTime); void FrameParticle(float rTime);
void DrawParticle(int sheet); 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: protected:
void DeleteRank(int rank); void DeleteRank(int rank);

View File

@ -414,9 +414,9 @@ int CAutoSafe::CountKeys()
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i)); pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break; if ( pObj == 0 ) break;
oType = pObj->GetType();
if ( pObj->GetTruck() != 0 ) continue; if ( pObj->GetTruck() != 0 ) continue;
oType = pObj->GetType();
if ( oType != OBJECT_KEYa && if ( oType != OBJECT_KEYa &&
oType != OBJECT_KEYb && oType != OBJECT_KEYb &&
oType != OBJECT_KEYc && oType != OBJECT_KEYc &&
@ -588,7 +588,6 @@ CObject* CAutoSafe::SearchVehicle()
{ {
CObject* pObj; CObject* pObj;
Math::Vector cPos, oPos; Math::Vector cPos, oPos;
ObjectType oType;
float dist; float dist;
int i; int i;
@ -599,7 +598,6 @@ CObject* CAutoSafe::SearchVehicle()
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i)); pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break; if ( pObj == 0 ) break;
oType = pObj->GetType();
if ( pObj == m_object ) continue; if ( pObj == m_object ) continue;
if ( pObj->GetTruck() != 0 ) continue; if ( pObj->GetTruck() != 0 ) continue;

View File

@ -2789,7 +2789,7 @@ void CBrain::TraceRecordStart()
} }
delete m_traceRecordBuffer; delete m_traceRecordBuffer;
m_traceRecordBuffer = (TraceRecord*)malloc(sizeof(TraceRecord)*MAXTRACERECORD); m_traceRecordBuffer = static_cast<TraceRecord*>(malloc(sizeof(TraceRecord)*MAXTRACERECORD));
m_traceRecordIndex = 0; m_traceRecordIndex = 0;
} }
@ -2836,7 +2836,7 @@ void CBrain::TraceRecordFrame()
if ( color != m_traceColor ) if ( color != m_traceColor )
{ {
TraceRecordOper(TO_PEN, (float)color); TraceRecordOper(TO_PEN, static_cast<float>(color));
} }
m_traceOper = oper; m_traceOper = oper;
@ -2858,7 +2858,7 @@ void CBrain::TraceRecordStop()
if ( m_traceRecordBuffer == 0 ) return; if ( m_traceRecordBuffer == 0 ) return;
max = 10000; max = 10000;
buffer = (char*)malloc(max); buffer = static_cast<char*>(malloc(max));
*buffer = 0; *buffer = 0;
strncat(buffer, "extern void object::AutoDraw()\n{\n", max-1); 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 ) if ( oper == TO_TURN )
{ {
param = -param*180.0f/Math::PI; 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); //? sprintf(line, "\tturn(%.1f);\n", param);
strncat(buffer, line, max-1); strncat(buffer, line, max-1);
} }
if ( oper == TO_PEN ) 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, "\tpenup();\n", max-1);
if ( color == 1 ) strncat(buffer, "\tpendown(Black);\n", max-1); if ( color == 1 ) strncat(buffer, "\tpendown(Black);\n", max-1);
if ( color == 8 ) strncat(buffer, "\tpendown(Yellow);\n", max-1); if ( color == 8 ) strncat(buffer, "\tpendown(Yellow);\n", max-1);

View File

@ -710,7 +710,7 @@ bool CMotionHuman::EventFrame(const Event &event)
float tSt[9], tNd[9]; float tSt[9], tNd[9];
float aa, bb, shield, deadFactor, level; float aa, bb, shield, deadFactor, level;
int i, ii, st, nd, action, legAction, armAction; int i, ii, st, nd, action, legAction, armAction;
bool bOnBoard, bSwim, bStop; bool bOnBoard, bSwim;
if ( m_engine->GetPause() ) 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; m_armTimeSwim += Math::Min(Math::Max(s,a,3.0f),15.0f)*event.rTime*0.05f;
} }
bStop = ( s == 0.0f ); // stop?
prog = 0.0f; prog = 0.0f;
if ( m_physics->GetLand() ) // on the ground? if ( m_physics->GetLand() ) // on the ground?

View File

@ -87,8 +87,8 @@ const float UNIT = 4.0f;
// Global variables. // Global variables.
long g_id; // unique identifier long g_id; // unique identifier
long g_build; // constructible buildings int g_build; // constructible buildings
long g_researchDone; // research done int g_researchDone; // research done
long g_researchEnable; // research available long g_researchEnable; // research available
float g_unit; // conversion factor float g_unit; // conversion factor
@ -172,7 +172,7 @@ bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exceptio
// save the channel file // save the channel file
pVar = pThis->GetItem("handle"); pVar = pThis->GetItem("handle");
pVar->SetValInt((long)pFile); pVar->SetValInt(reinterpret_cast<long>(pFile));
} }
return true; return true;
@ -215,7 +215,7 @@ bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception
// don't open? no problem :) // don't open? no problem :)
if ( pVar->GetInit() != IS_DEF) return true; if ( pVar->GetInit() != IS_DEF) return true;
FILE* pFile= (FILE*)pVar->GetValInt(); FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
fclose(pFile); fclose(pFile);
m_CompteurFileOpen --; m_CompteurFileOpen --;
@ -282,7 +282,7 @@ bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
// Registered the channel file // Registered the channel file
pVar = pThis->GetItem("handle"); pVar = pThis->GetItem("handle");
pVar->SetValInt((long)pFile); pVar->SetValInt(reinterpret_cast<long>(pFile));
pResult->SetValInt(true); pResult->SetValInt(true);
return 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; } if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GetValInt(); FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
fclose(pFile); fclose(pFile);
m_CompteurFileOpen --; 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; } 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); 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; } if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GetValInt(); FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
char chaine[2000]; char chaine[2000];
int i; 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; } 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 ) ); pResult->SetValInt( feof( pFile ) );
@ -604,15 +604,15 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app)
m_app = app; m_app = app;
m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT)); m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE)); m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT)); m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE)); m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER)); m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
m_cloud = static_cast<Gfx::CCloud*>(m_iMan->SearchInstance(CLASS_CLOUD)); m_cloud = static_cast<Gfx::CCloud*>(m_iMan->SearchInstance(CLASS_CLOUD));
m_lightning = static_cast<Gfx::CLightning*>(m_iMan->SearchInstance(CLASS_BLITZ)); m_lightning = static_cast<Gfx::CLightning*>(m_iMan->SearchInstance(CLASS_BLITZ));
m_planet = static_cast<Gfx::CPlanet*>(m_iMan->SearchInstance(CLASS_PLANET)); m_planet = static_cast<Gfx::CPlanet*>(m_iMan->SearchInstance(CLASS_PLANET));
m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND)); m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
m_interface = new Ui::CInterface(); m_interface = new Ui::CInterface();
m_terrain = new Gfx::CTerrain(m_iMan); 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_windowPos = Math::Point(0.15f, 0.17f);
m_windowDim = Math::Point(0.70f, 0.66f); m_windowDim = Math::Point(0.70f, 0.66f);
float fValue; // TODO: profile
int iValue; // float fValue;
// int iValue;
/* TODO: profile // if (GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue;
if (GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue; // if (GetLocalProfileFloat("Edit", "WindowPos.x", fValue)) m_windowPos.x = fValue;
if (GetLocalProfileFloat("Edit", "WindowPos.x", fValue)) m_windowPos.x = fValue; // if (GetLocalProfileFloat("Edit", "WindowPos.y", fValue)) m_windowPos.y = 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.x", fValue)) m_windowDim.x = fValue; // if (GetLocalProfileFloat("Edit", "WindowDim.y", fValue)) m_windowDim.y = fValue;
if (GetLocalProfileFloat("Edit", "WindowDim.y", fValue)) m_windowDim.y = fValue; */
m_IOPublic = false; m_IOPublic = false;
m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f); 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++) for (int i = 0; i < OBJECT_MAX; i++)
{ {
ObjectType type = (ObjectType)i; ObjectType type = static_cast<ObjectType>(i);
const char* token = GetObjectName(type); const char* token = GetObjectName(type);
if (token[0] != 0) if (token[0] != 0)
CBotProgram::DefineNum(token, type); CBotProgram::DefineNum(token, type);
@ -943,7 +943,7 @@ void CRobotMain::ChangePhase(Phase phase)
dim.y = 18.0f/480.0f; dim.y = 18.0f/480.0f;
pos.x = 50.0f/640.0f; pos.x = 50.0f/640.0f;
pos.y = 452.0f/480.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; if (pe == nullptr) return;
pe->ClearState(Ui::STATE_VISIBLE); pe->ClearState(Ui::STATE_VISIBLE);
m_cmdEdit = false; // hidden for now m_cmdEdit = false; // hidden for now
@ -1145,7 +1145,7 @@ bool CRobotMain::EventProcess(const Event &event)
event.type == EVENT_KEY_DOWN && event.type == EVENT_KEY_DOWN &&
event.key.key == KEY(PAUSE)) // Pause ? 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; if (pe == nullptr) return false;
pe->SetState(Ui::STATE_VISIBLE); pe->SetState(Ui::STATE_VISIBLE);
pe->SetFocus(true); pe->SetFocus(true);
@ -1157,7 +1157,7 @@ bool CRobotMain::EventProcess(const Event &event)
event.key.key == KEY(RETURN) && m_cmdEdit) event.key.key == KEY(RETURN) && m_cmdEdit)
{ {
char cmd[50]; 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; if (pe == nullptr) return false;
pe->GetText(cmd, 50); pe->GetText(cmd, 50);
pe->SetText(""); pe->SetText("");
@ -1843,7 +1843,7 @@ void CRobotMain::StartDisplayInfo(int index, bool movie)
} }
//! Beginning of the displaying of instructions //! 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; if (m_cmdEdit) return;
@ -1857,7 +1857,7 @@ void CRobotMain::StartDisplayInfo(char *filename, int index)
m_sound->MuteAll(true); 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) if (pb != nullptr)
{ {
pb->ClearState(Ui::STATE_VISIBLE); pb->ClearState(Ui::STATE_VISIBLE);
@ -1889,7 +1889,7 @@ void CRobotMain::StopDisplayInfo()
if (!m_editLock) 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) if (pb != nullptr)
pb->SetState(Ui::STATE_VISIBLE); pb->SetState(Ui::STATE_VISIBLE);
@ -1930,7 +1930,7 @@ void CRobotMain::StartSuspend()
m_infoObject = DeselectAll(); // removes the control buttons m_infoObject = DeselectAll(); // removes the control buttons
m_displayText->HideText(true); 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) if (pb != nullptr)
pb->ClearState(Ui::STATE_VISIBLE); pb->ClearState(Ui::STATE_VISIBLE);
@ -1940,7 +1940,7 @@ void CRobotMain::StartSuspend()
//! End of dialogue during the game //! End of dialogue during the game
void CRobotMain::StopSuspend() 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) if (pb != nullptr)
pb->SetState(Ui::STATE_VISIBLE); pb->SetState(Ui::STATE_VISIBLE);
@ -2047,7 +2047,7 @@ void CRobotMain::StartDisplayVisit(EventType event)
{ {
if (m_editLock) return; 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 (pw == nullptr) return;
if (event == EVENT_NULL) // visit by keyboard shortcut? if (event == EVENT_NULL) // visit by keyboard shortcut?
@ -2064,10 +2064,10 @@ void CRobotMain::StartDisplayVisit(EventType event)
i --; i --;
if (i < 0) i = Ui::MAXDTLINE-1; 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; 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) if (group != nullptr)
{ {
event = static_cast<EventType>(EVENT_DT_VISIT0+i); 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); 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) if (pw != nullptr)
{ {
pw->SetState(Ui::STATE_SHADOW); pw->SetState(Ui::STATE_SHADOW);
@ -2843,7 +2843,7 @@ void CRobotMain::HelpObject()
CObject* obj = GetSelect(); CObject* obj = GetSelect();
if (obj == nullptr) return; if (obj == nullptr) return;
char* filename = GetHelpFilename(obj->GetType()); const char* filename = GetHelpFilename(obj->GetType());
if (filename[0] == 0) return; if (filename[0] == 0) return;
StartDisplayInfo(filename, -1); StartDisplayInfo(filename, -1);
@ -2919,7 +2919,7 @@ void CRobotMain::ChangeCamera()
} }
//! Remote control the camera using the arrow keys //! 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 // TODO: rewrite key handling to input bindings
@ -3068,14 +3068,14 @@ bool CRobotMain::EventFrame(const Event &event)
m_planet->EventProcess(event); m_planet->EventProcess(event);
Ui::CMap* pm = nullptr; 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) if (pw == nullptr)
{ {
pm = nullptr; pm = nullptr;
} }
else 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(); if (pm != nullptr) pm->FlushObject();
} }
@ -3510,7 +3510,7 @@ void CRobotMain::ScenePerso()
{ {
obj->SetDrawFront(true); // draws the interface obj->SetDrawFront(true); // draws the interface
CMotionHuman* mh = (CMotionHuman*)obj->GetMotion(); CMotionHuman* mh = static_cast<CMotionHuman*>(obj->GetMotion());
if (mh != nullptr) if (mh != nullptr)
mh->StartDisplayPerso(); mh->StartDisplayPerso();
} }
@ -5137,7 +5137,7 @@ void CRobotMain::SetShowLimit(int i, Gfx::ParticleType parti, CObject *obj,
m_showLimit[i].pos = pos; m_showLimit[i].pos = pos;
m_showLimit[i].radius = radius; m_showLimit[i].radius = radius;
m_showLimit[i].duration = duration; 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; if (m_showLimit[i].total > MAXSHOWPARTI) m_showLimit[i].total = MAXSHOWPARTI;
m_showLimit[i].time = 0.0f; m_showLimit[i].time = 0.0f;
@ -5350,8 +5350,6 @@ void CRobotMain::LoadFileScript(CObject *obj, char* filename, int objRank,
ObjectType type = obj->GetType(); ObjectType type = obj->GetType();
if (type == OBJECT_HUMAN) return; if (type == OBJECT_HUMAN) return;
char* name = m_dialog->GetSceneName();
int rank = m_dialog->GetSceneRank();
char fn[MAX_FNAME]; char fn[MAX_FNAME];
strcpy(fn, filename); strcpy(fn, filename);
@ -5523,7 +5521,7 @@ bool CRobotMain::IsBusy()
} }
//! Writes an object into the backup file //! 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; 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()); sprintf(line, "Map zoom=%.2f\n", m_map->GetZoomMap());
fputs(line, file); 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); fputs(line, file);
float sleep, delay, magnetic, progress; float sleep, delay, magnetic, progress;
@ -5981,7 +5979,7 @@ void CRobotMain::ResetObject()
// Removes all pyrotechnic effects in progress. // Removes all pyrotechnic effects in progress.
while ( true ) while ( true )
{ {
pyro = (CPyro*)m_iMan->SearchInstance(CLASS_PYRO, 0); pyro = static_cast<CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, 0));
if ( pyro == 0 ) break; if ( pyro == 0 ) break;
pyro->DeleteObject(); pyro->DeleteObject();
@ -6420,7 +6418,7 @@ void CRobotMain::SetSpeed(float speed)
{ {
// TODO: m_app->SetSimulationSpeed(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 (pb != nullptr)
{ {
if (speed == 1.0f) if (speed == 1.0f)

View File

@ -201,7 +201,7 @@ public:
void FlushDisplayInfo(); void FlushDisplayInfo();
void StartDisplayInfo(int index, bool movie); void StartDisplayInfo(int index, bool movie);
void StartDisplayInfo(char *filename, int index); void StartDisplayInfo(const char *filename, int index);
void StopDisplayInfo(); void StopDisplayInfo();
char* GetDisplayInfoName(int index); char* GetDisplayInfoName(int index);
int GetDisplayInfoPosition(int index); int GetDisplayInfoPosition(int index);
@ -287,7 +287,7 @@ public:
bool IsBusy(); bool IsBusy();
bool IOWriteScene(char *filename, char *filecbot, char *info); bool IOWriteScene(char *filename, char *filecbot, char *info);
CObject* IOReadScene(char *filename, char *filecbot); 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); CObject* IOReadObject(char *line, char* filename, int objRank);
int CreateSpot(Math::Vector pos, Gfx::Color color); int CreateSpot(Math::Vector pos, Gfx::Color color);
@ -314,7 +314,7 @@ protected:
CObject* DetectObject(Math::Point pos); CObject* DetectObject(Math::Point pos);
void ChangeCamera(); void ChangeCamera();
void RemoteCamera(float pan, float zoom, float rTime); void RemoteCamera(float pan, float zoom, float rTime);
void KeyCamera(EventType event, long key); void KeyCamera(EventType event, unsigned int key);
void AbortMovie(); void AbortMovie();
bool IsSelectable(CObject* pObj); bool IsSelectable(CObject* pObj);
void SelectOneObject(CObject* pObj, bool displayError=true); void SelectOneObject(CObject* pObj, bool displayError=true);
@ -446,8 +446,8 @@ protected:
char m_gamerName[100]; char m_gamerName[100];
long m_freeBuild; // constructible buildings int m_freeBuild; // constructible buildings
long m_freeResearch; // researches possible int m_freeResearch; // researches possible
ShowLimit m_showLimit[MAXSHOWLIMIT]; ShowLimit m_showLimit[MAXSHOWLIMIT];

View File

@ -24,7 +24,7 @@
// Seeking the name of an object. // Seeking the name of an object.
char* GetObjectName(ObjectType type) const char* GetObjectName(ObjectType type)
{ {
if ( type == OBJECT_PORTICO ) return "Portico"; if ( type == OBJECT_PORTICO ) return "Portico";
if ( type == OBJECT_BASE ) return "SpaceShip"; if ( type == OBJECT_BASE ) return "SpaceShip";
@ -117,7 +117,7 @@ char* GetObjectName(ObjectType type)
// Seeking the name of a secondary object. // Seeking the name of a secondary object.
// (because Otto thinks that Germans do not like nuclear power) // (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_NUCLEAR ) return "FuelCellPlant";
if ( type == OBJECT_URANIUM ) return "PlatinumOre"; if ( type == OBJECT_URANIUM ) return "PlatinumOre";
@ -130,7 +130,7 @@ char* GetObjectAlias(ObjectType type)
// Returns the help file to use for the object. // 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_BASE ) return "help\\object\\base.txt";
if ( type == OBJECT_DERRICK ) return "help\\object\\derrick.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. // 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, "if" ) == 0 ) return "help\\cbot\\if.txt";
if ( strcmp(token, "else" ) == 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. // 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, "if" ) == 0 ) return "if ( condition ) { bloc }";
if ( strcmp(token, "else" ) == 0 ) return "else { bloc }"; if ( strcmp(token, "else" ) == 0 ) return "else { bloc }";

View File

@ -25,12 +25,12 @@
// Procedures. // Procedures.
extern char* GetObjectName(ObjectType type); extern const char* GetObjectName(ObjectType type);
extern char* GetObjectAlias(ObjectType type); extern const char* GetObjectAlias(ObjectType type);
extern char* GetHelpFilename(ObjectType type); extern const char* GetHelpFilename(ObjectType type);
extern char* GetHelpFilename(const char *token); extern const char* GetHelpFilename(const char *token);
extern bool IsType(const char *token); extern bool IsType(const char *token);
extern bool IsFunction(const char *token); extern bool IsFunction(const char *token);
extern char* GetHelpText(const char *token); extern const char* GetHelpText(const char *token);

View File

@ -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 ! 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 ( Math::TestAngle(a, iAngle-focus/2.0f, iAngle+focus/2.0f) )
{ {
if ( (sens >= 0.0f && d < best) || if ( (sens >= 0.0f && d < best) ||

View File

@ -232,7 +232,7 @@ bool CDisplayInfo::EventProcess(const Event &event)
m_bInfoMaximized = false; m_bInfoMaximized = false;
} }
//? m_main->SetEditFull(m_bInfoMaximized); //? m_main->SetEditFull(m_bInfoMaximized);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); pw = dynamic_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw != 0 ) if ( pw != 0 )
{ {
pw->SetMaximized(m_bInfoMaximized); pw->SetMaximized(m_bInfoMaximized);
@ -834,7 +834,7 @@ void CDisplayInfo::StopDisplayInfo()
if ( m_bEditLock ) // editing running program? 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 ) if ( pw != 0 )
{ {
pw->SetState(STATE_ENABLE); // CStudio operating pw->SetState(STATE_ENABLE); // CStudio operating
@ -929,7 +929,7 @@ CObject* CDisplayInfo::SearchToto()
for ( i=0 ; i<1000000 ; i++ ) 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 == 0 ) break;
type = pObj->GetType(); type = pObj->GetType();
@ -991,7 +991,7 @@ void ObjectWrite(FILE* file, ObjectList list[], int i)
strcat(line, res); strcat(line, res);
strcat(line, "\\u "); strcat(line, "\\u ");
p = GetHelpFilename(list[i].type); p = const_cast<char*>(GetHelpFilename(list[i].type));
if ( p[0] == 0 ) return; if ( p[0] == 0 ) return;
strcat(line, p+5); // skip "help\" strcat(line, p+5); // skip "help\"
p = strstr(line, ".txt"); p = strstr(line, ".txt");
@ -1019,7 +1019,7 @@ void CDisplayInfo::CreateObjectsFile()
bRadar = false; bRadar = false;
for ( i=0 ; i<1000000 ; i++ ) 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 == 0 ) break;
if ( !pObj->GetActif() ) continue; if ( !pObj->GetActif() ) continue;

View File

@ -55,9 +55,9 @@ CDisplayText::CDisplayText()
m_iMan = CInstanceManager::GetInstancePointer(); m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_DISPLAYTEXT, this); m_iMan->AddInstance(CLASS_DISPLAYTEXT, this);
m_engine = (Gfx::CEngine*)m_iMan->SearchInstance(CLASS_ENGINE); m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
m_sound = (CSoundInterface*)m_iMan->SearchInstance(CLASS_SOUND); m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
for ( i=0 ; i<MAXDTLINE ; i++ ) for ( i=0 ; i<MAXDTLINE ; i++ )
{ {

View File

@ -466,7 +466,7 @@ bool CEdit::EventProcess(const Event &event)
{ {
if ( event.param >= ' ' && event.param <= 255 ) if ( event.param >= ' ' && event.param <= 255 )
{ {
Insert((char)event.param); Insert(static_cast<char>(event.param));
SendModifEvent(); SendModifEvent();
return true; return true;
} }
@ -581,7 +581,7 @@ void CEdit::MouseDoubleClick(Math::Point mouse)
while ( i > 0 ) while ( i > 0 )
{ {
character = (unsigned char)m_text[i-1]; character = static_cast<unsigned char>(m_text[i-1]);
if ( !IsWord(character) ) break; if ( !IsWord(character) ) break;
i --; i --;
} }
@ -589,7 +589,7 @@ void CEdit::MouseDoubleClick(Math::Point mouse)
while ( i < m_len ) while ( i < m_len )
{ {
character = (unsigned char)m_text[i]; character = static_cast<unsigned char>(m_text[i]);
if ( !IsWord(character) ) break; if ( !IsWord(character) ) break;
i ++; i ++;
} }
@ -1651,12 +1651,12 @@ bool CEdit::ReadText(const char *filename, int addSize)
for ( iCount=0 ; iCount<iLines ; iCount++ ) for ( iCount=0 ; iCount<iLines ; iCount++ )
{ {
strcpy(m_image[iIndex].name, iName); 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].height = 1.0f/iLines;
m_image[iIndex].width = iWidth*0.75f; m_image[iIndex].width = iWidth*0.75f;
m_text[j] = (char)(iIndex++); // as an index into m_image m_text[j] = static_cast<char>(iIndex++); // as an index into m_image
m_format[j] = (unsigned char)Gfx::FONT_MASK_IMAGE; m_format[j] = static_cast<unsigned char>(Gfx::FONT_MASK_IMAGE);
j ++; j ++;
} }
} }
@ -2179,7 +2179,7 @@ void CEdit::Scroll()
{ {
value = m_scroll->GetVisibleValue(); value = m_scroll->GetVisibleValue();
value *= m_lineTotal-m_lineVisible; 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 ) 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; if ( !IsSpace(character) ) break;
m_cursor1 --; m_cursor1 --;
} }
if ( m_cursor1 > 0 ) 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) ) if ( IsSpace(character) )
{ {
while ( m_cursor1 > 0 ) 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; if ( !IsSpace(character) ) break;
m_cursor1 --; m_cursor1 --;
} }
@ -2314,7 +2314,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{ {
while ( m_cursor1 > 0 ) 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; if ( !IsWord(character) ) break;
m_cursor1 --; m_cursor1 --;
} }
@ -2323,7 +2323,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{ {
while ( m_cursor1 > 0 ) 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; if ( !IsSep(character) ) break;
m_cursor1 --; m_cursor1 --;
} }
@ -2343,12 +2343,12 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{ {
if ( m_cursor1 < m_len ) if ( m_cursor1 < m_len )
{ {
character = (unsigned char)m_text[m_cursor1]; character = static_cast<unsigned char>(m_text[m_cursor1]);
if ( IsSpace(character) ) if ( IsSpace(character) )
{ {
while ( m_cursor1 < m_len ) 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; if ( !IsSpace(character) ) break;
m_cursor1 ++; m_cursor1 ++;
} }
@ -2357,7 +2357,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{ {
while ( m_cursor1 < m_len ) 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; if ( !IsWord(character) ) break;
m_cursor1 ++; m_cursor1 ++;
} }
@ -2366,7 +2366,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{ {
while ( m_cursor1 < m_len ) 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; if ( !IsSep(character) ) break;
m_cursor1 ++; m_cursor1 ++;
} }
@ -2375,7 +2375,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
while ( m_cursor1 < m_len ) 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; if ( !IsSpace(character) ) break;
m_cursor1 ++; m_cursor1 ++;
} }
@ -3034,7 +3034,7 @@ bool CEdit::MinMaj(bool bMaj)
for ( i=c1 ; i<c2 ; i++ ) 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); if ( bMaj ) character = GetToUpper(character);
else character = GetToLower(character); else character = GetToLower(character);
m_text[i] = character; m_text[i] = character;

View File

@ -759,16 +759,16 @@ void CList::UpdateScroll()
value = 0.0f; value = 0.0f;
step = 0.0f; step = 0.0f;
} else { } else {
ratio = (float)m_displayLine / m_totalLine; ratio = static_cast<float>m_displayLine / m_totalLine;
if ( ratio > 1.0f ) ratio = 1.0f; 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 ) if ( value < 0.0f )
value = 0.0f; value = 0.0f;
if ( value > 1.0f ) if ( value > 1.0f )
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 ) if ( step < 0.0f )
step = 0.0f; step = 0.0f;
} }
@ -791,7 +791,7 @@ void CList::MoveScroll()
n = m_totalLine - m_displayLine; n = m_totalLine - m_displayLine;
pos = m_scroll->GetVisibleValue(); pos = m_scroll->GetVisibleValue();
pos += m_scroll->GetArrowStep() / 2.0f; // it's magic! 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 ) if ( m_firstLine < 0 )
m_firstLine = 0; m_firstLine = 0;
if ( m_firstLine > n ) if ( m_firstLine > n )

View File

@ -6575,7 +6575,7 @@ bool CMainDialog::IsDialog()
// Specifies the name of the scene to read. // Specifies the name of the scene to read.
void CMainDialog::SetSceneRead(char* name) void CMainDialog::SetSceneRead(const char* name)
{ {
strcpy(m_sceneRead, name); strcpy(m_sceneRead, name);
} }
@ -6589,7 +6589,7 @@ char* CMainDialog::GetSceneRead()
// Specifies the name of the scene to read. // Specifies the name of the scene to read.
void CMainDialog::SetStackRead(char* name) void CMainDialog::SetStackRead(const char* name)
{ {
strcpy(m_stackRead, name); strcpy(m_stackRead, name);
} }
@ -6603,7 +6603,7 @@ char* CMainDialog::GetStackRead()
// Specifies the name of the chosen to play scene. // Specifies the name of the chosen to play scene.
void CMainDialog::SetSceneName(char* name) void CMainDialog::SetSceneName(const char* name)
{ {
strcpy(m_sceneName, name); strcpy(m_sceneName, name);
} }

View File

@ -71,9 +71,9 @@ public:
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
void ChangePhase(Phase phase); void ChangePhase(Phase phase);
void SetSceneRead(char* name); void SetSceneRead(const char* name);
void SetStackRead(char* name); void SetStackRead(const char* name);
void SetSceneName(char* name); void SetSceneName(const char* name);
void SetSceneRank(int rank); void SetSceneRank(int rank);
char* GetSceneRead(); char* GetSceneRead();
char* GetStackRead(); char* GetStackRead();

View File

@ -35,8 +35,8 @@ CMainMap::CMainMap()
m_iMan = CInstanceManager::GetInstancePointer(); m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_MAP, this); m_iMan->AddInstance(CLASS_MAP, this);
m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
m_event = (CEventQueue*)m_iMan->SearchInstance(CLASS_EVENT); m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
m_engine = (Gfx::CEngine*)m_iMan->SearchInstance(CLASS_ENGINE); m_engine = (Gfx::CEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
m_mapMode = 1; m_mapMode = 1;
@ -57,7 +57,7 @@ void CMainMap::CreateMap()
CWindow* pw; CWindow* pw;
Math::Point pos, dim; Math::Point pos, dim;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) { if (pw == nullptr) {
pos.x = 0.0f; pos.x = 0.0f;
pos.y = 0.0f; pos.y = 0.0f;
@ -83,11 +83,11 @@ void CMainMap::SetFixImage(const char *filename)
CWindow* pw; CWindow* pw;
CMap* pm; CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return; return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr) if (pm == nullptr)
return; return;
@ -104,11 +104,11 @@ void CMainMap::FloorColorMap(Gfx::Color floor, Gfx::Color water)
CWindow* pw; CWindow* pw;
CMap* pm; CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return; return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm != nullptr) { if (pm != nullptr) {
pm->SetFloorColor(floor); pm->SetFloorColor(floor);
pm->SetWaterColor(water); pm->SetWaterColor(water);
@ -123,18 +123,18 @@ void CMainMap::ShowMap(bool bShow)
CMap* pm; CMap* pm;
CSlider* ps; CSlider* ps;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return; return;
if (bShow) { if (bShow) {
DimMap(); DimMap();
} else { } else {
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm != nullptr) if (pm != nullptr)
pm->ClearState(STATE_VISIBLE); pm->ClearState(STATE_VISIBLE);
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
if (ps != nullptr) if (ps != nullptr)
ps->ClearState(STATE_VISIBLE); ps->ClearState(STATE_VISIBLE);
} }
@ -150,10 +150,10 @@ void CMainMap::DimMap()
Math::Point pos, dim; Math::Point pos, dim;
float value; float value;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return; return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr) if (pm == nullptr)
return; return;
@ -166,7 +166,7 @@ void CMainMap::DimMap()
pm->SetPos(pos); pm->SetPos(pos);
pm->SetDim(dim); pm->SetDim(dim);
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
if (ps != nullptr) { if (ps != nullptr) {
ps->SetState(STATE_VISIBLE, (m_mapMode != 0)); ps->SetState(STATE_VISIBLE, (m_mapMode != 0));
@ -193,15 +193,15 @@ float CMainMap::GetZoomMap()
CMap* pm; CMap* pm;
CSlider* ps; CSlider* ps;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return ZOOM_MIN; return ZOOM_MIN;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr) if (pm == nullptr)
return ZOOM_MIN; return ZOOM_MIN;
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
if (ps == nullptr) if (ps == nullptr)
return ZOOM_MIN; return ZOOM_MIN;
@ -216,14 +216,14 @@ void CMainMap::ZoomMap(float zoom)
CMap* pm; CMap* pm;
CSlider* ps; CSlider* ps;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return; return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr) if (pm == nullptr)
return; return;
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
if (ps == nullptr) if (ps == nullptr)
return; return;
@ -245,14 +245,14 @@ void CMainMap::ZoomMap()
CSlider* ps; CSlider* ps;
float zoom; float zoom;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return; return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr) if (pm == nullptr)
return; return;
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
if (ps == nullptr) if (ps == nullptr)
return; return;
@ -273,15 +273,15 @@ void CMainMap::MapEnable(bool bEnable)
CMap* pm; CMap* pm;
CSlider* ps; CSlider* ps;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return; return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm != nullptr) if (pm != nullptr)
pm->SetEnable(bEnable); pm->SetEnable(bEnable);
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
if (ps != nullptr) if (ps != nullptr)
ps->SetState(STATE_ENABLE, bEnable); ps->SetState(STATE_ENABLE, bEnable);
} }
@ -293,11 +293,11 @@ void CMainMap::SetToy(bool bToy)
CWindow* pw; CWindow* pw;
CMap* pm; CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return; return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr) if (pm == nullptr)
return; return;
@ -312,11 +312,11 @@ void CMainMap::SetFixParam(float zoom, float ox, float oy, float angle,
CWindow* pw; CWindow* pw;
CMap* pm; CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return; return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr) if (pm == nullptr)
return; return;
@ -334,11 +334,11 @@ void CMainMap::UpdateMap()
CWindow* pw; CWindow* pw;
CMap* pm; CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return; return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm != nullptr) if (pm != nullptr)
pm->UpdateTerrain(); pm->UpdateTerrain();
} }
@ -365,12 +365,12 @@ CObject* CMainMap::DetectMap(Math::Point pos, bool &bInMap)
CWindow* pw; CWindow* pw;
CMap* pm; CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return 0; return 0;
bInMap = false; bInMap = false;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm == nullptr) if (pm == nullptr)
return 0; return 0;
return pm->DetectObject(pos, bInMap); return pm->DetectObject(pos, bInMap);
@ -384,11 +384,11 @@ void CMainMap::SetHighlight(CObject* pObj)
CWindow* pw; CWindow* pw;
CMap* pm; CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr) if (pw == nullptr)
return; return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm != nullptr) if (pm != nullptr)
pm->SetHighlight(pObj); pm->SetHighlight(pObj);
} }

View File

@ -139,7 +139,7 @@ bool CMainShort::CreateShortcuts()
for ( i=0 ; i<1000000 ; i++ ) 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 == nullptr ) break;
if ( !pObj->GetActif() ) continue; if ( !pObj->GetActif() ) continue;