egs_users: Remove broadcast_spawn/2 in favor of broadcast/2.
This commit is contained in:
parent
40d2eed01b
commit
823ee73e7d
@ -20,7 +20,7 @@
|
|||||||
-module(egs_users).
|
-module(egs_users).
|
||||||
-behaviour(gen_server).
|
-behaviour(gen_server).
|
||||||
|
|
||||||
-export([start_link/0, stop/0, broadcast_spawn/2, broadcast_unspawn/2, broadcast/2, set_zone/3]). %% API.
|
-export([start_link/0, stop/0, broadcast_unspawn/2, 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,
|
-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.
|
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.
|
-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() ->
|
stop() ->
|
||||||
gen_server:call(?SERVER, stop).
|
gen_server:call(?SERVER, stop).
|
||||||
|
|
||||||
broadcast_spawn(GID, PlayersGID) ->
|
|
||||||
gen_server:cast(?SERVER, {broadcast_spawn, GID, PlayersGID}).
|
|
||||||
|
|
||||||
broadcast_unspawn(GID, PlayersGID) ->
|
broadcast_unspawn(GID, PlayersGID) ->
|
||||||
gen_server:cast(?SERVER, {broadcast_unspawn, GID, PlayersGID}).
|
gen_server:cast(?SERVER, {broadcast_unspawn, GID, PlayersGID}).
|
||||||
|
|
||||||
@ -222,13 +219,6 @@ handle_call(stop, _From, State) ->
|
|||||||
handle_call(_Request, _From, State) ->
|
handle_call(_Request, _From, State) ->
|
||||||
{reply, ignored, State}.
|
{reply, ignored, State}.
|
||||||
|
|
||||||
handle_cast({broadcast_spawn, 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_spawn, OrigUser}
|
|
||||||
end || DestGID <- PlayersGID],
|
|
||||||
{noreply, State};
|
|
||||||
|
|
||||||
handle_cast({broadcast_unspawn, GID, PlayersGID}, State) ->
|
handle_cast({broadcast_unspawn, GID, PlayersGID}, State) ->
|
||||||
{GID, OrigUser} = lists:keyfind(GID, 1, State#stateu.users),
|
{GID, OrigUser} = lists:keyfind(GID, 1, State#stateu.users),
|
||||||
[begin {_, #users{pid=DestPid}} = lists:keyfind(DestGID, 1, State#stateu.users),
|
[begin {_, #users{pid=DestPid}} = lists:keyfind(DestGID, 1, State#stateu.users),
|
||||||
|
@ -75,10 +75,9 @@ handle_call(setid, _From, State) ->
|
|||||||
handle_call({enter, GID}, _From, State) ->
|
handle_call({enter, GID}, _From, State) ->
|
||||||
[LID|FreeLIDs] = State#state.freelids,
|
[LID|FreeLIDs] = State#state.freelids,
|
||||||
egs_users:set_zone(GID, self(), LID),
|
egs_users:set_zone(GID, self(), LID),
|
||||||
Players = State#state.players,
|
{ok, Spawn} = egs_users:read(GID),
|
||||||
PlayersGID = players_gid(Players),
|
egs_users:broadcast({egs, player_spawn, Spawn}, players_gid(State#state.players)),
|
||||||
egs_users:broadcast_spawn(GID, PlayersGID),
|
{reply, LID, State#state{players=[{GID, LID}|State#state.players], freelids=FreeLIDs}};
|
||||||
{reply, LID, State#state{players=[{GID, LID}|Players], freelids=FreeLIDs}};
|
|
||||||
|
|
||||||
handle_call({leave, GID}, _From, State) ->
|
handle_call({leave, GID}, _From, State) ->
|
||||||
{_, LID} = lists:keyfind(GID, 1, State#state.players),
|
{_, LID} = lists:keyfind(GID, 1, State#state.players),
|
||||||
|
Loading…
Reference in New Issue
Block a user