void CLuaFile::PushParameter(const char *pString) { if (m_pLua == 0) return; if (StrIsInteger(pString)) { PushInteger(str_toint(pString)); } else if (StrIsFloat(pString)) { PushInteger(str_tofloat(pString)); } else { PushString(pString); } }
void CRaceDemo::CheckDemo() { // stop the demo recording Client()->RaceRecordStop(); char aTmpDemoName[128]; str_format(aTmpDemoName, sizeof(aTmpDemoName), "%s_tmp", m_pMap); // loop through demo files m_pClient->m_pMenus->DemolistPopulate(); for(int i = 0; i < m_pClient->m_pMenus->m_lDemos.size(); i++) { if(!str_comp_num(m_pClient->m_pMenus->m_lDemos[i].m_aName, m_pMap, str_length(m_pMap)) && str_comp_num(m_pClient->m_pMenus->m_lDemos[i].m_aName, aTmpDemoName, str_length(aTmpDemoName))) { const char *pDemo = m_pClient->m_pMenus->m_lDemos[i].m_aName; // set cursor pDemo += str_length(m_pMap)+1; float DemoTime = str_tofloat(pDemo); if(m_Time < DemoTime) { // save new record SaveDemo(m_pMap); // delete old demo char aFilename[512]; str_format(aFilename, sizeof(aFilename), "demos/%s.demo", m_pClient->m_pMenus->m_lDemos[i].m_aName); Storage()->RemoveFile(aFilename, IStorage::TYPE_SAVE); } m_Time = 0; return; } } // save demo if there is none SaveDemo(m_pMap); m_Time = 0; }
inline bool string_tofloat(const std::string& str, float& value) { return str_tofloat(str.c_str(), value); }
float CConsole::CResult::GetFloat(unsigned Index) { if (Index >= m_NumArgs) return 0.0f; return str_tofloat(m_apArgs[Index]); }