summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/script_admin.cpp2
-rw-r--r--src/script/api/script_controller.cpp12
-rw-r--r--src/script/script_config.cpp3
-rw-r--r--src/script/script_info.cpp10
-rw-r--r--src/script/script_scanner.cpp2
5 files changed, 15 insertions, 14 deletions
diff --git a/src/script/api/script_admin.cpp b/src/script/api/script_admin.cpp
index 9027b29a2..a84f999dd 100644
--- a/src/script/api/script_admin.cpp
+++ b/src/script/api/script_admin.cpp
@@ -30,7 +30,7 @@
sq_getinteger(vm, index, &res);
char buf[10];
- snprintf(buf, sizeof(buf), "%d", (int32)res);
+ seprintf(buf, lastof(buf), "%d", (int32)res);
data = buf;
return true;
}
diff --git a/src/script/api/script_controller.cpp b/src/script/api/script_controller.cpp
index 7f8df248d..4c3a5cd6e 100644
--- a/src/script/api/script_controller.cpp
+++ b/src/script/api/script_controller.cpp
@@ -53,7 +53,7 @@
ScriptObject::GetActiveInstance()->Pause();
char log_message[1024];
- snprintf(log_message, sizeof(log_message), "Break: %s", message);
+ seprintf(log_message, lastof(log_message), "Break: %s", message);
ScriptLog::Log(ScriptLog::LOG_SQ_ERROR, log_message);
/* Inform script developer that his script has been paused and
@@ -115,13 +115,13 @@ ScriptController::~ScriptController()
/* Internally we store libraries as 'library.version' */
char library_name[1024];
- snprintf(library_name, sizeof(library_name), "%s.%d", library, version);
+ seprintf(library_name, lastof(library_name), "%s.%d", library, version);
strtolower(library_name);
ScriptInfo *lib = ScriptObject::GetActiveInstance()->FindLibrary(library, version);
if (lib == NULL) {
char error[1024];
- snprintf(error, sizeof(error), "couldn't find library '%s' with version %d", library, version);
+ seprintf(error, lastof(error), "couldn't find library '%s' with version %d", library, version);
throw sq_throwerror(vm, OTTD2SQ(error));
}
@@ -138,7 +138,7 @@ ScriptController::~ScriptController()
int next_number = ++controller->loaded_library_count;
/* Create a new fake internal name */
- snprintf(fake_class, sizeof(fake_class), "_internalNA%d", next_number);
+ seprintf(fake_class, lastof(fake_class), "_internalNA%d", next_number);
/* Load the library in a 'fake' namespace, so we can link it to the name the user requested */
sq_pushroottable(vm);
@@ -147,7 +147,7 @@ ScriptController::~ScriptController()
/* Load the library */
if (!engine->LoadScript(vm, lib->GetMainScript(), false)) {
char error[1024];
- snprintf(error, sizeof(error), "there was a compile error when importing '%s' version %d", library, version);
+ seprintf(error, lastof(error), "there was a compile error when importing '%s' version %d", library, version);
throw sq_throwerror(vm, OTTD2SQ(error));
}
/* Create the fake class */
@@ -166,7 +166,7 @@ ScriptController::~ScriptController()
sq_pushstring(vm, OTTD2SQ(lib->GetInstanceName()), -1);
if (SQ_FAILED(sq_get(vm, -2))) {
char error[1024];
- snprintf(error, sizeof(error), "unable to find class '%s' in the library '%s' version %d", lib->GetInstanceName(), library, version);
+ seprintf(error, lastof(error), "unable to find class '%s' in the library '%s' version %d", lib->GetInstanceName(), library, version);
throw sq_throwerror(vm, OTTD2SQ(error));
}
HSQOBJECT obj;
diff --git a/src/script/script_config.cpp b/src/script/script_config.cpp
index 7842a3a9d..48a1459d9 100644
--- a/src/script/script_config.cpp
+++ b/src/script/script_config.cpp
@@ -14,6 +14,7 @@
#include "../core/random_func.hpp"
#include "script_info.hpp"
#include "../textfile_gui.h"
+#include "../string_func.h"
#include "../safeguards.h"
@@ -188,7 +189,7 @@ void ScriptConfig::SettingsToString(char *string, size_t size) const
string[0] = '\0';
for (SettingValueList::const_iterator it = this->settings.begin(); it != this->settings.end(); it++) {
char no[10];
- snprintf(no, sizeof(no), "%d", (*it).second);
+ seprintf(no, lastof(no), "%d", (*it).second);
/* Check if the string would fit in the destination */
size_t needed_size = strlen((*it).first) + 1 + strlen(no) + 1;
diff --git a/src/script/script_info.cpp b/src/script/script_info.cpp
index f3ea1747b..27bcec1eb 100644
--- a/src/script/script_info.cpp
+++ b/src/script/script_info.cpp
@@ -50,7 +50,7 @@ bool ScriptInfo::CheckMethod(const char *name) const
{
if (!this->engine->MethodExists(*this->SQ_instance, name)) {
char error[1024];
- snprintf(error, sizeof(error), "your info.nut/library.nut doesn't have the method '%s'", name);
+ seprintf(error, lastof(error), "your info.nut/library.nut doesn't have the method '%s'", name);
this->engine->ThrowError(error);
return false;
}
@@ -195,7 +195,7 @@ SQInteger ScriptInfo::AddSetting(HSQUIRRELVM vm)
items |= 0x100;
} else {
char error[1024];
- snprintf(error, sizeof(error), "unknown setting property '%s'", key);
+ seprintf(error, lastof(error), "unknown setting property '%s'", key);
this->engine->ThrowError(error);
return SQ_ERROR;
}
@@ -208,7 +208,7 @@ SQInteger ScriptInfo::AddSetting(HSQUIRRELVM vm)
* be set for the same config item. */
if ((items & 0x200) != 0 && (config.flags & SCRIPTCONFIG_RANDOM) != 0) {
char error[1024];
- snprintf(error, sizeof(error), "Setting both random_deviation and SCRIPTCONFIG_RANDOM is not allowed");
+ seprintf(error, lastof(error), "Setting both random_deviation and SCRIPTCONFIG_RANDOM is not allowed");
this->engine->ThrowError(error);
return SQ_ERROR;
}
@@ -219,7 +219,7 @@ SQInteger ScriptInfo::AddSetting(HSQUIRRELVM vm)
uint mask = (config.flags & SCRIPTCONFIG_BOOLEAN) ? 0x1F3 : 0x1FF;
if (items != mask) {
char error[1024];
- snprintf(error, sizeof(error), "please define all properties of a setting (min/max not allowed for booleans)");
+ seprintf(error, lastof(error), "please define all properties of a setting (min/max not allowed for booleans)");
this->engine->ThrowError(error);
return SQ_ERROR;
}
@@ -242,7 +242,7 @@ SQInteger ScriptInfo::AddLabels(HSQUIRRELVM vm)
if (config == NULL) {
char error[1024];
- snprintf(error, sizeof(error), "Trying to add labels for non-defined setting '%s'", setting_name);
+ seprintf(error, lastof(error), "Trying to add labels for non-defined setting '%s'", setting_name);
this->engine->ThrowError(error);
return SQ_ERROR;
}
diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp
index b90f63cd8..578068592 100644
--- a/src/script/script_scanner.cpp
+++ b/src/script/script_scanner.cpp
@@ -114,7 +114,7 @@ void ScriptScanner::RegisterScript(ScriptInfo *info)
strtolower(script_original_name);
char script_name[1024];
- snprintf(script_name, sizeof(script_name), "%s.%d", script_original_name, info->GetVersion());
+ seprintf(script_name, lastof(script_name), "%s.%d", script_original_name, info->GetVersion());
/* Check if GetShortName follows the rules */
if (strlen(info->GetShortName()) != 4) {