Exemplo n.º 1
0
bool CWebPageDef::r_WriteVal( lpctstr pszKey, CSString & sVal, CTextConsole * pSrc )
{
	ADDTOCALLSTACK("CWebPageDef::r_WriteVal");
	EXC_TRY("WriteVal");
	switch ( FindTableSorted( pszKey, sm_szLoadKeys, CountOf( sm_szLoadKeys )-1 ))
	{
		case WC_PLEVEL:
			sVal.FormatVal( m_privlevel );
			break;
		case WC_WEBPAGEFILE:
			sVal = m_sDstFilePath;
			break;
		case WC_WEBPAGELOG:
			sVal.FormatVal( m_iUpdateLog );
			break;
		case WC_WEBPAGESRC:
			sVal = m_sSrcFilePath;
			break;
		case WC_WEBPAGEUPDATE:	// (seconds)
			sVal.FormatVal( m_iUpdatePeriod );
			break;
		default:
			return( g_Serv.r_WriteVal( pszKey, sVal, pSrc ));
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
Exemplo n.º 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;
}
Exemplo n.º 3
0
bool CSpellDef::r_WriteVal( lpctstr pszKey, CSString & sVal, CTextConsole * pSrc )
{
    ADDTOCALLSTACK("CSpellDef::r_WriteVal");
    EXC_TRY("WriteVal");
    int index = FindTableSorted( pszKey, sm_szLoadKeys, CountOf( sm_szLoadKeys )-1 );
    if (index < 0)
    {
        if (!strnicmp( "RESOURCES.", pszKey, 10 ))
            index = SPC_RESOURCES;
    }
    switch (index)
    {
        case SPC_CAST_TIME:
            sVal = m_CastTime.Write();
            break;
        case SPC_DEFNAME:
            sVal = GetResourceName();
            break;
        case SPC_DURATION:
            sVal = m_Duration.Write();
            break;
        case SPC_EFFECT:
            sVal = m_Effect.Write();
            break;
        case SPC_EFFECT_ID:
            sVal.FormatVal( m_idEffect );
            break;
        case SPC_FLAGS:
            sVal.FormatVal( m_dwFlags );
            break;
        case SPC_GROUP:
            sVal.FormatVal( m_dwGroup );
            break;
        case SPC_INTERRUPT:
            sVal = m_Interrupt.Write();
            break;
        case SPC_LAYER:
            sVal.FormatVal(m_idLayer);
            break;
        case SPC_MANAUSE:
            sVal.FormatVal( m_wManaUse );
            break;
        case SPC_NAME:
            sVal = m_sName;
            break;
        case SPC_PROMPT_MSG:
            sVal	= m_sTargetPrompt;
            break;
        case SPC_RESOURCES:
        {
            pszKey	+= 9;
            // Check for "RESOURCES.*"
            if ( *pszKey == '.' )
            {
                bool fQtyOnly = false;
                bool fKeyOnly = false;
                SKIP_SEPARATORS( pszKey );
                // Determine the index of the resource
                // we wish to find
                index = Exp_GetVal( pszKey );
                SKIP_SEPARATORS( pszKey );

                // Check for "RESOURCES.x.KEY"
                if ( !strnicmp( pszKey, "KEY", 3 ))
                    fKeyOnly = true;
                // Check for "RESORUCES.x.VAL"
                else if ( !strnicmp( pszKey, "VAL", 3 ))
                    fQtyOnly = true;

                tchar *pszTmp = Str_GetTemp();
                m_Reags.WriteKeys( pszTmp, index, fQtyOnly, fKeyOnly );
                if ( fQtyOnly && pszTmp[0] == '\0' )
                    strcpy( pszTmp, "0" ); // Return 0 for empty quantity
                sVal = pszTmp;
            }
            else
            {
                tchar *pszTmp = Str_GetTemp();
                m_Reags.WriteKeys( pszTmp );
                sVal = pszTmp;
            }
            break;
        }
        case SPC_RUNE_ITEM:
            sVal.FormatVal( m_idSpell );
            break;
        case SPC_RUNES:
            // This may only be basic chars !
            sVal = m_sRunes;
            break;
        case SPC_SCROLL_ITEM:
            sVal.FormatVal( m_idScroll );
            break;
        case SPC_SKILLREQ:
        {
            tchar *pszTmp = Str_GetTemp();
            m_SkillReq.WriteKeys( pszTmp );
            sVal = pszTmp;
        }
        break;
        case SPC_SOUND:
            sVal.FormatVal(m_sound);
            break;
        case SPC_TITHINGUSE:
            sVal.FormatVal(m_wTithingUse);
            break;
        default:
            return( CResourceDef::r_WriteVal( pszKey, sVal, pSrc ));
    }
    return true;
    EXC_CATCH;

    EXC_DEBUG_START;
    EXC_ADD_KEYRET(pSrc);
    EXC_DEBUG_END;
    return false;
}
Exemplo n.º 4
0
bool CSector::r_WriteVal( lpctstr pszKey, CSString & sVal, CTextConsole * pSrc )
{
	ADDTOCALLSTACK("CSector::r_WriteVal");
	EXC_TRY("WriteVal");

	static const CValStr sm_ComplexityTitles[] =
	{
		{ "HIGH", INT32_MIN },	// speech can be very complex if low char count
		{ "MEDIUM", 5 },
		{ "LOW", 10 },
		{ nullptr, INT32_MAX }
	};

    SC_TYPE key = (SC_TYPE)FindTableHead(pszKey, sm_szLoadKeys, CountOf(sm_szLoadKeys) - 1);
	switch ( key )
	{
        case SC_CANSLEEP:
            {
                pszKey += 8;
                bool fCheckAdjacents = Exp_GetVal(pszKey);
                sVal.FormatBVal(CanSleep(fCheckAdjacents));
                return true;
            }
		case SC_CLIENTS:
			sVal.FormatSTVal(m_Chars_Active.GetClientsNumber());
			return true;
		case SC_COLDCHANCE:
			sVal.FormatVal( GetColdChance());
			return true;
		case SC_COMPLEXITY:
			if ( pszKey[10] == '.' )
			{
				pszKey += 11;
				sVal = ( ! strcmpi( pszKey, sm_ComplexityTitles->FindName( (int)GetCharComplexity() )) ) ? "1" : "0";
				return true;
			}
			sVal.FormatSTVal( GetCharComplexity() );
			return true;
		case SC_FLAGS:
			sVal.FormatHex(m_dwFlags);
			return true;
		case SC_LIGHT:
			sVal.FormatVal(GetLight());
			return true;
		case SC_LOCALTIME:
			sVal = GetLocalGameTime();
			return true;
		case SC_LOCALTOD:
			sVal.FormatVal( GetLocalTime());
			return true;
		case SC_NUMBER:
			sVal.FormatVal(m_index);
			return true;
		case SC_ISDARK:
			sVal.FormatVal( IsDark() );
			return true;
		case SC_ISNIGHTTIME:
			{
				int iMinutes = GetLocalTime();
				sVal = ( iMinutes < 7*60 || iMinutes > (9+12)*60 ) ? "1" : "0";
			}
			return true;
        case SC_ISSLEEPING:
            sVal.FormatVal(IsSleeping());
            return true;
		case SC_RAINCHANCE:
			sVal.FormatVal( GetRainChance());
			return true;
		case SC_ITEMCOUNT:
			sVal.FormatSTVal(GetItemComplexity());
			return true;
		case SC_SEASON:
			sVal.FormatVal((int)GetSeason());
			return true;
		case SC_WEATHER:
			sVal.FormatVal((int)GetWeather());
			return true;
	}
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
Exemplo n.º 5
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;
}