diff --git a/mk/windoze/vc2012/g2xml.vcxproj b/mk/windoze/vc2012/g2xml.vcxproj index c3f34ed6..753b7ecb 100644 --- a/mk/windoze/vc2012/g2xml.vcxproj +++ b/mk/windoze/vc2012/g2xml.vcxproj @@ -150,7 +150,7 @@ Level3 ProgramDatabase true - AdvancedVectorExtensions + StreamingSIMDExtensions2 true diff --git a/mk/windoze/vc2012/g3d_viewer.vcxproj b/mk/windoze/vc2012/g3d_viewer.vcxproj index 9333e6d3..9a0aa049 100644 --- a/mk/windoze/vc2012/g3d_viewer.vcxproj +++ b/mk/windoze/vc2012/g3d_viewer.vcxproj @@ -192,7 +192,7 @@ true Async MultiThreaded - AdvancedVectorExtensions + StreamingSIMDExtensions2 diff --git a/mk/windoze/vc2012/glest_editor.vcxproj b/mk/windoze/vc2012/glest_editor.vcxproj index 62424df6..1110d469 100644 --- a/mk/windoze/vc2012/glest_editor.vcxproj +++ b/mk/windoze/vc2012/glest_editor.vcxproj @@ -191,7 +191,7 @@ true Async MultiThreaded - AdvancedVectorExtensions + StreamingSIMDExtensions2 diff --git a/mk/windoze/vc2012/glest_game.vcxproj b/mk/windoze/vc2012/glest_game.vcxproj index a1b5d1cd..457a8c6c 100644 --- a/mk/windoze/vc2012/glest_game.vcxproj +++ b/mk/windoze/vc2012/glest_game.vcxproj @@ -259,7 +259,7 @@ Async MultiThreaded true - AdvancedVectorExtensions + StreamingSIMDExtensions2 Precise $(OutDir)$(TargetName).pdb Level3 diff --git a/mk/windoze/vc2012/megaglest_tests.vcxproj b/mk/windoze/vc2012/megaglest_tests.vcxproj index 270a9963..8599634f 100644 --- a/mk/windoze/vc2012/megaglest_tests.vcxproj +++ b/mk/windoze/vc2012/megaglest_tests.vcxproj @@ -168,7 +168,7 @@ ../../../source/shared_lib/include/graphics;../../../source/shared_lib/include/graphics/gl;../../../source/shared_lib/include/platform;../../../source/shared_lib/include/platform/win32;../../../source/shared_lib/include/sound;../../../source/shared_lib/include/util;../../../source/shared_lib/include/lua;../../../source/shared_lib/include/xml;../../../source/shared_lib/include/xml/rapidxml;../../../source/glest_game/ai;../../../source/glest_game/facilities;../../../source/glest_game/game;../../../source/glest_game/global;../../../source/glest_game/graphics;../../../source/glest_game/gui;../../../source/glest_game/main;../../../source/glest_game/menu;../../../source/glest_game/network;../../../source/glest_game/sound;../../../source/glest_game/type_instances;../../../source/glest_game/types;../../../source/glest_game/world;../../../source/windows_deps_2012/include;../../../source/windows_deps_2012/xerces-c-3.1.1/src;../../../source/windows_deps_2012/SDL-1.2.15/include;../../../source/shared_lib/include/platform/sdl;../../../source/shared_lib/include/sound/openal;../../../source/windows_deps_2012/openal-soft-1.14/include;../../../source/shared_lib/include/platform/posix;../../../source/shared_lib/include/platform/common;../../../source/windows_deps_2012/curl-7.21.3/include;../../../source/shared_lib/include/map;../../../source/windows_deps_2012/libircclient/include;../../../source/windows_deps_2012/glew-1.7.0/include;../../../source/windows_deps_2012/cppunit/include MultiThreaded Fast - AdvancedVectorExtensions + StreamingSIMDExtensions2 Console diff --git a/mk/windoze/vc2012/shared_lib.vcxproj b/mk/windoze/vc2012/shared_lib.vcxproj index b63ac2b8..f97ee03a 100644 --- a/mk/windoze/vc2012/shared_lib.vcxproj +++ b/mk/windoze/vc2012/shared_lib.vcxproj @@ -205,7 +205,7 @@ Async MultiThreaded true - AdvancedVectorExtensions + StreamingSIMDExtensions2 Precise true $(OutDir)$(ProjectName).pdb diff --git a/mk/windoze/vc2012/xml2g.vcxproj b/mk/windoze/vc2012/xml2g.vcxproj index c02781f2..55b46fb0 100644 --- a/mk/windoze/vc2012/xml2g.vcxproj +++ b/mk/windoze/vc2012/xml2g.vcxproj @@ -160,7 +160,7 @@ Level3 ProgramDatabase true - AdvancedVectorExtensions + StreamingSIMDExtensions2 wsock32.lib;libxml2_a.lib;%(AdditionalDependencies) diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index 866d95c9..6e6077cb 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -287,6 +287,7 @@ bool FactionThread::isSignalPathfinderCompleted(int frameIndex) { } void FactionThread::execute() { + string codeLocation = "1"; RunningStatusSafeWrapper runningStatus(this); try { //setRunningStatus(true); @@ -296,6 +297,7 @@ void FactionThread::execute() { bool minorDebugPerformance = false; Chrono chrono; + codeLocation = "2"; //unsigned int idx = 0; for(;this->faction != NULL;) { if(getQuitStatus() == true) { @@ -305,6 +307,7 @@ void FactionThread::execute() { semTaskSignalled.waitTillSignalled(); + codeLocation = "3"; //printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); static string masterSlaveOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); MasterSlaveThreadControllerSafeWrapper safeMasterController(masterController,20000,masterSlaveOwnerId); @@ -315,6 +318,7 @@ void FactionThread::execute() { break; } + codeLocation = "4"; static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); MutexSafeWrapper safeMutex(triggerIdMutex,mutexOwnerId); bool executeTask = (this->frameIndex.first >= 0); @@ -324,9 +328,11 @@ void FactionThread::execute() { safeMutex.ReleaseLock(); + codeLocation = "5"; //printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(executeTask == true) { + codeLocation = "6"; ExecutingTaskSafeWrapper safeExecutingTaskMutex(this); if(this->faction == NULL) { @@ -337,6 +343,7 @@ void FactionThread::execute() { throw megaglest_runtime_error("world == NULL"); } + codeLocation = "7"; //Config &config= Config::getInstance(); //bool sortedUnitsAllowed = config.getBool("AllowGroupedUnitCommands","true"); bool sortedUnitsAllowed = false; @@ -344,6 +351,7 @@ void FactionThread::execute() { this->faction->sortUnitsByCommandGroups(); } + codeLocation = "8"; static string mutexOwnerId2 = string(__FILE__) + string("_") + intToStr(__LINE__); MutexSafeWrapper safeMutex(faction->getUnitMutex(),mutexOwnerId2); @@ -352,22 +360,28 @@ void FactionThread::execute() { //printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + codeLocation = "9"; int unitCount = this->faction->getUnitCount(); for(int j = 0; j < unitCount; ++j) { + codeLocation = "10"; Unit *unit = this->faction->getUnit(j); if(unit == NULL) { throw megaglest_runtime_error("unit == NULL"); } + codeLocation = "11"; int64 elapsed1 = 0; if(minorDebugPerformance) elapsed1 = chrono.getMillis(); bool update = unit->needToUpdate(); + codeLocation = "12"; if(minorDebugPerformance && (chrono.getMillis() - elapsed1) >= 1) printf("Faction [%d - %s] #1-unit threaded updates on frame: %d for [%d] unit # %d, unitCount = %d, took [%lld] msecs\n",faction->getStartLocationIndex(),faction->getType()->getName(false).c_str(),currentTriggeredFrameIndex,faction->getUnitPathfindingListCount(),j,unitCount,(long long int)chrono.getMillis() - elapsed1); //update = true; - if(update == true) { + if(update == true) + { + codeLocation = "13"; if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) { int64 updateProgressValue = unit->getUpdateProgress(); int64 speed = unit->getCurrSkill()->getTotalSpeed(unit->getTotalUpgrade()); @@ -386,12 +400,14 @@ void FactionThread::execute() { if(world->getUnitUpdater() == NULL) { throw megaglest_runtime_error("world->getUnitUpdater() == NULL"); } - + codeLocation = "14"; world->getUnitUpdater()->updateUnitCommand(unit,currentTriggeredFrameIndex); + codeLocation = "15"; if(minorDebugPerformance && (chrono.getMillis() - elapsed2) >= 1) printf("Faction [%d - %s] #2-unit threaded updates on frame: %d for [%d] unit # %d, unitCount = %d, took [%lld] msecs\n",faction->getStartLocationIndex(),faction->getType()->getName(false).c_str(),currentTriggeredFrameIndex,faction->getUnitPathfindingListCount(),j,unitCount,(long long int)chrono.getMillis() - elapsed2); } else { + codeLocation = "16"; if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) { int64 updateProgressValue = unit->getUpdateProgress(); int64 speed = unit->getCurrSkill()->getTotalSpeed(unit->getTotalUpgrade()); @@ -406,12 +422,14 @@ void FactionThread::execute() { } } + codeLocation = "17"; if(minorDebugPerformance && chrono.getMillis() >= 1) printf("Faction [%d - %s] threaded updates on frame: %d for [%d] units took [%lld] msecs\n",faction->getStartLocationIndex(),faction->getType()->getName(false).c_str(),currentTriggeredFrameIndex,faction->getUnitPathfindingListCount(),(long long int)chrono.getMillis()); //printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); safeMutex.ReleaseLock(); + codeLocation = "18"; //printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); setTaskCompleted(currentTriggeredFrameIndex); @@ -421,6 +439,7 @@ void FactionThread::execute() { //printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + codeLocation = "19"; if(getQuitStatus() == true) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); break; @@ -433,14 +452,14 @@ void FactionThread::execute() { catch(const exception &ex) { //setRunningStatus(false); - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Loc [%s] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str(),ex.what()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); throw megaglest_runtime_error(ex.what()); } catch(...) { char szBuf[8096]=""; - snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error\n",__FILE__,__FUNCTION__,__LINE__); + snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error Loc [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); throw megaglest_runtime_error(szBuf); } diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 63c7efa1..9d23eeaf 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -302,6 +302,8 @@ bool UnitUpdater::updateUnit(Unit *unit) { //VERY IMPORTANT: compute next state depending on the first order of the list void UnitUpdater::updateUnitCommand(Unit *unit, int frameIndex) { + string codeLocation = "1"; + try { bool minorDebugPerformance = false; Chrono chrono; if((minorDebugPerformance == true && frameIndex > 0) || SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start(); @@ -309,31 +311,40 @@ void UnitUpdater::updateUnitCommand(Unit *unit, int frameIndex) { //if unit has command process it bool hasCommand = (unit->anyCommand()); + codeLocation = "2"; if((minorDebugPerformance && frameIndex > 0) && chrono.getMillis() >= 1) printf("UnitUpdate [%d - %s] #1-unit threaded updates on frame: %d took [%lld] msecs\n",unit->getId(),unit->getType()->getName(false).c_str(),frameIndex,(long long int)chrono.getMillis()); int64 elapsed1 = 0; if(minorDebugPerformance && frameIndex > 0) elapsed1 = chrono.getMillis(); if(hasCommand == true) { + codeLocation = "3"; if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit [%s] has command [%s]\n",__FILE__,__FUNCTION__,__LINE__,unit->toString(false).c_str(), unit->getCurrCommand()->toString(false).c_str()); bool commandUsesPathFinder = (frameIndex < 0); if(frameIndex > 0) { + codeLocation = "3a"; if(unit->getCurrCommand() != NULL && unit->getCurrCommand()->getCommandType() != NULL) { + codeLocation = "3b"; commandUsesPathFinder = unit->getCurrCommand()->getCommandType()->usesPathfinder(); // Clear previous cached unit data if(commandUsesPathFinder == true) { + codeLocation = "3c"; clearUnitPrecache(unit); } } } + codeLocation = "4"; if(commandUsesPathFinder == true) { + codeLocation = "4a"; if(unit->getCurrCommand() != NULL && unit->getCurrCommand()->getCommandType() != NULL) { + codeLocation = "4b"; unit->getCurrCommand()->getCommandType()->update(this, unit, frameIndex); } } + codeLocation = "5"; if((minorDebugPerformance && frameIndex > 0) && (chrono.getMillis() - elapsed1) >= 1) { //CommandClass cc = unit->getCurrCommand()->getCommandType()->commandTypeClass; printf("UnitUpdate [%d - %s] #2-unit threaded updates on frame: %d commandUsesPathFinder = %d took [%lld] msecs\nCommand: %s\n",unit->getId(),unit->getType()->getName(false).c_str(),frameIndex,commandUsesPathFinder,(long long int)chrono.getMillis() - elapsed1,unit->getCurrCommand()->toString(false).c_str()); @@ -343,21 +354,40 @@ void UnitUpdater::updateUnitCommand(Unit *unit, int frameIndex) { if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(frameIndex < 0) { + codeLocation = "6"; //if no commands stop and add stop command if(unit->anyCommand() == false && unit->isOperative()) { if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - + codeLocation = "6a"; if(unit->getType()->hasSkillClass(scStop)) { unit->setCurrSkill(scStop); } - + codeLocation = "6b"; if(unit->getType()->hasCommandClass(ccStop)) { unit->giveCommand(new Command(unit->getType()->getFirstCtOfClass(ccStop))); } } } + codeLocation = "7"; if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if((minorDebugPerformance && frameIndex > 0) && chrono.getMillis() >= 1) printf("UnitUpdate [%d - %s] #3-unit threaded updates on frame: %d took [%lld] msecs\n",unit->getId(),unit->getType()->getName(false).c_str(),frameIndex,(long long int)chrono.getMillis()); + + } + catch(const exception &ex) { + //setRunningStatus(false); + + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Loc [%s] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str(),ex.what()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + throw megaglest_runtime_error(ex.what()); + } + catch(...) { + char szBuf[8096]=""; + snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error Loc [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); + throw megaglest_runtime_error(szBuf); + } + } // ==================== updateStop ====================