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 ); }
void CDanBattleSys::SendBattleResult() { TEAM_ITOR iLoop; int userIdx; BYTE WinTeam; MSG_BeginWriting( &netMessage ); MSG_Clear( &netMessage ); MSG_WriteByte( &netMessage, GSC_EXTEND ); MSG_WriteByte( &netMessage, GSC_DAN_BATTLE ); MSG_WriteByte( &netMessage, DANB_BATTLE_RESULT ); WinTeam=GetWinTeam(); MSG_WriteByte( &netMessage, WinTeam ); for (iLoop=m_BattleTeam[0].begin();iLoop!=m_BattleTeam[0].end();iLoop++) { userIdx=(*iLoop); NET_SendMessage( &g_pc[userIdx].sock, &netMessage ); } for (iLoop=m_BattleTeam[1].begin();iLoop!=m_BattleTeam[1].end();iLoop++) { userIdx=(*iLoop); NET_SendMessage( &g_pc[userIdx].sock, &netMessage ); } MSG_EndWriting( &netMessage ); }
void CDanBattleSys::SendBattleInfo() { TEAM_ITOR iLoop; int userIdx; int totalUser; int aliveUser; DWORD remainTime=g_logic.danBattleStatusTime[m_iBattleStatus]-(g_globalTime-m_dwStatusStartTime); MSG_BeginWriting( &netMessage ); MSG_Clear( &netMessage ); MSG_WriteByte( &netMessage, GSC_EXTEND ); MSG_WriteByte( &netMessage, GSC_DAN_BATTLE ); MSG_WriteByte( &netMessage, DANB_BATTLE_INFO ); MSG_WriteLong( &netMessage, m_BattleTeamInfo[0].BattlePoint ); MSG_WriteLong( &netMessage, m_BattleTeamInfo[1].BattlePoint ); MSG_WriteLong( &netMessage, remainTime ); totalUser=m_BattleTeam[0].size(); aliveUser=CountLiveUser(0); MSG_WriteLong( &netMessage, totalUser ); MSG_WriteLong( &netMessage, aliveUser ); totalUser=m_BattleTeam[1].size(); aliveUser=CountLiveUser(1); MSG_WriteLong( &netMessage, totalUser ); MSG_WriteLong( &netMessage, aliveUser ); MSG_WriteLong( &netMessage, m_BattleTeamInfo[0].startDanUserCount ); MSG_WriteLong( &netMessage, m_BattleTeamInfo[1].startDanUserCount ); MSG_WriteString( &netMessage, m_BattleTeamInfo[0].DanName); MSG_WriteString( &netMessage, m_BattleTeamInfo[1].DanName); for (iLoop=m_BattleTeam[0].begin();iLoop!=m_BattleTeam[0].end();iLoop++) { userIdx=(*iLoop); NET_SendMessage( &g_pc[userIdx].sock, &netMessage ); } for (iLoop=m_BattleTeam[1].begin();iLoop!=m_BattleTeam[1].end();iLoop++) { userIdx=(*iLoop); NET_SendMessage( &g_pc[userIdx].sock, &netMessage ); } MSG_EndWriting( &netMessage ); }
void CDanBattleManager::SendRequesterList(i3socket_t* sock,BYTE msgType,int serverID) { MSG_BeginWriting(&netMessage); MSG_Clear( &netMessage ); MSG_WriteByte(&netMessage, GSC_EXTEND); MSG_WriteByte(&netMessage, msgType); MSG_WriteByte(&netMessage, DANB_REQUESTER_LIST); if ( msgType == GMS_DAN_BATTLE ) { } BYTE listSize = m_RequestList.size(); MSG_WriteByte(&netMessage, listSize); BATTLE_ITOR iLoop; LPREQUEST_RECORD pReq; for ( iLoop=m_RequestList.begin();iLoop!=m_RequestList.end();iLoop++) { pReq=static_cast<LPREQUEST_RECORD>(*iLoop); MSG_WriteLong(&netMessage, pReq->DanIdx); MSG_WriteString(&netMessage, pReq->DanName); MSG_WriteString(&netMessage, pReq->MasterName); } NET_SendMessage( sock, &netMessage); MSG_EndWriting(&netMessage); }
/* ===================== 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); } }
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); }
/* ================== 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)); }
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 ); }
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; }
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); }
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); }
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); } } }
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); }
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); }
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 ); }
/* ================== 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"); }
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); }
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); } }
void CHelperManager_Encoder::SendMessage_Helper_StackOpen(playerCharacter_t* pHelper) { MSG_BeginWriting(&netMessage); MSG_Clear( &netMessage ); { MSG_WriteByte(&netMessage, EXTEND_SECOND); MSG_WriteShort ( &netMessage, HELPER_SYSTEM ); MSG_WriteShort(&netMessage, SC_STACK_OPEN_Req_toPlayer); NET_SendMessage(&pHelper->sock, &netMessage); } MSG_EndWriting(&netMessage); }
void GTH_SendMessageRequestItemSyncItem() { MSG_BeginWriting(&netMessage); MSG_Clear( &netMessage ); { MSG_WriteByte(&netMessage, EXTEND_SECOND); MSG_WriteShort(&netMessage, ITEM_EXTEND_SYSTEM); MSG_WriteShort(&netMessage, REQUEST_ITEM_SYNC_TIME); NET_SendMessage(&gsSocket, &netMessage); } MSG_EndWriting(&netMessage); }
void CHelperManager::ProcessMessage_ServerReplySummons(void) { int idx=-1; char toName[NAMESTRING+1], fromName[NAMESTRING+1]; int reply = MSG_ReadByte(); strncpy(toName, MSG_ReadString(),NAMESTRING); toName[NAMESTRING]=NULL; strncpy(fromName, MSG_ReadString(),NAMESTRING); fromName[NAMESTRING]=NULL; 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, GSC_REPLYSUMMONS); MSG_WriteByte(&netMessage, reply); MSG_WriteString(&netMessage, fromName); NET_SendMessage(&pTaker->sock, &netMessage); } MSG_EndWriting(&netMessage); } else { if (TRUE == g_config.isManager ) { int fromMemberIdx = MSG_ReadByte(); MSG_BeginWriting(&netMessage); MSG_Clear( &netMessage ); { MSG_WriteByte(&netMessage, GSC_REPLYSUMMONS); MSG_WriteByte(&netMessage, reply); MSG_WriteString(&netMessage, toName); MSG_WriteString(&netMessage, fromName); for (int severidx=1; severidx < MAX_MEMBER_SERVER; severidx++) { if ( !g_memberServer[severidx].active ) continue; if ( severidx == fromMemberIdx ) continue; NET_SendUnreliableMessage(&g_memberServer[severidx].sock, &netMessage); } } MSG_EndWriting(&netMessage); } } }
/* ================== CL_KeepaliveMessage When the client is taking a long time to load stuff, send keepalive messages so the server doesn't disconnect. ================== */ static void CL_KeepaliveMessage (void) { float time; static float lastmsg; int ret; sizebuf_t old; byte olddata[NET_MAXMESSAGE]; 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; memcpy (olddata, net_message.data, net_message.cursize); do { ret = CL_GetMessage (); switch (ret) { default: Host_Error ("%s: CL_GetMessage failed", __thisfunc__); case 0: break; // nothing waiting case 1: Host_Error ("%s: received a message", __thisfunc__); break; case 2: if (MSG_ReadByte() != svc_nop) Host_Error ("%s: datagram wasn't a nop", __thisfunc__); break; } } while (ret); net_message = old; memcpy (net_message.data, olddata, net_message.cursize); // check time time = Sys_DoubleTime (); if (time - lastmsg < 5) 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); }
void CHelperManager_Encoder::SendMessage_Helper_Helppoint(playerCharacter_t* pHelper) { MSG_BeginWriting(&netMessage); MSG_Clear( &netMessage ); { MSG_WriteByte(&netMessage, EXTEND_SECOND); MSG_WriteShort ( &netMessage, HELPER_SYSTEM ); MSG_WriteShort(&netMessage, SC_CONFIRM_HELPPOINT_Res_toPlayer); MSG_WriteLong(&netMessage, pHelper->tHelper.tPoint.iHelpPoint); NET_SendMessage(&pHelper->sock, &netMessage); } MSG_EndWriting(&netMessage); }
void CGs_To_Cc::Send(playerCharacter_t* pPlayer,int SystemType,int mainType, int subType) { MSG_BeginWriting( &netMessage ); MSG_Clear( &netMessage ); { MSG_WriteByte(&netMessage, EXTEND_SECOND); MSG_WriteShort(&netMessage, SystemType); MSG_WriteShort(&netMessage, mainType); MSG_WriteShort(&netMessage, subType); NET_SendMessage(&pPlayer->sock, &netMessage); } MSG_EndWriting(&netMessage); }
void CGMCtrl::TransmitePacket_cs_request_AUTHstate(void) { MSG_BeginWriting(&netMessage); MSG_Clear( &netMessage ); { MSG_WriteByte(&netMessage, EXTEND_SECOND); MSG_WriteShort(&netMessage, GMsystem); MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::GMsystem_NProtect); MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::tagNProtect::cs_request_AUTHstate); NET_SendMessage(&gsSocket, &netMessage); } MSG_EndWriting( &netMessage ); }
void CPostFunc::GTH_SendMessage_PostSystem_WriteOpen(void) { MSG_BeginWriting(&netMessage); MSG_Clear( &netMessage ); { MSG_WriteByte(&netMessage, CC_EXTEND); MSG_WriteByte(&netMessage, CC_POSTSYSTEM); MSG_WriteByte(&netMessage, POSTSYSTEM_WRITEOPEN); NET_SendMessage(&gsSocket, &netMessage); } MSG_EndWriting( &netMessage ); }
void GTH_SendMessage_Request_WorldChangeUseItem(WorldChangeSystem *pWorldChangeSystem) { MSG_BeginWriting( &netMessage); MSG_Clear( &netMessage ); { MSG_WriteByte ( &netMessage, CC_EXTEND); MSG_WriteByte ( &netMessage, CC_WORLD_CHANGE); MSG_WriteByte ( &netMessage, GTH_REQUEST_USE_ITEM); MSG_WriteByte ( &netMessage, pWorldChangeSystem->m_SaveInvenPos); NET_SendMessage ( &gsSocket, &netMessage); } MSG_EndWriting( &netMessage ); }
void CHelperManager_Encoder::SendMessage_Invite_Respond_toTaker( playerCharacter_t* pTaker,int errorCode) { MSG_BeginWriting(&netMessage); MSG_Clear( &netMessage ); { MSG_WriteByte(&netMessage, EXTEND_SECOND); MSG_WriteShort(&netMessage, HELPER_SYSTEM); MSG_WriteShort(&netMessage, SC_INVITE_Res_toTAKER); MSG_WriteShort(&netMessage, errorCode); NET_SendMessage(&pTaker->sock, &netMessage); } MSG_EndWriting(&netMessage); }
inline void CGuildCtrl::TransmitePackete_Summary_Req(const int guildIdx) const { MSG_BeginWriting( &netMessage ); MSG_Clear( &netMessage ); { MSG_WriteByte(&netMessage, CC_GUILD ); MSG_WriteByte(&netMessage, GUILD_SYNC ); MSG_WriteByte(&netMessage,enumClientGsvr::fromClient_toGsvr_Summary_Req); MSG_WriteShort( &netMessage, guildIdx ); NET_SendMessage( &gsSocket, &netMessage ); } MSG_EndWriting( &netMessage ); }
void GTH_SendMessage_GambleSystem_Active(BOOL bActive) { MSG_BeginWriting(&netMessage); MSG_Clear( &netMessage ); { MSG_WriteByte(&netMessage, EXTEND_SECOND); MSG_WriteShort(&netMessage, GAMBLE_SYSTEM ); MSG_WriteShort(&netMessage, ACTIVE_SYSTEM_REQUEST ); MSG_WriteLong(&netMessage, bActive); NET_SendMessage(&gsSocket, &netMessage); } MSG_EndWriting( &netMessage ); }