Пример #1
0
bool CComponentProps::BaseProp_WritePropVal(int iPropIndex, bool fPropStr, CSString & sVal) const
{
    ADDTOCALLSTACK("CComponentProps::BaseProp_WritePropVal");
    if (fPropStr)
    {
        return GetPropertyStrPtr(iPropIndex, &sVal);
    }
    else
    {
        PropertyValNum_t iVal = 0;
        bool fRet = GetPropertyNumPtr(iPropIndex, &iVal);
        sVal.FormatLLVal(iVal);
        return fRet;
    }
}
Пример #2
0
bool CServerDef::r_WriteVal( lpctstr pszKey, CSString &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:
		{
			char 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.FormatSTVal( StatGet( SERV_STAT_ACCOUNTS ) );
		break;
	case SC_CLIENTS:
		sVal.FormatSTVal( StatGet( SERV_STAT_CLIENTS ) );
		break;
	case SC_ITEMS:
		sVal.FormatSTVal( StatGet( SERV_STAT_ITEMS ) );
		break;
	case SC_MEM:
		sVal.FormatSTVal( StatGet( SERV_STAT_MEM ) );
		break;
	case SC_CHARS:
		sVal.FormatSTVal( 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 = SPHERE_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;
}
Пример #3
0
bool CCharNPC::r_WriteVal( CChar * pChar, lpctstr pszKey, CSString & sVal )
{
	EXC_TRY("WriteVal");
	switch ( FindTableSorted( pszKey, sm_szLoadKeys, CNC_QTY ))
	{

		//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_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, CPC_QTY ) >= 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;
}