本文整理汇总了C++中NET_SendMessage函数的典型用法代码示例。如果您正苦于以下问题:C++ NET_SendMessage函数的具体用法?C++ NET_SendMessage怎么用?C++ NET_SendMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NET_SendMessage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MSG_BeginWriting
void CDanBattleSys::SendBattleStart()
{
TEAM_ITOR iLoop;
int userIdx;
MSG_BeginWriting( &netMessage );
MSG_Clear( &netMessage );
MSG_WriteByte( &netMessage, GSC_EXTEND );
MSG_WriteByte( &netMessage, GSC_DAN_BATTLE );
MSG_WriteByte( &netMessage, DANB_BATTLE_START );
for (iLoop=m_BattleTeam[0].begin();iLoop!=m_BattleTeam[0].end();iLoop++)
{
userIdx=(*iLoop);
NET_SendMessage( &g_pc[userIdx].sock, &netMessage );
ShowLogInfo("SendName = %s",g_pc[userIdx].name);
}
for (iLoop=m_BattleTeam[1].begin();iLoop!=m_BattleTeam[1].end();iLoop++)
{
userIdx=(*iLoop);
NET_SendMessage( &g_pc[userIdx].sock, &netMessage );
ShowLogInfo("SendName = %s",g_pc[userIdx].name);
}
MSG_EndWriting( &netMessage );
}
示例2: SV_DropClient
/*
=====================
SV_DropClient
Called when the player is getting totally kicked off the host
if (crash = true), don't bother sending signofs
=====================
*/
void SV_DropClient (bool crash)
{
int saveSelf;
int i;
client_t *client;
if (!host_client->active)
return;
if (!crash)
{
// send any final messages (don't check for errors)
if (NET_CanSendMessage (host_client->netconnection))
{
MSG_WriteByte (&host_client->message, svc_disconnect);
NET_SendMessage (host_client->netconnection, &host_client->message);
}
if (host_client->edict && host_client->spawned)
{
// call the prog function for removing a client
// this will set the body to a dead frame, among other things
saveSelf = pr_global_struct->self;
pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
PR_ExecuteProgram (pr_global_struct->ClientDisconnect);
pr_global_struct->self = saveSelf;
}
Sys_Printf ("Client %s removed\n",host_client->name);
}
/*if (host_client->netconnection->proquake_connection == MOD_QSMACK)
qsmackActive = false;*/
// break the net connection
NET_Close (host_client->netconnection);
host_client->netconnection = NULL;
// free the client (the body stays around)
host_client->active = false;
host_client->name[0] = 0;
host_client->old_frags = -999999;
net_activeconnections--;
// send notification to all clients
for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
{
if (!client->active)
continue;
MSG_WriteByte (&client->message, svc_updatename);
MSG_WriteByte (&client->message, host_client - svs.clients);
MSG_WriteString (&client->message, "");
MSG_WriteByte (&client->message, svc_updatefrags);
MSG_WriteByte (&client->message, host_client - svs.clients);
MSG_WriteShort (&client->message, 0);
MSG_WriteByte (&client->message, svc_updatecolors);
MSG_WriteByte (&client->message, host_client - svs.clients);
MSG_WriteByte (&client->message, 0);
}
}
示例3: GTH_SendMessage_DestroyItem
void GTH_SendMessage_DestroyItem( playerCharacter_t *pc, int reply, int error, int itemIdx )
{
MSG_BeginWriting(&netMessage);
MSG_Clear( &netMessage );
{
MSG_WriteByte(&netMessage, GSC_REPLY_DESTROY_ITEM );
MSG_WriteByte(&netMessage, reply );
if( reply > 0 )
{
MSG_WriteShort(&netMessage, (int)pc->curChargeRA );
MSG_WriteShort(&netMessage, (int)pc->curChargeSA );
MSG_WriteShort(&netMessage, itemIdx );
MSG_WriteShort(&netMessage, pc->curItemWeight );
MSG_WriteShort(&netMessage, error);
}
else
{
MSG_WriteByte(&netMessage, error );
}
NET_SendMessage(&pc->sock, &netMessage);
}
MSG_EndWriting(&netMessage);
}
示例4: Host_ShutdownServer
/*
==================
Host_ShutdownServer
This only happens at the end of a game, not between levels
==================
*/
void
Host_ShutdownServer(qboolean crash)
{
int i;
int count;
sizebuf_t buf;
byte message[4];
double start;
if (!sv.active)
return;
sv.active = false;
// stop all client sounds immediately
if (cls.state >= ca_connected)
CL_Disconnect();
// flush any pending messages - like the score!!!
start = Sys_DoubleTime();
do {
count = 0;
for (i = 0, host_client = svs.clients; i < svs.maxclients;
i++, host_client++) {
if (host_client->active && host_client->message.cursize) {
if (NET_CanSendMessage(host_client->netconnection)) {
NET_SendMessage(host_client->netconnection,
&host_client->message);
SZ_Clear(&host_client->message);
} else {
NET_GetMessage(host_client->netconnection);
count++;
}
}
}
if ((Sys_DoubleTime() - start) > 3.0)
break;
} while (count);
// make sure all the clients know we're disconnecting
buf.data = message;
buf.maxsize = 4;
buf.cursize = 0;
MSG_WriteByte(&buf, svc_disconnect);
count = NET_SendToAll(&buf, 5);
if (count)
Con_Printf("%s: NET_SendToAll failed for %u clients\n", __func__,
count);
for (i = 0, host_client = svs.clients; i < svs.maxclients;
i++, host_client++)
if (host_client->active)
SV_DropClient(crash);
//
// clear structures
//
memset(&sv, 0, sizeof(sv));
memset(svs.clients, 0, svs.maxclientslimit * sizeof(client_t));
}
示例5: GTH_SendMessage_ReplyGetInventoryItem
void GTH_SendMessage_ReplyGetInventoryItem(playerCharacter_t *pc, int reply, int error, int inventoryPos, int equipPos )
{
int itemIdx;
MSG_BeginWriting(&netMessage);
MSG_Clear( &netMessage );
{
MSG_WriteByte(&netMessage, GSC_REPLY_GETINVENTORYITEM);
if( reply > 0 )
{
MSG_WriteByte(&netMessage, reply);
MSG_WriteByte(&netMessage, inventoryPos);
MSG_WriteByte(&netMessage, equipPos);
if( reply == 5 )
{
MSG_WriteByte(&netMessage, pc->mouseInventory);
itemIdx = pc->inventory[inventoryPos];
MSG_WriteItem( &netMessage, &pc->item[itemIdx] );
MSG_WriteItem( &netMessage, &pc->item[pc->mouseInventory] );
}
}
else
{
MSG_WriteByte(&netMessage, reply);
MSG_WriteByte(&netMessage, error);
}
NET_SendMessage(&pc->sock, &netMessage);
}
MSG_EndWriting(&netMessage);
GTH_PC_Calculate( pc, PCINFO_BASIC );
}
示例6: MSG_BeginWriting
int CPostFunc::GTH_SendMessage_PostSystem_ReceiveItems()
{
CPostManager::PostPackage_t* pPostPackage = NULL;
pPostPackage = g_cgv.myCharacterInfo->m_PostMng.GetOpenPost();
int OpenIdx = g_cgv.myCharacterInfo->m_PostMng.m_OpenPostIdx;
MSG_BeginWriting(&netMessage);
MSG_Clear( &netMessage );
{
MSG_WriteByte(&netMessage, CC_EXTEND );
MSG_WriteByte(&netMessage, CC_MAILBOX );
MSG_WriteByte(&netMessage, MAILBOX_RECEIVE_ITEMS );
MSG_WriteLong(&netMessage, OpenIdx );
NET_SendMessage(&gsSocket, &netMessage);
}
MSG_EndWriting( &netMessage );
return 1;
}
示例7: GTH_SendMessage_AddItemObject
void GTH_SendMessage_AddItemObject(itemObject_t *itemObject)
{
int i;
int idx;
GTH_GetPCListInValidRange(itemObject->worldIdx, itemObject->position);
if (g_zonePCListNumber < 1) return;
MSG_BeginWriting(&netMessage);
MSG_Clear( &netMessage );
{
MSG_WriteByte(&netMessage, GSC_ADDITEMOBJECT);
MSG_WriteShort(&netMessage, itemObject->idx);
MSG_WritePosition(&netMessage, itemObject->position);
MSG_WriteByte(&netMessage, itemObject->objectType);
if( itemObject->objectType == OBJECT_TYPE_ITEM )
{
MSG_WriteShort(&netMessage, itemObject->item.itemTableIdx);
} else if( itemObject->objectType == OBJECT_TYPE_PORTAL )
{
MSG_WriteShort(&netMessage, itemObject->portal.portalType);
}
for (i=0; i < g_zonePCListNumber; i++)
{
idx = g_zonePCList[i].idx;
if ( !g_pc[idx].ready ) continue;
NET_SendMessage(&g_pc[idx].sock, &netMessage);
}
}
MSG_EndWriting(&netMessage);
}
示例8: MSG_ReadShort
void CHelperManager::ProcessMessage_Reply_Helpers_Update ()
{
if ( g_config.gameServerNo != MSG_ReadByte () ) return;
int idx = MSG_ReadShort ();
playerCharacter_t* pTaker=gcpTools->GetPlayerRecordPointer(idx);
if(NULL==pTaker) return;
HelperEntry HelperEntries;
HelperEntries.level = MSG_ReadByte ();
HelperEntries.job = MSG_ReadByte ();
HelperEntries.worldIdx = MSG_ReadByte ();
strncpy ( HelperEntries.name, MSG_ReadString(),NAMESTRING);
HelperEntries.name[NAMESTRING]=NULL;
MSG_BeginWriting( &netMessage );
MSG_Clear( &netMessage );
{
MSG_WriteByte(&netMessage, EXTEND_SECOND);
MSG_WriteShort ( &netMessage, HELPER_SYSTEM );
MSG_WriteShort ( &netMessage, SC_LISTINFO_toAllPlayer);
MSG_WriteByte ( &netMessage, HelperEntries.level );
MSG_WriteByte ( &netMessage, HelperEntries.job );
MSG_WriteByte ( &netMessage, HelperEntries.worldIdx );
MSG_WriteString ( &netMessage, HelperEntries.name );
NET_SendMessage ( &pTaker->sock, &netMessage );
}
MSG_EndWriting(&netMessage);
}
示例9: GetHelperPtr
void CHelperManager::MemberListInfo_Send_toAllPlayer(entityPCList_t* pl, int fstate )
{
struct tagHelper *helperlist = GetHelperPtr(pl->idx);
if(NULL == helperlist) return;
entityPCList_t target = { 0, };
for (int idx = 0; idx < helperlist->List.count; idx++ )
{
if ( g_entityListMng.FindPCList ( helperlist->List.Member[idx].name, &target ) < 0) continue;
if( TRUE == helperlist->List.Member[idx].bIsMatchHELPERandTACKER) continue;
if ( target.serverIdx == 0 )
{
MSG_BeginWriting ( &netMessage );
MSG_Clear( &netMessage );
MSG_WriteByte(&netMessage, EXTEND_SECOND);
MSG_WriteShort ( &netMessage, HELPER_SYSTEM );
MSG_WriteShort ( &netMessage, SC_LISTINFO_toAllPlayer );
MSG_WriteByte ( &netMessage, pl->level );
MSG_WriteByte ( &netMessage, pl->job );
MSG_WriteByte ( &netMessage, fstate == HelpersLogout ? -1 : pl->worldIdx );
MSG_WriteString ( &netMessage, pl->name );
MSG_WriteShort ( &netMessage, helperlist->List.mode);
playerCharacter_t* pPlayer=gcpTools->GetPlayerRecordPointer(target.idxOnServer);
if(NULL == pPlayer) {
MSG_EndWriting(&netMessage);
return;
}
NET_SendMessage ( &pPlayer->sock, &netMessage );
MSG_EndWriting(&netMessage);
ShowLogInfo("SC_LISTINFO_toAllPlayer: PlayName= %s, level= %d, job= %d, fstate=%d,mode=%d,",
pl->name,pl->level, pl->job,fstate,helperlist->List.mode );
}else{
MSG_BeginWriting ( &netMessage );
MSG_Clear( &netMessage );
MSG_WriteByte(&netMessage, EXTEND_SECOND);
MSG_WriteShort ( &netMessage, HELPER_SYSTEM );
MSG_WriteShort ( &netMessage, SS_REPLY_UPDATE_MemberList_toServer);
MSG_WriteByte ( &netMessage, target.serverIdx );
MSG_WriteShort ( &netMessage, target.idxOnServer );
MSG_WriteByte ( &netMessage, pl->level );
MSG_WriteByte ( &netMessage, pl->job );
MSG_WriteByte ( &netMessage, fstate == HelpersLogout ? -1 : pl->worldIdx );
MSG_WriteString ( &netMessage, pl->name );
MSG_WriteShort ( &netMessage, helperlist->List.mode);
NET_SendUnreliableMessage ( &g_memberServer[target.serverIdx].sock, &netMessage );
MSG_EndWriting(&netMessage);
}
}
}
示例10: CL_SendCmd
void CL_SendCmd(void) {
usercmd_t cmd;
if (cls.state != ca_connected)
return;
if (cls.signon == SIGNONS) {
// get basic movement from keyboard
CL_BaseMove(&cmd);
// allow mice or other external controllers to add to the move
IN_Move(&cmd);
// send the unreliable message
CL_SendMove(&cmd);
}
if (cls.demoplayback) {
SZ_Clear(&cls.message);
return;
}
// send the reliable message
if (!cls.message.cursize)
return; // no message at all
if (!NET_CanSendMessage(cls.netcon)) {
Con_DPrintf("CL_WriteToServer: can't send\n");
return;
}
if (NET_SendMessage(cls.netcon, &cls.message) == -1)
Host_Error("CL_WriteToServer: lost server connection");
SZ_Clear(&cls.message);
}
示例11: GTH_SendMessage_AddInvItem
void GTH_SendMessage_AddInvItem( playerCharacter_t *pc, int reply, int error, item_t *item )
{
MSG_BeginWriting(&netMessage);
MSG_Clear( &netMessage );
{
MSG_WriteByte(&netMessage, GSC_ADDITEMINV);
MSG_WriteByte(&netMessage, reply);
if( reply )
{
MSG_WriteItem(&netMessage, item);
MSG_WriteByte(&netMessage, error);
}
else
{
MSG_WriteByte(&netMessage, error);
}
NET_SendMessage(&pc->sock, &netMessage);
}
MSG_EndWriting(&netMessage);
}
示例12: MSG_BeginWriting
void CWeatherSystem::GTH_SendMessageEventSeting(int event)
{
if ( event < 0)
event = 0;
MSG_BeginWriting( &netMessage );
MSG_Clear( &netMessage );
{
MSG_WriteByte(&netMessage, EXTEND_SECOND);
MSG_WriteShort(&netMessage, WEATHER_SYSTEM );
MSG_WriteShort(&netMessage, CC_WEATHER_SYSTEM );
MSG_WriteByte(&netMessage, CC_WEATHER_SYSTEM_BROAD_CASTING_EVENT_SETING);
MSG_WriteByte(&netMessage, event);
NET_SendMessage(&gsSocket, &netMessage);
}
MSG_EndWriting(&netMessage);
if ( event == 0)
{
g_ifMng->AddChatMessage( g_LPACK.GetMassage(LPACK_TYPE_NORMAL2, 251), GTHCOLOR_SYSMESSAGE, g_LPACK.GetMessage(LPACK_TYPE_NORMAL,322));
}
else
{
g_ifMng->AddChatMessage( g_LPACK.GetMassage(LPACK_TYPE_NORMAL2, 252), GTHCOLOR_SYSMESSAGE, g_LPACK.GetMessage(LPACK_TYPE_NORMAL,322));
}
g_musicMng->PlaySample( g_soundMng->GetNormalSoundID( GTH_SOUND_ID_WARNING_2 ), GTH_SOUND_PLAY_ONCE );
}
示例13: CL_KeepaliveMessage
/*
==================
CL_KeepaliveMessage
When the client is taking a long time to load stuff, send keepalive messages
so the server doesn't disconnect.
==================
*/
void CL_KeepaliveMessage (void)
{
float time;
static float lastmsg;
int ret;
sizebuf_t old;
byte* olddata;
if (sv.active)
return; // no need if server is local
if (cls.demoplayback)
return;
// read messages from server, should just be nops
old = net_message;
olddata = Sys_BigStackAlloc(8192 * sizeof(byte), "CL_KeepaliveMessage");
memcpy (olddata, net_message.data, net_message.cursize);
do
{
ret = CL_GetMessage ();
switch (ret)
{
default:
Host_Error ("CL_KeepaliveMessage: CL_GetMessage failed");
case 0:
break; // nothing waiting
case 1:
Host_Error ("CL_KeepaliveMessage: received a message");
break;
case 2:
if (MSG_ReadByte() != svc_nop)
Host_Error ("CL_KeepaliveMessage: datagram wasn't a nop");
break;
}
} while (ret);
net_message = old;
memcpy (net_message.data, olddata, net_message.cursize);
// check time
time = Sys_FloatTime ();
if (time - lastmsg < 5)
{
Sys_BigStackFree(8192 * sizeof(byte), "CL_KeepaliveMessage");
return;
}
lastmsg = time;
// write out a nop
Con_Printf ("--> client to server keepalive\n");
MSG_WriteByte (&cls.message, clc_nop);
NET_SendMessage (cls.netcon, &cls.message);
SZ_Clear (&cls.message);
Sys_BigStackFree(8192 * sizeof(byte), "CL_KeepaliveMessage");
}
示例14: strncpy
void CHelperManager::ProcessMessage_Reply_Helpers_List ()
{
if ( g_config.gameServerNo != MSG_ReadByte () ) return;
char czTempName[NAMESTRING+1];
strncpy(czTempName,MSG_ReadString(),NAMESTRING);
int idx = MSG_ReadShort ();
int count = MSG_ReadByte ();
int enumMode = static_cast<tagHelper::tagMemberList::enumMode>(MSG_ReadShort());
playerCharacter_t* pTaker=gcpTools->GetPlayerRecordPointer(idx);
if(NULL == pTaker) return;
if(NULL != strcmp(pTaker->name,czTempName)) return;
if(count < USERCOUNT || count > tagHelper::MAX_MEMBER) return;
HelperEntry HelperEntries[tagHelper::MAX_MEMBER];
for (int listmember = 0; listmember < count; listmember++ )
{
HelperEntries[listmember].level = MSG_ReadByte ();
HelperEntries[listmember].job = MSG_ReadByte ();
HelperEntries[listmember].worldIdx = MSG_ReadByte ();
strncpy (HelperEntries[listmember].name, MSG_ReadString (),NAMESTRING);
HelperEntries[listmember].name[NAMESTRING]=NULL;
HelperEntries[listmember].bsync= MSG_ReadByte ();
}
MSG_BeginWriting ( &netMessage );
MSG_Clear( &netMessage );
{
MSG_WriteByte(&netMessage, EXTEND_SECOND);
MSG_WriteShort( &netMessage, HELPER_SYSTEM );
MSG_WriteShort( &netMessage, SC_LIST_Res_toServer );
MSG_WriteByte( &netMessage, count);
MSG_WriteShort ( &netMessage, enumMode);
for ( int listmember = 0; listmember < count; listmember++)
{
MSG_WriteByte ( &netMessage, HelperEntries[listmember].level );
MSG_WriteByte ( &netMessage, HelperEntries[listmember].job );
MSG_WriteByte ( &netMessage, HelperEntries[listmember].worldIdx );
MSG_WriteString ( &netMessage, HelperEntries[listmember].name );
MSG_WriteByte(&netMessage, HelperEntries[listmember].bsync);
}
NET_SendMessage ( &pTaker->sock, &netMessage );
}
MSG_EndWriting(&netMessage);
}
示例15: GTH_FindPCByName
void CHelperManager_Encoder::SendMessage_ReplySummons(int reply, char* toName, char* fromName)
{
int idx = GTH_FindPCByName(toName);
if ( 0 <= idx)
{
playerCharacter_t* pTaker=gcpTools->GetPlayerRecordPointer(idx);
if(NULL == pTaker) return;
MSG_BeginWriting(&netMessage);
MSG_Clear( &netMessage );
{
MSG_WriteByte(&netMessage, EXTEND_SECOND);
MSG_WriteShort ( &netMessage, HELPER_SYSTEM );
MSG_WriteShort(&netMessage, SC_SPAWN_Res_toTaker);
MSG_WriteByte(&netMessage, reply);
MSG_WriteString(&netMessage, fromName);
NET_SendMessage(&pTaker->sock, &netMessage);
}
MSG_EndWriting(&netMessage);
}
else
{
MSG_BeginWriting(&netMessage);
MSG_Clear( &netMessage );
{
MSG_WriteByte(&netMessage, EXTEND_SECOND);
MSG_WriteShort ( &netMessage, HELPER_SYSTEM );
MSG_WriteShort(&netMessage, SS_SPAWN_Res_fromServer);
MSG_WriteByte(&netMessage, reply);
MSG_WriteString(&netMessage, toName);
MSG_WriteString(&netMessage, fromName);
if ( TRUE == g_config.isManager )
{
for (int serveridx=1; serveridx < MAX_MEMBER_SERVER; serveridx++)
{
if ( !g_memberServer[serveridx].active ) continue;
NET_SendUnreliableMessage(&g_memberServer[serveridx].sock, &netMessage);
}
}
else
{
MSG_WriteByte(&netMessage, g_config.gameServerNo);
NET_SendUnreliableMessage(&localSocket, &netMessage);
}
}
MSG_EndWriting(&netMessage);
}
}