Commit 74d53175 authored by Chen Bill's avatar Chen Bill

SingleDuel: use std vector

parent bbec144b
......@@ -1477,10 +1477,11 @@ inline unsigned int GetPosition(unsigned char*& qbuf, int offset) {
return info >> 24;
}
void SingleDuel::RefreshMzone(int player, int flag, int use_cache) {
unsigned char query_buffer[0x2000];
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);
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, query_buffer.data(), len + 3);
int qlen = 0;
while(qlen < len) {
const int clen = BufferIO::ReadInt32(qbuf);
......@@ -1492,15 +1493,16 @@ void SingleDuel::RefreshMzone(int player, int flag, int use_cache) {
memset(qbuf, 0, clen - 4);
qbuf += clen - 4;
}
NetServer::SendBufferToPlayer(players[1 - player], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[1 - player], STOC_GAME_MSG, query_buffer.data(), len + 3);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
}
void SingleDuel::RefreshSzone(int player, int flag, int use_cache) {
unsigned char query_buffer[0x2000];
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);
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, query_buffer.data(), len + 3);
int qlen = 0;
while(qlen < len) {
const int clen = BufferIO::ReadInt32(qbuf);
......@@ -1512,15 +1514,16 @@ void SingleDuel::RefreshSzone(int player, int flag, int use_cache) {
memset(qbuf, 0, clen - 4);
qbuf += clen - 4;
}
NetServer::SendBufferToPlayer(players[1 - player], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[1 - player], STOC_GAME_MSG, query_buffer.data(), len + 3);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
}
void SingleDuel::RefreshHand(int player, int flag, int use_cache) {
unsigned char query_buffer[0x2000];
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(players[player], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, query_buffer.data(), len + 3);
int qlen = 0;
while(qlen < len) {
const int slen = BufferIO::ReadInt32(qbuf);
......@@ -1532,28 +1535,30 @@ void SingleDuel::RefreshHand(int player, int flag, int use_cache) {
memset(qbuf, 0, slen - 4);
qbuf += slen - 4;
}
NetServer::SendBufferToPlayer(players[1 - player], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[1 - player], STOC_GAME_MSG, query_buffer.data(), len + 3);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
}
void SingleDuel::RefreshGrave(int player, int flag, int use_cache) {
unsigned char query_buffer[0x2000];
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]);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
}
void SingleDuel::RefreshExtra(int player, int flag, int use_cache) {
unsigned char query_buffer[0x2000];
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(players[player], STOC_GAME_MSG, query_buffer, len + 3);
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, query_buffer.data(), len + 3);
}
void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag) {
flag |= (QUERY_CODE | QUERY_POSITION);
unsigned char query_buffer[0x2000];
unsigned char query_buffer[0x1000];
auto qbuf = query_buffer;
BufferIO::WriteInt8(qbuf, MSG_UPDATE_CARD);
BufferIO::WriteInt8(qbuf, player);
......
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