31 std::string dummy_script = fmt::format(
32 "class Dummy{0} extends {0}Info {{\n"
33 "function GetAuthor() {{ return \"OpenTTD Developers Team\"; }}\n"
34 "function GetName() {{ return \"Dummy{0}\"; }}\n"
35 "function GetShortName() {{ return \"DUMM\"; }}\n"
36 "function GetDescription() {{ return \"A Dummy {0} that is loaded when your {1}/ dir is empty\"; }}\n"
37 "function GetVersion() {{ return 1; }}\n"
38 "function GetDate() {{ return \"2008-07-26\"; }}\n"
39 "function CreateInstance() {{ return \"Dummy{0}\"; }}\n"
40 "}} RegisterDummy{0}(Dummy{0}());\n", type, dir);
45 if (SQ_SUCCEEDED(sq_compilebuffer(vm, dummy_script.c_str(), dummy_script.size(),
"dummy", SQTrue))) {
47 if (SQ_SUCCEEDED(sq_call(vm, 1, SQFalse, SQTrue))) {
63 std::vector<std::string> messages;
65 std::string safe_message;
66 for (
auto c : message) {
68 messages.emplace_back(std::move(safe_message));
72 if (c ==
'"' || c ==
'\\') safe_message.push_back(
'\\');
73 safe_message.push_back(c);
75 messages.emplace_back(std::move(safe_message));
87 std::string error_message =
GetString(
string);
91 std::string dummy_script;
92 auto back_inserter = std::back_inserter(dummy_script);
94 dummy_script.reserve(error_message.size() + 128 + 64 * messages.size());
96 fmt::format_to(back_inserter,
"class Dummy{0} extends {0}Controller {{\n function Start()\n {{\n", type);
97 for (std::string &message : messages) {
98 fmt::format_to(back_inserter,
" {}Log.Error(\"{}\");\n", type, message);
100 dummy_script +=
" }\n}\n";
103 sq_pushroottable(vm);
104 if (SQ_SUCCEEDED(sq_compilebuffer(vm, dummy_script.c_str(), dummy_script.size(),
"dummy", SQTrue))) {
106 if (SQ_SUCCEEDED(sq_call(vm, 1, SQFalse, SQTrue))) {