this have been bothered me for a while and i know that i am not the only one who struggles to break this tough nut. The methodology of sending the Jump packets to clients is a pain in the ass as there are many things to be considered in order to implement a bug-free method of doing it.
Let's say that player X jumps(distance between them > max_view_distance before jump) near player Y(distance between them <= max_view_distance after jump), both packets for entity information are sent(
), however, it happens sometimes that either player X does not see player Y or viceversa/
Any thoughts how to fix this?
the method i am using right now is the one from the HybridCo source for client 5017:
Let's say that player X jumps(distance between them > max_view_distance before jump) near player Y(distance between them <= max_view_distance after jump), both packets for entity information are sent(
Code:
X->Send((EntityPacket)Y); Y->Send((EntityPacket)X);
Any thoughts how to fix this?
the method i am using right now is the one from the HybridCo source for client 5017:
Code:
void PlayerJump(CGameClient *Client, DataPacket *Ptr)
{
WORD X = LOWORD(Ptr->dwParam);
WORD Y = HIWORD(Ptr->dwParam);
if (Distance(X, Y, Client->Entity->X, Client->Entity->Y) > MAX_SCREEN_WIDTH)
{
Client->Socket->Disconnect();
return;
}
Client->Entity->X = X;
Client->Entity->Y = Y;
SendRangePacket(Ptr, Client->Entity, true);
LoadScreen(Client, NULL);
}
void SendRangePacket(void* Packet, IMapObject* mapObj, bool SendSelf, StdConquerCallback Callback, bool Delete)
{
CGameClient* Client;
CDatabaseRoot::Core->Clients->ObtainSyncHandle();
for (int i = 0; i < CDatabaseRoot::Core->Clients->Count; i++)
{
Client = CDatabaseRoot::Core->Clients->Elements[i];
if (Client->Entity->Map == mapObj->Map)
{
if (Distance(Client->Entity->X, Client->Entity->Y, mapObj->X, mapObj->Y) <= MAX_VIEW_DISTANCE)
{
if (Client->ID == mapObj->UID)
{
if (SendSelf)
{
Client->Send(Packet);
if (Callback != NULL)
Callback(mapObj, Client->Entity, NULL);
}
}
else
{
Client->Send(Packet);
if (Callback != NULL)
Callback(mapObj, Client->Entity, NULL);
}
}
}
}
CDatabaseRoot::Core->Clients->FreeSyncHandle();
if (Delete)
{
delete[] Packet;
}
}
void LoadScreen(CGameClient *Client, DataPacket *Ptr)
{
if (Ptr != NULL) // LoadScreen() Standerd
{
Client->Screen->Wipe();
Ptr->ID = DATA_ID_SET_MAP_COLOR;
Ptr->dwParam = 0xFFFFFFFF;
Client->Send(Ptr);
// <todo = weather>
// </todo>
}
else
{
Client->Screen->Cleanup();
}
// <Clients>
CDatabaseRoot::Core->Clients->ObtainSyncHandle();
for (int i = 0; i < CDatabaseRoot::Core->Clients->Count; i++)
{
CGameClient* iClient = CDatabaseRoot::Core->Clients->Elements[i];
if (iClient->Entity->Map == Client->Entity->Map &&
iClient->ID != Client->ID)
{
if (Distance(Client->Entity->X, Client->Entity->Y,
iClient->Entity->X, iClient->Entity->Y) <= MAX_SCREEN_WIDTH)
{
if (Client->Screen->Add(iClient->Entity))
{
Client->Send(iClient->Entity->Data);
if (Ptr != NULL) // LoadScreen() Standerd
{
iClient->Screen->Add(Client->Entity);
iClient->Send(Client->Entity->Data);
}
}
}
}
}
CDatabaseRoot::Core->Clients->FreeSyncHandle();
// </Clients>
}