- crc thread program exit cleanup, client download now using language string in connected menu

This commit is contained in:
Mark Vejvoda
2011-03-27 16:39:19 +00:00
parent 965ac7e00b
commit 453e5a12e6
2 changed files with 29 additions and 7 deletions

View File

@@ -83,6 +83,8 @@ bool disableBacktrace = false;
bool gameInitialized = false; bool gameInitialized = false;
static char *application_binary=NULL; static char *application_binary=NULL;
FileCRCPreCacheThread *preCacheThread=NULL;
const char *GAME_ARGS[] = { const char *GAME_ARGS[] = {
"--help", "--help",
"--autostart-lastgame", "--autostart-lastgame",
@@ -137,6 +139,22 @@ string runtimeErrorMsg = "";
static void cleanupProcessObjects() { static void cleanupProcessObjects() {
showCursor(true); showCursor(true);
restoreVideoMode(true); restoreVideoMode(true);
if(preCacheThread != NULL) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
time_t elapsed = time(NULL);
preCacheThread->signalQuit();
for(;preCacheThread->canShutdown(false) == false &&
difftime(time(NULL),elapsed) <= 15;) {
//sleep(150);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
sleep(25);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
Renderer::getInstance().end(); Renderer::getInstance().end();
SystemFlags::Close(); SystemFlags::Close();
SystemFlags::SHUTDOWN_PROGRAM_MODE=true; SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
@@ -1627,8 +1645,8 @@ int glestMain(int argc, char** argv) {
SystemFlags::ENABLE_THREADED_LOGGING = false; SystemFlags::ENABLE_THREADED_LOGGING = false;
disableBacktrace = false; disableBacktrace = false;
bool foundInvalidArgs = false; bool foundInvalidArgs = false;
preCacheThread=NULL;
Properties::setApplicationPath(extractDirectoryPathFromFile(argv[0])); Properties::setApplicationPath(extractDirectoryPathFromFile(argv[0]));
@@ -1820,8 +1838,6 @@ int glestMain(int argc, char** argv) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("**WARNING** Disabling VBO's\n"); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("**WARNING** Disabling VBO's\n");
} }
// Setup the file crc thread
std::auto_ptr<FileCRCPreCacheThread> preCacheThread;
//Game preCacheThreadGame; //Game preCacheThreadGame;
//float pingTime = Socket::getAveragePingMS("soft-haus.com"); //float pingTime = Socket::getAveragePingMS("soft-haus.com");
@@ -2082,7 +2098,7 @@ int glestMain(int argc, char** argv) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] precache thread enabled = %d\n",__FILE__,__FUNCTION__,__LINE__,startCRCPrecacheThread); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] precache thread enabled = %d\n",__FILE__,__FUNCTION__,__LINE__,startCRCPrecacheThread);
if(startCRCPrecacheThread == true) { if(startCRCPrecacheThread == true) {
vector<string> techDataPaths = config.getPathListForType(ptTechs); vector<string> techDataPaths = config.getPathListForType(ptTechs);
preCacheThread.reset(new FileCRCPreCacheThread()); preCacheThread = new FileCRCPreCacheThread();
preCacheThread->setUniqueID(__FILE__); preCacheThread->setUniqueID(__FILE__);
preCacheThread->setTechDataPaths(techDataPaths); preCacheThread->setTechDataPaths(techDataPaths);
//preCacheThread->setFileCRCPreCacheThreadCallbackInterface(&preCacheThreadGame); //preCacheThread->setFileCRCPreCacheThreadCallbackInterface(&preCacheThreadGame);
@@ -2117,19 +2133,24 @@ int glestMain(int argc, char** argv) {
// } // }
} }
if(preCacheThread.get() != NULL) { if(preCacheThread != NULL) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
time_t elapsed = time(NULL); time_t elapsed = time(NULL);
preCacheThread->signalQuit(); preCacheThread->signalQuit();
for(;preCacheThread->canShutdown(false) == false && for(;preCacheThread->canShutdown(false) == false &&
difftime(time(NULL),elapsed) <= 15;) { difftime(time(NULL),elapsed) <= 15;) {
//sleep(150); //sleep(150);
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
sleep(25); sleep(25);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
showCursor(true); showCursor(true);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
catch(const exception &e){ catch(const exception &e){
ExceptionHandler::handleRuntimeError(e.what()); ExceptionHandler::handleRuntimeError(e.what());
@@ -2144,6 +2165,7 @@ int glestMain(int argc, char** argv) {
ExceptionHandler::handleRuntimeError("Unknown error!"); ExceptionHandler::handleRuntimeError("Unknown error!");
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
delete mainWindow; delete mainWindow;

View File

@@ -866,11 +866,11 @@ void MenuStateConnectedGame::render() {
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
if(fileFTPProgressList.size() > 0) { if(fileFTPProgressList.size() > 0) {
Lang &lang= Lang::getInstance();
int yLocation = buttonDisconnect.getY(); int yLocation = buttonDisconnect.getY();
for(std::map<string,pair<int,string> >::iterator iterMap = fileFTPProgressList.begin(); for(std::map<string,pair<int,string> >::iterator iterMap = fileFTPProgressList.begin();
iterMap != fileFTPProgressList.end(); ++iterMap) { iterMap != fileFTPProgressList.end(); ++iterMap) {
string progressLabelPrefix = lang.get("ModDownloading") + " " + iterMap->first + " ";
string progressLabelPrefix = "Downloading " + iterMap->first + " [" + iterMap->second.second + "] ";
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nRendering file progress with the following prefix [%s]\n",progressLabelPrefix.c_str()); //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nRendering file progress with the following prefix [%s]\n",progressLabelPrefix.c_str());
renderer.renderProgressBar( renderer.renderProgressBar(