mirror of
https://github.com/glest/glest-source.git
synced 2025-08-25 09:10:49 +02:00
- more code cleanup based on suggestions from cppcheck
This commit is contained in:
@@ -88,11 +88,11 @@ void BaseThread::setThreadOwnerValid(bool value) {
|
||||
}
|
||||
|
||||
bool BaseThread::getThreadOwnerValid() {
|
||||
bool ret = false;
|
||||
//bool ret = false;
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,mutexOwnerId);
|
||||
//mutexThreadOwnerValid.setOwnerId(mutexOwnerId);
|
||||
ret = threadOwnerValid;
|
||||
bool ret = threadOwnerValid;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
return ret;
|
||||
@@ -115,22 +115,22 @@ void BaseThread::setQuitStatus(bool value) {
|
||||
}
|
||||
|
||||
bool BaseThread::getQuitStatus() {
|
||||
bool retval = false;
|
||||
//bool retval = false;
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexQuit,mutexOwnerId);
|
||||
//mutexQuit.setOwnerId(mutexOwnerId);
|
||||
retval = quit;
|
||||
bool retval = quit;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool BaseThread::getHasBeginExecution() {
|
||||
bool retval = false;
|
||||
//bool retval = false;
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexBeginExecution,mutexOwnerId);
|
||||
//mutexBeginExecution.setOwnerId(mutexOwnerId);
|
||||
retval = hasBeginExecution;
|
||||
bool retval = hasBeginExecution;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
return retval;
|
||||
@@ -149,11 +149,11 @@ void BaseThread::setHasBeginExecution(bool value) {
|
||||
}
|
||||
|
||||
bool BaseThread::getRunningStatus() {
|
||||
bool retval = false;
|
||||
//bool retval = false;
|
||||
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexRunning,mutexOwnerId);
|
||||
retval = running;
|
||||
bool retval = running;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
if(retval == false) {
|
||||
@@ -183,20 +183,20 @@ void BaseThread::setExecutingTask(bool value) {
|
||||
}
|
||||
|
||||
bool BaseThread::getExecutingTask() {
|
||||
bool retval = false;
|
||||
//bool retval = false;
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexExecutingTask,mutexOwnerId);
|
||||
retval = executingTask;
|
||||
bool retval = executingTask;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool BaseThread::getDeleteSelfOnExecutionDone() {
|
||||
bool retval = false;
|
||||
//bool retval = false;
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,mutexOwnerId);
|
||||
retval = deleteSelfOnExecutionDone;
|
||||
bool retval = deleteSelfOnExecutionDone;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
return retval;
|
||||
|
@@ -443,7 +443,7 @@ bool fileExists(const string &path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void removeFolder(const string path) {
|
||||
void removeFolder(const string &path) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());
|
||||
|
||||
string deletePath = path;
|
||||
@@ -1433,9 +1433,15 @@ void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight,bo
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
/* Get available fullscreen/hardware modes */
|
||||
int flags = SDL_RESIZABLE;
|
||||
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
flags = 0;
|
||||
|
||||
int flags = 0;
|
||||
|
||||
#else
|
||||
|
||||
int flags = SDL_RESIZABLE;
|
||||
|
||||
#endif
|
||||
if(isFullscreen) flags = SDL_FULLSCREEN;
|
||||
SDL_Rect**modes = SDL_ListModes(NULL, SDL_OPENGL|flags);
|
||||
@@ -1528,9 +1534,15 @@ void getFullscreenVideoModes(vector<ModeInfo> *modeinfos, bool isFullscreen) {
|
||||
/* Get available fullscreen/hardware modes */
|
||||
//SDL_Rect**modes = SDL_ListModes(NULL, SDL_OPENGL|SDL_RESIZABLE);
|
||||
|
||||
int flags = SDL_RESIZABLE;
|
||||
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
flags = 0;
|
||||
|
||||
int flags = 0;
|
||||
|
||||
#else
|
||||
|
||||
int flags = SDL_RESIZABLE;
|
||||
|
||||
#endif
|
||||
if(isFullscreen) flags = SDL_FULLSCREEN;
|
||||
SDL_Rect**modes = SDL_ListModes(&format, SDL_OPENGL|flags);
|
||||
|
@@ -389,12 +389,12 @@ void SimpleTaskThread::setOverrideShutdownTask(taskFunctionCallback *ptr) {
|
||||
}
|
||||
|
||||
bool SimpleTaskThread::isThreadExecutionLagging() {
|
||||
bool result = false;
|
||||
//bool result = false;
|
||||
//static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,mutexOwnerId);
|
||||
mutexLastExecuteTimestamp.setOwnerId(mutexOwnerId);
|
||||
result = (difftime(time(NULL),lastExecuteTimestamp) >= 5.0);
|
||||
bool result = (difftime(time(NULL),lastExecuteTimestamp) >= 5.0);
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
return result;
|
||||
@@ -507,12 +507,12 @@ void SimpleTaskThread::setTaskSignalled(bool value) {
|
||||
}
|
||||
|
||||
bool SimpleTaskThread::getTaskSignalled() {
|
||||
bool retval = false;
|
||||
//bool retval = false;
|
||||
//static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexTaskSignaller,mutexOwnerId);
|
||||
mutexTaskSignaller.setOwnerId(mutexOwnerId);
|
||||
retval = taskSignalled;
|
||||
bool retval = taskSignalled;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
return retval;
|
||||
|
@@ -2592,15 +2592,15 @@ bool UPNP_Tools::upnp_add_redirect(int ports[2],bool mutexLock) {
|
||||
sprintf(ext_port_str, "%d", ports[0]);
|
||||
sprintf(int_port_str, "%d", ports[1]);
|
||||
|
||||
int r = 0;
|
||||
//int r = 0;
|
||||
#ifndef MINIUPNPC_VERSION_PRE1_5
|
||||
#ifndef MINIUPNPC_VERSION_PRE1_6
|
||||
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0, NULL);
|
||||
int r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0, NULL);
|
||||
#else
|
||||
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0);
|
||||
int r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0);
|
||||
#endif
|
||||
#else
|
||||
r = UPNP_AddPortMapping(urls.controlURL, data.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0);
|
||||
int r = UPNP_AddPortMapping(urls.controlURL, data.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0);
|
||||
#endif
|
||||
if (r != UPNPCOMMAND_SUCCESS) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] AddPortMapping(%s, %s, %s) failed\n",__FILE__,__FUNCTION__,__LINE__,ext_port_str, int_port_str, lanaddr);
|
||||
|
@@ -54,7 +54,7 @@ LPWSTR Ansi2WideString(LPCSTR lpaszString) {
|
||||
}
|
||||
|
||||
// Convert a wide Unicode string to an UTF8 string
|
||||
std::string utf8_encode(const std::wstring wstr) {
|
||||
std::string utf8_encode(const std::wstring &wstr) {
|
||||
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (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);
|
||||
|
Reference in New Issue
Block a user