本文整理汇总了C++中CGString::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ CGString::Format方法的具体用法?C++ CGString::Format怎么用?C++ CGString::Format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGString
的用法示例。
在下文中一共展示了CGString::Format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: r_WriteVal
bool CItemMulti::r_WriteVal( LPCTSTR pszKey, CGString & sVal, CTextConsole * pSrc )
{
if ( !strnicmp(pszKey, "COMP", 4) )
{
const CItemBaseMulti *pMultiDef = Multi_GetDef();
pszKey += 4;
// no component uid
if ( !*pszKey ) sVal.FormatVal(pMultiDef->m_Components.GetCount());
else if ( *pszKey == '.' )
{
CMultiComponentItem item;
SKIP_SEPERATORS(pszKey);
int iQty = Exp_GetVal(pszKey);
if (( iQty < 0 ) || ( iQty >= pMultiDef->m_Components.GetCount())) return false;
SKIP_SEPERATORS(pszKey);
item = pMultiDef->m_Components.GetAt(iQty);
if ( !strnicmp(pszKey, "ID", 2) ) sVal.FormatVal(item.m_id);
else if ( !strnicmp(pszKey, "DX", 2) ) sVal.FormatVal(item.m_dx);
else if ( !strnicmp(pszKey, "DY", 2) ) sVal.FormatVal(item.m_dy);
else if ( !strnicmp(pszKey, "DZ", 2) ) sVal.FormatVal(item.m_dz);
else if ( !strnicmp(pszKey, "D", 1) ) sVal.Format("%i,%i,%i", item.m_dx, item.m_dy, item.m_dz);
else sVal.Format("%i,%i,%i,%i", item.m_id, item.m_dx, item.m_dy, item.m_dz);
}
else return false;
return true;
}
return( CItem::r_WriteVal(pszKey, sVal, pSrc));
}
示例2: DecorateName
void CChat::DecorateName(CGString &sName, const CChatChanMember * pMember, bool fSystem) // static
{
ADDTOCALLSTACK("CChat::DecorateName");
CChatChannel * pChannel = NULL;
if (pMember)
pChannel = pMember->GetChannel();
// 0 = yellow
// 1 = purple
// 2 = blue
// 3 = purple
// 4 = white
// 5 = green
int iResult = 0;
if (!pMember || !pChannel) // Must be a system command if these are invalid
{
if (fSystem)
iResult = 5;
else
iResult = 4;
}
else if (pChannel->IsModerator(pMember->GetChatName()))
iResult = 1;
else if (!pChannel->HasVoice(pMember->GetChatName()))
iResult = 2;
if (!pMember || !pChannel)
sName.Format("%i%s", iResult, "SYSTEM");
else
sName.Format("%i%s", iResult, static_cast<LPCTSTR>(pMember->GetChatName()));
}
示例3: FormatName
void CChat::FormatName(CGString &sName, const CChatMember *pMember, bool bSystem) //static
{
ADDTOCALLSTACK("CChat::FormatName");
// Format chat name with proper color
// 0 = Yellow (user)
// 1 = Purple (moderator)
// 2 = Blue (muted)
// 3 = Purple (unused?)
// 4 = White (me)
// 5 = Green (system)
int iColor = 0;
if ( pMember )
{
CChatChannel *pChannel = pMember->GetChannel();
if ( pChannel )
{
LPCTSTR pszName = const_cast<CChatMember *>(pMember)->GetChatName();
if ( pChannel->IsModerator(pszName) )
iColor = 1;
else if ( !pChannel->HasVoice(pszName) )
iColor = 2;
sName.Format("%d%s", iColor, pszName);
return;
}
}
iColor = bSystem ? 5 : 4;
sName.Format("%d%s", iColor, "SYSTEM");
}
示例4: r_WriteVal
bool CItemMap::r_WriteVal(LPCTSTR pszKey, CGString &sVal, CTextConsole *pSrc)
{
ADDTOCALLSTACK("CItemMap::r_WriteVal");
EXC_TRY("WriteVal");
if ( !strnicmp(pszKey, "PINS", 4) )
{
sVal.FormatVal(m_Pins.GetCount());
return true;
}
if ( !strnicmp(pszKey, "PIN.", 4) )
{
pszKey += 4;
size_t i = Exp_GetVal(pszKey) - 1;
if ( m_Pins.IsValidIndex(i) )
{
sVal.Format("%i,%i", m_Pins[i].m_x, m_Pins[i].m_y);
return true;
}
}
return CItemVendable::r_WriteVal(pszKey, sVal, pSrc);
EXC_CATCH;
EXC_DEBUG_START;
EXC_ADD_KEYRET(pSrc);
EXC_DEBUG_END;
return false;
}
示例5: StringFunction
static void StringFunction( int iFunc, LPCTSTR pszKey, CGString &sVal )
{
GETNONWHITESPACE(pszKey);
if ( *pszKey == '(' )
pszKey++;
TCHAR * ppCmd[4];
int iCount = Str_ParseCmds( const_cast<TCHAR *>(pszKey), ppCmd, COUNTOF(ppCmd), ",)" );
if ( ! iCount )
{
DEBUG_ERR(( "Bad string function usage. missing )\n" ));
return;
}
TCHAR * psArg1 = ppCmd[0];
switch ( iFunc )
{
case SSC_CHR:
sVal.Format( "%c", Exp_GetSingle( ppCmd[0] ) );
return;
case SSC_StrToLower: // strlower(str) = lower case the string
sVal = ppCmd[0];
sVal.MakeLower();
return;
case SSC_StrToUpper: // strupper(str) = upper case the string
sVal = ppCmd[0];
sVal.MakeUpper();
return;
}
}
示例6: r_WriteVal
bool CItemMap::r_WriteVal( LPCTSTR pszKey, CGString &sVal, CTextConsole * pSrc )
{
EXC_TRY(("r_WriteVal('%s',,%x)", pszKey, pSrc));
if ( ! strnicmp( pszKey, "PIN", 3 ))
{
pszKey += 3;
int i = Exp_GetVal(pszKey) - 1;
if ( i >= 0 && i < m_Pins.GetCount())
{
sVal.Format( "%i,%i", m_Pins[i].m_x, m_Pins[i].m_y );
return( true );
}
}
return CItemVendable::r_WriteVal(pszKey, sVal, pSrc);
EXC_CATCH("CItemMap");
return false;
}
示例7: r_WriteVal
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) )
//.........这里部分代码省略.........
示例8: ServPage
bool CWebPageDef::ServPage( CClient * pClient, TCHAR * pszPage, CGTime * pdateIfModifiedSince ) // static
{
ADDTOCALLSTACK("CWebPageDef::ServPage");
// make sure this is a valid format for the request.
TCHAR szPageName[_MAX_PATH];
Str_GetBare( szPageName, pszPage, sizeof(szPageName), "!\"#$%&()*,:;<=>?[]^{|}-+'`" );
int iError = 404;
CWebPageDef * pWebPage = g_Cfg.FindWebPage(szPageName);
if ( pWebPage )
{
iError = pWebPage->ServPageRequest(pClient, szPageName, pdateIfModifiedSince);
if ( ! iError )
return true;
}
// Is it a file in the Script directory ?
if ( iError == 404 )
{
const RESOURCE_ID ridjunk( RES_UNKNOWN, 1 );
CWebPageDef tmppage( ridjunk );
if ( tmppage.SetSourceFile( szPageName, pClient ))
{
if ( !tmppage.ServPageRequest(pClient, szPageName, pdateIfModifiedSince) )
return true;
}
}
// Can't find it !?
// just take the default page. or have a custom 404 page ?
pClient->m_Targ_Text = pszPage;
TCHAR *pszTemp = Str_GetTemp();
sprintf(pszTemp, GRAY_FILE "%d.htm", iError);
pWebPage = g_Cfg.FindWebPage(pszTemp);
if ( pWebPage )
{
if ( ! pWebPage->ServPageRequest( pClient, pszPage, NULL ))
return true;
}
// Hmm we should do something !!!?
// Try to give a reasonable default error msg.
LPCTSTR pszErrText;
switch (iError)
{
case 401: pszErrText = "Authorization Required"; break;
case 403: pszErrText = "Forbidden"; break;
case 404: pszErrText = "Object Not Found"; break;
case 500: pszErrText = "Internal Server Error"; break;
default: pszErrText = "Unknown Error"; break;
}
CGTime datetime = CGTime::GetCurrentTime();
const char *sDate = datetime.FormatGmt(NULL);
CGString sMsgHead;
CGString sText;
sText.Format(
"<html><head><title>Error %d</title>"
"<meta name=robots content=noindex>"
"</head><body>"
"<h2>HTTP Error %d</h2><p><strong>%d %s</strong></p>"
"<p>The " GRAY_TITLE " server cannot deliver the file or script you asked for.</p>"
"<p>Please contact the server's administrator if this problem persists.</p>"
"</body></html>",
iError,
iError,
iError,
static_cast<LPCTSTR>(pszErrText));
sMsgHead.Format(
"HTTP/1.1 %d %s\r\n"
"Date: %s\r\n"
"Server: " GRAY_TITLE " V " GRAY_VERSION "\r\n"
"Content-Type: text/html\r\n"
"Content-Length: %d\r\n"
"Connection: close\r\n"
"\r\n%s",
iError, static_cast<LPCTSTR>(pszErrText),
static_cast<LPCTSTR>(sDate),
sText.GetLength(),
static_cast<LPCTSTR>(sText));
new PacketWeb(pClient, reinterpret_cast<const BYTE *>(sMsgHead.GetPtr()), sMsgHead.GetLength());
return false;
}
示例9: r_WriteVal
//.........这里部分代码省略.........
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 == '.' )
{
示例10: r_WriteVal
bool CRegionBase::r_WriteVal( LPCTSTR pszKey, CGString & sVal, CTextConsole * pSrc )
{
ADDTOCALLSTACK("CRegionBase::r_WriteVal");
EXC_TRY("WriteVal");
bool fZero = false;
int index = FindTableHeadSorted(pszKey, sm_szLoadKeys, COUNTOF(sm_szLoadKeys) - 1);
if ( index < 0 )
return CScriptObj::r_WriteVal(pszKey, sVal, pSrc);
switch ( index )
{
case RC_ANNOUNCE:
sVal.FormatVal( IsFlag(REGION_FLAG_ANNOUNCE));
break;
case RC_ARENA:
sVal.FormatVal( IsFlag(REGION_FLAG_ARENA));
break;
case RC_BUILDABLE:
sVal.FormatVal( ! IsFlag(REGION_FLAG_NOBUILDING));
break;
case RC_CLIENTS:
{
int i = 0;
size_t iClients = 0;
for ( ; ; i++ )
{
CSector *pSector = GetSector(i);
if ( pSector == NULL ) break;
iClients += pSector->m_Chars_Active.HasClients();
}
sVal.FormatVal(static_cast<long>(iClients));
break;
}
case RC_EVENTS:
m_Events.WriteResourceRefList( sVal );
break;
case RC_ISEVENT:
if ( pszKey[7] != '.' )
return( false );
pszKey += 8;
sVal.FormatVal(m_Events.ContainsResourceName(RES_EVENTS, pszKey));
return( true );
case RC_FLAGS:
sVal.FormatHex( GetRegionFlags() );
break;
case RC_GATE:
sVal.FormatVal( ! IsFlag(REGION_ANTIMAGIC_GATE));
break;
case RC_GROUP:
sVal = m_sGroup;
break;
case RC_GUARDED:
sVal.FormatVal( IsFlag(REGION_FLAG_GUARDED));
break;
case RC_MAGIC:
sVal.FormatVal( ! IsFlag(REGION_ANTIMAGIC_ALL));
break;
case RC_MAP:
sVal.FormatVal( m_pt.m_map );
break;
case RC_MARK:
case RC_RECALLIN:
sVal.FormatVal( ! IsFlag(REGION_ANTIMAGIC_RECALL_IN));
break;
case RC_NAME:
// The previous name was really the DEFNAME ???
sVal = GetName();
break;
case RC_NOBUILD:
sVal.FormatVal( IsFlag(REGION_FLAG_NOBUILDING));
break;
case RC_NODECAY:
sVal.FormatVal( IsFlag(REGION_FLAG_NODECAY));
break;
case RC_NOPVP:
sVal.FormatVal( IsFlag(REGION_FLAG_NO_PVP));
break;
case RC_P:
sVal = m_pt.WriteUsed();
break;
case RC_RECALL:
case RC_RECALLOUT:
sVal.FormatVal( ! IsFlag(REGION_ANTIMAGIC_RECALL_OUT));
break;
case RC_RECT:
{
size_t iQty = m_Rects.GetCount();
pszKey += 4;
if ( *pszKey == '\0' )
{
sVal.FormatVal( static_cast<long>(iQty));
return true;
}
SKIP_SEPARATORS( pszKey );
size_t iRect = Exp_GetVal( pszKey );
if ( iRect <= 0 )
{
sVal = m_rectUnion.Write();
return true;
}
//.........这里部分代码省略.........
示例11: r_WriteVal
bool CPartyDef::r_WriteVal( LPCTSTR pszKey, CGString &sVal, CTextConsole *pSrc )
{
ADDTOCALLSTACK("CPartyDef::r_WriteVal");
EXC_TRY("WriteVal");
CScriptObj *pRef;
if ( r_GetRef(pszKey, pRef) )
{
if ( pRef == NULL ) // good command but bad link.
{
sVal = "0";
return true;
}
if ( pszKey[0] == '\0' ) // we where just testing the ref.
{
CObjBase *pObj = dynamic_cast<CObjBase *>(pRef);
if ( pObj )
sVal.FormatHex(static_cast<DWORD>(pObj->GetUID()));
else
sVal.FormatVal(1);
return true;
}
return pRef->r_WriteVal(pszKey, sVal, pSrc);
}
bool fZero = false;
switch ( FindTableHeadSorted(pszKey, sm_szLoadKeys, COUNTOF(sm_szLoadKeys) - 1) )
{
case PDC_ISSAMEPARTYOF:
{
pszKey += 13;
GETNONWHITESPACE(pszKey);
if ( pszKey[0] != '\0' )
{
CGrayUID uidToCheck = static_cast<CGrayUID>(Exp_GetVal(pszKey));
CChar *pCharToCheck = uidToCheck.CharFind();
sVal.FormatVal(pCharToCheck && (pCharToCheck->m_pParty == this));
}
else
return false;
} break;
case PDC_MEMBERS:
sVal.FormatVal(m_Chars.GetCharCount());
break;
case PDC_SPEECHFILTER:
sVal = m_pSpeechFunction.IsEmpty() ? "" : m_pSpeechFunction;
break;
case PDC_TAG0:
fZero = true;
pszKey++;
case PDC_TAG:
{
if ( pszKey[3] != '.' )
return false;
pszKey += 4;
sVal = m_TagDefs.GetKeyStr(pszKey, fZero);
} break;
case PDC_TAGAT:
{
pszKey += 5; // eat the 'TAGAT'
if ( *pszKey == '.' ) // do we have an argument?
{
SKIP_SEPARATORS(pszKey);
size_t iQty = static_cast<size_t>(Exp_GetVal(pszKey));
if ( iQty >= m_TagDefs.GetCount() )
return false; // trying to get non-existant tag
CVarDefCont *pTagAt = m_TagDefs.GetAt(iQty);
if ( !pTagAt )
return false; // trying to get non-existant tag
SKIP_SEPARATORS(pszKey);
if ( !*pszKey )
{
sVal.Format("%s=%s", pTagAt->GetKey(), pTagAt->GetValStr());
return true;
}
else if ( !strnicmp(pszKey, "KEY", 3) )
{
sVal = pTagAt->GetKey();
return true;
}
else if ( !strnicmp(pszKey, "VAL", 3) )
{
sVal = pTagAt->GetValStr();
return true;
}
}
return false;
}
case PDC_TAGCOUNT:
sVal.FormatVal(m_TagDefs.GetCount());
break;
//.........这里部分代码省略.........
示例12: r_WriteVal
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 ));
}
}
//.........这里部分代码省略.........
示例13: r_WriteVal
bool CScriptObj::r_WriteVal( LPCTSTR pszKey, CGString &sVal, CTextConsole * pSrc )
{
EXC_TRY(("r_WriteVal('%s',,%x)", pszKey, pSrc));
CScriptObj * pRef;
if ( r_GetRef( pszKey, pRef ))
{
if ( pRef == NULL ) // good command but bad link.
{
sVal = "0";
return true;
}
if ( pszKey[0] == '\0' ) // we where just testing the ref.
{
CObjBase * pObj = dynamic_cast <CObjBase *> (pRef);
if ( pObj )
sVal.FormatHex( (DWORD) pObj->GetUID() );
else
sVal.FormatVal( 1 );
return( true );
}
return pRef->r_WriteVal( pszKey, sVal, pSrc );
}
int i = FindTableHeadSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 );
if ( i < 0 )
{
// <dSOMEVAL> same as <eval <SOMEVAL>> to get dec from the val
if (( *pszKey == 'd' ) || ( *pszKey == 'D' ))
{
LPCTSTR arg = pszKey + 1;
if ( r_WriteVal(arg, sVal, pSrc) )
{
if ( !IsStrNumericDec(sVal) ) // dValue dec -> hex fix
{
sVal.FormatVal(ahextoi(sVal));
}
return true;
}
}
// <r>, <r15>, <r3,15> are shortcuts to rand(), rand(15) and rand(3,15)
else if (( *pszKey == 'r' ) || ( *pszKey == 'R' ))
{
char *zTemp = Str_GetTemp();
strcpy(zTemp, pszKey+1);
if (( *zTemp ) && (( *zTemp < '0' ) || ( *zTemp > '9' )) )
goto badcmd;
TCHAR *ppCmd[2];
int qty = Str_ParseCmds(zTemp, ppCmd, COUNTOF(ppCmd));
int min = 0, max = 1000;
if ( qty == 1 ) max = atoi(ppCmd[0]);
else if ( qty == 2 )
{
min = g_Exp.GetVal(ppCmd[0]);
max = g_Exp.GetVal(ppCmd[1]);
}
if ( min > max )
{
int a = min;
min = max;
max = a;
}
if ( min == max )
sVal.FormatVal(min);
else
sVal.FormatVal(min + Calc_GetRandVal(max - min));
return true;
}
badcmd:
return false; // Bad command.
}
pszKey += strlen( sm_szLoadKeys[i] );
SKIP_SEPERATORS(pszKey);
bool fZero = false;
switch ( i )
{
case SSC_LISTCOL:
// Set the alternating color.
sVal = (CWebPageDef::sm_iListIndex&1) ? "bgcolor=\"#E8E8E8\"" : "";
return( true );
case SSC_OBJ:
if ( !g_World.m_uidObj.ObjFind() ) g_World.m_uidObj = 0;
sVal.FormatHex((DWORD)g_World.m_uidObj);
return true;
case SSC_NEW:
if ( !g_World.m_uidNew.ObjFind() ) g_World.m_uidNew = 0;
sVal.FormatHex((DWORD)g_World.m_uidNew);
return true;
case SSC_SRC:
if ( pSrc == NULL )
pRef = NULL;
else
{
pRef = pSrc->GetChar(); // if it can be converted .
//.........这里部分代码省略.........
示例14: r_WriteVal
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;
//.........这里部分代码省略.........
示例15: r_WriteVal
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;
//.........这里部分代码省略.........