Oi, basicamente eu estou acessando o SQL e pegando as linhas e enviado elas via socket do server para o cliente. Eu havia colocado essas linha como fixas ( inteiro na struct) mas é um pé no saco ter q ficar editando sempre quando eu for adicionar mais linhas no sql, então resolvi mudar para um vetor, mas estou com umas dúvidas para como serializar e depois deserializar a struct. Da para dar uma moral ai? valeu
Antes
{
int i = 0;
char szQuery[512];
SHOP packet;
ZeroMemory(&packet, sizeof(SHOP));
packet.size = sizeof(SHOP);
packet.code = PACKET_SEND_ITEM_GAME;
SQL::GetInstance()->EnterSqlSection();
.
.//cod não muda nada do objetivo que quero
.
Player->lpsmSock->Send((char*)&packet, packet.size, true);
SQL::GetInstance()->LeaveSqlSection();
}
struct SHOP
{
int size;
int code;
SHOP_ITEM item[88];
};
Agora
[code]
{
int i = 0;
char szQuery[512];
SHOP packet;
packet.size = sizeof(SHOP); //precisa mudar
packet.code = PACKET_SEND_ITEM_GAME;
SQL::GetInstance()->EnterSqlSection();
.
.
Player->lpsmSock->Send((char*)&packet, packet.size, true); //precisa mudar tmb
SQL::GetInstance()->LeaveSqlSection();
}
struct SHOP
{
int size;
int code;
std::vector<SHOP_ITEM> items;
SHOP() : size(0), code(0) { };
};