server: 0011-host-seats-rules-restart
TICKET-285: the host plans every seat (Open / Cpu, 0x50), a bot claims its Cpu seat with a token before JoinGame (0x51), host swap 0x52 and move 0x53; capability bit 0x8, protocol 2. Replayed from Tools/YGOLegacy/patches/0011-host-seats-rules-restart.patch in the Unity repo. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
76e359f6cf
commit
9dbe0437f6
7 files changed
+615
-100
No files matched your search
@@ -306,6 +306,25 @@ void NetServer::DisconnectPlayer(DuelPlayer* dp) {
|
||||
users.erase(bit);
|
||||
}
|
||||
}
|
||||
// YGOL host seats: bufferevent_free drops unsent output, so a refusal is written out before the close
|
||||
void NetServer::DisconnectAfterFlush(DuelPlayer* dp) {
|
||||
if(!dp->bev) {
|
||||
DisconnectPlayer(dp);
|
||||
return;
|
||||
}
|
||||
dp->state = 0xff;
|
||||
bufferevent_disable(dp->bev, EV_READ);
|
||||
if(evbuffer_get_length(bufferevent_get_output(dp->bev)) == 0) {
|
||||
DisconnectPlayer(dp);
|
||||
return;
|
||||
}
|
||||
bufferevent_setcb(dp->bev, nullptr, FlushedDisconnect, ServerEchoEvent, nullptr);
|
||||
}
|
||||
void NetServer::FlushedDisconnect(bufferevent* bev, void* ctx) {
|
||||
auto user = users.find(bev);
|
||||
if(user != users.end())
|
||||
DisconnectPlayer(&user->second);
|
||||
}
|
||||
void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, size_t len) {
|
||||
auto pdata = data;
|
||||
unsigned char pktType = BufferIO::Read<uint8_t>(pdata);
|
||||
@@ -367,6 +386,40 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, size_t len
|
||||
duel_mode->Dialogue(dp, pdata, len - 1);
|
||||
break;
|
||||
}
|
||||
// YGOL host seats: exact size or dropped; the claim is the one message accepted BEFORE JoinGame
|
||||
case CTOS_SEAT_REQUEST: {
|
||||
if(dp->game)
|
||||
return;
|
||||
if (len != 1 + sizeof(CTOS_SeatRequest))
|
||||
return;
|
||||
std::memcpy(&dp->seat_request, pdata, sizeof dp->seat_request);
|
||||
dp->has_seat_request = true;
|
||||
break;
|
||||
}
|
||||
case CTOS_SEAT_PLAN: {
|
||||
if(!dp->game)
|
||||
return;
|
||||
if (len != 1 + sizeof(CTOS_SeatPlan))
|
||||
return;
|
||||
duel_mode->SeatPlan(dp, pdata, len - 1);
|
||||
break;
|
||||
}
|
||||
case CTOS_SEAT_SWAP: {
|
||||
if(!dp->game)
|
||||
return;
|
||||
if (len != 1 + sizeof(CTOS_SeatSwap))
|
||||
return;
|
||||
duel_mode->SeatSwap(dp, pdata, len - 1);
|
||||
break;
|
||||
}
|
||||
case CTOS_SEAT_MOVE: {
|
||||
if(!dp->game)
|
||||
return;
|
||||
if (len != 1 + sizeof(CTOS_SeatMove))
|
||||
return;
|
||||
duel_mode->SeatMove(dp, pdata, len - 1);
|
||||
break;
|
||||
}
|
||||
case CTOS_UPDATE_DECK: {
|
||||
if(!dp->game)
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user