void __cdecl CYahooProto::search_simplethread(void *snsearch) { TCHAR *id = (TCHAR *) snsearch; if (lstrlen(id) < 4) { SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0); MessageBoxA(NULL, "Please enter a valid ID to search for.", "Search", MB_OK); return; } TCHAR *c = _tcsstr(id, _T("@yahoo.com")); if (c) *c = 0; PROTOSEARCHRESULT psr = { 0 }; psr.cbSize = sizeof(psr); psr.flags = PSR_TCHAR; psr.id = (TCHAR*)_tcslwr(id); psr.reserved[0] = YAHOO_IM_YAHOO; SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr); //yahoo_search(m_id, YAHOO_SEARCH_YID, m, YAHOO_GENDER_NONE, YAHOO_AGERANGE_NONE, 0, 1); SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0); }
void CYahooProto::ext_got_search_result(int found, int start, int total, YList *contacts) { struct yahoo_found_contact *yct=NULL; int i=start; YList *en=contacts; LOG(("got search result: ")); LOG(("Found: %d", found)); LOG(("Start: %d", start)); LOG(("Total: %d", total)); PROTOSEARCHRESULT psr = { 0 }; psr.cbSize = sizeof(psr); psr.flags = PSR_TCHAR; psr.reserved[0] = YAHOO_IM_YAHOO; while (en) { yct = ( yahoo_found_contact* )en->data; if (yct == NULL) { LOG(("[%d] Empty record?",i++)); } else { LOG(("[%d] id: '%s', online: %d, age: %d, sex: '%s', location: '%s'", i++, yct->id, yct->online, yct->age, yct->gender, yct->location)); psr.id = mir_utf8decodeT( yct->id ); if (yct->gender[0] != 5) psr.firstName = mir_utf8decodeT( yct->gender ); else psr.firstName = NULL; TCHAR c[10]; if (yct->age > 0) { _itot(yct->age, c,10); psr.lastName = ( TCHAR* )c; } else psr.lastName = NULL; if (yct->location[0] != 5) psr.email = mir_utf8decodeT( yct->location ); else psr.email = NULL; //void yahoo_search(int id, enum yahoo_search_type t, const char *text, enum yahoo_search_gender g, enum yahoo_search_agerange ar, // int photo, int yahoo_only) SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr); mir_free(psr.id); mir_free(psr.firstName); mir_free(psr.email); } en = y_list_next(en); } SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0); }
void CMsnProto::MsgQueue_Clear(const char* wlid, bool msg) { int i; EnterCriticalSection(&csMsgQueue); if (wlid == NULL) { for(i=0; i < msgQueueList.getCount(); i++) { const MsgQueueEntry& E = msgQueueList[i]; if (E.msgSize == 0) { HANDLE hContact = MSN_HContactFromEmail(E.wlid); SendBroadcast(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)E.seq, (LPARAM)MSN_Translate("Message delivery failed")); } mir_free(E.message); mir_free(E.wlid); if (E.cont) delete E.cont; } msgQueueList.destroy(); msgQueueSeq = 1; } else { for(i=0; i < msgQueueList.getCount(); i++) { time_t ts = time(NULL); const MsgQueueEntry& E = msgQueueList[i]; if (_stricmp(msgQueueList[i].wlid, wlid) == 0 && (!msg || E.msgSize == 0)) { bool msgfnd = E.msgSize == 0 && E.ts < ts; int seq = E.seq; mir_free(E.message); mir_free(E.wlid); if (E.cont) delete E.cont; msgQueueList.remove(i); if (msgfnd) { LeaveCriticalSection(&csMsgQueue); HANDLE hContact = MSN_HContactFromEmail(wlid); SendBroadcast(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)seq, (LPARAM)MSN_Translate("Message delivery failed")); i = 0; EnterCriticalSection(&csMsgQueue); } } } } LeaveCriticalSection(&csMsgQueue); }
int __cdecl CMsnProto::SetStatus(int iNewStatus) { if (m_iDesiredStatus == iNewStatus) return 0; m_iDesiredStatus = iNewStatus; MSN_DebugLog("PS_SETSTATUS(%d,0)", iNewStatus); if (m_iDesiredStatus == ID_STATUS_OFFLINE) { if (msnNsThread) msnNsThread->sendTerminate(); } else if (!msnLoggedIn && m_iStatus == ID_STATUS_OFFLINE) { char szPassword[100]; int ps = getStaticString(NULL, "Password", szPassword, sizeof(szPassword)); if (ps != 0 || *szPassword == 0) { SendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; return 0; } if (*MyOptions.szEmail == 0) { SendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; return 0; } sessionList.destroy(); dcList.destroy(); usingGateway = false; int oldMode = m_iStatus; m_iStatus = ID_STATUS_CONNECTING; SendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldMode, m_iStatus); ThreadData* newThread = new ThreadData; newThread->mType = SERVER_NOTIFICATION; newThread->mIsMainThread = true; newThread->startThread(&CMsnProto::MSNServerThread, this); } else if (m_iStatus > ID_STATUS_OFFLINE) MSN_SetServerStatus(m_iDesiredStatus); return 0; }
void __cdecl CMsnProto::MsnSearchAckThread(void* arg) { const TCHAR* emailT = (TCHAR*)arg; char *email = mir_utf8encodeT(emailT); if (Lists_IsInList(LIST_FL, email)) { MSN_ShowPopup(emailT, _T("Contact already in your contact list"), MSN_ALLOW_MSGBOX, NULL); SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); mir_free(arg); return; } unsigned res = MSN_ABContactAdd(email, NULL, NETID_MSN, NULL, 1, true); switch(res) { case 0: case 2: case 3: { PROTOSEARCHRESULT isr = {0}; isr.cbSize = sizeof(isr); isr.flags = PSR_TCHAR; isr.id = (TCHAR*)emailT; isr.nick = (TCHAR*)emailT; isr.email = (TCHAR*)emailT; SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, arg, (LPARAM)&isr); SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); } break; case 1: if (strstr(email, "@yahoo.com") == NULL) SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); else { msnSearchId = arg; MSN_FindYahooUser(email); } break; default: SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); break; } mir_free(email); mir_free(arg); }
void __cdecl CMsnProto::MsnGetAwayMsgThread(void* arg) { Sleep(150); AwayMsgInfo *inf = (AwayMsgInfo*)arg; DBVARIANT dbv; if (!DBGetContactSettingString(inf->hContact, "CList", "StatusMsg", &dbv)) { SendBroadcast(inf->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)inf->id, (LPARAM)dbv.pszVal); MSN_FreeVariant(&dbv); } else SendBroadcast(inf->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)inf->id, (LPARAM)0); mir_free(inf); }
void xrServer::Process_event_activate (NET_Packet& P, const ClientID sender, const u32 time, const u16 id_parent, const u16 id_entity, bool send_message) { // Parse message CSE_Abstract* e_parent = game->get_entity_from_eid (id_parent); CSE_Abstract* e_entity = game->get_entity_from_eid (id_entity); #ifndef MASTER_GOLD Msg("* Artefact activate (parent = %d) (item = %d)", id_parent, id_entity); #endif // #ifndef MASTER_GOLD R_ASSERT2 (e_parent, make_string("parent not found. id_parent=%d id_entity=%d frame=%d",id_parent,id_entity, Device.dwFrame).c_str()); R_ASSERT2 (e_entity, make_string("entity not found. id_parent=%d id_entity=%d frame=%d",id_parent,id_entity, Device.dwFrame).c_str()); if (!game->OnActivate(id_parent, id_entity)) return; if (0xffff == e_entity->ID_Parent) { #ifndef MASTER_GOLD Msg ("! ERROR: can't activate independant object. entity[%s:%d], parent[%s:%d], section[%s]", e_entity->name_replace(),id_entity,e_parent->name_replace(),id_parent, *e_entity->s_name); #endif // #ifndef MASTER_GOLD return; } // Signal to everyone (including sender) if (send_message) { DWORD MODE = net_flags(TRUE,TRUE, FALSE, TRUE); SendBroadcast (BroadcastCID,P,MODE); } return; }
unsigned __stdcall sttFakeAck( LPVOID param ) { TFakeAckParams* tParam = ( TFakeAckParams* )param; WaitForSingleObject( tParam->hEvent, INFINITE ); Sleep( 100 ); if ( tParam->msg == NULL ) SendBroadcast( tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, ( HANDLE )tParam->id, 0 ); else SendBroadcast( tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, ( HANDLE )tParam->id, LPARAM( tParam->msg )); CloseHandle( tParam->hEvent ); delete tParam; return 0; }
Layer::~Layer() { if ( mProperties ) delete mProperties; SendBroadcast( "LayerObjectDeleted", this ); }
void Layer::SetName( const char* name ) { if ( m_strName != name ) { m_strName = name; SendBroadcast( "LayerNameChanged", this ); } }
void __cdecl CYahooProto::searchadv_thread(void *pHWND) { HWND hwndDlg = (HWND) pHWND; TCHAR searchid[128]; GetDlgItemText(hwndDlg, IDC_SEARCH_ID, searchid, 128); if (lstrlen(searchid) == 0) { SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0); MessageBoxA(NULL, "Please enter a valid ID to search for.", "Search", MB_OK); return; } PROTOSEARCHRESULT psr = { 0 }; psr.cbSize = sizeof(psr); psr.flags = PSR_TCHAR; psr.id = _tcslwr(searchid); int pid = SendDlgItemMessage(hwndDlg , IDC_SEARCH_PROTOCOL, CB_GETCURSEL, 0, 0); switch (pid){ case 0: psr.firstName = _T("<Yahoo >"); pid = YAHOO_IM_YAHOO; break; case 1: psr.firstName = _T("<Lotus Sametime>"); pid = YAHOO_IM_SAMETIME;break; case 2: psr.firstName = _T("<LCS>"); pid = YAHOO_IM_LCS; break; case 3: psr.firstName = _T("<Windows Live (MSN)>"); pid = YAHOO_IM_MSN; break; } psr.reserved[0] = pid; /* * Show this in results */ SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr); /* * Done searching. */ SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0); }
void __cdecl CMsnProto::MsnFileAckThread(void* arg) { filetransfer* ft = (filetransfer*)arg; TCHAR filefull[MAX_PATH]; mir_sntprintf(filefull, SIZEOF(filefull), _T("%s\\%s"), ft->std.tszWorkingDir, ft->std.tszCurrentFile); replaceStr(ft->std.tszCurrentFile, filefull); if (SendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, ft, (LPARAM)&ft->std)) return; bool fcrt = ft->create() != -1; if (ft->p2p_appID != 0) { if (fcrt) p2p_sendFeedStart(ft); p2p_sendStatus(ft, fcrt ? 200 : 603); } else msnftp_sendAcceptReject (ft, fcrt); SendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, ft, 0); }
HANDLE __cdecl CMsnProto::SendFile(HANDLE hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles) { if (!msnLoggedIn) return 0; if (getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) return 0; MsnContact *cont = Lists_Get(hContact); if (!cont || _stricmp(cont->email, MyOptions.szEmail) == 0) return 0; if ((cont->cap1 & 0xf0000000) == 0 && cont->netId != NETID_MSN) return 0; filetransfer* sft = new filetransfer(this); sft->std.ptszFiles = ppszFiles; sft->std.hContact = hContact; sft->std.flags |= PFTS_SENDING; int count = 0; while (ppszFiles[count] != NULL) { struct _stati64 statbuf; if (_tstati64(ppszFiles[count++], &statbuf) == 0 && (statbuf.st_mode & _S_IFDIR) == 0) { sft->std.totalBytes += statbuf.st_size; ++sft->std.totalFiles; } } if (sft->openNext() == -1) { delete sft; return 0; } if (cont->cap1 & 0xf0000000) p2p_invite(MSN_APPID_FILE, sft, NULL); else { sft->p2p_dest = mir_strdup(cont->email); msnftp_invite(sft); } SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_SENTREQUEST, sft, 0); return sft; }
void xrServer::Perform_destroy (CSE_Abstract* object, u32 mode) { R_ASSERT (object); R_ASSERT (object->ID_Parent == 0xffff); #ifdef DEBUG # ifdef SLOW_VERIFY_ENTITIES verify_entities (); # endif #endif while (!object->children.empty()) { CSE_Abstract *child = game->get_entity_from_eid(object->children.back()); R_ASSERT2 (child, make_string("child registered but not found [%d]",object->children.back())); // Msg ("SLS-CLEAR : REJECT [%s][%s] FROM [%s][%s]",child->name(),child->name_replace(),object->name(),object->name_replace()); Perform_reject (child,object,2*NET_Latency); #ifdef DEBUG # ifdef SLOW_VERIFY_ENTITIES verify_entities (); # endif #endif Perform_destroy (child,mode); } // Msg ("SLS-CLEAR : DESTROY [%s][%s]",object->name(),object->name_replace()); u16 object_id = object->ID; entity_Destroy (object); #ifdef DEBUG # ifdef SLOW_VERIFY_ENTITIES verify_entities (); # endif #endif NET_Packet P; P.w_begin (M_EVENT); P.w_u32 (Device.dwTimeGlobal - 2*NET_Latency); P.w_u16 (GE_DESTROY); P.w_u16 (object_id); ClientID clientID; clientID.setBroadcast (); SendBroadcast (clientID,P,mode); }
void CNoticeModule::OnLogic() { int nid = m_list.Head(); while( CNotice* notice = GetObj(nid) ) { int temId = nid; nid = m_list.Next(temId); PersonID pid = PlayerMgr.m_list.Head(); while( CPlayer* player = PlayerMgr.GetObj(pid) ) { pid = PlayerMgr.m_list.Next(pid); SendBroadcast(player, notice); } Delete(temId); } }
bool xrServer::Process_event_reject (NET_Packet& P, const ClientID sender, const u32 time, const u16 id_parent, const u16 id_entity, bool send_message) { // Parse message CSE_Abstract* e_parent = game->get_entity_from_eid (id_parent); CSE_Abstract* e_entity = game->get_entity_from_eid (id_entity); #ifdef DEBUG Msg("sv reject. id_parent %s id_entity %s [%d]",ent_name_safe(id_parent).c_str(),ent_name_safe(id_entity).c_str(), Device.dwFrame); #endif R_ASSERT (e_parent && e_entity); game->OnDetach (id_parent,id_entity); if (0xffff == e_entity->ID_Parent) { Msg ("~ ERROR: can't detach independant object. entity[%s:%d], parent[%s:%d], section[%s]", e_entity->name_replace(),id_entity,e_parent->name_replace(),id_parent, *e_entity->s_name); if (game_lua()) Msg("~ %s", get_lua_traceback(game_lua(), 2)); return (false); } // Rebuild parentness R_ASSERT3 (e_entity->ID_Parent == id_parent, e_entity->name_replace(), e_parent->name_replace()); e_entity->ID_Parent = 0xffff; xr_vector<u16>& C = e_parent->children; xr_vector<u16>::iterator c = std::find (C.begin(),C.end(),id_entity); R_ASSERT3 (C.end()!=c,e_entity->name_replace(),e_parent->name_replace()); C.erase (c); // Signal to everyone (including sender) if (send_message) { DWORD MODE = net_flags(TRUE,TRUE, FALSE, TRUE); SendBroadcast (BroadcastCID,P,MODE); } return (true); }
int __cdecl CMsnProto::FileResume(HANDLE hTransfer, int* action, const PROTOCHAR** szFilename) { filetransfer* ft = (filetransfer*)hTransfer; if (!msnLoggedIn || !p2p_sessionRegistered(ft)) return 1; switch (*action) { case FILERESUME_SKIP: if (ft->p2p_appID != 0) p2p_sendStatus(ft, 603); else msnftp_sendAcceptReject (ft, false); break; case FILERESUME_RENAME: replaceStr(ft->std.tszCurrentFile, *szFilename); default: bool fcrt = ft->create() != -1; if (ft->p2p_appID != 0) { if (fcrt) p2p_sendFeedStart(ft); p2p_sendStatus(ft, fcrt ? 200 : 603); } else msnftp_sendAcceptReject (ft, fcrt); SendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, ft, 0); break; } return 0; }
void PixelInfoPanel::DoListenToMessage( std::string const iMsg, void* iData, void* sender ) { if ( iMsg == "MouseRASPositionChanged" ) { m_listCtrlCursor->BlockListen( true ); m_listCtrlMouse->SetRASPosition( MainWindow::GetMainWindowPointer()->GetLayerCollection( "MRI" )->GetCurrentRASPosition() ); m_listCtrlMouse->HideEditor(); } else if ( iMsg == "CursorRASPositionChanged" ) { m_listCtrlMouse->BlockListen( true ); m_listCtrlCursor->SetRASPosition( MainWindow::GetMainWindowPointer()->GetLayerCollection( "MRI" )->GetCursorRASPosition() ); m_listCtrlCursor->HideEditor(); } else if ( iMsg == "LayerActiveFrameChanged" || iMsg == "LayerShowInfoChanged" ) { m_listCtrlMouse->UpdateList(); m_listCtrlCursor->UpdateList(); } SendBroadcast( iMsg, iData, sender ); m_listCtrlMouse->BlockListen( false ); m_listCtrlCursor->BlockListen( false ); }
void xrServer::Process_event (NET_Packet& P, ClientID sender) { # ifdef SLOW_VERIFY_ENTITIES VERIFY (verify_entities()); # endif u32 timestamp; u16 type; u16 destination; u32 MODE = net_flags(TRUE,TRUE); // correct timestamp with server-unique-time (note: direct message correction) P.r_u32 (timestamp ); // read generic info P.r_u16 (type ); P.r_u16 (destination); CSE_Abstract* receiver = game->get_entity_from_eid (destination); if (receiver) { R_ASSERT(receiver->owner); receiver->OnEvent (P,type,timestamp,sender); }; switch (type) { case GE_GAME_EVENT: { u16 game_event_type; P.r_u16(game_event_type); game->AddDelayedEvent(P,game_event_type,timestamp,sender); }break; case GE_INFO_TRANSFER: case GE_WPN_STATE_CHANGE: case GE_ZONE_STATE_CHANGE: case GE_ACTOR_JUMPING: case GEG_PLAYER_PLAY_HEADSHOT_PARTICLE: case GEG_PLAYER_ATTACH_HOLDER: case GEG_PLAYER_DETACH_HOLDER: case GEG_PLAYER_ITEM2SLOT: case GEG_PLAYER_ITEM2BELT: case GEG_PLAYER_ITEM2RUCK: case GE_GRENADE_EXPLODE: { SendBroadcast (BroadcastCID,P,MODE); }break; case GEG_PLAYER_ACTIVATEARTEFACT: { Process_event_activate (P,sender,timestamp,destination,P.r_u16(), true); break; }; case GE_INV_ACTION: { xrClientData* CL = ID_to_client(sender); if (CL) CL->net_Ready = TRUE; if (SV_Client) SendTo(SV_Client->ID, P, net_flags(TRUE, TRUE)); }break; case GE_RESPAWN: { CSE_Abstract* E = receiver; if (E) { R_ASSERT (E->s_flags.is(M_SPAWN_OBJECT_PHANTOM)); svs_respawn R; R.timestamp = timestamp + E->RespawnTime*1000; R.phantom = destination; q_respawn.insert (R); } } break; case GE_TRADE_BUY: case GE_OWNERSHIP_TAKE: { Process_event_ownership (P,sender,timestamp,destination); VERIFY (verify_entities()); }break; case GE_OWNERSHIP_TAKE_MP_FORCED: { Process_event_ownership (P,sender,timestamp,destination,TRUE); VERIFY (verify_entities()); }break; case GE_TRADE_SELL: case GE_OWNERSHIP_REJECT: case GE_LAUNCH_ROCKET: { Process_event_reject (P,sender,timestamp,destination,P.r_u16()); VERIFY (verify_entities()); }break; case GE_DESTROY: { Process_event_destroy (P,sender,timestamp,destination, NULL); VERIFY (verify_entities()); } break; case GE_TRANSFER_AMMO: { u16 id_entity; P.r_u16 (id_entity); CSE_Abstract* e_parent = receiver; // кто забирает (для своих нужд) CSE_Abstract* e_entity = game->get_entity_from_eid (id_entity); // кто отдает if (!e_entity) break; if (0xffff != e_entity->ID_Parent) break; // this item already taken xrClientData* c_parent = e_parent->owner; xrClientData* c_from = ID_to_client (sender); R_ASSERT (c_from == c_parent); // assure client ownership of event // Signal to everyone (including sender) SendBroadcast (BroadcastCID,P,MODE); // Perfrom real destroy entity_Destroy (e_entity ); VERIFY (verify_entities()); } break; case GE_HIT: case GE_HIT_STATISTIC: { P.r_pos -=2; if (type == GE_HIT_STATISTIC) { P.B.count -= 4; P.w_u32(sender.value()); }; game->AddDelayedEvent(P,GAME_EVENT_ON_HIT, 0, ClientID() ); } break; case GE_ASSIGN_KILLER: { u16 id_src; P.r_u16 (id_src); CSE_Abstract *e_dest = receiver; // кто умер // this is possible when hit event is sent before destroy event if (!e_dest) break; CSE_ALifeCreatureAbstract *creature = smart_cast<CSE_ALifeCreatureAbstract*>(e_dest); if (creature) creature->set_killer_id( id_src ); // Msg ("[%d][%s] killed [%d][%s]",id_src,id_src==u16(-1) ? "UNKNOWN" : game->get_entity_from_eid(id_src)->name_replace(),id_dest,e_dest->name_replace()); break; } case GE_CHANGE_VISUAL: { CSE_Visual* visual = smart_cast<CSE_Visual*>(receiver); VERIFY(visual); string256 tmp; P.r_stringZ (tmp); visual->set_visual (tmp); }break; case GE_DIE: { // Parse message u16 id_dest = destination, id_src; P.r_u16 (id_src); xrClientData *l_pC = ID_to_client(sender); VERIFY (game && l_pC); #ifndef MASTER_GOLD if ((game->Type() != eGameIDSingle) && l_pC && l_pC->owner) { Msg ("* [%2d] killed by [%2d] - sended by [%s:%2d]", id_dest, id_src, game->get_option_s(*l_pC->name,"name","Player"), l_pC->owner->ID); } #endif // #ifndef MASTER_GOLD CSE_Abstract* e_dest = receiver; // кто умер // this is possible when hit event is sent before destroy event if (!e_dest) break; #ifndef MASTER_GOLD if (game->Type() != eGameIDSingle) Msg ("* [%2d] is [%s:%s]", id_dest, *e_dest->s_name, e_dest->name_replace()); #endif // #ifndef MASTER_GOLD CSE_Abstract* e_src = game->get_entity_from_eid (id_src ); // кто убил if (!e_src) { xrClientData* C = (xrClientData*) game->get_client(id_src); if (C) e_src = C->owner; }; VERIFY (e_src); if (!e_src) { Msg("! ERROR: SV: src killer not exist."); return; } // R_ASSERT2 (e_dest && e_src, "Killer or/and being killed are offline or not exist at all :("); #ifndef MASTER_GOLD if (game->Type() != eGameIDSingle) Msg ("* [%2d] is [%s:%s]", id_src, *e_src->s_name, e_src->name_replace()); #endif // #ifndef MASTER_GOLD game->on_death (e_dest,e_src); xrClientData* c_src = e_src->owner; // клиент, чей юнит убил if (c_src->owner->ID == id_src) { // Main unit P.w_begin (M_EVENT); P.w_u32 (timestamp); P.w_u16 (type); P.w_u16 (destination); P.w_u16 (id_src); P.w_clientID (c_src->ID); } SendBroadcast (BroadcastCID,P,MODE); ////////////////////////////////////////////////////////////////////////// // if (game->Type() == eGameIDSingle) { P.w_begin (M_EVENT); P.w_u32 (timestamp); P.w_u16 (GE_KILL_SOMEONE); P.w_u16 (id_src); P.w_u16 (destination); SendTo (c_src->ID, P, net_flags(TRUE, TRUE)); } ////////////////////////////////////////////////////////////////////////// VERIFY (verify_entities()); } break; case GE_ADDON_ATTACH: case GE_ADDON_DETACH: case GE_CHANGE_POS: { SendTo(SV_Client->ID, P, net_flags(TRUE, TRUE)); }break; case GE_INSTALL_UPGRADE: { shared_str upgrade_id; P.r_stringZ ( upgrade_id ); CSE_ALifeInventoryItem* iitem = smart_cast<CSE_ALifeInventoryItem*>( receiver ); if ( !iitem ) { break; } iitem->add_upgrade ( upgrade_id ); }break; case GEG_PLAYER_DISABLE_SPRINT: case GEG_PLAYER_WEAPON_HIDE_STATE: { SendTo (SV_Client->ID, P, net_flags(TRUE, TRUE)); # ifdef SLOW_VERIFY_ENTITIES VERIFY (verify_entities()); # endif }break; case GEG_PLAYER_ACTIVATE_SLOT: case GEG_PLAYER_ITEM_EAT: { SendTo(SV_Client->ID, P, net_flags(TRUE, TRUE)); # ifdef SLOW_VERIFY_ENTITIES VERIFY (verify_entities()); # endif }break; case GEG_PLAYER_ITEM_SELL: { game->OnPlayer_Sell_Item(sender, P); }break; case GE_TELEPORT_OBJECT: { game->teleport_object (P,destination); }break; case GE_ADD_RESTRICTION: { game->add_restriction (P,destination); }break; case GE_REMOVE_RESTRICTION: { game->remove_restriction(P,destination); }break; case GE_REMOVE_ALL_RESTRICTIONS: { game->remove_all_restrictions(P,destination); }break; case GE_MONEY: { CSE_Abstract *e_dest = receiver; CSE_ALifeTraderAbstract* pTa = smart_cast<CSE_ALifeTraderAbstract*>(e_dest); pTa->m_dwMoney = P.r_u32(); }break; case GE_FREEZE_OBJECT: break; default: R_ASSERT2 (0,"Game Event not implemented!!!"); break; } }
bool Interactor2DRegionEdit::ProcessMouseDownEvent( wxMouseEvent& event, RenderView* renderview ) { RenderView2D* view = ( RenderView2D* )renderview; // UpdateCursor( event, view ); if ( event.LeftDown() ) { // if ( event.CmdDown() ) // return Interactor2D::ProcessMouseDownEvent( event, renderview ); LayerCollection* lc = MainWindow::GetMainWindowPointer()->GetLayerCollectionManager()->GetLayerCollection( "MRI" ); LayerMRI* mri = ( LayerMRI* )lc->GetActiveLayer(); if ( (!mri || !mri->IsVisible()) ) //&& ( event.CmdDown() || m_nAction == EM_Polyline ) ) { SendBroadcast( "MRINotVisible", this ); } else if ( !mri->IsEditable() ) //&& ( event.CmdDown() || m_nAction == EM_Polyline ) ) { SendBroadcast( "MRINotEditable", this ); } else { m_nMousePosX = event.GetX(); m_nMousePosY = event.GetY(); double ras[3]; view->MousePositionToRAS( m_nMousePosX, m_nMousePosY, ras ); if ( m_nAction == EM_Freehand ) //&& ( event.CmdDown() ) ) { mri->SaveForUndo( view->GetViewPlane() ); if ( event.CmdDown() ) { mri->FloodFillByRAS( ras, view->GetViewPlane(), !event.ShiftDown() ); } else { m_bEditing = true; mri->SetVoxelByRAS( ras, view->GetViewPlane(), !event.ShiftDown() ); } } else if ( m_nAction == EM_Fill ) //&& ( event.CmdDown() ) ) { mri->SaveForUndo( view->GetViewPlane() ); mri->FloodFillByRAS( ras, view->GetViewPlane(), !event.ShiftDown() ); } else if ( m_nAction == EM_Polyline ) { m_bEditing = true; double ras2[3]; view->GetCursor2D()->GetPosition( ras2 ); view->GetCursor2D()->SetPosition( ras ); view->GetCursor2D()->SetPosition2( ras ); if ( m_dPolylinePoints.size() > 0 ) { mri->SetVoxelByRAS( ras, ras2, view->GetViewPlane(), !event.ShiftDown() ); } else { mri->SaveForUndo( view->GetViewPlane() ); m_dPolylinePoints.push_back( ras[0] ); m_dPolylinePoints.push_back( ras[1] ); m_dPolylinePoints.push_back( ras[2] ); } if ( view->GetCapture() == view ) view->ReleaseMouse(); view->CaptureMouse(); } else return Interactor2D::ProcessMouseDownEvent( event, renderview ); } return false; } else if ( m_bEditing ) { m_bEditing = false; if ( m_nAction == EM_Polyline ) { if ( event.MiddleDown() ) { view->GetCursor2D()->Update(); view->NeedRedraw(); } else if ( event.RightDown() ) { if ( m_dPolylinePoints.size() > 0 ) { LayerCollection* lc = MainWindow::GetMainWindowPointer()->GetLayerCollection( "MRI" ); LayerMRI* mri = ( LayerMRI* )lc->GetActiveLayer(); double ras1[3] = { m_dPolylinePoints[0], m_dPolylinePoints[1], m_dPolylinePoints[2] }; double ras2[3]; view->GetCursor2D()->GetPosition( ras2 ); view->GetCursor2D()->SetPosition2( ras2 ); view->GetCursor2D()->SetPosition( ras1 ); mri->SetVoxelByRAS( ras1, ras2, view->GetViewPlane(), !event.ShiftDown() ); } } } m_dPolylinePoints.clear(); if ( view->GetCapture() == view ) view->ReleaseMouse(); return false; } return Interactor2D::ProcessMouseDownEvent( event, renderview ); // pass down the event }
bool Interactor2DVolumeEdit::ProcessMouseDownEvent( wxMouseEvent& event, RenderView* renderview ) { RenderView2D* view = ( RenderView2D* )renderview; // UpdateCursor( event, view ); if ( event.LeftDown() || ( event.RightDown() && event.LeftIsDown() ) ) { if ( event.CmdDown() && event.ShiftDown() ) return Interactor2D::ProcessMouseDownEvent( event, renderview ); LayerCollection* lc = MainWindow::GetMainWindowPointer()->GetLayerCollectionManager()->GetLayerCollection( m_strLayerTypeName.c_str() ); LayerVolumeBase* mri = ( LayerVolumeBase* )lc->GetActiveLayer(); if ( (!mri || !mri->IsVisible()) ) //&& ( event.CmdDown() || m_nAction == EM_Polyline ) ) { SendBroadcast( m_strLayerTypeName + "NotVisible", this ); } else if ( !mri->IsEditable() ) //&& ( event.CmdDown() || m_nAction == EM_Polyline ) ) { SendBroadcast( m_strLayerTypeName + "NotEditable", this ); } else if ( m_strLayerTypeName == "MRI" && ((LayerMRI*)mri)->IsTransformed() ) { SendBroadcast( m_strLayerTypeName + "NotEditableForTransformation", this ); } else { m_nMousePosX = event.GetX(); m_nMousePosY = event.GetY(); double ras[3]; view->MousePositionToRAS( m_nMousePosX, m_nMousePosY, ras ); if ( m_nAction == EM_Freehand ) //&& ( event.CmdDown() ) ) { mri->SaveForUndo( view->GetViewPlane() ); if ( event.CmdDown() ) { mri->FloodFillByRAS( ras, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() ); } else { m_bEditing = true; mri->SetVoxelByRAS( ras, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() ); } } else if ( m_nAction == EM_Fill ) //&& ( event.CmdDown() ) ) { mri->SaveForUndo( view->GetViewPlane() ); mri->FloodFillByRAS( ras, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() ); } else if ( m_nAction == EM_Polyline || m_nAction == EM_Livewire ) { mri->SaveForUndo( view->GetViewPlane() ); if ( event.CmdDown() ) { mri->FloodFillByRAS( ras, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() ); } else { m_bEditing = true; double ras2[3]; view->GetCursor2D()->ClearInterpolationPoints(); view->GetCursor2D()->GetPosition( ras2 ); view->GetCursor2D()->SetPosition( ras ); view->GetCursor2D()->SetPosition2( ras ); if ( m_dPolylinePoints.size() > 0 ) { if ( m_nAction == EM_Polyline ) mri->SetVoxelByRAS( ras, ras2, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() ); else mri->SetLiveWireByRAS( ras, ras2, view->GetViewPlane() ); } else { // mri->SaveForUndo( view->GetViewPlane() ); m_dPolylinePoints.push_back( ras[0] ); m_dPolylinePoints.push_back( ras[1] ); m_dPolylinePoints.push_back( ras[2] ); view->GetCursor2D()->SetPosition( ras ); } if ( view->GetCapture() == view ) view->ReleaseMouse(); view->CaptureMouse(); } } else if ( m_nAction == EM_ColorPicker && mri->IsTypeOf( "MRI" ) ) { if ( event.CmdDown() ) { mri->SaveForUndo( view->GetViewPlane() ); mri->FloodFillByRAS( ras, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() ); } else { double dValue = ((LayerMRI*)mri)->GetVoxelValue( ras ); if ( dValue != 0 ) { mri->SetFillValue( (float)dValue ); mri->SendBroadcast( "LayerActorUpdated", mri ); } } } else if ( m_nAction == EM_Contour && mri->IsTypeOf( "MRI" ) ) { LayerMRI* mri_ref = (LayerMRI*)MainWindow::GetMainWindowPointer()->GetBrushProperty()->GetReferenceLayer(); if ( !mri_ref ) { SendBroadcast( m_strLayerTypeName + "ReferenceNotSet", this ); return false; } Contour2D* c2d = view->GetContour2D(); if ( event.CmdDown() && event.AltDown() ) { double dValue = mri_ref->GetVoxelValue( ras ); if ( dValue != 0 ) { m_bEditing = true; c2d->SetInput( mri_ref->GetSliceImageData( view->GetViewPlane() ), dValue, ras[view->GetViewPlane()], mri_ref->GetActiveFrame() ); c2d->SetVisible( true ); view->NeedRedraw(); } else if ( c2d->IsVisible() ) { m_bEditing = true; } } else if ( event.CmdDown() && !event.AltDown() ) { mri->SaveForUndo( view->GetViewPlane() ); ((LayerMRI*)mri)->FloodFillByContour2D( ras, c2d ); } else if ( event.ShiftDown() ) { m_bEditing = true; c2d->RemoveLine( ras, ras ); view->NeedRedraw(); } else { m_bEditing = true; c2d->AddLine( ras, ras ); view->NeedRedraw(); } } else return Interactor2D::ProcessMouseDownEvent( event, renderview ); } return false; } else if ( m_bEditing ) { m_bEditing = false; if ( m_nAction == EM_Polyline || m_nAction == EM_Livewire ) { if ( event.MiddleDown() ) { view->GetCursor2D()->Update(); view->NeedRedraw(); } else if ( event.RightDown() ) { if ( m_dPolylinePoints.size() > 0 && m_nAction == EM_Polyline ) { LayerCollection* lc = MainWindow::GetMainWindowPointer()->GetLayerCollection( m_strLayerTypeName.c_str() ); LayerVolumeBase* mri = ( LayerVolumeBase* )lc->GetActiveLayer(); double ras1[3] = { m_dPolylinePoints[0], m_dPolylinePoints[1], m_dPolylinePoints[2] }; double ras2[3]; view->GetCursor2D()->GetPosition( ras2 ); view->GetCursor2D()->SetPosition2( ras2 ); view->GetCursor2D()->SetPosition( ras1 ); mri->SetVoxelByRAS( ras1, ras2, view->GetViewPlane(), !event.ShiftDown() ); } else { // mri->SetLiveWireByRAS( ras1, ras2, view->GetViewPlane() ); view->GetCursor2D()->Update(); view->NeedRedraw(); } } } m_dPolylinePoints.clear(); if ( view->GetCapture() == view ) view->ReleaseMouse(); return false; } return Interactor2D::ProcessMouseDownEvent( event, renderview ); // pass down the event }
void MainWindow::RecvBroadcastInfo() { qDebug(__func__); while(udpsocket->hasPendingDatagrams()) { QByteArray data; int type; QDataStream in(&data, QIODevice::ReadOnly); data.resize(udpsocket->pendingDatagramSize()); udpsocket->readDatagram(data.data(), data.size()); in>>type; in>>rfileInfo; in>>rfriendInfo; if(type == 4 || type == 5) { qDebug("ddddddddddddddddddddddddddddd"); RecvFileInfo(rfileInfo,type); return; } if(type == 6) { SysTrayIconTwinkle(); } qDebug()<<"Recv::"<<rfriendInfo.logHostIp; qDebug()<<"Recv::"<<type; for(vector<PersonLoginInfo>::iterator it = LoginInfo.begin(); it!=LoginInfo.end(); ++it) { if(it->logHostIp == rfriendInfo.logHostIp) { if(type == 1) { LoginInfo.erase(it); return; } else if(type == 3) { LoginInfo.erase(it); LoginInfo.push_back(rfriendInfo); return; } else { return; } } } if(type != 1) //判断是否为下线广播 { list->AddBuddy(rfriendInfo); QString name = rfriendInfo.logInfo.userName == "" ? rfriendInfo.logHostName : rfriendInfo.logInfo.userName; emit initMsg(name,rfriendInfo.logHostIp); LoginInfo.push_back(rfriendInfo); SendBroadcast(rfriendInfo.logHostIp,2); } } }
void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) { void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgID, pUnpacker); CPlayer *pPlayer = m_apPlayers[ClientID]; if(!pRawMsg) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgID), MsgID, m_NetObjHandler.FailedMsgOn()); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf); return; } if(MsgID == NETMSGTYPE_CL_SAY) { CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg; int Team = pMsg->m_Team; if(Team) Team = pPlayer->GetTeam(); else Team = CGameContext::CHAT_ALL; if(g_Config.m_SvSpamprotection && pPlayer->m_Last_Chat && pPlayer->m_Last_Chat+Server()->TickSpeed() > Server()->Tick()) return; pPlayer->m_Last_Chat = Server()->Tick(); // check for invalid chars unsigned char *pMessage = (unsigned char *)pMsg->m_pMessage; while (*pMessage) { if(*pMessage < 32) *pMessage = ' '; pMessage++; } SendChat(ClientID, Team, pMsg->m_pMessage); } else if(MsgID == NETMSGTYPE_CL_CALLVOTE) { if(g_Config.m_SvSpamprotection && pPlayer->m_Last_VoteTry && pPlayer->m_Last_VoteTry+Server()->TickSpeed()*3 > Server()->Tick()) return; int64 Now = Server()->Tick(); pPlayer->m_Last_VoteTry = Now; if(pPlayer->GetTeam() == TEAM_SPECTATORS) { SendChatTarget(ClientID, "Spectators aren't allowed to start a vote."); return; } if(m_VoteCloseTime) { SendChatTarget(ClientID, "Wait for current vote to end before calling a new one."); return; } int Timeleft = pPlayer->m_Last_VoteCall + Server()->TickSpeed()*60 - Now; if(pPlayer->m_Last_VoteCall && Timeleft > 0) { char aChatmsg[512] = {0}; str_format(aChatmsg, sizeof(aChatmsg), "You must wait %d seconds before making another vote", (Timeleft/Server()->TickSpeed())+1); SendChatTarget(ClientID, aChatmsg); return; } char aChatmsg[512] = {0}; char aDesc[512] = {0}; char aCmd[512] = {0}; CNetMsg_Cl_CallVote *pMsg = (CNetMsg_Cl_CallVote *)pRawMsg; if(str_comp_nocase(pMsg->m_Type, "option") == 0) { CVoteOption *pOption = m_pVoteOptionFirst; while(pOption) { if(str_comp_nocase(pMsg->m_Value, pOption->m_aCommand) == 0) { str_format(aChatmsg, sizeof(aChatmsg), "'%s' called vote to change server option '%s'", Server()->ClientName(ClientID), pOption->m_aCommand); str_format(aDesc, sizeof(aDesc), "%s", pOption->m_aCommand); str_format(aCmd, sizeof(aCmd), "%s", pOption->m_aCommand); break; } pOption = pOption->m_pNext; } if(!pOption) { str_format(aChatmsg, sizeof(aChatmsg), "'%s' isn't an option on this server", pMsg->m_Value); SendChatTarget(ClientID, aChatmsg); return; } } else if(str_comp_nocase(pMsg->m_Type, "kick") == 0) { if(!g_Config.m_SvVoteKick) { SendChatTarget(ClientID, "Server does not allow voting to kick players"); return; } int KickID = str_toint(pMsg->m_Value); if(KickID < 0 || KickID >= MAX_CLIENTS || !m_apPlayers[KickID]) { SendChatTarget(ClientID, "Invalid client id to kick"); return; } if(KickID == ClientID) { SendChatTarget(ClientID, "You cant kick yourself"); return; } if(Server()->IsAuthed(KickID)) { SendChatTarget(ClientID, "You cant kick admins"); char aBufKick[128]; str_format(aBufKick, sizeof(aBufKick), "'%s' called for vote to kick you", Server()->ClientName(ClientID)); SendChatTarget(KickID, aBufKick); return; } const char *pReason = "No reason given"; for(const char *pStr = pMsg->m_Value; *pStr; ++pStr) { if(*pStr == ' ') { pReason = pStr+1; break; } } str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientID), Server()->ClientName(KickID), pReason); str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickID)); if (!g_Config.m_SvVoteKickBantime) str_format(aCmd, sizeof(aCmd), "kick %d Kicked by vote", KickID); else { char aBuf[64] = {0}; Server()->GetClientIP(KickID, aBuf, sizeof(aBuf)); str_format(aCmd, sizeof(aCmd), "ban %s %d Banned by vote", aBuf, g_Config.m_SvVoteKickBantime); } } if(aCmd[0]) { SendChat(-1, CGameContext::CHAT_ALL, aChatmsg); StartVote(aDesc, aCmd); pPlayer->m_Vote = 1; pPlayer->m_VotePos = m_VotePos = 1; m_VoteCreator = ClientID; pPlayer->m_Last_VoteCall = Now; } } else if(MsgID == NETMSGTYPE_CL_VOTE) { if(!m_VoteCloseTime) return; if(pPlayer->m_Vote == 0) { CNetMsg_Cl_Vote *pMsg = (CNetMsg_Cl_Vote *)pRawMsg; if(!pMsg->m_Vote) return; pPlayer->m_Vote = pMsg->m_Vote; pPlayer->m_VotePos = ++m_VotePos; m_VoteUpdate = true; } } else if (MsgID == NETMSGTYPE_CL_SETTEAM && !m_World.m_Paused) { CNetMsg_Cl_SetTeam *pMsg = (CNetMsg_Cl_SetTeam *)pRawMsg; if(pPlayer->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && pPlayer->m_Last_SetTeam && pPlayer->m_Last_SetTeam+Server()->TickSpeed()*3 > Server()->Tick())) return; // Switch team on given client and kill/respawn him if(m_pController->CanJoinTeam(pMsg->m_Team, ClientID)) { if(m_pController->CanChangeTeam(pPlayer, pMsg->m_Team)) { pPlayer->m_Last_SetTeam = Server()->Tick(); if(pPlayer->GetTeam() == TEAM_SPECTATORS || pMsg->m_Team == TEAM_SPECTATORS) m_VoteUpdate = true; pPlayer->SetTeam(pMsg->m_Team); (void)m_pController->CheckTeamBalance(); } else SendBroadcast("Teams must be balanced, please join other team", ClientID); } else { char aBuf[128]; str_format(aBuf, sizeof(aBuf), "Only %d active players are allowed", g_Config.m_SvMaxClients-g_Config.m_SvSpectatorSlots); SendBroadcast(aBuf, ClientID); } } else if (MsgID == NETMSGTYPE_CL_CHANGEINFO || MsgID == NETMSGTYPE_CL_STARTINFO) { CNetMsg_Cl_ChangeInfo *pMsg = (CNetMsg_Cl_ChangeInfo *)pRawMsg; if(g_Config.m_SvSpamprotection && pPlayer->m_Last_ChangeInfo && pPlayer->m_Last_ChangeInfo+Server()->TickSpeed()*5 > Server()->Tick()) return; pPlayer->m_Last_ChangeInfo = Server()->Tick(); pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet; // copy old name char aOldName[MAX_NAME_LENGTH]; str_copy(aOldName, Server()->ClientName(ClientID), MAX_NAME_LENGTH); Server()->SetClientName(ClientID, pMsg->m_pName); if(MsgID == NETMSGTYPE_CL_CHANGEINFO && str_comp(aOldName, Server()->ClientName(ClientID)) != 0) { char aChatText[256]; str_format(aChatText, sizeof(aChatText), "'%s' changed name to '%s'", aOldName, Server()->ClientName(ClientID)); SendChat(-1, CGameContext::CHAT_ALL, aChatText); } // set skin str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); m_pController->OnPlayerInfoChange(pPlayer); if(MsgID == NETMSGTYPE_CL_STARTINFO) { // send vote options CNetMsg_Sv_VoteClearOptions ClearMsg; Server()->SendPackMsg(&ClearMsg, MSGFLAG_VITAL, ClientID); CVoteOption *pCurrent = m_pVoteOptionFirst; while(pCurrent) { CNetMsg_Sv_VoteOption OptionMsg; OptionMsg.m_pCommand = pCurrent->m_aCommand; Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID); pCurrent = pCurrent->m_pNext; } // send tuning parameters to client SendTuningParams(ClientID); // CNetMsg_Sv_ReadyToEnter m; Server()->SendPackMsg(&m, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID); } } else if (MsgID == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused) { CNetMsg_Cl_Emoticon *pMsg = (CNetMsg_Cl_Emoticon *)pRawMsg; if(g_Config.m_SvSpamprotection && pPlayer->m_Last_Emote && pPlayer->m_Last_Emote+Server()->TickSpeed()*3 > Server()->Tick()) return; pPlayer->m_Last_Emote = Server()->Tick(); SendEmoticon(ClientID, pMsg->m_Emoticon); } else if (MsgID == NETMSGTYPE_CL_KILL && !m_World.m_Paused) { if(pPlayer->m_Last_Kill && pPlayer->m_Last_Kill+Server()->TickSpeed()*3 > Server()->Tick()) return; pPlayer->m_Last_Kill = Server()->Tick(); pPlayer->KillCharacter(WEAPON_SELF); pPlayer->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()*3; } }
void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) { void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgID, pUnpacker); CPlayer *pPlayer = m_apPlayers[ClientID]; if(!pRawMsg) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgID), MsgID, m_NetObjHandler.FailedMsgOn()); Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf); return; } if(MsgID == NETMSGTYPE_CL_SAY) { CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg; int Team = pMsg->m_Team; if(Team) Team = pPlayer->GetTeam(); else Team = CGameContext::CHAT_ALL; if(g_Config.m_SvSpamprotection && pPlayer->m_LastChat && pPlayer->m_LastChat+Server()->TickSpeed() > Server()->Tick()) return; pPlayer->m_LastChat = Server()->Tick(); // check for invalid chars unsigned char *pMessage = (unsigned char *)pMsg->m_pMessage; while (*pMessage) { if(*pMessage < 32) *pMessage = ' '; pMessage++; } SendChat(ClientID, Team, pMsg->m_pMessage); } else if(MsgID == NETMSGTYPE_CL_CALLVOTE) { if(g_Config.m_SvSpamprotection && pPlayer->m_LastVoteTry && pPlayer->m_LastVoteTry+Server()->TickSpeed()*3 > Server()->Tick()) return; int64 Now = Server()->Tick(); pPlayer->m_LastVoteTry = Now; if(pPlayer->GetTeam() == TEAM_SPECTATORS) { SendChatTarget(ClientID, "Spectators aren't allowed to start a vote."); return; } if(m_VoteCloseTime) { SendChatTarget(ClientID, "Wait for current vote to end before calling a new one."); return; } int Timeleft = pPlayer->m_LastVoteCall + Server()->TickSpeed()*60 - Now; if(pPlayer->m_LastVoteCall && Timeleft > 0) { char aChatmsg[512] = {0}; str_format(aChatmsg, sizeof(aChatmsg), "You must wait %d seconds before making another vote", (Timeleft/Server()->TickSpeed())+1); SendChatTarget(ClientID, aChatmsg); return; } char aChatmsg[512] = {0}; char aDesc[VOTE_DESC_LENGTH] = {0}; char aCmd[VOTE_CMD_LENGTH] = {0}; CNetMsg_Cl_CallVote *pMsg = (CNetMsg_Cl_CallVote *)pRawMsg; const char *pReason = pMsg->m_Reason[0] ? pMsg->m_Reason : "No reason given"; if(str_comp_nocase(pMsg->m_Type, "option") == 0) { CVoteOptionServer *pOption = m_pVoteOptionFirst; while(pOption) { if(str_comp_nocase(pMsg->m_Value, pOption->m_aDescription) == 0) { str_format(aChatmsg, sizeof(aChatmsg), "'%s' called vote to change server option '%s' (%s)", Server()->ClientName(ClientID), pOption->m_aDescription, pReason); str_format(aDesc, sizeof(aDesc), "%s", pOption->m_aDescription); str_format(aCmd, sizeof(aCmd), "%s", pOption->m_aCommand); break; } pOption = pOption->m_pNext; } if(!pOption) { str_format(aChatmsg, sizeof(aChatmsg), "'%s' isn't an option on this server", pMsg->m_Value); SendChatTarget(ClientID, aChatmsg); return; } } else if(str_comp_nocase(pMsg->m_Type, "kick") == 0) { if(!g_Config.m_SvVoteKick) { SendChatTarget(ClientID, "Server does not allow voting to kick players"); return; } if(g_Config.m_SvVoteKickMin) { int PlayerNum = 0; for(int i = 0; i < MAX_CLIENTS; ++i) if(m_apPlayers[i] && m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS) ++PlayerNum; if(PlayerNum < g_Config.m_SvVoteKickMin) { str_format(aChatmsg, sizeof(aChatmsg), "Kick voting requires %d players on the server", g_Config.m_SvVoteKickMin); SendChatTarget(ClientID, aChatmsg); return; } } int KickID = str_toint(pMsg->m_Value); if(KickID < 0 || KickID >= MAX_CLIENTS || !m_apPlayers[KickID]) { SendChatTarget(ClientID, "Invalid client id to kick"); return; } if(KickID == ClientID) { SendChatTarget(ClientID, "You cant kick yourself"); return; } if(Server()->IsAuthed(KickID)) { SendChatTarget(ClientID, "You cant kick admins"); char aBufKick[128]; str_format(aBufKick, sizeof(aBufKick), "'%s' called for vote to kick you", Server()->ClientName(ClientID)); SendChatTarget(KickID, aBufKick); return; } str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientID), Server()->ClientName(KickID), pReason); str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickID)); if (!g_Config.m_SvVoteKickBantime) str_format(aCmd, sizeof(aCmd), "kick %d Kicked by vote", KickID); else { char aAddrStr[NETADDR_MAXSTRSIZE] = {0}; Server()->GetClientAddr(KickID, aAddrStr, sizeof(aAddrStr)); str_format(aCmd, sizeof(aCmd), "ban %s %d Banned by vote", aAddrStr, g_Config.m_SvVoteKickBantime); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aCmd); } } else if(str_comp_nocase(pMsg->m_Type, "spectate") == 0) { if(!g_Config.m_SvVoteSpectate) { SendChatTarget(ClientID, "Server does not allow voting to move players to spectators"); return; } int SpectateID = str_toint(pMsg->m_Value); if(SpectateID < 0 || SpectateID >= MAX_CLIENTS || !m_apPlayers[SpectateID] || m_apPlayers[SpectateID]->GetTeam() == TEAM_SPECTATORS) { SendChatTarget(ClientID, "Invalid client id to move"); return; } if(SpectateID == ClientID) { SendChatTarget(ClientID, "You cant move yourself"); return; } str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to move '%s' to spectators (%s)", Server()->ClientName(ClientID), Server()->ClientName(SpectateID), pReason); str_format(aDesc, sizeof(aDesc), "move '%s' to spectators", Server()->ClientName(SpectateID)); str_format(aCmd, sizeof(aCmd), "set_team %d -1", SpectateID); } if(aCmd[0]) { SendChat(-1, CGameContext::CHAT_ALL, aChatmsg); StartVote(aDesc, aCmd, pReason); pPlayer->m_Vote = 1; pPlayer->m_VotePos = m_VotePos = 1; m_VoteCreator = ClientID; pPlayer->m_LastVoteCall = Now; } } else if(MsgID == NETMSGTYPE_CL_VOTE) { if(!m_VoteCloseTime) return; if(pPlayer->m_Vote == 0) { CNetMsg_Cl_Vote *pMsg = (CNetMsg_Cl_Vote *)pRawMsg; if(!pMsg->m_Vote) return; pPlayer->m_Vote = pMsg->m_Vote; pPlayer->m_VotePos = ++m_VotePos; m_VoteUpdate = true; } } else if (MsgID == NETMSGTYPE_CL_SETTEAM && !m_World.m_Paused) { CNetMsg_Cl_SetTeam *pMsg = (CNetMsg_Cl_SetTeam *)pRawMsg; if(pPlayer->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && pPlayer->m_LastSetTeam && pPlayer->m_LastSetTeam+Server()->TickSpeed()*3 > Server()->Tick())) return; // Switch team on given client and kill/respawn him if(m_pController->CanJoinTeam(pMsg->m_Team, ClientID)) { if(m_pController->CanChangeTeam(pPlayer, pMsg->m_Team)) { pPlayer->m_LastSetTeam = Server()->Tick(); if(pPlayer->GetTeam() == TEAM_SPECTATORS || pMsg->m_Team == TEAM_SPECTATORS) m_VoteUpdate = true; pPlayer->SetTeam(pMsg->m_Team); (void)m_pController->CheckTeamBalance(); } else SendBroadcast("Teams must be balanced, please join other team", ClientID); } else { char aBuf[128]; str_format(aBuf, sizeof(aBuf), "Only %d active players are allowed", g_Config.m_SvMaxClients-g_Config.m_SvSpectatorSlots); SendBroadcast(aBuf, ClientID); } } else if (MsgID == NETMSGTYPE_CL_SETSPECTATORMODE && !m_World.m_Paused) { CNetMsg_Cl_SetSpectatorMode *pMsg = (CNetMsg_Cl_SetSpectatorMode *)pRawMsg; if(pPlayer->GetTeam() != TEAM_SPECTATORS || pPlayer->m_SpectatorID == pMsg->m_SpectatorID || ClientID == pMsg->m_SpectatorID || (g_Config.m_SvSpamprotection && pPlayer->m_LastSetSpectatorMode && pPlayer->m_LastSetSpectatorMode+Server()->TickSpeed()*3 > Server()->Tick())) return; pPlayer->m_LastSetSpectatorMode = Server()->Tick(); if(pMsg->m_SpectatorID != SPEC_FREEVIEW && (!m_apPlayers[pMsg->m_SpectatorID] || m_apPlayers[pMsg->m_SpectatorID]->GetTeam() == TEAM_SPECTATORS)) SendChatTarget(ClientID, "Invalid spectator id used"); else pPlayer->m_SpectatorID = pMsg->m_SpectatorID; } else if (MsgID == NETMSGTYPE_CL_STARTINFO) { if(pPlayer->m_IsReady) return; CNetMsg_Cl_StartInfo *pMsg = (CNetMsg_Cl_StartInfo *)pRawMsg; pPlayer->m_LastChangeInfo = Server()->Tick(); // set start infos Server()->SetClientName(ClientID, pMsg->m_pName); Server()->SetClientClan(ClientID, pMsg->m_pClan); Server()->SetClientCountry(ClientID, pMsg->m_Country); str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet; m_pController->OnPlayerInfoChange(pPlayer); // send vote options CNetMsg_Sv_VoteClearOptions ClearMsg; Server()->SendPackMsg(&ClearMsg, MSGFLAG_VITAL, ClientID); CNetMsg_Sv_VoteOptionListAdd OptionMsg; int NumOptions = 0; OptionMsg.m_pDescription0 = ""; OptionMsg.m_pDescription1 = ""; OptionMsg.m_pDescription2 = ""; OptionMsg.m_pDescription3 = ""; OptionMsg.m_pDescription4 = ""; OptionMsg.m_pDescription5 = ""; OptionMsg.m_pDescription6 = ""; OptionMsg.m_pDescription7 = ""; OptionMsg.m_pDescription8 = ""; OptionMsg.m_pDescription9 = ""; OptionMsg.m_pDescription10 = ""; OptionMsg.m_pDescription11 = ""; OptionMsg.m_pDescription12 = ""; OptionMsg.m_pDescription13 = ""; OptionMsg.m_pDescription14 = ""; CVoteOptionServer *pCurrent = m_pVoteOptionFirst; while(pCurrent) { switch(NumOptions++) { case 0: OptionMsg.m_pDescription0 = pCurrent->m_aDescription; break; case 1: OptionMsg.m_pDescription1 = pCurrent->m_aDescription; break; case 2: OptionMsg.m_pDescription2 = pCurrent->m_aDescription; break; case 3: OptionMsg.m_pDescription3 = pCurrent->m_aDescription; break; case 4: OptionMsg.m_pDescription4 = pCurrent->m_aDescription; break; case 5: OptionMsg.m_pDescription5 = pCurrent->m_aDescription; break; case 6: OptionMsg.m_pDescription6 = pCurrent->m_aDescription; break; case 7: OptionMsg.m_pDescription7 = pCurrent->m_aDescription; break; case 8: OptionMsg.m_pDescription8 = pCurrent->m_aDescription; break; case 9: OptionMsg.m_pDescription9 = pCurrent->m_aDescription; break; case 10: OptionMsg.m_pDescription10 = pCurrent->m_aDescription; break; case 11: OptionMsg.m_pDescription11 = pCurrent->m_aDescription; break; case 12: OptionMsg.m_pDescription12 = pCurrent->m_aDescription; break; case 13: OptionMsg.m_pDescription13 = pCurrent->m_aDescription; break; case 14: { OptionMsg.m_pDescription14 = pCurrent->m_aDescription; OptionMsg.m_NumOptions = NumOptions; Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID); OptionMsg = CNetMsg_Sv_VoteOptionListAdd(); NumOptions = 0; OptionMsg.m_pDescription1 = ""; OptionMsg.m_pDescription2 = ""; OptionMsg.m_pDescription3 = ""; OptionMsg.m_pDescription4 = ""; OptionMsg.m_pDescription5 = ""; OptionMsg.m_pDescription6 = ""; OptionMsg.m_pDescription7 = ""; OptionMsg.m_pDescription8 = ""; OptionMsg.m_pDescription9 = ""; OptionMsg.m_pDescription10 = ""; OptionMsg.m_pDescription11 = ""; OptionMsg.m_pDescription12 = ""; OptionMsg.m_pDescription13 = ""; OptionMsg.m_pDescription14 = ""; } } pCurrent = pCurrent->m_pNext; } if(NumOptions > 0) { OptionMsg.m_NumOptions = NumOptions; Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID); NumOptions = 0; } // send tuning parameters to client SendTuningParams(ClientID); // client is ready to enter pPlayer->m_IsReady = true; CNetMsg_Sv_ReadyToEnter m; Server()->SendPackMsg(&m, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID); } else if (MsgID == NETMSGTYPE_CL_CHANGEINFO) { if(g_Config.m_SvSpamprotection && pPlayer->m_LastChangeInfo && pPlayer->m_LastChangeInfo+Server()->TickSpeed()*5 > Server()->Tick()) return; CNetMsg_Cl_ChangeInfo *pMsg = (CNetMsg_Cl_ChangeInfo *)pRawMsg; pPlayer->m_LastChangeInfo = Server()->Tick(); // set infos char aOldName[MAX_NAME_LENGTH]; str_copy(aOldName, Server()->ClientName(ClientID), sizeof(aOldName)); Server()->SetClientName(ClientID, pMsg->m_pName); if(str_comp(aOldName, Server()->ClientName(ClientID)) != 0) { char aChatText[256]; str_format(aChatText, sizeof(aChatText), "'%s' changed name to '%s'", aOldName, Server()->ClientName(ClientID)); SendChat(-1, CGameContext::CHAT_ALL, aChatText); } Server()->SetClientClan(ClientID, pMsg->m_pClan); Server()->SetClientCountry(ClientID, pMsg->m_Country); str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet; m_pController->OnPlayerInfoChange(pPlayer); } else if (MsgID == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused) { CNetMsg_Cl_Emoticon *pMsg = (CNetMsg_Cl_Emoticon *)pRawMsg; if(g_Config.m_SvSpamprotection && pPlayer->m_LastEmote && pPlayer->m_LastEmote+Server()->TickSpeed()*3 > Server()->Tick()) return; pPlayer->m_LastEmote = Server()->Tick(); SendEmoticon(ClientID, pMsg->m_Emoticon); } else if (MsgID == NETMSGTYPE_CL_KILL && !m_World.m_Paused) { if(pPlayer->m_LastKill && pPlayer->m_LastKill+Server()->TickSpeed()*3 > Server()->Tick()) return; pPlayer->m_LastKill = Server()->Tick(); pPlayer->KillCharacter(WEAPON_SELF); } }
void xrServer::Process_event_destroy (NET_Packet& P, ClientID sender, u32 time, u16 ID, NET_Packet* pEPack) { u32 MODE = net_flags(TRUE,TRUE); // Parse message u16 id_dest = ID; #ifdef DEBUG if( dbg_net_Draw_Flags.test( dbg_destroy ) ) Msg ("sv destroy object %s [%d]", ent_name_safe(id_dest).c_str(), Device.dwFrame); #endif CSE_Abstract* e_dest = game->get_entity_from_eid (id_dest); // кто должен быть уничтожен if (!e_dest) { #ifndef MASTER_GOLD Msg ("! SV:ge_destroy: [%d] not found on server",id_dest); #endif // #ifndef MASTER_GOLD return; }; R_ASSERT (e_dest); xrClientData *c_dest = e_dest->owner; // клиент, чей юнит R_ASSERT (c_dest); xrClientData *c_from = ID_to_client(sender); // клиент, кто прислал R_ASSERT (c_dest == c_from); // assure client ownership of event u16 parent_id = e_dest->ID_Parent; #ifdef MP_LOGGING Msg("- SV: Process destroy: parent [%d] item [%d][%s]", parent_id, id_dest, e_dest->name()); #endif //#ifdef MP_LOGGING //--------------------------------------------- NET_Packet P2, *pEventPack = pEPack; P2.w_begin (M_EVENT_PACK); //--------------------------------------------- // check if we have children if (!e_dest->children.empty()) { if (!pEventPack) pEventPack = &P2; while (!e_dest->children.empty()) Process_event_destroy (P,sender,time,*e_dest->children.begin(), pEventPack); }; if (0xffff == parent_id && NULL == pEventPack) { SendBroadcast (BroadcastCID,P,MODE); } else { NET_Packet tmpP; if (0xffff != parent_id && Process_event_reject(P,sender,time,parent_id,ID,false)) { game->u_EventGen(tmpP, GE_OWNERSHIP_REJECT, parent_id); tmpP.w_u16(id_dest); tmpP.w_u8(1); if (!pEventPack) pEventPack = &P2; pEventPack->w_u8(u8(tmpP.B.count)); pEventPack->w(&tmpP.B.data, tmpP.B.count); }; game->u_EventGen(tmpP, GE_DESTROY, id_dest); pEventPack->w_u8(u8(tmpP.B.count)); pEventPack->w(&tmpP.B.data, tmpP.B.count); }; if (NULL == pEPack && NULL != pEventPack) { SendBroadcast (BroadcastCID, *pEventPack, MODE); } // Everything OK, so perform entity-destroy if (e_dest->m_bALifeControl && ai().get_alife()) { game_sv_Single *_game = smart_cast<game_sv_Single*>(game); VERIFY (_game); if (ai().alife().objects().object(id_dest,true)) _game->alife().release (e_dest,false); } if (game) game->OnDestroyObject (e_dest->ID); entity_Destroy (e_dest); }
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); if (CL) { CL->net_Ready = TRUE; CL->ps->DeathTime = Device.dwTimeGlobal; game->OnPlayerConnectFinished(sender); }; game->signal_Syncronize (); VERIFY (verify_entities()); }break; case M_SWITCH_DISTANCE: { game->switch_distance (P,sender); VERIFY (verify_entities()); }break; case M_CHANGE_LEVEL: { if (game->change_level(P,sender)){ ClientID clientID;clientID.setBroadcast(); SendBroadcast (clientID,P,net_flags(TRUE,TRUE)); } VERIFY (verify_entities()); }break; case M_SAVE_GAME: { game->save_game (P,sender); VERIFY (verify_entities()); }break; case M_LOAD_GAME: { game->load_game (P,sender); ClientID clientID;clientID.setBroadcast(); SendBroadcast (clientID,P,net_flags(TRUE,TRUE)); VERIFY (verify_entities()); }break; case M_RELOAD_GAME: { ClientID clientID;clientID.setBroadcast(); SendBroadcast (clientID,P,net_flags(TRUE,TRUE)); VERIFY (verify_entities()); }break; case M_SAVE_PACKET: { Process_save (P,sender); VERIFY (verify_entities()); }break; case M_CLIENT_REQUEST_CONNECTION_DATA: { xrClientData* CL = ID_to_client (sender); OnCL_Connected (CL); }break; case M_CHAT_MESSAGE: { xrClientData *l_pC = ID_to_client(sender); OnChatMessage (&P, l_pC); }break; case M_CHANGE_LEVEL_GAME: { ClientID CID; CID.set (0xffffffff); SendBroadcast (CID,P,net_flags(TRUE,TRUE)); }break; case M_CL_AUTH: { game->AddDelayedEvent (P,GAME_EVENT_PLAYER_AUTH, 0, sender); }break; case M_PAUSE_GAME: { ClientID clientID;clientID.setBroadcast(); SendBroadcast (clientID,P,net_flags(TRUE,TRUE)); }break; case M_STATISTIC_UPDATE: { ClientID clientID;clientID.setBroadcast(); if (SV_Client) SendBroadcast (SV_Client->ID,P,net_flags(TRUE,TRUE)); else SendBroadcast (clientID,P,net_flags(TRUE,TRUE)); }break; case M_STATISTIC_UPDATE_RESPOND: { if (SV_Client) SendTo (SV_Client->ID, P, net_flags(TRUE, TRUE)); }break; case M_PLAYER_FIRE: { if (game) game->OnPlayerFire(sender, P); }break; } VERIFY (verify_entities()); csPlayers.Leave (); return IPureServer::OnMessage(P, sender); }