game: Make sure the supervisor process doesn't die.

This commit is contained in:
Loïc Hoguin 2010-06-13 23:45:30 +02:00
parent 02983da6f7
commit 16bbe2e308

View File

@ -55,10 +55,14 @@ supervisor() ->
%% @doc Close the connection for the given user and cleanup. %% @doc Close the connection for the given user and cleanup.
supervisor_close(Pid) -> supervisor_close(Pid) ->
User = egs_db:users_select_by_pid(Pid), try
log(User#users.gid, "quit"), User = egs_db:users_select_by_pid(Pid),
lists:foreach(fun(Other) -> Other#users.pid ! {psu_player_unspawn, User} end, egs_db:users_select_others_in_area(User)), log(User#users.gid, "quit"),
egs_db:users_delete(User#users.gid). lists:foreach(fun(Other) -> Other#users.pid ! {psu_player_unspawn, User} end, egs_db:users_select_others_in_area(User)),
egs_db:users_delete(User#users.gid)
catch _:_ ->
ignore
end.
%% @doc Listen for connections. %% @doc Listen for connections.