示例#1
0
void CChat::BroadcastRemoveChannel(CChatChannel *pChannel)
{
	ADDTOCALLSTACK("CChat::BroadcastRemoveChannel");
	// Send 'delete channel' message to all clients

	ClientIterator it;
	for ( CClient *pClient = it.next(); pClient != NULL; pClient = it.next() )
		pClient->addChatSystemMessage(CHATCMD_RemoveChannel, static_cast<LPCTSTR>(pChannel->m_sName));
}
示例#2
0
void CChat::BroadcastAddChannel(CChatChannel *pChannel)
{
	ADDTOCALLSTACK("CChat::BroadcastAddChannel");
	// Send 'add channel' message to all clients

	ClientIterator it;
	for ( CClient *pClient = it.next(); pClient != NULL; pClient = it.next() )
		pClient->addChatSystemMessage(CHATCMD_AddChannel, static_cast<LPCTSTR>(pChannel->m_sName), pClient->m_UseNewChatSystem ? NULL : pChannel->GetPasswordString());
}
示例#3
0
bool CRegionBase::r_Verb( CScript & s, CTextConsole * pSrc ) // Execute command from script
{
	ADDTOCALLSTACK("CRegionBase::r_Verb");
	EXC_TRY("Verb");
	LPCTSTR pszKey = s.GetKey();

	if ( !strnicmp(pszKey, "CLEARTAGS", 9) )
	{
		pszKey = s.GetArgStr();
		SKIP_SEPARATORS(pszKey);
		m_TagDefs.ClearKeys(pszKey);
		return true;
	}	

	int index = FindTableSorted(pszKey, sm_szVerbKeys, COUNTOF(sm_szVerbKeys) - 1);
	if ( index < 0 )
	{
		index = FindTableSorted(s.GetKey(), CSector::sm_szVerbKeys, SEV_QTY);
		if ( index >= 0 )
			return SendSectorsVerb(s.GetKey(), s.GetArgRaw(), pSrc);
	}

	switch ( static_cast<RV_TYPE>(index) )
	{
		case RV_ALLCLIENTS:
		{
			ClientIterator it;
			for (CClient* pClient = it.next(); pClient != NULL; pClient = it.next())
			{
				CChar * pChar = pClient->GetChar();
				if ( !pChar || (pChar->m_pArea != this) )
					continue;

				CScript script( s.GetArgStr() );
				pChar->r_Verb(script, pSrc);
			}
			return true;
		}
		case RV_TAGLIST:
		{
			m_TagDefs.DumpKeys( pSrc, "TAG." );
			return true;
		}

		default:
			break;
	}

	return CScriptObj::r_Verb(s, pSrc);
	EXC_CATCH;

	EXC_DEBUG_START;
	g_Log.EventDebug("command '%s' args '%s' [%p]\n", s.GetKey(), s.GetArgRaw(), static_cast<void *>(pSrc));
	EXC_DEBUG_END;
	return false;
}
示例#4
0
void CChat::SendNewChannel(CChatChannel * pNewChannel)
{
	ADDTOCALLSTACK("CChat::SendNewChannel");
	// Send this new channel name to all clients using the chat system
	ClientIterator it;
	for (CClient* pClient = it.next(); pClient != NULL; pClient = it.next())
	{
		if ( ! pClient->IsChatActive())
			continue;
		pClient->addChatSystemMessage(CHATMSG_SendChannelName, pNewChannel->GetName(), pNewChannel->GetModeString());
	}
}
示例#5
0
void CClient::Announce(bool fArrive) const
{
	ADDTOCALLSTACK("CClient::Announce");
	if ( !m_pAccount || !m_pChar || !m_pChar->m_pPlayer )
		return;

	// We have logged in or disconnected.
	// Annouce my arrival or departure.
	TCHAR *pszMsg = Str_GetTemp();
	if ( (g_Cfg.m_iArriveDepartMsg == 2) && (GetPrivLevel() > PLEVEL_Player) )		// notify of GMs
	{
		LPCTSTR pszTitle = m_pChar->Noto_GetFameTitle();
		sprintf(pszMsg, "@231 STAFF: %s%s logged %s.", pszTitle, m_pChar->GetName(), fArrive ? "in" : "out");
	}
	else if ( g_Cfg.m_iArriveDepartMsg == 1 )		// notify of players
	{
		const CRegionBase *pRegion = m_pChar->GetTopPoint().GetRegion(REGION_TYPE_AREA);
		sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_MSG_ARRDEP_1), m_pChar->GetName(), g_Cfg.GetDefaultMsg(fArrive ? DEFMSG_MSG_ARRDEP_2 : DEFMSG_MSG_ARRDEP_3), pRegion ? pRegion->GetName() : g_Serv.GetName());
	}
	if ( pszMsg )
	{
		ClientIterator it;
		for ( CClient *pClient = it.next(); pClient != NULL; pClient = it.next() )
		{
			if ( (pClient == this) || (GetPrivLevel() > pClient->GetPrivLevel()) )
				continue;
			pClient->SysMessage(pszMsg);
		}
	}

	// Check murder decay timer
	CItem *pMurders = m_pChar->LayerFind(LAYER_FLAG_Murders);
	if ( pMurders )
	{
		if ( fArrive )
		{
			// On client login, set active timer on murder memory
			pMurders->SetTimeout(pMurders->m_itEqMurderCount.m_Decay_Balance * TICK_PER_SEC);
		}
		else
		{
			// Or make it inactive on logout
			pMurders->m_itEqMurderCount.m_Decay_Balance = static_cast<DWORD>(pMurders->GetTimerAdjusted());
			pMurders->SetTimeout(-1);
		}
	}
	else if ( fArrive )
	{
		// If there's no murder memory found, check if we need a new memory
		m_pChar->Noto_Murder();
	}
}
示例#6
0
void CChat::SendDeleteChannel(CChatChannel * pChannel)
{
	ADDTOCALLSTACK("CChat::SendDeleteChannel");
	// Send a delete channel name message to all clients using the chat system
	
	ClientIterator it;
	for (CClient* pClient = it.next(); pClient != NULL; pClient = it.next())
	{
		if ( ! pClient->IsChatActive())
			continue;
		pClient->addChatSystemMessage(CHATMSG_RemoveChannelName, pChannel->GetName());
	}
}
示例#7
0
void CChat::Broadcast(CChatMember *pFrom, LPCTSTR pszText, CLanguageID lang, bool bOverride)
{
	ADDTOCALLSTACK("CChat::Broadcast");
	CGString sName;
	FormatName(sName, pFrom, bOverride);

	ClientIterator it;
	for ( CClient *pClient = it.next(); pClient != NULL; pClient = it.next() )
	{
		if ( !pClient->m_bChatActive )
			continue;
		if ( bOverride || pClient->m_bReceiving )
			pClient->SendChatMsg(CHATMSG_PlayerMessage, sName, pszText, lang);
	}
}
示例#8
0
void CChat::Broadcast(CChatChanMember *pFrom, LPCTSTR pszText, CLanguageID lang, bool fOverride)
{
	ADDTOCALLSTACK("CChat::Broadcast");
	ClientIterator it;
	for (CClient *pClient = it.next(); pClient != NULL; pClient = it.next())
	{
		if (!pClient->IsChatActive())
			continue;
		if (fOverride || pClient->IsReceivingAllowed())
		{
			CGString sName;
			DecorateName(sName, pFrom, fOverride);
			pClient->SendChatMsg(CHATMSG_PlayerTalk, sName, pszText, lang);
		}
	}
}
示例#9
0
void CChat::WhereIs(CChatChanMember * pBy, LPCTSTR pszName ) const
{
	ADDTOCALLSTACK("CChat::WhereIs");
	
	ClientIterator it;
	for (CClient* pClient = it.next(); pClient != NULL; pClient = it.next())
	{
		if ( ! strcmp( pClient->GetChatName(), pszName))
			continue;

		TCHAR *pszMsg = Str_GetTemp();
		if (! pClient->IsChatActive() || !pClient->GetChannel())
			sprintf(pszMsg, "%s is not currently in a conference.", pszName);
		else
			sprintf(pszMsg, "%s is in conference '%s'.", static_cast<LPCTSTR>(pszName), static_cast<LPCTSTR>(pClient->GetChannel()->GetName()));
		CGString sFrom;
		DecorateName(sFrom, NULL, true);
		pBy->SendChatMsg(CHATMSG_PlayerTalk, sFrom, pszMsg);
		return;
	}

	pBy->SendChatMsg(CHATMSG_NoPlayer, pszName);
}
示例#10
0
void CChat::WhereIs(CChatChanMember * pBy, lpctstr pszName ) const
{
	ADDTOCALLSTACK("CChat::WhereIs");
	
	ClientIterator it;
	for (CClient* pClient = it.next(); pClient != nullptr; pClient = it.next())
	{
		if ( ! strcmp( pClient->GetChatName(), pszName))
			continue;

		tchar *pszMsg = Str_GetTemp();
		if (! pClient->IsChatActive() || !pClient->GetChannel())
			sprintf(pszMsg, "%s is not currently in a conference.", pszName);
		else
			sprintf(pszMsg, "%s is in conference '%s'.", pszName, pClient->GetChannel()->GetName());
		CSString sFrom;
		DecorateName(sFrom, nullptr, true);
		pBy->SendChatMsg(CHATMSG_PlayerTalk, sFrom, pszMsg);
		return;
	}

	pBy->SendChatMsg(CHATMSG_NoPlayer, pszName);
}
示例#11
0
bool CWebPageDef::r_Verb( CScript & s, CTextConsole * pSrc )	// some command on this object as a target
{
	ADDTOCALLSTACK("CWebPageDef::r_Verb");
	EXC_TRY("Verb");
	ASSERT(pSrc);
	sm_iListIndex = 0;
	TCHAR *pszTmp2 = Str_GetTemp();

	WV_TYPE iHeadKey = (WV_TYPE) FindTableSorted( s.GetKey(), sm_szVerbKeys, COUNTOF(sm_szVerbKeys)-1 );
	switch ( iHeadKey )
	{
		case WV_WEBPAGE:
		{
			// serv a web page to the pSrc
			CClient *pClient = dynamic_cast<CClient *>(pSrc);
			if ( !pClient )
				return false;
			return ServPage(pClient, s.GetArgStr(), NULL);
		}
	
		case WV_CLIENTLIST:
		{
			ClientIterator it;
			for ( CClient *pClient = it.next(); pClient != NULL; pClient = it.next() )
			{
				CChar *pChar = pClient->GetChar();
				if ( !pChar )
					continue;
				if ( pChar->IsStatFlag(STATF_Insubstantial) && (pClient->GetPrivLevel() > PLEVEL_Player) )
					continue;

				sm_iListIndex++;

				LPCTSTR pszArgs = s.GetArgStr();
				if ( pszArgs[0] == '\0' )
					pszArgs = "<tr><td>%NAME%</td><td>%REGION.NAME%</td></tr>\n";
				strcpy(pszTmp2, pszArgs);
				pChar->ParseText(Str_MakeFiltered(pszTmp2), &g_Serv, 1);
				pSrc->SysMessage(pszTmp2);
			}
			break;
		}
	
		case WV_GUILDLIST:
		case WV_TOWNLIST:
		{
			if ( !s.HasArgs() )
				return false;

			IT_TYPE	needtype = (iHeadKey == WV_GUILDLIST) ? IT_STONE_GUILD : IT_STONE_TOWN;

			for ( size_t i = 0; i < g_World.m_Stones.GetCount(); i++ )
			{
				CItemStone *pStone = g_World.m_Stones[i];
				if ( !pStone || !pStone->IsType(needtype) )
					continue;

				sm_iListIndex++;

				strcpy(pszTmp2, s.GetArgStr());
				pStone->ParseText(Str_MakeFiltered(pszTmp2), &g_Serv, 1);
				pSrc->SysMessage(pszTmp2);
			}
			break;
		}

		case WV_GMPAGELIST:
		{
			if ( !s.HasArgs() )
				return false;
			CGMPage *pPage = static_cast<CGMPage *>(g_World.m_GMPages.GetHead());
			for ( ; pPage != NULL; pPage = pPage->GetNext() )
			{
				sm_iListIndex++;
				strcpy(pszTmp2, s.GetArgStr());
				pPage->ParseText(Str_MakeFiltered(pszTmp2), &g_Serv, 1);
				pSrc->SysMessage(pszTmp2);
			}
			break;
		}
	
		default:
			return CResourceLink::r_Verb(s, pSrc);
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPTSRC;
	EXC_DEBUG_END;
	return false;
}