mirror of
https://github.com/glest/glest-source.git
synced 2025-08-12 19:33:59 +02:00
cleaned up code based on feedback from cppcheck
This commit is contained in:
@@ -153,13 +153,13 @@ Pixmap2D* JPGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
|
||||
//std::cout << "output width and height: " << cinfo.output_width <<" pixels and " << cinfo.output_height <<" pixels." << std::endl;
|
||||
/* now actually read the jpeg into the raw buffer */
|
||||
row_pointer[0] = new unsigned char[cinfo.output_width*cinfo.num_components];
|
||||
size_t location = 0; //Current pixel
|
||||
/* read one scan line at a time */
|
||||
/* Again you need to invert the lines unfortunately*/
|
||||
while( cinfo.output_scanline < cinfo.output_height )
|
||||
{
|
||||
jpeg_read_scanlines( &cinfo, row_pointer, 1 );
|
||||
location = (cinfo.output_height - cinfo.output_scanline)*cinfo.output_width*picComponents;
|
||||
//Current pixel
|
||||
size_t location = (cinfo.output_height - cinfo.output_scanline) * cinfo.output_width * picComponents;
|
||||
if (picComponents == cinfo.num_components) {
|
||||
memcpy(pixels+location,row_pointer[0],cinfo.output_width*cinfo.num_components);
|
||||
} else {
|
||||
|
@@ -438,14 +438,14 @@ bool fileExists(const string &path) {
|
||||
fclose(file);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
// else {
|
||||
//int fileErrno = errno;
|
||||
#ifdef WIN32
|
||||
int fileErrno = errno;
|
||||
DWORD error = GetLastError();
|
||||
string strError = "[#6] Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";
|
||||
#endif
|
||||
}
|
||||
//#ifdef WIN32
|
||||
//int fileErrno = errno;
|
||||
//DWORD error = GetLastError();
|
||||
//string strError = "[#6] Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";
|
||||
//#endif
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -699,7 +699,7 @@ pair<bool,time_t> hasCachedFileCRCValue(string crcCacheFile, uint32 &value) {
|
||||
char gameVer[500]="";
|
||||
char svnVer[500]="";
|
||||
char actualFilePath[8096]="";
|
||||
int readbytes = fscanf(fp,"%20ld,%20u,%20ld\n%s\n%s\n%s",
|
||||
int readbytes = fscanf(fp,"%20ld,%20u,%20ld\n%499s\n%499s\n%8095s",
|
||||
&refreshDate,
|
||||
&crcValue,
|
||||
&lastUpdateDate,
|
||||
|
@@ -96,9 +96,8 @@ void FileCRCPreCacheThread::execute() {
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] techsPerWorker = %u, MAX_FileCRCPreCacheThread_WORKER_THREADS = %d, techPaths.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,techsPerWorker,MAX_FileCRCPreCacheThread_WORKER_THREADS,(int)techPaths.size());
|
||||
|
||||
unsigned int consumedWorkers = 0;
|
||||
|
||||
try {
|
||||
unsigned int consumedWorkers = 0;
|
||||
for(unsigned int workerIdx = 0; workerIdx < MAX_FileCRCPreCacheThread_WORKER_THREADS; ++workerIdx) {
|
||||
if(getQuitStatus() == true) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
@@ -162,9 +161,9 @@ void FileCRCPreCacheThread::execute() {
|
||||
|
||||
sleep(0);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] Waiting for Spawned CRC threads to complete, preCacheWorkerThreadList.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,(int)preCacheWorkerThreadList.size());
|
||||
bool hasRunningWorkerThread = true;
|
||||
|
||||
try {
|
||||
bool hasRunningWorkerThread = true;
|
||||
for(;hasRunningWorkerThread == true;) {
|
||||
hasRunningWorkerThread = false;
|
||||
for(unsigned int idx = 0; idx < preCacheWorkerThreadList.size(); idx++) {
|
||||
|
@@ -236,8 +236,6 @@ void event_privmsg (irc_session_t * session, const char * event, const char * or
|
||||
}
|
||||
|
||||
void dcc_recv_callback (irc_session_t * session, irc_dcc_t id, int status, void * ctx, const char * data, unsigned int length) {
|
||||
static int count = 1;
|
||||
char buf[12]="";
|
||||
|
||||
switch (status)
|
||||
{
|
||||
@@ -252,6 +250,9 @@ void dcc_recv_callback (irc_session_t * session, irc_dcc_t id, int status, void
|
||||
}
|
||||
else {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("DCC %d: %s\n", id, data);
|
||||
|
||||
static int count = 1;
|
||||
char buf[12]="";
|
||||
sprintf (buf, "DCC [%d]: %d", id, count++);
|
||||
irc_dcc_msg (session, id, buf);
|
||||
}
|
||||
|
@@ -272,7 +272,7 @@ void Thread::queueAutoCleanThread() {
|
||||
if(Thread::getEnableVerboseMode()) printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||
|
||||
BaseThread *base_thread = dynamic_cast<BaseThread *>(this);
|
||||
ThreadGarbageCollector *garbage_collector = dynamic_cast<ThreadGarbageCollector *>(this);
|
||||
//ThreadGarbageCollector *garbage_collector = dynamic_cast<ThreadGarbageCollector *>(this);
|
||||
if(Thread::getEnableVerboseMode()) printf("In Thread::shutdownThreads Line: %d thread = %p base_thread = %p [%s]\n",__LINE__,this,base_thread,(base_thread != NULL ? base_thread->getUniqueID().c_str() : "n/a"));
|
||||
|
||||
MutexSafeWrapper safeMutex(cleanupThreadMutex.get());
|
||||
|
@@ -179,7 +179,6 @@ void Properties::load(const string &path, bool clearCurrentProperties) {
|
||||
|
||||
string getUserHomeFromGLIBC() {
|
||||
string home_folder = "";
|
||||
char dateiname[512];
|
||||
const char *homedir = getenv("HOME");
|
||||
if (!homedir) {
|
||||
#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
|
||||
|
@@ -833,31 +833,17 @@ bool checkVersionComptability(string clientVersionString, string serverVersionSt
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) {
|
||||
// debug version strings
|
||||
for(unsigned int i = 0; i < tokensServer.size(); ++i) {
|
||||
printf("Server version index = %d str [%s] IsNumeric = %d\n",i,tokensServer[i].c_str(),IsNumeric(tokensServer[i].c_str(),false));
|
||||
printf("Server version index = %u str [%s] IsNumeric = %d\n",i,tokensServer[i].c_str(),IsNumeric(tokensServer[i].c_str(),false));
|
||||
}
|
||||
for(unsigned int i = 0; i < tokens.size(); ++i) {
|
||||
printf("Client version index = %d str [%s] IsNumeric = %d\n",i,tokens[i].c_str(),IsNumeric(tokens[i].c_str(),false));
|
||||
printf("Client version index = %u str [%s] IsNumeric = %d\n",i,tokens[i].c_str(),IsNumeric(tokens[i].c_str(),false));
|
||||
}
|
||||
}
|
||||
// **NOTE:
|
||||
// after of 3.7.0 we go to 2 digi version compatibility, check if both
|
||||
// client and server are at least 3.7
|
||||
bool compatiblePost3_7_0_Check = false;
|
||||
bool compatiblePre3_7_0_1_Check = true;
|
||||
|
||||
// if(tokens.size() >= 3 && tokensServer.size() >= 3 &&
|
||||
// tokensServer[0] != "" && IsNumeric(tokensServer[0].c_str(),false) && strToInt(tokensServer[0]) == 3 &&
|
||||
// tokensServer[1] != "" && IsNumeric(tokensServer[1].c_str(),false) && strToInt(tokensServer[1]) == 7 &&
|
||||
// (tokensServer[2][0] == '0' || tokensServer[2][0] == '1') &&
|
||||
// tokens[0] != "" && IsNumeric(tokens[0].c_str(),false) && strToInt(tokens[0]) == 3 &&
|
||||
// tokens[1] != "" && IsNumeric(tokens[1].c_str(),false) && strToInt(tokens[1]) == 7 &&
|
||||
// (tokens[2][0] == '0' || tokens[2][0] == '1')) {
|
||||
//
|
||||
// compatiblePost3_7_0_Check = false;
|
||||
// compatiblePre3_7_0_1_Check = false;
|
||||
// compatible = true;
|
||||
// }
|
||||
// else if(tokens.size() >= 2 && tokensServer.size() >= 2) {
|
||||
if(tokens.size() >= 2 && tokensServer.size() >= 2) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
@@ -869,6 +855,7 @@ bool checkVersionComptability(string clientVersionString, string serverVersionSt
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
bool compatiblePost3_7_0_Check = false;
|
||||
// Both are at least 3.7.0, now check if both are > 3.7.0
|
||||
if(tokens.size() >= 3 && tokensServer.size() >= 3) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
Reference in New Issue
Block a user