Antes de tudo, não está completo, fiz de modo bem bruto pra ver se funciona !
Quem conseguir entender e souber o que está sendo feito de errado e otimizar o codigo deixando menor, compartilha com a gente :)
DATASERVER
DataServerProtocol.cpp
case 0x13:
switch(((lpMsg[0]==0xC1)?lpMsg[3]:lpMsg[4]))
{
case 0x31:
GSC((SC_INFO_D*)lpMsg, index);
break;
}
void GSC(SC_INFO_D* lpMsg, int index)
{
LogAdd(LOG_GREEN, "PACKET RECEBIDO GS -> DS [%s]", lpMsg->name);
SC_INFO_E pMsg;
pMsg.header.set(0x0F, 0x07, sizeof(pMsg));
if (gQueryManager->ExecQuery("SELECT * FROM Character WHERE Name='%s'", lpMsg->name) == 0 || gQueryManager->Fetch() == SQL_NO_DATA)
{
gQueryManager->Close();
}
else
{
pMsg.Reset = (WORD)gQueryManager->GetAsInteger("ResetCount");
pMsg.MReset = (BYTE)gQueryManager->GetAsInteger("MasterResetCount");
gQueryManager->Close();
}
LogAdd(LOG_GREEN, "PACKET ENVIADO %s - %d - %d", lpMsg->name, pMsg.Reset, pMsg.MReset);
gSocketManager->DataSend(index, (BYTE*)&pMsg, sizeof(pMsg));
}
DataServerProtocol.h
struct SC_INFO_D
{
PSBMSG_HEAD header;
char name[11];
};
struct SC_INFO_E
{
PSBMSG_HEAD header;
char name[11];
DWORD Reset;
DWORD MReset;
};
void GSC(SC_INFO_D* lpMsg, int index);
GAMESERVER
DSProtocol.cpp
case 0x0F:
switch(((lpMsg[0]==0xC1)?lpMsg[3]:lpMsg[4]))
{
case 0x07:
DSC((SC_INFO_F*)lpMsg,0);
break;
}
Protocol.cpp
case 0xF2:
SC((SC_INFO_B*)lpMsg, aIndex);
break;
void SC(SC_INFO_B* lpMsg, int aIndex)
{
//LogAdd(LOG_GREEN, "PACKET RECEBIDO MAIN -> CLIENTE [Char: %s]", lpMsg->name); // ENVIAR PRO DATASERVER PARA RETORNAR
SC_INFO_C pMsg;
pMsg.header.set(0x13, 0x31, sizeof(pMsg));
memcpy(pMsg.name, lpMsg->name, sizeof(pMsg.name));
gDataServerConnection.DataSend((BYTE*)&pMsg, sizeof(pMsg));
}
void DSC(SC_INFO_F* lpMsg, int aIndex)
{
LogAdd(LOG_GREEN, "PACKET RECEBIDO DS -> GS [Char: %s - Reset:%d - MReset - %d]", lpMsg->name, lpMsg->Reset, lpMsg->MReset); // ENVIAR PRO DATASERVER PARA RETORNAR
SC_INFO_G pMsg;
//
pMsg.header.set(0xF3, 0xF2, sizeof(pMsg));
pMsg.Reset = lpMsg->Reset;
pMsg.MReset = lpMsg->MReset;
DataSend(aIndex, (BYTE*)&pMsg, pMsg.header.size);
}
Protoco.h
struct SC_INFO_B
{
PSBMSG_HEAD header;
char name[11];
};
struct SC_INFO_C
{
PSBMSG_HEAD header;
char name[11];
};
struct SC_INFO_F
{
PSBMSG_HEAD header;
char name[11];
DWORD Reset;
DWORD MReset;
};
struct SC_INFO_G
{
PSBMSG_HEAD header;
char name[11];
DWORD Reset;
DWORD MReset;
};
MAIN
Protocol.cpp
case 0xF2:
GSC((PMSG_SC_H*)lpMsg);
return 0;
Protocol.h
struct PMSG_SC_A
{
PSBMSG_HEAD header;
DWORD Reset;
DWORD MasterReset;
};
struct PMSG_SC_H
{
PSBMSG_HEAD header;
DWORD Reset;
DWORD MasterReset;
};
struct SC_INFO_A {
PSBMSG_HEAD header;
char name[11];
};
struct SCData {
int SCViewReset;
int SCViewMReset;
};
void GSC(PMSG_SC_H* lpMsg);
void CSetInfo(float x, float Y, int Class) <-- Select PJ S13 1.04j
SC_INFO_A pMsg;
pMsg.header.set(0xF3, 0xF2, sizeof(pMsg));
memcpy(pMsg.name, (char*)m_szName, sizeof(pMsg.name));
DataSend((BYTE*)&pMsg, pMsg.header.size);
gInterface.AddText(X + 10, Y + 47, "%d/500", 0, dados[Class].SCViewReset, 0, 4, size);
gInterface.AddText(X + 10, Y + 57, "%d", 0, dados[Class].SCViewMReset, 0, 4, size);

Creditos: eu pela tentativa haha