Fix object.factory() code type detection, closes #938
parent
ac27bdac4a
commit
bb35585194
|
@ -405,12 +405,12 @@ bool CAutoFactory::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
Program* program = dynamic_cast<CProgramStorageObject*>(vehicle)->AddProgram();
|
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";
|
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());
|
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());
|
program->script->ReadScript(m_program.c_str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue