From a397922e8d53c6f7ff469d38e5139fd003c705b5 Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Tue, 18 Sep 2012 00:01:00 +0200 Subject: [PATCH] warnings fight in progress. --- lib/simpleini/SimpleIni.h | 46 +++++++------- src/CBot/CBotString.cpp | 21 ++----- src/app/app.h | 8 +-- src/app/system_windows.h | 8 +-- src/common/event.cpp | 4 +- src/common/global.h | 4 +- src/common/metafile.cpp | 4 +- src/common/misc.cpp | 4 +- src/common/misc.h | 2 +- src/graphics/engine/particle.cpp | 2 +- src/graphics/engine/particle.h | 2 +- src/object/auto/autosafe.cpp | 4 +- src/object/brain.cpp | 10 +-- src/object/motion/motionhuman.cpp | 3 +- src/object/robotmain.cpp | 100 +++++++++++++++--------------- src/object/robotmain.h | 10 +-- src/script/cbottoken.cpp | 10 +-- src/script/cbottoken.h | 10 +-- src/script/script.cpp | 1 + src/ui/displayinfo.cpp | 10 +-- src/ui/displaytext.cpp | 6 +- src/ui/edit.cpp | 36 +++++------ src/ui/list.cpp | 8 +-- src/ui/maindialog.cpp | 6 +- src/ui/maindialog.h | 6 +- src/ui/mainmap.cpp | 70 ++++++++++----------- src/ui/mainshort.cpp | 2 +- 27 files changed, 190 insertions(+), 207 deletions(-) diff --git a/lib/simpleini/SimpleIni.h b/lib/simpleini/SimpleIni.h index f9f36bbe..c75408e3 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(-1)) { return false; } while (uLen > m_scratch.size()) { @@ -1360,7 +1360,7 @@ CSimpleIniTempl::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(lSize)) { delete[] pData; return SI_FILE; } @@ -1394,7 +1394,7 @@ CSimpleIniTempl::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(-1)) { return SI_FAIL; } @@ -1753,7 +1753,7 @@ CSimpleIniTempl::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 (a_pData - pCurrLine); memmove(pDataLine, pCurrLine, nLen * sizeof(SI_CHAR)); pDataLine[nLen] = '\0'; } @@ -1816,10 +1816,10 @@ CSimpleIniTempl::CopyString( { size_t uLen = 0; if (sizeof(SI_CHAR) == sizeof(char)) { - uLen = strlen((const char *)a_pString); + uLen = strlen(static_cast(a_pString)); } else if (sizeof(SI_CHAR) == sizeof(wchar_t)) { - uLen = wcslen((const wchar_t *)a_pString); + uLen = wcslen(reinterpret_cast(a_pString)); } else { for ( ; a_pString[uLen]; ++uLen) /*loop*/ ; @@ -2225,7 +2225,7 @@ CSimpleIniTempl::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 (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 (*pLeft) - static_cast (*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 (locase(*pLeft)) - static_cast (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(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(a_pInputData)) + 1; if (uInputLen > a_uOutputDataSize) { return false; } @@ -3195,12 +3195,12 @@ template 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(pLeft), + reinterpret_cast(pRight)) < 0; } if (sizeof(SI_CHAR) == sizeof(wchar_t)) { - return _wcsicmp((const wchar_t *)pLeft, - (const wchar_t *)pRight) < 0; + return _wcsicmp(reinterpret_cast(pLeft), + reinterpret_cast(pRight)) < 0; } return SI_GenericNoCase()(pLeft, pRight); } @@ -3251,9 +3251,9 @@ public: int retval = MultiByteToWideChar( m_uCodePage, 0, - a_pInputData, (int) a_uInputDataLen, + a_pInputData, static_cast (a_uInputDataLen), 0, 0); - return (size_t)(retval > 0 ? retval : -1); + return static_cast(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 (a_uInputDataLen), + static_cast (a_pOutputData), static_cast (a_uOutputDataSize)); return (nSize > 0); } @@ -3297,9 +3297,9 @@ public: { int retval = WideCharToMultiByte( m_uCodePage, 0, - (const wchar_t *) a_pInputData, -1, + static_cast (a_pInputData), -1, 0, 0, 0, 0); - return (size_t) (retval > 0 ? retval : -1); + return static_cast (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 (a_pInputData), -1, + a_pOutputData, static_cast (a_uOutputDataSize), 0, 0); return retval > 0; } }; diff --git a/src/CBot/CBotString.cpp b/src/CBot/CBotString.cpp index 7223e6f0..84f9ca2f 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(m_pData); - delete[] (unsigned char *)m_pData; + delete[] reinterpret_cast(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 (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 (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(m_pData); m_pData = pNewData; m_nSize = nNewSize; m_nMaxSize = nNewMax; diff --git a/src/app/app.h b/src/app/app.h index 1834a679..849f4412 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(-1); } }; diff --git a/src/app/system_windows.h b/src/app/system_windows.h index 72d9f88d..c9743e67 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(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(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(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(str.size()), &wstrTo[0], size_needed); return wstrTo; } diff --git a/src/common/event.cpp b/src/common/event.cpp index d082ba9a..87c8a5c2 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(g_uniqueEventType+1); + g_uniqueEventType = static_cast(i); return g_uniqueEventType; } diff --git a/src/common/global.h b/src/common/global.h index 88f753ea..9cb3dd9a 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 d1692cef..4e7e9163 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(buffer); int i; for ( i=0 ; i(malloc(sizeof(MetaHeader)*m_list[i].total)); offset = 4; for ( j=0 ; j(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 002c910b..dd559e4c 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 37a3975b..c177deb8 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 c53aea59..f78e2425 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 82b1c120..ea0c183c 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 d0471851..3f2dcb25 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(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(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(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(param)); //? sprintf(line, "\tturn(%.1f);\n", param); strncat(buffer, line, max-1); } if ( oper == TO_PEN ) { - color = (int)param; + color = static_cast(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 2349e1ea..560a0de6 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 fb683ae6..c4da53d8 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(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(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(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(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(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(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(pVar->GetValInt()); pResult->SetValInt( feof( pFile ) ); @@ -604,15 +604,15 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app) m_app = app; - m_eventQueue = static_cast(m_iMan->SearchInstance(CLASS_EVENT)); - m_engine = static_cast(m_iMan->SearchInstance(CLASS_ENGINE)); - m_lightMan = static_cast(m_iMan->SearchInstance(CLASS_LIGHT)); - m_particle = static_cast(m_iMan->SearchInstance(CLASS_PARTICULE)); - m_water = static_cast(m_iMan->SearchInstance(CLASS_WATER)); - m_cloud = static_cast(m_iMan->SearchInstance(CLASS_CLOUD)); - m_lightning = static_cast(m_iMan->SearchInstance(CLASS_BLITZ)); - m_planet = static_cast(m_iMan->SearchInstance(CLASS_PLANET)); - m_sound = static_cast(m_iMan->SearchInstance(CLASS_SOUND)); + m_eventQueue = static_cast(m_iMan->SearchInstance(CLASS_EVENT)); + m_engine = static_cast(m_iMan->SearchInstance(CLASS_ENGINE)); + m_lightMan = static_cast(m_iMan->SearchInstance(CLASS_LIGHT)); + m_particle = static_cast(m_iMan->SearchInstance(CLASS_PARTICULE)); + m_water = static_cast(m_iMan->SearchInstance(CLASS_WATER)); + m_cloud = static_cast(m_iMan->SearchInstance(CLASS_CLOUD)); + m_lightning = static_cast(m_iMan->SearchInstance(CLASS_BLITZ)); + m_planet = static_cast(m_iMan->SearchInstance(CLASS_PLANET)); + m_sound = static_cast(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(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(m_interface->CreateEdit(pos, dim, 0, EVENT_CMD)); + Ui::CEdit* pe = dynamic_cast(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(m_interface->SearchControl(EVENT_CMD)); + Ui::CEdit* pe = dynamic_cast(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(m_interface->SearchControl(EVENT_CMD)); + Ui::CEdit* pe = dynamic_cast(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(m_interface->SearchControl(EVENT_BUTTON_QUIT)); + Ui::CButton* pb = dynamic_cast(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(m_interface->SearchControl(EVENT_BUTTON_QUIT)); + Ui::CButton* pb = dynamic_cast(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(m_interface->SearchControl(EVENT_BUTTON_QUIT)); + Ui::CButton* pb = dynamic_cast(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(m_interface->SearchControl(EVENT_BUTTON_QUIT)); + Ui::CButton* pb = dynamic_cast(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(m_interface->SearchControl(EVENT_WINDOW2)); + Ui::CWindow* pw = dynamic_cast(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(pw->SearchControl(static_cast(EVENT_DT_VISIT0+i))); + Ui::CButton* button = dynamic_cast(pw->SearchControl(static_cast(EVENT_DT_VISIT0+i))); if (button == nullptr || !button->TestState(Ui::STATE_ENABLE)) continue; - Ui::CGroup* group = static_cast(pw->SearchControl(static_cast(EVENT_DT_GROUP0+i))); + Ui::CGroup* group = dynamic_cast(pw->SearchControl(static_cast(EVENT_DT_GROUP0+i))); if (group != nullptr) { event = static_cast(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(m_interface->SearchControl(EVENT_TOOLTIP)); + Ui::CWindow* pw = dynamic_cast(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(m_interface->SearchControl(EVENT_WINDOW1)); + Ui::CWindow* pw = dynamic_cast(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) { pm = nullptr; } else { - pm = static_cast(pw->SearchControl(EVENT_OBJECT_MAP)); + pm = dynamic_cast(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(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((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(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(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(m_interface->SearchControl(EVENT_SPEED)); + Ui::CButton* pb = dynamic_cast(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 db960164..96fdc517 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 a9cc5990..0bb368c2 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 4be5f037..1f2d6e78 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 4f7f1ee6..bcf0bda4 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 43909b25..e6e95a27 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(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(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(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(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(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 63075ee7..85786555 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(m_iMan->SearchInstance(CLASS_ENGINE)); + m_interface = static_cast(m_iMan->SearchInstance(CLASS_INTERFACE)); + m_sound = static_cast(m_iMan->SearchInstance(CLASS_SOUND)); for ( i=0 ; i= ' ' && event.param <= 255 ) { - Insert((char)event.param); + Insert(static_cast(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(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(m_text[i]); if ( !IsWord(character) ) break; i ++; } @@ -1651,12 +1651,12 @@ bool CEdit::ReadText(const char *filename, int addSize) for ( iCount=0 ; iCount(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(iIndex++); // as an index into m_image + m_format[j] = static_cast(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(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(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(m_text[m_cursor1-1]); if ( IsSpace(character) ) { while ( m_cursor1 > 0 ) { - character = (unsigned char)m_text[m_cursor1-1]; + character = static_cast(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(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(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(m_text[m_cursor1]); if ( IsSpace(character) ) { while ( m_cursor1 < m_len ) { - character = (unsigned char)m_text[m_cursor1]; + character = static_cast(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(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(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(m_text[m_cursor1]); if ( !IsSpace(character) ) break; m_cursor1 ++; } @@ -3034,7 +3034,7 @@ bool CEdit::MinMaj(bool bMaj) for ( i=c1 ; i(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 80609d7f..2aeb240d 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_castm_displayLine / m_totalLine; if ( ratio > 1.0f ) ratio = 1.0f; - value = (float)m_firstLine / (m_totalLine - m_displayLine); + value = static_castm_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_cast1.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(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 4523b2ce..96a1a4c3 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 df36a4df..8b0ef816 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 601c0358..f8531788 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(m_iMan->SearchInstance(CLASS_INTERFACE)); + m_event = static_cast(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(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; if (bShow) { DimMap(); } else { - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm != nullptr) pm->ClearState(STATE_VISIBLE); - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); + ps = static_cast(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(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(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return ZOOM_MIN; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm == nullptr) return ZOOM_MIN; - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); + ps = static_cast(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm == nullptr) return; - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); + ps = static_cast(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm == nullptr) return; - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); + ps = static_cast(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm != nullptr) pm->SetEnable(bEnable); - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); + ps = static_cast(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return 0; bInMap = false; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(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(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm != nullptr) pm->SetHighlight(pObj); } diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp index f51ee9b6..5b1271f5 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(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == nullptr ) break; if ( !pObj->GetActif() ) continue;