summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-06-12 09:10:17 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-06-13 12:45:45 +0200
commit55a11710a6c0f7942f3947711f2050c34782c39d (patch)
tree491b3009324e623236977614e91371a0ea4abac7 /src/script
parenta99ac62c1ab816ee48cac85fdf834f9fdc599cb1 (diff)
downloadopenttd-55a11710a6c0f7942f3947711f2050c34782c39d.tar.xz
Codechange: convert printf DEBUG statements to fmt Debug statements
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/script_list.cpp4
-rw-r--r--src/script/api/script_log.cpp2
-rw-r--r--src/script/api/script_log.hpp2
-rw-r--r--src/script/api/script_object.cpp4
-rw-r--r--src/script/api/script_order.cpp2
-rw-r--r--src/script/api/script_rail.cpp2
-rw-r--r--src/script/script_instance.cpp6
-rw-r--r--src/script/script_scanner.cpp12
-rw-r--r--src/script/squirrel.cpp14
-rw-r--r--src/script/squirrel_std.cpp2
10 files changed, 25 insertions, 25 deletions
diff --git a/src/script/api/script_list.cpp b/src/script/api/script_list.cpp
index 4d8b39ea1..1985cdbfb 100644
--- a/src/script/api/script_list.cpp
+++ b/src/script/api/script_list.cpp
@@ -469,7 +469,7 @@ int64 ScriptList::Begin()
int64 ScriptList::Next()
{
if (this->initialized == false) {
- DEBUG(script, 0, "Next() is invalid as Begin() is never called");
+ Debug(script, 0, "Next() is invalid as Begin() is never called");
return 0;
}
return this->sorter->Next();
@@ -483,7 +483,7 @@ bool ScriptList::IsEmpty()
bool ScriptList::IsEnd()
{
if (this->initialized == false) {
- DEBUG(script, 0, "IsEnd() is invalid as Begin() is never called");
+ Debug(script, 0, "IsEnd() is invalid as Begin() is never called");
return true;
}
return this->sorter->IsEnd();
diff --git a/src/script/api/script_log.cpp b/src/script/api/script_log.cpp
index 38a9a87d9..63c4548aa 100644
--- a/src/script/api/script_log.cpp
+++ b/src/script/api/script_log.cpp
@@ -74,7 +74,7 @@
}
/* Also still print to debug window */
- DEBUG(script, level, "[%d] [%c] %s", (uint)ScriptObject::GetRootCompany(), logc, log->lines[log->pos]);
+ Debug(script, level, "[{}] [{}] {}", (uint)ScriptObject::GetRootCompany(), logc, log->lines[log->pos]);
InvalidateWindowData(WC_AI_DEBUG, 0, ScriptObject::GetRootCompany());
}
diff --git a/src/script/api/script_log.hpp b/src/script/api/script_log.hpp
index a71e09c2e..b6767d3f8 100644
--- a/src/script/api/script_log.hpp
+++ b/src/script/api/script_log.hpp
@@ -23,7 +23,7 @@ class ScriptLog : public ScriptObject {
public:
/**
- * Log levels; The value is also feed to DEBUG() lvl.
+ * Log levels; The value is also feed to Debug() lvl.
* This has no use for you, as script writer.
* @api -all
*/
diff --git a/src/script/api/script_object.cpp b/src/script/api/script_object.cpp
index 208e0d8e8..1e20b55ed 100644
--- a/src/script/api/script_object.cpp
+++ b/src/script/api/script_object.cpp
@@ -85,7 +85,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
/* static */ void ScriptObject::SetLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
{
ScriptStorage *s = GetStorage();
- DEBUG(script, 6, "SetLastCommand company=%02d tile=%06x p1=%08x p2=%08x cmd=%d", s->root_company, tile, p1, p2, cmd);
+ Debug(script, 6, "SetLastCommand company={:02d} tile={:06x} p1={:08x} p2={:08x} cmd={}", s->root_company, tile, p1, p2, cmd);
s->last_tile = tile;
s->last_p1 = p1;
s->last_p2 = p2;
@@ -95,7 +95,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
/* static */ bool ScriptObject::CheckLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
{
ScriptStorage *s = GetStorage();
- DEBUG(script, 6, "CheckLastCommand company=%02d tile=%06x p1=%08x p2=%08x cmd=%d", s->root_company, tile, p1, p2, cmd);
+ Debug(script, 6, "CheckLastCommand company={:02d} tile={:06x} p1={:08x} p2={:08x} cmd={}", s->root_company, tile, p1, p2, cmd);
if (s->last_tile != tile) return false;
if (s->last_p1 != p1) return false;
if (s->last_p2 != p2) return false;
diff --git a/src/script/api/script_order.cpp b/src/script/api/script_order.cpp
index b7bcde730..ce0ee76de 100644
--- a/src/script/api/script_order.cpp
+++ b/src/script/api/script_order.cpp
@@ -564,7 +564,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance)
/* Make sure we don't go into an infinite loop */
int retry = ScriptObject::GetCallbackVariable(3) - 1;
if (retry < 0) {
- DEBUG(script, 0, "Possible infinite loop in SetOrderFlags() detected");
+ Debug(script, 0, "Possible infinite loop in SetOrderFlags() detected");
return false;
}
ScriptObject::SetCallbackVariable(3, retry);
diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp
index 01916c8c5..8668906c2 100644
--- a/src/script/api/script_rail.cpp
+++ b/src/script/api/script_rail.cpp
@@ -195,7 +195,7 @@
int index = 0;
const StationSpec *spec = StationClass::GetByGrf(file->grfid, res, &index);
if (spec == nullptr) {
- DEBUG(grf, 1, "%s returned an invalid station ID for 'AI construction/purchase selection (18)' callback", file->filename);
+ Debug(grf, 1, "{} returned an invalid station ID for 'AI construction/purchase selection (18)' callback", file->filename);
} else {
/* We might have gotten an usable station spec. Try to build it, but if it fails we'll fall back to the original station. */
if (ScriptObject::DoCommand(tile, p1, p2 | spec->cls_id | index << 8, CMD_BUILD_RAIL_STATION)) return true;
diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp
index c354126ca..2d32b02e8 100644
--- a/src/script/script_instance.cpp
+++ b/src/script/script_instance.cpp
@@ -124,7 +124,7 @@ bool ScriptInstance::LoadCompatibilityScripts(const char *api_version, Subdirect
if (this->engine->LoadScript(buf.c_str())) return true;
ScriptLog::Error("Failed to load API compatibility script");
- DEBUG(script, 0, "Error compiling / running API compatibility script: %s", buf.c_str());
+ Debug(script, 0, "Error compiling / running API compatibility script: {}", buf);
return false;
}
@@ -152,7 +152,7 @@ void ScriptInstance::Continue()
void ScriptInstance::Died()
{
- DEBUG(script, 0, "The script died unexpectedly.");
+ Debug(script, 0, "The script died unexpectedly.");
this->is_dead = true;
this->in_shutdown = true;
@@ -692,7 +692,7 @@ bool ScriptInstance::DoCommandCallback(const CommandCost &result, TileIndex tile
ScriptObject::ActiveInstance active(this);
if (!ScriptObject::CheckLastCommand(tile, p1, p2, cmd)) {
- DEBUG(script, 1, "DoCommandCallback terminating a script, last command does not match expected command");
+ Debug(script, 1, "DoCommandCallback terminating a script, last command does not match expected command");
return false;
}
diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp
index bdde99f6c..dc14da1db 100644
--- a/src/script/script_scanner.cpp
+++ b/src/script/script_scanner.cpp
@@ -38,7 +38,7 @@ bool ScriptScanner::AddFile(const std::string &filename, size_t basepath_length,
try {
this->engine->LoadScript(filename.c_str());
} catch (Script_FatalError &e) {
- DEBUG(script, 0, "Fatal error '%s' when trying to load the script '%s'.", e.GetErrorMessage().c_str(), filename.c_str());
+ Debug(script, 0, "Fatal error '{}' when trying to load the script '{}'.", e.GetErrorMessage(), filename);
return false;
}
return true;
@@ -106,7 +106,7 @@ void ScriptScanner::RegisterScript(ScriptInfo *info)
/* Check if GetShortName follows the rules */
if (strlen(info->GetShortName()) != 4) {
- DEBUG(script, 0, "The script '%s' returned a string from GetShortName() which is not four characaters. Unable to load the script.", info->GetName());
+ Debug(script, 0, "The script '{}' returned a string from GetShortName() which is not four characaters. Unable to load the script.", info->GetName());
delete info;
return;
}
@@ -123,10 +123,10 @@ void ScriptScanner::RegisterScript(ScriptInfo *info)
return;
}
- DEBUG(script, 1, "Registering two scripts with the same name and version");
- DEBUG(script, 1, " 1: %s", this->info_list[script_name]->GetMainScript());
- DEBUG(script, 1, " 2: %s", info->GetMainScript());
- DEBUG(script, 1, "The first is taking precedence.");
+ Debug(script, 1, "Registering two scripts with the same name and version");
+ Debug(script, 1, " 1: {}", this->info_list[script_name]->GetMainScript());
+ Debug(script, 1, " 2: {}", info->GetMainScript());
+ Debug(script, 1, "The first is taking precedence.");
delete info;
return;
diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp
index 41024b2f9..995776408 100644
--- a/src/script/squirrel.cpp
+++ b/src/script/squirrel.cpp
@@ -207,7 +207,7 @@ void Squirrel::CompileError(HSQUIRRELVM vm, const SQChar *desc, const SQChar *so
engine->crashed = true;
SQPrintFunc *func = engine->print_func;
if (func == nullptr) {
- DEBUG(misc, 0, "[Squirrel] Compile error: %s", buf);
+ Debug(misc, 0, "[Squirrel] Compile error: {}", buf);
} else {
(*func)(true, buf);
}
@@ -340,8 +340,8 @@ void Squirrel::AddClassBegin(const char *class_name, const char *parent_class)
sq_pushstring(this->vm, class_name, -1);
sq_pushstring(this->vm, parent_class, -1);
if (SQ_FAILED(sq_get(this->vm, -3))) {
- DEBUG(misc, 0, "[squirrel] Failed to initialize class '%s' based on parent class '%s'", class_name, parent_class);
- DEBUG(misc, 0, "[squirrel] Make sure that '%s' exists before trying to define '%s'", parent_class, class_name);
+ Debug(misc, 0, "[squirrel] Failed to initialize class '{}' based on parent class '{}'", class_name, parent_class);
+ Debug(misc, 0, "[squirrel] Make sure that '{}' exists before trying to define '{}'", parent_class, class_name);
return;
}
sq_newclass(this->vm, SQTrue);
@@ -425,7 +425,7 @@ bool Squirrel::CallMethod(HSQOBJECT instance, const char *method_name, HSQOBJECT
/* Find the function-name inside the script */
sq_pushstring(this->vm, method_name, -1);
if (SQ_FAILED(sq_get(this->vm, -2))) {
- DEBUG(misc, 0, "[squirrel] Could not find '%s' in the class", method_name);
+ Debug(misc, 0, "[squirrel] Could not find '{}' in the class", method_name);
sq_settop(this->vm, top);
return false;
}
@@ -490,14 +490,14 @@ bool Squirrel::CallBoolMethod(HSQOBJECT instance, const char *method_name, bool
}
if (SQ_FAILED(sq_get(vm, -2))) {
- DEBUG(misc, 0, "[squirrel] Failed to find class by the name '%s%s'", prepend_API_name ? engine->GetAPIName() : "", class_name);
+ Debug(misc, 0, "[squirrel] Failed to find class by the name '{}{}'", prepend_API_name ? engine->GetAPIName() : "", class_name);
sq_settop(vm, oldtop);
return false;
}
/* Create the instance */
if (SQ_FAILED(sq_createinstance(vm, -1))) {
- DEBUG(misc, 0, "[squirrel] Failed to create instance for class '%s%s'", prepend_API_name ? engine->GetAPIName() : "", class_name);
+ Debug(misc, 0, "[squirrel] Failed to create instance for class '{}{}'", prepend_API_name ? engine->GetAPIName() : "", class_name);
sq_settop(vm, oldtop);
return false;
}
@@ -736,7 +736,7 @@ bool Squirrel::LoadScript(HSQUIRRELVM vm, const char *script, bool in_root)
}
vm->_ops_till_suspend = ops_left;
- DEBUG(misc, 0, "[squirrel] Failed to compile '%s'", script);
+ Debug(misc, 0, "[squirrel] Failed to compile '{}'", script);
return false;
}
diff --git a/src/script/squirrel_std.cpp b/src/script/squirrel_std.cpp
index 502721f36..82943e526 100644
--- a/src/script/squirrel_std.cpp
+++ b/src/script/squirrel_std.cpp
@@ -50,7 +50,7 @@ SQInteger SquirrelStd::require(HSQUIRRELVM vm)
SQStackInfos si;
sq_stackinfos(vm, 1, &si);
if (si.source == nullptr) {
- DEBUG(misc, 0, "[squirrel] Couldn't detect the script-name of the 'require'-caller; this should never happen!");
+ Debug(misc, 0, "[squirrel] Couldn't detect the script-name of the 'require'-caller; this should never happen!");
return SQ_ERROR;
}