Fix object.factory() code type detection, closes #938

dev-buzzingcars
krzys-h 2017-06-03 21:43:10 +02:00
parent ac27bdac4a
commit bb35585194
1 changed files with 2 additions and 2 deletions

View File

@ -405,12 +405,12 @@ bool CAutoFactory::EventProcess(const Event &event)
{
Program* program = dynamic_cast<CProgramStorageObject*>(vehicle)->AddProgram();
if (boost::regex_search(m_program, boost::regex("^[A-Za-z0-9_]+$"))) // Public function name?
if (boost::regex_match(m_program, boost::regex("[A-Za-z0-9_]+"))) // Public function name?
{
std::string code = "extern void object::Start_"+m_program+"()\n{\n\t\n\t//Automatically generated by object.factory()\n\t"+m_program+"();\n\t\n}\n";
program->script->SendScript(code.c_str());
}
else if (boost::regex_search(m_program, boost::regex("\\.txt$"))) // File name (with .txt extension)?
else if (boost::regex_match(m_program, boost::regex(".*\\.txt"))) // File name (with .txt extension)?
{
program->script->ReadScript(m_program.c_str());
}