aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2013-04-07 19:41:12 +0200
committerkwolekr <kwolekr@minetest.net>2013-04-07 22:42:36 -0400
commitcd27c8ef5df35edd2cc606291f3f7985a61d41d5 (patch)
treef417ea9e2f8efe7f263a9ce1bca25c11d8097bc5 /src
parent2bdff11d5472e4e5299c4e4e25e128b0869367a8 (diff)
downloadminetest-cd27c8ef5df35edd2cc606291f3f7985a61d41d5.tar.gz
minetest-cd27c8ef5df35edd2cc606291f3f7985a61d41d5.tar.bz2
minetest-cd27c8ef5df35edd2cc606291f3f7985a61d41d5.zip
replace Server smart pointer with conventional one to gain control over dtor call order
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp22
-rw-r--r--src/main.cpp10
2 files changed, 19 insertions, 13 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 65feb50bf..4f6eb472d 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -992,6 +992,9 @@ void the_game(
sound_is_dummy = true;
}
+ Server *server = NULL;
+
+ try{
// Event manager
EventManager eventmgr;
@@ -1007,9 +1010,8 @@ void the_game(
/*
Create server.
- SharedPtr will delete it when it goes out of scope.
*/
- SharedPtr<Server> server;
+
if(address == ""){
draw_load_screen(L"Creating server...", driver, font);
infostream<<"Creating server"<<std::endl;
@@ -1018,7 +1020,6 @@ void the_game(
server->start(port);
}
- try{
do{ // Client scope (breakable do-while(0))
/*
@@ -3290,10 +3291,25 @@ void the_game(
L" running a different version of Minetest.";
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)
delete sound;
+ //has to be deleted first to stop all server threads
+ delete server;
+
delete tsrc;
delete shsrc;
delete nodedef;
diff --git a/src/main.cpp b/src/main.cpp
index 08af6a37d..b0cabfe81 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1902,16 +1902,6 @@ int main(int argc, char *argv[])
error_message = wgettext("Connection error (timed out?)");
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
catch(std::exception &e)
{