Skip to content

Commit

Permalink
add field of online player, enums
Browse files Browse the repository at this point in the history
  • Loading branch information
fienestar committed Nov 27, 2024
1 parent f6b2bbb commit b0ad891
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
38 changes: 30 additions & 8 deletions src/game_api/online.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,38 @@
#include <cstdint> // for uint32_t, uint8_t, int8_t, int32_t
#include <string> // 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?
};
Expand Down
11 changes: 10 additions & 1 deletion src/game_api/script/usertypes/state_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,21 @@ void register_usertypes(sol::state& lua)
/// Used in Online
lua.new_usertype<OnlinePlayer>(
"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>(
"OnlineLobby",
Expand Down

0 comments on commit b0ad891

Please sign in to comment.