Exemple #1
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;
}
Exemple #2
0
LPCTSTR CChatMember::GetChatName()
{
	ADDTOCALLSTACK("CChatMember::GetChatName");
	CClient *pClient = GetClient();
	if ( pClient )
	{
		if ( !pClient->m_UseNewChatSystem && (g_Cfg.m_iChatFlags & CHATF_CUSTOMNAMES) )
			return pClient->m_pAccount->m_sChatName;

		CChar *pChar = pClient->GetChar();
		if ( pChar )
			return pChar->GetName();
	}
	return "<NA>";
}
Exemple #3
0
bool CCharPlayer::r_LoadVal( CChar * pChar, CScript &s )
{
	ADDTOCALLSTACK("CCharPlayer::r_LoadVal");
	EXC_TRY("LoadVal");
	
	LPCTSTR pszKey = s.GetKey();

	if ( !strnicmp(pszKey, "GMPAGE", 6) )		//	GM pages
	{
		pszKey += 6;
		if ( *pszKey == '.' )						//	GMPAGE.*
		{
			SKIP_SEPARATORS(pszKey);
			size_t index = Exp_GetVal(pszKey);
			if ( index >= g_World.m_GMPages.GetCount() )
				return false;

			CGMPage* pPage = STATIC_CAST <CGMPage*> (g_World.m_GMPages.GetAt(index));
			if ( pPage == NULL )
				return false;

			SKIP_SEPARATORS(pszKey);
			if ( !strcmpi(pszKey, "HANDLE") )
			{
				CChar *ppChar = pChar;
				LPCTSTR pszArgs = s.GetArgStr(); //Moved here because of error with quoted strings!?!?
				if ( *pszArgs )
					ppChar = dynamic_cast<CChar*>(g_World.FindUID(s.GetArgVal()));

				if ( ppChar == NULL )
					return false;

				CClient *pClient = ppChar->GetClient();
				if ( pClient == NULL )
					return false;

				pPage->SetGMHandler(pClient);
			}
			else if ( !strcmpi(pszKey, "DELETE") )
			{
				delete pPage;
			}
			else if ( pPage->FindGMHandler() )
			{
				CClient* pClient = pChar->GetClient();
				if ( pClient != NULL && pClient->GetChar() != NULL )
					pClient->Cmd_GM_PageCmd(pszKey);
			}
			else
			{
				return false;
			}

			return true;
		}
		return false;
	}
	else if ( ( !strnicmp(pszKey, "GUILD", 5) ) || ( !strnicmp(pszKey, "TOWN", 4) ) )
	{
		bool bIsGuild = !strnicmp(pszKey, "GUILD", 5);
		pszKey += bIsGuild ? 5 : 4;
		if ( *pszKey == '.' )
		{
			pszKey += 1;
			CItemStone *pMyGuild = pChar->Guild_Find(bIsGuild ? MEMORY_GUILD : MEMORY_TOWN);
			if ( pMyGuild ) return pMyGuild->r_SetVal(pszKey, s.GetArgRaw());
		}
		return false;
	}

	switch ( FindTableHeadSorted( s.GetKey(), sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
		case CPC_DEATHS:
			m_wDeaths = static_cast<WORD>(s.GetArgVal());
			return true;
		case CPC_DSPEECH:
			return( m_Speech.r_LoadVal( s, RES_SPEECH ));
		case CPC_KILLS:
			m_wMurders = static_cast<WORD>(s.GetArgVal());
			pChar->NotoSave_Update();
			return true;
		case CPC_KRTOOLBARSTATUS:
			m_bKrToolbarEnabled = ( s.GetArgVal() != 0 );
			if ( pChar->IsClient() )
				pChar->GetClient()->addKRToolbar( m_bKrToolbarEnabled );
			return true;
		case CPC_LASTUSED:
			m_timeLastUsed = CServTime::GetCurrentTime() - ( s.GetArgVal() * TICK_PER_SEC );
			return( true );
		case CPC_PFLAG:
			{
				m_pflag = s.GetArgVal();
			} return( true );
		case CPC_PROFILE:
			m_sProfile = Str_MakeFiltered( s.GetArgStr());
			return( true );
		case CPC_REFUSETRADES:
			pChar->SetDefNum(s.GetKey(), s.GetArgVal() > 0 ? 1 : 0, false);
			return( true );
		case CPC_SKILLCLASS:
			return SetSkillClass( pChar, g_Cfg.ResourceGetIDType( RES_SKILLCLASS, s.GetArgStr()));
		case CPC_SKILLLOCK:
			{
				SKILL_TYPE skill = Skill_GetLockType( s.GetKey());
				if ( skill <= SKILL_NONE )
					return false;
				int bState = s.GetArgVal();
				if ( bState < SKILLLOCK_UP || bState > SKILLLOCK_LOCK )
					return false;
				Skill_SetLock(skill, static_cast<SKILLLOCK_TYPE>(bState));
			} return true;
		case CPC_SPEEDMODE:
			{
				m_speedMode = static_cast<unsigned short>(s.GetArgVal());
				pChar->UpdateSpeedMode();
			} return true;
		case CPC_STATLOCK:
			{
				STAT_TYPE stat = Stat_GetLockType( s.GetKey());
				if (( stat <= STAT_NONE ) || ( stat >= STAT_BASE_QTY ))
					return false;
				int bState = s.GetArgVal();
				if ( bState < SKILLLOCK_UP || bState > SKILLLOCK_LOCK )
					return false;
				Stat_SetLock(stat, static_cast<SKILLLOCK_TYPE>(bState));
			} return true;

		default:
			// Just ignore any NPC type stuff.
			if ( FindTableSorted( s.GetKey(), CCharNPC::sm_szLoadKeys, COUNTOF( CCharNPC::sm_szLoadKeys )-1 ) >= 0 )
			{
				return( true );
			}
			return( false );
	}
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPT;
	EXC_DEBUG_END;
	return false;
}
Exemple #4
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;
}