diff --git a/src/game_api/online.hpp b/src/game_api/online.hpp index 5e4b9cd8a..1d26f8a6b 100644 --- a/src/game_api/online.hpp +++ b/src/game_api/online.hpp @@ -4,16 +4,38 @@ #include // for uint32_t, uint8_t, int8_t, int32_t #include // for string +enum class GAME_MODE : uint8_t +{ + COOP = 1, + ARENA = 2 +}; + +enum class READY_STATE : uint8_t +{ + NOT_READY = 0, + READY = 1, + SEARCHING = 2 +}; + +enum class PLATFORM : uint8_t +{ + NONE = 16, + DISCORD = 17, + STEAM = 18, + XBOX = 19, + SWITCH = 32, + PLAYSTATION = 48 +}; + struct OnlinePlayer { - uint8_t unknown39; - uint8_t padding[3]; - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - uint32_t unknown4; - uint8_t unknown5; - uint8_t ready_state; + uint8_t player_name_length; + uint8_t padding1[7]; + uint64_t id; + GAME_MODE game_mode; + uint8_t padding2[4]; + READY_STATE ready_state : 2; + PLATFORM platform : 6; uint8_t character; char player_name[33]; // could be 32 actually? }; diff --git a/src/game_api/script/usertypes/state_lua.cpp b/src/game_api/script/usertypes/state_lua.cpp index d99677bff..fb481f138 100644 --- a/src/game_api/script/usertypes/state_lua.cpp +++ b/src/game_api/script/usertypes/state_lua.cpp @@ -510,12 +510,21 @@ void register_usertypes(sol::state& lua) /// Used in Online lua.new_usertype( "OnlinePlayer", + "game_mode", + sol::readonly(&OnlinePlayer::game_mode), + "platform", + sol::property([](OnlinePlayer& op) -> PLATFORM + { return op.platform; }), "ready_state", - sol::readonly(&OnlinePlayer::ready_state), + sol::property([](OnlinePlayer& op) -> READY_STATE + { return op.ready_state; }), "character", &OnlinePlayer::character, "player_name", sol::readonly(&OnlinePlayer::player_name)); + lua.create_named_table("GAME_MODE", "COOP", GAME_MODE::COOP, "ARENA", GAME_MODE::ARENA); + lua.create_named_table("PLATFORM", "NONE", PLATFORM::NONE, "DISCORD", PLATFORM::DISCORD, "STEAM", PLATFORM::STEAM, "XBOX", PLATFORM::XBOX, "SWITCH", PLATFORM::SWITCH, "PLAYSTATION", PLATFORM::PLAYSTATION); + lua.create_named_table("READY_STATE", "NOT_READY", READY_STATE::NOT_READY, "READY", READY_STATE::READY, "SEARCHING", READY_STATE::SEARCHING); /// Used in Online lua.new_usertype( "OnlineLobby",