psu_proto: Review and move send_0225 to psu_proto.
This commit is contained in:
parent
f4bff9eaa1
commit
5f2ad649a5
@ -97,10 +97,6 @@ event({system_login_auth_request, Username, Password}, State=#state{socket=Socke
|
||||
|
||||
%% @doc MOTD request handler. Page number starts at 0.
|
||||
%% @todo Currently ignore the language and send the same MOTD file to everyone.
|
||||
event({system_motd_request, Page, _Language}, #state{socket=Socket}) ->
|
||||
{ok, File} = file:read_file("priv/psu_login/motd.txt"),
|
||||
Tokens = re:split(File, "\n."),
|
||||
MOTD = << << Line/binary, "\n", 0 >> || Line <- lists:sublist(Tokens, 1 + Page * 15, 15) >>,
|
||||
NbPages = 1 + length(Tokens) div 15,
|
||||
Packet = << 16#0225:16, 0:304, NbPages:8, Page:8, 16#8200:16/unsigned-integer, MOTD/binary, 0:16 >>,
|
||||
psu_proto:packet_send(Socket, Packet).
|
||||
event({system_motd_request, Page, _Language}, State) ->
|
||||
{ok, MOTD} = file:read_file("priv/psu_login/motd.txt"),
|
||||
psu_proto:send_0225(MOTD, Page, State).
|
||||
|
@ -1227,6 +1227,14 @@ send_0223(ErrorMsg, #state{socket=Socket, gid=DestGID}) ->
|
||||
Length = byte_size(ErrorMsg) div 2 + 2,
|
||||
packet_send(Socket, << 16#02230300:32, 0:160, 16#00000f00:32, DestGID:32/little, 0:128, 3:32/little, 0:48, Length:16/little, ErrorMsg/binary, 0:16 >>).
|
||||
|
||||
%% @doc Send a MOTD page.
|
||||
send_0225(MOTD, CurrentPage, #state{socket=Socket, lid=DestLID}) ->
|
||||
Tokens = re:split(MOTD, "\n."),
|
||||
Msg = << << Line/binary, "\n", 0 >> || Line <- lists:sublist(Tokens, 1 + CurrentPage * 15, 15) >>,
|
||||
NbPages = 1 + length(Tokens) div 15,
|
||||
Length = byte_size(Msg) div 2 + 2,
|
||||
packet_send(Socket, << 16#02250300:32, DestLID:16/little, 0:272, NbPages:8, CurrentPage:8, Length:16/little, Msg/binary, 0:16 >>).
|
||||
|
||||
%% @doc Forward the player to a website. The website will open when the player closes the game. Used for login issues mostly.
|
||||
send_0231(URL, #state{socket=Socket, gid=DestGID, lid=DestLID}) ->
|
||||
URLBin = list_to_binary(URL),
|
||||
|
Loading…
Reference in New Issue
Block a user