server: 0006-feature-messages
TICKET-170: Capability / Appearance / Dialogue as real messages (0x40-0x42), sender stamped from the connection, appearance replayed in the join snapshot. Replayed from Tools/YGOLegacy/patches/0006-feature-messages.patch in the Unity repo. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
d84fab84ed
commit
00a715f181
7 files changed
+218
-2
No files matched your search
@@ -193,6 +193,40 @@ struct STOC_HS_WatchChange {
|
||||
check_trivially_copyable(STOC_HS_WatchChange);
|
||||
static_assert(sizeof(STOC_HS_WatchChange) == 2, "size mismatch: STOC_HS_WatchChange");
|
||||
|
||||
// YGOL feature messages: fixed-size payloads; the STOC form is uint16_t player_type + the same bytes
|
||||
#pragma pack(push, 1)
|
||||
struct CTOS_Capability {
|
||||
uint16_t protocol{};
|
||||
uint32_t flags{};
|
||||
};
|
||||
struct CTOS_Appearance {
|
||||
int32_t items[8]{};
|
||||
uint16_t deck_name[48]{};
|
||||
uint16_t character_id[64]{};
|
||||
uint16_t deck_group[48]{};
|
||||
};
|
||||
struct CTOS_Dialogue {
|
||||
uint8_t version{};
|
||||
uint8_t flags{};
|
||||
int16_t index{};
|
||||
uint32_t card_code{};
|
||||
uint32_t target_code{};
|
||||
uint16_t corpus_key[48]{};
|
||||
uint16_t event_key[48]{};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
check_trivially_copyable(CTOS_Capability);
|
||||
static_assert(sizeof(CTOS_Capability) == 6, "size mismatch: CTOS_Capability");
|
||||
check_trivially_copyable(CTOS_Appearance);
|
||||
static_assert(sizeof(CTOS_Appearance) == 352, "size mismatch: CTOS_Appearance");
|
||||
check_trivially_copyable(CTOS_Dialogue);
|
||||
static_assert(sizeof(CTOS_Dialogue) == 204, "size mismatch: CTOS_Dialogue");
|
||||
constexpr int SIZE_STOC_FEATURE = sizeof(uint16_t) + sizeof(CTOS_Appearance);
|
||||
constexpr uint16_t FEATURE_PROTOCOL = 1;
|
||||
constexpr uint32_t FEATURE_APPEARANCE = 0x1;
|
||||
constexpr uint32_t FEATURE_DIALOGUE = 0x2;
|
||||
constexpr uint16_t FEATURE_SENDER_SERVER = 0xff;
|
||||
|
||||
class DuelMode;
|
||||
|
||||
struct DuelPlayer {
|
||||
@@ -201,6 +235,8 @@ struct DuelPlayer {
|
||||
uint8_t type{};
|
||||
uint8_t state{};
|
||||
bufferevent* bev{};
|
||||
bool has_capability{}; // YGOL feature messages
|
||||
CTOS_Capability capability{};
|
||||
};
|
||||
|
||||
inline unsigned int GetPosition(unsigned char* qbuf, size_t offset) {
|
||||
@@ -214,6 +250,10 @@ public:
|
||||
DuelMode() = default;
|
||||
virtual ~DuelMode() = default;
|
||||
virtual void Chat(DuelPlayer* dp, unsigned char* pdata, int len) = 0;
|
||||
// YGOL feature messages
|
||||
virtual void Capability(DuelPlayer* dp, unsigned char* pdata, int len) = 0;
|
||||
virtual void Appearance(DuelPlayer* dp, unsigned char* pdata, int len) = 0;
|
||||
virtual void Dialogue(DuelPlayer* dp, unsigned char* pdata, int len) = 0;
|
||||
virtual void JoinGame(DuelPlayer* dp, unsigned char* pdata, bool is_creater) = 0;
|
||||
virtual void LeaveGame(DuelPlayer* dp) = 0;
|
||||
virtual void ToDuelist(DuelPlayer* dp) = 0;
|
||||
@@ -281,6 +321,13 @@ public:
|
||||
#define CTOS_HS_KICK 0x24 // CTOS_Kick
|
||||
#define CTOS_HS_START 0x25 // no data
|
||||
#define CTOS_REQUEST_FIELD 0x30
|
||||
// YGOL feature messages
|
||||
#define CTOS_CAPABILITY 0x40 // CTOS_Capability
|
||||
#define CTOS_APPEARANCE 0x41 // CTOS_Appearance
|
||||
#define CTOS_DIALOGUE 0x42 // CTOS_Dialogue
|
||||
inline bool IsFeatureMessage(unsigned char pktType) {
|
||||
return pktType == CTOS_CAPABILITY || pktType == CTOS_APPEARANCE || pktType == CTOS_DIALOGUE;
|
||||
}
|
||||
|
||||
#define STOC_GAME_MSG 0x1 // byte array
|
||||
#define STOC_ERROR_MSG 0x2 // STOC_ErrorMsg
|
||||
@@ -306,6 +353,10 @@ public:
|
||||
#define STOC_TEAMMATE_SURRENDER 0x23 // no data
|
||||
#define STOC_FIELD_FINISH 0x30
|
||||
#define STOC_SRVPRO_ROOMLIST 0x31
|
||||
// YGOL feature messages: uint16_t player_type + the CTOS payload
|
||||
#define STOC_CAPABILITY 0x40 // uint16_t + CTOS_Capability
|
||||
#define STOC_APPEARANCE 0x41 // uint16_t + CTOS_Appearance
|
||||
#define STOC_DIALOGUE 0x42 // uint16_t + CTOS_Dialogue
|
||||
|
||||
// STOC_GAME_MSG header
|
||||
#define MSG_WAITING 3
|
||||
|
||||
Reference in new issue
Block a user