Edit on GitHub

LoginService Server Login Packet

Summary

This packet is sent by the PangYa server in a variety of circumstances, and has many different forms. The primary function of this packet is to provide a response to the client Login request packet.

The other roles this packet is used in are still fairly related. During first login, a user is sent this packet with status::need_set_nickname, which prompts the client to set a nickname. After that, the login packet is sent again with status::need_select_character. Finally, it is sent with the usual status::success once the character is selected.

When the server returns error_code::already_logged_in, the client then automatically sends LoginService Client 0x0004 Ghost to end the old session. This may happen, for example, if your last session was disconnected before you were able to log out or exit properly. If you are still connected, the server will instead return error_code::duplicate_connection.

In hsreina/pangya-server, the packet ID is TSLPID.LOGIN.

See Also: LoginService Client 0x0001 Login Packet

Structure

loginservice_server_0001_login

Name Type Summary
status u1 Status code; zero when the login was successful.
response switch(status)
case success login_success Case when status == success
case need_set_nickname login_need_set_nickname Case when status == need_set_nickname
case need_select_character login_need_select_character Case when status == need_select_character
case error login_error Case when status == error

Subtypes

login_success

Sent after a successful login.

Name Type Summary
username pstring Name used for authentication. The game typically enforces that this differ from your nickname.
user_id u4 User ID. Probably usually just the primary key in a database.
unknown bytes[14] Some unknown bytes; most of these are zeros.
nickname pstring The user's nickname. As a wrinkle, official servers seem to return an empty string for this after the first login process is completed, despite the fact that a nickname was set already.

login_need_set_nickname

Name Type Summary
unused bytes Appears to just be a constant, 0xff 0xff 0xff 0xff.

login_need_select_character

Name Type Summary
This structure does not have any fields of its own.

login_error

Name Type Summary
error_code u4 An error code. See the error_code enumeration for known possible values.

Enums

status

Key Value
status::success 0
status::need_set_nickname 217
status::need_select_character 218
status::error 227

error_code

Key Value
error_code::already_logged_in 5100019
error_code::duplicate_connection 5100107
error_code::invalid_credentials 5100143
error_code::bad_reconnect_token 5157002

Definition

meta:
  id: loginservice_server_0001_login
  title: LoginService Server Login Packet
  encoding: ASCII
  endian: le
  imports:
    - ../../common/pstring
seq:
  - id: status
    type: u1
    enum: status
  - id: response
    type:
      switch-on: status
      cases:
        status::success: login_success
        status::need_set_nickname: login_need_set_nickname
        status::need_select_character: login_need_select_character
        status::error: login_error
types:
  login_success:
    seq:
      - id: username
        type: pstring
      - id: user_id
        type: u4
      - id: unknown
        size: 14
      - id: nickname
        type: pstring
  login_need_set_nickname:
    seq:
      - id: unused
        contents:
          - 255
          - 255
          - 255
          - 255
  login_need_select_character:
    seq: []
  login_error:
    seq:
      - id: error_code
        type: u4
        enum: error_code
enums:
  status:
    0: success
    217: need_set_nickname
    218: need_select_character
    227: error
  error_code:
    5100019: already_logged_in
    5100107: duplicate_connection
    5100143: invalid_credentials
    5157002: bad_reconnect_token

Examples

Agent: TH.R6.829.01
00000000
01 00 e3 6f d2 4d 00
...o.M.
Agent: TH.R6.829.01
00000000
01 00 e3 f3 d1 4d 00
.....M.
Agent: TH.R6.829.01
00000000
01 00 d9 ff ff ff ff
.......
Agent: TH.R6.829.01
00000000
01 00 da
...
Agent: TH.R6.829.01
00000000 00000010
01 00 00 07 00 70 61 6e 67 62 6f 78 d2 c4 49 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00
.....pangbox..I. ....%...........