本文整理汇总了C++中NET_Packet::r_tell方法的典型用法代码示例。如果您正苦于以下问题:C++ NET_Packet::r_tell方法的具体用法?C++ NET_Packet::r_tell怎么用?C++ NET_Packet::r_tell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NET_Packet
的用法示例。
在下文中一共展示了NET_Packet::r_tell方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Process_save
void xrServer::Process_save(NET_Packet& P, ClientID sender)
{
xrClientData* CL = ID_to_client(sender);
if (CL) CL->net_Ready = TRUE;
R_ASSERT(CL->flags.bLocal);
// while has information
while (!P.r_eof())
{
// find entity
u16 ID;
u16 size;
P.r_u16 (ID);
P.r_u16 (size);
s32 _pos_start = P.r_tell ();
CSE_Abstract *E = ID_to_entity(ID);
if (E) {
E->net_Ready = TRUE;
E->load (P);
}
else
P.r_advance (size);
s32 _pos_end = P.r_tell ();
s32 _size = size;
if (_size != (_pos_end-_pos_start)) {
Msg ("! load/save mismatch, object: '%s'",E?E->name_replace():"unknown");
s32 _rollback = _pos_start+_size;
P.r_seek (_rollback);
}
}
}
示例2: Process_update
void xrServer::Process_update(NET_Packet& P, ClientID sender)
{
xrClientData* CL = ID_to_client(sender);
if (!CL)
{
return;
}
// if (CL) CL->net_Ready = TRUE;
#ifdef DEBUG
if (g_Dump_Update_Read) Msg("---- UPDATE_Read --- ");
#endif // Entities
R_ASSERT(CL->flags.bLocal);
// while has information
while (!P.r_eof())
{
// find entity
u16 ID;
u8 size;
P.r_u16 (ID);
P.r_u8 (size);
u32 _pos = P.r_tell();
CSE_Abstract *E = ID_to_entity(ID);
if (E) {
//Msg ("sv_import: %d '%s'",E->ID,E->name_replace());
E->net_Ready = TRUE;
E->UPDATE_Read (P);
#ifdef DEBUG
if (g_Dump_Update_Read) Msg("* %s : %d - %d", E->name(), size, P.r_tell() - _pos);
#endif
if ((P.r_tell()-_pos) != size) {
string16 tmp;
CLSID2TEXT (E->m_tClassID,tmp);
Debug.fatal (DEBUG_INFO,"Beer from the creator of '%s'",tmp);
}
}
else
P.r_advance (size);
}
#ifdef DEBUG
if (g_Dump_Update_Read) Msg("-------------------- ");
#endif // Entities
}
示例3: Process_update
void xrServer::Process_update(NET_Packet& P, ClientID sender)
{
xrClientData* CL = ID_to_client(sender);
R_ASSERT2 (CL,"Process_update client not found");
if (g_Dump_Update_Read) Msg("---- UPDATE_Read --- ");
R_ASSERT(CL->flags.bLocal);
// while has information
while (!P.r_eof())
{
// find entity
u16 ID;
u8 size;
P.r_u16 (ID);
P.r_u8 (size);
u32 _pos = P.r_tell();
CSE_Abstract *E = ID_to_entity(ID);
if (E) {
//Msg ("sv_import: %d '%s'",E->ID,E->name_replace());
E->net_Ready = TRUE;
E->UPDATE_Read (P);
u32 cp = P.r_tell();
if (g_Dump_Update_Read) Msg("* %s : %d - %d", E->name(), size, cp - _pos);
if ((cp - _pos) != size) {
string16 tmp;
CLSID2TEXT (E->m_tClassID,tmp);
Msg("* size = %d, start read = %d, end read = %d", size, _pos, cp);
Debug.fatal (DEBUG_INFO,"Beer from the creator of '%s', version of object = %d", tmp, E->m_wVersion);
}
}
else
P.r_advance (size);
}
if (g_Dump_Update_Read) Msg("-------------------- ");
}
示例4:
void CLevel::cl_Process_Event (u16 dest, u16 type, NET_Packet& P)
{
// Msg ("--- event[%d] for [%d]",type,dest);
CObject* O = Objects.net_Find (dest);
if (0==O) {
#ifdef DEBUG
Msg("* WARNING: c_EVENT[%d] to [%d]: unknown dest",type,dest);
#endif // DEBUG
return;
}
CGameObject* GO = smart_cast<CGameObject*>(O);
if (!GO) {
Msg("! ERROR: c_EVENT[%d] : non-game-object",dest);
return;
}
if (type != GE_DESTROY_REJECT)
{
if (type == GE_DESTROY)
Game().OnDestroy(GO);
GO->OnEvent (P,type);
}
else { // handle GE_DESTROY_REJECT here
u32 pos = P.r_tell();
u16 id = P.r_u16();
P.r_seek (pos);
bool ok = true;
CObject *D = Objects.net_Find (id);
if (0==D) {
Msg ("! ERROR: c_EVENT[%d] : unknown dest",id);
ok = false;
}
CGameObject *GD = smart_cast<CGameObject*>(D);
if (!GD) {
Msg ("! ERROR: c_EVENT[%d] : non-game-object",id);
ok = false;
}
GO->OnEvent (P,GE_OWNERSHIP_REJECT);
if (ok)
{
Game().OnDestroy(GD);
GD->OnEvent (P,GE_DESTROY);
};
}
};
示例5:
void message_filter::check_new_data (NET_Packet & packet)
{
u32 tmp_old_pos = packet.r_tell();
msg_type_subtype_t packet_mtype;
packet_mtype.import (packet);
if (packet_mtype.msg_type == M_EVENT_PACK)
{
NET_Packet tmp_packet;
while (!packet.r_eof())
{
tmp_packet.B.count = packet.r_u8();
packet.r (tmp_packet.B.data, tmp_packet.B.count);
packet_mtype.import(tmp_packet);
R_ASSERT2(packet_mtype.msg_type != M_EVENT_PACK, "M_EVENT_PACK in M_EVENT_PACK");
dbg_print_msg (tmp_packet, packet_mtype);
filters_map_t::iterator tmp_iter = m_filters.find(packet_mtype);
if (tmp_iter != m_filters.end())
{
tmp_iter->second(packet_mtype.msg_type,
packet_mtype.msg_subtype,
tmp_packet);
}
}
} else {
dbg_print_msg (packet, packet_mtype);
filters_map_t::iterator tmp_iter = m_filters.find(packet_mtype);
if (tmp_iter != m_filters.end())
{
tmp_iter->second(packet_mtype.msg_type,
packet_mtype.msg_subtype,
packet);
}
}
packet.r_seek (tmp_old_pos);
}
示例6:
void CLevel::cl_Process_Event (u16 dest, u16 type, NET_Packet& P)
{
// Msg ("* event[%d] for [%d]",type,dest);
CObject* O = Objects.net_Find (dest);
if (0==O) {
#ifdef DEBUG
Msg("! WARNING: c_EVENT[%d] to [%d]: unknown dest",type,dest);
#endif // DEBUG
return;
}
CGameObject* GO = smart_cast<CGameObject*>(O);
if (!GO) {
#ifndef MASTER_GOLD
Msg("! ERROR: c_EVENT[%d] : non-game-object",dest);
#endif // #ifndef MASTER_GOLD
return;
}
if (type != GE_DESTROY_REJECT)
{
if (type == GE_DESTROY)
{
Game().OnDestroy(GO);
// if ( GO->H_Parent() )
// {
// = GameObject.cpp (210)
// Msg( "! ERROR (Level): GE_DESTROY arrived to object[%d][%s], that has parent[%d][%s], frame[%d]",
// GO->ID(), GO->cNameSect().c_str(),
// GO->H_Parent()->ID(), GO->H_Parent()->cName().c_str(), Device.dwFrame );
// }
}
GO->OnEvent (P,type);
}
else { // handle GE_DESTROY_REJECT here
u32 pos = P.r_tell();
u16 id = P.r_u16();
P.r_seek (pos);
bool ok = true;
CObject *D = Objects.net_Find (id);
if (0==D) {
#ifndef MASTER_GOLD
Msg ("! ERROR: c_EVENT[%d] : unknown dest",id);
#endif // #ifndef MASTER_GOLD
ok = false;
}
CGameObject *GD = smart_cast<CGameObject*>(D);
if (!GD) {
#ifndef MASTER_GOLD
Msg ("! ERROR: c_EVENT[%d] : non-game-object",id);
#endif // #ifndef MASTER_GOLD
ok = false;
}
GO->OnEvent (P,GE_OWNERSHIP_REJECT);
if (ok)
{
Game().OnDestroy(GD);
GD->OnEvent (P,GE_DESTROY);
};
}
};
示例7:
u32 xrServer::OnMessage (NET_Packet& P, ClientID sender) // Non-Zero means broadcasting with "flags" as returned
{
if (g_pGameLevel && Level().IsDemoSave()) Level().Demo_StoreServerData(P.B.data, P.B.count);
u16 type;
P.r_begin (type);
csPlayers.Enter ();
VERIFY (verify_entities());
xrClientData* CL = ID_to_client(sender);
switch (type)
{
case M_UPDATE:
{
Process_update (P,sender); // No broadcast
VERIFY (verify_entities());
}break;
case M_SPAWN:
{
// R_ASSERT(CL->flags.bLocal);
if (CL->flags.bLocal)
Process_spawn (P,sender);
VERIFY (verify_entities());
}break;
case M_EVENT:
{
Process_event (P,sender);
VERIFY (verify_entities());
}break;
case M_EVENT_PACK:
{
NET_Packet tmpP;
while (!P.r_eof())
{
tmpP.B.count = P.r_u8();
P.r (&tmpP.B.data, tmpP.B.count);
OnMessage (tmpP, sender);
};
}break;
case M_CL_UPDATE:
{
xrClientData* CL = ID_to_client (sender);
if (!CL) break;
CL->net_Ready = TRUE;
if (!CL->net_PassUpdates)
break;
//-------------------------------------------------------------------
u32 ClientPing = CL->stats.getPing();
P.w_seek(P.r_tell()+2, &ClientPing, 4);
//-------------------------------------------------------------------
if (SV_Client)
SendTo (SV_Client->ID, P, net_flags(TRUE, TRUE));
VERIFY (verify_entities());
}break;
case M_MOVE_PLAYERS_RESPOND:
{
xrClientData* CL = ID_to_client (sender);
if (!CL) break;
CL->net_Ready = TRUE;
CL->net_PassUpdates = TRUE;
}break;
//-------------------------------------------------------------------
case M_CL_PING_CHALLENGE:
{
P.r_u32();
u32 id = sender.value();
P.w_seek( P.r_tell(), &(id), 4);
if (SV_Client) SendTo (SV_Client->ID, P, net_flags(FALSE));
}break;
case M_CL_PING_CHALLENGE_RESPOND:
{
P.r_u32();
u32 id = P.r_u32();
ClientID clientID; clientID.set(id);
u32 clLastPing = P.r_u32();
xrClientData* pCL = ID_to_client(clientID);
pCL->ps->Rping = u16(clLastPing);
SendTo (clientID, P, net_flags(FALSE));
}break;
//-------------------------------------------------------------------
case M_CL_INPUT:
{
xrClientData* CL = ID_to_client (sender);
if (CL) CL->net_Ready = TRUE;
if (SV_Client) SendTo (SV_Client->ID, P, net_flags(TRUE, TRUE));
VERIFY (verify_entities());
}break;
case M_GAMEMESSAGE:
{
ClientID clientID;clientID.setBroadcast();
SendBroadcast (clientID,P,net_flags(TRUE,TRUE));
VERIFY (verify_entities());
}break;
case M_CLIENTREADY:
{
xrClientData* CL = ID_to_client(sender);
//.........这里部分代码省略.........