mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
replace Server smart pointer with conventional one to gain control over dtor call order
This commit is contained in:
parent
2bdff11d54
commit
cd27c8ef5d
22
src/game.cpp
22
src/game.cpp
@ -992,6 +992,9 @@ void the_game(
|
|||||||
sound_is_dummy = true;
|
sound_is_dummy = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Server *server = NULL;
|
||||||
|
|
||||||
|
try{
|
||||||
// Event manager
|
// Event manager
|
||||||
EventManager eventmgr;
|
EventManager eventmgr;
|
||||||
|
|
||||||
@ -1007,9 +1010,8 @@ void the_game(
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Create server.
|
Create server.
|
||||||
SharedPtr will delete it when it goes out of scope.
|
|
||||||
*/
|
*/
|
||||||
SharedPtr<Server> server;
|
|
||||||
if(address == ""){
|
if(address == ""){
|
||||||
draw_load_screen(L"Creating server...", driver, font);
|
draw_load_screen(L"Creating server...", driver, font);
|
||||||
infostream<<"Creating server"<<std::endl;
|
infostream<<"Creating server"<<std::endl;
|
||||||
@ -1018,7 +1020,6 @@ void the_game(
|
|||||||
server->start(port);
|
server->start(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
|
||||||
do{ // Client scope (breakable do-while(0))
|
do{ // Client scope (breakable do-while(0))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3290,10 +3291,25 @@ void the_game(
|
|||||||
L" running a different version of Minetest.";
|
L" running a different version of Minetest.";
|
||||||
errorstream<<wide_to_narrow(error_message)<<std::endl;
|
errorstream<<wide_to_narrow(error_message)<<std::endl;
|
||||||
}
|
}
|
||||||
|
catch(ServerError &e)
|
||||||
|
{
|
||||||
|
error_message = narrow_to_wide(e.what());
|
||||||
|
errorstream<<wide_to_narrow(error_message)<<std::endl;
|
||||||
|
}
|
||||||
|
catch(ModError &e)
|
||||||
|
{
|
||||||
|
errorstream<<e.what()<<std::endl;
|
||||||
|
error_message = narrow_to_wide(e.what()) + wgettext("\nCheck debug.txt for details.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(!sound_is_dummy)
|
if(!sound_is_dummy)
|
||||||
delete sound;
|
delete sound;
|
||||||
|
|
||||||
|
//has to be deleted first to stop all server threads
|
||||||
|
delete server;
|
||||||
|
|
||||||
delete tsrc;
|
delete tsrc;
|
||||||
delete shsrc;
|
delete shsrc;
|
||||||
delete nodedef;
|
delete nodedef;
|
||||||
|
10
src/main.cpp
10
src/main.cpp
@ -1902,16 +1902,6 @@ int main(int argc, char *argv[])
|
|||||||
error_message = wgettext("Connection error (timed out?)");
|
error_message = wgettext("Connection error (timed out?)");
|
||||||
errorstream<<wide_to_narrow(error_message)<<std::endl;
|
errorstream<<wide_to_narrow(error_message)<<std::endl;
|
||||||
}
|
}
|
||||||
catch(ServerError &e)
|
|
||||||
{
|
|
||||||
error_message = narrow_to_wide(e.what());
|
|
||||||
errorstream<<wide_to_narrow(error_message)<<std::endl;
|
|
||||||
}
|
|
||||||
catch(ModError &e)
|
|
||||||
{
|
|
||||||
errorstream<<e.what()<<std::endl;
|
|
||||||
error_message = narrow_to_wide(e.what()) + wgettext("\nCheck debug.txt for details.");
|
|
||||||
}
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user