Changeset - r26958:e418be5dc8a5
[Not reviewed]
master
0 1 0
glx22 - 19 months ago 2023-02-09 18:28:50
glx@openttd.org
Codechange: Use {fmt} for script_admin JSON generation
1 file changed with 2 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/script/api/script_admin.cpp
Show inline comments
 
@@ -25,15 +25,13 @@
 

	
 
	switch (sq_gettype(vm, index)) {
 
		case OT_INTEGER: {
 
			SQInteger res;
 
			sq_getinteger(vm, index, &res);
 

	
 
			char buf[10];
 
			seprintf(buf, lastof(buf), "%d", (int32)res);
 
			data = buf;
 
			data = fmt::format("{}", res);
 
			return true;
 
		}
 

	
 
		case OT_STRING: {
 
			const SQChar *buf;
 
			sq_getstring(vm, index, &buf);
 
@@ -41,13 +39,13 @@
 
			size_t len = strlen(buf) + 1;
 
			if (len >= 255) {
 
				ScriptLog::Error("Maximum string length is 254 chars. No data sent.");
 
				return false;
 
			}
 

	
 
			data = std::string("\"") + buf + "\"";
 
			data = fmt::format("\"{}\"", buf);
 
			return true;
 
		}
 

	
 
		case OT_ARRAY: {
 
			data = "[ ";
 

	
0 comments (0 inline, 0 general)