From 8ce2993e5d4c36ff0608560520832d7736c111c0 Mon Sep 17 00:00:00 2001 From: mathusummut Date: Mon, 4 Mar 2019 00:18:52 +0100 Subject: [PATCH] Now mod center is loaded from glest.io --- mk/shared/glest.ini | 1 + mk/windows/glest.ini | 1 + mk/windows/glest_release.ini | 1 + source/game/facilities/logger.cpp | 2 +- source/game/game/game.cpp | 203 +++++++++++------------ source/game/graphics/renderer.cpp | 140 +++++++++------- source/game/main/program.cpp | 12 +- source/game/menu/menu_state_mods.cpp | 11 +- source/game/network/server_interface.cpp | 7 +- source/game/types/faction_type.cpp | 3 +- source/game/types/tech_tree.cpp | 25 ++- source/game/world/world.cpp | 18 +- 12 files changed, 228 insertions(+), 196 deletions(-) diff --git a/mk/shared/glest.ini b/mk/shared/glest.ini index eb2ee811e..a1acc5292 100644 --- a/mk/shared/glest.ini +++ b/mk/shared/glest.ini @@ -62,6 +62,7 @@ IRCChannel=#glest-lobby Lang=english MaxLights=8 Masterserver=http://master.megaglest.org/ +Modserver=https://glest.io/ NetPlayerName=newbie NetworkConsistencyChecks=true NetworkInterfaces=lo,eth,wlan,vlan,vboxnet,br-lan,br-gest,enp0s,enp1s,enp2s,enp3s,enp4s,enp5s,enp6s,enp7s,enp8s,enp9s diff --git a/mk/windows/glest.ini b/mk/windows/glest.ini index fc5f27471..728614322 100644 --- a/mk/windows/glest.ini +++ b/mk/windows/glest.ini @@ -62,6 +62,7 @@ IRCChannel=#glest-lobby Lang=english MaxLights=8 Masterserver=http://master.megaglest.org/ +Modserver=https://glest.io/ NetPlayerName=newbie NetworkConsistencyChecks=true PhotoMode=false diff --git a/mk/windows/glest_release.ini b/mk/windows/glest_release.ini index ea6944764..52adb5ded 100644 --- a/mk/windows/glest_release.ini +++ b/mk/windows/glest_release.ini @@ -62,6 +62,7 @@ IRCChannel=#glest-lobby Lang=english MaxLights=8 Masterserver=http://master.megaglest.org/ +Modserver=http://master.megaglest.org/ NetPlayerName=newbie NetworkConsistencyChecks=true PhotoMode=false diff --git a/source/game/facilities/logger.cpp b/source/game/facilities/logger.cpp index bd0668860..e5549b002 100644 --- a/source/game/facilities/logger.cpp +++ b/source/game/facilities/logger.cpp @@ -333,7 +333,7 @@ namespace Game { } - if (Config::getInstance().getBool("EnableLoadCancel", "true")) { + if (Config::getInstance().getBool("EnableLoadCancel", "false")) { if (buttonCancel.getEnabled() == false) { buttonCancel.init((metrics.getVirtualW() / 2) - (125 / 2), 50 * metrics.getVirtualH() / 100, 125); buttonCancel.setText(lang.getString("Cancel")); diff --git a/source/game/game/game.cpp b/source/game/game/game.cpp index cb11ce5a3..daa42a908 100644 --- a/source/game/game/game.cpp +++ b/source/game/game/game.cpp @@ -1540,11 +1540,8 @@ namespace Game { ::Shared::Platform::Window::handleEvent(); SDL_PumpEvents(); } - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if ((loadTypes & lgt_FactionPreview) == lgt_FactionPreview) { if (SystemFlags:: @@ -1559,11 +1556,8 @@ namespace Game { ::Shared::Platform::Window::handleEvent(); SDL_PumpEvents(); } - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if (showPerfStats) { sprintf(perfBuf, @@ -1624,11 +1618,8 @@ namespace Game { (__FILE__).c_str(), __FUNCTION__, __LINE__); - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } //tileset if ((loadTypes & lgt_TileSet) == lgt_TileSet) { @@ -1643,11 +1634,8 @@ namespace Game { loadTileset(config.getPathListForType(ptTilesets, scenarioDir), tilesetName, &checksum, loadedFileList); } - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if (showPerfStats) { sprintf(perfBuf, @@ -1662,11 +1650,8 @@ namespace Game { ::Shared::Platform::Window::handleEvent(); SDL_PumpEvents(); - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if (SystemFlags:: getSystemSettingType(SystemFlags::debugSystem).enabled) @@ -1726,11 +1711,8 @@ namespace Game { ::Shared::Platform::Window::handleEvent(); SDL_PumpEvents(); - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if (SystemFlags:: getSystemSettingType(SystemFlags::debugSystem).enabled) @@ -1752,11 +1734,8 @@ namespace Game { world.loadMap(Config::getMapPath(mapName, scenarioDir), &checksum); } - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if (showPerfStats) { sprintf(perfBuf, @@ -1771,11 +1750,8 @@ namespace Game { ::Shared::Platform::Window::handleEvent(); SDL_PumpEvents(); - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if (SystemFlags:: getSystemSettingType(SystemFlags::debugSystem).enabled) @@ -1823,11 +1799,8 @@ namespace Game { sleep(0); SDL_PumpEvents(); - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if (SystemFlags:: getSystemSettingType(SystemFlags::debugSystem).enabled) @@ -1919,11 +1892,8 @@ namespace Game { SDL_PumpEvents(); } - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } try { world.init(this, gameSettings.getDefaultUnits()); @@ -1993,11 +1963,9 @@ namespace Game { ::Shared::Platform::Window::handleEvent(); SDL_PumpEvents(); - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } + gui.init(this); if (SystemFlags:: @@ -2015,11 +1983,8 @@ namespace Game { chatManager.init(&console, world.getThisTeamIndex()); console.clearStoredLines(); } - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if (showPerfStats) { sprintf(perfBuf, @@ -2039,11 +2004,8 @@ namespace Game { } } - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if (showPerfStats) { sprintf(perfBuf, @@ -2094,11 +2056,8 @@ namespace Game { std::vector < SlaveThreadControllerInterface * >slaveThreadList; aiInterfaces.resize(world.getFactionCount()); for (int i = 0; i < world.getFactionCount(); ++i) { - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } Faction *faction = world.getFaction(i); @@ -2150,11 +2109,8 @@ namespace Game { ::Shared::Platform::Window::handleEvent(); SDL_PumpEvents(); - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if (world.getFactionCount() == 1 && world.getFaction(0)->getPersonalityType() == fpt_Observer) { @@ -2205,21 +2161,15 @@ namespace Game { add(Lang:: getInstance().getString("LogScreenGameLoadingInitRenderer", ""), true); - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } //printf("Before renderer.initGame\n"); renderer.initGame(this, this->getGameCameraPtr()); //printf("After renderer.initGame\n"); - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if (showPerfStats) { sprintf(perfBuf, @@ -2252,11 +2202,8 @@ namespace Game { ::Shared::Platform::Window::handleEvent(); SDL_PumpEvents(); - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } if (SystemFlags:: getSystemSettingType(SystemFlags::debugSystem).enabled) @@ -2357,11 +2304,8 @@ namespace Game { setupPopupMenus(false); for (int i = 0; i < world.getFactionCount(); ++i) { - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + if (logger.getCancelLoading()) return; - } Faction *faction = world.getFaction(i); @@ -3890,6 +3834,8 @@ namespace Game { //world->getMapPtr()->end(); //world.end(); + Logger& logger = Logger::getInstance(); + if (keepFactions == false) { world.end(); @@ -3909,7 +3855,6 @@ namespace Game { // unit particles and fade them out etc and this end method deletes the original // object pointers. Renderer& renderer = Renderer::getInstance(); - Logger& logger = Logger::getInstance(); renderer.endGame(true); GameConstants::updateFps = original_updateFps; @@ -3919,14 +3864,34 @@ namespace Game { this->resetMembers(); this->load(); if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); - } else { - this->init(); - if (logger.getCancelLoading()) { - logger.setCancelLoading(false); - //endGame(); + Lang &lang = Lang::getInstance(); + const vector languageList = this->gameSettings.getUniqueNetworkPlayerLanguages(); + for (unsigned int langIndex = 0; langIndex < languageList.size(); ++langIndex) { + string sErr = lang.getString("GameCancelledByUser", languageList[langIndex]); + bool localEcho = lang.isLanguageLocal(languageList[langIndex]); + //sendTextMessage(sErr, -1, localEcho, languageList[langIndex]); + /*GameNetworkInterface* gameNetworkInterface = NetworkManager::getInstance().getGameNetworkInterface(); + if (gameNetworkInterface != NULL) + gameNetworkInterface->sendTextMessage(sErr, -1, localEcho, languageList[langIndex]); */ + printf("\niuieioeioeui\n"); } + quitGame(); + logger.setCancelLoading(false); + return; + } + this->init(); + if (logger.getCancelLoading()) { + Lang &lang = Lang::getInstance(); + const vector languageList = this->gameSettings.getUniqueNetworkPlayerLanguages(); + for (unsigned int langIndex = 0; langIndex < languageList.size(); ++langIndex) { + string sErr = lang.getString("GameCancelledByUser", languageList[langIndex]); + bool localEcho = lang.isLanguageLocal(languageList[langIndex]); + //sendTextMessage(sErr, -1, localEcho, languageList[langIndex]); + printf("\niuieioeioeui\n"); + } + quitGame(); + logger.setCancelLoading(false); + return; } } else { SoundRenderer & soundRenderer = SoundRenderer::getInstance(); @@ -3946,6 +3911,19 @@ namespace Game { this->setGameSettings(&gameSettings); this->load(lgt_FactionPreview | lgt_TileSet | lgt_Map | lgt_Scenario); + if (logger.getCancelLoading()) { + Lang &lang = Lang::getInstance(); + const vector languageList = this->gameSettings.getUniqueNetworkPlayerLanguages(); + for (unsigned int langIndex = 0; langIndex < languageList.size(); ++langIndex) { + string sErr = lang.getString("GameCancelledByUser", languageList[langIndex]); + bool localEcho = lang.isLanguageLocal(languageList[langIndex]); + //sendTextMessage(sErr, -1, localEcho, languageList[langIndex]); + printf("\niuieioeioeui\n"); + } + quitGame(); + logger.setCancelLoading(false); + return; + } try { world.init(this, gameSettings.getDefaultUnits(), false); } catch (const exception & ex) { @@ -3964,6 +3942,19 @@ namespace Game { ErrorDisplayMessage(ex.what(), true); } } + if (logger.getCancelLoading()) { + Lang &lang = Lang::getInstance(); + const vector languageList = this->gameSettings.getUniqueNetworkPlayerLanguages(); + for (unsigned int langIndex = 0; langIndex < languageList.size(); ++langIndex) { + string sErr = lang.getString("GameCancelledByUser", languageList[langIndex]); + bool localEcho = lang.isLanguageLocal(languageList[langIndex]); + //sendTextMessage(sErr, -1, localEcho, languageList[langIndex]); + printf("\niuieioeioeui\n"); + } + quitGame(); + logger.setCancelLoading(false); + return; + } world.initUnitsForScenario(); Map *map = world.getMap(); @@ -4048,34 +4039,34 @@ namespace Game { printf("%s", perfList[x].c_str()); } } - } catch (const exception & ex) { - quitPendingIndicator = true; + } catch (const exception & ex) { + quitPendingIndicator = true; - char szBuf[8096] = ""; - snprintf(szBuf, 8096, "In [%s::%s Line: %d] Error [%s]\n", - extractFileFromDirectoryPath(__FILE__).c_str(), - __FUNCTION__, __LINE__, ex.what()); + char szBuf[8096] = ""; + snprintf(szBuf, 8096, "In [%s::%s Line: %d] Error [%s]\n", + extractFileFromDirectoryPath(__FILE__).c_str(), + __FUNCTION__, __LINE__, ex.what()); - SystemFlags::OutputDebug(SystemFlags::debugError, szBuf); - if (SystemFlags:: - getSystemSettingType(SystemFlags::debugSystem).enabled) - SystemFlags::OutputDebug(SystemFlags::debugSystem, szBuf); + SystemFlags::OutputDebug(SystemFlags::debugError, szBuf); + if (SystemFlags:: + getSystemSettingType(SystemFlags::debugSystem).enabled) + SystemFlags::OutputDebug(SystemFlags::debugSystem, szBuf); - //printf("#100 quitPendingIndicator = %d, errorMessageBox.getEnabled() = %d\n",quitPendingIndicator,errorMessageBox.getEnabled()); + //printf("#100 quitPendingIndicator = %d, errorMessageBox.getEnabled() = %d\n",quitPendingIndicator,errorMessageBox.getEnabled()); - NetworkManager & networkManager = NetworkManager::getInstance(); - if (networkManager.getGameNetworkInterface() != NULL) { - GameNetworkInterface *networkInterface = - NetworkManager::getInstance().getGameNetworkInterface(); - networkInterface->sendTextMessage(szBuf, -1, true, ""); - sleep(10); - networkManager.getGameNetworkInterface()->quitGame(true); - } - if (errorMessageBox.getEnabled() == false) { - ErrorDisplayMessage(ex.what(), true); - } + NetworkManager & networkManager = NetworkManager::getInstance(); + if (networkManager.getGameNetworkInterface() != NULL) { + GameNetworkInterface *networkInterface = + NetworkManager::getInstance().getGameNetworkInterface(); + networkInterface->sendTextMessage(szBuf, -1, true, ""); + sleep(10); + networkManager.getGameNetworkInterface()->quitGame(true); + } + if (errorMessageBox.getEnabled() == false) { + ErrorDisplayMessage(ex.what(), true); } } + } void Game::addPerformanceCount(string key, int64 value) { gamePerformanceCounts[key] = value + gamePerformanceCounts[key] / 2; diff --git a/source/game/graphics/renderer.cpp b/source/game/graphics/renderer.cpp index 1ef597303..e101dfbfd 100644 --- a/source/game/graphics/renderer.cpp +++ b/source/game/graphics/renderer.cpp @@ -963,7 +963,7 @@ namespace Game { //places all the opengl lights void Renderer::setupLighting() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) { return; } @@ -1067,6 +1067,9 @@ namespace Game { //} void Renderer::loadGameCameraMatrix() { + if (game == NULL) + return; + const GameCamera *gameCamera = game->getGameCamera(); glMatrixMode(GL_MODELVIEW); @@ -1395,6 +1398,9 @@ namespace Game { } void Renderer::computeVisibleQuad() { + if (gameCamera == NULL) + return; + visibleQuad = this->gameCamera->computeVisibleQuad(); bool frustumChanged = false; @@ -1672,7 +1678,7 @@ namespace Game { } void Renderer::renderMouse3d() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) { return; } @@ -1681,7 +1687,7 @@ namespace Game { return; } - if (game == NULL) { + /*if (game == NULL) { char szBuf[8096] = ""; snprintf(szBuf, 8096, "In [%s::%s] Line: %d game == NULL", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); throw game_runtime_error(szBuf); @@ -1693,16 +1699,16 @@ namespace Game { char szBuf[8096] = ""; snprintf(szBuf, 8096, "In [%s::%s] Line: %d game->getGui()->getMouse3d() == NULL", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); throw game_runtime_error(szBuf); - } + }*/ const Gui *gui = game->getGui(); const Mouse3d *mouse3d = gui->getMouse3d(); const Map *map = game->getWorld()->getMap(); - if (map == NULL) { + /*if (map == NULL) { char szBuf[8096] = ""; snprintf(szBuf, 8096, "In [%s::%s] Line: %d map == NULL", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); throw game_runtime_error(szBuf); - } + }*/ assertGl(); @@ -2186,7 +2192,7 @@ namespace Game { void Renderer::renderPerformanceStats() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) { return; } @@ -2222,7 +2228,7 @@ namespace Game { } void Renderer::renderClock() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) { return; } @@ -2294,7 +2300,7 @@ namespace Game { } void Renderer::renderResourceStatus() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) { return; } @@ -2501,9 +2507,12 @@ namespace Game { string str = intToStr(r->getAmount()); glEnable(GL_TEXTURE_2D); + Vec4f resourceFontColor = Vec4f(1.f, 1.f, 1.f, 1.f); + if (game == NULL) { + const Vec4f fontColor = game->getGui()->getDisplay()->getColor(); + resourceFontColor = fontColor; + } - const Vec4f fontColor = game->getGui()->getDisplay()->getColor(); - Vec4f resourceFontColor = fontColor; bool isNegativeConsumableDisplayCycle = false; if (rt->getClass() == rcConsumable) { @@ -2565,9 +2574,8 @@ namespace Game { } void Renderer::renderSelectionQuad() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) return; - } Config &config = Config::getInstance(); if (config.getBool("RecordMode", "false") == true) { @@ -2610,7 +2618,6 @@ namespace Game { Vec2i computeCenteredPos(const string &text, Font2D *font, int x, int y) { if (font == NULL) { - //abort(); throw game_runtime_error("font == NULL (1) text = " + text); } const Metrics &metrics = Metrics::getInstance(); @@ -2655,6 +2662,8 @@ namespace Game { void Renderer::renderTextSurroundingBox(int x, int y, int w, int h, int maxEditWidth, int maxEditRenderWidth) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) + return; //glColor4fv(color.ptr()); //glBegin(GL_QUADS); // Start drawing a quad primitive @@ -4328,11 +4337,11 @@ namespace Game { } void Renderer::renderSurface(const int renderFps) { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) { return; } - assertGl(); + assertGl(); const World *world = game->getWorld(); const Map *map = world->getMap(); @@ -4741,7 +4750,7 @@ namespace Game { } void Renderer::renderObjects(const int renderFps) { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) { return; } @@ -4840,9 +4849,8 @@ namespace Game { } void Renderer::renderWater() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) return; - } const World *world = game->getWorld(); const Map *map = world->getMap(); @@ -5090,6 +5098,8 @@ namespace Game { } void Renderer::renderGhostModel(const UnitType *building, const Vec2i pos, CardinalDir facing, Vec4f *forceColor) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) + return; //const UnitType *building= gui->getBuilding(); //const Vec2i &pos= gui->getPosObjWorld(); @@ -5240,7 +5250,7 @@ namespace Game { glPopMatrix(); unit->setVisible(true); - if (showDebugUI == true && + if (game != NULL && showDebugUI == true && (showDebugUILevel & debugui_unit_titles) == debugui_unit_titles) { unit->setScreenPos(computeScreenPosition(currVec)); @@ -5336,9 +5346,8 @@ namespace Game { } void Renderer::renderMorphEffects() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) return; - } VisibleQuadContainerCache &qCache = getQuadCache(); if (qCache.visibleQuadUnitList.empty() == false) { @@ -5395,9 +5404,8 @@ namespace Game { void Renderer::renderSelectionEffects(int healthbarMode) { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) return; - } Config &config = Config::getInstance(); if (config.getBool("RecordMode", "false") == true) { @@ -5704,6 +5712,9 @@ namespace Game { } bool Renderer::isHealthBarVisible(const Unit *unit, int healthbarMode) { + if (game == NULL) + return false; + int healthbarVisible = hbvUndefined; //check options (hotkey) if (healthbarMode == hbvUndefined) { @@ -5733,9 +5744,8 @@ namespace Game { } void Renderer::renderWaterEffects() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) return; - } const World *world = game->getWorld(); const WaterEffects *we = world->getWaterEffects(); @@ -5832,9 +5842,8 @@ namespace Game { } void Renderer::renderHud() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) return; - } Texture2D *hudTexture = game->getGui()->getHudTexture(); if (hudTexture != NULL) { @@ -5844,9 +5853,8 @@ namespace Game { } void Renderer::renderMinimap() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) return; - } const World *world = game->getWorld(); const Minimap *minimap = world->getMinimap(); @@ -6176,9 +6184,9 @@ namespace Game { } void Renderer::renderHighlightedCellsOnMinimap() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) return; - } + // Draw marked cells const std::vector *highlightedCells = game->getHighlightedCells(); if (highlightedCells->empty() == false) { @@ -6226,6 +6234,9 @@ namespace Game { } void Renderer::renderMarkedCellsOnMinimap() { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) + return; + // Draw marked cells std::map markedCells = game->getMapMarkedCellList(); if (markedCells.empty() == false) { @@ -6307,9 +6318,8 @@ namespace Game { } } void Renderer::renderVisibleMarkedCells(bool renderTextHint, int x, int y) { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) return; - } // Draw marked cells std::map markedCells = game->getMapMarkedCellList(); @@ -6424,9 +6434,8 @@ namespace Game { } void Renderer::renderDisplay() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || game == NULL) return; - } CoreData &coreData = CoreData::getInstance(); const Metrics &metrics = Metrics::getInstance(); @@ -6800,6 +6809,9 @@ namespace Game { // ==================== computing ==================== bool Renderer::ccomputePosition(const Vec2i &screenPos, Vec2i &worldPos, bool exactCoords) { + if (game == NULL) + return false; + assertGl(); const Map* map = game->getWorld()->getMap(); const Metrics &metrics = Metrics::getInstance(); @@ -7205,11 +7217,10 @@ namespace Game { //assertGl(); - if (nearestLightPos.w == 0.f) { + if (nearestLightPos.w == 0.f && game != NULL) { //directional light //light pos - assert(game != NULL); assert(game->getWorld() != NULL); const TimeFlow *tf = game->getWorld()->getTimeFlow(); assert(tf != NULL); @@ -7419,36 +7430,37 @@ namespace Game { } void Renderer::autoConfig() { - if (GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) { - Config &config = Config::getInstance(); + if (GlobalStaticFlags::getIsNonGraphicalModeEnabled()) + return; - bool nvidiaCard = toLower(getGlVendor()).find("nvidia") != string::npos; - bool atiCard = toLower(getGlVendor()).find("ati") != string::npos; - //bool shadowExtensions = isGlExtensionSupported("GL_ARB_shadow") && isGlExtensionSupported("GL_ARB_shadow_ambient"); - bool shadowExtensions = isGlExtensionSupported("GL_ARB_shadow"); + Config &config = Config::getInstance(); - //3D textures - config.setBool("Textures3D", isGlExtensionSupported("GL_EXT_texture3D")); + bool nvidiaCard = toLower(getGlVendor()).find("nvidia") != string::npos; + bool atiCard = toLower(getGlVendor()).find("ati") != string::npos; + //bool shadowExtensions = isGlExtensionSupported("GL_ARB_shadow") && isGlExtensionSupported("GL_ARB_shadow_ambient"); + bool shadowExtensions = isGlExtensionSupported("GL_ARB_shadow"); - //shadows - string shadows = ""; - if (getGlMaxTextureUnits() >= 3) { - if (nvidiaCard && shadowExtensions) { - shadows = shadowsToStr(sShadowMapping); - } else { - shadows = shadowsToStr(sProjected); - } + //3D textures + config.setBool("Textures3D", isGlExtensionSupported("GL_EXT_texture3D")); + + //shadows + string shadows = ""; + if (getGlMaxTextureUnits() >= 3) { + if (nvidiaCard && shadowExtensions) { + shadows = shadowsToStr(sShadowMapping); } else { - shadows = shadowsToStr(sDisabled); + shadows = shadowsToStr(sProjected); } - config.setString("Shadows", shadows); - - //lights - config.setInt("MaxLights", atiCard ? 1 : 8); - - //filter - config.setString("Filter", "Bilinear"); + } else { + shadows = shadowsToStr(sDisabled); } + config.setString("Shadows", shadows); + + //lights + config.setInt("MaxLights", atiCard ? 1 : 8); + + //filter + config.setString("Filter", "Bilinear"); } void Renderer::clearBuffers() { @@ -7605,7 +7617,6 @@ namespace Game { return unitsList; } - assert(game != NULL); //const World *world= game->getWorld(); //assert(world != NULL); @@ -9172,6 +9183,9 @@ namespace Game { } void Renderer::updateMarkedCellScreenPosQuadCache(Vec2i pos) { + if (game == NULL) + return; + const World *world = game->getWorld(); const Map *map = world->getMap(); diff --git a/source/game/main/program.cpp b/source/game/main/program.cpp index 42eb1d50a..513f8c8a3 100644 --- a/source/game/main/program.cpp +++ b/source/game/main/program.cpp @@ -671,8 +671,7 @@ namespace Game { } programState->addPerformanceCount("programState->updateCamera()", - chronoPerformanceCounts.getMillis - ()); + chronoPerformanceCounts.getMillis()); if (showPerfStats) { sprintf(perfBuf, @@ -707,6 +706,12 @@ namespace Game { while (prevState == this->programState && updateTimer.isTime()) { Chrono chronoUpdateLoop; + /*if (Logger::getInstance().getCancelLoading()) { + Logger::getInstance().setCancelLoading(false); + printf("hmm"); + break; + }*/ + #ifdef DEBUG if (SystemFlags:: getSystemSettingType(SystemFlags::debugPerformance).enabled) @@ -881,8 +886,7 @@ namespace Game { } programState->addPerformanceCount("programState->tick()", - chronoPerformanceCounts.getMillis - ()); + chronoPerformanceCounts.getMillis()); if (showPerfStats) { sprintf(perfBuf, diff --git a/source/game/menu/menu_state_mods.cpp b/source/game/menu/menu_state_mods.cpp index 2acd6076c..23862c3db 100644 --- a/source/game/menu/menu_state_mods.cpp +++ b/source/game/menu/menu_state_mods.cpp @@ -549,11 +549,12 @@ namespace Game { if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n", __FILE__, __FUNCTION__, __LINE__); - if (config.getString("Masterserver", "") != "") { - string baseURL = config.getString("Masterserver"); - if (baseURL != "") { - endPathWithSlash(baseURL, false); - } + string baseURL = config.getString("Modserver", ""); + if (baseURL == "") + baseURL = config.getString("Masterserver", ""); + + if (baseURL != "") { + endPathWithSlash(baseURL, false); string phpVersionParam = config.getString("phpVersionParam", "?version=0.1"); diff --git a/source/game/network/server_interface.cpp b/source/game/network/server_interface.cpp index 58352ed6f..b5bf6c659 100644 --- a/source/game/network/server_interface.cpp +++ b/source/game/network/server_interface.cpp @@ -1911,9 +1911,7 @@ namespace Game { int sleepMillis = Config::getInstance().getInt("NetworkServerLoopGameLoadingCapSleepMillis", "10"); int64 lastStatusUpdate = 0; - while (exitServer == false && - allReady == false && - logger.getCancelLoading() == false) { + while (exitServer == false && allReady == false && logger.getCancelLoading() == false) { waitLoopIterationCount++; if (waitLoopIterationCount > 0 && @@ -2103,11 +2101,10 @@ namespace Game { Shared::Platform::Window::handleEvent(); } - if (logger.getCancelLoading() == true) { + if (logger.getCancelLoading()) { Lang &lang = Lang::getInstance(); const vector languageList = this->gameSettings.getUniqueNetworkPlayerLanguages(); for (unsigned int langIndex = 0; langIndex < languageList.size(); ++langIndex) { - string sErr = lang.getString("GameCancelledByUser", languageList[langIndex]); bool localEcho = lang.isLanguageLocal(languageList[langIndex]); sendTextMessage(sErr, -1, localEcho, languageList[langIndex]); diff --git a/source/game/types/faction_type.cpp b/source/game/types/faction_type.cpp index 23389e32b..c8816d3e9 100644 --- a/source/game/types/faction_type.cpp +++ b/source/game/types/faction_type.cpp @@ -79,9 +79,8 @@ namespace Game { //printf("\n>>> factionname=%s\n",factionName.c_str()); for (bool realFactionPathFound = false; realFactionPathFound == false;) { - if (logger.getCancelLoading()) { + if (logger.getCancelLoading()) return; - } currentPath = techTreePath + "factions/" + factionName; endPathWithSlash(currentPath); diff --git a/source/game/types/tech_tree.cpp b/source/game/types/tech_tree.cpp index ac35006ef..35f11d59b 100644 --- a/source/game/types/tech_tree.cpp +++ b/source/game/types/tech_tree.cpp @@ -251,7 +251,11 @@ namespace Game { snprintf(szBuf, 8096, Lang::getInstance().getString("LogScreenGameLoadingTechtree", "").c_str(), formatString(getName(true)).c_str()); - Logger::getInstance().add(szBuf, true); + + Logger & logger = Logger::getInstance(); + logger.add(szBuf, true); + if (logger.getCancelLoading()) + return; vector < string > filenames; //load resources @@ -262,6 +266,9 @@ namespace Game { resourceTypes.resize(filenames.size()); for (int i = 0; i < (int) filenames.size(); ++i) { + if (logger.getCancelLoading()) + return; + str = currentPath + "resources/" + filenames[i]; resourceTypes[i].load(str, checksum, &checksumValue, loadedFileList, treePath); @@ -298,6 +305,8 @@ namespace Game { sleep(0); Window::handleEvent(); SDL_PumpEvents(); + if (logger.getCancelLoading()) + return; //load tech tree xml info try { @@ -329,6 +338,8 @@ namespace Game { techTreeNode->getChild("attack-types"); attackTypes.resize(attackTypesNode->getChildCount()); for (int i = 0; i < (int) attackTypes.size(); ++i) { + if (logger.getCancelLoading()) + return; const XmlNode *attackTypeNode = attackTypesNode->getChild("attack-type", i); attackTypes[i].setName(attackTypeNode->getAttribute("name")-> @@ -348,6 +359,9 @@ namespace Game { techTreeNode->getChild("armor-types"); armorTypes.resize(armorTypesNode->getChildCount()); for (int i = 0; i < (int) armorTypes.size(); ++i) { + if (logger.getCancelLoading()) + return; + const XmlNode *armorTypeNode = armorTypesNode->getChild("armor-type", i); armorTypes[i].setName(armorTypeNode->getAttribute("name")-> @@ -365,6 +379,9 @@ namespace Game { techTreeNode->getChild("damage-multipliers"); for (int i = 0; i < (int) damageMultipliersNode->getChildCount(); ++i) { + if (logger.getCancelLoading()) + return; + const XmlNode *damageMultiplierNode = damageMultipliersNode->getChild("damage-multiplier", i); const AttackType *attackType = @@ -424,10 +441,10 @@ namespace Game { getTranslatedFactionName(name, factionName)). c_str()); - Logger & logger = Logger::getInstance(); + if (logger.getCancelLoading()) + return; logger.setState(szBuf); - logger. - setProgress((int) + logger.setProgress((int) ((((double) i) / (double) factions.size()) * 100.0)); diff --git a/source/game/world/world.cpp b/source/game/world/world.cpp index 94ba41416..5edcfa3a7 100644 --- a/source/game/world/world.cpp +++ b/source/game/world/world.cpp @@ -479,7 +479,11 @@ namespace Game { endPathWithSlash(currentPath); string path = currentPath + lastDir(currentPath) + ".xml"; const XmlNode *techTreeNode = xmlTree.getRootNode(); - if (scriptManager) scriptManager->init(this, this->getGame()->getGameCameraPtr(), techTreeNode); + if (scriptManager && !Logger::getInstance().getCancelLoading()) { + Game* game = getGame(); + if (game != NULL) + scriptManager->init(this, game->getGameCameraPtr(), techTreeNode); + } return techtreeChecksum; } @@ -530,11 +534,13 @@ namespace Game { } void World::updateAllTilesetObjects() { - Gui *gui = this->game->getGuiPtr(); - if (gui != NULL) { - Object *selObj = gui->getHighlightedResourceObject(); - if (selObj != NULL) { - selObj->updateHighlight(); + if (game != NULL) { + Gui *gui = this->game->getGuiPtr(); + if (gui != NULL) { + Object *selObj = gui->getHighlightedResourceObject(); + if (selObj != NULL) { + selObj->updateHighlight(); + } } }