(svn r26486) -Codechange: replace a number of snprintfs with seprintf

pull/155/head
rubidium 10 years ago
parent 24c7134bff
commit 6ecc602050

@ -120,7 +120,7 @@ AIInfo *AIScannerInfo::FindInfo(const char *nameParam, int versionParam, bool fo
if (force_exact_match) {
/* Try to find a direct 'name.version' match */
char ai_name_tmp[1024];
snprintf(ai_name_tmp, sizeof(ai_name_tmp), "%s.%d", ai_name, versionParam);
seprintf(ai_name_tmp, lastof(ai_name_tmp), "%s.%d", ai_name, versionParam);
strtolower(ai_name_tmp);
if (this->info_list.find(ai_name_tmp) != this->info_list.end()) return static_cast<AIInfo *>(this->info_list[ai_name_tmp]);
}
@ -160,7 +160,7 @@ AILibrary *AIScannerLibrary::FindLibrary(const char *library, int version)
{
/* 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);
/* Check if the library + version exists */

@ -1168,7 +1168,7 @@ CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, u
if (c->name_1 == STR_SV_UNNAMED && c->name == NULL) {
char buf[80];
snprintf(buf, lengthof(buf), "%s Transport", text);
seprintf(buf, lastof(buf), "%s Transport", text);
DoCommand(0, 0, 0, DC_EXEC, CMD_RENAME_COMPANY, buf);
}
}

@ -113,7 +113,7 @@ static void debug_print(const char *dbg, const char *buf)
if (_debug_socket != INVALID_SOCKET) {
char buf2[1024 + 32];
snprintf(buf2, lengthof(buf2), "%sdbg: [%s] %s\n", GetLogPrefix(), dbg, buf);
seprintf(buf2, lastof(buf2), "%sdbg: [%s] %s\n", GetLogPrefix(), dbg, buf);
/* Sending out an error when this fails would be nice, however... the error
* would have to be send over this failing socket which won't work. */
send(_debug_socket, buf2, (int)strlen(buf2), 0);
@ -238,10 +238,10 @@ const char *GetDebugString()
memset(dbgstr, 0, sizeof(dbgstr));
i = debug_level;
snprintf(dbgstr, sizeof(dbgstr), "%s=%d", i->name, *i->level);
seprintf(dbgstr, lastof(dbgstr), "%s=%d", i->name, *i->level);
for (i++; i != endof(debug_level); i++) {
snprintf(dbgval, sizeof(dbgval), ", %s=%d", i->name, *i->level);
seprintf(dbgval, lastof(dbgval), ", %s=%d", i->name, *i->level);
strecat(dbgstr, dbgval, lastof(dbgstr));
}

@ -61,7 +61,7 @@ GameInfo *GameScannerInfo::FindInfo(const char *nameParam, int versionParam, boo
if (force_exact_match) {
/* Try to find a direct 'name.version' match */
char game_name_tmp[1024];
snprintf(game_name_tmp, sizeof(game_name_tmp), "%s.%d", game_name, versionParam);
seprintf(game_name_tmp, lastof(game_name_tmp), "%s.%d", game_name, versionParam);
strtolower(game_name_tmp);
if (this->info_list.find(game_name_tmp) != this->info_list.end()) return static_cast<GameInfo *>(this->info_list[game_name_tmp]);
}
@ -101,7 +101,7 @@ GameLibrary *GameScannerLibrary::FindLibrary(const char *library, int version)
{
/* 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);
/* Check if the library + version exists */

@ -189,7 +189,7 @@ void GamelogPrint(GamelogPrintProc *proc)
for (const LoggedAction *la = _gamelog_action; la != laend; la++) {
assert((uint)la->at < GLAT_END);
snprintf(buf, GAMELOG_BUF_LEN, "Tick %u: %s", (uint)la->tick, la_text[(uint)la->at]);
seprintf(buf, lastof(buf), "Tick %u: %s", (uint)la->tick, la_text[(uint)la->at]);
proc(buf);
const LoggedChange *lcend = &la->change[la->changes];

@ -33,6 +33,7 @@
#include "error.h"
#include "game/game.hpp"
#include "game/game_instance.hpp"
#include "string_func.h"
#include "safeguards.h"
@ -202,7 +203,7 @@ static void _GenerateWorld(void *)
if (_debug_desync_level > 0) {
char name[MAX_PATH];
snprintf(name, lengthof(name), "dmp_cmds_%08x_%08x.sav", _settings_game.game_creation.generation_seed, _date);
seprintf(name, lastof(name), "dmp_cmds_%08x_%08x.sav", _settings_game.game_creation.generation_seed, _date);
SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR, false);
}
} catch (...) {

@ -211,7 +211,7 @@ public:
/* Location */
char tmp[16];
snprintf(tmp, lengthof(tmp), "0x%.4X", tile);
seprintf(tmp, lastof(tmp), "0x%.4X", tile);
SetDParam(0, TileX(tile));
SetDParam(1, TileY(tile));
SetDParam(2, GetTileZ(tile));

@ -199,7 +199,7 @@ const char *GenerateCompanyPasswordHash(const char *password, const char *passwo
char salted_password[NETWORK_SERVER_ID_LENGTH];
memset(salted_password, 0, sizeof(salted_password));
snprintf(salted_password, sizeof(salted_password), "%s", password);
seprintf(salted_password, lastof(salted_password), "%s", password);
/* Add the game seed and the server's ID as the salt. */
for (uint i = 0; i < NETWORK_SERVER_ID_LENGTH - 1; i++) {
salted_password[i] ^= password_server_id[i] ^ (password_game_seed >> (i % 32));
@ -213,8 +213,7 @@ const char *GenerateCompanyPasswordHash(const char *password, const char *passwo
checksum.Append(salted_password, sizeof(salted_password) - 1);
checksum.Finish(digest);
for (int di = 0; di < 16; di++) sprintf(hashed_password + di * 2, "%02x", digest[di]);
hashed_password[lengthof(hashed_password) - 1] = '\0';
for (int di = 0; di < 16; di++) seprintf(hashed_password + di * 2, lastof(hashed_password), "%02x", digest[di]);
return hashed_password;
}
@ -703,7 +702,7 @@ void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const c
static void NetworkInitGameInfo()
{
if (StrEmpty(_settings_client.network.server_name)) {
snprintf(_settings_client.network.server_name, sizeof(_settings_client.network.server_name), "Unnamed Server");
seprintf(_settings_client.network.server_name, lastof(_settings_client.network.server_name), "Unnamed Server");
}
/* The server is a client too */
@ -1028,18 +1027,18 @@ static void NetworkGenerateServerId()
char coding_string[NETWORK_NAME_LENGTH];
int di;
snprintf(coding_string, sizeof(coding_string), "%d%s", (uint)Random(), "OpenTTD Server ID");
seprintf(coding_string, lastof(coding_string), "%d%s", (uint)Random(), "OpenTTD Server ID");
/* Generate the MD5 hash */
checksum.Append((const uint8*)coding_string, strlen(coding_string));
checksum.Finish(digest);
for (di = 0; di < 16; ++di) {
sprintf(hex_output + di * 2, "%02x", digest[di]);
seprintf(hex_output + di * 2, lastof(hex_output), "%02x", digest[di]);
}
/* _settings_client.network.network_id is our id */
snprintf(_settings_client.network.network_id, sizeof(_settings_client.network.network_id), "%s", hex_output);
seprintf(_settings_client.network.network_id, lastof(_settings_client.network.network_id), "%s", hex_output);
}
void NetworkStartDebugLog(NetworkAddress address)

@ -428,7 +428,7 @@ struct NetworkChatWindow : public Window {
len = strlen(cur_name);
if (tb_len < len && strncasecmp(cur_name, tb_buf, tb_len) == 0) {
/* Save the data it was before completion */
if (!second_scan) snprintf(_chat_tab_completion_buf, lengthof(_chat_tab_completion_buf), "%s", tb->buf);
if (!second_scan) seprintf(_chat_tab_completion_buf, lastof(_chat_tab_completion_buf), "%s", tb->buf);
_chat_tab_completion_active = true;
/* Change to the found name. Add ': ' if we are at the start of the line (pretty) */

@ -958,7 +958,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(Packet *p)
switch (action) {
case NETWORK_ACTION_CHAT_CLIENT:
/* For speaking to client we need the client-name */
snprintf(name, sizeof(name), "%s", ci_to->client_name);
seprintf(name, lastof(name), "%s", ci_to->client_name);
ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
break;
@ -979,7 +979,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(Packet *p)
}
} else {
/* Display message from somebody else */
snprintf(name, sizeof(name), "%s", ci_to->client_name);
seprintf(name, lastof(name), "%s", ci_to->client_name);
ci = ci_to;
}

@ -756,7 +756,7 @@ public:
case WID_NG_JOIN: // Join Game
if (this->server != NULL) {
snprintf(_settings_client.network.last_host, sizeof(_settings_client.network.last_host), "%s", this->server->address.GetHostname());
seprintf(_settings_client.network.last_host, lastof(_settings_client.network.last_host), "%s", this->server->address.GetHostname());
_settings_client.network.last_port = this->server->address.GetPort();
ShowNetworkLobbyWindow(this->server);
}

@ -384,7 +384,7 @@ void ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE(Packet *p, NetworkAd
}
if (item->info.hostname[0] == '\0') {
snprintf(item->info.hostname, sizeof(item->info.hostname), "%s", client_addr->GetHostname());
seprintf(item->info.hostname, lastof(item->info.hostname), "%s", client_addr->GetHostname());
}
if (client_addr->GetAddress()->ss_family == AF_INET6) {

@ -90,7 +90,7 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint right, uint
/* Prepare and draw GRF ID */
char buff[256];
snprintf(buff, lengthof(buff), "%08X", BSWAP32(c->ident.grfid));
seprintf(buff, lastof(buff), "%08X", BSWAP32(c->ident.grfid));
SetDParamStr(0, buff);
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_GRF_ID);

@ -1090,7 +1090,7 @@ void SwitchToMode(SwitchMode new_mode)
case SM_NEWGAME: // New Game --> 'Random game'
#ifdef ENABLE_NETWORK
if (_network_server) {
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "Random Map");
seprintf(_network_game_info.map_name, lastof(_network_game_info.map_name), "Random Map");
}
#endif /* ENABLE_NETWORK */
MakeNewGame(false, new_mode == SM_NEWGAME);
@ -1117,7 +1117,7 @@ void SwitchToMode(SwitchMode new_mode)
DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE);
#ifdef ENABLE_NETWORK
if (_network_server) {
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded game)", _file_to_saveload.title);
seprintf(_network_game_info.map_name, lastof(_network_game_info.map_name), "%s (Loaded game)", _file_to_saveload.title);
}
#endif /* ENABLE_NETWORK */
}
@ -1127,7 +1127,7 @@ void SwitchToMode(SwitchMode new_mode)
case SM_START_HEIGHTMAP: // Load a heightmap and start a new game from it
#ifdef ENABLE_NETWORK
if (_network_server) {
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Heightmap)", _file_to_saveload.title);
seprintf(_network_game_info.map_name, lastof(_network_game_info.map_name), "%s (Heightmap)", _file_to_saveload.title);
}
#endif /* ENABLE_NETWORK */
MakeNewGame(true, true);
@ -1373,7 +1373,7 @@ void StateGameLoop()
if (_debug_desync_level > 2 && _date_fract == 0 && (_date & 0x1F) == 0) {
/* Save the desync savegame if needed. */
char name[MAX_PATH];
snprintf(name, lengthof(name), "dmp_cmds_%08x_%08x.sav", _settings_game.game_creation.generation_seed, _date);
seprintf(name, lastof(name), "dmp_cmds_%08x_%08x.sav", _settings_game.game_creation.generation_seed, _date);
SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR, false);
}
@ -1425,7 +1425,7 @@ static void DoAutosave()
static int _autosave_ctr = 0;
/* generate a savegame name and number according to _settings_client.gui.max_num_autosaves */
snprintf(buf, sizeof(buf), "autosave%d.sav", _autosave_ctr);
seprintf(buf, lastof(buf), "autosave%d.sav", _autosave_ctr);
if (++_autosave_ctr >= _settings_client.gui.max_num_autosaves) _autosave_ctr = 0;
}

@ -15,6 +15,7 @@
#include "../../crashlog.h"
#include "../../core/random_func.hpp"
#include "../../debug.h"
#include "../../string_func.h"
#include <dirent.h>
@ -107,13 +108,13 @@ bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb
#if defined(__MORPHOS__) || defined(__AMIGAOS__)
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
if (FiosIsRoot(path)) {
res = snprintf(filename, lengthof(filename), "%s:%s", path, ent->d_name);
res = seprintf(filename, lastof(filename), "%s:%s", path, ent->d_name);
} else // XXX - only next line!
#else
assert(path[strlen(path) - 1] == PATHSEPCHAR);
if (strlen(path) > 2) assert(path[strlen(path) - 2] != PATHSEPCHAR);
#endif
res = snprintf(filename, lengthof(filename), "%s%s", path, ent->d_name);
res = seprintf(filename, lastof(filename), "%s%s", path, ent->d_name);
/* Could we fully concatenate the path and filename? */
if (res >= (int)lengthof(filename) || res < 0) return false;

@ -2614,7 +2614,7 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check)
/* loader for this savegame type is not implemented? */
if (fmt->init_load == NULL) {
char err_str[64];
snprintf(err_str, lengthof(err_str), "Loader for '%s' is not available.", fmt->name);
seprintf(err_str, lastof(err_str), "Loader for '%s' is not available.", fmt->name);
SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, err_str);
}

@ -718,12 +718,12 @@ static const char *MakeScreenshotName(const char *default_fn, const char *ext, b
/* Add extension to screenshot file */
size_t len = strlen(_screenshot_name);
snprintf(&_screenshot_name[len], lengthof(_screenshot_name) - len, ".%s", ext);
seprintf(&_screenshot_name[len], lastof(_screenshot_name), ".%s", ext);
const char *screenshot_dir = crashlog ? _personal_dir : FiosGetScreenshotDir();
for (uint serial = 1;; serial++) {
if (snprintf(_full_screenshot_name, lengthof(_full_screenshot_name), "%s%s", screenshot_dir, _screenshot_name) >= (int)lengthof(_full_screenshot_name)) {
if (seprintf(_full_screenshot_name, lastof(_full_screenshot_name), "%s%s", screenshot_dir, _screenshot_name) >= (int)lengthof(_full_screenshot_name)) {
/* We need more characters than MAX_PATH -> end with error */
_full_screenshot_name[0] = '\0';
break;
@ -731,7 +731,7 @@ static const char *MakeScreenshotName(const char *default_fn, const char *ext, b
if (!generate) break; // allow overwriting of non-automatic filenames
if (!FileExists(_full_screenshot_name)) break;
/* If file exists try another one with same name, but just with a higher index */
snprintf(&_screenshot_name[len], lengthof(_screenshot_name) - len, "#%u.%s", serial, ext);
seprintf(&_screenshot_name[len], lastof(_screenshot_name) - len, "#%u.%s", serial, ext);
}
return _full_screenshot_name;

@ -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;
}

@ -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;

@ -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;

@ -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;
}

@ -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) {

@ -1537,7 +1537,7 @@ static void SaveVersionInConfig(IniFile *ini)
IniGroup *group = ini->GetGroup("version");
char version[9];
snprintf(version, lengthof(version), "%08X", _openttd_newgrf_version);
seprintf(version, lastof(version), "%08X", _openttd_newgrf_version);
const char * const versions[][2] = {
{ "version_string", _openttd_revision },
@ -2040,9 +2040,9 @@ void IConsoleGetSetting(const char *name, bool force_newgame)
IConsolePrintF(CC_WARNING, "Current value for '%s' is: '%s'", name, (GetVarMemType(sd->save.conv) == SLE_VAR_STRQ) ? *(const char * const *)ptr : (const char *)ptr);
} else {
if (sd->desc.cmd == SDT_BOOLX) {
snprintf(value, sizeof(value), (*(const bool*)ptr != 0) ? "on" : "off");
seprintf(value, lastof(value), (*(const bool*)ptr != 0) ? "on" : "off");
} else {
snprintf(value, sizeof(value), sd->desc.min < 0 ? "%d" : "%u", (int32)ReadValue(ptr, sd->save.conv));
seprintf(value, lastof(value), sd->desc.min < 0 ? "%d" : "%u", (int32)ReadValue(ptr, sd->save.conv));
}
IConsolePrintF(CC_WARNING, "Current value for '%s' is: '%s' (min: %s%d, max: %u)",
@ -2066,11 +2066,11 @@ void IConsoleListSettings(const char *prefilter)
const void *ptr = GetVariableAddress(&GetGameSettings(), &sd->save);
if (sd->desc.cmd == SDT_BOOLX) {
snprintf(value, lengthof(value), (*(const bool *)ptr != 0) ? "on" : "off");
seprintf(value, lastof(value), (*(const bool *)ptr != 0) ? "on" : "off");
} else if (sd->desc.cmd == SDT_STRING) {
snprintf(value, sizeof(value), "%s", (GetVarMemType(sd->save.conv) == SLE_VAR_STRQ) ? *(const char * const *)ptr : (const char *)ptr);
seprintf(value, lastof(value), "%s", (GetVarMemType(sd->save.conv) == SLE_VAR_STRQ) ? *(const char * const *)ptr : (const char *)ptr);
} else {
snprintf(value, lengthof(value), sd->desc.min < 0 ? "%d" : "%u", (int32)ReadValue(ptr, sd->save.conv));
seprintf(value, lastof(value), sd->desc.min < 0 ? "%d" : "%u", (int32)ReadValue(ptr, sd->save.conv));
}
IConsolePrintF(CC_DEFAULT, "%s = %s", sd->desc.name, value);
}

@ -433,8 +433,8 @@ static char *FormatTinyOrISODate(char *buff, Date date, StringID str, const char
char day[3];
char month[3];
/* We want to zero-pad the days and months */
snprintf(day, lengthof(day), "%02i", ymd.day);
snprintf(month, lengthof(month), "%02i", ymd.month + 1);
seprintf(day, lastof(day), "%02i", ymd.day);
seprintf(month, lastof(month), "%02i", ymd.month + 1);
int64 args[] = {(int64)(size_t)day, (int64)(size_t)month, ymd.year};
StringParameters tmp_params(args);

@ -224,7 +224,7 @@ static bool CreateMainSurface(uint w, uint h)
InitPalette();
char caption[32];
snprintf(caption, sizeof(caption), "OpenTTD %s", _openttd_revision);
seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision);
set_window_title(caption);
enable_hardware_cursor();

@ -418,7 +418,7 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
NOT_REACHED();
}
snprintf(caption, sizeof(caption), "OpenTTD %s", _openttd_revision);
seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision);
SDL_CALL SDL_WM_SetCaption(caption, caption);
GameSizeChanged();

Loading…
Cancel
Save