1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

- Moved place bonus hero before normal random hero and starting hero placement -> same behaviour as in OH3

- Moved placing campaign heroes before random object generation -> same behaviour as in OH3
- Refactored pickHero into pickNextHeroType (hero generation sequence) and pickUnusedHeroTypeRandomly
- Added a SIGSEV violation handler to vcmiserver executable for logging stacktrace (for convenience only)
- Fixed Fuzzy.cpp and VCAI.h compilation on Clang
- Added a handleException function in addition to our macros (no use of macros, enables debugging support, does not re-throw, catches ...-case too)
This commit is contained in:
beegee1
2013-12-28 12:47:55 +00:00
parent 9ec299931d
commit b8eddcd9a8
6 changed files with 141 additions and 59 deletions

View File

@@ -32,6 +32,10 @@
#include "../lib/UnlockGuard.h"
#ifdef __GNUC__
#include <execinfo.h>
#endif
std::string NAME_AFFIX = "server";
std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX + ')'; //application name
using namespace boost;
@@ -531,8 +535,41 @@ static void handleCommandOptions(int argc, char *argv[])
po::notify(cmdLineOptions);
}
#ifdef __GNUC__
void handleLinuxSignal(int sig)
{
const int STACKTRACE_SIZE = 100;
void * buffer[STACKTRACE_SIZE];
int ptrCount = backtrace(buffer, STACKTRACE_SIZE);
char ** strings;
logGlobal->errorStream() << "Error: signal " << sig << ":";
strings = backtrace_symbols(buffer, ptrCount);
if(strings == nullptr)
{
logGlobal->errorStream() << "There are no symbols.";
}
else
{
for(int i = 0; i < ptrCount; ++i)
{
logGlobal->errorStream() << strings[i];
}
free(strings);
}
_exit(EXIT_FAILURE);
}
#endif
int main(int argc, char** argv)
{
// Installs a sig sev segmentation violation handler
// to log stacktrace
#ifdef __GNUC__
signal(SIGSEGV, handleLinuxSignal);
#endif
console = new CConsoleHandler;
CBasicLogConfigurator logConfig(VCMIDirs::get().userCachePath() + "/VCMI_Server_log.txt", console);
logConfig.configureDefault();
@@ -564,7 +601,11 @@ int main(int argc, char** argv)
{
logNetwork->errorStream() << e.what();
end2 = true;
}HANDLE_EXCEPTION
}
catch(...)
{
handleException();
}
}
catch(boost::system::system_error &e)
{