egs_users: Remove broadcast_unspawn/2 in favor of broadcast/2.
This commit is contained in:
parent
823ee73e7d
commit
6e922a7ec9
@ -20,7 +20,7 @@
|
||||
-module(egs_users).
|
||||
-behaviour(gen_server).
|
||||
|
||||
-export([start_link/0, stop/0, broadcast_unspawn/2, broadcast/2, set_zone/3]). %% API.
|
||||
-export([start_link/0, stop/0, broadcast/2, set_zone/3]). %% API.
|
||||
-export([read/1, select/1, write/1, delete/1, item_nth/2, item_add/3, item_qty_add/3,
|
||||
shop_enter/2, shop_leave/1, shop_get/1, money_add/2]). %% Deprecated API.
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). %% gen_server.
|
||||
@ -44,9 +44,6 @@ start_link() ->
|
||||
stop() ->
|
||||
gen_server:call(?SERVER, stop).
|
||||
|
||||
broadcast_unspawn(GID, PlayersGID) ->
|
||||
gen_server:cast(?SERVER, {broadcast_unspawn, GID, PlayersGID}).
|
||||
|
||||
broadcast(Message, PlayersGID) ->
|
||||
gen_server:cast(?SERVER, {broadcast, Message, PlayersGID}).
|
||||
|
||||
@ -219,13 +216,6 @@ handle_call(stop, _From, State) ->
|
||||
handle_call(_Request, _From, State) ->
|
||||
{reply, ignored, State}.
|
||||
|
||||
handle_cast({broadcast_unspawn, GID, PlayersGID}, State) ->
|
||||
{GID, OrigUser} = lists:keyfind(GID, 1, State#stateu.users),
|
||||
[begin {_, #users{pid=DestPid}} = lists:keyfind(DestGID, 1, State#stateu.users),
|
||||
DestPid ! {egs, player_unspawn, OrigUser}
|
||||
end || DestGID <- PlayersGID],
|
||||
{noreply, State};
|
||||
|
||||
handle_cast({broadcast, Message, PlayersGID}, State) ->
|
||||
[begin {GID, #users{pid=Pid}} = lists:keyfind(GID, 1, State#stateu.users),
|
||||
Pid ! Message
|
||||
|
@ -82,10 +82,9 @@ handle_call({enter, GID}, _From, State) ->
|
||||
handle_call({leave, GID}, _From, State) ->
|
||||
{_, LID} = lists:keyfind(GID, 1, State#state.players),
|
||||
Players = lists:delete({GID, LID}, State#state.players),
|
||||
PlayersGID = players_gid(Players),
|
||||
FreeLIDs = State#state.freelids,
|
||||
egs_users:broadcast_unspawn(GID, PlayersGID),
|
||||
{reply, ok, State#state{players=Players, freelids=[LID|FreeLIDs]}};
|
||||
{ok, Spawn} = egs_users:read(GID),
|
||||
egs_users:broadcast({egs, player_unspawn, Spawn}, players_gid(Players)),
|
||||
{reply, ok, State#state{players=Players, freelids=[LID|State#state.freelids]}};
|
||||
|
||||
handle_call({get_all_players, ExcludeGID}, _From, State) ->
|
||||
{reply, lists:delete(ExcludeGID, players_gid(State#state.players)), State};
|
||||
|
Loading…
Reference in New Issue
Block a user