Commit 6784a0ff authored by Chen Bill's avatar Chen Bill

TagDuel: use std vector

parent 32ac47c2
......@@ -1563,11 +1563,12 @@ inline unsigned int GetPosition(unsigned char*& qbuf, int offset) {
return info >> 24;
}
void TagDuel::RefreshMzone(int player, int flag, int use_cache) {
unsigned char query_buffer[0x4000];
auto qbuf = query_buffer;
std::vector<unsigned char> query_buffer;
query_buffer.resize(SIZE_QUERY_BUFFER);
auto qbuf = query_buffer.data();
auto len = WriteUpdateData(player, LOCATION_MZONE, flag, qbuf, use_cache);
int pid = (player == 0) ? 0 : 2;
NetServer::SendBufferToPlayer(players[pid], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[pid], STOC_GAME_MSG, query_buffer.data(), len + 3);
NetServer::ReSendToPlayer(players[pid + 1]);
int qlen = 0;
while(qlen < len) {
......@@ -1581,17 +1582,18 @@ void TagDuel::RefreshMzone(int player, int flag, int use_cache) {
qbuf += clen - 4;
}
pid = 2 - pid;
NetServer::SendBufferToPlayer(players[pid], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[pid], STOC_GAME_MSG, query_buffer.data(), len + 3);
NetServer::ReSendToPlayer(players[pid + 1]);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
}
void TagDuel::RefreshSzone(int player, int flag, int use_cache) {
unsigned char query_buffer[0x4000];
auto qbuf = query_buffer;
std::vector<unsigned char> query_buffer;
query_buffer.resize(SIZE_QUERY_BUFFER);
auto qbuf = query_buffer.data();
auto len = WriteUpdateData(player, LOCATION_SZONE, flag, qbuf, use_cache);
int pid = (player == 0) ? 0 : 2;
NetServer::SendBufferToPlayer(players[pid], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[pid], STOC_GAME_MSG, query_buffer.data(), len + 3);
NetServer::ReSendToPlayer(players[pid + 1]);
int qlen = 0;
while(qlen < len) {
......@@ -1605,16 +1607,17 @@ void TagDuel::RefreshSzone(int player, int flag, int use_cache) {
qbuf += clen - 4;
}
pid = 2 - pid;
NetServer::SendBufferToPlayer(players[pid], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[pid], STOC_GAME_MSG, query_buffer.data(), len + 3);
NetServer::ReSendToPlayer(players[pid + 1]);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
}
void TagDuel::RefreshHand(int player, int flag, int use_cache) {
unsigned char query_buffer[0x4000];
auto qbuf = query_buffer;
std::vector<unsigned char> query_buffer;
query_buffer.resize(SIZE_QUERY_BUFFER);
auto qbuf = query_buffer.data();
auto len = WriteUpdateData(player, LOCATION_HAND, flag, qbuf, use_cache);
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, query_buffer.data(), len + 3);
int qlen = 0;
while(qlen < len) {
int slen = BufferIO::ReadInt32(qbuf);
......@@ -1628,15 +1631,16 @@ void TagDuel::RefreshHand(int player, int flag, int use_cache) {
}
for(int i = 0; i < 4; ++i)
if(players[i] != cur_player[player])
NetServer::SendBufferToPlayer(players[i], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[i], STOC_GAME_MSG, query_buffer.data(), len + 3);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
}
void TagDuel::RefreshGrave(int player, int flag, int use_cache) {
unsigned char query_buffer[0x4000];
auto qbuf = query_buffer;
std::vector<unsigned char> query_buffer;
query_buffer.resize(SIZE_QUERY_BUFFER);
auto qbuf = query_buffer.data();
auto len = WriteUpdateData(player, LOCATION_GRAVE, flag, qbuf, use_cache);
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, query_buffer.data(), len + 3);
NetServer::ReSendToPlayer(players[1]);
NetServer::ReSendToPlayer(players[2]);
NetServer::ReSendToPlayer(players[3]);
......@@ -1644,10 +1648,11 @@ void TagDuel::RefreshGrave(int player, int flag, int use_cache) {
NetServer::ReSendToPlayer(*pit);
}
void TagDuel::RefreshExtra(int player, int flag, int use_cache) {
unsigned char query_buffer[0x4000];
auto qbuf = query_buffer;
std::vector<unsigned char> query_buffer;
query_buffer.resize(SIZE_QUERY_BUFFER);
auto qbuf = query_buffer.data();
auto len = WriteUpdateData(player, LOCATION_EXTRA, flag, qbuf, use_cache);
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, query_buffer.data(), len + 3);
}
void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) {
flag |= (QUERY_CODE | QUERY_POSITION);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment