当前位置: 首页>>代码示例>>C++>>正文


C++ CGameContext::ProcessSpamProtection方法代码示例

本文整理汇总了C++中CGameContext::ProcessSpamProtection方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameContext::ProcessSpamProtection方法的具体用法?C++ CGameContext::ProcessSpamProtection怎么用?C++ CGameContext::ProcessSpamProtection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGameContext的用法示例。


在下文中一共展示了CGameContext::ProcessSpamProtection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ConPrivMsg

void CGameContext::ConPrivMsg(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *) pUserData;
    
	int to = pResult->GetVictim();
    
	if(!CheckClientID(to))
		return;
	if(CheckClientID(pResult->m_ClientID) && pSelf->ProcessSpamProtection(pResult->m_ClientID))
		return;
    
	char message[512];
	str_format(message, sizeof(message), "PM -> %s: ", pSelf->Server()->ClientName(to));
	str_append(message, pResult->GetString(0), sizeof(message));
    
	CNetMsg_Sv_Chat Msg;
	Msg.m_Team = 1;
	Msg.m_ClientID = CheckClientID(pResult->m_ClientID) ? pResult->m_ClientID : -1;
	Msg.m_pMessage = message;
	pSelf->Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, to);
	
	if(CheckClientID(pResult->m_ClientID))
	{
		pSelf->Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, pResult->m_ClientID);
		str_format(message, sizeof(message), "\"%s\" -> \"%s\" : %s", 
			   pSelf->Server()->ClientName(pResult->m_ClientID),
			   pSelf->Server()->ClientName(to),
			   pResult->GetString(0));

	}
	else
	{
		str_format(message, sizeof(message), "%d -> \"%s\" : %s", 
			   pResult->m_ClientID,
			   pSelf->Server()->ClientName(to),
			   pResult->GetString(0));
	}
	pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "pmchat", message);
}
开发者ID:ftk,项目名称:XXLDDRace,代码行数:39,代码来源:ddracechat.cpp

示例2: ConSwap

void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *) pUserData;
	const int ClientID = pResult->m_ClientID;

	if(!g_Config.m_SvSwap)
	{
		pSelf->SendChatTarget(ClientID, "Swap is not activated");
		return;
	}
	
	int ToSwap = pResult->GetVictim();
	if(!CheckClientID(ToSwap) || ClientID == ToSwap)
		ToSwap = -1;

	if(!CheckClientID(ClientID))
		return;
	
	pSelf->m_aSwapRequest[ClientID] = ToSwap;
	if(ToSwap == -1)
		return;
	
	if(pSelf->ProcessSpamProtection(ClientID)) // dont flood
		return;
	
	// check if ToSwap agrees
	char aBuf[128];
	if(pSelf->m_aSwapRequest[ToSwap] != ClientID)
	{
		// send  notification to ToSwap
		str_format(aBuf, sizeof(aBuf), "%s wants to swap places with you. Type \'/swap %d\' to accept.",
			   pSelf->Server()->ClientName(ClientID), ClientID);
		pSelf->SendChatTarget(ToSwap, aBuf);
		
		str_format(aBuf, sizeof(aBuf), "Requst sent to %s.",
			   pSelf->Server()->ClientName(ToSwap));
		pSelf->SendChatTarget(ClientID, aBuf);
	}
	else
	{
		// ToSwap agreed
		CCharacter * pChar1 = pSelf->GetPlayerChar(ClientID);
		CCharacter * pChar2 = pSelf->GetPlayerChar(ToSwap);
		if(!pChar1 || !pChar2 || pChar1->Team() != pChar2->Team())
		{
			// one is not alive or not in the same team
			const char * pStr = "Can\'t swap!";
			pSelf->SendChatTarget(ToSwap, pStr);
			pSelf->SendChatTarget(ClientID, pStr);
			return;
		}

		CPlayerRescueState state1 = GetPlayerState(pChar1),
			state2 = GetPlayerState(pChar2);
		
		// swap
		ApplyPlayerState(state2, pChar1);
		ApplyPlayerState(state1, pChar2);
		
		str_format(aBuf, sizeof(aBuf), "%s swapped with %s.",
			   pSelf->Server()->ClientName(ToSwap),
			   pSelf->Server()->ClientName(ClientID));
		pSelf->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
		// reset swap requests
		pSelf->m_aSwapRequest[ToSwap] = -1;
		pSelf->m_aSwapRequest[ClientID] = -1;
	}
}
开发者ID:ftk,项目名称:XXLDDRace,代码行数:68,代码来源:ddracechat.cpp


注:本文中的CGameContext::ProcessSpamProtection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。