int CVarDefMap::SetStr( LPCTSTR pszName, bool fQuoted, LPCTSTR pszVal, bool fZero ) { ADDTOCALLSTACK("CVarDefMap::SetStr"); // ASSUME: This has been clipped of unwanted beginning and trailing spaces. if ( !pszName || !pszName[0] ) return -1; if ( pszVal == NULL || pszVal[0] == '\0' ) // but not if empty { DeleteAtKey(pszName); return( -1 ); } if ( !fQuoted && IsSimpleNumberString(pszVal)) { // Just store the number and not the string. return SetNum( pszName, Exp_GetLLVal( pszVal ), fZero); } CVarDefContTest * pVarSearch = new CVarDefContTest(pszName); DefSet::iterator iResult = m_Container.find(pVarSearch); delete pVarSearch; CVarDefCont * pVarBase = NULL; if ( iResult != m_Container.end() ) pVarBase = (*iResult); if ( !pVarBase ) { return SetStrNew( pszName, pszVal ); } CVarDefContStr * pVarStr = dynamic_cast <CVarDefContStr *>( pVarBase ); if ( pVarStr ) { pVarStr->SetValStr( pszVal ); } else { if ( g_Serv.IsLoading()) { DEBUG_ERR(( "Replace existing VarNum '%s' with %s\n", pVarBase->GetKey(), pszVal )); } return SetStrOverride( pszName, pszVal ); } return static_cast<int>(std::distance(m_Container.begin(), iResult) ); }
bool IsValidGameObjDef( LPCTSTR pszTest ) { if (!IsSimpleNumberString(pszTest)) { CVarDefCont * pVarBase = g_Exp.m_VarDefs.CheckParseKey( pszTest ); if ( pVarBase == NULL ) return false; TCHAR ch = *pVarBase->GetValStr(); if (( ! ch ) || ( ch == '<')) return false; RESOURCE_ID rid = g_Cfg.ResourceGetID( RES_QTY, pszTest); if (( rid.GetResType() != RES_CHARDEF ) && ( rid.GetResType() != RES_ITEMDEF ) && ( rid.GetResType() != RES_SPAWN ) && ( rid.GetResType() != RES_TEMPLATE )) return false; } return true; }
bool IsValidGameObjDef( lpctstr pszTest ) { if (!IsSimpleNumberString(pszTest)) { const CVarDefCont * pVarBase = g_Exp.m_VarResDefs.CheckParseKey( pszTest ); if ( pVarBase == nullptr ) return false; const tchar ch = *pVarBase->GetValStr(); if (( ! ch ) || ( ch == '<')) return false; const CResourceID rid = g_Cfg.ResourceGetID(RES_QTY, pszTest); const RES_TYPE resType = rid.GetResType(); if ((resType != RES_CHARDEF) && (resType != RES_ITEMDEF) && (resType != RES_SPAWN) && (resType != RES_TEMPLATE) && (resType != RES_CHAMPION)) return false; } return true; }