bool ChatMessage(LPCTSTR szSession, LPCTSTR szMessage) { CString sMe; CString sMyNick = GetNick( NULL ); if ( ! sMyNick.IsEmpty() ) sMe = sMyNick; else sMe = pluginMachineName; GCDEST gcdest = { modname, (LPSTR)szSession, GC_EVENT_MESSAGE }; GCEVENT gce = { sizeof( GCEVENT ), &gcdest, (LPCSTR)szMessage, (LPCSTR)(LPCTSTR)sMe, (LPCSTR)(LPCTSTR)sMe, NULL, NULL, TRUE, 0, 0, time() }; return ( CallServiceSync( MS_GC_EVENT, 0, (LPARAM)&gce ) == 0 ); }
void NickImpl::Delete() { Event::OnDelNick(&Event::DelNick::OnDelNick, this); if (this->GetAccount()) { /* Next: see if our core is still useful. */ std::vector<NickServ::Nick *> aliases = this->GetAccount()->GetRefs<NickServ::Nick *>(NickServ::nick); auto it = std::find(aliases.begin(), aliases.end(), this); if (it != aliases.end()) aliases.erase(it); if (aliases.empty()) { /* just me */ this->GetAccount()->Delete(); } else { /* Display updating stuff */ if (GetNick().equals_ci(this->GetAccount()->GetDisplay())) this->GetAccount()->SetDisplay(aliases[0]); } } return Serialize::Object::Delete(); }
bool ChatJoinMe(LPCTSTR szSession, LPCTSTR szGroup) { CString sMe; CString sMyNick = GetNick( NULL ); if ( ! sMyNick.IsEmpty() ) sMe = sMyNick; else sMe = pluginMachineName; GCDEST gcdest = { modname, (LPSTR)szSession, GC_EVENT_JOIN }; GCEVENT gce = { sizeof( GCEVENT ), &gcdest, NULL, (LPCSTR)(LPCTSTR)sMe, (LPCSTR)(LPCTSTR)sMe, (LPCSTR)szGroup, NULL, TRUE, 0, 0, NULL }; return ( CallServiceSync( MS_GC_EVENT, 0, (LPARAM)&gce ) == 0 ); }
QVariantMap RoomCLEntry::GetIdentifyingData () const { QVariantMap result; const QStringList& list = RH_-> GetRoomJID ().split ('@', QString::SkipEmptyParts); const QString& room = list.at (0); const QString& server = list.value (1); result ["HumanReadableName"] = QString ("%2@%3 (%1)") .arg (GetNick ()) .arg (room) .arg (server); result ["AccountID"] = Account_->GetAccountID (); result ["Nick"] = GetNick (); result ["Room"] = room; result ["Server"] = server; return result; }
bool User::ExecuteSayCommand(const std::string& cmd) const { if (TowxString(cmd).BeforeFirst(' ').Lower() == _T("/me")) { GetServer().DoActionPrivate(GetNick(), LSL::Util::AfterFirst(cmd, " ")); return true; } return false; }
virtual EModRet OnRaw(CString& sLine) { // Are we trying to get our primary nick and we caused this error? // :irc.server.net 433 mynick badnick :Nickname is already in use. if (m_pTimer && sLine.Token(1) == "433" && sLine.Token(3).Equals(GetNick())) return HALT; return CONTINUE; }
void CPlayer::MovePlayerToNearList ( CPlayer* pOther ) { OutputDebugLine ( SString ( "[Sync] ++ %s: Move %s to nearlist", GetNick (), pOther->GetNick () ) ); dassert ( !MapContains ( m_NearPlayerList, pOther ) && MapContains ( m_FarPlayerList, pOther ) ); SViewerInfo* pInfo = MapFind ( m_FarPlayerList, pOther ); MapSet ( m_NearPlayerList, pOther, *pInfo ); MapRemove ( m_FarPlayerList, pOther ); }
// // Dynamically increase the interval between near sync updates depending on stuffs // bool CPlayer::IsTimeToReceiveNearSyncFrom ( CPlayer* pOther, SNearInfo& nearInfo ) { int iZone = GetSyncZone ( pOther ); int iUpdateInterval = g_pBandwidthSettings->ZoneUpdateIntervals [ iZone ]; #if MTA_DEBUG if ( m_iLastZoneDebug != iZone ) { // Calc direction from our camera to the other player const CVector& vecOtherPosition = pOther->GetPosition (); CVector vecDirToOther = pOther->GetPosition () - m_vecCamPosition; // Get distance float fDistSq = vecDirToOther.LengthSquared (); // Get angle between camera direction and direction to other vecDirToOther.Normalize (); float fDot = m_vecCamFwd.DotProduct ( &vecDirToOther ); OutputDebugLine ( SString ( "Dist:%1.0f Dot:%0.3f %s SyncTo %s zone changing: %d -> %d [Interval:%d] CamPos:%1.0f,%1.0f,%1.0f CamFwd:%1.2f,%1.2f,%1.2f " ,sqrtf ( fDistSq ) ,fDot ,pOther->GetNick () ,GetNick () ,m_iLastZoneDebug ,iZone ,iUpdateInterval ,m_vecCamPosition.fX ,m_vecCamPosition.fY ,m_vecCamPosition.fZ ,m_vecCamFwd.fX ,m_vecCamFwd.fY ,m_vecCamFwd.fZ ) ); m_iLastZoneDebug = iZone; } #endif long long llTimeNow = GetModuleTickCount64 (); long long llNextUpdateTime = nearInfo.llLastUpdateTime + iUpdateInterval; if ( llNextUpdateTime > llTimeNow ) { g_pStats->puresync.llSkippedPacketsByZone[ iZone ]++; return false; } nearInfo.llLastUpdateTime = llTimeNow; g_pStats->puresync.llSentPacketsByZone[ iZone ]++; return true; }
void AddBotDialog::ShowAIOptions() { m_opts_list->DeleteAllItems(); m_opt_list_map.clear(); m_battle.CustomBattleOptions().loadAIOptions(m_battle.GetHostGameName(), GetAIType(), STD_STRING(GetNick())); AddMMOptionsToList(0, m_battle.CustomBattleOptions().GetAIOptionIndex(STD_STRING(GetNick()))); m_opts_list->SetColumnWidth(0, wxLIST_AUTOSIZE); m_opts_list->SetColumnWidth(1, wxLIST_AUTOSIZE); Layout(); SetSize(wxDefaultSize); }
void OnNick(const CNick& Nick, const CString& sNewNick, const vector<CChan*>& vChans) { if (sNewNick == m_pNetwork->GetIRCSock()->GetNick()) { // We are changing our own nick if (Nick.GetNick().Equals(GetNick())) { // We are changing our nick away from the conf setting. // Let's assume the user wants this and disable // this module (to avoid fighting nickserv). Disable(); } else if (sNewNick.Equals(GetNick())) { // We are changing our nick to the conf setting, // so we don't need that timer anymore. Disable(); } return; } // If the nick we want is free now, be fast and get the nick if (Nick.GetNick().Equals(GetNick())) { KeepNick(); } }
void AddBotDialog::ShowAIOptions() { if ( !usync().VersionSupports( IUnitSync::USYNC_GetSkirmishAI ) ) return; m_opts_list->DeleteAllItems(); m_opt_list_map.clear(); m_battle.CustomBattleOptions().loadAIOptions( m_battle.GetHostModName(), GetAIType(), GetNick() ); AddMMOptionsToList( 0, m_battle.CustomBattleOptions().GetAIOptionIndex( GetNick() ) ); m_opts_list->SetColumnWidth( 0, wxLIST_AUTOSIZE ); m_opts_list->SetColumnWidth( 1, wxLIST_AUTOSIZE ); Layout(); SetSize( wxDefaultSize ); }
CString& CUser::ExpandString(const CString& sStr, CString& sRet) const { CString sTime = CUtils::CTime(time(NULL), m_sTimezone); sRet = sStr; sRet.Replace("%user%", GetUserName()); sRet.Replace("%defnick%", GetNick()); sRet.Replace("%nick%", GetNick()); sRet.Replace("%altnick%", GetAltNick()); sRet.Replace("%ident%", GetIdent()); sRet.Replace("%realname%", GetRealName()); sRet.Replace("%vhost%", GetBindHost()); sRet.Replace("%bindhost%", GetBindHost()); sRet.Replace("%version%", CZNC::GetVersion()); sRet.Replace("%time%", sTime); sRet.Replace("%uptime%", CZNC::Get().GetUptime()); // The following lines do not exist. You must be on DrUgS! sRet.Replace("%znc%", "All your IRC are belong to ZNC"); // Chosen by fair zocchihedron dice roll by SilverLeo sRet.Replace("%rand%", "42"); return sRet; }
void AddToChannel(struct Channel *cptr, char *nick) { struct Luser *lptr; struct UserChannel *ptr; struct ChannelUser *ptr2; char *tmpnick; tmpnick = GetNick(nick); lptr = FindClient(tmpnick); if (!lptr || !cptr) return; ptr = (struct UserChannel *) MyMalloc(sizeof(struct UserChannel)); ptr->chptr = cptr; ptr->flags = 0; if ((nick[0] == '+') || (nick[1] == '+')) ptr->flags |= CH_VOICED; if ((nick[0] == '@') || (nick[1] == '@')) ptr->flags |= CH_OPPED; #ifdef HYBRID7 /* Add halfopped feature - Janos */ if ((nick[0] == '%') || (nick[1] == '%')) ptr->flags |= CH_HOPPED; #endif ptr->next = lptr->firstchan; lptr->firstchan = ptr; ptr2 = (struct ChannelUser *) MyMalloc(sizeof(struct ChannelUser)); ptr2->lptr = lptr; ptr2->flags = 0; if ((nick[0] == '+') || (nick[1] == '+')) ptr2->flags |= CH_VOICED; if ((nick[0] == '@') || (nick[1] == '@')) ptr2->flags |= CH_OPPED; #ifdef HYBRID7 /* Add halfopped feature - Janos */ if ((nick[0] == '%') || (nick[1] == '%')) ptr2->flags |= CH_HOPPED; #endif ptr2->next = cptr->firstuser; cptr->firstuser = ptr2; } /* AddToChannel() */
void GetAwayMsgThread(LPVOID param) { // Задержка чтобы миранда успела "переварить" ответ Sleep( 250 ); ContactData* data = (ContactData*)param; bool ret = false; bool bGroup = IsGroup( data->hContact ); CString sNick = GetNick( data->hContact ); if ( ! bGroup && ! sNick.IsEmpty() ) { ThreadEvent te = { CreateEvent( NULL, TRUE, FALSE, NULL ), data->cookie }; // Отмечаемся в карте ожидающих нитей { CLock oLock( pluginGuard ); pluginAwayThreadMap.SetAt( data->hContact, te ); } // Асинхронный запрос эвей-сообщения ret = pluginNetBIOS.AskAway( netbios_name( sNick, 0x03, false ) ); // Ожидание завершения (3 секунды) ret = ret && ( WaitForSingleObject( te.evt, 3000 ) == WAIT_OBJECT_0 ); // Очистка карты ожидающих нитей { CLock oLock( pluginGuard ); pluginAwayThreadMap.Lookup( data->hContact, te ); pluginAwayThreadMap.RemoveKey( data->hContact ); } CloseHandle( te.evt ); } if ( ! ret ) { // Уведомление о неудаче ProtoBroadcastAck (modname, data->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS /* ACKRESULT_FAILED */, data->cookie, (LPARAM)"" ); LOG( "Get away message failed" ); } delete data; }
void User::SetStatus(const UserStatus& status) { CommonUser::SetStatus(status); // If user is host of a game, then his in_game status tells if the game is on! if (m_battle != 0) { try { User& user = m_battle->GetFounder(); if (user.GetNick() == GetNick()) { m_battle->Update(""); } } catch (...) { } } m_statusicon_idx = icons().GetUserListStateIcon(GetStatus(), false, m_battle != 0); m_rankicon_idx = icons().GetRankIcon(GetStatus().rank); }
QString CUserInfoXmpp::GetShowName() { QString szText; switch(CGlobal::Instance()->GetRosterShowType()) { case CGlobal::E_ROSTER_SHOW_NICK: szText = GetNick(); if(!szText.isEmpty()) break; case CGlobal::E_ROSTER_SHOW_NAME: szText = GetName(); if(!szText.isEmpty()) break; case CGlobal::E_ROSTER_SHOW_JID: szText = GetId(); default: break; } return szText; }
// Assumes CSimControl::UpdatePuresyncSimPlayer is called soon after this function void CPlayer::MovePlayerToFarList ( CPlayer* pOther ) { OutputDebugLine ( SString ( "[Sync] -- %s: Move %s to farlist", GetNick (), pOther->GetNick () ) ); dassert ( MapContains ( m_NearPlayerList, pOther ) && !MapContains ( m_FarPlayerList, pOther ) ); SViewerInfo* pInfo = MapFind ( m_NearPlayerList, pOther ); #ifdef MTA_DEBUG dassert ( MapContains ( m_PureSyncSimSendList, pOther ) == pInfo->bInPureSyncSimSendList ); #endif if ( pInfo->bInPureSyncSimSendList ) { MapRemove ( m_PureSyncSimSendList, pOther ); m_bPureSyncSimSendListDirty = true; pInfo->bInPureSyncSimSendList = false; } MapSet ( m_FarPlayerList, pOther, *pInfo ); MapRemove ( m_NearPlayerList, pOther ); }
bool CUser::SendFile(const CString& sRemoteNick, const CString& sFileName, const CString& sModuleName) { CString sFullPath = CDir::ChangeDir(GetDLPath(), sFileName, CZNC::Get().GetHomePath()); CDCCSock* pSock = new CDCCSock(this, sRemoteNick, sFullPath, sModuleName); CFile* pFile = pSock->OpenFile(false); if (!pFile) { delete pSock; return false; } unsigned short uPort = CZNC::Get().GetManager().ListenRand("DCC::LISTEN::" + sRemoteNick, GetLocalDCCIP(), false, SOMAXCONN, pSock, 120); if (GetNick().Equals(sRemoteNick)) { PutUser(":" + GetStatusPrefix() + "[email protected] PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(GetLocalDCCIP())) + " " + CString(uPort) + " " + CString(pFile->GetSize()) + "\001"); } else { PutIRC("PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(GetLocalDCCIP())) + " " + CString(uPort) + " " + CString(pFile->GetSize()) + "\001"); } PutModule(sModuleName, "DCC -> [" + sRemoteNick + "][" + pFile->GetShortName() + "] - Attempting Send."); return true; }
CConfig CUser::ToConfig() { CConfig config; CConfig passConfig; CString sHash; switch (m_eHashType) { case HASH_NONE: sHash = "Plain"; break; case HASH_MD5: sHash = "MD5"; break; case HASH_SHA256: sHash = "SHA256"; break; } passConfig.AddKeyValuePair("Salt", m_sPassSalt); passConfig.AddKeyValuePair("Method", sHash); passConfig.AddKeyValuePair("Hash", GetPass()); config.AddSubConfig("Pass", "password", passConfig); config.AddKeyValuePair("Nick", GetNick()); config.AddKeyValuePair("AltNick", GetAltNick()); config.AddKeyValuePair("Ident", GetIdent()); config.AddKeyValuePair("RealName", GetRealName()); config.AddKeyValuePair("BindHost", GetBindHost()); config.AddKeyValuePair("DCCBindHost", GetDCCBindHost()); config.AddKeyValuePair("QuitMsg", GetQuitMsg()); if (CZNC::Get().GetStatusPrefix() != GetStatusPrefix()) config.AddKeyValuePair("StatusPrefix", GetStatusPrefix()); config.AddKeyValuePair("Skin", GetSkinName()); config.AddKeyValuePair("Language", GetLanguage()); config.AddKeyValuePair("ChanModes", GetDefaultChanModes()); config.AddKeyValuePair("Buffer", CString(GetBufferCount())); config.AddKeyValuePair("KeepBuffer", CString(KeepBuffer())); config.AddKeyValuePair("MultiClients", CString(MultiClients())); config.AddKeyValuePair("DenyLoadMod", CString(DenyLoadMod())); config.AddKeyValuePair("Admin", CString(IsAdmin())); config.AddKeyValuePair("DenySetBindHost", CString(DenySetBindHost())); config.AddKeyValuePair("TimestampFormat", GetTimestampFormat()); config.AddKeyValuePair("AppendTimestamp", CString(GetTimestampAppend())); config.AddKeyValuePair("PrependTimestamp", CString(GetTimestampPrepend())); config.AddKeyValuePair("TimezoneOffset", CString(m_fTimezoneOffset)); config.AddKeyValuePair("JoinTries", CString(m_uMaxJoinTries)); config.AddKeyValuePair("MaxJoins", CString(m_uMaxJoins)); config.AddKeyValuePair("IRCConnectEnabled", CString(GetIRCConnectEnabled())); // Allow Hosts if (!m_ssAllowedHosts.empty()) { for (set<CString>::iterator it = m_ssAllowedHosts.begin(); it != m_ssAllowedHosts.end(); ++it) { config.AddKeyValuePair("Allow", *it); } } // CTCP Replies if (!m_mssCTCPReplies.empty()) { for (MCString::const_iterator itb = m_mssCTCPReplies.begin(); itb != m_mssCTCPReplies.end(); ++itb) { config.AddKeyValuePair("CTCPReply", itb->first.AsUpper() + " " + itb->second); } } // Modules CModules& Mods = GetModules(); if (!Mods.empty()) { for (unsigned int a = 0; a < Mods.size(); a++) { CString sArgs = Mods[a]->GetArgs(); if (!sArgs.empty()) { sArgs = " " + sArgs; } config.AddKeyValuePair("LoadModule", Mods[a]->GetModName() + sArgs); } } // Networks for (unsigned int d = 0; d < m_vIRCNetworks.size(); d++) { CIRCNetwork *pNetwork = m_vIRCNetworks[d]; config.AddSubConfig("Network", pNetwork->GetName(), pNetwork->ToConfig()); } return config; }
bool CUser::WriteConfig(CFile& File) { File.Write("<User " + GetUserName().FirstLine() + ">\n"); if (m_eHashType != HASH_NONE) { CString sHash = "md5"; if (m_eHashType == HASH_SHA256) sHash = "sha256"; if (m_sPassSalt.empty()) { PrintLine(File, "Pass", sHash + "#" + GetPass()); } else { PrintLine(File, "Pass", sHash + "#" + GetPass() + "#" + m_sPassSalt + "#"); } } else { PrintLine(File, "Pass", "plain#" + GetPass()); } PrintLine(File, "Nick", GetNick()); PrintLine(File, "AltNick", GetAltNick()); PrintLine(File, "Ident", GetIdent()); PrintLine(File, "RealName", GetRealName()); PrintLine(File, "BindHost", GetBindHost()); PrintLine(File, "DCCBindHost", GetDCCBindHost()); PrintLine(File, "QuitMsg", GetQuitMsg()); if (CZNC::Get().GetStatusPrefix() != GetStatusPrefix()) PrintLine(File, "StatusPrefix", GetStatusPrefix()); PrintLine(File, "Skin", GetSkinName()); PrintLine(File, "ChanModes", GetDefaultChanModes()); PrintLine(File, "Buffer", CString(GetBufferCount())); PrintLine(File, "KeepBuffer", CString(KeepBuffer())); PrintLine(File, "MultiClients", CString(MultiClients())); PrintLine(File, "BounceDCCs", CString(BounceDCCs())); PrintLine(File, "DenyLoadMod", CString(DenyLoadMod())); PrintLine(File, "Admin", CString(IsAdmin())); PrintLine(File, "DenySetBindHost", CString(DenySetBindHost())); PrintLine(File, "DCCLookupMethod", CString((UseClientIP()) ? "client" : "default")); PrintLine(File, "TimestampFormat", GetTimestampFormat()); PrintLine(File, "AppendTimestamp", CString(GetTimestampAppend())); PrintLine(File, "PrependTimestamp", CString(GetTimestampPrepend())); PrintLine(File, "TimezoneOffset", CString(m_fTimezoneOffset)); PrintLine(File, "JoinTries", CString(m_uMaxJoinTries)); PrintLine(File, "MaxJoins", CString(m_uMaxJoins)); PrintLine(File, "IRCConnectEnabled", CString(GetIRCConnectEnabled())); File.Write("\n"); // Allow Hosts if (!m_ssAllowedHosts.empty()) { for (set<CString>::iterator it = m_ssAllowedHosts.begin(); it != m_ssAllowedHosts.end(); ++it) { PrintLine(File, "Allow", *it); } File.Write("\n"); } // CTCP Replies if (!m_mssCTCPReplies.empty()) { for (MCString::const_iterator itb = m_mssCTCPReplies.begin(); itb != m_mssCTCPReplies.end(); ++itb) { PrintLine(File, "CTCPReply", itb->first.AsUpper() + " " + itb->second); } File.Write("\n"); } // Modules CModules& Mods = GetModules(); if (!Mods.empty()) { for (unsigned int a = 0; a < Mods.size(); a++) { CString sArgs = Mods[a]->GetArgs(); if (!sArgs.empty()) { sArgs = " " + sArgs; } PrintLine(File, "LoadModule", Mods[a]->GetModName() + sArgs); } File.Write("\n"); } // Servers for (unsigned int b = 0; b < m_vServers.size(); b++) { PrintLine(File, "Server", m_vServers[b]->GetString()); } // Chans for (unsigned int c = 0; c < m_vChans.size(); c++) { CChan* pChan = m_vChans[c]; if (pChan->InConfig()) { File.Write("\n"); if (!pChan->WriteConfig(File)) { return false; } } } File.Write("</User>\n"); return true; }
void CIRCSock::ReadLine(const CString& sData) { CString sLine = sData; sLine.TrimRight("\n\r"); DEBUG("(" << m_pUser->GetUserName() << ") IRC -> ZNC [" << sLine << "]"); MODULECALL(OnRaw(sLine), m_pUser, NULL, return); if (sLine.Equals("PING ", false, 5)) { // Generate a reply and don't forward this to any user, // we don't want any PING forwarded PutIRC("PONG " + sLine.substr(5)); return; } else if (sLine.Token(1).Equals("PONG")) { // Block PONGs, we already responded to the pings return; } else if (sLine.Equals("ERROR ", false, 6)) { //ERROR :Closing Link: nick[24.24.24.24] (Excess Flood) CString sError(sLine.substr(6)); if (sError.Left(1) == ":") { sError.LeftChomp(); } m_pUser->PutStatus("Error from Server [" + sError + "]"); return; } CString sCmd = sLine.Token(1); if ((sCmd.length() == 3) && (isdigit(sCmd[0])) && (isdigit(sCmd[1])) && (isdigit(sCmd[2]))) { CString sServer = sLine.Token(0); sServer.LeftChomp(); unsigned int uRaw = sCmd.ToUInt(); CString sNick = sLine.Token(2); CString sRest = sLine.Token(3, true); switch (uRaw) { case 1: { // :irc.server.com 001 nick :Welcome to the Internet Relay Network nick if (m_bAuthed && sServer == "irc.znc.in") { // m_bAuthed == true => we already received another 001 => we might be in a traffic loop m_pUser->PutStatus("ZNC seems to be connected to itself, disconnecting..."); Quit(); return; } m_pUser->SetIRCServer(sServer); SetTimeout(240, TMO_READ); // Now that we are connected, let nature take its course PutIRC("WHO " + sNick); m_bAuthed = true; m_pUser->PutStatus("Connected!"); vector<CClient*>& vClients = m_pUser->GetClients(); for (unsigned int a = 0; a < vClients.size(); a++) { CClient* pClient = vClients[a]; CString sClientNick = pClient->GetNick(false); if (!sClientNick.Equals(sNick)) { // If they connected with a nick that doesn't match the one we got on irc, then we need to update them pClient->PutClient(":" + sClientNick + "!" + m_Nick.GetIdent() + "@" + m_Nick.GetHost() + " NICK :" + sNick); } } SetNick(sNick); MODULECALL(OnIRCConnected(), m_pUser, NULL, ); m_pUser->ClearRawBuffer(); m_pUser->AddRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); CZNC::Get().ReleaseISpoof(); m_bISpoofReleased = true; break; } case 5: ParseISupport(sRest); m_pUser->UpdateExactRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; case 2: case 3: case 4: case 250: // highest connection count case 251: // user count case 252: // oper count case 254: // channel count case 255: // client count case 265: // local users case 266: // global users m_pUser->UpdateRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; case 305: m_pUser->SetIRCAway(false); break; case 306: m_pUser->SetIRCAway(true); break; case 324: { // MODE sRest.Trim(); CChan* pChan = m_pUser->FindChan(sRest.Token(0)); if (pChan) { pChan->SetModes(sRest.Token(1, true)); } } break; case 329: { sRest.Trim(); CChan* pChan = m_pUser->FindChan(sRest.Token(0)); if (pChan) { unsigned long ulDate = sLine.Token(4).ToULong(); pChan->SetCreationDate(ulDate); } } break; case 331: { // :irc.server.com 331 yournick #chan :No topic is set. CChan* pChan = m_pUser->FindChan(sLine.Token(3)); if (pChan) { pChan->SetTopic(""); } break; } case 332: { // :irc.server.com 332 yournick #chan :This is a topic CChan* pChan = m_pUser->FindChan(sLine.Token(3)); if (pChan) { CString sTopic = sLine.Token(4, true); sTopic.LeftChomp(); pChan->SetTopic(sTopic); } break; } case 333: { // :irc.server.com 333 yournick #chan setternick 1112320796 CChan* pChan = m_pUser->FindChan(sLine.Token(3)); if (pChan) { sNick = sLine.Token(4); unsigned long ulDate = sLine.Token(5).ToULong(); pChan->SetTopicOwner(sNick); pChan->SetTopicDate(ulDate); } break; } case 352: { // :irc.yourserver.com 352 yournick #chan ident theirhost.com irc.theirserver.com theirnick H :0 Real Name sServer = sLine.Token(0); sNick = sLine.Token(7); CString sIdent = sLine.Token(4); CString sHost = sLine.Token(5); sServer.LeftChomp(); if (sNick.Equals(GetNick())) { m_Nick.SetIdent(sIdent); m_Nick.SetHost(sHost); } m_pUser->SetIRCNick(m_Nick); m_pUser->SetIRCServer(sServer); const vector<CChan*>& vChans = m_pUser->GetChans(); for (unsigned int a = 0; a < vChans.size(); a++) { vChans[a]->OnWho(sNick, sIdent, sHost); } break; } case 353: { // NAMES sRest.Trim(); // Todo: allow for non @+= server msgs CChan* pChan = m_pUser->FindChan(sRest.Token(1)); // If we don't know that channel, some client might have // requested a /names for it and we really should forward this. if (pChan) { CString sNicks = sRest.Token(2, true); if (sNicks.Left(1) == ":") { sNicks.LeftChomp(); } pChan->AddNicks(sNicks); } ForwardRaw353(sLine); // We forwarded it already, so return return; } case 366: { // end of names list m_pUser->PutUser(sLine); // First send them the raw // :irc.server.com 366 nick #chan :End of /NAMES list. CChan* pChan = m_pUser->FindChan(sRest.Token(0)); if (pChan) { if (pChan->IsOn()) { // If we are the only one in the chan, set our default modes if (pChan->GetNickCount() == 1) { CString sModes = pChan->GetDefaultModes(); if (sModes.empty()) { sModes = m_pUser->GetDefaultChanModes(); } if (!sModes.empty()) { PutIRC("MODE " + pChan->GetName() + " " + sModes); } } } } return; // return so we don't send them the raw twice } case 375: // begin motd case 422: // MOTD File is missing m_pUser->ClearMotdBuffer(); case 372: // motd case 376: // end motd m_pUser->AddMotdBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; case 437: // :irc.server.net 437 * badnick :Nick/channel is temporarily unavailable // :irc.server.net 437 mynick badnick :Nick/channel is temporarily unavailable // :irc.server.net 437 mynick badnick :Cannot change nickname while banned on channel if (m_pUser->IsChan(sRest.Token(0)) || sNick != "*") break; case 432: // :irc.server.com 432 * nick :Erroneous Nickname: Illegal characters case 433: { CString sBadNick = sRest.Token(0); if (!m_bAuthed) { SendAltNick(sBadNick); return; } break; } case 451: // :irc.server.com 451 CAP :You have not registered // Servers that dont support CAP will give us this error, dont send it to the client if (sNick.Equals("CAP")) return; case 470: { // :irc.unreal.net 470 mynick [Link] #chan1 has become full, so you are automatically being transferred to the linked channel #chan2 // :mccaffrey.freenode.net 470 mynick #electronics ##electronics :Forwarding to another channel // freenode style numeric CChan* pChan = m_pUser->FindChan(sRest.Token(0)); if (!pChan) { // unreal style numeric pChan = m_pUser->FindChan(sRest.Token(1)); } if (pChan) { pChan->Disable(); m_pUser->PutStatus("Channel [" + pChan->GetName() + "] is linked to " "another channel and was thus disabled."); } break; } } } else {
struct Channel * AddChannel(char **line, int nickcnt, char **nicks) { char *names; char **anames; char *currnick; char modes[MAXLINE]; struct Channel *chname, *cptr; struct Channel *tempchan; int ii, ncnt, acnt; ncnt = 5; /* default position for channel nicks, if no limit/key */ strcpy(modes, line[4]); while (line[ncnt][0] != ':') { strcat(modes, " "); strcat(modes, line[ncnt]); ncnt++; } if (nickcnt > 0) { acnt = nickcnt; anames = nicks; } else { names = line[ncnt]; names++; /* point past the leading : */ ii = strlen(names); /* kill the \n char on the end */ if (IsSpace(names[ii - 2])) names[ii - 2] = '\0'; else if (IsSpace(names[ii - 1])) names[ii - 1] = '\0'; acnt = SplitBuf(names, &anames); } if (!(cptr = FindChannel(line[3]))) { #ifdef BLOCK_ALLOCATION tempchan = (struct Channel *) BlockSubAllocate(ChannelHeap); memset(tempchan, 0, sizeof(struct Channel)); strncpy(tempchan->name, line[3], CHANNELLEN); #else tempchan = (struct Channel *) MyMalloc(sizeof(struct Channel)); memset(tempchan, 0, sizeof(struct Channel)); tempchan->name = MyStrdup(line[3]); #endif /* BLOCK_ALLOCATION */ tempchan->since = atol(line[2]); tempchan->numusers = acnt; tempchan->next = ChannelList; tempchan->prev = NULL; if (tempchan->next) tempchan->next->prev = tempchan; HashAddChan(tempchan); ChannelList = tempchan; chname = ChannelList; ++Network->TotalChannels; #ifdef STATSERVICES if (Network->TotalChannels > Network->MaxChannels) { Network->MaxChannels = Network->TotalChannels; Network->MaxChannels_ts = current_ts; if ((Network->MaxChannels % 10) == 0) { /* notify +y people about new max channel count */ SendUmode(OPERUMODE_Y, "*** New Max Channel Count: %ld", Network->MaxChannels); } } if (Network->TotalChannels > Network->MaxChannelsT) { Network->MaxChannelsT = Network->TotalChannels; Network->MaxChannelsT_ts = current_ts; } #endif /* STATSERVICES */ } else /* it's an existing channel, but someone has joined it */ { cptr->numusers += acnt; chname = cptr; } /* Add the channel to each nick's channel list */ for (ii = 0; ii < acnt; ii++) { currnick = GetNick(anames[ii]); if (!currnick) continue; if (!IsChannelMember(chname, FindClient(currnick))) { /* * Use anames[ii] instead of currnick here so we get * the @/+ flags */ AddToChannel(chname, anames[ii]); } else chname->numusers--; } /* finally, add the modes for the channel */ UpdateChanModes(0, line[0] + 1, chname, modes); /* * Only free anames[] if there was no nick list * given */ if (!nickcnt) MyFree(anames); return (chname); } /* AddChannel() */
//------------------------------------------------------------------------------- //------------------------------------------------------------------------------- bool VoidBot::PublicCommands(const char* SessionID, const String& Command) { // todo: these should all be busted out into their own functions // "Message For" command String keyword("message for"); int32 pos = WholeWordPos(Command, keyword.Cstr()); if( B_ERROR != pos ) { if( 2048 < Command.Length() ) { SendMessage(SessionID, "There is _no way_ I can remember all that, please phrase the message shorter."); return true; } pos += keyword.Length(); String name(GetNick(Command, pos)); if( 0 == name.Length() ) { SendMessage(SessionID, "Please specify a nick!"); return true; } if( B_ERROR != name.IndexOf(' ') ) { // name with space, adjust for delimiter chars. pos += 2; } pos += name.Length() + 1; if( (int32)Command.Length() < (pos - 1) ) { SendMessage(SessionID, "Please specify a message."); return true; } String message("Message from "); message += fData.UserByID(SessionID)->Name(); message += " Left at"; message += " ["; message += Time(); message += "]"; message += ": "; message += Command.Substring(pos); fMessagesForName[name].push_back(message); SendPrivateMessage(SessionID, "Will there be anything else?."); fReportedNewMessages[name] = false; return true; } // "Seen" command keyword = "seen"; pos = WholeWordPos(Command, keyword.Cstr()); if( -1 != pos ) { pos += keyword.Length(); String name(GetNick(Command, pos)); if( 0 == name.Length() ) { SendMessage(SessionID, "Please specify a nick!"); return true; } if( fLastWords.find(name.Cstr()) != fLastWords.end() ) { String info(name); info += " was last seen "; info += fLastWords[name.Cstr()]; SendMessage(SessionID, info.Cstr()); } else { String negatory("No, I haven't seen "); negatory += name; SendMessage(SessionID, negatory.Cstr()); } return true; } //*****************<FORTUNE ADDED BY MISZA>************************// pos = WholeWordPos(Command, "fortune"); if(-1 != pos) { FILE *fp = popen ("fortune", "r"); if(fp != NULL) { char ch; String cool= "\n"; while((ch = fgetc(fp))!= EOF) { cool += ch; } fclose(fp); if(cool != "\n") { cool = cool.Substring(0,(cool.Length()-1)); SendPrivateMessage(SessionID,cool.Cstr()); } } return true; } //*****************</FORTUNE ADDED BY MISZA>************************// // "GMTime" command pos = WholeWordPos(Command, "gmtime"); if( -1 != pos ) { String info("The time is: "); info += Time(); SendMessage(SessionID, info.Cstr()); return true; } // "Time" command pos = WholeWordPos(Command, "time"); if( -1 != pos ) { String info("The time is: "); info += MyTime(); SendMessage(SessionID, info.Cstr()); return true; } // "iTime" command pos = WholeWordPos(Command, "itime"); if( -1 != pos ) { String info("The time is: "); info += NetTime(); SendMessage(SessionID, info.Cstr()); return true; } // "Atrus" Prevent messages to bebop keyword = "message for bebop"; pos = WholeWordPos(Command, keyword.Cstr()); if( B_ERROR != pos ) { SendPrivateMessage(SessionID, "You didn't say the magic word..."); return true; } // "Atrus" Prevent messages to Atrus keyword = "message for Atrus"; pos = WholeWordPos(Command, keyword.Cstr()); if( B_ERROR != pos ) { SendPrivateMessage(SessionID, "You didn't say the magic word..."); return true; } // "Atrus" Prevent messages to Bubbles keyword = "message for Bubbles"; pos = WholeWordPos(Command, keyword.Cstr()); if( B_ERROR != pos ) { SendPrivateMessage(SessionID, "You didn't say the magic word..."); return true; } // "Atrus" Prevent messages to FAQbot keyword = "message for FAQbot"; pos = WholeWordPos(Command, keyword.Cstr()); if( B_ERROR != pos ) { SendPrivateMessage(SessionID, "You didn't say the magic word..."); return true; } // "Messages" command pos = WholeWordPos(Command, "messages"); if( B_ERROR != pos ) { bool messages = false; uint32 quantity = 0; const char* name = fData.UserByID(SessionID)->Name(); if( fMessagesForName.find(name) != fMessagesForName.end() ) { quantity = fMessagesForName[name].size(); if( quantity != 0 ) { messages = true; } } if( true == messages ) { for( uint32 i = 0; i < quantity; i++ ) { SendPrivateMessage(SessionID, fMessagesForName[name][i].Cstr()); } fMessagesForName[name].clear(); fReportedNewMessages[name] = true; } else { String reply("Sorry "); reply += fData.UserByID(SessionID)->Name(); reply += ", You get nothing and like it!"; SendPrivateMessage(SessionID, reply.Cstr()); } return true; } // "Version" command pos = WholeWordPos(Command, "version"); if( B_ERROR != pos ) { // The version string is made up of MAJOR_RELEASE.MINOR_RELEASE.BUG_FIXES SendPrivateMessage(SessionID, "I am at version 2.1 (MUSCLE " MUSCLE_VERSION_STRING ")"); return true; } pos = WholeWordPos(Command, "catsup"); if( B_ERROR != pos ) { // Figure out how many lines of chat to return pos++; pos += strlen("catsup"); uint32 lines; if( (uint32)pos < Command.Length() ) { lines = (uint32)atoi(&(Command.Cstr()[pos])); if( 0 == lines ) { lines = kDefaultChatHistory; } } else { lines = 25; } if( lines > fChatHistory.size() ) { lines = fChatHistory.size(); } String chatText("\n"); for( uint32 i = lines; i > 0 ; i-- ) { chatText += fChatHistory[i-1]; chatText += "\n"; } SendPrivateMessage(SessionID, chatText.Cstr()); return true; } // "Email" command keyword = "email"; pos = WholeWordPos(Command, keyword.Cstr()); if( -1 != pos ) { pos += keyword.Length(); String name(GetNick(Command, pos)); if( 0 == name.Length() ) { SendPrivateMessage(SessionID, "Please specify a nick!"); return true; } { String fullname(botPath); fullname += "/email/"; fullname += name; if(!SendTextfile(SessionID, fullname.Cstr(), false)) { SendPrivateMessage(SessionID, "No email address found for that nick!"); } return true; } } // "Gimme" command (v.2) keyword = "gimme"; pos = WholeWordPos(Command, keyword.Cstr()); if( -1 != pos ) { pos += keyword.Length(); String name(GetNick(Command, pos)); if( 0 == name.Length() ) { SendPrivateMessage(SessionID, "Please specify help page!"); return true; } { String fullname(botPath); fullname += "/faq/"; fullname += name; return SendTextfile(SessionID, fullname.Cstr(), false); } } // Do all one word commands (aka send text file with same name to user) String name(Command.Substring( Command.IndexOf(" ") + 1)); if ( 0 < name.Length() ) { String fullname(botPath); fullname += "/commands/"; fullname += name.Cstr(); return SendTextfile(SessionID, fullname.Cstr(), false); } return false; }
NickImpl::~NickImpl() { /* Remove us from the aliases list */ NickServ::nickalias_map &map = NickServ::service->GetNickMap(); map.erase(GetNick()); }
void User::DoAction(const std::string& message) const { GetServer().DoActionPrivate(GetNick(), message); }
void User::Say(const std::string& message) const { GetServer().SayPrivate(GetNick(), message); }
void CNetworkPlayer::ExitVehicle( bool bExit, bool bQuickly ) { DEBUG_TRACE("CNetworkPlayer::ExitVehicle"); // Are we not in a vehicle? if( !m_pVehicle ) return; // Are we already exiting? if ( IsExitingVehicle() ) { CLogFile::Printf ( "WARNING: This player (%s) is already exiting a vehicle, skipping!", GetNick().Get () ); return; } // Is the player ped active? if( m_pPlayerPed && IsSpawned() ) { // Should we remove the player from the vehicle? if( bExit ) { // Are we in a vehicle? if( InternalIsInVehicle() ) { #ifdef DEBUG CLogFile::Printf( "CPlayer::ExitVehicle - Quickly? %s", (bQuickly ? "true" : "false") ); #endif // Reset the target data SetEnteringVehicle( NULL, INVALID_ENTITY_ID ); m_VehicleEnter.m_bIsEntering = false; // Remove from vehicle C_SyncObject * pSyncObject = m_pPlayerPed->GetInOutVehicle( m_pPlayerPed->GetCurrentVehicle(), m_seat, bQuickly ); #ifdef DEBUG CLogFile::Printf ( "Exit vehicle sync object: 0x%p", pSyncObject ); #endif // Are we not quickly exiting? if( !bQuickly ) { m_VehicleExit.m_pExitAICommand = new CM2SyncObject( pSyncObject ); m_VehicleExit.m_bIsExiting = true; m_VehicleExit.m_ulExitStartTime = SharedUtility::GetTime (); } } #ifdef DEBUG CLogFile::Print ( "Handling with vehicle..." ); #endif // Handle this enter with the network vehicle m_pVehicle->HandlePlayerExit( this, (m_seat - 1) ); #ifdef DEBUG CLogFile::Print ( "Done!" ); #endif } // Reset the vehicle SetVehicle( NULL ); // Reset the seat SetSeat( INVALID_ENTITY_ID ); // Reset the playerstate m_playerState = ePlayerState::PLAYERSTATE_ONFOOT; } }
void CIRCSock::ReadLine(const CString& sData) { CString sLine = sData; sLine.TrimRight("\n\r"); DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" << m_pNetwork->GetName() << ") IRC -> ZNC [" << sLine << "]"); NETWORKMODULECALL(OnRaw(sLine), m_pNetwork->GetUser(), m_pNetwork, NULL, return); if (sLine.Equals("PING ", false, 5)) { // Generate a reply and don't forward this to any user, // we don't want any PING forwarded PutIRC("PONG " + sLine.substr(5)); return; } else if (sLine.Token(1).Equals("PONG")) { // Block PONGs, we already responded to the pings return; } else if (sLine.Equals("ERROR ", false, 6)) { //ERROR :Closing Link: nick[24.24.24.24] (Excess Flood) CString sError(sLine.substr(6)); sError.TrimPrefix(); m_pNetwork->PutStatus("Error from Server [" + sError + "]"); return; } CString sCmd = sLine.Token(1); if ((sCmd.length() == 3) && (isdigit(sCmd[0])) && (isdigit(sCmd[1])) && (isdigit(sCmd[2]))) { CString sServer = sLine.Token(0).LeftChomp_n(); unsigned int uRaw = sCmd.ToUInt(); CString sNick = sLine.Token(2); CString sRest = sLine.Token(3, true); switch (uRaw) { case 1: { // :irc.server.com 001 nick :Welcome to the Internet Relay Network nick if (m_bAuthed && sServer == "irc.znc.in") { // m_bAuthed == true => we already received another 001 => we might be in a traffic loop m_pNetwork->PutStatus("ZNC seems to be connected to itself, disconnecting..."); Quit(); return; } m_pNetwork->SetIRCServer(sServer); SetTimeout(540, TMO_READ); // Now that we are connected, let nature take its course PutIRC("WHO " + sNick); m_bAuthed = true; m_pNetwork->PutStatus("Connected!"); vector<CClient*>& vClients = m_pNetwork->GetClients(); for (unsigned int a = 0; a < vClients.size(); a++) { CClient* pClient = vClients[a]; CString sClientNick = pClient->GetNick(false); if (!sClientNick.Equals(sNick)) { // If they connected with a nick that doesn't match the one we got on irc, then we need to update them pClient->PutClient(":" + sClientNick + "!" + m_Nick.GetIdent() + "@" + m_Nick.GetHost() + " NICK :" + sNick); } } SetNick(sNick); NETWORKMODULECALL(OnIRCConnected(), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); m_pNetwork->ClearRawBuffer(); m_pNetwork->AddRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; } case 5: ParseISupport(sRest); m_pNetwork->UpdateExactRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; case 10: { // :irc.server.com 010 nick <hostname> <port> :<info> CString sHost = sRest.Token(0); CString sPort = sRest.Token(1); CString sInfo = sRest.Token(2, true).TrimPrefix_n(); m_pNetwork->PutStatus("Server [" + m_pNetwork->GetCurrentServer()->GetString(false) + "] redirects us to [" + sHost + ":" + sPort + "] with reason [" + sInfo + "]"); m_pNetwork->PutStatus("Perhaps you want to add it as a new server."); // Don't send server redirects to the client return; } case 2: case 3: case 4: case 250: // highest connection count case 251: // user count case 252: // oper count case 254: // channel count case 255: // client count case 265: // local users case 266: // global users m_pNetwork->UpdateRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; case 305: m_pNetwork->SetIRCAway(false); break; case 306: m_pNetwork->SetIRCAway(true); break; case 324: { // MODE sRest.Trim(); CChan* pChan = m_pNetwork->FindChan(sRest.Token(0)); if (pChan) { pChan->SetModes(sRest.Token(1, true)); // We don't SetModeKnown(true) here, // because a 329 will follow if (!pChan->IsModeKnown()) { // When we JOIN, we send a MODE // request. This makes sure the // reply isn't forwarded. return; } } } break; case 329: { sRest.Trim(); CChan* pChan = m_pNetwork->FindChan(sRest.Token(0)); if (pChan) { unsigned long ulDate = sLine.Token(4).ToULong(); pChan->SetCreationDate(ulDate); if (!pChan->IsModeKnown()) { pChan->SetModeKnown(true); // When we JOIN, we send a MODE // request. This makes sure the // reply isn't forwarded. return; } } } break; case 331: { // :irc.server.com 331 yournick #chan :No topic is set. CChan* pChan = m_pNetwork->FindChan(sLine.Token(3)); if (pChan) { pChan->SetTopic(""); } break; } case 332: { // :irc.server.com 332 yournick #chan :This is a topic CChan* pChan = m_pNetwork->FindChan(sLine.Token(3)); if (pChan) { CString sTopic = sLine.Token(4, true); sTopic.LeftChomp(); pChan->SetTopic(sTopic); } break; } case 333: { // :irc.server.com 333 yournick #chan setternick 1112320796 CChan* pChan = m_pNetwork->FindChan(sLine.Token(3)); if (pChan) { sNick = sLine.Token(4); unsigned long ulDate = sLine.Token(5).ToULong(); pChan->SetTopicOwner(sNick); pChan->SetTopicDate(ulDate); } break; } case 352: { // :irc.yourserver.com 352 yournick #chan ident theirhost.com irc.theirserver.com theirnick H :0 Real Name sServer = sLine.Token(0); sNick = sLine.Token(7); CString sIdent = sLine.Token(4); CString sHost = sLine.Token(5); sServer.LeftChomp(); if (sNick.Equals(GetNick())) { m_Nick.SetIdent(sIdent); m_Nick.SetHost(sHost); } m_pNetwork->SetIRCNick(m_Nick); m_pNetwork->SetIRCServer(sServer); const vector<CChan*>& vChans = m_pNetwork->GetChans(); for (unsigned int a = 0; a < vChans.size(); a++) { vChans[a]->OnWho(sNick, sIdent, sHost); } break; } case 353: { // NAMES sRest.Trim(); // Todo: allow for non @+= server msgs CChan* pChan = m_pNetwork->FindChan(sRest.Token(1)); // If we don't know that channel, some client might have // requested a /names for it and we really should forward this. if (pChan) { CString sNicks = sRest.Token(2, true).TrimPrefix_n(); pChan->AddNicks(sNicks); } ForwardRaw353(sLine); // We forwarded it already, so return return; } case 366: { // end of names list m_pNetwork->PutUser(sLine); // First send them the raw // :irc.server.com 366 nick #chan :End of /NAMES list. CChan* pChan = m_pNetwork->FindChan(sRest.Token(0)); if (pChan) { if (pChan->IsOn()) { // If we are the only one in the chan, set our default modes if (pChan->GetNickCount() == 1) { CString sModes = pChan->GetDefaultModes(); if (sModes.empty()) { sModes = m_pNetwork->GetUser()->GetDefaultChanModes(); } if (!sModes.empty()) { PutIRC("MODE " + pChan->GetName() + " " + sModes); } } } } return; // return so we don't send them the raw twice } case 375: // begin motd case 422: // MOTD File is missing m_pNetwork->ClearMotdBuffer(); case 372: // motd case 376: // end motd m_pNetwork->AddMotdBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; case 437: // :irc.server.net 437 * badnick :Nick/channel is temporarily unavailable // :irc.server.net 437 mynick badnick :Nick/channel is temporarily unavailable // :irc.server.net 437 mynick badnick :Cannot change nickname while banned on channel if (m_pNetwork->IsChan(sRest.Token(0)) || sNick != "*") break; case 432: // :irc.server.com 432 * nick :Erroneous Nickname: Illegal characters case 433: { CString sBadNick = sRest.Token(0); if (!m_bAuthed) { SendAltNick(sBadNick); return; } break; } case 451: // :irc.server.com 451 CAP :You have not registered // Servers that dont support CAP will give us this error, dont send it to the client if (sNick.Equals("CAP")) return; case 470: { // :irc.unreal.net 470 mynick [Link] #chan1 has become full, so you are automatically being transferred to the linked channel #chan2 // :mccaffrey.freenode.net 470 mynick #electronics ##electronics :Forwarding to another channel // freenode style numeric CChan* pChan = m_pNetwork->FindChan(sRest.Token(0)); if (!pChan) { // unreal style numeric pChan = m_pNetwork->FindChan(sRest.Token(1)); } if (pChan) { pChan->Disable(); m_pNetwork->PutStatus("Channel [" + pChan->GetName() + "] is linked to " "another channel and was thus disabled."); } break; } } } else { CNick Nick(sLine.Token(0).TrimPrefix_n()); sCmd = sLine.Token(1); CString sRest = sLine.Token(2, true); if (sCmd.Equals("NICK")) { CString sNewNick = sRest.TrimPrefix_n(); bool bIsVisible = false; vector<CChan*> vFoundChans; const vector<CChan*>& vChans = m_pNetwork->GetChans(); for (unsigned int a = 0; a < vChans.size(); a++) { CChan* pChan = vChans[a]; if (pChan->ChangeNick(Nick.GetNick(), sNewNick)) { vFoundChans.push_back(pChan); if (!pChan->IsDetached()) { bIsVisible = true; } } } // Todo: use nick compare function here if (Nick.GetNick().Equals(GetNick())) { // We are changing our own nick, the clients always must see this! bIsVisible = true; SetNick(sNewNick); } NETWORKMODULECALL(OnNick(Nick, sNewNick, vFoundChans), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); if (!bIsVisible) { return; } } else if (sCmd.Equals("QUIT")) { CString sMessage = sRest.TrimPrefix_n(); bool bIsVisible = false; // :[email protected] QUIT :message if (Nick.GetNick().Equals(GetNick())) { m_pNetwork->PutStatus("You quit [" + sMessage + "]"); // We don't call module hooks and we don't // forward this quit to clients (Some clients // disconnect if they receive such a QUIT) return; } vector<CChan*> vFoundChans; const vector<CChan*>& vChans = m_pNetwork->GetChans(); for (unsigned int a = 0; a < vChans.size(); a++) { CChan* pChan = vChans[a]; if (pChan->RemNick(Nick.GetNick())) { vFoundChans.push_back(pChan); if (!pChan->IsDetached()) { bIsVisible = true; } } } NETWORKMODULECALL(OnQuit(Nick, sMessage, vFoundChans), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); if (!bIsVisible) { return; } } else if (sCmd.Equals("JOIN")) { CString sChan = sRest.Token(0).TrimPrefix_n(); CChan* pChan; // Todo: use nick compare function if (Nick.GetNick().Equals(GetNick())) { m_pNetwork->AddChan(sChan, false); pChan = m_pNetwork->FindChan(sChan); if (pChan) { pChan->ResetJoinTries(); pChan->Enable(); pChan->SetIsOn(true); PutIRC("MODE " + sChan); } } else { pChan = m_pNetwork->FindChan(sChan); } if (pChan) { pChan->AddNick(Nick.GetNickMask()); NETWORKMODULECALL(OnJoin(Nick.GetNickMask(), *pChan), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); if (pChan->IsDetached()) { return; } } } else if (sCmd.Equals("PART")) { CString sChan = sRest.Token(0).TrimPrefix_n(); CString sMsg = sRest.Token(1, true).TrimPrefix_n(); CChan* pChan = m_pNetwork->FindChan(sChan); bool bDetached = false; if (pChan) { pChan->RemNick(Nick.GetNick()); NETWORKMODULECALL(OnPart(Nick.GetNickMask(), *pChan, sMsg), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); if (pChan->IsDetached()) bDetached = true; } // Todo: use nick compare function if (Nick.GetNick().Equals(GetNick())) { m_pNetwork->DelChan(sChan); } /* * We use this boolean because * m_pNetwork->DelChan() will delete this channel * and thus we would dereference an * already-freed pointer! */ if (bDetached) { return; } } else if (sCmd.Equals("MODE")) { CString sTarget = sRest.Token(0); CString sModes = sRest.Token(1, true); if (sModes.Left(1) == ":") sModes = sModes.substr(1); CChan* pChan = m_pNetwork->FindChan(sTarget); if (pChan) { pChan->ModeChange(sModes, &Nick); if (pChan->IsDetached()) { return; } } else if (sTarget == m_Nick.GetNick()) { CString sModeArg = sModes.Token(0); bool bAdd = true; /* no module call defined (yet?) MODULECALL(OnRawUserMode(*pOpNick, *this, sModeArg, sArgs), m_pNetwork->GetUser(), NULL, ); */ for (unsigned int a = 0; a < sModeArg.size(); a++) { const unsigned char& uMode = sModeArg[a]; if (uMode == '+') { bAdd = true; } else if (uMode == '-') { bAdd = false; } else { if (bAdd) { m_scUserModes.insert(uMode); } else { m_scUserModes.erase(uMode); } } } } } else if (sCmd.Equals("KICK")) { // :[email protected] KICK #chan nick :msg CString sChan = sRest.Token(0); CString sKickedNick = sRest.Token(1); CString sMsg = sRest.Token(2, true); sMsg.LeftChomp(); CChan* pChan = m_pNetwork->FindChan(sChan); if (pChan) { NETWORKMODULECALL(OnKick(Nick, sKickedNick, *pChan, sMsg), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); // do not remove the nick till after the OnKick call, so modules // can do Chan.FindNick or something to get more info. pChan->RemNick(sKickedNick); } if (GetNick().Equals(sKickedNick) && pChan) { pChan->SetIsOn(false); // Don't try to rejoin! pChan->Disable(); } if ((pChan) && (pChan->IsDetached())) { return; } } else if (sCmd.Equals("NOTICE")) { // :[email protected] NOTICE #chan :Message CString sTarget = sRest.Token(0); CString sMsg = sRest.Token(1, true); sMsg.LeftChomp(); if (sMsg.WildCmp("\001*\001")) { sMsg.LeftChomp(); sMsg.RightChomp(); if (sTarget.Equals(GetNick())) { if (OnCTCPReply(Nick, sMsg)) { return; } } m_pNetwork->PutUser(":" + Nick.GetNickMask() + " NOTICE " + sTarget + " :\001" + sMsg + "\001"); return; } else { if (sTarget.Equals(GetNick())) { if (OnPrivNotice(Nick, sMsg)) { return; } } else { if (OnChanNotice(Nick, sTarget, sMsg)) { return; } } } if (Nick.GetNick().Equals(m_pNetwork->GetIRCServer())) { m_pNetwork->PutUser(":" + Nick.GetNick() + " NOTICE " + sTarget + " :" + sMsg); } else { m_pNetwork->PutUser(":" + Nick.GetNickMask() + " NOTICE " + sTarget + " :" + sMsg); } return; } else if (sCmd.Equals("TOPIC")) { // :[email protected] TOPIC #chan :This is a topic CChan* pChan = m_pNetwork->FindChan(sLine.Token(2)); if (pChan) { CString sTopic = sLine.Token(3, true); sTopic.LeftChomp(); NETWORKMODULECALL(OnTopic(Nick, *pChan, sTopic), m_pNetwork->GetUser(), m_pNetwork, NULL, return); pChan->SetTopicOwner(Nick.GetNick()); pChan->SetTopicDate((unsigned long) time(NULL)); pChan->SetTopic(sTopic); if (pChan->IsDetached()) { return; // Don't forward this } sLine = ":" + Nick.GetNickMask() + " TOPIC " + pChan->GetName() + " :" + sTopic; } } else if (sCmd.Equals("PRIVMSG")) {
void CClientPlayer::DischargeWeapon ( eWeaponType weaponType, const CVector& vecStart, const CVector& vecEnd, float fBackupDamage, uchar ucBackupHitZone, CClientPlayer* pBackupDamagedPlayer ) { if ( m_pPlayerPed ) { g_pApplyDamageLastDamagedPed = NULL; g_fApplyDamageLastAmount = 0; // Check weapon matches and is enabled for bullet sync if ( weaponType == GetCurrentWeaponType () && g_pClientGame->GetWeaponTypeUsesBulletSync ( weaponType ) ) { // Set bullet start and end points m_shotSyncData->m_vecRemoteBulletSyncStart = vecStart; m_shotSyncData->m_vecRemoteBulletSyncEnd = vecEnd; m_shotSyncData->m_bRemoteBulletSyncVectorsValid = true; g_iDamageEventLimit = 1; // Fixed #9038: bugged shotgun with bullet sync if ( weaponType == WEAPONTYPE_SHOTGUN || weaponType == WEAPONTYPE_SAWNOFF_SHOTGUN || weaponType == WEAPONTYPE_SPAS12_SHOTGUN ) { if ( g_pClientGame->GetMiscGameSettings().bAllowShotgunDamageFix ) g_iDamageEventLimit = 2; } // Fire CWeapon* pWeapon = m_pPlayerPed->GetWeapon ( m_pPlayerPed->GetCurrentWeaponSlot () ); pWeapon->FireBullet ( m_pPlayerPed, vecStart, vecEnd ); g_iDamageEventLimit = -1; m_shotSyncData->m_bRemoteBulletSyncVectorsValid = false; } // Apply extra damage if player has bad network if ( pBackupDamagedPlayer && pBackupDamagedPlayer->GetGamePlayer() && pBackupDamagedPlayer->GetWasRecentlyInNetworkInterruption( 1000 ) ) { // Subtract any damage that did get applied during FireBullet if ( pBackupDamagedPlayer == g_pApplyDamageLastDamagedPed ) fBackupDamage -= g_fApplyDamageLastAmount; if ( fBackupDamage > 0 ) { // Apply left over damage like what the game would: // CClientPlayer has pre damage health/armor // CPlayerPed has post damage health/armor float fPreviousHealth = pBackupDamagedPlayer->m_fHealth; float fPreviousArmor = pBackupDamagedPlayer->m_fArmor; // Calculate how much damage should be applied to health/armor float fArmorDamage = Min( fBackupDamage, pBackupDamagedPlayer->m_fArmor ); float fHealthDamage = Min( fBackupDamage - fArmorDamage, pBackupDamagedPlayer->m_fHealth ); float fNewArmor = pBackupDamagedPlayer->m_fArmor - fArmorDamage; float fNewHealth = pBackupDamagedPlayer->m_fHealth - fHealthDamage; // Ensure CPlayerPed has post damage health/armor pBackupDamagedPlayer->GetGamePlayer()->SetHealth( fNewHealth ); pBackupDamagedPlayer->GetGamePlayer()->SetArmor( fNewArmor ); g_pClientGame->ApplyPedDamageFromGame( weaponType, fBackupDamage, ucBackupHitZone, pBackupDamagedPlayer, this, NULL ); SString strMessage( "Applied %0.2f damage to %s (from %s) due to network interruption", fBackupDamage, pBackupDamagedPlayer->GetNick(), GetNick() ); g_pClientGame->TellServerSomethingImportant( 1010, strMessage ); } } } }
void CNetworkPlayer::EnterVehicle( CNetworkVehicle * pVehicle, M2Enums::eVehicleSeat seat, bool bEnter ) { DEBUG_TRACE("CNetworkPlayer::EnterVehicle"); // Are we already entering? if ( IsEnteringVehicle() ) { CLogFile::Printf ( "WARNING: This player (%s) is already entering a vehicle, skipping!", GetNick().Get () ); return; } // Is the player ped and network vehicle active? if( m_pPlayerPed && pVehicle && IsSpawned() ) { // Clean up any sync objects TerminateSyncObjects (); // Should we put the player in the vehicle? if( bEnter ) { // Remove the ped from the vehicle if we're already in one if( InternalIsInVehicle() ) m_pPlayerPed->GetInOutVehicle( m_pPlayerPed->GetCurrentVehicle(), m_seat, false, true ); // Get our current position CVector3 vecPosition; GetPosition( &vecPosition ); // Get the vehicle position CVector3 vecVehiclePos; pVehicle->GetPosition( &vecVehiclePos ); // bool bForced = false; // Is the vehicle too far away? if( Math::GetDistanceBetweenPoints( vecPosition, vecVehiclePos ) > 4.0f ) // 2.68 = max distance bForced = true; CLogFile::Printf ( "EnterVehicle - Forced: %s", (bForced ? "Yes" : "No") ); // Is the vehicle invalid? if ( !pVehicle->GetVehicle() || !pVehicle->GetVehicle()->GetVehicle() ) { CLogFile::Printf ( "EnterVehicle - Invalid game vehicle, skipping to prevent crash!" ); return; } // Enter the vehicle m_VehicleEnter.m_pEnterAICommand = new CM2SyncObject( m_pPlayerPed->GetInOutVehicle( pVehicle->GetVehicle()->GetVehicle(), seat, true, bForced ) ); CLogFile::Printf ( "Done!" ); // Don't finish this sync object when we delete it m_VehicleEnter.m_pEnterAICommand->SetDoneOnDelete ( false ); // Handle this enter with the network vehicle pVehicle->HandlePlayerEnter( this, (seat - 1) ); } // Set the vehicle SetVehicle( pVehicle ); // Set the seat SetSeat( seat ); // Reset the target data SetEnteringVehicle( pVehicle, seat ); // Set the player state m_playerState = (seat == 1 ? ePlayerState::PLAYERSTATE_DRIVER : ePlayerState::PLAYERSTATE_PASSENGER); } }