- overhaul of thread processing, especially in the menus, things now freeze much less and should be more reliable
This commit is contained in:
parent
9150701e70
commit
2b1732e27e
|
@ -238,7 +238,7 @@ Renderer::~Renderer() {
|
||||||
this->game = NULL;
|
this->game = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::simpleTask() {
|
void Renderer::simpleTask(BaseThread *callingThread) {
|
||||||
// This code reads pixmaps from a queue and saves them to disk
|
// This code reads pixmaps from a queue and saves them to disk
|
||||||
Pixmap2D *savePixMapBuffer=NULL;
|
Pixmap2D *savePixMapBuffer=NULL;
|
||||||
string path="";
|
string path="";
|
||||||
|
|
|
@ -433,7 +433,7 @@ private:
|
||||||
void renderTile(const Vec2i &pos);
|
void renderTile(const Vec2i &pos);
|
||||||
void renderQuad(int x, int y, int w, int h, const Texture2D *texture);
|
void renderQuad(int x, int y, int w, int h, const Texture2D *texture);
|
||||||
|
|
||||||
void simpleTask();
|
void simpleTask(BaseThread *callingThread);
|
||||||
|
|
||||||
//static
|
//static
|
||||||
static Texture2D::Filter strToTextureFilter(const string &s);
|
static Texture2D::Filter strToTextureFilter(const string &s);
|
||||||
|
|
|
@ -222,7 +222,7 @@ void Program::eventMouseMove(int x, int y, const MouseState *ms) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Program::simpleTask() {
|
void Program::simpleTask(BaseThread *callingThread) {
|
||||||
loopWorker();
|
loopWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ public:
|
||||||
void init(WindowGl *window, bool initSound=true, bool toggleFullScreen=false);
|
void init(WindowGl *window, bool initSound=true, bool toggleFullScreen=false);
|
||||||
void exit();
|
void exit();
|
||||||
|
|
||||||
virtual void simpleTask();
|
virtual void simpleTask(BaseThread *callingThread);
|
||||||
|
|
||||||
void mouseDownLeft(int x, int y);
|
void mouseDownLeft(int x, int y);
|
||||||
void eventMouseMove(int x, int y, const MouseState *ms);
|
void eventMouseMove(int x, int y, const MouseState *ms);
|
||||||
|
|
|
@ -507,14 +507,10 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
|
|
||||||
console.addLine(lang.get("To switch off music press")+" - \""+configKeys.getCharKey("ToggleMusic")+"\"");
|
console.addLine(lang.get("To switch off music press")+" - \""+configKeys.getCharKey("ToggleMusic")+"\"");
|
||||||
|
|
||||||
//chatManager.init(&console, world.getThisTeamIndex());
|
|
||||||
chatManager.init(&console, -1,true);
|
chatManager.init(&console, -1,true);
|
||||||
|
|
||||||
GraphicComponent::applyAllCustomProperties(containerName);
|
GraphicComponent::applyAllCustomProperties(containerName);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutexPtr(&publishToMasterserverThreadPtrChangeAccessor);
|
|
||||||
publishToMasterserverThreadInDeletion = false;
|
|
||||||
|
|
||||||
publishToMasterserverThread = new SimpleTaskThread(this,0,25);
|
publishToMasterserverThread = new SimpleTaskThread(this,0,25);
|
||||||
publishToMasterserverThread->setUniqueID(__FILE__);
|
publishToMasterserverThread->setUniqueID(__FILE__);
|
||||||
publishToMasterserverThread->start();
|
publishToMasterserverThread->start();
|
||||||
|
@ -523,34 +519,19 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuStateCustomGame::~MenuStateCustomGame() {
|
MenuStateCustomGame::~MenuStateCustomGame() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
if(publishToMasterserverThreadInDeletion == false) {
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
MutexSafeWrapper safeMutexPtr(&publishToMasterserverThreadPtrChangeAccessor);
|
|
||||||
|
|
||||||
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(publishToMasterserverThread != NULL) {
|
if(publishToMasterserverThread != NULL) {
|
||||||
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__);
|
||||||
needToBroadcastServerSettings = false;
|
|
||||||
needToRepublishToMasterserver = false;
|
|
||||||
|
|
||||||
//BaseThread::shutdownAndWait(publishToMasterserverThread);
|
|
||||||
if(publishToMasterserverThread != NULL &&
|
if(publishToMasterserverThread != NULL &&
|
||||||
|
publishToMasterserverThread->canShutdown(true) == true &&
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == 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__);
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
|
}
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
}
|
needToBroadcastServerSettings = false;
|
||||||
|
needToRepublishToMasterserver = false;
|
||||||
publishToMasterserverThreadInDeletion = false;
|
|
||||||
safeMutexPtr.ReleaseLock();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
safeMutexPtr.ReleaseLock();
|
|
||||||
}
|
|
||||||
|
|
||||||
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__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -561,26 +542,20 @@ MenuStateCustomGame::~MenuStateCustomGame() {
|
||||||
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__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::returnToParentMenu(){
|
void MenuStateCustomGame::returnToParentMenu() {
|
||||||
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__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutexPtr(&publishToMasterserverThreadPtrChangeAccessor);
|
|
||||||
publishToMasterserverThreadInDeletion = true;
|
|
||||||
|
|
||||||
needToBroadcastServerSettings = false;
|
needToBroadcastServerSettings = false;
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
bool returnToMasterServerMenu = parentMenuIsMs;
|
bool returnToMasterServerMenu = parentMenuIsMs;
|
||||||
|
|
||||||
//BaseThread::shutdownAndWait(publishToMasterserverThread);
|
|
||||||
if(publishToMasterserverThread != NULL &&
|
if(publishToMasterserverThread != NULL &&
|
||||||
|
publishToMasterserverThread->canShutdown() == true &&
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
publishToMasterserverThreadInDeletion = false;
|
|
||||||
safeMutexPtr.ReleaseLock();
|
|
||||||
|
|
||||||
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(returnToMasterServerMenu) {
|
if(returnToMasterServerMenu) {
|
||||||
|
@ -618,22 +593,20 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
needToBroadcastServerSettings = false;
|
needToBroadcastServerSettings = false;
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
MutexSafeWrapper safeMutexPtr(&publishToMasterserverThreadPtrChangeAccessor);
|
|
||||||
publishToMasterserverThreadInDeletion = true;
|
|
||||||
//BaseThread::shutdownAndWait(publishToMasterserverThread);
|
|
||||||
if(publishToMasterserverThread != NULL &&
|
if(publishToMasterserverThread != NULL &&
|
||||||
|
publishToMasterserverThread->canShutdown() == true &&
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
publishToMasterserverThreadInDeletion = false;
|
//publishToMasterserverThreadInDeletion = false;
|
||||||
safeMutexPtr.ReleaseLock();
|
//safeMutexPtr.ReleaseLock();
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
|
@ -652,7 +625,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
else if(listBoxMap.mouseClick(x, y)){
|
else if(listBoxMap.mouseClick(x, y)){
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", getCurrentMapFile().c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", getCurrentMapFile().c_str());
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
loadMapInfo(Map::getMapPath(getCurrentMapFile(),"",false), &mapInfo, true);
|
loadMapInfo(Map::getMapPath(getCurrentMapFile(),"",false), &mapInfo, true);
|
||||||
labelMapInfo.setText(mapInfo.desc);
|
labelMapInfo.setText(mapInfo.desc);
|
||||||
|
@ -670,7 +643,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxFogOfWar.mouseClick(x, y)) {
|
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxFogOfWar.mouseClick(x, y)) {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
|
@ -683,7 +656,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxAllowObservers.mouseClick(x, y)) {
|
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxAllowObservers.mouseClick(x, y)) {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
|
@ -697,7 +670,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxEnableObserverMode.mouseClick(x, y)) {
|
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxEnableObserverMode.mouseClick(x, y)) {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
|
@ -710,7 +683,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxPathFinderType.mouseClick(x, y)) {
|
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxPathFinderType.mouseClick(x, y)) {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
|
@ -725,20 +698,8 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
else if (listBoxAdvanced.mouseClick(x, y)) {
|
else if (listBoxAdvanced.mouseClick(x, y)) {
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxEnableServerControlledAI.mouseClick(x, y) && listBoxEnableServerControlledAI.getEditable()) {
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
|
||||||
{
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
else if(listBoxTileset.mouseClick(x, y)){
|
else if(listBoxTileset.mouseClick(x, y)){
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
|
@ -750,7 +711,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(listBoxMapFilter.mouseClick(x, y)){
|
else if(listBoxMapFilter.mouseClick(x, y)){
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
switchToNextMapGroup(listBoxMapFilter.getSelectedItemIndex()-oldListBoxMapfilterIndex);
|
switchToNextMapGroup(listBoxMapFilter.getSelectedItemIndex()-oldListBoxMapfilterIndex);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", getCurrentMapFile().c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", getCurrentMapFile().c_str());
|
||||||
|
|
||||||
|
@ -772,7 +733,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
else if(listBoxTechTree.mouseClick(x, y)){
|
else if(listBoxTechTree.mouseClick(x, y)){
|
||||||
reloadFactions(false);
|
reloadFactions(false);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
|
@ -785,25 +746,12 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(listBoxPublishServer.mouseClick(x, y) && listBoxPublishServer.getEditable()) {
|
else if(listBoxPublishServer.mouseClick(x, y) && listBoxPublishServer.getEditable()) {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
soundRenderer.playFx(coreData.getClickSoundC());
|
soundRenderer.playFx(coreData.getClickSoundC());
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
else if(listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxNetworkFramePeriod.mouseClick(x, y)){
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
if(hasNetworkGameSettings() == true)
|
|
||||||
{
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
soundRenderer.playFx(coreData.getClickSoundC());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
else if(listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxNetworkPauseGameForLaggedClients.mouseClick(x, y)){
|
else if(listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxNetworkPauseGameForLaggedClients.mouseClick(x, y)){
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
|
@ -818,7 +766,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(int i=0; i<mapInfo.players; ++i) {
|
for(int i=0; i<mapInfo.players; ++i) {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
if (listBoxAdvanced.getSelectedItemIndex() == 1) {
|
if (listBoxAdvanced.getSelectedItemIndex() == 1) {
|
||||||
// set multiplier
|
// set multiplier
|
||||||
|
@ -993,7 +941,7 @@ void MenuStateCustomGame::RestoreLastGameSettings() {
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
serverInterface->setGameSettings(&gameSettings,false);
|
serverInterface->setGameSettings(&gameSettings,false);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
|
@ -1007,7 +955,7 @@ void MenuStateCustomGame::RestoreLastGameSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::PlayNow() {
|
void MenuStateCustomGame::PlayNow() {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
saveGameSettingsToFile("lastCustomGamSettings.mgg");
|
saveGameSettingsToFile("lastCustomGamSettings.mgg");
|
||||||
|
|
||||||
closeUnusedSlots();
|
closeUnusedSlots();
|
||||||
|
@ -1145,18 +1093,13 @@ void MenuStateCustomGame::PlayNow() {
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
MutexSafeWrapper safeMutexPtr(&publishToMasterserverThreadPtrChangeAccessor);
|
|
||||||
publishToMasterserverThreadInDeletion = true;
|
|
||||||
//BaseThread::shutdownAndWait(publishToMasterserverThread);
|
|
||||||
if(publishToMasterserverThread != NULL &&
|
if(publishToMasterserverThread != NULL &&
|
||||||
|
publishToMasterserverThread->canShutdown() == true &&
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
publishToMasterserverThreadInDeletion = false;
|
|
||||||
safeMutexPtr.ReleaseLock();
|
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
assert(program != NULL);
|
assert(program != NULL);
|
||||||
|
@ -1379,11 +1322,9 @@ void MenuStateCustomGame::update() {
|
||||||
Chrono chrono;
|
Chrono chrono;
|
||||||
chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
if(serverInitError == true) {
|
if(serverInitError == 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__);
|
||||||
|
|
||||||
|
@ -1633,7 +1574,6 @@ void MenuStateCustomGame::update() {
|
||||||
labelNetStatus[i].setText(szBuf);
|
labelNetStatus[i].setText(szBuf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] C - ctNetwork\n",__FILE__,__FUNCTION__);
|
|
||||||
string port = intToStr(config.getInt("ServerPort"));
|
string port = intToStr(config.getInt("ServerPort"));
|
||||||
if(port != intToStr(GameConstants::serverPort)){
|
if(port != intToStr(GameConstants::serverPort)){
|
||||||
port = port + " " + lang.get("NonStandardPort") + "!)";
|
port = port + " " + lang.get("NonStandardPort") + "!)";
|
||||||
|
@ -1852,46 +1792,36 @@ void MenuStateCustomGame::publishToMasterserver()
|
||||||
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__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::simpleTask() {
|
void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(publishToMasterserverThreadInDeletion == true) {
|
if(callingThread->getQuitStatus() == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( publishToMasterserverThread == NULL ||
|
MutexSafeWrapper safeMutex(callingThread->getMutexThreadObjectAccessor());
|
||||||
publishToMasterserverThread->getQuitStatus() == true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
bool republish = (needToRepublishToMasterserver == true && publishToServerInfo.size() != 0);
|
bool republish = (needToRepublishToMasterserver == true && publishToServerInfo.size() != 0);
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
std::map<string,string> newPublishToServerInfo = publishToServerInfo;
|
std::map<string,string> newPublishToServerInfo = publishToServerInfo;
|
||||||
publishToServerInfo.clear();
|
publishToServerInfo.clear();
|
||||||
|
|
||||||
bool broadCastSettings = needToBroadcastServerSettings;
|
bool broadCastSettings = needToBroadcastServerSettings;
|
||||||
needToBroadcastServerSettings=false;
|
needToBroadcastServerSettings = false;
|
||||||
|
|
||||||
bool hasClientConnection = false;
|
bool hasClientConnection = false;
|
||||||
if(broadCastSettings) {
|
if(broadCastSettings == true) {
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
hasClientConnection = serverInterface->hasClientConnection();
|
hasClientConnection = serverInterface->hasClientConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool needPing = (difftime(time(NULL),lastNetworkPing) >= GameConstants::networkPingInterval);
|
bool needPing = (difftime(time(NULL),lastNetworkPing) >= GameConstants::networkPingInterval);
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock(true);
|
||||||
|
|
||||||
if( publishToMasterserverThread == NULL ||
|
if(callingThread->getQuitStatus() == true) {
|
||||||
publishToMasterserverThread->getQuitStatus() == true) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(republish == true) {
|
if(republish == true) {
|
||||||
|
safeMutex.Lock();
|
||||||
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__);
|
||||||
|
|
||||||
//string request = Config::getInstance().getString("Masterserver") + "addServerInfo.php?" + newPublishToServerInfo;
|
|
||||||
string request = Config::getInstance().getString("Masterserver") + "addServerInfo.php?";
|
string request = Config::getInstance().getString("Masterserver") + "addServerInfo.php?";
|
||||||
|
|
||||||
CURL *handle = SystemFlags::initHTTP();
|
CURL *handle = SystemFlags::initHTTP();
|
||||||
|
@ -1906,10 +1836,16 @@ void MenuStateCustomGame::simpleTask() {
|
||||||
|
|
||||||
//printf("the request is:\n%s\n",request.c_str());
|
//printf("the request is:\n%s\n",request.c_str());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the request is:\n%s\n",__FILE__,__FUNCTION__,__LINE__,request.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the request is:\n%s\n",__FILE__,__FUNCTION__,__LINE__,request.c_str());
|
||||||
|
safeMutex.ReleaseLock(true);
|
||||||
|
|
||||||
std::string serverInfo = SystemFlags::getHTTP(request,handle);
|
std::string serverInfo = SystemFlags::getHTTP(request,handle);
|
||||||
SystemFlags::cleanupHTTP(&handle);
|
SystemFlags::cleanupHTTP(&handle);
|
||||||
|
|
||||||
|
if(callingThread->getQuitStatus() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
safeMutex.Lock();
|
||||||
//printf("the result is:\n'%s'\n",serverInfo.c_str());
|
//printf("the result is:\n'%s'\n",serverInfo.c_str());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the result is:\n'%s'\n",__FILE__,__FUNCTION__,__LINE__,serverInfo.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the result is:\n'%s'\n",__FILE__,__FUNCTION__,__LINE__,serverInfo.c_str());
|
||||||
|
|
||||||
|
@ -1918,47 +1854,39 @@ void MenuStateCustomGame::simpleTask() {
|
||||||
showMasterserverError=true;
|
showMasterserverError=true;
|
||||||
masterServererErrorToShow = (serverInfo != "" ? serverInfo : "No Reply");
|
masterServererErrorToShow = (serverInfo != "" ? serverInfo : "No Reply");
|
||||||
}
|
}
|
||||||
|
safeMutex.ReleaseLock(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( publishToMasterserverThread == NULL ||
|
if(callingThread->getQuitStatus() == true) {
|
||||||
publishToMasterserverThread->getQuitStatus() == true) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(broadCastSettings) {
|
if(broadCastSettings == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
safeMutex.Lock();
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex2(&masterServerThreadAccessor);
|
|
||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
loadGameSettings(&gameSettings);
|
loadGameSettings(&gameSettings);
|
||||||
|
|
||||||
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__);
|
||||||
serverInterface->setGameSettings(&gameSettings,false);
|
serverInterface->setGameSettings(&gameSettings,false);
|
||||||
safeMutex2.ReleaseLock();
|
|
||||||
|
|
||||||
if(hasClientConnection == true) {
|
if(hasClientConnection == 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__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex3(&masterServerThreadAccessor);
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
serverInterface->broadcastGameSetup(&gameSettings);
|
serverInterface->broadcastGameSetup(&gameSettings);
|
||||||
safeMutex3.ReleaseLock();
|
|
||||||
}
|
}
|
||||||
|
safeMutex.ReleaseLock(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( publishToMasterserverThread == NULL ||
|
if(callingThread->getQuitStatus() == true) {
|
||||||
publishToMasterserverThread->getQuitStatus() == true) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
safeMutex.Lock();
|
||||||
if(needPing == true) {
|
if(needPing == true) {
|
||||||
lastNetworkPing = time(NULL);
|
lastNetworkPing = time(NULL);
|
||||||
|
|
||||||
|
@ -1966,20 +1894,22 @@ void MenuStateCustomGame::simpleTask() {
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
NetworkMessagePing msg(GameConstants::networkPingInterval,time(NULL));
|
NetworkMessagePing msg(GameConstants::networkPingInterval,time(NULL));
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex2(&masterServerThreadAccessor);
|
|
||||||
serverInterface->broadcastPing(&msg);
|
serverInterface->broadcastPing(&msg);
|
||||||
safeMutex2.ReleaseLock();
|
|
||||||
}
|
}
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
}
|
}
|
||||||
catch(const std::exception &ex) {
|
catch(const std::exception &ex) {
|
||||||
char szBuf[4096]="";
|
char szBuf[4096]="";
|
||||||
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
|
||||||
|
|
||||||
|
if(callingThread->getQuitStatus() == false) {
|
||||||
//throw runtime_error(szBuf);!!!
|
//throw runtime_error(szBuf);!!!
|
||||||
showGeneralError=true;
|
showGeneralError=true;
|
||||||
generalErrorToShow = ex.what();
|
generalErrorToShow = ex.what();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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__);
|
||||||
}
|
}
|
||||||
|
@ -2638,7 +2568,7 @@ void MenuStateCustomGame::keyDown(char key) {
|
||||||
|
|
||||||
activeInputLabel->setText(text);
|
activeInputLabel->setText(text);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
if(hasNetworkGameSettings() == true) {
|
if(hasNetworkGameSettings() == true) {
|
||||||
needToSetChangedGameSettings = true;
|
needToSetChangedGameSettings = true;
|
||||||
lastSetChangedGameSettings = time(NULL);
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
@ -2693,7 +2623,7 @@ void MenuStateCustomGame::keyPress(char c) {
|
||||||
text.insert(text.end()-1, c);
|
text.insert(text.end()-1, c);
|
||||||
activeInputLabel->setText(text);
|
activeInputLabel->setText(text);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
if(hasNetworkGameSettings() == true) {
|
if(hasNetworkGameSettings() == true) {
|
||||||
needToSetChangedGameSettings = true;
|
needToSetChangedGameSettings = true;
|
||||||
lastSetChangedGameSettings = time(NULL);
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
|
|
@ -102,9 +102,9 @@ private:
|
||||||
bool needToBroadcastServerSettings;
|
bool needToBroadcastServerSettings;
|
||||||
std::map<string,string> publishToServerInfo;
|
std::map<string,string> publishToServerInfo;
|
||||||
SimpleTaskThread *publishToMasterserverThread;
|
SimpleTaskThread *publishToMasterserverThread;
|
||||||
Mutex masterServerThreadAccessor;
|
//Mutex masterServerThreadAccessor;
|
||||||
Mutex publishToMasterserverThreadPtrChangeAccessor;
|
//Mutex publishToMasterserverThreadPtrChangeAccessor;
|
||||||
bool publishToMasterserverThreadInDeletion;
|
//bool publishToMasterserverThreadInDeletion;
|
||||||
|
|
||||||
bool parentMenuIsMs;
|
bool parentMenuIsMs;
|
||||||
int soundConnectionCount;
|
int soundConnectionCount;
|
||||||
|
@ -157,7 +157,7 @@ public:
|
||||||
virtual void keyUp(char key);
|
virtual void keyUp(char key);
|
||||||
|
|
||||||
|
|
||||||
virtual void simpleTask();
|
virtual void simpleTask(BaseThread *callingThread);
|
||||||
virtual bool isInSpecialKeyCaptureEvent() { return chatManager.getEditEnabled(); }
|
virtual bool isInSpecialKeyCaptureEvent() { return chatManager.getEditEnabled(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -241,8 +241,6 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
||||||
chatManager.setYPos(consoleIRC.getYPos()-20);
|
chatManager.setYPos(consoleIRC.getYPos()-20);
|
||||||
chatManager.setFont(CoreData::getInstance().getMenuFontNormal());
|
chatManager.setFont(CoreData::getInstance().getMenuFontNormal());
|
||||||
|
|
||||||
MutexSafeWrapper safeMutexPtr(&masterServerThreadPtrChangeAccessor);
|
|
||||||
masterServerThreadInDeletion = false;
|
|
||||||
needUpdateFromServer = true;
|
needUpdateFromServer = true;
|
||||||
updateFromMasterserverThread = new SimpleTaskThread(this,0,100);
|
updateFromMasterserverThread = new SimpleTaskThread(this,0,100);
|
||||||
updateFromMasterserverThread->setUniqueID(__FILE__);
|
updateFromMasterserverThread->setUniqueID(__FILE__);
|
||||||
|
@ -300,48 +298,29 @@ void MenuStateMasterserver::IRC_CallbackEvent(IRCEventType evt, const char* orig
|
||||||
void MenuStateMasterserver::cleanup() {
|
void MenuStateMasterserver::cleanup() {
|
||||||
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__);
|
||||||
|
|
||||||
//printf("In [%s::%s Line: %d] [%p]\n",__FILE__,__FUNCTION__,__LINE__,ircClient);
|
MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
if(masterServerThreadInDeletion == false) {
|
|
||||||
MutexSafeWrapper safeMutexPtr(&masterServerThreadPtrChangeAccessor);
|
|
||||||
if(updateFromMasterserverThread != NULL) {
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
needUpdateFromServer = false;
|
needUpdateFromServer = false;
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
//BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
|
||||||
masterServerThreadInDeletion = true;
|
|
||||||
if(updateFromMasterserverThread != NULL &&
|
if(updateFromMasterserverThread != NULL &&
|
||||||
|
updateFromMasterserverThread->canShutdown(true) == true &&
|
||||||
updateFromMasterserverThread->shutdownAndWait() == true) {
|
updateFromMasterserverThread->shutdownAndWait() == true) {
|
||||||
delete updateFromMasterserverThread;
|
delete updateFromMasterserverThread;
|
||||||
}
|
}
|
||||||
updateFromMasterserverThread = NULL;
|
updateFromMasterserverThread = NULL;
|
||||||
masterServerThreadInDeletion = false;
|
|
||||||
safeMutexPtr.ReleaseLock();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
safeMutexPtr.ReleaseLock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
clearServerLines();
|
clearServerLines();
|
||||||
clearUserButtons();
|
clearUserButtons();
|
||||||
|
|
||||||
//printf("Exiting master server menu [%p]\n",ircClient);
|
|
||||||
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient);
|
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient);
|
||||||
if(ircClient != NULL) {
|
if(ircClient != NULL) {
|
||||||
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__);
|
||||||
|
|
||||||
ircClient->setCallbackObj(NULL);
|
ircClient->setCallbackObj(NULL);
|
||||||
ircClient->signalQuit();
|
ircClient->signalQuit();
|
||||||
//if(ircClient->shutdownAndWait() == true) {
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
//delete ircClient;
|
|
||||||
//}
|
|
||||||
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__);
|
||||||
ircClient = NULL;
|
ircClient = NULL;
|
||||||
}
|
}
|
||||||
|
@ -351,14 +330,12 @@ void MenuStateMasterserver::cleanup() {
|
||||||
|
|
||||||
MenuStateMasterserver::~MenuStateMasterserver() {
|
MenuStateMasterserver::~MenuStateMasterserver() {
|
||||||
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__);
|
||||||
|
|
||||||
//printf("In [%s::%s Line: %d] [%p]\n",__FILE__,__FUNCTION__,__LINE__,ircClient);
|
|
||||||
cleanup();
|
cleanup();
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] END\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] END\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateMasterserver::clearServerLines() {
|
void MenuStateMasterserver::clearServerLines() {
|
||||||
while(!serverLines.empty()){
|
while(!serverLines.empty()) {
|
||||||
delete serverLines.back();
|
delete serverLines.back();
|
||||||
serverLines.pop_back();
|
serverLines.pop_back();
|
||||||
}
|
}
|
||||||
|
@ -401,7 +378,7 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
else if(buttonRefresh.mouseClick(x, y)){
|
else if(buttonRefresh.mouseClick(x, y)){
|
||||||
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__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
soundRenderer.playFx(coreData.getClickSoundB());
|
soundRenderer.playFx(coreData.getClickSoundB());
|
||||||
needUpdateFromServer = true;
|
needUpdateFromServer = true;
|
||||||
|
|
||||||
|
@ -410,22 +387,8 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
else if(buttonReturn.mouseClick(x, y)){
|
else if(buttonReturn.mouseClick(x, y)){
|
||||||
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__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
soundRenderer.playFx(coreData.getClickSoundB());
|
soundRenderer.playFx(coreData.getClickSoundB());
|
||||||
|
|
||||||
//BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
|
||||||
MutexSafeWrapper safeMutexPtr(&masterServerThreadPtrChangeAccessor);
|
|
||||||
masterServerThreadInDeletion = true;
|
|
||||||
if(updateFromMasterserverThread != NULL &&
|
|
||||||
updateFromMasterserverThread->shutdownAndWait() == true) {
|
|
||||||
delete updateFromMasterserverThread;
|
|
||||||
}
|
|
||||||
updateFromMasterserverThread = NULL;
|
|
||||||
masterServerThreadInDeletion = false;
|
|
||||||
safeMutexPtr.ReleaseLock();
|
|
||||||
|
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
@ -439,26 +402,13 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
else if(buttonCreateGame.mouseClick(x, y)){
|
else if(buttonCreateGame.mouseClick(x, y)){
|
||||||
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__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
soundRenderer.playFx(coreData.getClickSoundB());
|
soundRenderer.playFx(coreData.getClickSoundB());
|
||||||
needUpdateFromServer = false;
|
needUpdateFromServer = false;
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
//BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
|
||||||
MutexSafeWrapper safeMutexPtr(&masterServerThreadPtrChangeAccessor);
|
|
||||||
masterServerThreadInDeletion = true;
|
|
||||||
if(updateFromMasterserverThread != NULL &&
|
|
||||||
updateFromMasterserverThread->shutdownAndWait() == true) {
|
|
||||||
delete updateFromMasterserverThread;
|
|
||||||
}
|
|
||||||
updateFromMasterserverThread = NULL;
|
|
||||||
masterServerThreadInDeletion = false;
|
|
||||||
safeMutexPtr.ReleaseLock();
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
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__);
|
||||||
|
|
||||||
|
@ -467,12 +417,12 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
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__);
|
||||||
}
|
}
|
||||||
else if(listBoxAutoRefresh.mouseClick(x, y)){
|
else if(listBoxAutoRefresh.mouseClick(x, y)){
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
autoRefreshTime=10*listBoxAutoRefresh.getSelectedItemIndex();
|
autoRefreshTime=10*listBoxAutoRefresh.getSelectedItemIndex();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
bool clicked=false;
|
bool clicked=false;
|
||||||
if(!clicked && serverScrollBar.getElementCount()!=0){
|
if(!clicked && serverScrollBar.getElementCount()!=0){
|
||||||
for(int i = serverScrollBar.getVisibleStart(); i <= serverScrollBar.getVisibleEnd(); ++i) {
|
for(int i = serverScrollBar.getVisibleStart(); i <= serverScrollBar.getVisibleEnd(); ++i) {
|
||||||
|
@ -486,15 +436,7 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
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__);
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
MutexSafeWrapper safeMutexPtr(&masterServerThreadPtrChangeAccessor);
|
cleanup();
|
||||||
masterServerThreadInDeletion = true;
|
|
||||||
if(updateFromMasterserverThread != NULL &&
|
|
||||||
updateFromMasterserverThread->shutdownAndWait() == true) {
|
|
||||||
delete updateFromMasterserverThread;
|
|
||||||
}
|
|
||||||
updateFromMasterserverThread = NULL;
|
|
||||||
masterServerThreadInDeletion = false;
|
|
||||||
safeMutexPtr.ReleaseLock();
|
|
||||||
|
|
||||||
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__);
|
||||||
mainMenu->setState(new MenuStateConnectedGame(program, mainMenu,jmMasterserver));
|
mainMenu->setState(new MenuStateConnectedGame(program, mainMenu,jmMasterserver));
|
||||||
|
@ -523,7 +465,7 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateMasterserver::mouseMove(int x, int y, const MouseState *ms){
|
void MenuStateMasterserver::mouseMove(int x, int y, const MouseState *ms){
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
|
|
||||||
if (mainMessageBox.getEnabled()) {
|
if (mainMessageBox.getEnabled()) {
|
||||||
mainMessageBox.mouseMove(x, y);
|
mainMessageBox.mouseMove(x, y);
|
||||||
|
@ -556,7 +498,7 @@ void MenuStateMasterserver::mouseMove(int x, int y, const MouseState *ms){
|
||||||
void MenuStateMasterserver::render(){
|
void MenuStateMasterserver::render(){
|
||||||
Renderer &renderer= Renderer::getInstance();
|
Renderer &renderer= Renderer::getInstance();
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
if(mainMessageBox.getEnabled()) {
|
if(mainMessageBox.getEnabled()) {
|
||||||
renderer.renderMessageBox(&mainMessageBox);
|
renderer.renderMessageBox(&mainMessageBox);
|
||||||
}
|
}
|
||||||
|
@ -632,7 +574,7 @@ void MenuStateMasterserver::render(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateMasterserver::update() {
|
void MenuStateMasterserver::update() {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
if(autoRefreshTime!=0 && difftime(time(NULL),lastRefreshTimer) >= autoRefreshTime ) {
|
if(autoRefreshTime!=0 && difftime(time(NULL),lastRefreshTimer) >= autoRefreshTime ) {
|
||||||
needUpdateFromServer = true;
|
needUpdateFromServer = true;
|
||||||
lastRefreshTimer= time(NULL);
|
lastRefreshTimer= time(NULL);
|
||||||
|
@ -727,47 +669,33 @@ void MenuStateMasterserver::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateMasterserver::simpleTask() {
|
void MenuStateMasterserver::simpleTask(BaseThread *callingThread) {
|
||||||
if(masterServerThreadInDeletion == true) {
|
if(callingThread->getQuitStatus() == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
MutexSafeWrapper safeMutex(callingThread->getMutexThreadObjectAccessor());
|
||||||
if( updateFromMasterserverThread == NULL ||
|
|
||||||
updateFromMasterserverThread->getQuitStatus() == true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
bool needUpdate = needUpdateFromServer;
|
bool needUpdate = needUpdateFromServer;
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
|
|
||||||
if(needUpdate == true) {
|
if(needUpdate == true) {
|
||||||
updateServerInfo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuStateMasterserver::updateServerInfo() {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(masterServerThreadInDeletion == true) {
|
if(callingThread->getQuitStatus() == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MutexSafeWrapper safeMutexPtr(&masterServerThreadPtrChangeAccessor);
|
|
||||||
if( updateFromMasterserverThread == NULL ||
|
|
||||||
updateFromMasterserverThread->getQuitStatus() == true) {
|
|
||||||
safeMutexPtr.ReleaseLock();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
safeMutexPtr.ReleaseLock(true);
|
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
needUpdateFromServer = false;
|
needUpdateFromServer = false;
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
|
|
||||||
if(announcementLoaded == false) {
|
if(announcementLoaded == false) {
|
||||||
string announcementURL = Config::getInstance().getString("AnnouncementURL","http://master.megaglest.org/files/announcement.txt");
|
string announcementURL = Config::getInstance().getString("AnnouncementURL","http://master.megaglest.org/files/announcement.txt");
|
||||||
if(announcementURL != "") {
|
if(announcementURL != "") {
|
||||||
|
|
||||||
|
safeMutex.ReleaseLock(true);
|
||||||
std::string announcementTxt = SystemFlags::getHTTP(announcementURL);
|
std::string announcementTxt = SystemFlags::getHTTP(announcementURL);
|
||||||
|
if(callingThread->getQuitStatus() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
safeMutex.Lock();
|
||||||
|
|
||||||
if(StartsWith(announcementTxt,"Announcement from Masterserver:") == true) {
|
if(StartsWith(announcementTxt,"Announcement from Masterserver:") == true) {
|
||||||
int newlineCount=0;
|
int newlineCount=0;
|
||||||
size_t lastIndex=0;
|
size_t lastIndex=0;
|
||||||
|
@ -775,19 +703,17 @@ void MenuStateMasterserver::updateServerInfo() {
|
||||||
//announcementLabel.setText(announcementTxt);
|
//announcementLabel.setText(announcementTxt);
|
||||||
consoleIRC.addLine(announcementTxt);
|
consoleIRC.addLine(announcementTxt);
|
||||||
|
|
||||||
while(true){
|
while(true) {
|
||||||
lastIndex=announcementTxt.find("\n",lastIndex+1);
|
lastIndex=announcementTxt.find("\n",lastIndex+1);
|
||||||
if(lastIndex==string::npos)
|
if(lastIndex==string::npos) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
newlineCount++;
|
newlineCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newlineCount--;// remove my own line
|
newlineCount--;// remove my own line
|
||||||
for( int i=0; i< newlineCount;++i ){
|
for( int i=0; i< newlineCount;++i ) {
|
||||||
consoleIRC.addLine("");
|
consoleIRC.addLine("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -796,7 +722,13 @@ void MenuStateMasterserver::updateServerInfo() {
|
||||||
string versionURL = Config::getInstance().getString("VersionURL","http://master.megaglest.org/files/versions/")+glestVersionString+".txt";
|
string versionURL = Config::getInstance().getString("VersionURL","http://master.megaglest.org/files/versions/")+glestVersionString+".txt";
|
||||||
//printf("\nversionURL=%s\n",versionURL.c_str());
|
//printf("\nversionURL=%s\n",versionURL.c_str());
|
||||||
if(versionURL != "") {
|
if(versionURL != "") {
|
||||||
|
safeMutex.ReleaseLock(true);
|
||||||
std::string versionTxt = SystemFlags::getHTTP(versionURL);
|
std::string versionTxt = SystemFlags::getHTTP(versionURL);
|
||||||
|
if(callingThread->getQuitStatus() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
safeMutex.Lock();
|
||||||
|
|
||||||
if(StartsWith(versionTxt,"Version info:") == true) {
|
if(StartsWith(versionTxt,"Version info:") == true) {
|
||||||
int newlineCount=0;
|
int newlineCount=0;
|
||||||
size_t lastIndex=0;
|
size_t lastIndex=0;
|
||||||
|
@ -804,19 +736,17 @@ void MenuStateMasterserver::updateServerInfo() {
|
||||||
//versionInfoLabel.setText(versionTxt);
|
//versionInfoLabel.setText(versionTxt);
|
||||||
consoleIRC.addLine(versionTxt);
|
consoleIRC.addLine(versionTxt);
|
||||||
|
|
||||||
while(true){
|
while(true) {
|
||||||
lastIndex=versionTxt.find("\n",lastIndex+1);
|
lastIndex=versionTxt.find("\n",lastIndex+1);
|
||||||
if(lastIndex==string::npos)
|
if(lastIndex==string::npos) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
newlineCount++;
|
newlineCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newlineCount--;// remove my own line
|
newlineCount--;// remove my own line
|
||||||
for( int i=0; i< newlineCount;++i ){
|
for( int i=0; i< newlineCount;++i ) {
|
||||||
consoleIRC.addLine("");
|
consoleIRC.addLine("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -833,7 +763,13 @@ void MenuStateMasterserver::updateServerInfo() {
|
||||||
try {
|
try {
|
||||||
if(Config::getInstance().getString("Masterserver","") != "") {
|
if(Config::getInstance().getString("Masterserver","") != "") {
|
||||||
|
|
||||||
|
safeMutex.ReleaseLock(true);
|
||||||
std::string localServerInfoString = SystemFlags::getHTTP(Config::getInstance().getString("Masterserver") + "showServersForGlest.php");
|
std::string localServerInfoString = SystemFlags::getHTTP(Config::getInstance().getString("Masterserver") + "showServersForGlest.php");
|
||||||
|
if(callingThread->getQuitStatus() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
safeMutex.Lock();
|
||||||
|
|
||||||
serverInfoString=localServerInfoString;
|
serverInfoString=localServerInfoString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -841,25 +777,16 @@ void MenuStateMasterserver::updateServerInfo() {
|
||||||
serverInfoString=ex.what();
|
serverInfoString=ex.what();
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line %d] error during Internet game status update: [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line %d] error during Internet game status update: [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
safeMutexPtr.Lock();
|
|
||||||
if( updateFromMasterserverThread == NULL ||
|
|
||||||
updateFromMasterserverThread->getQuitStatus() == true) {
|
|
||||||
safeMutexPtr.ReleaseLock();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
safeMutexPtr.ReleaseLock();
|
|
||||||
}
|
}
|
||||||
catch(const exception &e){
|
catch(const exception &e){
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d, error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d, error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||||
threadedErrorMsg = e.what();
|
threadedErrorMsg = e.what();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuStateMasterserver::rebuildServerLines(const string &serverInfo) {
|
||||||
void MenuStateMasterserver::rebuildServerLines(const string &serverInfo)
|
|
||||||
{
|
|
||||||
int numberOfOldServerLines=serverLines.size();
|
int numberOfOldServerLines=serverLines.size();
|
||||||
clearServerLines();
|
clearServerLines();
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
|
@ -97,9 +97,6 @@ private:
|
||||||
|
|
||||||
static DisplayMessageFunction pCB_DisplayMessage;
|
static DisplayMessageFunction pCB_DisplayMessage;
|
||||||
std::string threadedErrorMsg;
|
std::string threadedErrorMsg;
|
||||||
Mutex masterServerThreadAccessor;
|
|
||||||
Mutex masterServerThreadPtrChangeAccessor;
|
|
||||||
bool masterServerThreadInDeletion;
|
|
||||||
|
|
||||||
std::vector<string> ircArgs;
|
std::vector<string> ircArgs;
|
||||||
Mutex mutexIRCClient;
|
Mutex mutexIRCClient;
|
||||||
|
@ -122,7 +119,7 @@ public:
|
||||||
virtual void keyPress(char c);
|
virtual void keyPress(char c);
|
||||||
virtual void keyUp(char key);
|
virtual void keyUp(char key);
|
||||||
|
|
||||||
virtual void simpleTask();
|
virtual void simpleTask(BaseThread *callingThread);
|
||||||
|
|
||||||
static void setDisplayMessageFunction(DisplayMessageFunction pDisplayMessage) { pCB_DisplayMessage = pDisplayMessage; }
|
static void setDisplayMessageFunction(DisplayMessageFunction pDisplayMessage) { pCB_DisplayMessage = pDisplayMessage; }
|
||||||
|
|
||||||
|
@ -133,7 +130,6 @@ private:
|
||||||
void setButtonLinePosition(int pos);
|
void setButtonLinePosition(int pos);
|
||||||
void clearServerLines();
|
void clearServerLines();
|
||||||
void clearUserButtons();
|
void clearUserButtons();
|
||||||
void updateServerInfo();
|
|
||||||
void rebuildServerLines(const string &serverInfo);
|
void rebuildServerLines(const string &serverInfo);
|
||||||
void cleanup();
|
void cleanup();
|
||||||
virtual void IRC_CallbackEvent(IRCEventType evt, const char* origin, const char **params, unsigned int count);
|
virtual void IRC_CallbackEvent(IRCEventType evt, const char* origin, const char **params, unsigned int count);
|
||||||
|
|
|
@ -146,7 +146,7 @@ ServerInterface::~ServerInterface() {
|
||||||
// This triggers a gameOver message to be sent to the masterserver
|
// This triggers a gameOver message to be sent to the masterserver
|
||||||
lastMasterserverHeartbeatTime = 0;
|
lastMasterserverHeartbeatTime = 0;
|
||||||
if(needToRepublishToMasterserver == true) {
|
if(needToRepublishToMasterserver == true) {
|
||||||
simpleTask();
|
simpleTask(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -1523,7 +1523,7 @@ std::map<string,string> ServerInterface::publishToMasterserver() {
|
||||||
return publishToServerInfo;
|
return publishToServerInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerInterface::simpleTask() {
|
void ServerInterface::simpleTask(BaseThread *callingThread) {
|
||||||
//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__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor,intToStr(__LINE__));
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor,intToStr(__LINE__));
|
||||||
|
|
|
@ -121,7 +121,7 @@ public:
|
||||||
|
|
||||||
Mutex * getServerSynchAccessor() { return &serverSynchAccessor; }
|
Mutex * getServerSynchAccessor() { return &serverSynchAccessor; }
|
||||||
|
|
||||||
virtual void simpleTask();
|
virtual void simpleTask(BaseThread *callingThread);
|
||||||
void addClientToServerIPAddress(uint32 clientIp,uint32 ServerIp);
|
void addClientToServerIPAddress(uint32 clientIp,uint32 ServerIp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
static SoundRenderer &getInstance();
|
static SoundRenderer &getInstance();
|
||||||
bool init(Window *window);
|
bool init(Window *window);
|
||||||
void update();
|
void update();
|
||||||
virtual void simpleTask() { update(); }
|
virtual void simpleTask(BaseThread *callingThread) { update(); }
|
||||||
SoundPlayer *getSoundPlayer() const {return soundPlayer;}
|
SoundPlayer *getSoundPlayer() const {return soundPlayer;}
|
||||||
|
|
||||||
//music
|
//music
|
||||||
|
|
|
@ -31,13 +31,21 @@ protected:
|
||||||
Mutex mutexRunning;
|
Mutex mutexRunning;
|
||||||
Mutex mutexQuit;
|
Mutex mutexQuit;
|
||||||
Mutex mutexBeginExecution;
|
Mutex mutexBeginExecution;
|
||||||
|
Mutex mutexDeleteSelfOnExecutionDone;
|
||||||
|
|
||||||
|
Mutex mutexThreadObjectAccessor;
|
||||||
|
|
||||||
|
Mutex mutexExecutingTask;
|
||||||
|
bool executingTask;
|
||||||
|
|
||||||
bool quit;
|
bool quit;
|
||||||
bool running;
|
bool running;
|
||||||
string uniqueID;
|
string uniqueID;
|
||||||
bool hasBeginExecution;
|
bool hasBeginExecution;
|
||||||
|
bool deleteSelfOnExecutionDone;
|
||||||
|
|
||||||
virtual void setQuitStatus(bool value);
|
virtual void setQuitStatus(bool value);
|
||||||
|
void deleteSelfIfRequired();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BaseThread();
|
BaseThread();
|
||||||
|
@ -47,17 +55,26 @@ public:
|
||||||
virtual void signalQuit();
|
virtual void signalQuit();
|
||||||
virtual bool getQuitStatus();
|
virtual bool getQuitStatus();
|
||||||
virtual bool getRunningStatus();
|
virtual bool getRunningStatus();
|
||||||
|
|
||||||
virtual bool getHasBeginExecution();
|
virtual bool getHasBeginExecution();
|
||||||
virtual void setHasBeginExecution(bool value);
|
virtual void setHasBeginExecution(bool value);
|
||||||
|
|
||||||
static bool shutdownAndWait(BaseThread *ppThread);
|
static bool shutdownAndWait(BaseThread *ppThread);
|
||||||
virtual bool shutdownAndWait();
|
virtual bool shutdownAndWait();
|
||||||
virtual bool canShutdown() { return true; }
|
virtual bool canShutdown(bool deleteSelfIfShutdownDelayed=false);
|
||||||
|
|
||||||
|
virtual bool getDeleteSelfOnExecutionDone();
|
||||||
|
virtual void setDeleteSelfOnExecutionDone(bool value);
|
||||||
|
|
||||||
void setUniqueID(string value) { uniqueID = value; }
|
void setUniqueID(string value) { uniqueID = value; }
|
||||||
string getUniqueID() { return uniqueID; }
|
string getUniqueID() { return uniqueID; }
|
||||||
|
|
||||||
virtual void setRunningStatus(bool value);
|
virtual void setRunningStatus(bool value);
|
||||||
|
|
||||||
|
void setExecutingTask(bool value);
|
||||||
|
bool getExecutingTask();
|
||||||
|
|
||||||
|
Mutex * getMutexThreadObjectAccessor() { return &mutexThreadObjectAccessor; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class RunningStatusSafeWrapper {
|
class RunningStatusSafeWrapper {
|
||||||
|
@ -85,6 +102,32 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ExecutingTaskSafeWrapper {
|
||||||
|
protected:
|
||||||
|
BaseThread *thread;
|
||||||
|
public:
|
||||||
|
|
||||||
|
ExecutingTaskSafeWrapper(BaseThread *thread) {
|
||||||
|
this->thread = thread;
|
||||||
|
Enable();
|
||||||
|
}
|
||||||
|
~ExecutingTaskSafeWrapper() {
|
||||||
|
Disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Enable() {
|
||||||
|
if(this->thread != NULL) {
|
||||||
|
this->thread->setExecutingTask(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Disable() {
|
||||||
|
if(this->thread != NULL) {
|
||||||
|
this->thread->setExecutingTask(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
//
|
//
|
||||||
class SimpleTaskCallbackInterface {
|
class SimpleTaskCallbackInterface {
|
||||||
public:
|
public:
|
||||||
virtual void simpleTask() = 0;
|
virtual void simpleTask(BaseThread *callingThread) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SimpleTaskThread : public BaseThread
|
class SimpleTaskThread : public BaseThread
|
||||||
|
@ -63,9 +63,6 @@ protected:
|
||||||
bool taskSignalled;
|
bool taskSignalled;
|
||||||
bool needTaskSignal;
|
bool needTaskSignal;
|
||||||
|
|
||||||
Mutex mutexExecutingTask;
|
|
||||||
bool executingTask;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SimpleTaskThread();
|
SimpleTaskThread();
|
||||||
SimpleTaskThread(SimpleTaskCallbackInterface *simpleTaskInterface,
|
SimpleTaskThread(SimpleTaskCallbackInterface *simpleTaskInterface,
|
||||||
|
@ -73,12 +70,10 @@ public:
|
||||||
unsigned int millisecsBetweenExecutions=0,
|
unsigned int millisecsBetweenExecutions=0,
|
||||||
bool needTaskSignal = false);
|
bool needTaskSignal = false);
|
||||||
virtual void execute();
|
virtual void execute();
|
||||||
virtual bool canShutdown();
|
virtual bool canShutdown(bool deleteSelfIfShutdownDelayed=false);
|
||||||
|
|
||||||
void setTaskSignalled(bool value);
|
void setTaskSignalled(bool value);
|
||||||
bool getTaskSignalled();
|
bool getTaskSignalled();
|
||||||
void setExecutingTask(bool value);
|
|
||||||
bool getExecutingTask();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
|
@ -121,7 +121,7 @@ public:
|
||||||
Socket();
|
Socket();
|
||||||
virtual ~Socket();
|
virtual ~Socket();
|
||||||
|
|
||||||
virtual void simpleTask();
|
virtual void simpleTask(BaseThread *callingThread);
|
||||||
|
|
||||||
static int getBroadCastPort() { return broadcast_portno; }
|
static int getBroadCastPort() { return broadcast_portno; }
|
||||||
static void setBroadCastPort(int value) { broadcast_portno = value; }
|
static void setBroadCastPort(int value) { broadcast_portno = value; }
|
||||||
|
|
|
@ -27,6 +27,8 @@ BaseThread::BaseThread() : Thread() {
|
||||||
setQuitStatus(false);
|
setQuitStatus(false);
|
||||||
setRunningStatus(false);
|
setRunningStatus(false);
|
||||||
setHasBeginExecution(false);
|
setHasBeginExecution(false);
|
||||||
|
setExecutingTask(false);
|
||||||
|
setDeleteSelfOnExecutionDone(false);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
@ -117,6 +119,46 @@ void BaseThread::setRunningStatus(bool value) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseThread::setExecutingTask(bool value) {
|
||||||
|
MutexSafeWrapper safeMutex(&mutexExecutingTask);
|
||||||
|
executingTask = value;
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BaseThread::getExecutingTask() {
|
||||||
|
bool retval = false;
|
||||||
|
MutexSafeWrapper safeMutex(&mutexExecutingTask);
|
||||||
|
retval = executingTask;
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BaseThread::getDeleteSelfOnExecutionDone() {
|
||||||
|
bool retval = false;
|
||||||
|
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone);
|
||||||
|
retval = deleteSelfOnExecutionDone;
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseThread::setDeleteSelfOnExecutionDone(bool value) {
|
||||||
|
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone);
|
||||||
|
deleteSelfOnExecutionDone = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseThread::deleteSelfIfRequired() {
|
||||||
|
if(getDeleteSelfOnExecutionDone() == true) {
|
||||||
|
delete this;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BaseThread::canShutdown(bool deleteSelfIfShutdownDelayed) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool BaseThread::shutdownAndWait(BaseThread *pThread) {
|
bool BaseThread::shutdownAndWait(BaseThread *pThread) {
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if(pThread != NULL) {
|
if(pThread != NULL) {
|
||||||
|
|
|
@ -26,10 +26,12 @@ FileCRCPreCacheThread::FileCRCPreCacheThread() : BaseThread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileCRCPreCacheThread::execute() {
|
void FileCRCPreCacheThread::execute() {
|
||||||
|
{
|
||||||
RunningStatusSafeWrapper runningStatus(this);
|
RunningStatusSafeWrapper runningStatus(this);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(getQuitStatus() == true) {
|
if(getQuitStatus() == true) {
|
||||||
|
deleteSelfIfRequired();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +58,7 @@ void FileCRCPreCacheThread::execute() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sleep( 100 );
|
sleep( 50 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +72,8 @@ void FileCRCPreCacheThread::execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] FILE CRC PreCache thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] FILE CRC PreCache thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
}
|
||||||
|
deleteSelfIfRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInterface,
|
SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInterface,
|
||||||
|
@ -81,14 +85,20 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter
|
||||||
this->millisecsBetweenExecutions = millisecsBetweenExecutions;
|
this->millisecsBetweenExecutions = millisecsBetweenExecutions;
|
||||||
this->needTaskSignal = needTaskSignal;
|
this->needTaskSignal = needTaskSignal;
|
||||||
setTaskSignalled(false);
|
setTaskSignalled(false);
|
||||||
setExecutingTask(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SimpleTaskThread::canShutdown() {
|
bool SimpleTaskThread::canShutdown(bool deleteSelfIfShutdownDelayed) {
|
||||||
return (getExecutingTask() == false);
|
bool ret = (getExecutingTask() == false);
|
||||||
|
if(deleteSelfIfShutdownDelayed == true) {
|
||||||
|
setDeleteSelfOnExecutionDone(deleteSelfIfShutdownDelayed);
|
||||||
|
signalQuit();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleTaskThread::execute() {
|
void SimpleTaskThread::execute() {
|
||||||
|
{
|
||||||
RunningStatusSafeWrapper runningStatus(this);
|
RunningStatusSafeWrapper runningStatus(this);
|
||||||
try {
|
try {
|
||||||
if(getQuitStatus() == true) {
|
if(getQuitStatus() == true) {
|
||||||
|
@ -114,15 +124,8 @@ void SimpleTaskThread::execute() {
|
||||||
else if(runTask == true) {
|
else if(runTask == true) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
if(getQuitStatus() == false) {
|
if(getQuitStatus() == false) {
|
||||||
try {
|
ExecutingTaskSafeWrapper safeExecutingTaskMutex(this);
|
||||||
setExecutingTask(true);
|
this->simpleTaskInterface->simpleTask(this);
|
||||||
this->simpleTaskInterface->simpleTask();
|
|
||||||
setExecutingTask(false);
|
|
||||||
}
|
|
||||||
catch(const exception &ex) {
|
|
||||||
setExecutingTask(false);
|
|
||||||
throw runtime_error(ex.what());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
}
|
}
|
||||||
|
@ -151,7 +154,10 @@ void SimpleTaskThread::execute() {
|
||||||
|
|
||||||
throw runtime_error(ex.what());
|
throw runtime_error(ex.what());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] END\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] END\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
|
|
||||||
|
deleteSelfIfRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleTaskThread::setTaskSignalled(bool value) {
|
void SimpleTaskThread::setTaskSignalled(bool value) {
|
||||||
|
@ -177,21 +183,6 @@ bool SimpleTaskThread::getTaskSignalled() {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleTaskThread::setExecutingTask(bool value) {
|
|
||||||
MutexSafeWrapper safeMutex(&mutexExecutingTask);
|
|
||||||
executingTask = value;
|
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SimpleTaskThread::getExecutingTask() {
|
|
||||||
bool retval = false;
|
|
||||||
MutexSafeWrapper safeMutex(&mutexExecutingTask);
|
|
||||||
retval = executingTask;
|
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
LogFileThread::LogFileThread() : BaseThread() {
|
LogFileThread::LogFileThread() : BaseThread() {
|
||||||
|
@ -223,10 +214,12 @@ bool LogFileThread::checkSaveCurrentLogBufferToDisk() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogFileThread::execute() {
|
void LogFileThread::execute() {
|
||||||
|
{
|
||||||
RunningStatusSafeWrapper runningStatus(this);
|
RunningStatusSafeWrapper runningStatus(this);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(getQuitStatus() == true) {
|
if(getQuitStatus() == true) {
|
||||||
|
deleteSelfIfRequired();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,6 +251,8 @@ void LogFileThread::execute() {
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] LogFile thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] LogFile thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] LogFile thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] LogFile thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
}
|
||||||
|
deleteSelfIfRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t LogFileThread::getLogEntryBufferCount() {
|
std::size_t LogFileThread::getLogEntryBufferCount() {
|
||||||
|
|
|
@ -787,7 +787,7 @@ float Socket::getThreadedPingMS(std::string host) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket::simpleTask() {
|
void Socket::simpleTask(BaseThread *callingThread) {
|
||||||
// update ping times every x seconds
|
// update ping times every x seconds
|
||||||
const int pingFrequencySeconds = 2;
|
const int pingFrequencySeconds = 2;
|
||||||
if(difftime(time(NULL),lastThreadedPing) < pingFrequencySeconds) {
|
if(difftime(time(NULL),lastThreadedPing) < pingFrequencySeconds) {
|
||||||
|
|
Loading…
Reference in New Issue