server: 0002-tag-duel-shared-team-hand
Tag duel: teammates share one visible hand. Server tree, gframe/tag_duel.cpp. Replayed from Tools/YGOLegacy/patches/0002-tag-duel-shared-team-hand.patch in the Unity repo. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
da27435cdb
commit
e6d3ec30d0
1 file changed
+72
-32
+72
-32
@@ -761,6 +761,7 @@ void TagDuel::Surrender(DuelPlayer* dp) {
|
||||
int TagDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
|
||||
unsigned char* offset, *pbufw, *pbuf = msgbuffer;
|
||||
int player, count, type;
|
||||
int tp = 0; // [YGOL] first index of a team's player pair (0 or 2)
|
||||
while (pbuf - msgbuffer < (int)len) {
|
||||
offset = pbuf;
|
||||
unsigned char engType = BufferIO::Read<uint8_t>(pbuf);
|
||||
@@ -1086,15 +1087,19 @@ int TagDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
|
||||
case MSG_SHUFFLE_HAND: {
|
||||
player = BufferIO::Read<uint8_t>(pbuf);
|
||||
count = BufferIO::Read<uint8_t>(pbuf);
|
||||
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, (pbuf - offset) + count * 4);
|
||||
// [YGOL] shared team hand: both teammates get the real card codes.
|
||||
tp = (player == 0) ? 0 : 2;
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, offset, (pbuf - offset) + count * 4);
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, offset, (pbuf - offset) + count * 4);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
NetServer::ReSendToPlayer(replay_recorder);
|
||||
#endif
|
||||
for(int i = 0; i < count; ++i)
|
||||
BufferIO::Write<int32_t>(pbuf, 0);
|
||||
for(int i = 0; i < 4; ++i)
|
||||
if(players[i] != cur_player[player])
|
||||
NetServer::SendBufferToPlayer(players[i], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
// [YGOL] the masked copy goes to the OTHER team only.
|
||||
tp = 2 - tp;
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
|
||||
NetServer::ReSendToPlayer(*oit);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
@@ -1106,15 +1111,19 @@ int TagDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
|
||||
case MSG_SHUFFLE_EXTRA: {
|
||||
player = BufferIO::Read<uint8_t>(pbuf);
|
||||
count = BufferIO::Read<uint8_t>(pbuf);
|
||||
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, (pbuf - offset) + count * 4);
|
||||
// [YGOL] shared team hand: both teammates get the real card codes.
|
||||
tp = (player == 0) ? 0 : 2;
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, offset, (pbuf - offset) + count * 4);
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, offset, (pbuf - offset) + count * 4);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
NetServer::ReSendToPlayer(replay_recorder);
|
||||
#endif
|
||||
for(int i = 0; i < count; ++i)
|
||||
BufferIO::Write<int32_t>(pbuf, 0);
|
||||
for(int i = 0; i < 4; ++i)
|
||||
if(players[i] != cur_player[player])
|
||||
NetServer::SendBufferToPlayer(players[i], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
// [YGOL] the masked copy goes to the OTHER team only.
|
||||
tp = 2 - tp;
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
|
||||
NetServer::ReSendToPlayer(*oit);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
@@ -1278,13 +1287,17 @@ int TagDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
|
||||
if (cl & LOCATION_ONFIELD)
|
||||
cp = NetServer::StripRevealFlag(pbufw, 8);
|
||||
pbuf += 16;
|
||||
NetServer::SendBufferToPlayer(cur_player[cc], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
// [YGOL] shared team hand: both teammates see the moved card.
|
||||
tp = (cc == 0) ? 0 : 2;
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
if (!(cl & (LOCATION_GRAVE | LOCATION_OVERLAY))
|
||||
&& ((cl & (LOCATION_DECK | LOCATION_HAND)) || hide_code))
|
||||
BufferIO::Write<int32_t>(pbufw, 0);
|
||||
for(int i = 0; i < 4; ++i)
|
||||
if(players[i] != cur_player[cc])
|
||||
NetServer::SendBufferToPlayer(players[i], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
// [YGOL] the masked copy goes to the OTHER team only.
|
||||
tp = 2 - tp;
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
|
||||
NetServer::ReSendToPlayer(*oit);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
@@ -1612,7 +1625,10 @@ int TagDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
|
||||
count = BufferIO::Read<uint8_t>(pbuf);
|
||||
pbufw = pbuf;
|
||||
pbuf += count * 4;
|
||||
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
// [YGOL] shared team hand: both teammates see what was drawn.
|
||||
tp = (player == 0) ? 0 : 2;
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
NetServer::ReSendToPlayer(replay_recorder);
|
||||
#endif
|
||||
@@ -1622,9 +1638,10 @@ int TagDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
|
||||
else
|
||||
pbufw += 4;
|
||||
}
|
||||
for(int i = 0; i < 4; ++i)
|
||||
if(players[i] != cur_player[player])
|
||||
NetServer::SendBufferToPlayer(players[i], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
// [YGOL] the masked copy goes to the OTHER team only.
|
||||
tp = 2 - tp;
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
|
||||
NetServer::ReSendToPlayer(*oit);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
@@ -1937,7 +1954,10 @@ int TagDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
|
||||
int hcount = BufferIO::Read<uint8_t>(pbuf);
|
||||
pbufw = pbuf + 4;
|
||||
pbuf += hcount * 4 + ecount * 4 + 4;
|
||||
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
// [YGOL] shared team hand: the incoming hand is visible to both teammates.
|
||||
tp = (player == 0) ? 0 : 2;
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
for (int i = 0; i < hcount; ++i) {
|
||||
if(!(pbufw[3] & 0x80))
|
||||
BufferIO::Write<int32_t>(pbufw, 0);
|
||||
@@ -1950,9 +1970,10 @@ int TagDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
|
||||
else
|
||||
pbufw += 4;
|
||||
}
|
||||
for(int i = 0; i < 4; ++i)
|
||||
if(players[i] != cur_player[player])
|
||||
NetServer::SendBufferToPlayer(players[i], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
// [YGOL] the masked copy goes to the OTHER team only.
|
||||
tp = 2 - tp;
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, offset, pbuf - offset);
|
||||
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
|
||||
NetServer::ReSendToPlayer(*oit);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
@@ -2323,10 +2344,17 @@ void TagDuel::RefreshHand(int player, int flag, int use_cache)
|
||||
std::array<unsigned char, SIZE_QUERY_BUFFER> query_buffer;
|
||||
auto qbuf = query_buffer.data();
|
||||
auto len = WriteUpdateData(player, LOCATION_HAND, flag, qbuf, use_cache);
|
||||
// [YGOL] shared team hand: the REAL hand goes to both members of the team,
|
||||
// not just the teammate currently in control (cur_player[player]).
|
||||
int tp = (player == 0) ? 0 : 2;
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
if(!dp || dp == cur_player[player])
|
||||
if(!dp || dp == players[tp])
|
||||
#endif
|
||||
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, query_buffer.data(), len + 3);
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, query_buffer.data(), len + 3);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
if(!dp || dp == players[tp + 1])
|
||||
#endif
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, query_buffer.data(), len + 3);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
if(!dp)
|
||||
NetServer::ReSendToPlayer(replay_recorder);
|
||||
@@ -2342,12 +2370,16 @@ if(!dp || dp == cur_player[player])
|
||||
std::memset(qbuf, 0, slen - 4);
|
||||
qbuf += slen - 4;
|
||||
}
|
||||
for(int i = 0; i < 4; ++i)
|
||||
// [YGOL] the masked copy goes to the OTHER team only.
|
||||
tp = 2 - tp;
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
if(!dp || dp == players[i])
|
||||
if(!dp || dp == players[tp])
|
||||
#endif
|
||||
if(players[i] != cur_player[player])
|
||||
NetServer::SendBufferToPlayer(players[i], STOC_GAME_MSG, query_buffer.data(), len + 3);
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, query_buffer.data(), len + 3);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
if(!dp || dp == players[tp + 1])
|
||||
#endif
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, query_buffer.data(), len + 3);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
if(!dp)
|
||||
#endif
|
||||
@@ -2394,10 +2426,16 @@ void TagDuel::RefreshExtra(int player, int flag, int use_cache)
|
||||
std::array<unsigned char, SIZE_QUERY_BUFFER> query_buffer;
|
||||
auto qbuf = query_buffer.data();
|
||||
auto len = WriteUpdateData(player, LOCATION_EXTRA, flag, qbuf, use_cache);
|
||||
// [YGOL] shared team extra deck -- see RefreshHand.
|
||||
int tp = (player == 0) ? 0 : 2;
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
if(!dp || dp == cur_player[player])
|
||||
if(!dp || dp == players[tp])
|
||||
#endif
|
||||
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, query_buffer.data(), len + 3);
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, query_buffer.data(), len + 3);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
if(!dp || dp == players[tp + 1])
|
||||
#endif
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, query_buffer.data(), len + 3);
|
||||
#ifdef YGOPRO_SERVER_MODE
|
||||
if(!dp)
|
||||
NetServer::ReSendToPlayer(replay_recorder);
|
||||
@@ -2412,10 +2450,12 @@ if(!dp || dp == cur_player[player])
|
||||
memset(qbuf, 0, clen - 4);
|
||||
qbuf += clen - 4;
|
||||
}
|
||||
for(int i = 0; i < 4; ++i)
|
||||
if(!dp || dp == players[i])
|
||||
if(players[i] != cur_player[player])
|
||||
NetServer::SendBufferToPlayer(players[i], STOC_GAME_MSG, query_buffer.data(), len + 3);
|
||||
// [YGOL] the masked copy goes to the OTHER team only.
|
||||
tp = 2 - tp;
|
||||
if(!dp || dp == players[tp])
|
||||
NetServer::SendBufferToPlayer(players[tp], STOC_GAME_MSG, query_buffer.data(), len + 3);
|
||||
if(!dp || dp == players[tp + 1])
|
||||
NetServer::SendBufferToPlayer(players[tp + 1], STOC_GAME_MSG, query_buffer.data(), len + 3);
|
||||
if(!dp)
|
||||
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
|
||||
NetServer::ReSendToPlayer(*pit);
|
||||
|
||||
Reference in new issue
Block a user