diff options
Diffstat (limited to 'src')
37 files changed, 456 insertions, 495 deletions
diff --git a/src/CBot/CBotString.cpp b/src/CBot/CBotString.cpp index 7223e6f..84f9ca2 100644 --- a/src/CBot/CBotString.cpp +++ b/src/CBot/CBotString.cpp @@ -597,18 +597,6 @@ static void DestructElements(CBotString* pOldData, int nCount) } } -static void CopyElements(CBotString* pDest, CBotString* pSrc, int nCount) -{ - while (nCount--) - { - *pDest = *pSrc; - ++pDest; - ++pSrc; - } -} - - - // set the array size void CBotStringArray::SetSize(int nNewSize) @@ -618,15 +606,14 @@ void CBotStringArray::SetSize(int nNewSize) // shrink to nothing DestructElements(m_pData, m_nSize); -// delete[] static_cast<unsigned char *>(m_pData); - delete[] (unsigned char *)m_pData; + delete[] reinterpret_cast<unsigned char *>(m_pData); m_pData = NULL; m_nSize = m_nMaxSize = 0; } else if (m_pData == NULL) { // create one with exact size - m_pData = (CBotString*) new unsigned char[nNewSize * sizeof(CBotString)]; + m_pData = reinterpret_cast<CBotString*> (new unsigned char[nNewSize * sizeof(CBotString)]); ConstructElements(m_pData, nNewSize); @@ -663,7 +650,7 @@ void CBotStringArray::SetSize(int nNewSize) else nNewMax = nNewSize; // no slush - CBotString* pNewData = (CBotString*) new unsigned char[nNewMax * sizeof(CBotString)]; + CBotString* pNewData = reinterpret_cast<CBotString*> (new unsigned char[nNewMax * sizeof(CBotString)]); // copy new data from old memcpy(pNewData, m_pData, m_nSize * sizeof(CBotString)); @@ -673,7 +660,7 @@ void CBotStringArray::SetSize(int nNewSize) // Get rid of old stuff (note: no destructors called) - delete[] (unsigned char *)m_pData; + delete[] reinterpret_cast<unsigned char *>(m_pData); m_pData = pNewData; m_nSize = nNewSize; m_nMaxSize = nNewMax; diff --git a/src/app/app.h b/src/app/app.h index 1275d10..8848be1 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -129,11 +129,11 @@ enum InputSlot struct InputBinding { //! Key - int key; + unsigned int key; //! Key modifier (e.g. shift, control) - int kmod; + unsigned int kmod; //! Joystick button - int joy; + unsigned int joy; inline InputBinding() { @@ -142,7 +142,7 @@ struct InputBinding inline void Reset() { - key = kmod = joy = -1; + key = kmod = joy = static_cast<unsigned int>(-1); } }; diff --git a/src/app/system_windows.h b/src/app/system_windows.h index 72d9f88..c9743e6 100644 --- a/src/app/system_windows.h +++ b/src/app/system_windows.h @@ -48,18 +48,18 @@ struct SystemTimeStamp // Convert a wide Unicode string to an UTF8 string std::string UTF8_Encode_Windows(const std::wstring &wstr) { - int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL); + int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast<int>(wstr.size()), NULL, 0, NULL, NULL); std::string strTo(size_needed, 0); - WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast<int>(wstr.size()), &strTo[0], size_needed, NULL, NULL); return strTo; } // Convert an UTF8 string to a wide Unicode String std::wstring UTF8_Decode_Windows(const std::string &str) { - int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0); + int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast<int>(str.size()), NULL, 0); std::wstring wstrTo(size_needed, 0); - MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed); + MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast<int>(str.size()), &wstrTo[0], size_needed); return wstrTo; } diff --git a/src/common/event.cpp b/src/common/event.cpp index d082ba9..87c8a5c 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -24,8 +24,8 @@ static EventType g_uniqueEventType = EVENT_USER; EventType GetUniqueEventType() { - int i = (int)g_uniqueEventType+1; - g_uniqueEventType = (EventType)i; + int i = static_cast<int>(g_uniqueEventType+1); + g_uniqueEventType = static_cast<EventType>(i); return g_uniqueEventType; } diff --git a/src/common/global.h b/src/common/global.h index 88f753e..9cb3dd9 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -118,7 +118,7 @@ enum KeyRank // TODO: move to CRobotMain extern long g_id; // unique identifier -extern long g_build; // constructible buildings -extern long g_researchDone; // research done +extern int g_build; // constructible buildings +extern int g_researchDone; // research done extern long g_researchEnable; // research available extern float g_unit; // conversion factor diff --git a/src/common/metafile.cpp b/src/common/metafile.cpp index d1692ce..4e7e916 100644 --- a/src/common/metafile.cpp +++ b/src/common/metafile.cpp @@ -34,7 +34,7 @@ static unsigned char table_codec[23] = void Codec(void* buffer, int len, int start) { - unsigned char *b = (unsigned char*)buffer; + unsigned char *b = static_cast<unsigned char*>(buffer); int i; for ( i=0 ; i<len ; i++ ) @@ -350,7 +350,7 @@ int CMetaFile::MetaOpen(char *metaname) strcpy(m_list[i].name, metaname); // memorized the name fread(&m_list[i].total, sizeof(int), 1, m_list[i].stream); - m_list[i].headers = (MetaHeader*)malloc(sizeof(MetaHeader)*m_list[i].total); + m_list[i].headers = static_cast<MetaHeader*>(malloc(sizeof(MetaHeader)*m_list[i].total)); offset = 4; for ( j=0 ; j<m_list[i].total ; j++ ) diff --git a/src/common/misc.cpp b/src/common/misc.cpp index 11f60ae..2ed6e2c 100644 --- a/src/common/misc.cpp +++ b/src/common/misc.cpp @@ -258,7 +258,7 @@ bool Xfer(char* src, char* dst) return false; } - buffer = (char*)malloc(10000); + buffer = static_cast<char*>(malloc(10000)); while ( true ) { @@ -338,7 +338,7 @@ bool CopyFileListToTemp(char* filename, int* list, int total) // Adds an extension to file, if doesn't already one. -void AddExt(char* filename, char* ext) +void AddExt(char* filename, const char* ext) { if ( strchr(filename, '.') != 0 ) return; // already an extension? strcat(filename, ext); @@ -347,7 +347,7 @@ void AddExt(char* filename, char* ext) // Specifies the user folder. -void UserDir(bool bUser, char* dir) +void UserDir(bool bUser, const char* dir) { g_bUserDir = bUser; strcpy(g_userDir, dir); diff --git a/src/common/misc.h b/src/common/misc.h index 002c910..f6fd609 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 UserDir(bool bUser, char* dir); +extern void AddExt(char* filename, const char* ext); +extern void UserDir(bool bUser, const char* dir); extern void UserDir(char* buffer, const char* dir, const char* def); diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp index 37a3975..c177deb 100644 --- a/src/graphics/engine/particle.cpp +++ b/src/graphics/engine/particle.cpp @@ -200,7 +200,7 @@ void Gfx::CParticle::DrawParticle(int sheet) // TODO! } -bool Gfx::CParticle::WriteWheelTrace(char *filename, int width, int height, Math::Vector dl, Math::Vector ur) +bool Gfx::CParticle::WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur) { GetLogger()->Trace("CParticle::WriteWheelTrace() stub!\n"); // TODO! diff --git a/src/graphics/engine/particle.h b/src/graphics/engine/particle.h index c53aea5..f78e242 100644 --- a/src/graphics/engine/particle.h +++ b/src/graphics/engine/particle.h @@ -306,7 +306,7 @@ public: void FrameParticle(float rTime); void DrawParticle(int sheet); - bool WriteWheelTrace(char *filename, int width, int height, Math::Vector dl, Math::Vector ur); + bool WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur); protected: void DeleteRank(int rank); diff --git a/src/object/auto/autosafe.cpp b/src/object/auto/autosafe.cpp index 82b1c12..ea0c183 100644 --- a/src/object/auto/autosafe.cpp +++ b/src/object/auto/autosafe.cpp @@ -414,9 +414,9 @@ int CAutoSafe::CountKeys() pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - oType = pObj->GetType(); if ( pObj->GetTruck() != 0 ) continue; + oType = pObj->GetType(); if ( oType != OBJECT_KEYa && oType != OBJECT_KEYb && oType != OBJECT_KEYc && @@ -588,7 +588,6 @@ CObject* CAutoSafe::SearchVehicle() { CObject* pObj; Math::Vector cPos, oPos; - ObjectType oType; float dist; int i; @@ -599,7 +598,6 @@ CObject* CAutoSafe::SearchVehicle() pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - oType = pObj->GetType(); if ( pObj == m_object ) continue; if ( pObj->GetTruck() != 0 ) continue; diff --git a/src/object/brain.cpp b/src/object/brain.cpp index d047185..3f2dcb2 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -2789,7 +2789,7 @@ void CBrain::TraceRecordStart() } delete m_traceRecordBuffer; - m_traceRecordBuffer = (TraceRecord*)malloc(sizeof(TraceRecord)*MAXTRACERECORD); + m_traceRecordBuffer = static_cast<TraceRecord*>(malloc(sizeof(TraceRecord)*MAXTRACERECORD)); m_traceRecordIndex = 0; } @@ -2836,7 +2836,7 @@ void CBrain::TraceRecordFrame() if ( color != m_traceColor ) { - TraceRecordOper(TO_PEN, (float)color); + TraceRecordOper(TO_PEN, static_cast<float>(color)); } m_traceOper = oper; @@ -2858,7 +2858,7 @@ void CBrain::TraceRecordStop() if ( m_traceRecordBuffer == 0 ) return; max = 10000; - buffer = (char*)malloc(max); + buffer = static_cast<char*>(malloc(max)); *buffer = 0; strncat(buffer, "extern void object::AutoDraw()\n{\n", max-1); @@ -2944,14 +2944,14 @@ bool CBrain::TraceRecordPut(char *buffer, int max, TraceOper oper, float param) if ( oper == TO_TURN ) { param = -param*180.0f/Math::PI; - sprintf(line, "\tturn(%d);\n", (int)param); + sprintf(line, "\tturn(%d);\n", static_cast<int>(param)); //? sprintf(line, "\tturn(%.1f);\n", param); strncat(buffer, line, max-1); } if ( oper == TO_PEN ) { - color = (int)param; + color = static_cast<int>(param); if ( color == -1 ) strncat(buffer, "\tpenup();\n", max-1); if ( color == 1 ) strncat(buffer, "\tpendown(Black);\n", max-1); if ( color == 8 ) strncat(buffer, "\tpendown(Yellow);\n", max-1); diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp index 2349e1e..560a0de 100644 --- a/src/object/motion/motionhuman.cpp +++ b/src/object/motion/motionhuman.cpp @@ -710,7 +710,7 @@ bool CMotionHuman::EventFrame(const Event &event) float tSt[9], tNd[9]; float aa, bb, shield, deadFactor, level; int i, ii, st, nd, action, legAction, armAction; - bool bOnBoard, bSwim, bStop; + bool bOnBoard, bSwim; if ( m_engine->GetPause() ) { @@ -837,7 +837,6 @@ bool CMotionHuman::EventFrame(const Event &event) m_armTimeSwim += Math::Min(Math::Max(s,a,3.0f),15.0f)*event.rTime*0.05f; } - bStop = ( s == 0.0f ); // stop? prog = 0.0f; if ( m_physics->GetLand() ) // on the ground? diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index fb683ae..3d1aff0 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -87,8 +87,8 @@ const float UNIT = 4.0f; // Global variables. long g_id; // unique identifier -long g_build; // constructible buildings -long g_researchDone; // research done +int g_build; // constructible buildings +int g_researchDone; // research done long g_researchEnable; // research available float g_unit; // conversion factor @@ -172,7 +172,7 @@ bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exceptio // save the channel file pVar = pThis->GetItem("handle"); - pVar->SetValInt((long)pFile); + pVar->SetValInt(reinterpret_cast<long>(pFile)); } return true; @@ -215,7 +215,7 @@ bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception // don't open? no problem :) if ( pVar->GetInit() != IS_DEF) return true; - FILE* pFile= (FILE*)pVar->GetValInt(); + FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt()); fclose(pFile); m_CompteurFileOpen --; @@ -282,7 +282,7 @@ bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) // Registered the channel file pVar = pThis->GetItem("handle"); - pVar->SetValInt((long)pFile); + pVar->SetValInt(reinterpret_cast<long>(pFile)); pResult->SetValInt(true); return true; @@ -328,7 +328,7 @@ bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; } - FILE* pFile= (FILE*)pVar->GetValInt(); + FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt()); fclose(pFile); m_CompteurFileOpen --; @@ -365,7 +365,7 @@ bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; } - FILE* pFile= (FILE*)pVar->GetValInt(); + FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt()); int res = fputs(param+CBotString("\n"), pFile); @@ -404,7 +404,7 @@ bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; } - FILE* pFile= (FILE*)pVar->GetValInt(); + FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt()); char chaine[2000]; int i; @@ -445,7 +445,7 @@ bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; } - FILE* pFile= (FILE*)pVar->GetValInt(); + FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt()); pResult->SetValInt( feof( pFile ) ); @@ -604,15 +604,15 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app) m_app = app; - m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT)); - m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE)); - m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT)); - m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE)); - m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER)); - m_cloud = static_cast<Gfx::CCloud*>(m_iMan->SearchInstance(CLASS_CLOUD)); - m_lightning = static_cast<Gfx::CLightning*>(m_iMan->SearchInstance(CLASS_BLITZ)); - m_planet = static_cast<Gfx::CPlanet*>(m_iMan->SearchInstance(CLASS_PLANET)); - m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND)); + m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT)); + m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE)); + m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT)); + m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE)); + m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER)); + m_cloud = static_cast<Gfx::CCloud*>(m_iMan->SearchInstance(CLASS_CLOUD)); + m_lightning = static_cast<Gfx::CLightning*>(m_iMan->SearchInstance(CLASS_BLITZ)); + m_planet = static_cast<Gfx::CPlanet*>(m_iMan->SearchInstance(CLASS_PLANET)); + m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND)); m_interface = new Ui::CInterface(); m_terrain = new Gfx::CTerrain(m_iMan); @@ -682,15 +682,15 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app) m_windowPos = Math::Point(0.15f, 0.17f); m_windowDim = Math::Point(0.70f, 0.66f); - float fValue; - int iValue; + // TODO: profile + // float fValue; + // int iValue; - /* TODO: profile - if (GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue; - if (GetLocalProfileFloat("Edit", "WindowPos.x", fValue)) m_windowPos.x = fValue; - if (GetLocalProfileFloat("Edit", "WindowPos.y", fValue)) m_windowPos.y = fValue; - if (GetLocalProfileFloat("Edit", "WindowDim.x", fValue)) m_windowDim.x = fValue; - if (GetLocalProfileFloat("Edit", "WindowDim.y", fValue)) m_windowDim.y = fValue; */ + // if (GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue; + // if (GetLocalProfileFloat("Edit", "WindowPos.x", fValue)) m_windowPos.x = fValue; + // if (GetLocalProfileFloat("Edit", "WindowPos.y", fValue)) m_windowPos.y = fValue; + // if (GetLocalProfileFloat("Edit", "WindowDim.x", fValue)) m_windowDim.x = fValue; + // if (GetLocalProfileFloat("Edit", "WindowDim.y", fValue)) m_windowDim.y = fValue; m_IOPublic = false; m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f); @@ -737,7 +737,7 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app) for (int i = 0; i < OBJECT_MAX; i++) { - ObjectType type = (ObjectType)i; + ObjectType type = static_cast<ObjectType>(i); const char* token = GetObjectName(type); if (token[0] != 0) CBotProgram::DefineNum(token, type); @@ -943,7 +943,7 @@ void CRobotMain::ChangePhase(Phase phase) dim.y = 18.0f/480.0f; pos.x = 50.0f/640.0f; pos.y = 452.0f/480.0f; - Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->CreateEdit(pos, dim, 0, EVENT_CMD)); + Ui::CEdit* pe = dynamic_cast<Ui::CEdit*>(m_interface->CreateEdit(pos, dim, 0, EVENT_CMD)); if (pe == nullptr) return; pe->ClearState(Ui::STATE_VISIBLE); m_cmdEdit = false; // hidden for now @@ -1145,7 +1145,7 @@ bool CRobotMain::EventProcess(const Event &event) event.type == EVENT_KEY_DOWN && event.key.key == KEY(PAUSE)) // Pause ? { - Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD)); + Ui::CEdit* pe = dynamic_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD)); if (pe == nullptr) return false; pe->SetState(Ui::STATE_VISIBLE); pe->SetFocus(true); @@ -1157,7 +1157,7 @@ bool CRobotMain::EventProcess(const Event &event) event.key.key == KEY(RETURN) && m_cmdEdit) { char cmd[50]; - Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD)); + Ui::CEdit* pe = dynamic_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD)); if (pe == nullptr) return false; pe->GetText(cmd, 50); pe->SetText(""); @@ -1843,7 +1843,7 @@ void CRobotMain::StartDisplayInfo(int index, bool movie) } //! Beginning of the displaying of instructions -void CRobotMain::StartDisplayInfo(char *filename, int index) +void CRobotMain::StartDisplayInfo(const char *filename, int index) { if (m_cmdEdit) return; @@ -1857,7 +1857,7 @@ void CRobotMain::StartDisplayInfo(char *filename, int index) m_sound->MuteAll(true); } - Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT)); + Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT)); if (pb != nullptr) { pb->ClearState(Ui::STATE_VISIBLE); @@ -1889,7 +1889,7 @@ void CRobotMain::StopDisplayInfo() if (!m_editLock) { - Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT)); + Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT)); if (pb != nullptr) pb->SetState(Ui::STATE_VISIBLE); @@ -1930,7 +1930,7 @@ void CRobotMain::StartSuspend() m_infoObject = DeselectAll(); // removes the control buttons m_displayText->HideText(true); - Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT)); + Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT)); if (pb != nullptr) pb->ClearState(Ui::STATE_VISIBLE); @@ -1940,7 +1940,7 @@ void CRobotMain::StartSuspend() //! End of dialogue during the game void CRobotMain::StopSuspend() { - Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT)); + Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT)); if (pb != nullptr) pb->SetState(Ui::STATE_VISIBLE); @@ -2047,7 +2047,7 @@ void CRobotMain::StartDisplayVisit(EventType event) { if (m_editLock) return; - Ui::CWindow* pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); + Ui::CWindow* pw = dynamic_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if (pw == nullptr) return; if (event == EVENT_NULL) // visit by keyboard shortcut? @@ -2064,10 +2064,10 @@ void CRobotMain::StartDisplayVisit(EventType event) i --; if (i < 0) i = Ui::MAXDTLINE-1; - Ui::CButton* button = static_cast<Ui::CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_VISIT0+i))); + Ui::CButton* button = dynamic_cast<Ui::CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_VISIT0+i))); if (button == nullptr || !button->TestState(Ui::STATE_ENABLE)) continue; - Ui::CGroup* group = static_cast<Ui::CGroup*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_GROUP0+i))); + Ui::CGroup* group = dynamic_cast<Ui::CGroup*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_GROUP0+i))); if (group != nullptr) { event = static_cast<EventType>(EVENT_DT_VISIT0+i); @@ -2819,7 +2819,7 @@ void CRobotMain::CreateTooltip(Math::Point pos, const char* text) m_interface->CreateWindows(pos, dim, 1, EVENT_TOOLTIP); - Ui::CWindow* pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_TOOLTIP)); + Ui::CWindow* pw = dynamic_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_TOOLTIP)); if (pw != nullptr) { pw->SetState(Ui::STATE_SHADOW); @@ -2843,7 +2843,7 @@ void CRobotMain::HelpObject() CObject* obj = GetSelect(); if (obj == nullptr) return; - char* filename = GetHelpFilename(obj->GetType()); + const char* filename = GetHelpFilename(obj->GetType()); if (filename[0] == 0) return; StartDisplayInfo(filename, -1); @@ -2919,7 +2919,7 @@ void CRobotMain::ChangeCamera() } //! Remote control the camera using the arrow keys -void CRobotMain::KeyCamera(EventType type, long key) +void CRobotMain::KeyCamera(EventType type, unsigned int key) { // TODO: rewrite key handling to input bindings @@ -3068,14 +3068,14 @@ bool CRobotMain::EventFrame(const Event &event) m_planet->EventProcess(event); Ui::CMap* pm = nullptr; - Ui::CWindow* pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + Ui::CWindow* pw = dynamic_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) { pm = nullptr; } else { - pm = static_cast<Ui::CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + pm = dynamic_cast<Ui::CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm != nullptr) pm->FlushObject(); } @@ -3510,7 +3510,7 @@ void CRobotMain::ScenePerso() { obj->SetDrawFront(true); // draws the interface - CMotionHuman* mh = (CMotionHuman*)obj->GetMotion(); + CMotionHuman* mh = static_cast<CMotionHuman*>(obj->GetMotion()); if (mh != nullptr) mh->StartDisplayPerso(); } @@ -5137,7 +5137,7 @@ void CRobotMain::SetShowLimit(int i, Gfx::ParticleType parti, CObject *obj, m_showLimit[i].pos = pos; m_showLimit[i].radius = radius; m_showLimit[i].duration = duration; - m_showLimit[i].total = (int)((radius*2.0f*Math::PI)/dist); + m_showLimit[i].total = static_cast<int>((radius*2.0f*Math::PI)/dist); if (m_showLimit[i].total > MAXSHOWPARTI) m_showLimit[i].total = MAXSHOWPARTI; m_showLimit[i].time = 0.0f; @@ -5350,8 +5350,6 @@ void CRobotMain::LoadFileScript(CObject *obj, char* filename, int objRank, ObjectType type = obj->GetType(); if (type == OBJECT_HUMAN) return; - char* name = m_dialog->GetSceneName(); - int rank = m_dialog->GetSceneRank(); char fn[MAX_FNAME]; strcpy(fn, filename); @@ -5523,7 +5521,7 @@ bool CRobotMain::IsBusy() } //! Writes an object into the backup file -void CRobotMain::IOWriteObject(FILE *file, CObject* obj, char *cmd) +void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd) { if (obj->GetType() == OBJECT_FIX) return; @@ -5643,7 +5641,7 @@ bool CRobotMain::IOWriteScene(char *filename, char *filecbot, char *info) sprintf(line, "Map zoom=%.2f\n", m_map->GetZoomMap()); fputs(line, file); - sprintf(line, "DoneResearch bits=%d\n", g_researchDone); + sprintf(line, "DoneResearch bits=%d\n", static_cast<int>(g_researchDone)); fputs(line, file); float sleep, delay, magnetic, progress; @@ -5981,7 +5979,7 @@ void CRobotMain::ResetObject() // Removes all pyrotechnic effects in progress. while ( true ) { - pyro = (CPyro*)m_iMan->SearchInstance(CLASS_PYRO, 0); + pyro = static_cast<CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, 0)); if ( pyro == 0 ) break; pyro->DeleteObject(); @@ -6364,7 +6362,7 @@ char* CRobotMain::GetFilesDir() //! Change the player's name -void CRobotMain::SetGamerName(char *name) +void CRobotMain::SetGamerName(const char *name) { strcpy(m_gamerName, name); SetGlobalGamerName(m_gamerName); @@ -6420,7 +6418,7 @@ void CRobotMain::SetSpeed(float speed) { // TODO: m_app->SetSimulationSpeed(speed); - Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_SPEED)); + Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_SPEED)); if (pb != nullptr) { if (speed == 1.0f) diff --git a/src/object/robotmain.h b/src/object/robotmain.h index db96016..25c55f6 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); @@ -245,7 +245,7 @@ public: char* GetPublicDir(); char* GetFilesDir(); - void SetGamerName(char *name); + void SetGamerName(const char *name); char* GetGamerName(); int GetGamerFace(); int GetGamerGlasses(); @@ -287,7 +287,7 @@ public: bool IsBusy(); bool IOWriteScene(char *filename, char *filecbot, char *info); CObject* IOReadScene(char *filename, char *filecbot); - void IOWriteObject(FILE *file, CObject* pObj, char *cmd); + void IOWriteObject(FILE *file, CObject* pObj, const char *cmd); CObject* IOReadObject(char *line, char* filename, int objRank); int CreateSpot(Math::Vector pos, Gfx::Color color); @@ -314,7 +314,7 @@ protected: CObject* DetectObject(Math::Point pos); void ChangeCamera(); void RemoteCamera(float pan, float zoom, float rTime); - void KeyCamera(EventType event, long key); + void KeyCamera(EventType event, unsigned int key); void AbortMovie(); bool IsSelectable(CObject* pObj); void SelectOneObject(CObject* pObj, bool displayError=true); @@ -446,8 +446,8 @@ protected: char m_gamerName[100]; - long m_freeBuild; // constructible buildings - long m_freeResearch; // researches possible + int m_freeBuild; // constructible buildings + int m_freeResearch; // researches possible ShowLimit m_showLimit[MAXSHOWLIMIT]; diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index a9cc599..0bb368c 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -24,7 +24,7 @@ // Seeking the name of an object. -char* GetObjectName(ObjectType type) +const char* GetObjectName(ObjectType type) { if ( type == OBJECT_PORTICO ) return "Portico"; if ( type == OBJECT_BASE ) return "SpaceShip"; @@ -117,7 +117,7 @@ char* GetObjectName(ObjectType type) // Seeking the name of a secondary object. // (because Otto thinks that Germans do not like nuclear power) -char* GetObjectAlias(ObjectType type) +const char* GetObjectAlias(ObjectType type) { if ( type == OBJECT_NUCLEAR ) return "FuelCellPlant"; if ( type == OBJECT_URANIUM ) return "PlatinumOre"; @@ -130,7 +130,7 @@ char* GetObjectAlias(ObjectType type) // Returns the help file to use for the object. -char* GetHelpFilename(ObjectType type) +const char* GetHelpFilename(ObjectType type) { if ( type == OBJECT_BASE ) return "help\\object\\base.txt"; if ( type == OBJECT_DERRICK ) return "help\\object\\derrick.txt"; @@ -215,7 +215,7 @@ char* GetHelpFilename(ObjectType type) // Returns the help file to use for instruction. -char* GetHelpFilename(const char *token) +const char* GetHelpFilename(const char *token) { if ( strcmp(token, "if" ) == 0 ) return "help\\cbot\\if.txt"; if ( strcmp(token, "else" ) == 0 ) return "help\\cbot\\if.txt"; @@ -427,7 +427,7 @@ bool IsFunction(const char *token) // Returns using a compact instruction. -char* GetHelpText(const char *token) +const char* GetHelpText(const char *token) { if ( strcmp(token, "if" ) == 0 ) return "if ( condition ) { bloc }"; if ( strcmp(token, "else" ) == 0 ) return "else { bloc }"; diff --git a/src/script/cbottoken.h b/src/script/cbottoken.h index 4be5f03..1f2d6e7 100644 --- a/src/script/cbottoken.h +++ b/src/script/cbottoken.h @@ -25,12 +25,12 @@ // Procedures. -extern char* GetObjectName(ObjectType type); -extern char* GetObjectAlias(ObjectType type); -extern char* GetHelpFilename(ObjectType type); -extern char* GetHelpFilename(const char *token); +extern const char* GetObjectName(ObjectType type); +extern const char* GetObjectAlias(ObjectType type); +extern const char* GetHelpFilename(ObjectType type); +extern const char* GetHelpFilename(const char *token); extern bool IsType(const char *token); extern bool IsFunction(const char *token); -extern char* GetHelpText(const char *token); +extern const char* GetHelpText(const char *token); diff --git a/src/script/script.cpp b/src/script/script.cpp index 4f7f1ee..b29c625 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) || @@ -2754,7 +2755,7 @@ CScript::~CScript() // Gives the script editable block of text. -void CScript::PutScript(Ui::CEdit* edit, char* name) +void CScript::PutScript(Ui::CEdit* edit, const char* name) { if ( m_script == 0 ) { @@ -3516,7 +3517,7 @@ void CScript::GetError(char* buffer) // New program. -void CScript::New(Ui::CEdit* edit, char* name) +void CScript::New(Ui::CEdit* edit, const char* name) { FILE *file = NULL; char res[100]; diff --git a/src/script/script.h b/src/script/script.h index 5462a18..5c1118f 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -53,7 +53,7 @@ public: static void InitFonctions(); - void PutScript(Ui::CEdit* edit, char* name); + void PutScript(Ui::CEdit* edit, const char* name); bool GetScript(Ui::CEdit* edit); bool GetCompile(); @@ -74,7 +74,7 @@ public: int GetError(); void GetError(char* buffer); - void New(Ui::CEdit* edit, char* name); + void New(Ui::CEdit* edit, const char* name); bool SendScript(char* text); bool ReadScript(const char* filename); bool WriteScript(const char* filename); diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp index 43909b2..e6e95a2 100644 --- a/src/ui/displayinfo.cpp +++ b/src/ui/displayinfo.cpp @@ -232,7 +232,7 @@ bool CDisplayInfo::EventProcess(const Event &event) m_bInfoMaximized = false; } //? m_main->SetEditFull(m_bInfoMaximized); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = dynamic_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw != 0 ) { pw->SetMaximized(m_bInfoMaximized); @@ -834,7 +834,7 @@ void CDisplayInfo::StopDisplayInfo() if ( m_bEditLock ) // editing running program? { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = dynamic_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != 0 ) { pw->SetState(STATE_ENABLE); // CStudio operating @@ -929,7 +929,7 @@ CObject* CDisplayInfo::SearchToto() for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; type = pObj->GetType(); @@ -991,7 +991,7 @@ void ObjectWrite(FILE* file, ObjectList list[], int i) strcat(line, res); strcat(line, "\\u "); - p = GetHelpFilename(list[i].type); + p = const_cast<char*>(GetHelpFilename(list[i].type)); if ( p[0] == 0 ) return; strcat(line, p+5); // skip "help\" p = strstr(line, ".txt"); @@ -1019,7 +1019,7 @@ void CDisplayInfo::CreateObjectsFile() bRadar = false; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; if ( !pObj->GetActif() ) continue; diff --git a/src/ui/displaytext.cpp b/src/ui/displaytext.cpp index 63075ee..8578655 100644 --- a/src/ui/displaytext.cpp +++ b/src/ui/displaytext.cpp @@ -55,9 +55,9 @@ CDisplayText::CDisplayText() m_iMan = CInstanceManager::GetInstancePointer(); m_iMan->AddInstance(CLASS_DISPLAYTEXT, this); - m_engine = (Gfx::CEngine*)m_iMan->SearchInstance(CLASS_ENGINE); - m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); - m_sound = (CSoundInterface*)m_iMan->SearchInstance(CLASS_SOUND); + m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE)); + m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE)); + m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND)); for ( i=0 ; i<MAXDTLINE ; i++ ) { diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index c1e7e5a..8c875b6 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.cpp @@ -466,7 +466,7 @@ bool CEdit::EventProcess(const Event &event) { if ( event.param >= ' ' && event.param <= 255 ) { - Insert((char)event.param); + Insert(static_cast<char>(event.param)); SendModifEvent(); return true; } @@ -581,7 +581,7 @@ void CEdit::MouseDoubleClick(Math::Point mouse) while ( i > 0 ) { - character = (unsigned char)m_text[i-1]; + character = static_cast<unsigned char>(m_text[i-1]); if ( !IsWord(character) ) break; i --; } @@ -589,7 +589,7 @@ void CEdit::MouseDoubleClick(Math::Point mouse) while ( i < m_len ) { - character = (unsigned char)m_text[i]; + character = static_cast<unsigned char>(m_text[i]); if ( !IsWord(character) ) break; i ++; } @@ -1651,12 +1651,12 @@ bool CEdit::ReadText(const char *filename, int addSize) for ( iCount=0 ; iCount<iLines ; iCount++ ) { strcpy(m_image[iIndex].name, iName); - m_image[iIndex].offset = (float)iCount/iLines; + m_image[iIndex].offset = static_cast<float>(iCount/iLines); m_image[iIndex].height = 1.0f/iLines; m_image[iIndex].width = iWidth*0.75f; - m_text[j] = (char)(iIndex++); // as an index into m_image - m_format[j] = (unsigned char)Gfx::FONT_MASK_IMAGE; + m_text[j] = static_cast<char>(iIndex++); // as an index into m_image + m_format[j] = static_cast<unsigned char>(Gfx::FONT_MASK_IMAGE); j ++; } } @@ -2179,7 +2179,7 @@ void CEdit::Scroll() { value = m_scroll->GetVisibleValue(); value *= m_lineTotal-m_lineVisible; - Scroll((int)(value+0.5f), true); + Scroll(static_cast<int>(value+0.5f), true); } } @@ -2293,19 +2293,19 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) { while ( m_cursor1 > 0 ) { - character = (unsigned char)m_text[m_cursor1-1]; + character = static_cast<unsigned char>(m_text[m_cursor1-1]); if ( !IsSpace(character) ) break; m_cursor1 --; } if ( m_cursor1 > 0 ) { - character = (unsigned char)m_text[m_cursor1-1]; + character = static_cast<unsigned char>(m_text[m_cursor1-1]); if ( IsSpace(character) ) { while ( m_cursor1 > 0 ) { - character = (unsigned char)m_text[m_cursor1-1]; + character = static_cast<unsigned char>(m_text[m_cursor1-1]); if ( !IsSpace(character) ) break; m_cursor1 --; } @@ -2314,7 +2314,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) { while ( m_cursor1 > 0 ) { - character = (unsigned char)m_text[m_cursor1-1]; + character = static_cast<unsigned char>(m_text[m_cursor1-1]); if ( !IsWord(character) ) break; m_cursor1 --; } @@ -2323,7 +2323,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) { while ( m_cursor1 > 0 ) { - character = (unsigned char)m_text[m_cursor1-1]; + character = static_cast<unsigned char>(m_text[m_cursor1-1]); if ( !IsSep(character) ) break; m_cursor1 --; } @@ -2343,12 +2343,12 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) { if ( m_cursor1 < m_len ) { - character = (unsigned char)m_text[m_cursor1]; + character = static_cast<unsigned char>(m_text[m_cursor1]); if ( IsSpace(character) ) { while ( m_cursor1 < m_len ) { - character = (unsigned char)m_text[m_cursor1]; + character = static_cast<unsigned char>(m_text[m_cursor1]); if ( !IsSpace(character) ) break; m_cursor1 ++; } @@ -2357,7 +2357,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) { while ( m_cursor1 < m_len ) { - character = (unsigned char)m_text[m_cursor1]; + character = static_cast<unsigned char>(m_text[m_cursor1]); if ( !IsWord(character) ) break; m_cursor1 ++; } @@ -2366,7 +2366,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) { while ( m_cursor1 < m_len ) { - character = (unsigned char)m_text[m_cursor1]; + character = static_cast<unsigned char>(m_text[m_cursor1]); if ( !IsSep(character) ) break; m_cursor1 ++; } @@ -2375,7 +2375,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) while ( m_cursor1 < m_len ) { - character = (unsigned char)m_text[m_cursor1]; + character = static_cast<unsigned char>(m_text[m_cursor1]); if ( !IsSpace(character) ) break; m_cursor1 ++; } @@ -3034,7 +3034,7 @@ bool CEdit::MinMaj(bool bMaj) for ( i=c1 ; i<c2 ; i++ ) { - character = (unsigned char)m_text[i]; + character = static_cast<unsigned char>(m_text[i]); if ( bMaj ) character = GetToUpper(character); else character = GetToLower(character); m_text[i] = character; diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp index e5780fd..1188903 100644 --- a/src/ui/editvalue.cpp +++ b/src/ui/editvalue.cpp @@ -18,12 +18,6 @@ // editvalue.cpp -//#include <windows.h> -//#include <stdio.h> -//#include <d3d.h> - -//#include "old/d3dengine.h" -//#include "old/math3d.h" #include "common/event.h" #include "common/misc.h" #include "common/iman.h" @@ -294,7 +288,7 @@ void CEditValue::SetValue(float value, bool bSendMessage) if ( m_type == EVT_INT ) { - sprintf(text, "%d", (int)value); + sprintf(text, "%d", static_cast<int>(value)); } if ( m_type == EVT_FLOAT ) @@ -304,7 +298,7 @@ void CEditValue::SetValue(float value, bool bSendMessage) if ( m_type == EVT_100 ) { - sprintf(text, "%d%%", (int)(value*100.0f)); + sprintf(text, "%d%%", static_cast<int>(value*100.0f)); } m_edit->SetText(text); @@ -321,19 +315,19 @@ void CEditValue::SetValue(float value, bool bSendMessage) float CEditValue::GetValue() { char text[100]; - float value; - - if ( m_edit == 0 ) 0.0f; + float value = 0.0f; - m_edit->GetText(text, 100); - sscanf(text, "%f", &value); - - if ( m_type == EVT_100 ) + if ( m_edit != 0 ) { - value = (value+0.5f)/100.0f; - if ( value < 0.01f ) value = 0.0f; // less than 1%? - } + m_edit->GetText(text, 100); + sscanf(text, "%f", &value); + if ( m_type == EVT_100 ) + { + value = (value+0.5f)/100.0f; + if ( value < 0.01f ) value = 0.0f; // less than 1%? + } + } return value; } diff --git a/src/ui/editvalue.h b/src/ui/editvalue.h index c5c857c..1469b69 100644 --- a/src/ui/editvalue.h +++ b/src/ui/editvalue.h @@ -75,15 +75,13 @@ protected: void MoveAdjust(); void HiliteValue(const Event &event); -protected: Ui::CEdit* m_edit; Ui::CButton* m_buttonUp; Ui::CButton* m_buttonDown; - - EditValueType m_type; - float m_stepValue; - float m_minValue; - float m_maxValue; + EditValueType m_type; + float m_stepValue; + float m_minValue; + float m_maxValue; }; diff --git a/src/ui/image.cpp b/src/ui/image.cpp index aff2dcb..3c52d86 100644 --- a/src/ui/image.cpp +++ b/src/ui/image.cpp @@ -75,7 +75,7 @@ bool CImage::Create(Math::Point pos, Math::Point dim, int icon, EventType eventT // Specifies the name of the image display. -void CImage::SetFilenameImage(char *name) +void CImage::SetFilenameImage(const char *name) { if ( m_filename[0] != 0 ) { diff --git a/src/ui/image.h b/src/ui/image.h index f24684a..b73a5ae 100644 --- a/src/ui/image.h +++ b/src/ui/image.h @@ -42,7 +42,7 @@ public: void Draw(); - void SetFilenameImage(char *name); + void SetFilenameImage(const char *name); char* GetFilenameImage(); protected: diff --git a/src/ui/list.cpp b/src/ui/list.cpp index 7bebb81..5ecebf3 100644 --- a/src/ui/list.cpp +++ b/src/ui/list.cpp @@ -602,7 +602,7 @@ bool CList::GetBlink() // Specifies the text of a line. -void CList::SetName(int i, char* name) +void CList::SetName(int i, const char* name) { if ( i < 0 || i >= LISTMAXTOTAL ) return; @@ -759,16 +759,16 @@ void CList::UpdateScroll() value = 0.0f; step = 0.0f; } else { - ratio = (float)m_displayLine / m_totalLine; + ratio = static_cast<float>(m_displayLine) / m_totalLine; if ( ratio > 1.0f ) ratio = 1.0f; - value = (float)m_firstLine / (m_totalLine - m_displayLine); + value = static_cast<float>(m_firstLine) / (m_totalLine - m_displayLine); if ( value < 0.0f ) value = 0.0f; if ( value > 1.0f ) value = 1.0f; - step = (float)1.0f/ (m_totalLine - m_displayLine); + step = static_cast<float>(1.0f)/ (m_totalLine - m_displayLine); if ( step < 0.0f ) step = 0.0f; } @@ -791,7 +791,7 @@ void CList::MoveScroll() n = m_totalLine - m_displayLine; pos = m_scroll->GetVisibleValue(); pos += m_scroll->GetArrowStep() / 2.0f; // it's magic! - m_firstLine = (int)(pos * n); + m_firstLine = static_cast<int>(pos * n); if ( m_firstLine < 0 ) m_firstLine = 0; if ( m_firstLine > n ) diff --git a/src/ui/list.h b/src/ui/list.h index 4b866f6..2408111 100644 --- a/src/ui/list.h +++ b/src/ui/list.h @@ -69,7 +69,7 @@ class CList : public CControl void SetBlink(bool bEnable); bool GetBlink(); - void SetName(int i, char* name); + void SetName(int i, const char* name); char* GetName(int i); void SetCheck(int i, bool bMode); diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 9ef9aaa..a2fc733 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -138,13 +138,13 @@ CMainDialog::CMainDialog(CInstanceManager* iMan) m_app = CApplication::GetInstancePointer(); - m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN); - m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); - m_eventQueue = (CEventQueue*)m_iMan->SearchInstance(CLASS_EVENT); - m_engine = (Gfx::CEngine*)m_iMan->SearchInstance(CLASS_ENGINE); - m_particle = (Gfx::CParticle*)m_iMan->SearchInstance(CLASS_PARTICULE); - m_camera = (Gfx::CCamera*)m_iMan->SearchInstance(CLASS_CAMERA); - m_sound = (CSoundInterface*)m_iMan->SearchInstance(CLASS_SOUND); + m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN)); + m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE)); + m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT)); + m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE)); + m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE)); + m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA)); + m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND)); m_phase = PHASE_NAME; m_phaseSetup = PHASE_SETUPg; @@ -652,7 +652,7 @@ void CMainDialog::ChangePhase(Phase phase) for ( i=0 ; i<6 ; i++ ) { int ti[6] = {11, 179, 180, 181, 182, 183}; - pb = pw->CreateButton(pos, ddim, ti[i], (EventType)(EVENT_INTERFACE_PGLASS0+i)); + pb = pw->CreateButton(pos, ddim, ti[i], static_cast<EventType>(EVENT_INTERFACE_PGLASS0+i)); pb->SetState(STATE_SHADOW); pos.x += (30.0f+2.8f)/640.0f; } @@ -673,7 +673,7 @@ void CMainDialog::ChangePhase(Phase phase) pos.x = 340.0f/640.0f; for ( i=0 ; i<3 ; i++ ) { - pco = pw->CreateColor(pos, ddim, -1, (EventType)(EVENT_INTERFACE_PC0a+j*3+i)); + pco = pw->CreateColor(pos, ddim, -1, static_cast<EventType>(EVENT_INTERFACE_PC0a+j*3+i)); pco->SetState(STATE_SHADOW); pos.x += 20.0f/640.0f; } @@ -686,7 +686,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 18.0f/480.0f; for ( i=0 ; i<3 ; i++ ) { - psl = pw->CreateSlider(pos, ddim, 0, (EventType)(EVENT_INTERFACE_PCRa+i)); + psl = pw->CreateSlider(pos, ddim, 0, static_cast<EventType>(EVENT_INTERFACE_PCRa+i)); psl->SetState(STATE_SHADOW); psl->SetLimit(0.0f, 255.0f); psl->SetArrowStep(16.0f); @@ -709,7 +709,7 @@ void CMainDialog::ChangePhase(Phase phase) pos.x = 340.0f/640.0f; for ( i=0 ; i<3 ; i++ ) { - pco = pw->CreateColor(pos, ddim, -1, (EventType)(EVENT_INTERFACE_PC0b+j*3+i)); + pco = pw->CreateColor(pos, ddim, -1, static_cast<EventType>(EVENT_INTERFACE_PC0b+j*3+i)); pco->SetState(STATE_SHADOW); pos.x += 20.0f/640.0f; } @@ -722,7 +722,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 18.0f/480.0f; for ( i=0 ; i<3 ; i++ ) { - psl = pw->CreateSlider(pos, ddim, 0, (EventType)(EVENT_INTERFACE_PCRb+i)); + psl = pw->CreateSlider(pos, ddim, 0, static_cast<EventType>(EVENT_INTERFACE_PCRb+i)); psl->SetState(STATE_SHADOW); psl->SetLimit(0.0f, 255.0f); psl->SetArrowStep(16.0f); @@ -1497,8 +1497,8 @@ void CMainDialog::ChangePhase(Phase phase) pos.x = 510.0f/640.0f; pos.y = 168.0f/480.0f; ps = pw->CreateScroll(pos, ddim, -1, EVENT_INTERFACE_KSCROLL); - ps->SetVisibleRatio((float)KEY_VISIBLE/KEY_TOTAL); - ps->SetArrowStep(1.0f/((float)KEY_TOTAL-KEY_VISIBLE)); + ps->SetVisibleRatio(static_cast<float>(KEY_VISIBLE/KEY_TOTAL)); + ps->SetArrowStep(1.0f/(static_cast<float>(KEY_TOTAL-KEY_VISIBLE))); UpdateKey(); ddim.x = dim.x*6; @@ -2285,9 +2285,9 @@ bool CMainDialog::EventProcess(const Event &event) } if ( event.param == KEY(ESCAPE) ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) break; - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_NCANCEL); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NCANCEL)); if ( pb == 0 ) break; if ( pb->TestState(STATE_ENABLE) ) { @@ -2319,9 +2319,9 @@ bool CMainDialog::EventProcess(const Event &event) break; case EVENT_INTERFACE_NDELETE: - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) break; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) break; StartDeleteGame(pl->GetName(pl->GetSelect())); break; @@ -2466,7 +2466,7 @@ bool CMainDialog::EventProcess(const Event &event) m_phase == PHASE_USER || m_phase == PHASE_PROTO ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; if ( event.type == pw->GetEventTypeClose() || @@ -2489,7 +2489,7 @@ bool CMainDialog::EventProcess(const Event &event) switch( event.type ) { case EVENT_INTERFACE_CHAP: - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_CHAP); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_CHAP)); if ( pl == 0 ) break; m_chap[m_index] = pl->GetSelect(); UpdateSceneList(m_chap[m_index], m_sel[m_index]); @@ -2497,14 +2497,14 @@ bool CMainDialog::EventProcess(const Event &event) break; case EVENT_INTERFACE_LIST: - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_LIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_LIST)); if ( pl == 0 ) break; m_sel[m_index] = pl->GetSelect(); UpdateSceneResume((m_chap[m_index]+1)*100+(m_sel[m_index]+1)); break; case EVENT_INTERFACE_SOLUCE: - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_SOLUCE); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE)); if ( pb == 0 ) break; m_bSceneSoluce = !m_bSceneSoluce; pb->SetState(STATE_CHECK, m_bSceneSoluce); @@ -2538,7 +2538,7 @@ bool CMainDialog::EventProcess(const Event &event) m_phase == PHASE_SETUPc || m_phase == PHASE_SETUPs ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; if ( event.type == pw->GetEventTypeClose() || @@ -2584,7 +2584,7 @@ bool CMainDialog::EventProcess(const Event &event) m_phase == PHASE_SETUPcs || m_phase == PHASE_SETUPss ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; if ( event.type == pw->GetEventTypeClose() || @@ -2637,11 +2637,11 @@ bool CMainDialog::EventProcess(const Event &event) break; case EVENT_INTERFACE_FULL: - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) break; - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_FULL); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL)); if ( pc == 0 ) break; - pl = (CList*)pw->SearchControl(EVENT_LIST2); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2)); if ( pl == 0 ) break; if ( pc->TestState(STATE_CHECK) ) { @@ -2657,9 +2657,9 @@ bool CMainDialog::EventProcess(const Event &event) break; case EVENT_INTERFACE_APPLY: - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) break; - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_APPLY); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_APPLY)); if ( pb == 0 ) break; pb->ClearState(STATE_PRESS); pb->ClearState(STATE_HILIGHT); @@ -2953,7 +2953,7 @@ bool CMainDialog::EventProcess(const Event &event) if ( m_phase == PHASE_READ ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; if ( event.type == pw->GetEventTypeClose() || @@ -2986,7 +2986,7 @@ bool CMainDialog::EventProcess(const Event &event) if ( m_phase == PHASE_WRITEs || m_phase == PHASE_READs ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; if ( event.type == pw->GetEventTypeClose() || @@ -3095,12 +3095,12 @@ void CMainDialog::GlintMove() if ( m_phase == PHASE_SIMUL ) return; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; if ( m_phase == PHASE_INIT ) { - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTl); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTl)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.23f); @@ -3114,7 +3114,7 @@ void CMainDialog::GlintMove() pg->SetDim(dim); } - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTr); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTr)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.21f); @@ -3137,7 +3137,7 @@ void CMainDialog::GlintMove() m_phase == PHASE_USER || m_phase == PHASE_PROTO ) { - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTl); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTl)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.22f); @@ -3151,7 +3151,7 @@ void CMainDialog::GlintMove() pg->SetDim(dim); } - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTr); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTr)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.19f); @@ -3177,7 +3177,7 @@ void CMainDialog::GlintMove() m_phase == PHASE_SETUPcs || m_phase == PHASE_SETUPss ) { - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTu); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTu)); if ( pg != 0 ) { zoom.y = sinf(m_glintTime*0.27f); @@ -3190,7 +3190,7 @@ void CMainDialog::GlintMove() pg->SetDim(dim); } - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTr); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTr)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.29f); @@ -3210,7 +3210,7 @@ void CMainDialog::GlintMove() m_phase == PHASE_WRITEs || m_phase == PHASE_READs ) { - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTl); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTl)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.22f); @@ -3224,7 +3224,7 @@ void CMainDialog::GlintMove() pg->SetDim(dim); } - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTr); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTr)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.19f); @@ -3380,8 +3380,8 @@ void CMainDialog::FrameParticle(float rTime) return; } - nParti = (int)(*pParti++); - nGlint = (int)(*pGlint++); + nParti = static_cast<int>(*pParti++); + nGlint = static_cast<int>(*pGlint++); for ( i=0 ; i<10 ; i++ ) { @@ -3398,7 +3398,7 @@ void CMainDialog::FrameParticle(float rTime) m_partiPos[i].x = pParti[ii*5+0]/640.0f; m_partiPos[i].y = (480.0f-pParti[ii*5+1])/480.0f; m_partiTime[i] = pParti[ii*5+2]+Math::Rand()*pParti[ii*5+3]; - m_partiPhase[i] = (int)pParti[ii*5+4]; + m_partiPhase[i] = static_cast<int>(pParti[ii*5+4]); if ( m_partiPhase[i] == 3 ) { m_sound->Play(SOUND_PSHHH, SoundPos(m_partiPos[i]), 0.3f+Math::Rand()*0.3f); @@ -3498,7 +3498,7 @@ void CMainDialog::FrameParticle(float rTime) dim.x = 0.01f+Math::Rand()*0.01f; dim.y = dim.x/0.75f; m_particle->CreateParticle(pos, speed, dim, - (Gfx::ParticleType)(Gfx::PARTILENS1+rand()%3), + static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3), Math::Rand()*0.5f+0.5f, 2.0f, 0.0f, Gfx::SH_INTERFACE); } @@ -3595,7 +3595,7 @@ void CMainDialog::NiceParticle(Math::Point mouse, bool bPress) dim.x = 0.01f+Math::Rand()*0.01f; dim.y = dim.x/0.75f; m_particle->CreateParticle(pos, speed, dim, - (Gfx::ParticleType)(Gfx::PARTILENS1+rand()%3), + static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3), Math::Rand()*0.5f+0.5f, 2.0f, 0.0f, Gfx::SH_INTERFACE); } @@ -3663,9 +3663,9 @@ void CMainDialog::ReadNameList() char filenames[MAX_FNAME][100]; int nbFilenames, i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; pl->Flush(); @@ -3720,11 +3720,11 @@ void CMainDialog::UpdateNameControl() char* gamer; int total, sel; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT)); if ( pe == 0 ) return; gamer = m_main->GetGamerName(); @@ -3732,25 +3732,25 @@ void CMainDialog::UpdateNameControl() sel = pl->GetSelect(); pe->GetText(name, 100); - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_NCANCEL); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NCANCEL)); if ( pb != 0 ) { pb->SetState(STATE_ENABLE, gamer[0]!=0); } - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_NDELETE); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NDELETE)); if ( pb != 0 ) { pb->SetState(STATE_ENABLE, total>0 && sel!=-1); } - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_NOK); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NOK)); if ( pb != 0 ) { pb->SetState(STATE_ENABLE, name[0]!=0 || sel!=-1); } - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_PERSO); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_PERSO)); if ( pb != 0 ) { pb->SetState(STATE_ENABLE, name[0]!=0 || sel!=-1); @@ -3765,18 +3765,17 @@ void CMainDialog::UpdateNameList() CList* pl; CEdit* pe; char name[100]; - int total, sel, i; + int total, i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT)); if ( pe == 0 ) return; pe->GetText(name, 100); total = pl->GetTotal(); - sel = pl->GetSelect(); for ( i=0 ; i<total ; i++ ) { @@ -3802,11 +3801,11 @@ void CMainDialog::UpdateNameEdit() char* name; int sel; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT)); if ( pe == 0 ) return; sel = pl->GetSelect(); @@ -3834,9 +3833,9 @@ void CMainDialog::UpdateNameFace() char* name; int sel; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; sel = pl->GetSelect(); @@ -3856,11 +3855,11 @@ void CMainDialog::NameSelect() char name[100]; int sel; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT)); if ( pe == 0 ) return; pe->GetText(name, 100); @@ -3892,9 +3891,9 @@ void CMainDialog::NameCreate() char c; int len, i, j; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT)); if ( pe == 0 ) return; pe->GetText(name, 100); @@ -3995,9 +3994,9 @@ void CMainDialog::NameDelete() char* gamer; char dir[100]; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; sel = pl->GetSelect(); @@ -4048,21 +4047,21 @@ void CMainDialog::UpdatePerso() char name[100]; int i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_PHEAD); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_PHEAD)); if ( pb != 0 ) { pb->SetState(STATE_CHECK, m_persoTab==0); } - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_PBODY); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_PBODY)); if ( pb != 0 ) { pb->SetState(STATE_CHECK, m_persoTab==1); } - pl = (CLabel*)pw->SearchControl(EVENT_LABEL11); + pl = static_cast<CLabel*>(pw->SearchControl(EVENT_LABEL11)); if ( pl != 0 ) { if ( m_persoTab == 0 ) @@ -4077,7 +4076,7 @@ void CMainDialog::UpdatePerso() } } - pl = (CLabel*)pw->SearchControl(EVENT_LABEL12); + pl = static_cast<CLabel*>(pw->SearchControl(EVENT_LABEL12)); if ( pl != 0 ) { if ( m_persoTab == 0 ) @@ -4092,7 +4091,7 @@ void CMainDialog::UpdatePerso() } } - pl = (CLabel*)pw->SearchControl(EVENT_LABEL13); + pl = static_cast<CLabel*>(pw->SearchControl(EVENT_LABEL13)); if ( pl != 0 ) { if ( m_persoTab == 0 ) GetResource(RES_TEXT, RT_PERSO_HAIR, name); @@ -4100,7 +4099,7 @@ void CMainDialog::UpdatePerso() pl->SetName(name); } - pl = (CLabel*)pw->SearchControl(EVENT_LABEL14); + pl = static_cast<CLabel*>(pw->SearchControl(EVENT_LABEL14)); if ( pl != 0 ) { if ( m_persoTab == 0 ) @@ -4117,7 +4116,7 @@ void CMainDialog::UpdatePerso() for ( i=0 ; i<4 ; i++ ) { - pb = (CButton*)pw->SearchControl((EventType)(EVENT_INTERFACE_PFACE1+i)); + pb = static_cast<CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PFACE1+i))); if ( pb == 0 ) break; pb->SetState(STATE_VISIBLE, m_persoTab==0); pb->SetState(STATE_CHECK, i==m_perso.face); @@ -4125,7 +4124,7 @@ void CMainDialog::UpdatePerso() for ( i=0 ; i<10 ; i++ ) { - pb = (CButton*)pw->SearchControl((EventType)(EVENT_INTERFACE_PGLASS0+i)); + pb = static_cast<CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PGLASS0+i))); if ( pb == 0 ) break; pb->SetState(STATE_VISIBLE, m_persoTab==0); pb->SetState(STATE_CHECK, i==m_perso.glasses); @@ -4133,7 +4132,7 @@ void CMainDialog::UpdatePerso() for ( i=0 ; i<3*3 ; i++ ) { - pc = (CColor*)pw->SearchControl((EventType)(EVENT_INTERFACE_PC0a+i)); + pc = static_cast<CColor*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PC0a+i))); if ( pc == 0 ) break; if ( m_persoTab == 0 ) { @@ -4150,7 +4149,7 @@ void CMainDialog::UpdatePerso() pc->SetState(STATE_CHECK, EqColor(color, m_perso.colorCombi)); } - pc = (CColor*)pw->SearchControl((EventType)(EVENT_INTERFACE_PC0b+i)); + pc = static_cast<CColor*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PC0b+i))); if ( pc == 0 ) break; color.r = perso_color[3*10*2*m_persoTab+3*i+0]/255.0f; color.g = perso_color[3*10*2*m_persoTab+3*i+1]/255.0f; @@ -4162,7 +4161,7 @@ void CMainDialog::UpdatePerso() for ( i=0 ; i<3 ; i++ ) { - ps = (CSlider*)pw->SearchControl((EventType)(EVENT_INTERFACE_PCRa+i)); + ps = static_cast<CSlider*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PCRa+i))); if ( ps == 0 ) break; ps->SetState(STATE_VISIBLE, m_persoTab==1); } @@ -4170,21 +4169,21 @@ void CMainDialog::UpdatePerso() if ( m_persoTab == 1 ) { color = m_perso.colorCombi; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCRa); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCRa)); if ( ps != 0 ) ps->SetVisibleValue(color.r*255.0f); - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCGa); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCGa)); if ( ps != 0 ) ps->SetVisibleValue(color.g*255.0f); - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCBa); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCBa)); if ( ps != 0 ) ps->SetVisibleValue(color.b*255.0f); } if ( m_persoTab == 0 ) color = m_perso.colorHair; else color = m_perso.colorBand; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCRb); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCRb)); if ( ps != 0 ) ps->SetVisibleValue(color.r*255.0f); - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCGb); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCGb)); if ( ps != 0 ) ps->SetVisibleValue(color.g*255.0f); - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCBb); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCBb)); if ( ps != 0 ) ps->SetVisibleValue(color.b*255.0f); } @@ -4247,24 +4246,24 @@ void CMainDialog::ColorPerso() CSlider* ps; Gfx::Color color; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; color.a = 0.0f; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCRa); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCRa)); if ( ps != 0 ) color.r = ps->GetVisibleValue()/255.0f; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCGa); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCGa)); if ( ps != 0 ) color.g = ps->GetVisibleValue()/255.0f; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCBa); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCBa)); if ( ps != 0 ) color.b = ps->GetVisibleValue()/255.0f; if ( m_persoTab == 1 ) m_perso.colorCombi = color; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCRb); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCRb)); if ( ps != 0 ) color.r = ps->GetVisibleValue()/255.0f; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCGb); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCGb)); if ( ps != 0 ) color.g = ps->GetVisibleValue()/255.0f; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCBb); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCBb)); if ( ps != 0 ) color.b = ps->GetVisibleValue()/255.0f; if ( m_persoTab == 0 ) m_perso.colorHair = color; else m_perso.colorBand = color; @@ -4345,9 +4344,9 @@ void CMainDialog::IOReadName() time_t now; int i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_IONAME); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_IONAME)); if ( pe == 0 ) return; sprintf(resume, "%s %d", m_sceneName, m_chap[m_index]+1); @@ -4398,9 +4397,9 @@ void CMainDialog::IOReadList() char name[100]; int i, j; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST)); if ( pl == 0 ) return; pl->Flush(); @@ -4411,7 +4410,6 @@ void CMainDialog::IOReadList() file = fopen(filename, "r"); if ( file == NULL ) break; - strcmp(name, filename); // default name while ( fgets(line, 500, file) != NULL ) { for ( i=0 ; i<500 ; i++ ) @@ -4459,11 +4457,11 @@ void CMainDialog::IOUpdateList() char filename[100]; int sel, max; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST)); if ( pl == 0 ) return; - pi = (CImage*)pw->SearchControl(EVENT_INTERFACE_IOIMAGE); + pi = static_cast<CImage*>(pw->SearchControl(EVENT_INTERFACE_IOIMAGE)); if ( pi == 0 ) return; sel = pl->GetSelect(); @@ -4483,7 +4481,7 @@ void CMainDialog::IOUpdateList() pi->SetFilenameImage(""); } - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_IODELETE); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_IODELETE)); if ( pb != 0 ) { pb->SetState(STATE_ENABLE, sel < max-1); @@ -4507,9 +4505,9 @@ void CMainDialog::IODeleteScene() //struct _finddata_t fBuffer; int sel, max, i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST)); if ( pl == 0 ) return; sel = pl->GetSelect(); @@ -4566,11 +4564,11 @@ bool CMainDialog::IOWriteScene() char info[100]; int sel; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST)); if ( pl == 0 ) return false; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_IONAME); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_IONAME)); if ( pe == 0 ) return false; sel = pl->GetSelect(); @@ -4606,9 +4604,9 @@ bool CMainDialog::IOReadScene() char dir[100]; int sel, i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST)); if ( pl == 0 ) return false; sel = pl->GetSelect(); @@ -4719,9 +4717,9 @@ void CMainDialog::UpdateSceneChap(int &chap) int i, j; bool bPassed, bDo; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_CHAP); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_CHAP)); if ( pl == 0 ) return; pl->Flush(); @@ -4889,9 +4887,9 @@ void CMainDialog::UpdateSceneList(int chap, int &sel) int i, j; bool bPassed; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_LIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_LIST)); if ( pl == 0 ) return; pl->Flush(); @@ -4997,11 +4995,11 @@ void CMainDialog::ShowSoluceUpdate() { m_bSceneSoluce = false; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_RESUME); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_RESUME)); if ( pe == 0 ) return; - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SOLUCE); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE)); if ( pc == 0 ) return; if ( m_main->GetShowSoluce() ) @@ -5034,11 +5032,11 @@ void CMainDialog::UpdateSceneResume(int rank) int i, numTry; bool bPassed, bVisible; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_RESUME); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_RESUME)); if ( pe == 0 ) return; - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SOLUCE); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE)); if ( pc == 0 ) { @@ -5098,9 +5096,9 @@ void CMainDialog::UpdateDisplayDevice() char bufModes[5000]; int i, j, totalDevices, selectDevices, totalModes, selectModes; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_LIST1); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST1)); if ( pl == 0 ) return; pl->Flush(); @@ -5135,9 +5133,9 @@ void CMainDialog::UpdateDisplayMode() char bufModes[5000]; int i, j, totalDevices, selectDevices, totalModes, selectModes; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_LIST2); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2)); if ( pl == 0 ) return; pl->Flush(); @@ -5173,20 +5171,20 @@ void CMainDialog::ChangeDisplay() char* mode; bool bFull; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_LIST1); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST1)); if ( pl == 0 ) return; m_setupSelDevice = pl->GetSelect(); device = pl->GetName(m_setupSelDevice); - pl = (CList*)pw->SearchControl(EVENT_LIST2); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2)); if ( pl == 0 ) return; m_setupSelMode = pl->GetSelect(); mode = pl->GetName(m_setupSelMode); - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_FULL); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL)); if ( pc == 0 ) return; bFull = pc->TestState(STATE_CHECK); m_setupFull = bFull; @@ -5214,21 +5212,21 @@ void CMainDialog::UpdateApply() int sel1, sel2; bool bFull; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_APPLY); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_APPLY)); if ( pb == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_LIST1); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST1)); if ( pl == 0 ) return; sel1 = pl->GetSelect(); - pl = (CList*)pw->SearchControl(EVENT_LIST2); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2)); if ( pl == 0 ) return; sel2 = pl->GetSelect(); - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_FULL); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL)); bFull = pc->TestState(STATE_CHECK); if ( sel1 == m_setupSelDevice && @@ -5253,34 +5251,34 @@ void CMainDialog::UpdateSetupButtons() CSlider* ps; float value; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_TOTO); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_TOTO)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_engine->GetTotoMode()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_TOOLTIP); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_TOOLTIP)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bTooltip); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_GLINT); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_GLINT)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bGlint); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_RAIN); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_RAIN)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bRain); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_MOUSE); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_MOUSE)); if ( pc != 0 ) { /* TODO: nice mouse? @@ -5288,163 +5286,163 @@ void CMainDialog::UpdateSetupButtons() pc->SetState(STATE_ENABLE, m_engine->GetNiceMouseCap());*/ } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_EDITMODE); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EDITMODE)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_engine->GetEditIndentMode()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_EDITVALUE); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EDITVALUE)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_engine->GetEditIndentValue()>2); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SOLUCE4); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE4)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bSoluce4); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_MOVIES); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_MOVIES)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bMovies); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_NICERST); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_NICERST)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bNiceReset); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_HIMSELF); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_HIMSELF)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bHimselfDamage); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SCROLL); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SCROLL)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bCameraScroll); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_INVERTX); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_INVERTX)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bCameraInvertX); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_INVERTY); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_INVERTY)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bCameraInvertY); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_EFFECT); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EFFECT)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bEffect); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SHADOW); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SHADOW)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_engine->GetShadow()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_GROUND); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_GROUND)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_engine->GetGroundSpot()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_DIRTY); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_DIRTY)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_engine->GetDirty()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_FOG); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FOG)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_engine->GetFog()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_LENS); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_LENS)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_engine->GetLensMode()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SKY); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SKY)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_engine->GetSkyMode()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_PLANET); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_PLANET)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_engine->GetPlanetMode()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_LIGHT); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_LIGHT)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_engine->GetLightMode()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_JOYSTICK); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_JOYSTICK)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_app->GetJoystickEnabled()); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_PARTI); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_PARTI)); if ( pv != 0 ) { value = m_engine->GetParticleDensity(); pv->SetValue(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_CLIP); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_CLIP)); if ( pv != 0 ) { value = m_engine->GetClippingDistance(); pv->SetValue(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_DETAIL); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_DETAIL)); if ( pv != 0 ) { value = m_engine->GetObjectDetail(); pv->SetValue(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_GADGET); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_GADGET)); if ( pv != 0 ) { value = m_engine->GetGadgetQuantity(); pv->SetValue(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_TEXTURE); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE)); if ( pv != 0 ) { - value = (float)m_engine->GetTextureQuality(); + value = static_cast<float>(m_engine->GetTextureQuality()); pv->SetValue(value); } - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_VOLSOUND); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLSOUND)); if ( ps != 0 ) { - value = (float)m_sound->GetAudioVolume(); + value = static_cast<float>(m_sound->GetAudioVolume()); ps->SetVisibleValue(value); } - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_VOLMUSIC); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC)); if ( ps != 0 ) { /* TODO: midi volume @@ -5452,7 +5450,7 @@ void CMainDialog::UpdateSetupButtons() ps->SetVisibleValue(value);*/ } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SOUND3D); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOUND3D)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_sound->GetSound3D()); @@ -5469,52 +5467,52 @@ void CMainDialog::ChangeSetupButtons() CSlider* ps; float value; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_PARTI); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_PARTI)); if ( pv != 0 ) { value = pv->GetValue(); m_engine->SetParticleDensity(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_CLIP); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_CLIP)); if ( pv != 0 ) { value = pv->GetValue(); m_engine->SetClippingDistance(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_DETAIL); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_DETAIL)); if ( pv != 0 ) { value = pv->GetValue(); m_engine->SetObjectDetail(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_GADGET); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_GADGET)); if ( pv != 0 ) { value = pv->GetValue(); m_engine->SetGadgetQuantity(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_TEXTURE); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE)); if ( pv != 0 ) { value = pv->GetValue(); - m_engine->SetTextureQuality((int)value); + m_engine->SetTextureQuality(static_cast<int>(value)); } - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_VOLSOUND); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLSOUND)); if ( ps != 0 ) { value = ps->GetVisibleValue(); - m_sound->SetAudioVolume((int)value); + m_sound->SetAudioVolume(static_cast<int>(value)); } - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_VOLMUSIC); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC)); if ( ps != 0 ) { /* @@ -6047,13 +6045,13 @@ void CMainDialog::UpdateKey() Math::Point pos, dim; int first, i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - ps = (CScroll*)pw->SearchControl(EVENT_INTERFACE_KSCROLL); + ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL)); if ( ps == 0 ) return; - first = (int)(ps->GetVisibleValue()*(KEY_TOTAL-KEY_VISIBLE)); + first = static_cast<int>(ps->GetVisibleValue()*(KEY_TOTAL-KEY_VISIBLE)); for ( i=0 ; i<KEY_TOTAL ; i++ ) { @@ -6067,7 +6065,7 @@ void CMainDialog::UpdateKey() for ( i=0 ; i<KEY_VISIBLE ; i++ ) { pw->CreateKey(pos, dim, -1, key_event[first+i]); - pk = (CKey*)pw->SearchControl(key_event[first+i]); + pk = static_cast<CKey*>(pw->SearchControl(key_event[first+i])); if ( pk == 0 ) break; /* TODO: set input bindings pk->SetKey(0, m_engine->GetKey(key_table[first+i], 0)); @@ -6085,17 +6083,17 @@ void CMainDialog::ChangeKey(EventType event) CKey* pk; int i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - ps = (CScroll*)pw->SearchControl(EVENT_INTERFACE_KSCROLL); + ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL)); if ( ps == 0 ) return; for ( i=0 ; i<KEY_TOTAL ; i++ ) { if ( key_event[i] == event ) { - pk = (CKey*)pw->SearchControl(key_event[i]); + pk = static_cast<CKey*>(pw->SearchControl(key_event[i])); if ( pk == 0 ) break; /* TODO: set key binding m_engine->SetKey(key_table[i], 0, pk->GetKey(0)); @@ -6118,7 +6116,7 @@ void CMainDialog::StartAbort() StartDialog(Math::Point(0.3f, 0.8f), true, false, false); m_bDialogDelete = false; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == 0 ) return; pos.x = 0.35f; @@ -6201,7 +6199,7 @@ void CMainDialog::StartDeleteObject() StartDialog(Math::Point(0.7f, 0.3f), false, true, true); m_bDialogDelete = true; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == 0 ) return; pos.x = 0.00f; @@ -6211,13 +6209,13 @@ void CMainDialog::StartDeleteObject() GetResource(RES_TEXT, RT_DIALOG_DELOBJ, name); pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, name); - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK)); if ( pb == 0 ) return; GetResource(RES_TEXT, RT_DIALOG_YESDEL, name); pb->SetName(name); pb->SetState(STATE_WARNING); - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_CANCEL); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_CANCEL)); if ( pb == 0 ) return; GetResource(RES_TEXT, RT_DIALOG_NODEL, name); pb->SetName(name); @@ -6236,7 +6234,7 @@ void CMainDialog::StartDeleteGame(char *gamer) StartDialog(Math::Point(0.7f, 0.3f), false, true, true); m_bDialogDelete = true; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == 0 ) return; pos.x = 0.00f; @@ -6247,13 +6245,13 @@ void CMainDialog::StartDeleteGame(char *gamer) sprintf(text, name, gamer); pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, text); - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK)); if ( pb == 0 ) return; GetResource(RES_TEXT, RT_DIALOG_YESDEL, name); pb->SetName(name); pb->SetState(STATE_WARNING); - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_CANCEL); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_CANCEL)); if ( pb == 0 ) return; GetResource(RES_TEXT, RT_DIALOG_NODEL, name); pb->SetName(name); @@ -6270,7 +6268,7 @@ void CMainDialog::StartQuit() StartDialog(Math::Point(0.6f, 0.3f), false, true, true); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == 0 ) return; pos.x = 0.00f; @@ -6280,13 +6278,13 @@ void CMainDialog::StartQuit() GetResource(RES_TEXT, RT_DIALOG_QUIT, name); pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, name); - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK)); if ( pb == 0 ) return; GetResource(RES_TEXT, RT_DIALOG_YESQUIT, name); pb->SetName(name); pb->SetState(STATE_WARNING); - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_CANCEL); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_CANCEL)); if ( pb == 0 ) return; GetResource(RES_TEXT, RT_DIALOG_NOQUIT, name); pb->SetName(name); @@ -6303,34 +6301,34 @@ void CMainDialog::StartDialog(Math::Point dim, bool bFire, bool bOK, bool bCance StartSuspend(); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW6)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW7)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW8)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pb = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT); + pb = static_cast<CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT)); if ( pb != 0 ) { pb->ClearState(STATE_VISIBLE); @@ -6394,7 +6392,7 @@ void CMainDialog::FrameDialog(float rTime) m_dialogTime += rTime; if ( m_dialogTime < 1.0f ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw != 0 ) { if ( m_dialogTime < 0.50f ) @@ -6444,7 +6442,7 @@ void CMainDialog::FrameDialog(float rTime) dim.x = 0.01f+Math::Rand()*0.01f; dim.y = dim.x/0.75f; m_particle->CreateParticle(pos, speed, dim, - (Gfx::ParticleType)(Gfx::PARTILENS1+rand()%3), + static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3), 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE); // Top. @@ -6455,7 +6453,7 @@ void CMainDialog::FrameDialog(float rTime) dim.x = 0.01f+Math::Rand()*0.01f; dim.y = dim.x/0.75f; m_particle->CreateParticle(pos, speed, dim, - (Gfx::ParticleType)(Gfx::PARTILENS1+rand()%3), + static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3), 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE); // Left. @@ -6466,7 +6464,7 @@ void CMainDialog::FrameDialog(float rTime) dim.x = 0.01f+Math::Rand()*0.01f; dim.y = dim.x/0.75f; m_particle->CreateParticle(pos, speed, dim, - (Gfx::ParticleType)(Gfx::PARTILENS1+rand()%3), + static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3), 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE); // Right. @@ -6477,7 +6475,7 @@ void CMainDialog::FrameDialog(float rTime) dim.x = 0.01f+Math::Rand()*0.01f; dim.y = dim.x/0.75f; m_particle->CreateParticle(pos, speed, dim, - (Gfx::ParticleType)(Gfx::PARTILENS1+rand()%3), + static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3), 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE); } } @@ -6489,34 +6487,34 @@ void CMainDialog::StopDialog() CWindow* pw; CButton* pb; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW6)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW7)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW8)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pb = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT); + pb = static_cast<CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT)); if ( pb != 0 ) { pb->SetState(STATE_VISIBLE); @@ -6575,7 +6573,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 +6587,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 +6601,7 @@ char* CMainDialog::GetStackRead() // Specifies the name of the chosen to play scene. -void CMainDialog::SetSceneName(char* name) +void CMainDialog::SetSceneName(const char* name) { strcpy(m_sceneName, name); } diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h index df36a4d..8b0ef81 100644 --- a/src/ui/maindialog.h +++ b/src/ui/maindialog.h @@ -71,9 +71,9 @@ public: bool EventProcess(const Event &event); void ChangePhase(Phase phase); - void SetSceneRead(char* name); - void SetStackRead(char* name); - void SetSceneName(char* name); + void SetSceneRead(const char* name); + void SetStackRead(const char* name); + void SetSceneName(const char* name); void SetSceneRank(int rank); char* GetSceneRead(); char* GetStackRead(); diff --git a/src/ui/mainmap.cpp b/src/ui/mainmap.cpp index 601c035..b70bad9 100644 --- a/src/ui/mainmap.cpp +++ b/src/ui/mainmap.cpp @@ -18,7 +18,7 @@ // mainmap.cpp -#include <ui/mainmap.h> +#include "ui/mainmap.h" namespace Ui { @@ -35,9 +35,9 @@ 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_engine = (Gfx::CEngine*)m_iMan->SearchInstance(CLASS_ENGINE); + m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE)); + m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT)); + m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE)); m_mapMode = 1; m_bFixImage = false; @@ -57,7 +57,7 @@ void CMainMap::CreateMap() CWindow* pw; Math::Point pos, dim; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) { pos.x = 0.0f; pos.y = 0.0f; @@ -83,11 +83,11 @@ void CMainMap::SetFixImage(const char *filename) CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm == nullptr) return; @@ -104,11 +104,11 @@ void CMainMap::FloorColorMap(Gfx::Color floor, Gfx::Color water) CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm != nullptr) { pm->SetFloorColor(floor); pm->SetWaterColor(water); @@ -123,18 +123,18 @@ void CMainMap::ShowMap(bool bShow) CMap* pm; CSlider* ps; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; if (bShow) { DimMap(); } else { - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm != nullptr) pm->ClearState(STATE_VISIBLE); - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); if (ps != nullptr) ps->ClearState(STATE_VISIBLE); } @@ -150,10 +150,10 @@ void CMainMap::DimMap() Math::Point pos, dim; float value; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm == nullptr) return; @@ -166,7 +166,7 @@ void CMainMap::DimMap() pm->SetPos(pos); pm->SetDim(dim); - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); if (ps != nullptr) { ps->SetState(STATE_VISIBLE, (m_mapMode != 0)); @@ -193,15 +193,15 @@ float CMainMap::GetZoomMap() CMap* pm; CSlider* ps; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return ZOOM_MIN; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm == nullptr) return ZOOM_MIN; - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); if (ps == nullptr) return ZOOM_MIN; @@ -216,14 +216,14 @@ void CMainMap::ZoomMap(float zoom) CMap* pm; CSlider* ps; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm == nullptr) return; - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); if (ps == nullptr) return; @@ -245,14 +245,14 @@ void CMainMap::ZoomMap() CSlider* ps; float zoom; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm == nullptr) return; - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); if (ps == nullptr) return; @@ -273,15 +273,15 @@ void CMainMap::MapEnable(bool bEnable) CMap* pm; CSlider* ps; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm != nullptr) pm->SetEnable(bEnable); - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); if (ps != nullptr) ps->SetState(STATE_ENABLE, bEnable); } @@ -293,11 +293,11 @@ void CMainMap::SetToy(bool bToy) CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm == nullptr) return; @@ -312,11 +312,11 @@ void CMainMap::SetFixParam(float zoom, float ox, float oy, float angle, CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm == nullptr) return; @@ -334,11 +334,11 @@ void CMainMap::UpdateMap() CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm != nullptr) pm->UpdateTerrain(); } @@ -365,12 +365,12 @@ CObject* CMainMap::DetectMap(Math::Point pos, bool &bInMap) CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return 0; bInMap = false; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm == nullptr) return 0; return pm->DetectObject(pos, bInMap); @@ -384,11 +384,11 @@ void CMainMap::SetHighlight(CObject* pObj) CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm != nullptr) pm->SetHighlight(pObj); } diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp index f51ee9b..5b1271f 100644 --- a/src/ui/mainshort.cpp +++ b/src/ui/mainshort.cpp @@ -139,7 +139,7 @@ bool CMainShort::CreateShortcuts() for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == nullptr ) break; if ( !pObj->GetActif() ) continue; diff --git a/src/ui/map.cpp b/src/ui/map.cpp index 1cb4405..1b3dd70 100644 --- a/src/ui/map.cpp +++ b/src/ui/map.cpp @@ -866,20 +866,13 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, void CMap::DrawHighlight(Math::Point pos) { - Math::Point dim, uv1, uv2; - bool bOut, bUp, bDown, bLeft, bRight; + Math::Point dim, uv1, uv2; if ( m_bToy || m_fixImage[0] != 0 ) return; // map with still image? pos.x = (pos.x-m_offset.x)*(m_zoom*0.5f)/m_half+0.5f; pos.y = (pos.y-m_offset.y)*(m_zoom*0.5f)/m_half+0.5f; - bOut = bUp = bDown = bLeft = bRight = false; - if ( pos.x < 0.06f ) { pos.x = 0.02f; bOut = bLeft = true; } - if ( pos.y < 0.06f ) { pos.y = 0.02f; bOut = bDown = true; } - if ( pos.x > 0.94f ) { pos.x = 0.98f; bOut = bRight = true; } - if ( pos.y > 0.94f ) { pos.y = 0.98f; bOut = bUp = true; } - pos.x = m_mapPos.x+m_mapDim.x*pos.x; pos.y = m_mapPos.y+m_mapDim.y*pos.y; dim.x = 2.0f/128.0f*0.75f; @@ -1013,8 +1006,8 @@ void CMap::UpdateTerrain() { for ( x=0 ; x<256 ; x++ ) { - pos.x = ((float)x-128.0f)*m_half/128.0f; - pos.z = -((float)y-128.0f)*m_half/128.0f; + pos.x = (static_cast<float>(x)-128.0f)*m_half/128.0f; + pos.z = -(static_cast<float>(y)-128.0f)*m_half/128.0f; pos.y = 0.0f; if ( pos.x >= -m_half && pos.x <= m_half && @@ -1077,8 +1070,8 @@ void CMap::UpdateTerrain(int bx, int by, int ex, int ey) { for ( x=bx ; x<ex ; x++ ) { - pos.x = ((float)x-128.0f)*m_half/128.0f; - pos.z = -((float)y-128.0f)*m_half/128.0f; + pos.x = (static_cast<float>(x)-128.0f)*m_half/128.0f; + pos.z = -(static_cast<float>(y)-128.0f)*m_half/128.0f; pos.y = 0.0f; if ( pos.x >= -m_half && pos.x <= m_half && diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index 21f8158..41240ca 100644 --- a/src/ui/scroll.cpp +++ b/src/ui/scroll.cpp @@ -99,7 +99,7 @@ void CScroll::MoveAdjust() if ( m_buttonUp == 0 ) { m_buttonUp = new CButton(); - pc = (CButton*)m_buttonUp; + pc = m_buttonUp; pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 49, EVENT_NULL); pc->SetRepeat(true); m_eventUp = pc->GetEventType(); @@ -108,7 +108,7 @@ void CScroll::MoveAdjust() if ( m_buttonDown == 0 ) { m_buttonDown = new CButton(); - pc = (CButton*)m_buttonDown; + pc = m_buttonDown; pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 50, EVENT_NULL); pc->SetRepeat(true); m_eventDown = pc->GetEventType(); @@ -345,7 +345,7 @@ void CScroll::Draw() dim.y *= m_visibleRatio; DrawVertex(pos, dim, 2); - n = (int)(dim.y*0.8f/0.012f); + n = static_cast<int>(dim.y*0.8f/0.012f); if ( n < 1 ) n = 1; if ( n > 5 ) n = 5; diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp index 869fa42..185ee35 100644 --- a/src/ui/slider.cpp +++ b/src/ui/slider.cpp @@ -467,7 +467,7 @@ void CSlider::Draw() if ( m_bHoriz ) { - sprintf(text, "%d", (int)(m_min+m_visibleValue*(m_max-m_min))); + sprintf(text, "%d", static_cast<int>(m_min+m_visibleValue*(m_max-m_min))); h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize); pos.x = m_pos.x+m_dim.x+(10.0f/640.0f); pos.y = m_pos.y+(m_dim.y-h)/2.0f; @@ -483,8 +483,8 @@ void CSlider::Draw() pos.y += (h-CURSOR_WIDTH)*m_visibleValue; dim.x = 50.0f/640.0f; dim.y = 16.0f/480.0f; - sprintf(text, "%d", (int)(m_min+(m_visibleValue*(m_max-m_min)))); - m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, dim.x, Gfx::TEXT_ALIGN_LEFT, 0); + sprintf(text, "%d", static_cast<int>(m_min+(m_visibleValue*(m_max-m_min)))); + m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, dim.x, Gfx::TEXT_ALIGN_RIGHT, 0); } } } diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index cde00c7..809ed0c 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -507,7 +507,7 @@ void CStudio::SearchToken(CEdit* edit) for ( i=0 ; i<OBJECT_MAX ; i++ ) { type = static_cast< ObjectType >(i); - text = GetObjectName(type); + text = const_cast<char *>(GetObjectName(type)); if ( text[0] != 0 ) { if ( strcmp(token, text) == 0 ) @@ -517,7 +517,7 @@ void CStudio::SearchToken(CEdit* edit) return; } } - text = GetObjectAlias(type); + text = const_cast<char *>(GetObjectAlias(type)); if ( text[0] != 0 ) { if ( strcmp(token, text) == 0 ) @@ -530,7 +530,7 @@ void CStudio::SearchToken(CEdit* edit) } } - text = GetHelpText(token); + text = const_cast<char *>(GetHelpText(token)); if ( text[0] == 0 && m_helpFilename.length() > 0 ) { SetInfoText(std::string(token), true); @@ -606,11 +606,8 @@ void CStudio::StartEditScript(CScript *script, std::string name, int rank) edit->SetFontStretch(0.7f); edit->SetDisplaySpec(true); edit->SetAutoIndent(m_engine->GetEditIndentMode()); - // TODO replace to PutScript after change to std::string - char* tmp; - strcpy(tmp, name.c_str()); -// m_script->PutScript(edit, name); - m_script->PutScript(edit, tmp); + + m_script->PutScript(edit, name.c_str()); ColorizeScript(edit); ViewEditScript(); @@ -908,9 +905,7 @@ void CStudio::SetInfoText(std::string text, bool bClickable) if ( list == 0 ) return; list->Flush(); // just text - char* tmp; - strcpy(tmp,text.c_str()); - list->SetName(0, tmp); // TODO + list->SetName(0, text.c_str()); if ( text[0] == 0 ) bClickable = false; list->SetSelectCap(bClickable); @@ -1224,7 +1219,7 @@ void CStudio::AdjustDialog() pla->SetDim(ddim); } - nli = (int)((wdim.y-120.0f/480.0f)/(18.0f/480.0f)); + nli = static_cast<int>((wdim.y-120.0f/480.0f)/(18.0f/480.0f)); ddim.y = nli*18.0f/480.0f+9.0f/480.0f; ppos.y = wpos.y+wdim.y-48.0f/480.0f-ddim.y; pli = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST)); diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 6755909..4967795 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -18,7 +18,7 @@ // window.cpp -#include <ui/window.h> +#include "ui/window.h" @@ -124,7 +124,7 @@ CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, Event { // m_table[i] = new CButton(m_iMan); m_table[i] = new CButton(); - pc = (CButton*)m_table[i]; + pc = static_cast<CButton*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -147,7 +147,7 @@ CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventTy { // m_table[i] = new CColor(m_iMan); m_table[i] = new CColor(); - pc = (CColor*)m_table[i]; + pc = static_cast<CColor*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -170,7 +170,7 @@ CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventTy { // m_table[i] = new CCheck(m_iMan); m_table[i] = new CCheck(); - pc = (CCheck*)m_table[i]; + pc = static_cast<CCheck*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -193,7 +193,7 @@ CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventType e { // m_table[i] = new CKey(m_iMan); m_table[i] = new CKey(); - pc = (CKey*)m_table[i]; + pc = static_cast<CKey*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -216,7 +216,7 @@ CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventTy { // m_table[i] = new CGroup(m_iMan); m_table[i] = new CGroup(); - pc = (CGroup*)m_table[i]; + pc = static_cast<CGroup*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -239,7 +239,7 @@ CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventTy { // m_table[i] = new CImage(m_iMan); m_table[i] = new CImage(); - pc = (CImage*)m_table[i]; + pc = static_cast<CImage*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -262,7 +262,7 @@ CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventTy { // m_table[i] = new CLabel(m_iMan); m_table[i] = new CLabel(); - pc = (CLabel*)m_table[i]; + pc = static_cast<CLabel*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); auto p = name.find("\\"); @@ -291,7 +291,7 @@ CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType { // m_table[i] = new CEdit(m_iMan); m_table[i] = new CEdit(); - pc = (CEdit*)m_table[i]; + pc = static_cast<CEdit*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -314,7 +314,7 @@ CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon, { // m_table[i] = new CEditValue(m_iMan); m_table[i] = new CEditValue(); - pc = (CEditValue*)m_table[i]; + pc = static_cast<CEditValue*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -337,7 +337,7 @@ CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, Event { // m_table[i] = new CScroll(m_iMan); m_table[i] = new CScroll(); - pc = (CScroll*)m_table[i]; + pc = static_cast<CScroll*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -360,7 +360,7 @@ CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, Event { // m_table[i] = new CSlider(m_iMan); m_table[i] = new CSlider(); - pc = (CSlider*)m_table[i]; + pc = static_cast<CSlider*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -384,7 +384,7 @@ CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventType { // m_table[i] = new CList(m_iMan); m_table[i] = new CList(); - pc = (CList*)m_table[i]; + pc = static_cast<CList*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg, expand); return pc; } @@ -406,7 +406,7 @@ CShortcut* CWindow::CreateShortcut(Math::Point pos, Math::Point dim, int icon, E if ( m_table[i] == 0 ) { m_table[i] = new CShortcut(); - ps = (CShortcut*)m_table[i]; + ps = static_cast<CShortcut*>(m_table[i]); ps->Create(pos, dim, icon, eventMsg); return ps; } @@ -428,7 +428,7 @@ CMap* CWindow::CreateMap(Math::Point pos, Math::Point dim, int icon, EventType e if ( m_table[i] == 0 ) { m_table[i] = new CMap(); - pm = (CMap*)m_table[i]; + pm = static_cast<CMap*>(m_table[i]); pm->Create(pos, dim, icon, eventMsg); return pm; } @@ -450,7 +450,7 @@ CGauge* CWindow::CreateGauge(Math::Point pos, Math::Point dim, int icon, EventTy if ( m_table[i] == 0 ) { m_table[i] = new CGauge(); - pc = (CGauge*)m_table[i]; + pc = static_cast<CGauge*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -472,7 +472,7 @@ CCompass* CWindow::CreateCompass(Math::Point pos, Math::Point dim, int icon, Eve if ( m_table[i] == 0 ) { m_table[i] = new CCompass(); - pc = (CCompass*)m_table[i]; + pc = static_cast<CCompass*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -494,7 +494,7 @@ CTarget* CWindow::CreateTarget(Math::Point pos, Math::Point dim, int icon, Event if ( m_table[i] == 0 ) { m_table[i] = new CTarget(); - pc = (CTarget*)m_table[i]; + pc = static_cast<CTarget*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -618,11 +618,11 @@ void CWindow::SetName(std::string name) if ( m_name.length() > 0 && m_bRedim ) // title bar exists? { m_buttonReduce = new CButton(); - pc = (CButton*)m_buttonReduce; + pc = m_buttonReduce; pc->Create(m_pos, m_dim, 0, EVENT_NULL); m_buttonFull = new CButton(); - pc = (CButton*)m_buttonFull; + pc = m_buttonFull; pc->Create(m_pos, m_dim, 0, EVENT_NULL); bAdjust = true; @@ -631,7 +631,7 @@ void CWindow::SetName(std::string name) if ( m_name.length() > 0 && m_bClosable ) // title bar exists? { m_buttonClose = new CButton(); - pc = (CButton*)m_buttonClose; + pc = m_buttonClose; pc->Create(m_pos, m_dim, 0, EVENT_NULL); bAdjust = true; |