forked from teamnwah/openmw-tes3coop
[Server] Log all exceptions
This commit is contained in:
parent
51b95f35cd
commit
7b98f9f7ff
1 changed files with 60 additions and 29 deletions
|
@ -247,8 +247,7 @@ int main(int argc, char *argv[])
|
|||
setenv("LUA_CPATH", Utils::convertPath(plugin_home + "/lib/?.so").c_str(), 1);
|
||||
#endif
|
||||
|
||||
for (auto plugin : plugins)
|
||||
Script::LoadScript(plugin.c_str(), plugin_home.c_str());
|
||||
int code;
|
||||
|
||||
RakNet::RakPeerInterface *peer = RakNet::RakPeerInterface::GetInstance();
|
||||
|
||||
|
@ -265,8 +264,33 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
RakNet::SocketDescriptor sd((unsigned short) port, addr.c_str());
|
||||
if (peer->Startup((unsigned)players, &sd, 1) != RakNet::RAKNET_STARTED)
|
||||
return 1;
|
||||
|
||||
try
|
||||
{
|
||||
for (auto plugin : plugins)
|
||||
Script::LoadScript(plugin.c_str(), plugin_home.c_str());
|
||||
|
||||
switch (peer->Startup((unsigned) players, &sd, 1))
|
||||
{
|
||||
case RakNet::RAKNET_STARTED:
|
||||
break;
|
||||
case RakNet::RAKNET_ALREADY_STARTED:
|
||||
throw runtime_error("Already started");
|
||||
case RakNet::INVALID_SOCKET_DESCRIPTORS:
|
||||
throw runtime_error("Incorrect port or address");
|
||||
case RakNet::INVALID_MAX_CONNECTIONS:
|
||||
throw runtime_error("Max players cannot be negative or 0");
|
||||
case RakNet::SOCKET_FAILED_TO_BIND:
|
||||
case RakNet::SOCKET_PORT_ALREADY_IN_USE:
|
||||
case RakNet::PORT_CANNOT_BE_ZERO:
|
||||
throw runtime_error("Failed to bind port");
|
||||
case RakNet::SOCKET_FAILED_TEST_SEND:
|
||||
case RakNet::SOCKET_FAMILY_NOT_SUPPORTED:
|
||||
case RakNet::FAILED_TO_CREATE_NETWORK_THREAD:
|
||||
case RakNet::COULD_NOT_GENERATE_GUID:
|
||||
case RakNet::STARTUP_OTHER_FAILURE:
|
||||
throw runtime_error("Cannot start server");
|
||||
}
|
||||
|
||||
peer->SetMaximumIncomingConnections((unsigned short) (players));
|
||||
|
||||
|
@ -292,11 +316,17 @@ int main(int argc, char *argv[])
|
|||
|
||||
networking.postInit();
|
||||
|
||||
int code = networking.mainLoop();
|
||||
|
||||
RakNet::RakPeerInterface::DestroyInstance(peer);
|
||||
code = networking.mainLoop();
|
||||
|
||||
networking.getMasterClient()->Stop();
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, e.what());
|
||||
throw; //fall through
|
||||
}
|
||||
|
||||
RakNet::RakPeerInterface::DestroyInstance(peer);
|
||||
|
||||
if (code == 0)
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Quitting peacefully.");
|
||||
|
@ -308,6 +338,7 @@ int main(int argc, char *argv[])
|
|||
std::cerr.rdbuf(cerr_rdbuf);
|
||||
}
|
||||
|
||||
|
||||
breakpad_close();
|
||||
return code;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue