Changeset - r21387:4ac1de161213
[Not reviewed]
src/ai/ai_scanner.cpp
Show inline comments
 
@@ -117,13 +117,13 @@ AIInfo *AIScannerInfo::FindInfo(const ch
 
		/* FALL THROUGH, like we were calling this function with a version. */
 
	}
 

	
 
	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]);
 
	}
 

	
 
	/* See if there is a compatible AI which goes by that name, with the highest
 
	 *  version which allows loading the requested version */
 
@@ -157,13 +157,13 @@ void AIScannerLibrary::RegisterAPI(class
 
}
 

	
 
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 */
 
	ScriptInfoList::iterator iter = this->info_list.find(library_name);
 
	if (iter == this->info_list.end()) return NULL;
 

	
src/company_cmd.cpp
Show inline comments
 
@@ -1165,13 +1165,13 @@ CommandCost CmdRenamePresident(TileIndex
 
		} else {
 
			c->president_name = strdup(text);
 

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

	
 
		MarkWholeScreenDirty();
 
		CompanyAdminUpdate(c);
src/debug.cpp
Show inline comments
 
@@ -110,13 +110,13 @@ char *DumpDebugFacilityNames(char *buf, 
 
static void debug_print(const char *dbg, const char *buf)
 
{
 
#if defined(ENABLE_NETWORK)
 
	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);
 
		return;
 
	}
 
#endif /* ENABLE_NETWORK */
 
@@ -235,16 +235,16 @@ const char *GetDebugString()
 
	const DebugLevel *i;
 
	static char dbgstr[150];
 
	char dbgval[20];
 

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

	
 
	return dbgstr;
 
}
 

	
src/game/game_scanner.cpp
Show inline comments
 
@@ -58,13 +58,13 @@ GameInfo *GameScannerInfo::FindInfo(cons
 
		/* FALL THROUGH, like we were calling this function with a version. */
 
	}
 

	
 
	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]);
 
	}
 

	
 
	/* See if there is a compatible Game script which goes by that name, with the highest
 
	 *  version which allows loading the requested version */
 
@@ -98,13 +98,13 @@ void GameScannerLibrary::RegisterAPI(cla
 
}
 

	
 
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 */
 
	ScriptInfoList::iterator iter = this->info_list.find(library_name);
 
	if (iter == this->info_list.end()) return NULL;
 

	
src/gamelog.cpp
Show inline comments
 
@@ -186,13 +186,13 @@ void GamelogPrint(GamelogPrintProc *proc
 

	
 
	const LoggedAction *laend = &_gamelog_action[_gamelog_actions];
 

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

	
 
		for (const LoggedChange *lc = la->change; lc != lcend; lc++) {
 
			_dbgofs = 0;
src/genworld.cpp
Show inline comments
 
@@ -30,12 +30,13 @@
 
#include "core/random_func.hpp"
 
#include "core/backup_type.hpp"
 
#include "progress.h"
 
#include "error.h"
 
#include "game/game.hpp"
 
#include "game/game_instance.hpp"
 
#include "string_func.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
void GenerateClearTile();
 
void GenerateIndustries();
 
@@ -199,13 +200,13 @@ static void _GenerateWorld(void *)
 

	
 
		if (_network_dedicated) DEBUG(net, 0, "Map generated, starting game");
 
		DEBUG(desync, 1, "new_map: %08x", _settings_game.game_creation.generation_seed);
 

	
 
		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 (...) {
 
		BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP, true);
 
		if (_cur_company.IsValid()) _cur_company.Restore();
 
		_generating_world = false;
src/misc_gui.cpp
Show inline comments
 
@@ -208,13 +208,13 @@ public:
 
		}
 
		GetString(this->landinfo_data[line_nr], str, lastof(this->landinfo_data[line_nr]));
 
		line_nr++;
 

	
 
		/* 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));
 
		SetDParamStr(3, tmp);
 
		GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_LANDINFO_COORDS, lastof(this->landinfo_data[line_nr]));
 
		line_nr++;
src/network/network.cpp
Show inline comments
 
@@ -196,13 +196,13 @@ const char *GenerateCompanyPasswordHash(
 
{
 
	if (StrEmpty(password)) return password;
 

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

	
 
	Md5 checksum;
 
@@ -210,14 +210,13 @@ const char *GenerateCompanyPasswordHash(
 
	static char hashed_password[NETWORK_SERVER_ID_LENGTH];
 

	
 
	/* Generate the MD5 hash */
 
	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;
 
}
 

	
 
/**
 
 * Check if the company we want to join requires a password.
 
@@ -700,13 +699,13 @@ void NetworkClientConnectGame(NetworkAdd
 
	new TCPClientConnecter(address);
 
}
 

	
 
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 */
 
	_network_game_info.clients_on = _network_dedicated ? 0 : 1;
 

	
 
	/* There should be always space for the server. */
 
@@ -1025,24 +1024,24 @@ static void NetworkGenerateServerId()
 
	Md5 checksum;
 
	uint8 digest[16];
 
	char hex_output[16 * 2 + 1];
 
	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)
 
{
 
	extern SOCKET _debug_socket;  // Comes from debug.c
 

	
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -425,13 +425,13 @@ struct NetworkChatWindow : public Window
 
				/* Now any match we make on _chat_tab_completion_buf after this, is perfect */
 
			}
 

	
 
			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) */
 
				if (pre_buf == tb_buf) {
 
					this->message_editbox.text.Print("%s: ", cur_name);
 
				} else {
src/network/network_client.cpp
Show inline comments
 
@@ -955,13 +955,13 @@ NetworkRecvStatus ClientNetworkGameSocke
 

	
 
	/* Did we initiate the action locally? */
 
	if (self_send) {
 
		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;
 

	
 
			/* For speaking to company or giving money, we need the company-name */
 
			case NETWORK_ACTION_GIVE_MONEY:
 
				if (!Company::IsValidID(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
 
@@ -976,13 +976,13 @@ NetworkRecvStatus ClientNetworkGameSocke
 
			}
 

	
 
			default: return NETWORK_RECV_STATUS_MALFORMED_PACKET;
 
		}
 
	} 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;
 
	}
 

	
 
	if (ci != NULL) {
 
		NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), self_send, name, msg, data);
 
	}
src/network/network_gui.cpp
Show inline comments
 
@@ -753,13 +753,13 @@ public:
 
			case WID_NG_START: // Start server
 
				ShowNetworkStartServerWindow();
 
				break;
 

	
 
			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);
 
				}
 
				break;
 

	
 
			case WID_NG_REFRESH: // Refresh
src/network/network_udp.cpp
Show inline comments
 
@@ -381,13 +381,13 @@ void ClientNetworkUDPSocketHandler::Rece
 

	
 
			this->SendPacket(&packet, &item->address);
 
		}
 
	}
 

	
 
	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) {
 
		strecat(item->info.server_name, " (IPv6)", lastof(item->info.server_name));
 
	}
 

	
src/newgrf_gui.cpp
Show inline comments
 
@@ -87,13 +87,13 @@ static void ShowNewGRFInfo(const GRFConf
 
		SetDParamStr(0, c->filename);
 
		y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_FILENAME);
 
	}
 

	
 
	/* 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);
 

	
 
	if ((_settings_client.gui.newgrf_developer_tools || _settings_client.gui.newgrf_show_old_versions) && c->version != 0) {
 
		SetDParam(0, c->version);
 
		y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_VERSION);
src/openttd.cpp
Show inline comments
 
@@ -1087,13 +1087,13 @@ void SwitchToMode(SwitchMode new_mode)
 
			break;
 

	
 
		case SM_RESTARTGAME: // Restart --> 'Random game' with current settings
 
		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);
 
			break;
 

	
 
		case SM_LOAD_GAME: { // Load game, Play Scenario
 
@@ -1114,23 +1114,23 @@ void SwitchToMode(SwitchMode new_mode)
 
				/* Execute the game-start script */
 
				IConsoleCmdExec("exec scripts/game_start.scr 0");
 
				/* Decrease pause counter (was increased from opening load dialog) */
 
				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 */
 
			}
 
			break;
 
		}
 

	
 
		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);
 
			break;
 

	
 
		case SM_LOAD_HEIGHTMAP: // Load heightmap from scenario editor
 
@@ -1370,13 +1370,13 @@ void StateGameLoop()
 
		CallWindowTickEvent();
 
		NewsLoop();
 
	} else {
 
		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);
 
		}
 

	
 
		CheckCaches();
 

	
 
		/* All these actions has to be done from OWNER_NONE
 
@@ -1422,13 +1422,13 @@ static void DoAutosave()
 
		GenerateDefaultSaveName(buf, lastof(buf));
 
		strecat(buf, ".sav", lastof(buf));
 
	} else {
 
		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;
 
	}
 

	
 
	DEBUG(sl, 2, "Autosaving to '%s'", buf);
 
	if (SaveOrLoad(buf, SL_SAVE, AUTOSAVE_DIR) != SL_OK) {
src/os/unix/unix.cpp
Show inline comments
 
@@ -12,12 +12,13 @@
 
#include "../../stdafx.h"
 
#include "../../textbuf_gui.h"
 
#include "../../openttd.h"
 
#include "../../crashlog.h"
 
#include "../../core/random_func.hpp"
 
#include "../../debug.h"
 
#include "../../string_func.h"
 

	
 

	
 
#include <dirent.h>
 
#include <unistd.h>
 
#include <sys/stat.h>
 
#include <time.h>
 
@@ -104,19 +105,19 @@ bool FiosIsValidFile(const char *path, c
 
{
 
	char filename[MAX_PATH];
 
	int res;
 
#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;
 

	
 
	return stat(filename, sb) == 0;
 
}
src/saveload/saveload.cpp
Show inline comments
 
@@ -2611,13 +2611,13 @@ static SaveOrLoadResult DoLoad(LoadFilte
 
		fmt++;
 
	}
 

	
 
	/* 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);
 
	}
 

	
 
	_sl.lf = fmt->init_load(_sl.lf);
 
	_sl.reader = new ReadBuffer(_sl.lf);
 
	_next_offs = 0;
src/screenshot.cpp
Show inline comments
 
@@ -715,26 +715,26 @@ static const char *MakeScreenshotName(co
 
			GenerateDefaultSaveName(_screenshot_name, lastof(_screenshot_name));
 
		}
 
	}
 

	
 
	/* 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;
 
		}
 
		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;
 
}
 

	
 
/** Make a screenshot of the current screen. */
src/script/api/script_admin.cpp
Show inline comments
 
@@ -27,13 +27,13 @@
 
	switch (sq_gettype(vm, index)) {
 
		case OT_INTEGER: {
 
			SQInteger res;
 
			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;
 
		}
 

	
 
		case OT_STRING: {
 
			const SQChar *res;
src/script/api/script_controller.cpp
Show inline comments
 
@@ -50,13 +50,13 @@
 
{
 
	if (_network_dedicated || !_settings_client.gui.ai_developer_tools) return;
 

	
 
	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
 
	 * needs manual action to continue. */
 
	ShowAIDebugWindow(ScriptObject::GetRootCompany());
 

	
 
@@ -112,19 +112,19 @@ ScriptController::~ScriptController()
 
	ScriptController *controller = ScriptObject::GetActiveInstance()->GetController();
 
	Squirrel *engine = ScriptObject::GetActiveInstance()->engine;
 
	HSQUIRRELVM vm = engine->GetVM();
 

	
 
	/* 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));
 
	}
 

	
 
	/* Get the current table/class we belong to */
 
	HSQOBJECT parent;
 
	sq_getstackobj(vm, 1, &parent);
 
@@ -135,22 +135,22 @@ ScriptController::~ScriptController()
 
	if (iter != controller->loaded_library.end()) {
 
		strecpy(fake_class, (*iter).second, lastof(fake_class));
 
	} else {
 
		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);
 
		sq_pushstring(vm, OTTD2SQ(fake_class), -1);
 
		sq_newclass(vm, SQFalse);
 
		/* 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 */
 
		sq_newslot(vm, -3, SQFalse);
 
		sq_pop(vm, 1);
 

	
 
@@ -163,13 +163,13 @@ ScriptController::~ScriptController()
 
	if (SQ_FAILED(sq_get(vm, -2))) {
 
		throw sq_throwerror(vm, _SC("internal error assigning library class"));
 
	}
 
	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;
 
	sq_getstackobj(vm, -1, &obj);
 
	sq_pop(vm, 3);
 

	
src/script/script_config.cpp
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#include "../stdafx.h"
 
#include "../settings_type.h"
 
#include "../core/random_func.hpp"
 
#include "script_info.hpp"
 
#include "../textfile_gui.h"
 
#include "../string_func.h"
 

	
 
#include "../safeguards.h"
 

	
 
void ScriptConfig::Change(const char *name, int version, bool force_exact_match, bool is_random)
 
{
 
	free(this->name);
 
@@ -185,13 +186,13 @@ void ScriptConfig::StringToSettings(cons
 

	
 
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;
 
		/* If it doesn't fit, skip the next settings */
 
		if (size <= needed_size) break;
 
		size -= needed_size;
src/script/script_info.cpp
Show inline comments
 
@@ -47,13 +47,13 @@ ScriptInfo::~ScriptInfo()
 
}
 

	
 
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;
 
	}
 
	return true;
 
}
 

	
 
@@ -192,37 +192,37 @@ SQInteger ScriptInfo::AddSetting(HSQUIRR
 
			SQInteger res;
 
			if (SQ_FAILED(sq_getinteger(vm, -1, &res))) return SQ_ERROR;
 
			config.flags = (ScriptConfigFlags)res;
 
			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;
 
		}
 

	
 
		sq_pop(vm, 2);
 
	}
 
	sq_pop(vm, 1);
 

	
 
	/* Don't allow both random_deviation and SCRIPTCONFIG_RANDOM to
 
	 * 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;
 
	}
 
	/* Reset the bit for random_deviation as it's optional. */
 
	items &= ~0x200;
 

	
 
	/* Make sure all properties are defined */
 
	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;
 
	}
 

	
 
	this->config_list.push_back(config);
 
	return 0;
 
@@ -239,13 +239,13 @@ SQInteger ScriptInfo::AddLabels(HSQUIRRE
 
	for (ScriptConfigItemList::iterator it = this->config_list.begin(); it != this->config_list.end(); it++) {
 
		if (strcmp((*it).name, setting_name) == 0) config = &(*it);
 
	}
 

	
 
	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;
 
	}
 
	if (config->labels != NULL) return SQ_ERROR;
 

	
 
	config->labels = new LabelMapping;
src/script/script_scanner.cpp
Show inline comments
 
@@ -111,13 +111,13 @@ void ScriptScanner::RegisterScript(Scrip
 
{
 
	char script_original_name[1024];
 
	this->GetScriptName(info, script_original_name, sizeof(script_original_name));
 
	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) {
 
		DEBUG(script, 0, "The script '%s' returned a string from GetShortName() which is not four characaters. Unable to load the script.", info->GetName());
 
		delete info;
 
		return;
src/settings.cpp
Show inline comments
 
@@ -1534,13 +1534,13 @@ static void GameSaveConfig(IniFile *ini,
 
 */
 
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 },
 
		{ "version_number", version }
 
	};
 

	
 
@@ -2037,15 +2037,15 @@ void IConsoleGetSetting(const char *name
 
	ptr = GetVariableAddress((_game_mode == GM_MENU || force_newgame) ? &_settings_newgame : &_settings_game, &sd->save);
 

	
 
	if (sd->desc.cmd == SDT_STRING) {
 
		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)",
 
			name, value, (sd->desc.flags & SGF_0ISDISABLED) ? "(0) " : "", sd->desc.min, sd->desc.max);
 
	}
 
}
 
@@ -2063,17 +2063,17 @@ void IConsoleListSettings(const char *pr
 
		if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
 
		if (prefilter != NULL && strstr(sd->desc.name, prefilter) == NULL) continue;
 
		char value[80];
 
		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);
 
	}
 

	
 
	IConsolePrintF(CC_WARNING, "Use 'setting' command to change a value");
 
}
src/strings.cpp
Show inline comments
 
@@ -430,14 +430,14 @@ static char *FormatTinyOrISODate(char *b
 
	YearMonthDay ymd;
 
	ConvertDateToYMD(date, &ymd);
 

	
 
	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);
 
	return FormatString(buff, GetStringPtr(str), &tmp_params, last);
 
}
 

	
src/video/allegro_v.cpp
Show inline comments
 
@@ -221,13 +221,13 @@ static bool CreateMainSurface(uint w, ui
 

	
 
	BlitterFactory::GetCurrentBlitter()->PostResize();
 

	
 
	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();
 
	select_mouse_cursor(MOUSE_CURSOR_ARROW);
 
	show_mouse(_allegro_screen);
 

	
src/video/sdl_v.cpp
Show inline comments
 
@@ -415,13 +415,13 @@ bool VideoDriver_SDL::CreateMainSurface(
 
			break;
 

	
 
		default:
 
			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();
 

	
 
	return true;
 
}
0 comments (0 inline, 0 general)