Exemplo n.º 1
0
bool CVarDefContNum::r_WriteVal( LPCTSTR pKey, CGString & sVal, CTextConsole * pSrc = NULL )
{
	UNREFERENCED_PARAMETER(pKey);
	UNREFERENCED_PARAMETER(pSrc);
	sVal.FormatLLVal( GetValNum() );
	return( true );
}
Exemplo n.º 2
0
bool CClient::r_WriteVal( LPCTSTR pszKey, CGString & sVal, CTextConsole * pSrc )
{
	ADDTOCALLSTACK("CClient::r_WriteVal");
	EXC_TRY("WriteVal");
	int index;

	if ( !strnicmp("CTAG.", pszKey, 5) )		//	CTAG.xxx - client tag
	{
		if ( pszKey[4] != '.' )
			return( false );
		pszKey += 5;
		CVarDefCont *vardef = m_TagDefs.GetKey(pszKey);
		sVal = vardef ? vardef->GetValStr() : "";
		return true;
	}

	if ( !strnicmp("CTAG0.", pszKey, 6) )		//	CTAG0.xxx - client tag
	{
		if ( pszKey[5] != '.' )
			return( false );
		pszKey += 6;
		CVarDefCont *vardef = m_TagDefs.GetKey(pszKey);
		sVal = vardef ? vardef->GetValStr() : "0";
		return true;
	}

	if ( !strnicmp( "TARGP", pszKey, 5 ) && ( pszKey[5] == '\0' || pszKey[5] == '.' ) )
		index = CC_TARGP;
	else if ( !strnicmp( "SCREENSIZE", pszKey, 10 ) && ( pszKey[10] == '\0' || pszKey[10] == '.' ) )
		index = CC_SCREENSIZE;
	else if ( !strnicmp( "REPORTEDCLIVER", pszKey, 14 ) && ( pszKey[14] == '\0' || pszKey[14] == '.' ) )
		index = CC_REPORTEDCLIVER;
	else
		index	= FindTableSorted( pszKey, sm_szLoadKeys, COUNTOF(sm_szLoadKeys)-1 );

	switch (index)
	{
		case CC_ALLMOVE:
			sVal.FormatVal( IsPriv( PRIV_ALLMOVE ));
			break;
		case CC_ALLSHOW:
			sVal.FormatVal( IsPriv( PRIV_ALLSHOW ));
			break;
		case CC_CLIENTIS3D:
			sVal.FormatVal( GetNetState()->isClient3D() );
			break;
		case CC_CLIENTISKR:
			sVal.FormatVal( GetNetState()->isClientKR() );
			break;
		case CC_CLIENTISSA:
			sVal.FormatVal( GetNetState()->isClientSA() );
			break;
		case CC_CLIENTVERSION:
			{
				TCHAR szVersion[ 128 ];
				sVal = m_Crypt.WriteClientVer( szVersion );
			}
			break;
		case CC_DEBUG:
			sVal.FormatVal( IsPriv( PRIV_DEBUG ));
			break;
		case CC_DETAIL:
			sVal.FormatVal( IsPriv( PRIV_DETAIL ));
			break;
		case CC_GM:	// toggle your GM status on/off
			sVal.FormatVal( IsPriv( PRIV_GM ));
			break;
		case CC_HEARALL:
			sVal.FormatVal( IsPriv( PRIV_HEARALL ));
			break;
		case CC_LASTEVENT:
			sVal.FormatLLVal( m_timeLastEvent.GetTimeRaw() );
			break;
		case CC_PRIVSHOW:
			// Show my priv title.
			sVal.FormatVal( ! IsPriv( PRIV_PRIV_NOSHOW ));
			break;
		case CC_REPORTEDCLIVER:
			{
				pszKey += strlen(sm_szLoadKeys[index]);
				GETNONWHITESPACE( pszKey );

				int iCliVer = (GetNetState()->getReportedVersion() & 0xFFFFFF0);
				if ( pszKey[0] != '\0' )
					iCliVer = GetNetState()->getReportedVersion();

				TCHAR szVersion[128];
				sVal = CCrypt::WriteClientVerString( iCliVer, szVersion );
			}
			break;
		case CC_SCREENSIZE:
			{
				if ( pszKey[10] == '.' )
				{
					pszKey += strlen(sm_szLoadKeys[index]);
					SKIP_SEPARATORS(pszKey);

					if ( !strnicmp("X", pszKey, 1) )
						sVal.Format( "%lu", m_ScreenSize.x );
					else if ( !strnicmp("Y", pszKey, 1) )
						sVal.Format( "%lu", m_ScreenSize.y );
					else
						return( false );
				}
				else
					sVal.Format( "%lu,%lu", m_ScreenSize.x, m_ScreenSize.y );
			} break;
		case CC_TARG:
			sVal.FormatHex(m_Targ_UID);
			break;
		case CC_TARGP:
			if ( pszKey[5] == '.' )
			{
				return m_Targ_p.r_WriteVal( pszKey+6, sVal );
			}
			sVal = m_Targ_p.WriteUsed();
			break;
		case CC_TARGPROP:
			sVal.FormatHex(m_Prop_UID);
			break;
		case CC_TARGPRV:
			sVal.FormatHex(m_Targ_PrvUID);
			break;
		case CC_TARGTXT:
			sVal = m_Targ_Text;
			break;
		default:
			return( CScriptObj::r_WriteVal( pszKey, sVal, pSrc ));
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
Exemplo n.º 3
0
bool CCharNPC::r_WriteVal( CChar * pChar, LPCTSTR pszKey, CGString & sVal )
{
	EXC_TRY("WriteVal");
	switch ( FindTableSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
	
	//return as string or hex number or NULL if not set
	//On these ones, check BaseDef too if not found on dynamic
	case CNC_THROWDAM:
	case CNC_THROWOBJ:
	case CNC_THROWRANGE:
		sVal = pChar->GetDefStr(pszKey, false, true);
		break;
	//return as decimal number or 0 if not set
	//On these ones, check BaseDef if not found on dynamic
	case CNC_BONDED:
		sVal.FormatVal( m_bonded );
		break;
	case CNC_FOLLOWERSLOTS:
		sVal.FormatLLVal(pChar->GetDefNum(pszKey, true, true));
		break;
	case CNC_ACTPRI:
		sVal.FormatVal( m_Act_Motivation );
		break;
	case CNC_NPC:
		sVal.FormatVal( m_Brain );
		break;
	case CNC_HOMEDIST:
		sVal.FormatVal( m_Home_Dist_Wander );
		break;
	case CNC_NEED:
		{
			TCHAR *pszTmp = Str_GetTemp();
			m_Need.WriteKey( pszTmp );
			sVal = pszTmp;
		}
		break;
	case CNC_NEEDNAME:
		{
			TCHAR *pszTmp = Str_GetTemp();
			m_Need.WriteNameSingle( pszTmp );
			sVal = pszTmp;
		}
		break;
	case CNC_SPEECH:
		m_Speech.WriteResourceRefList( sVal );
		break;
	case CNC_SPEECHCOLOR:
		sVal.FormatVal( m_SpeechHue );
		break;
	case CNC_VENDCAP:
		{
			CItemContainer * pBank = pChar->GetBank();
			if ( pBank )
				sVal.FormatVal( pBank->m_itEqBankBox.m_Check_Restock );
		}
		break;
	case CNC_VENDGOLD:
		{
			CItemContainer * pBank = pChar->GetBank();
			if ( pBank )
				sVal.FormatVal( pBank->m_itEqBankBox.m_Check_Amount );
		}
		break;
	default:
		if ( FindTableHeadSorted( pszKey, CCharPlayer::sm_szLoadKeys, COUNTOF( CCharPlayer::sm_szLoadKeys )-1 ) >= 0 )
		{
			sVal = "0";
			return( true );
		}
		if ( FindTableSorted( pszKey, CClient::sm_szLoadKeys, CC_QTY ) >= 0 )
		{
			sVal = "0";
			return( true );
		}
		return(false );
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pChar);
	EXC_DEBUG_END;
	return false;
}
Exemplo n.º 4
0
bool CCharPlayer::r_WriteVal( CChar * pChar, LPCTSTR pszKey, CGString & sVal )
{
	ADDTOCALLSTACK("CCharPlayer::r_WriteVal");
	EXC_TRY("WriteVal");

	if ( !pChar || !GetAccount() )
		return false;

	if ( !strnicmp(pszKey, "SKILLCLASS.", 11) )
	{
		return GetSkillClass()->r_WriteVal(pszKey + 11, sVal, pChar);
	}
	else if ( ( !strnicmp(pszKey, "GUILD", 5) ) || ( !strnicmp(pszKey, "TOWN", 4) ) )
	{
		bool bIsGuild = !strnicmp(pszKey, "GUILD", 5);
		pszKey += bIsGuild ? 5 : 4;
		if ( *pszKey == 0 )
		{
			CItemStone *pMyGuild = pChar->Guild_Find(bIsGuild ? MEMORY_GUILD : MEMORY_TOWN);
			if ( pMyGuild ) sVal.FormatHex((DWORD)pMyGuild->GetUID());
			else sVal.FormatVal(0);
			return true;
		}
		else if ( *pszKey == '.' )
		{
			pszKey += 1;
			CItemStone *pMyGuild = pChar->Guild_Find(bIsGuild ? MEMORY_GUILD : MEMORY_TOWN);
			if ( pMyGuild ) return pMyGuild->r_WriteVal(pszKey, sVal, pChar);
		}
		return false;
	}

	switch ( FindTableHeadSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
		case CPC_ACCOUNT:
			sVal = GetAccount()->GetName();
			return( true );
		case CPC_DEATHS:
			sVal.FormatVal( m_wDeaths );
			return( true );
		case CPC_DSPEECH:
			m_Speech.WriteResourceRefList( sVal );
			return( true );
		case CPC_KILLS:
			sVal.FormatVal( m_wMurders );
			return( true );
		case CPC_KRTOOLBARSTATUS:
			sVal.FormatVal( m_bKrToolbarEnabled );
			return true;
		case CPC_ISDSPEECH:
			if ( pszKey[9] != '.' )
				return( false );
			pszKey += 10;
			sVal = m_Speech.ContainsResourceName(RES_SPEECH, pszKey) ? "1" : "0";
			return( true );
		case CPC_LASTUSED:
			sVal.FormatLLVal( - g_World.GetTimeDiff( m_timeLastUsed ) / TICK_PER_SEC );
			return( true );
		case CPC_PFLAG:
			sVal.FormatVal(m_pflag);
			return( true );
		case CPC_PROFILE:
			{
				TCHAR szLine[SCRIPT_MAX_LINE_LEN-16];
				Str_MakeUnFiltered( szLine, m_sProfile, sizeof(szLine));
				sVal = szLine;
			}
			return( true );
		case CPC_REFUSETRADES:
			{
				CVarDefCont * pVar = pChar->GetDefKey(pszKey, true);
				sVal.FormatLLVal(pVar ? pVar->GetValNum() : 0);
			}
			return( true );
		case CPC_SKILLCLASS:
			sVal = GetSkillClass()->GetResourceName();
			return( true );
		case CPC_SKILLLOCK:
			{
				// "SkillLock[alchemy]"
				SKILL_TYPE skill = Skill_GetLockType( pszKey );
				if ( skill <= SKILL_NONE )
					return( false );
				sVal.FormatVal( Skill_GetLock( skill ));
			} return( true );
		case CPC_SPEEDMODE:
			sVal.FormatVal( m_speedMode );
			return( true );
		case CPC_STATLOCK:
			{
				// "StatLock[str]"
				STAT_TYPE stat = Stat_GetLockType( pszKey );
				if (( stat <= STAT_NONE ) || ( stat >= STAT_BASE_QTY ))
					return( false );
				sVal.FormatVal( Stat_GetLock( stat ));
			} return( true );
		default:
			if ( FindTableSorted( pszKey, CCharNPC::sm_szLoadKeys, COUNTOF( CCharNPC::sm_szLoadKeys )-1 ) >= 0 )
			{
				sVal = "0";
				return( true );
			}
			return( false );
	}
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pChar);
	EXC_DEBUG_END;
	return false;
}
Exemplo n.º 5
0
bool CBaseBaseDef::r_WriteVal( LPCTSTR pszKey, CGString & sVal, CTextConsole * pSrc )
{
	ADDTOCALLSTACK("CBaseBaseDef::r_WriteVal");
	EXC_TRY("WriteVal");
	bool	fZero	= false;
	int index = FindTableHeadSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 );

	switch ( index )
	{
		//return as string or hex number or NULL if not set
		case OBC_CATEGORY:
		case OBC_DESCRIPTION:
		case OBC_SUBSECTION:
		case OBC_HITSPELL:
		case OBC_SLAYER:
		case OBC_SLAYERLESSER:
		case OBC_SLAYERMISC:
		case OBC_SLAYERSUPER:
		case OBC_ABILITYPRIMARY:
		case OBC_ABILITYSECONDARY:
		case OBC_MANABURST:
			sVal = GetDefStr(pszKey, false);
			break;
		//return as decimal number or 0 if not set
		case OBC_BALANCED:
		case OBC_BANE:
		case OBC_BATTLELUST:
		case OBC_BLOODDRINKER:
		case OBC_CASTINGFOCUS:
		case OBC_DAMCHAOS:
		case OBC_DAMCOLD:
		case OBC_DAMDIRECT:
		case OBC_DAMENERGY:
		case OBC_DAMFIRE:
		case OBC_DAMMODIFIER:
		case OBC_DAMPHYSICAL:
		case OBC_DECREASEHITCHANCE:
		case OBC_DAMPOISON:
		case OBC_EATERCOLD:
		case OBC_EATERDAM:
		case OBC_EATERENERGY:
		case OBC_EATERFIRE:
		case OBC_EATERKINETIC:
		case OBC_EATERPOISON:
		case OBC_ENHANCEPOTIONS:
		case OBC_EXPANSION:
		case OBC_FASTERCASTING:
		case OBC_FASTERCASTRECOVERY:
		case OBC_HITAREACOLD:
		case OBC_HITAREAENERGY:
		case OBC_HITAREAFIRE:
		case OBC_HITAREAPHYSICAL:
		case OBC_HITAREAPOISON:
		case OBC_HITCURSE:
		case OBC_HITDISPEL:
		case OBC_HITFATIGUE:
		case OBC_HITFIREBALL:
		case OBC_HITHARM:
		case OBC_HITLEECHLIFE:
		case OBC_HITLEECHMANA:
		case OBC_HITLEECHSTAM:
		case OBC_HITLIGHTNING:
		case OBC_HITLOWERATK:
		case OBC_HITLOWERDEF:
		case OBC_HITMAGICARROW:
		case OBC_HITMANADRAIN:
		case OBC_INCREASEDAM:
		case OBC_INCREASEDEFCHANCE:
		case OBC_INCREASEDEFCHANCEMAX:
		case OBC_INCREASEHITCHANCE:
		case OBC_INCREASEGOLD:
		case OBC_INCREASEKARMALOSS:
		case OBC_INCREASESPELLDAM:
		case OBC_INCREASESWINGSPEED:
		case OBC_LOWERAMMOCOST:
		case OBC_LOWERMANACOST:
		case OBC_LOWERREAGENTCOST:
		case OBC_LOWERREQ:
		case OBC_LUCK:
		case OBC_MANABURSTFREQUENCY:
		case OBC_MANABURSTKARMA:
		case OBC_NIGHTSIGHT:
		case OBC_RAGEFOCUS:
		case OBC_REACTIVEPARALYZE:
		case OBC_REFLECTPHYSICALDAM:
		case OBC_REGENFOOD:
		case OBC_REGENHITS:
		case OBC_REGENMANA:
		case OBC_REGENSTAM:
		case OBC_REGENVALFOOD:
		case OBC_REGENVALHITS:
		case OBC_REGENVALMANA:
		case OBC_REGENVALSTAM:
		case OBC_RESCOLD:
		case OBC_RESFIRE:
		case OBC_RESENERGY:
		case OBC_RESPHYSICAL:
		case OBC_RESPOISON:
		case OBC_RESCOLDMAX:
		case OBC_RESFIREMAX:
		case OBC_RESENERGYMAX:
		case OBC_RESPHYSICALMAX:
		case OBC_RESPOISONMAX:
		case OBC_RESONANCECOLD:
		case OBC_RESONANCEENERGY:
		case OBC_RESONANCEFIRE:
		case OBC_RESONANCEKINETIC:
		case OBC_RESONANCEPOISON:
		case OBC_SOULCHARGE:
		case OBC_SOULCHARGECOLD:
		case OBC_SOULCHARGEENERGY:
		case OBC_SOULCHARGEFIRE:
		case OBC_SOULCHARGEKINETIC:
		case OBC_SOULCHARGEPOISON:
		case OBC_SPELLCONSUMPTION:
		case OBC_SPELLFOCUSING:
		case OBC_SPLINTERINGWEAPON:
		case OBC_VELOCITY:
		case OBC_SPELLCHANNELING:
		case OBC_NAMELOC:
		case OBC_HITSPELLSTR:
		case OBC_WEIGHTREDUCTION:
		case OBC_COMBATBONUSSTAT:
		case OBC_COMBATBONUSPERCENT:
			sVal.FormatLLVal(GetDefNum(pszKey, true));
			break;

		case OBC_DEFNAME:
			sVal = GetResourceName();
			break;

		case OBC_ARMOR:
			{
				pszKey += strlen(sm_szLoadKeys[index]); // 9;
				if ( *pszKey == '.' )
				{
					SKIP_SEPARATORS( pszKey );

					if ( !strnicmp( pszKey, "LO", 2 ) )
					{
						sVal.Format( "%d", m_defenseBase );
					}
					else if ( !strnicmp( pszKey, "HI", 2 ) )
					{
						sVal.Format( "%d", m_defenseBase+m_defenseRange );
					}
				}
				else
				{
					sVal.Format( "%d,%d", m_defenseBase, m_defenseBase+m_defenseRange );
				}
			} break;
		case OBC_DAM:
			{
				pszKey += strlen(sm_szLoadKeys[index]); // 9;
				if ( *pszKey == '.' )
				{
					SKIP_SEPARATORS( pszKey );

					if ( !strnicmp( pszKey, "LO", 2 ) )
					{
						sVal.Format( "%d", m_attackBase );
					}
					else if ( !strnicmp( pszKey, "HI", 2 ) )
					{
						sVal.Format( "%d", m_attackBase+m_attackRange );
					}
				}
				else
				{
					sVal.Format( "%d,%d", m_attackBase, m_attackBase+m_attackRange );
				}
			} break;
		case OBC_BASEID:
			sVal = g_Cfg.ResourceGetName( GetResourceID());
			break;
		case OBC_CAN:
			sVal.FormatHex( m_Can );
			break;
		case OBC_HEIGHT:
			{
				//CBaseBaseDef * pBaseBaseDef = dynamic_cast<CBaseBaseDef*>(this);
				//DEBUG_ERR(("OBC_HEIGHT  -  m_dwDispIndex %d  GetHeight() %d  pBaseBaseDef->GetHeight() %d  pBaseBaseDef 0x%x\n",m_wDispIndex,GetHeight(),pBaseBaseDef->GetHeight(),pBaseBaseDef));
				sVal.FormatVal( GetHeight() );
			}
			break;
		case OBC_INSTANCES:
			sVal.FormatVal( GetRefInstances());
			break;
		case OBC_NAME:
			sVal = GetName();
			break;

		case OBC_RANGE:
			if ( RangeH() == 0 ) sVal.Format( "%d", RangeL() );
			else sVal.Format( "%d,%d", RangeH(), RangeL() );
			break;
		case OBC_RANGEL: // internally: rangel seems to be Range Highest value
			sVal.FormatVal( RangeH() );
			break;
		case OBC_RANGEH: // but rangeh seems to be the Range Lowest value.
			sVal.FormatVal( RangeL() );
			break;

		case OBC_RESOURCES:		// Print the resources
			{
				pszKey += strlen(sm_szLoadKeys[index]); // 9;
				if ( *pszKey == '.' )
				{
					SKIP_SEPARATORS( pszKey );

					if ( !strnicmp( pszKey, "COUNT", 5 ))
					{
						sVal.FormatVal(m_BaseResources.GetCount());
					}
					else
					{
						bool fQtyOnly = false;
						bool fKeyOnly = false;
						index = Exp_GetVal( pszKey );
						SKIP_SEPARATORS( pszKey );

						if ( !strnicmp( pszKey, "KEY", 3 ))
							fKeyOnly	= true;
						else if ( !strnicmp( pszKey, "VAL", 3 ))
							fQtyOnly	= true;

						TCHAR *pszTmp = Str_GetTemp();
						m_BaseResources.WriteKeys( pszTmp, index, fQtyOnly, fKeyOnly );
						if ( fQtyOnly && pszTmp[0] == '\0' )
							strcpy( pszTmp, "0" );

						sVal = pszTmp;
					}
				}
				else
				{
					TCHAR *pszTmp = Str_GetTemp();
					m_BaseResources.WriteKeys( pszTmp );
					sVal = pszTmp;
				}
			}
			break;
		case OBC_RESLEVEL:
			sVal.FormatVal( GetResLevel() );
			break;
		case OBC_RESDISPDNHUE:
			sVal.FormatHex( GetResDispDnHue() );
			break;
		case OBC_TAG0:
			fZero	= true;
			pszKey++;
		case OBC_TAG:			// "TAG" = get/set a local tag.
			if ( pszKey[3] != '.' )
				return( false );
			pszKey += 4;
			sVal = m_TagDefs.GetKeyStr(pszKey, fZero );
			break;
		case OBC_TEVENTS:
			m_TEvents.WriteResourceRefList( sVal );
			break;
		default:
			return false;
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
Exemplo n.º 6
0
bool CServerDef::r_WriteVal( LPCTSTR pszKey, CGString &sVal, CTextConsole * pSrc )
{
	ADDTOCALLSTACK("CServerDef::r_WriteVal");
	EXC_TRY("WriteVal");
	switch ( FindTableSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
	case SC_ACCAPP:
		sVal.FormatVal( m_eAccApp );
		break;
	case SC_ACCAPPS:
		// enum string
		ASSERT( m_eAccApp >= 0 && m_eAccApp < ACCAPP_QTY );
		sVal = sm_AccAppTable[ m_eAccApp ];
		break;
	case SC_ADMINEMAIL:
		sVal = m_sEMail;
		break;
	case SC_AGE:
		// display the age in days.
		sVal.FormatLLVal( GetAgeHours()/24 );
		break;
	case SC_CLIENTVERSION:
		{
			TCHAR szVersion[ 128 ];
			sVal = m_ClientVersion.WriteClientVer( szVersion );
		}
		break;
	case SC_CREATE:
		sVal.FormatLLVal( -( g_World.GetTimeDiff(m_timeCreate) / TICK_PER_SEC ));
		break;
	case SC_LANG:
		sVal = m_sLang;
		break;

	case SC_LASTVALIDDATE:
		if ( m_timeLastValid.IsTimeValid() )
			sVal.FormatLLVal( GetTimeSinceLastValid() / ( TICK_PER_SEC * 60 ));
		else
			sVal = "NA";
		break;
	case SC_LASTVALIDTIME:
		// How many seconds ago.
		sVal.FormatLLVal( m_timeLastValid.IsTimeValid() ? ( GetTimeSinceLastValid() / TICK_PER_SEC ) : -1 );
		break;
	case SC_SERVIP:
		sVal = m_ip.GetAddrStr();
		break;
	case SC_NAME:
	case SC_SERVNAME:
		sVal = GetName();	// What the name should be. Fill in from ping.
		break;
	case SC_SERVPORT:
		sVal.FormatVal( m_ip.GetPort());
		break;
	case SC_ACCOUNTS:
		sVal.FormatVal( StatGet( SERV_STAT_ACCOUNTS ));
		break;
	case SC_CLIENTS:
		sVal.FormatVal( StatGet( SERV_STAT_CLIENTS ));
		break;
	case SC_ITEMS:
		sVal.FormatVal( StatGet( SERV_STAT_ITEMS ));
		break;
	case SC_MEM:
		sVal.FormatVal( StatGet( SERV_STAT_MEM ) );
		break;
	case SC_CHARS:
		sVal.FormatVal( StatGet( SERV_STAT_CHARS ));
		break;
	case SC_TIMEZONE:
		sVal.FormatVal( m_TimeZone );
		break;
	case SC_URL:
		sVal = m_sURL;
		break;
	case SC_URLLINK:
		// try to make a link of it.
		if ( m_sURL.IsEmpty())
		{
			sVal = GetName();
			break;
		}
		sVal.Format("<a href=\"http://%s\">%s</a>", static_cast<LPCTSTR>(m_sURL), GetName());
		break;
	case SC_VERSION:
		sVal = GRAY_VERSION;
		break;
	default:
		{
			LPCTSTR pszArgs = strchr(pszKey, ' ');
			if (pszArgs != NULL)
				GETNONWHITESPACE(pszArgs);

			CScriptTriggerArgs Args( pszArgs ? pszArgs : "" );
			if ( r_Call( pszKey, pSrc, &Args, &sVal ) )
				return true;

			return( CScriptObj::r_WriteVal( pszKey, sVal, pSrc ));
		}
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
Exemplo n.º 7
0
bool CBaseBaseDef::r_WriteVal(LPCTSTR pszKey, CGString &sVal, CTextConsole *pSrc)
{
	ADDTOCALLSTACK("CBaseBaseDef::r_WriteVal");
	EXC_TRY("WriteVal");
	bool fZero = false;

	switch ( FindTableHeadSorted(pszKey, sm_szLoadKeys, COUNTOF(sm_szLoadKeys) - 1) )
	{
		// Return as string or hex number (NULL if not set)
		case OBC_CATEGORY:
		case OBC_DESCRIPTION:
		case OBC_SUBSECTION:
			sVal = GetDefStr(pszKey, false);
			break;
		// Return as decimal number (0 if not set)
		case OBC_COMBATBONUSPERCENT:
		case OBC_COMBATBONUSSTAT:
		case OBC_DAMCHAOS:
		case OBC_DAMDIRECT:
		case OBC_EXPANSION:
		case OBC_NAMELOC:
		case OBC_REGENFOOD:
		case OBC_REGENHITS:
		case OBC_REGENMANA:
		case OBC_REGENSTAM:
		case OBC_REGENVALFOOD:
		case OBC_REGENVALHITS:
		case OBC_REGENVALMANA:
		case OBC_REGENVALSTAM:
			sVal.FormatLLVal(GetDefNum(pszKey));
			break;
		case OBC_ARMOR:
		{
			pszKey += 5;
			if ( *pszKey == '.' )
			{
				SKIP_SEPARATORS(pszKey);
				if ( !strnicmp(pszKey, "LO", 2) )
					sVal.Format("%hu", m_defenseBase);
				else if ( !strnicmp(pszKey, "HI", 2) )
					sVal.Format("%hu", m_defenseBase + m_defenseRange);
			}
			else
				sVal.Format("%hu,%hu", m_defenseBase, m_defenseBase + m_defenseRange);
			break;
		}
		case OBC_BASEID:
			sVal = g_Cfg.ResourceGetName(GetResourceID());
			break;
		case OBC_CAN:
			sVal.FormatHex(m_Can);
			break;
		case OBC_DAM:
		{
			pszKey += 3;
			if ( *pszKey == '.' )
			{
				SKIP_SEPARATORS(pszKey);
				if ( !strnicmp(pszKey, "LO", 2) )
					sVal.Format("%hu", m_attackBase);
				else if ( !strnicmp(pszKey, "HI", 2) )
					sVal.Format("%hu", m_attackBase + m_attackRange);
			}
			else
				sVal.Format("%hu,%hu", m_attackBase, m_attackBase + m_attackRange);
			break;
		}
		case OBC_DAMCOLD:
			sVal.FormatVal(m_DamCold);
			break;
		case OBC_DAMENERGY:
			sVal.FormatVal(m_DamEnergy);
			break;
		case OBC_DAMFIRE:
			sVal.FormatVal(m_DamFire);
			break;
		case OBC_DAMPHYSICAL:
			sVal.FormatVal(m_DamPhysical);
			break;
		case OBC_DAMPOISON:
			sVal.FormatVal(m_DamPoison);
			break;
		case OBC_DEFNAME:
			sVal = GetResourceName();
			break;
		case OBC_ENHANCEPOTIONS:
			sVal.FormatVal(m_EnhancePotions);
			break;
		case OBC_FASTERCASTING:
			sVal.FormatVal(m_FasterCasting);
			break;
		case OBC_FASTERCASTRECOVERY:
			sVal.FormatVal(m_FasterCastRecovery);
			break;
		case OBC_HEIGHT:
			sVal.FormatVal(GetHeight());
			break;
		case OBC_HITLEECHLIFE:
			sVal.FormatVal(m_HitLifeLeech);
			break;
		case OBC_HITLEECHMANA:
			sVal.FormatVal(m_HitManaLeech);
			break;
		case OBC_HITLEECHSTAM:
			sVal.FormatVal(m_HitStaminaLeech);
			break;
		case OBC_HITMANADRAIN:
			sVal.FormatVal(m_HitManaDrain);
			break;
		case OBC_INCREASEDAM:
			sVal.FormatVal(m_DamIncrease);
			break;
		case OBC_INCREASEDEFCHANCE:
			sVal.FormatVal(m_DefChanceIncrease);
			break;
		case OBC_INCREASEDEFCHANCEMAX:
			sVal.FormatVal(m_DefChanceIncreaseMax);
			break;
		case OBC_INCREASEHITCHANCE:
			sVal.FormatVal(m_HitChanceIncrease);
			break;
		case OBC_INCREASESPELLDAM:
			sVal.FormatVal(m_SpellDamIncrease);
			break;
		case OBC_INCREASESWINGSPEED:
			sVal.FormatVal(m_SwingSpeedIncrease);
			break;
		case OBC_INSTANCES:
			sVal.FormatUVal(GetRefInstances());
			break;
		case OBC_LOWERMANACOST:
			sVal.FormatVal(m_LowerManaCost);
			break;
		case OBC_LOWERREAGENTCOST:
			sVal.FormatVal(m_LowerReagentCost);
			break;
		case OBC_LUCK:
			sVal.FormatVal(m_Luck);
			break;
		case OBC_NAME:
			sVal = GetName();
			break;
		case OBC_NIGHTSIGHT:
			sVal.FormatVal(m_NightSight);
			break;
		case OBC_REFLECTPHYSICALDAM:
			sVal.FormatVal(m_ReflectPhysicalDamage);
			break;
		case OBC_RANGE:
			if ( GetRangeH() == 0 )
				sVal.Format("%hhu", GetRangeL());
			else
				sVal.Format("%hhu,%hhu", GetRangeH(), GetRangeL());
			break;
		case OBC_RANGEH:
			sVal.FormatUVal(GetRangeL());
			break;
		case OBC_RANGEL:
			sVal.FormatUVal(GetRangeH());
			break;
		case OBC_RESCOLD:
			sVal.FormatVal(m_ResCold);
			break;
		case OBC_RESCOLDMAX:
			sVal.FormatVal(m_ResColdMax);
			break;
		case OBC_RESDISPDNHUE:
			sVal.FormatHex(GetResDispDnHue());
			break;
		case OBC_RESENERGY:
			sVal.FormatVal(m_ResEnergy);
			break;
		case OBC_RESENERGYMAX:
			sVal.FormatVal(m_ResEnergyMax);
			break;
		case OBC_RESFIRE:
			sVal.FormatVal(m_ResFire);
			break;
		case OBC_RESFIREMAX:
			sVal.FormatVal(m_ResFireMax);
			break;
		case OBC_RESLEVEL:
			sVal.FormatUVal(GetResLevel());
			break;
		case OBC_RESOURCES:
		{
			pszKey += 9;
			if ( *pszKey == '.' )
			{
				SKIP_SEPARATORS(pszKey);
				if ( !strnicmp(pszKey, "COUNT", 5) )
					sVal.FormatVal(m_BaseResources.GetCount());
				else
				{
					size_t index = static_cast<size_t>(Exp_GetLLVal(pszKey));
					SKIP_SEPARATORS(pszKey);

					bool fQtyOnly = false;
					bool fKeyOnly = false;
					if ( !strnicmp(pszKey, "KEY", 3) )
						fKeyOnly = true;
					else if ( !strnicmp(pszKey, "VAL", 3) )
						fQtyOnly = true;

					TCHAR *pszTmp = Str_GetTemp();
					m_BaseResources.WriteKeys(pszTmp, index, fQtyOnly, fKeyOnly);
					if ( fQtyOnly && (pszTmp[0] == '\0') )
						strcpy(pszTmp, "0");
					sVal = pszTmp;
				}
			}
			else
			{
				TCHAR *pszTmp = Str_GetTemp();
				m_BaseResources.WriteKeys(pszTmp);
				sVal = pszTmp;
			}
			break;
		}
		case OBC_RESPHYSICAL:
			sVal.FormatVal(m_ResPhysical);
			break;
		case OBC_RESPHYSICALMAX:
			sVal.FormatVal(m_ResPhysicalMax);
			break;
		case OBC_RESPOISON:
			sVal.FormatVal(m_ResPoison);
			break;
		case OBC_RESPOISONMAX:
			sVal.FormatVal(m_ResPoisonMax);
			break;
		case OBC_TAG0:
			fZero = true;
			++pszKey;
			// fall through
		case OBC_TAG:
			if ( pszKey[3] != '.' )
				return false;
			pszKey += 4;
			sVal = m_TagDefs.GetKeyStr(pszKey, fZero);
			break;
		case OBC_TEVENTS:
			m_TEvents.WriteResourceRefList(sVal);
			break;
		default:
			return false;
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
Exemplo n.º 8
0
bool CClient::r_WriteVal(LPCTSTR pszKey, CGString &sVal, CTextConsole *pSrc)
{
	ADDTOCALLSTACK("CClient::r_WriteVal");
	EXC_TRY("WriteVal");

	if ( !strnicmp("CTAG.", pszKey, 5) )
	{
		if ( pszKey[4] != '.' )
			return false;
		pszKey += 5;
		CVarDefCont *pVar = m_TagDefs.GetKey(pszKey);
		sVal = pVar ? pVar->GetValStr() : "";
		return true;
	}

	if ( !strnicmp("CTAG0.", pszKey, 6) )
	{
		if ( pszKey[5] != '.' )
			return false;
		pszKey += 6;
		CVarDefCont *pVar = m_TagDefs.GetKey(pszKey);
		sVal = pVar ? pVar->GetValStr() : "0";
		return true;
	}

	int index;
	if ( !strnicmp("TARGP", pszKey, 5) && ((pszKey[5] == '\0') || (pszKey[5] == '.')) )
		index = CC_TARGP;
	else if ( !strnicmp("SCREENSIZE", pszKey, 10) && ((pszKey[10] == '\0') || (pszKey[10] == '.')) )
		index = CC_SCREENSIZE;
	else if ( !strnicmp("REPORTEDCLIVER", pszKey, 14) && ((pszKey[14] == '\0') || (pszKey[14] == '.')) )
		index = CC_REPORTEDCLIVER;
	else
		index = FindTableSorted(pszKey, sm_szLoadKeys, COUNTOF(sm_szLoadKeys) - 1);

	switch ( index )
	{
		case CC_ALLMOVE:
			sVal.FormatVal(IsPriv(PRIV_ALLMOVE));
			break;
		case CC_ALLSHOW:
			sVal.FormatVal(IsPriv(PRIV_ALLSHOW));
			break;
		case CC_CLIENTIS3D:
			sVal.FormatVal(m_NetState->isClient3D());
			break;
		case CC_CLIENTISKR:
			sVal.FormatVal(m_NetState->isClientKR());
			break;
		case CC_CLIENTISSA:
			sVal.FormatVal(m_NetState->isClientEnhanced());
			break;
		case CC_CLIENTVERSION:
		{
			TCHAR szVersion[128];
			sVal = m_Crypt.WriteClientVerString(m_Crypt.GetClientVer(), szVersion);
			break;
		}
		case CC_DEBUG:
			sVal.FormatVal(IsPriv(PRIV_DEBUG));
			break;
		case CC_DETAIL:
			sVal.FormatVal(IsPriv(PRIV_DETAIL));
			break;
		case CC_GM:
			sVal.FormatVal(IsPriv(PRIV_GM));
			break;
		case CC_HEARALL:
			sVal.FormatVal(IsPriv(PRIV_HEARALL));
			break;
		case CC_LASTEVENT:
			sVal.FormatLLVal(m_timeLastEvent.GetTimeRaw());
			break;
		case CC_PRIVSHOW:
			sVal.FormatVal(!IsPriv(PRIV_PRIV_NOSHOW));
			break;
		case CC_REPORTEDCLIVER:
		{
			pszKey += 14;
			GETNONWHITESPACE(pszKey);

			DWORD dwCliVer = m_NetState->getReportedVersion();
			if ( pszKey[0] == '\0' )
			{
				// Return full version string (eg: 5.0.2d)
				TCHAR szVersion[128];
				sVal = CCrypt::WriteClientVerString(dwCliVer, szVersion);
			}
			else
			{
				// Return raw version number (eg: 5.0.2d = 5000204)
				sVal.FormatUVal(dwCliVer);
			}
			break;
		}
		case CC_SCREENSIZE:
		{
			if ( pszKey[10] == '.' )
			{
				pszKey += 10;
				SKIP_SEPARATORS(pszKey);

				if ( !strnicmp("X", pszKey, 1) )
					sVal.Format("%hu", m_ScreenSize.x);
				else if ( !strnicmp("Y", pszKey, 1) )
					sVal.Format("%hu", m_ScreenSize.y);
				else
					return false;
			}
			else
				sVal.Format("%hu,%hu", m_ScreenSize.x, m_ScreenSize.y);
			break;
		}
		case CC_TARG:
			sVal.FormatHex(m_Targ_UID);
			break;
		case CC_TARGP:
		{
			if ( pszKey[5] == '.' )
				return m_Targ_p.r_WriteVal(pszKey + 6, sVal);
			sVal = m_Targ_p.WriteUsed();
			break;
		}
		case CC_TARGPROP:
			sVal.FormatHex(m_Prop_UID);
			break;
		case CC_TARGPRV:
			sVal.FormatHex(m_Targ_PrvUID);
			break;
		case CC_TARGTXT:
			sVal = m_Targ_Text;
			break;
		default:
			return CScriptObj::r_WriteVal(pszKey, sVal, pSrc);
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}