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
@@ -310,9 +310,9 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, size_t len
|
||||
auto pdata = data;
|
||||
unsigned char pktType = BufferIO::Read<uint8_t>(pdata);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
if((pktType != CTOS_SURRENDER) && (pktType != CTOS_CHAT) && (pktType != CTOS_REQUEST_FIELD) && (dp->state == 0xff || (dp->state && dp->state != pktType)))
|
||||
if((pktType != CTOS_SURRENDER) && (pktType != CTOS_CHAT) && (pktType != CTOS_REQUEST_FIELD) && !IsFeatureMessage(pktType) && (dp->state == 0xff || (dp->state && dp->state != pktType))) // YGOL feature messages: legal in every state, like chat
|
||||
#else
|
||||
if((pktType != CTOS_SURRENDER) && (pktType != CTOS_CHAT) && (dp->state == 0xff || (dp->state && dp->state != pktType)))
|
||||
if((pktType != CTOS_SURRENDER) && (pktType != CTOS_CHAT) && !IsFeatureMessage(pktType) && (dp->state == 0xff || (dp->state && dp->state != pktType)))
|
||||
#endif
|
||||
return;
|
||||
switch(pktType) {
|
||||
@@ -342,6 +342,31 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, size_t len
|
||||
duel_mode->Chat(dp, pdata, len - 1);
|
||||
break;
|
||||
}
|
||||
// YGOL feature messages: exact size or dropped, connection kept
|
||||
case CTOS_CAPABILITY: {
|
||||
if(!dp->game)
|
||||
return;
|
||||
if (len != 1 + sizeof(CTOS_Capability))
|
||||
return;
|
||||
duel_mode->Capability(dp, pdata, len - 1);
|
||||
break;
|
||||
}
|
||||
case CTOS_APPEARANCE: {
|
||||
if(!dp->game)
|
||||
return;
|
||||
if (len != 1 + sizeof(CTOS_Appearance))
|
||||
return;
|
||||
duel_mode->Appearance(dp, pdata, len - 1);
|
||||
break;
|
||||
}
|
||||
case CTOS_DIALOGUE: {
|
||||
if(!dp->game)
|
||||
return;
|
||||
if (len != 1 + sizeof(CTOS_Dialogue))
|
||||
return;
|
||||
duel_mode->Dialogue(dp, pdata, len - 1);
|
||||
break;
|
||||
}
|
||||
case CTOS_UPDATE_DECK: {
|
||||
if(!dp->game)
|
||||
return;
|
||||
@@ -525,5 +550,12 @@ size_t NetServer::CreateChatPacket(unsigned char* src, int src_size, unsigned ch
|
||||
pdst += src_size;
|
||||
return sizeof(dst_player_type) + src_size;
|
||||
}
|
||||
// YGOL feature messages: the sender is the connection, never the payload
|
||||
size_t NetServer::CreateStampedPacket(unsigned char* src, int src_size, unsigned char* dst, uint16_t dst_player_type) {
|
||||
auto pdst = dst;
|
||||
BufferIO::Write<uint16_t>(pdst, dst_player_type);
|
||||
std::memcpy(pdst, src, src_size);
|
||||
return sizeof(dst_player_type) + src_size;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user