Changeset - r23483:3733e6b8ff17
[Not reviewed]
master
! ! !
Patric Stout - 5 years ago 2019-03-20 16:01:13
truebrain@openttd.org
Remove: ENABLE_NETWORK switch

This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.

Additionaly, it has grown so hugely in our codebase, that it
clearly shows that the current solution was a poor one. 350+
instances of "#ifdef ENABLE_NETWORK" were in the code, of which
only ~30 in the networking code itself. The rest were all around
the code to do the right thing, from GUI to NewGRF.

A more proper solution would be to stub all the functions, and
make sure the rest of the code can simply assume network is
available. This was also partially done, and most variables were
correct if networking was disabled. Despite that, often the #ifdefs
were still used.

With the recent removal of DOS, there is also no platform anymore
which we support where networking isn't working out-of-the-box.

All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
96 files changed with 30 insertions and 601 deletions:
0 comments (0 inline, 0 general)
Doxyfile
Show inline comments
 
@@ -286,14 +286,13 @@ PERLMOD_MAKEVAR_PREFIX =
 
ENABLE_PREPROCESSING   = YES
 
MACRO_EXPANSION        = YES
 
EXPAND_ONLY_PREDEF     = YES
 
SEARCH_INCLUDES        = YES
 
INCLUDE_PATH           =
 
INCLUDE_FILE_PATTERNS  =
 
PREDEFINED             = ENABLE_NETWORK \
 
                         WITH_ZLIB \
 
PREDEFINED             = WITH_ZLIB \
 
                         WITH_LZO \
 
                         WITH_LIBLZMA \
 
                         WITH_SDL \
 
                         WITH_PNG \
 
                         WITH_FONTCONFIG \
 
                         WITH_FREETYPE \
config.lib
Show inline comments
 
@@ -49,13 +49,12 @@ set_default() {
 
	binary_name="openttd"
 
	enable_debug="0"
 
	enable_desync_debug="0"
 
	enable_profiling="0"
 
	enable_lto="0"
 
	enable_dedicated="0"
 
	enable_network="1"
 
	enable_static="1"
 
	enable_translator="0"
 
	enable_unicode="1"
 
	enable_console="1";
 
	enable_assert="1"
 
	enable_strip="0"
 
@@ -127,13 +126,12 @@ set_default() {
 
		binary_name
 
		enable_debug
 
		enable_desync_debug
 
		enable_profiling
 
		enable_lto
 
		enable_dedicated
 
		enable_network
 
		enable_static
 
		enable_translator
 
		enable_unicode
 
		enable_console
 
		enable_assert
 
		enable_strip
 
@@ -286,15 +284,12 @@ detect_params() {
 
			--enable-lto)                 enable_lto="1";;
 
			--enable-lto=*)               enable_lto="$optarg";;
 
			--enable-ipo)                 enable_lto="1";;
 
			--enable-ipo=*)               enable_lto="$optarg";;
 
			--enable-dedicated)           enable_dedicated="1";;
 
			--enable-dedicated=*)         enable_dedicated="$optarg";;
 
			--enable-network)             enable_network="2";;
 
			--enable-network=*)           enable_network="$optarg";;
 
			--disable-network)            enable_network="0";;
 
			--disable-static)             enable_static="0";;
 
			--enable-static)              enable_static="2";;
 
			--enable-static=*)            enable_static="$optarg";;
 
			--disable-translator)         enable_translator="0";;
 
			--enable-translator)          enable_translator="2";;
 
			--enable-translator=*)        enable_translator="$optarg";;
 
@@ -746,17 +741,12 @@ check_params() {
 
	detect_sdl
 
	detect_cocoa
 

	
 
	if [ "$enable_dedicated" != "0" ]; then
 
		log 1 "checking GDI video driver... dedicated server, skipping"
 
		log 1 "checking dedicated... found"
 

	
 
		if [ "$enable_network" = "0" ]; then
 
			log 1 "configure: error: building a dedicated server without network support is pointless"
 
			exit 1
 
		fi
 
	else
 
		if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
 
			log 1 "checking GDI video driver... found"
 
		else
 
			log 1 "checking GDI video driver... not Windows, skipping"
 
		fi
 
@@ -781,18 +771,12 @@ check_params() {
 
	elif [ "$enable_console" = "0" ]; then
 
		log 1 "checking console application... disabled"
 
	else
 
		log 1 "checking console application... enabled"
 
	fi
 

	
 
    if [ "$enable_network" != "0" ]; then
 
		log 1 "checking network... found"
 
	else
 
		log 1 "checking network... disabled"
 
	fi
 

	
 
	log 1 "checking squirrel... found"
 
	SCRIPT_SRC_DIR="$ROOT_DIR/src/3rdparty/squirrel/include"
 

	
 
	if [ "$enable_translator" != "0" ]; then
 
		log 1 "checking translator... debug"
 
		# -t shows TODO items, normally they are muted
 
@@ -1830,22 +1814,18 @@ make_cflags_and_ldflags() {
 
	fi
 

	
 
	if [ "$enable_unicode" != "0" ]; then
 
		CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"
 
	fi
 

	
 
	if [ "$enable_network" != "0" ]; then
 
		CFLAGS="$CFLAGS -DENABLE_NETWORK"
 

	
 
		if [ "$os" = "HAIKU" ]; then
 
			LDFLAGS="$LDFLAGS -lnetwork"
 
		fi
 

	
 
		if [ "$os" = "SUNOS" ]; then
 
			LDFLAGS="$LDFLAGS -lnsl -lsocket"
 
		fi
 
	if [ "$os" = "HAIKU" ]; then
 
		LDFLAGS="$LDFLAGS -lnetwork"
 
	fi
 

	
 
	if [ "$os" = "SUNOS" ]; then
 
		LDFLAGS="$LDFLAGS -lnsl -lsocket"
 
	fi
 

	
 
	if [ "$enable_static" != "0" ]; then
 
		# OSX can't handle -static in LDFLAGS
 
		if [ "$os" != "OSX" ]; then
 
			LDFLAGS="$LDFLAGS -static"
 
@@ -3496,13 +3476,12 @@ showhelp() {
 
	echo "  --disable-cocoa-quickdraw      disable the quickdraw window mode driver for Cocoa (OSX ONLY)"
 
	echo "  --disable-unicode              disable unicode support to build win9x"
 
	echo "                                 version (Win32 ONLY)"
 
	echo "  --enable-console               compile as a console application instead of as a GUI application."
 
	echo "                                 If this setting is active, debug output will appear in the same"
 
	echo "                                 console instead of opening a new window. (Win32 ONLY)"
 
	echo "  --disable-network              disable network support"
 
	echo "  --disable-assert               disable asserts (continue on errors)"
 
	echo "  --enable-strip                 enable any possible stripping"
 
	echo "  --without-osx-sysroot          disable the automatic adding of sysroot "
 
	echo "                                 (OSX ONLY)"
 
	echo "  --without-application-bundle   disable generation of application bundle"
 
	echo "                                 (OSX ONLY)"
src/ai/ai.hpp
Show inline comments
 
@@ -161,17 +161,15 @@ public:
 

	
 
	/** Gets the ScriptScanner instance that is used to find AIs */
 
	static AIScannerInfo *GetScannerInfo();
 
	/** Gets the ScriptScanner instance that is used to find AI Libraries */
 
	static AIScannerLibrary *GetScannerLibrary();
 

	
 
#if defined(ENABLE_NETWORK)
 
	/** Wrapper function for AIScanner::HasAI */
 
	static bool HasAI(const struct ContentInfo *ci, bool md5sum);
 
	static bool HasAILibrary(const ContentInfo *ci, bool md5sum);
 
#endif
 
private:
 
	static uint frame_counter;                      ///< Tick counter for the AI code
 
	static class AIScannerInfo *scanner_info;       ///< ScriptScanner instance that is used to find AIs
 
	static class AIScannerLibrary *scanner_library; ///< ScriptScanner instance that is used to find AI Libraries
 
};
 

	
src/ai/ai_core.cpp
Show inline comments
 
@@ -359,14 +359,12 @@
 

	
 
	InvalidateWindowData(WC_AI_LIST, 0, 1);
 
	SetWindowClassesDirty(WC_AI_DEBUG);
 
	InvalidateWindowClassesData(WC_AI_SETTINGS);
 
}
 

	
 
#if defined(ENABLE_NETWORK)
 

	
 
/**
 
 * Check whether we have an AI (library) with the exact characteristics as ci.
 
 * @param ci the characteristics to search on (shortname and md5sum)
 
 * @param md5sum whether to check the MD5 checksum
 
 * @return true iff we have an AI (library) matching.
 
 */
 
@@ -377,14 +375,12 @@
 

	
 
/* static */ bool AI::HasAILibrary(const ContentInfo *ci, bool md5sum)
 
{
 
	return AI::scanner_library->HasScript(ci, md5sum);
 
}
 

	
 
#endif /* defined(ENABLE_NETWORK) */
 

	
 
/* static */ AIScannerInfo *AI::GetScannerInfo()
 
{
 
	return AI::scanner_info;
 
}
 

	
 
/* static */ AIScannerLibrary *AI::GetScannerLibrary()
src/ai/ai_gui.cpp
Show inline comments
 
@@ -925,15 +925,13 @@ struct AIConfigWindow : public Window {
 
				break;
 

	
 
			case WID_AIC_CONTENT_DOWNLOAD:
 
				if (!_network_available) {
 
					ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
 
				} else {
 
#if defined(ENABLE_NETWORK)
 
					ShowNetworkContentListWindow(NULL, CONTENT_TYPE_AI, CONTENT_TYPE_GAME);
 
#endif
 
				}
 
				break;
 
		}
 
	}
 

	
 
	/**
src/base_media_func.h
Show inline comments
 
@@ -274,13 +274,12 @@ template <class Tbase_set>
 
	}
 
	p += seprintf(p, last, "\n");
 

	
 
	return p;
 
}
 

	
 
#if defined(ENABLE_NETWORK)
 
#include "network/network_content.h"
 

	
 
template <class Tbase_set> const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s)
 
{
 
	for (; s != NULL; s = s->next) {
 
		if (s->GetNumMissing() != 0) continue;
 
@@ -304,28 +303,12 @@ template <class Tbase_set>
 
/* static */ bool BaseMedia<Tbase_set>::HasSet(const ContentInfo *ci, bool md5sum)
 
{
 
	return (TryGetBaseSetFile(ci, md5sum, BaseMedia<Tbase_set>::available_sets) != NULL) ||
 
			(TryGetBaseSetFile(ci, md5sum, BaseMedia<Tbase_set>::duplicate_sets) != NULL);
 
}
 

	
 
#else
 

	
 
template <class Tbase_set>
 
const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s)
 
{
 
	return NULL;
 
}
 

	
 
template <class Tbase_set>
 
/* static */ bool BaseMedia<Tbase_set>::HasSet(const ContentInfo *ci, bool md5sum)
 
{
 
	return false;
 
}
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
/**
 
 * Count the number of available graphics sets.
 
 * @return the number of sets
 
 */
 
template <class Tbase_set>
 
/* static */ int BaseMedia<Tbase_set>::GetNumSets()
src/bootstrap_gui.cpp
Show inline comments
 
@@ -10,13 +10,13 @@
 
/** @file bootstrap_gui.cpp Barely used user interface for bootstrapping OpenTTD, i.e. downloading the required content. */
 

	
 
#include "stdafx.h"
 
#include "base_media_base.h"
 
#include "blitter/factory.hpp"
 

	
 
#if defined(ENABLE_NETWORK) && defined(WITH_FREETYPE)
 
#if defined(WITH_FREETYPE)
 

	
 
#include "core/geometry_func.hpp"
 
#include "fontcache.h"
 
#include "gfx_func.h"
 
#include "network/network.h"
 
#include "network/network_content_gui.h"
 
@@ -201,13 +201,13 @@ public:
 
		_network_content_client.Select(ci->id);
 
		new BootstrapContentDownloadStatusWindow();
 
		delete this;
 
	}
 
};
 

	
 
#endif /* defined(ENABLE_NETWORK) && defined(WITH_FREETYPE) */
 
#endif /* defined(WITH_FREETYPE) */
 

	
 
/**
 
 * Handle all procedures for bootstrapping OpenTTD without a base graphics set.
 
 * This requires all kinds of trickery that is needed to avoid the use of
 
 * sprites from the base graphics set which are pretty interwoven.
 
 * @return True if a base set exists, otherwise false.
 
@@ -217,13 +217,13 @@ bool HandleBootstrap()
 
	if (BaseGraphics::GetUsedSet() != NULL) return true;
 

	
 
	/* No user interface, bail out with an error. */
 
	if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) goto failure;
 

	
 
	/* If there is no network or no freetype, then there is nothing we can do. Go straight to failure. */
 
#if defined(ENABLE_NETWORK) && defined(WITH_FREETYPE) && (defined(WITH_FONTCONFIG) || defined(_WIN32) || defined(__APPLE__))
 
#if defined(WITH_FREETYPE) && (defined(WITH_FONTCONFIG) || defined(_WIN32) || defined(__APPLE__))
 
	if (!_network_available) goto failure;
 

	
 
	/* First tell the game we're bootstrapping. */
 
	_game_mode = GM_BOOTSTRAP;
 

	
 
	/* Initialise the freetype font code. */
src/command.cpp
Show inline comments
 
@@ -570,16 +570,14 @@ bool DoCommandP(TileIndex tile, uint32 p
 

	
 
	if (_pause_mode != PM_UNPAUSED && !IsCommandAllowedWhilePaused(cmd)) {
 
		ShowErrorMessage(GB(cmd, 16, 16), STR_ERROR_NOT_ALLOWED_WHILE_PAUSED, WL_INFO, x, y);
 
		return false;
 
	}
 

	
 
#ifdef ENABLE_NETWORK
 
	/* Only set p2 when the command does not come from the network. */
 
	if (!(cmd & CMD_NETWORK_COMMAND) && GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = CLIENT_ID_SERVER;
 
#endif
 

	
 
	CommandCost res = DoCommandPInternal(tile, p1, p2, cmd, callback, text, my_cmd, estimate_only);
 
	if (res.Failed()) {
 
		/* Only show the error when it's for us. */
 
		StringID error_part1 = GB(cmd, 16, 16);
 
		if (estimate_only || (IsLocalCompany() && error_part1 != 0 && my_cmd)) {
 
@@ -643,16 +641,14 @@ CommandCost DoCommandPInternal(TileIndex
 

	
 
	/* Command flags are used internally */
 
	CommandFlags cmd_flags = GetCommandFlags(cmd);
 
	/* Flags get send to the DoCommand */
 
	DoCommandFlag flags = CommandFlagsToDCFlags(cmd_flags);
 

	
 
#ifdef ENABLE_NETWORK
 
	/* Make sure p2 is properly set to a ClientID. */
 
	assert(!(cmd_flags & CMD_CLIENT_ID) || p2 != 0);
 
#endif
 

	
 
	/* Do not even think about executing out-of-bounds tile-commands */
 
	if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (cmd_flags & CMD_ALL_TILES) == 0))) return_dcpi(CMD_ERROR);
 

	
 
	/* Always execute server and spectator commands as spectator */
 
	bool exec_as_spectator = (cmd_flags & (CMD_SPECTATOR | CMD_SERVER)) != 0;
 
@@ -693,13 +689,12 @@ CommandCost DoCommandPInternal(TileIndex
 
			DEBUG(desync, 1, "cmdf: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
 
		}
 
		cur_company.Restore();
 
		return_dcpi(res);
 
	}
 

	
 
#ifdef ENABLE_NETWORK
 
	/*
 
	 * If we are in network, and the command is not from the network
 
	 * send it to the command-queue and abort execution
 
	 */
 
	if (_networking && !_generating_world && !(cmd & CMD_NETWORK_COMMAND)) {
 
		NetworkSendCommand(tile, p1, p2, cmd & ~CMD_FLAGS_MASK, callback, text, _current_company);
 
@@ -708,13 +703,12 @@ CommandCost DoCommandPInternal(TileIndex
 
		/* Don't return anything special here; no error, no costs.
 
		 * This way it's not handled by DoCommand and only the
 
		 * actual execution of the command causes messages. Also
 
		 * reset the storages as we've not executed the command. */
 
		return_dcpi(CommandCost());
 
	}
 
#endif /* ENABLE_NETWORK */
 
	DEBUG(desync, 1, "cmd: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
 

	
 
	/* Actually try and execute the command. If no cost-type is given
 
	 * use the construction one */
 
	_cleared_object_areas.Clear();
 
	BasePersistentStorageArray::SwitchMode(PSM_ENTER_COMMAND);
src/command_func.h
Show inline comments
 
@@ -39,15 +39,13 @@ CommandCost DoCommand(const CommandConta
 

	
 
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = NULL, const char *text = NULL, bool my_cmd = true);
 
bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
 

	
 
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only);
 

	
 
#ifdef ENABLE_NETWORK
 
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company);
 
#endif /* ENABLE_NETWORK */
 

	
 
extern Money _additional_cash_required;
 

	
 
bool IsValidCommand(uint32 cmd);
 
CommandFlags GetCommandFlags(uint32 cmd);
 
const char *GetCommandName(uint32 cmd);
src/company_cmd.cpp
Show inline comments
 
@@ -101,16 +101,14 @@ void Company::PostDestructor(size_t inde
 
 */
 
void SetLocalCompany(CompanyID new_company)
 
{
 
	/* company could also be COMPANY_SPECTATOR or OWNER_NONE */
 
	assert(Company::IsValidID(new_company) || new_company == COMPANY_SPECTATOR || new_company == OWNER_NONE);
 

	
 
#ifdef ENABLE_NETWORK
 
	/* Delete the chat window, if you were team chatting. */
 
	InvalidateWindowData(WC_SEND_NETWORK_MSG, DESTTYPE_TEAM, _local_company);
 
#endif
 

	
 
	assert(IsLocalCompany());
 

	
 
	_current_company = _local_company = new_company;
 

	
 
	/* Delete any construction windows... */
 
@@ -594,15 +592,13 @@ void StartupCompanies()
 
	_next_competitor_start = 0;
 
}
 

	
 
/** Start a new competitor company if possible. */
 
static bool MaybeStartNewCompany()
 
{
 
#ifdef ENABLE_NETWORK
 
	if (_networking && Company::GetNumItems() >= _settings_client.network.max_companies) return false;
 
#endif /* ENABLE_NETWORK */
 

	
 
	Company *c;
 

	
 
	/* count number of competitors */
 
	uint n = 0;
 
	FOR_ALL_COMPANIES(c) {
 
@@ -789,27 +785,23 @@ void CompanyNewsInformation::FillData(co
 
/**
 
 * Called whenever company related information changes in order to notify admins.
 
 * @param company The company data changed of.
 
 */
 
void CompanyAdminUpdate(const Company *company)
 
{
 
#ifdef ENABLE_NETWORK
 
	if (_network_server) NetworkAdminCompanyUpdate(company);
 
#endif /* ENABLE_NETWORK */
 
}
 

	
 
/**
 
 * Called whenever a company is removed in order to notify admins.
 
 * @param company_id The company that was removed.
 
 * @param reason     The reason the company was removed.
 
 */
 
void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
 
{
 
#ifdef ENABLE_NETWORK
 
	if (_network_server) NetworkAdminCompanyRemove(company_id, (AdminCompanyRemoveReason)reason);
 
#endif /* ENABLE_NETWORK */
 
}
 

	
 
/**
 
 * Control the companies: add, delete, etc.
 
 * @param tile unused
 
 * @param flags operation to perform
 
@@ -829,13 +821,12 @@ CommandCost CmdCompanyCtrl(TileIndex til
 

	
 
	switch ((CompanyCtrlAction)GB(p1, 0, 16)) {
 
		case CCA_NEW: { // Create a new company
 
			/* This command is only executed in a multiplayer game */
 
			if (!_networking) return CMD_ERROR;
 

	
 
#ifdef ENABLE_NETWORK
 
			/* Has the network client a correct ClientIndex? */
 
			if (!(flags & DC_EXEC)) return CommandCost();
 

	
 
			ClientID client_id = (ClientID)p2;
 
			NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id);
 
#ifndef DEBUG_DUMP_COMMANDS
 
@@ -873,24 +864,21 @@ CommandCost CmdCompanyCtrl(TileIndex til
 
				SyncCompanySettings();
 

	
 
				MarkWholeScreenDirty();
 
			}
 

	
 
			NetworkServerNewCompany(c, ci);
 
#endif /* ENABLE_NETWORK */
 
			break;
 
		}
 

	
 
		case CCA_NEW_AI: { // Make a new AI company
 
			if (!(flags & DC_EXEC)) return CommandCost();
 

	
 
			if (company_id != INVALID_COMPANY && (company_id >= MAX_COMPANIES || Company::IsValidID(company_id))) return CMD_ERROR;
 
			Company *c = DoStartupNewCompany(true, company_id);
 
#ifdef ENABLE_NETWORK
 
			if (c != NULL) NetworkServerNewCompany(c, NULL);
 
#endif /* ENABLE_NETWORK */
 
			break;
 
		}
 

	
 
		case CCA_DELETE: { // Delete a company
 
			CompanyRemoveReason reason = (CompanyRemoveReason)GB(p2, 0, 2);
 
			if (reason >= CRR_END) return CMD_ERROR;
src/company_gui.cpp
Show inline comments
 
@@ -2384,17 +2384,15 @@ struct CompanyWindow : Window
 

	
 
					size->width = max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_SHARES_OWNED_BY).width);
 
				}
 
				break;
 
			}
 

	
 
#ifdef ENABLE_NETWORK
 
			case WID_C_HAS_PASSWORD:
 
				*size = maxdim(*size, GetSpriteSize(SPR_LOCK));
 
				break;
 
#endif /* ENABLE_NETWORK */
 
		}
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		const Company *c = Company::Get((CompanyID)this->window_number);
 
@@ -2495,19 +2493,17 @@ struct CompanyWindow : Window
 
						y += FONT_HEIGHT_NORMAL;
 
					}
 
				}
 
				break;
 
			}
 

	
 
#ifdef ENABLE_NETWORK
 
			case WID_C_HAS_PASSWORD:
 
				if (_networking && NetworkCompanyIsPassworded(c->index)) {
 
					DrawSprite(SPR_LOCK, PAL_NONE, r.left, r.top);
 
				}
 
				break;
 
#endif /* ENABLE_NETWORK */
 
		}
 
	}
 

	
 
	virtual void SetStringParameters(int widget) const
 
	{
 
		switch (widget) {
 
@@ -2591,13 +2587,12 @@ struct CompanyWindow : Window
 
				break;
 

	
 
			case WID_C_SELL_SHARE:
 
				DoCommandP(0, this->window_number, 0, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_ERROR_CAN_T_SELL_25_SHARE_IN));
 
				break;
 

	
 
#ifdef ENABLE_NETWORK
 
			case WID_C_COMPANY_PASSWORD:
 
				if (this->window_number == _local_company) ShowNetworkCompanyPasswordWindow(this);
 
				break;
 

	
 
			case WID_C_COMPANY_JOIN: {
 
				this->query_widget = WID_C_COMPANY_JOIN;
 
@@ -2611,13 +2606,12 @@ struct CompanyWindow : Window
 
				} else {
 
					/* just send the join command */
 
					NetworkClientRequestMove(company);
 
				}
 
				break;
 
			}
 
#endif /* ENABLE_NETWORK */
 
		}
 
	}
 

	
 
	virtual void OnHundredthTick()
 
	{
 
		/* redraw the window every now and then */
 
@@ -2649,17 +2643,15 @@ struct CompanyWindow : Window
 
				break;
 

	
 
			case WID_C_COMPANY_NAME:
 
				DoCommandP(0, 0, 0, CMD_RENAME_COMPANY | CMD_MSG(STR_ERROR_CAN_T_CHANGE_COMPANY_NAME), NULL, str);
 
				break;
 

	
 
#ifdef ENABLE_NETWORK
 
			case WID_C_COMPANY_JOIN:
 
				NetworkClientRequestMove((CompanyID)this->window_number, str);
 
				break;
 
#endif /* ENABLE_NETWORK */
 
		}
 
	}
 

	
 

	
 
	/**
 
	 * Some data on this window has become invalid.
src/console.cpp
Show inline comments
 
@@ -30,16 +30,14 @@ IConsoleAlias *_iconsole_aliases; ///< l
 

	
 
FILE *_iconsole_output_file;
 

	
 
void IConsoleInit()
 
{
 
	_iconsole_output_file = NULL;
 
#ifdef ENABLE_NETWORK /* Initialize network only variables */
 
	_redirect_console_to_client = INVALID_CLIENT_ID;
 
	_redirect_console_to_admin  = INVALID_ADMIN_ID;
 
#endif
 

	
 
	IConsoleGUIInit();
 

	
 
	IConsoleStdLibRegister();
 
}
 

	
 
@@ -87,35 +85,31 @@ void IConsoleFree()
 
 */
 
void IConsolePrint(TextColour colour_code, const char *string)
 
{
 
	assert(IsValidConsoleColour(colour_code));
 

	
 
	char *str;
 
#ifdef ENABLE_NETWORK
 
	if (_redirect_console_to_client != INVALID_CLIENT_ID) {
 
		/* Redirect the string to the client */
 
		NetworkServerSendRcon(_redirect_console_to_client, colour_code, string);
 
		return;
 
	}
 

	
 
	if (_redirect_console_to_admin != INVALID_ADMIN_ID) {
 
		NetworkServerSendAdminRcon(_redirect_console_to_admin, colour_code, string);
 
		return;
 
	}
 
#endif
 

	
 
	/* Create a copy of the string, strip if of colours and invalid
 
	 * characters and (when applicable) assign it to the console buffer */
 
	str = stredup(string);
 
	str_strip_colours(str);
 
	str_validate(str, str + strlen(str));
 

	
 
	if (_network_dedicated) {
 
#ifdef ENABLE_NETWORK
 
		NetworkAdminConsole("console", str);
 
#endif /* ENABLE_NETWORK */
 
		fprintf(stdout, "%s%s\n", GetLogPrefix(), str);
 
		fflush(stdout);
 
		IConsoleWriteToLogFile(str);
 
		free(str); // free duplicated string since it's not used anymore
 
		return;
 
	}
src/console_cmds.cpp
Show inline comments
 
@@ -83,14 +83,12 @@ static ConsoleFileList _console_file_lis
 

	
 

	
 
/****************
 
 * command hooks
 
 ****************/
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/**
 
 * Check network availability and inform in console about failure of detection.
 
 * @return Network availability.
 
 */
 
static inline bool NetworkAvailable(bool echo)
 
{
 
@@ -156,28 +154,20 @@ DEF_CONSOLE_HOOK(ConHookNoNetwork)
 
		if (echo) IConsoleError("This command is forbidden in multiplayer.");
 
		return CHR_DISALLOW;
 
	}
 
	return CHR_ALLOW;
 
}
 

	
 
#else
 
#	define ConHookNoNetwork NULL
 
#endif /* ENABLE_NETWORK */
 

	
 
DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool)
 
{
 
	if (_settings_client.gui.newgrf_developer_tools) {
 
		if (_game_mode == GM_MENU) {
 
			if (echo) IConsoleError("This command is only available in game and editor.");
 
			return CHR_DISALLOW;
 
		}
 
#ifdef ENABLE_NETWORK
 
		return ConHookNoNetwork(echo);
 
#else
 
		return CHR_ALLOW;
 
#endif
 
	}
 
	return CHR_HIDE;
 
}
 

	
 
/**
 
 * Show help for the console.
 
@@ -476,13 +466,12 @@ DEF_CONSOLE_CMD(ConClearBuffer)
 
}
 

	
 

	
 
/**********************************
 
 * Network Core Console Commands
 
 **********************************/
 
#ifdef ENABLE_NETWORK
 

	
 
static bool ConKickOrBan(const char *argv, bool ban)
 
{
 
	uint n;
 

	
 
	if (strchr(argv, '.') == NULL && strchr(argv, ':') == NULL) { // banning with ID
 
@@ -927,14 +916,12 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
 

	
 
	NetworkClientConnectGame(NetworkAddress(ip, rport), join_as);
 

	
 
	return true;
 
}
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
/*********************************
 
 *  script file console commands
 
 *********************************/
 

	
 
DEF_CONSOLE_CMD(ConExec)
 
{
 
@@ -1544,18 +1531,15 @@ DEF_CONSOLE_CMD(ConCompanies)
 
		SetDParam(0, c->index);
 
		GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
 

	
 
		const char *password_state = "";
 
		if (c->is_ai) {
 
			password_state = "AI";
 
		}
 
#ifdef ENABLE_NETWORK
 
		else if (_network_server) {
 
		} else if (_network_server) {
 
				password_state = StrEmpty(_network_company_states[c->index].password) ? "unprotected" : "protected";
 
		}
 
#endif
 

	
 
		char colour[512];
 
		GetString(colour, STR_COLOUR_DARK_BLUE + _company_colours[c->index], lastof(colour));
 
		IConsolePrintF(CC_INFO, "#:%d(%s) Company Name: '%s'  Year Founded: %d  Money: " OTTD_PRINTF64 "  Loan: " OTTD_PRINTF64 "  Value: " OTTD_PRINTF64 "  (T:%d, R:%d, P:%d, S:%d) %s",
 
			c->index + 1, colour, company_name,
 
			c->inaugurated_year, (int64)c->money, (int64)c->current_loan, (int64)CalculateCompanyValue(c),
 
@@ -1566,14 +1550,12 @@ DEF_CONSOLE_CMD(ConCompanies)
 
			password_state);
 
	}
 

	
 
	return true;
 
}
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
DEF_CONSOLE_CMD(ConSay)
 
{
 
	if (argc == 0) {
 
		IConsoleHelp("Chat to your fellow players in a multiplayer game. Usage: 'say \"<msg>\"'");
 
		return true;
 
	}
 
@@ -1809,13 +1791,12 @@ DEF_CONSOLE_CMD(ConContent)
 
		return true;
 
	}
 

	
 
	return false;
 
}
 
#endif /* defined(WITH_ZLIB) */
 
#endif /* ENABLE_NETWORK */
 

	
 
DEF_CONSOLE_CMD(ConSetting)
 
{
 
	if (argc == 0) {
 
		IConsoleHelp("Change setting for all clients. Usage: 'setting <name> [<value>]'");
 
		IConsoleHelp("Omitting <value> will print out the current value of the setting.");
 
@@ -1989,13 +1970,13 @@ void IConsoleStdLibRegister()
 
	IConsoleCmdRegister("rescan_game",    ConRescanGame);
 

	
 
	IConsoleCmdRegister("companies",       ConCompanies);
 
	IConsoleAliasRegister("players",       "companies");
 

	
 
	/* networking functions */
 
#ifdef ENABLE_NETWORK
 

	
 
/* Content downloading is only available with ZLIB */
 
#if defined(WITH_ZLIB)
 
	IConsoleCmdRegister("content",         ConContent);
 
#endif /* defined(WITH_ZLIB) */
 

	
 
	/*** Networking commands ***/
 
@@ -2047,13 +2028,12 @@ void IConsoleStdLibRegister()
 
	IConsoleAliasRegister("autoclean_companies",   "setting autoclean_companies %+");
 
	IConsoleAliasRegister("autoclean_protected",   "setting autoclean_protected %+");
 
	IConsoleAliasRegister("autoclean_unprotected", "setting autoclean_unprotected %+");
 
	IConsoleAliasRegister("restart_game_year",     "setting restart_game_year %+");
 
	IConsoleAliasRegister("min_players",           "setting min_active_clients %+");
 
	IConsoleAliasRegister("reload_cfg",            "setting reload_cfg %+");
 
#endif /* ENABLE_NETWORK */
 

	
 
	/* debugging stuff */
 
#ifdef _DEBUG
 
	IConsoleDebugLibRegister();
 
#endif
 
	IConsoleCmdRegister("fps",     ConFramerate);
src/date.cpp
Show inline comments
 
@@ -192,15 +192,13 @@ static const Month _autosave_months[] = 
 
static void OnNewYear()
 
{
 
	CompaniesYearlyLoop();
 
	VehiclesYearlyLoop();
 
	TownsYearlyLoop();
 
	InvalidateWindowClassesData(WC_BUILD_STATION);
 
#ifdef ENABLE_NETWORK
 
	if (_network_server) NetworkServerYearlyLoop();
 
#endif /* ENABLE_NETWORK */
 

	
 
	if (_cur_year == _settings_client.gui.semaphore_build_before) ResetSignalVariant();
 

	
 
	/* check if we reached end of the game */
 
	if (_cur_year == ORIGINAL_END_YEAR) {
 
		ShowEndGameChart();
 
@@ -214,17 +212,15 @@ static void OnNewYear()
 
		_date -= days_this_year;
 
		FOR_ALL_VEHICLES(v) v->date_of_last_service -= days_this_year;
 

	
 
		LinkGraph *lg;
 
		FOR_ALL_LINK_GRAPHS(lg) lg->ShiftDates(-days_this_year);
 

	
 
#ifdef ENABLE_NETWORK
 
		/* Because the _date wraps here, and text-messages expire by game-days, we have to clean out
 
		 *  all of them if the date is set back, else those messages will hang for ever */
 
		NetworkInitChatMessage();
 
#endif /* ENABLE_NETWORK */
 
	}
 

	
 
	if (_settings_client.gui.auto_euro) CheckSwitchToEuro();
 
}
 

	
 
/**
 
@@ -241,25 +237,21 @@ static void OnNewMonth()
 
	CompaniesMonthlyLoop();
 
	EnginesMonthlyLoop();
 
	TownsMonthlyLoop();
 
	IndustryMonthlyLoop();
 
	SubsidyMonthlyLoop();
 
	StationMonthlyLoop();
 
#ifdef ENABLE_NETWORK
 
	if (_network_server) NetworkServerMonthlyLoop();
 
#endif /* ENABLE_NETWORK */
 
}
 

	
 
/**
 
 * Runs various procedures that have to be done daily
 
 */
 
static void OnNewDay()
 
{
 
#ifdef ENABLE_NETWORK
 
	if (_network_server) NetworkServerDailyLoop();
 
#endif /* ENABLE_NETWORK */
 

	
 
	DisasterDailyLoop();
 
	IndustryDailyLoop();
 

	
 
	SetWindowWidgetDirty(WC_STATUS_BAR, 0, 0);
 
	EnginesDailyLoop();
src/debug.cpp
Show inline comments
 
@@ -20,16 +20,14 @@
 
#if defined(_WIN32)
 
#include "os/windows/win32.h"
 
#endif
 

	
 
#include <time.h>
 

	
 
#if defined(ENABLE_NETWORK)
 
#include "network/network_admin.h"
 
SOCKET _debug_socket = INVALID_SOCKET;
 
#endif /* ENABLE_NETWORK */
 

	
 
#include "safeguards.h"
 

	
 
int _debug_driver_level;
 
int _debug_grf_level;
 
int _debug_map_level;
 
@@ -108,23 +106,21 @@ char *DumpDebugFacilityNames(char *buf, 
 
 * Internal function for outputting the debug line.
 
 * @param dbg Debug category.
 
 * @param buf Text line to output.
 
 */
 
static void debug_print(const char *dbg, const char *buf)
 
{
 
#if defined(ENABLE_NETWORK)
 
	if (_debug_socket != INVALID_SOCKET) {
 
		char buf2[1024 + 32];
 

	
 
		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 */
 
	if (strcmp(dbg, "desync") == 0) {
 
		static FILE *f = FioFOpenFile("commands-out.log", "wb", AUTOSAVE_DIR);
 
		if (f == NULL) return;
 

	
 
		fprintf(f, "%s%s\n", GetLogPrefix(), buf);
 
		fflush(f);
 
@@ -143,15 +139,13 @@ static void debug_print(const char *dbg,
 
		TCHAR system_buf[512];
 
		convert_to_fs(buffer, system_buf, lengthof(system_buf), true);
 
		_fputts(system_buf, stderr);
 
#else
 
		fputs(buffer, stderr);
 
#endif
 
#ifdef ENABLE_NETWORK
 
		NetworkAdminConsole(dbg, buf);
 
#endif /* ENABLE_NETWORK */
 
		IConsoleDebug(dbg, buf);
 
	}
 
}
 

	
 
/**
 
 * Output a debug line.
src/dedicated.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/** @file dedicated.cpp Forking support for dedicated servers. */
 

	
 
#include "stdafx.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
char *_log_file = NULL; ///< File to reroute output of a forked OpenTTD to
 
FILE *_log_fd   = NULL; ///< File to reroute output of a forked OpenTTD to
 

	
 
#if defined(UNIX)
 

	
 
#include <unistd.h>
 
@@ -64,13 +62,6 @@ void DedicatedFork()
 
			printf("Loading dedicated server...\n");
 
			printf("  - Forked to background with pid " PRINTF_PID_T "\n", pid);
 
			exit(0);
 
	}
 
}
 
#endif
 

	
 
#else
 

	
 
/** Empty helper function call for NOT(UNIX) systems */
 
void DedicatedFork() {}
 

	
 
#endif /* ENABLE_NETWORK */
src/economy.cpp
Show inline comments
 
@@ -289,16 +289,14 @@ int UpdateCompanyRatingAndValue(Company 
 
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
 
{
 
	/* We need to set _current_company to old_owner before we try to move
 
	 * the client. This is needed as it needs to know whether "you" really
 
	 * are the current local company. */
 
	Backup<CompanyByte> cur_company(_current_company, old_owner, FILE_LINE);
 
#ifdef ENABLE_NETWORK
 
	/* In all cases, make spectators of clients connected to that company */
 
	if (_networking) NetworkClientsToSpectators(old_owner);
 
#endif /* ENABLE_NETWORK */
 
	if (old_owner == _local_company) {
 
		/* Single player cheated to AI company.
 
		 * There are no spectators in single player, so we must pick some other company. */
 
		assert(!_networking);
 
		Backup<CompanyByte> cur_company2(_current_company, FILE_LINE);
 
		Company *c;
src/fileio.cpp
Show inline comments
 
@@ -1237,33 +1237,24 @@ void DeterminePaths(const char *exe)
 
		FioCreateDirectory(dir);
 
		free(dir);
 
	}
 

	
 
	/* If we have network we make a directory for the autodownloading of content */
 
	_searchpaths[SP_AUTODOWNLOAD_DIR] = str_fmt("%s%s", _personal_dir, "content_download" PATHSEP);
 
#ifdef ENABLE_NETWORK
 
	FioCreateDirectory(_searchpaths[SP_AUTODOWNLOAD_DIR]);
 

	
 
	/* Create the directory for each of the types of content */
 
	const Subdirectory dirs[] = { SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR };
 
	for (uint i = 0; i < lengthof(dirs); i++) {
 
		char *tmp = str_fmt("%s%s", _searchpaths[SP_AUTODOWNLOAD_DIR], _subdirs[dirs[i]]);
 
		FioCreateDirectory(tmp);
 
		free(tmp);
 
	}
 

	
 
	extern char *_log_file;
 
	_log_file = str_fmt("%sopenttd.log",  _personal_dir);
 
#else /* ENABLE_NETWORK */
 
	/* If we don't have networking, we don't need to make the directory. But
 
	 * if it exists we keep it, otherwise remove it from the search paths. */
 
	if (!FileExists(_searchpaths[SP_AUTODOWNLOAD_DIR]))  {
 
		free(_searchpaths[SP_AUTODOWNLOAD_DIR]);
 
		_searchpaths[SP_AUTODOWNLOAD_DIR] = NULL;
 
	}
 
#endif /* ENABLE_NETWORK */
 
}
 

	
 
/**
 
 * Sanitizes a filename, i.e. removes all illegal characters from it.
 
 * @param filename the "\0" terminated filename
 
 */
src/fios.cpp
Show inline comments
 
@@ -10,17 +10,19 @@
 
/**
 
 * @file fios.cpp
 
 * This file contains functions for building file lists for the save/load dialogs.
 
 */
 

	
 
#include "stdafx.h"
 
#include "fios.h"
 
#include "3rdparty/md5/md5.h"
 
#include "fileio_func.h"
 
#include "tar_type.h"
 
#include "fios.h"
 
#include "network/network_content.h"
 
#include "screenshot.h"
 
#include "string_func.h"
 
#include "tar_type.h"
 
#include <sys/stat.h>
 

	
 
#ifndef _WIN32
 
# include <unistd.h>
 
#endif /* _WIN32 */
 

	
 
@@ -629,16 +631,12 @@ const char *FiosGetScreenshotDir()
 
		FioGetDirectory(fios_screenshot_path, fios_screenshot_path + MAX_PATH - 1, SCREENSHOT_DIR);
 
	}
 

	
 
	return fios_screenshot_path;
 
}
 

	
 
#if defined(ENABLE_NETWORK)
 
#include "network/network_content.h"
 
#include "3rdparty/md5/md5.h"
 

	
 
/** Basic data to distinguish a scenario. Used in the server list window */
 
struct ScenarioIdentifier {
 
	uint32 scenid;           ///< ID for the scenario (generated by content).
 
	uint8 md5sum[16];        ///< MD5 checksum of file.
 
	char filename[MAX_PATH]; ///< filename of the file.
 

	
 
@@ -751,8 +749,6 @@ bool HasScenario(const ContentInfo *ci, 
 
 * Force a (re)scan of the scenarios.
 
 */
 
void ScanScenarios()
 
{
 
	_scanner.Scan(true);
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/fios_gui.cpp
Show inline comments
 
@@ -631,15 +631,13 @@ public:
 
				break;
 

	
 
			case WID_SL_MISSING_NEWGRFS:
 
				if (!_network_available) {
 
					ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
 
				} else if (_load_check_data.HasNewGrfs()) {
 
#if defined(ENABLE_NETWORK)
 
					ShowMissingContentWindow(_load_check_data.grfconfig);
 
#endif
 
				}
 
				break;
 

	
 
			case WID_SL_DRIVES_DIRECTORIES_LIST: { // Click the listbox
 
				int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WD_FRAMERECT_TOP);
 
				if (y == INT_MAX) return;
 
@@ -695,20 +693,18 @@ public:
 
			}
 

	
 
			case WID_SL_CONTENT_DOWNLOAD:
 
				if (!_network_available) {
 
					ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
 
				} else {
 
#if defined(ENABLE_NETWORK)
 
					assert(this->fop == SLO_LOAD);
 
					switch (this->abstract_filetype) {
 
						default: NOT_REACHED();
 
						case FT_SCENARIO:  ShowNetworkContentListWindow(NULL, CONTENT_TYPE_SCENARIO);  break;
 
						case FT_HEIGHTMAP: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_HEIGHTMAP); break;
 
					}
 
#endif
 
				}
 
				break;
 

	
 
			case WID_SL_DELETE_SELECTION: // Delete
 
				break;
 

	
src/game/game.hpp
Show inline comments
 
@@ -109,17 +109,15 @@ public:
 

	
 
	/**
 
	 * Get the current active instance.
 
	 */
 
	static class GameInstance *GetInstance() { return Game::instance; }
 

	
 
#if defined(ENABLE_NETWORK)
 
	/** Wrapper function for GameScanner::HasGame */
 
	static bool HasGame(const struct ContentInfo *ci, bool md5sum);
 
	static bool HasGameLibrary(const ContentInfo *ci, bool md5sum);
 
#endif
 
	/** Gets the ScriptScanner instance that is used to find Game scripts */
 
	static GameScannerInfo *GetScannerInfo();
 
	/** Gets the ScriptScanner instance that is used to find Game Libraries */
 
	static GameScannerLibrary *GetScannerLibrary();
 

	
 
private:
src/game/game_core.cpp
Show inline comments
 
@@ -254,14 +254,12 @@
 

	
 
/* static */ GameLibrary *Game::FindLibrary(const char *library, int version)
 
{
 
	return Game::scanner_library->FindLibrary(library, version);
 
}
 

	
 
#if defined(ENABLE_NETWORK)
 

	
 
/**
 
 * Check whether we have an Game (library) with the exact characteristics as ci.
 
 * @param ci the characteristics to search on (shortname and md5sum)
 
 * @param md5sum whether to check the MD5 checksum
 
 * @return true iff we have an Game (library) matching.
 
 */
 
@@ -272,14 +270,12 @@
 

	
 
/* static */ bool Game::HasGameLibrary(const ContentInfo *ci, bool md5sum)
 
{
 
	return Game::scanner_library->HasScript(ci, md5sum);
 
}
 

	
 
#endif /* defined(ENABLE_NETWORK) */
 

	
 
/* static */ GameScannerInfo *Game::GetScannerInfo()
 
{
 
	return Game::scanner_info;
 
}
 
/* static */ GameScannerLibrary *Game::GetScannerLibrary()
 
{
src/gfx.cpp
Show inline comments
 
@@ -83,15 +83,13 @@ void GfxScroll(int left, int top, int wi
 
	Blitter *blitter = BlitterFactory::GetCurrentBlitter();
 

	
 
	if (xo == 0 && yo == 0) return;
 

	
 
	if (_cursor.visible) UndrawMouseCursor();
 

	
 
#ifdef ENABLE_NETWORK
 
	if (_networking) NetworkUndrawChatMessage();
 
#endif /* ENABLE_NETWORK */
 

	
 
	blitter->ScrollBuffer(_screen.dst_ptr, left, top, width, height, xo, yo);
 
	/* This part of the screen is now dirty. */
 
	VideoDriver::GetInstance()->MakeDirty(left, top, width, height);
 
}
 

	
 
@@ -1285,15 +1283,13 @@ void RedrawScreenRect(int left, int top,
 
				bottom > _cursor.draw_pos.y &&
 
				top < _cursor.draw_pos.y + _cursor.draw_size.y) {
 
			UndrawMouseCursor();
 
		}
 
	}
 

	
 
#ifdef ENABLE_NETWORK
 
	if (_networking) NetworkUndrawChatMessage();
 
#endif /* ENABLE_NETWORK */
 

	
 
	DrawOverlappedWindowForAll(left, top, right, bottom);
 

	
 
	VideoDriver::GetInstance()->MakeDirty(left, top, right - left, bottom - top);
 
}
 

	
src/goal.cpp
Show inline comments
 
@@ -244,38 +244,30 @@ CommandCost CmdSetGoalCompleted(TileInde
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdGoalQuestion(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	uint16 uniqueid = (GoalType)GB(p1, 0, 16);
 
	CompanyID company = (CompanyID)GB(p1, 16, 8);
 
#ifdef ENABLE_NETWORK
 
	ClientIndex client = (ClientIndex)GB(p1, 16, 8);
 
#endif
 
	byte type = GB(p1, 24, 2);
 
	bool is_client = HasBit(p1, 31);
 

	
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	if (StrEmpty(text)) return CMD_ERROR;
 
	if (is_client) {
 
#ifdef ENABLE_NETWORK
 
		if (!NetworkClientInfo::IsValidID(client)) return CMD_ERROR;
 
#else
 
		return CMD_ERROR;
 
#endif
 
	} else {
 
		if (company != INVALID_COMPANY && !Company::IsValidID(company)) return CMD_ERROR;
 
	}
 
	if (CountBits(p2) < 1 || CountBits(p2) > 3) return CMD_ERROR;
 
	if (p2 >= (1 << GOAL_QUESTION_BUTTON_COUNT)) return CMD_ERROR;
 
	if (type >= GOAL_QUESTION_TYPE_COUNT) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		if (is_client) {
 
#ifdef ENABLE_NETWORK
 
			if (NetworkClientInfo::Get(client)->client_id != _network_own_client_id) return CommandCost();
 
#endif
 
		} else {
 
			if (company == INVALID_COMPANY && !Company::IsValidID(_local_company)) return CommandCost();
 
			if (company != INVALID_COMPANY && company != _local_company) return CommandCost();
 
		}
 
		ShowGoalQuestion(uniqueid, type, p2, text);
 
	}
src/intro_gui.cpp
Show inline comments
 
@@ -110,17 +110,15 @@ struct SelectGameWindow : public Window 
 
			}
 
		}
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
#ifdef ENABLE_NETWORK
 
		/* Do not create a network server when you (just) have closed one of the game
 
		 * creation/load windows for the network server. */
 
		if (IsInsideMM(widget, WID_SGI_GENERATE_GAME, WID_SGI_EDIT_SCENARIO + 1)) _is_network_server = false;
 
#endif /* ENABLE_NETWORK */
 

	
 
		switch (widget) {
 
			case WID_SGI_GENERATE_GAME:
 
				if (_ctrl_pressed) {
 
					StartNewGameWithoutGUI(GENERATE_NEW_SEED);
 
				} else {
src/lang/english.txt
Show inline comments
 
@@ -2136,13 +2136,13 @@ STR_NETWORK_CHAT_TO_COMPANY             
 
STR_NETWORK_CHAT_CLIENT                                         :[Private] {RAW_STRING}: {WHITE}{RAW_STRING}
 
STR_NETWORK_CHAT_TO_CLIENT                                      :[Private] To {RAW_STRING}: {WHITE}{RAW_STRING}
 
STR_NETWORK_CHAT_ALL                                            :[All] {RAW_STRING}: {WHITE}{RAW_STRING}
 
STR_NETWORK_CHAT_OSKTITLE                                       :{BLACK}Enter text for network chat
 

	
 
# Network messages
 
STR_NETWORK_ERROR_NOTAVAILABLE                                  :{WHITE}No network devices found or compiled without ENABLE_NETWORK
 
STR_NETWORK_ERROR_NOTAVAILABLE                                  :{WHITE}No network devices found
 
STR_NETWORK_ERROR_NOSERVER                                      :{WHITE}Could not find any network games
 
STR_NETWORK_ERROR_NOCONNECTION                                  :{WHITE}The server didn't answer the request
 
STR_NETWORK_ERROR_NEWGRF_MISMATCH                               :{WHITE}Could not connect due to NewGRF mismatch
 
STR_NETWORK_ERROR_DESYNC                                        :{WHITE}Network-Game synchronisation failed
 
STR_NETWORK_ERROR_LOSTCONNECTION                                :{WHITE}Network-Game connection lost
 
STR_NETWORK_ERROR_SAVEGAMEERROR                                 :{WHITE}Could not load savegame
src/main_gui.cpp
Show inline comments
 
@@ -50,44 +50,40 @@
 

	
 
static int _rename_id = 1;
 
static int _rename_what = -1;
 

	
 
void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
#ifdef ENABLE_NETWORK
 
	if (result.Failed() || !_settings_game.economy.give_money) return;
 

	
 
	/* Inform the company of the action of one of its clients (controllers). */
 
	char msg[64];
 
	SetDParam(0, p2);
 
	GetString(msg, STR_COMPANY_NAME, lastof(msg));
 

	
 
	if (!_network_server) {
 
		NetworkClientSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, p1);
 
	} else {
 
		NetworkServerSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, CLIENT_ID_SERVER, p1);
 
	}
 
#endif /* ENABLE_NETWORK */
 
}
 

	
 
void HandleOnEditText(const char *str)
 
{
 
	switch (_rename_what) {
 
#ifdef ENABLE_NETWORK
 
	case 3: { // Give money, you can only give money in excess of loan
 
		const Company *c = Company::GetIfValid(_local_company);
 
		if (c == NULL) break;
 
		Money money = min(c->money - c->current_loan, (Money)(atoi(str) / _currency->rate));
 
		case 3: { // Give money, you can only give money in excess of loan
 
			const Company *c = Company::GetIfValid(_local_company);
 
			if (c == NULL) break;
 
			Money money = min(c->money - c->current_loan, (Money)(atoi(str) / _currency->rate));
 

	
 
		uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
 
			uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
 

	
 
		/* Give 'id' the money, and subtract it from ourself */
 
		DoCommandP(0, money_c, _rename_id, CMD_GIVE_MONEY | CMD_MSG(STR_ERROR_INSUFFICIENT_FUNDS), CcGiveMoney, str);
 
		break;
 
	}
 
#endif /* ENABLE_NETWORK */
 
			/* Give 'id' the money, and subtract it from ourself */
 
			DoCommandP(0, money_c, _rename_id, CMD_GIVE_MONEY | CMD_MSG(STR_ERROR_INSUFFICIENT_FUNDS), CcGiveMoney, str);
 
			break;
 
		}
 
		default: NOT_REACHED();
 
	}
 

	
 
	_rename_id = _rename_what = -1;
 
}
 

	
 
@@ -121,20 +117,18 @@ bool HandlePlacePushButton(Window *w, in
 

	
 
void CcPlaySound_EXPLOSION(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_12_EXPLOSION, tile);
 
}
 

	
 
#ifdef ENABLE_NETWORK
 
void ShowNetworkGiveMoneyWindow(CompanyID company)
 
{
 
	_rename_id = company;
 
	_rename_what = 3;
 
	ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, NULL, CS_NUMERAL, QSF_NONE);
 
}
 
#endif /* ENABLE_NETWORK */
 

	
 

	
 
/**
 
 * Zooms a viewport in a window in or out.
 
 * @param how Zooming direction.
 
 * @param w   Window owning the viewport.
 
@@ -394,13 +388,12 @@ struct MainWindow : Window
 
				break;
 

	
 
			case GHK_TRANSPARANCY:
 
				ResetRestoreAllTransparency();
 
				break;
 

	
 
#ifdef ENABLE_NETWORK
 
			case GHK_CHAT: // smart chat; send to team if any, otherwise to all
 
				if (_networking) {
 
					const NetworkClientInfo *cio = NetworkClientInfo::GetByClientID(_network_own_client_id);
 
					if (cio == NULL) break;
 

	
 
					ShowNetworkChatQueryWindow(NetworkClientPreferTeamChat(cio) ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas);
 
@@ -422,13 +415,12 @@ struct MainWindow : Window
 

	
 
			case GHK_CHAT_SERVER: // send text to the server
 
				if (_networking && !_network_server) {
 
					ShowNetworkChatQueryWindow(DESTTYPE_CLIENT, CLIENT_ID_SERVER);
 
				}
 
				break;
 
#endif
 

	
 
			default: return ES_NOT_HANDLED;
 
		}
 
		return ES_HANDLED;
 
	}
 

	
 
@@ -513,18 +505,16 @@ static Hotkey global_hotkeys[] = {
 
	Hotkey('5' | WKC_CTRL | WKC_SHIFT, "invisibility_buildings", GHK_TOGGLE_INVISIBILITY + 4),
 
	Hotkey('6' | WKC_CTRL | WKC_SHIFT, "invisibility_bridges", GHK_TOGGLE_INVISIBILITY + 5),
 
	Hotkey('7' | WKC_CTRL | WKC_SHIFT, "invisibility_structures", GHK_TOGGLE_INVISIBILITY + 6),
 
	Hotkey('8' | WKC_CTRL | WKC_SHIFT, "invisibility_catenary", GHK_TOGGLE_INVISIBILITY + 7),
 
	Hotkey('X' | WKC_CTRL, "transparency_toolbar", GHK_TRANSPARENCY_TOOLBAR),
 
	Hotkey('X', "toggle_transparency", GHK_TRANSPARANCY),
 
#ifdef ENABLE_NETWORK
 
	Hotkey(_ghk_chat_keys, "chat", GHK_CHAT),
 
	Hotkey(_ghk_chat_all_keys, "chat_all", GHK_CHAT_ALL),
 
	Hotkey(_ghk_chat_company_keys, "chat_company", GHK_CHAT_COMPANY),
 
	Hotkey(_ghk_chat_server_keys, "chat_server", GHK_CHAT_SERVER),
 
#endif
 
	HOTKEY_LIST_END
 
};
 
HotkeyList MainWindow::hotkeys("global", global_hotkeys);
 

	
 
static WindowDesc _main_window_desc(
 
	WDP_MANUAL, NULL, 0, 0,
src/misc.cpp
Show inline comments
 
@@ -108,15 +108,13 @@ void InitializeGame(uint size_x, uint si
 
	InitializeCompanies();
 
	AI::Initialize();
 
	Game::Initialize();
 
	InitializeCheats();
 

	
 
	InitTextEffects();
 
#ifdef ENABLE_NETWORK
 
	NetworkInitChatMessage();
 
#endif /* ENABLE_NETWORK */
 
	InitializeAnimatedTiles();
 

	
 
	InitializeEconomy();
 

	
 
	ResetObjectToPlace();
 

	
src/misc_cmd.cpp
Show inline comments
 
@@ -151,43 +151,37 @@ CommandCost CmdPause(TileIndex tile, DoC
 
		case PM_PAUSED_SAVELOAD:
 
		case PM_PAUSED_ERROR:
 
		case PM_PAUSED_NORMAL:
 
		case PM_PAUSED_GAME_SCRIPT:
 
			break;
 

	
 
#ifdef ENABLE_NETWORK
 
		case PM_PAUSED_JOIN:
 
		case PM_PAUSED_ACTIVE_CLIENTS:
 
			if (!_networking) return CMD_ERROR;
 
			break;
 
#endif /* ENABLE_NETWORK */
 

	
 
		default: return CMD_ERROR;
 
	}
 
	if (flags & DC_EXEC) {
 
		if (p1 == PM_PAUSED_NORMAL && _pause_mode & PM_PAUSED_ERROR) {
 
			ShowQuery(
 
				STR_NEWGRF_UNPAUSE_WARNING_TITLE,
 
				STR_NEWGRF_UNPAUSE_WARNING,
 
				NULL,
 
				AskUnsafeUnpauseCallback
 
			);
 
		} else {
 
#ifdef ENABLE_NETWORK
 
			PauseMode prev_mode = _pause_mode;
 
#endif /* ENABLE_NETWORK */
 

	
 
			if (p2 == 0) {
 
				_pause_mode = _pause_mode & ~p1;
 
			} else {
 
				_pause_mode = _pause_mode | p1;
 
			}
 

	
 
#ifdef ENABLE_NETWORK
 
			NetworkHandlePauseChange(prev_mode, (PauseMode)p1);
 
#endif /* ENABLE_NETWORK */
 
		}
 

	
 
		SetWindowDirty(WC_STATUS_BAR, 0);
 
		SetWindowDirty(WC_MAIN_TOOLBAR, 0);
 
	}
 
	return CommandCost();
src/network/core/address.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/** @file core/address.cpp Implementation of the address. */
 

	
 
#include "../../stdafx.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "address.h"
 
#include "../../debug.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/**
 
@@ -430,8 +428,6 @@ void NetworkAddress::Listen(int socktype
 
		case AF_UNSPEC: return "either IPv4 or IPv6";
 
		case AF_INET:   return "IPv4";
 
		case AF_INET6:  return "IPv6";
 
		default:        return "unsupported";
 
	}
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/core/address.h
Show inline comments
 
@@ -14,14 +14,12 @@
 

	
 
#include "os_abstraction.h"
 
#include "config.h"
 
#include "../../string_func.h"
 
#include "../../core/smallmap_type.hpp"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
class NetworkAddress;
 
typedef SmallVector<NetworkAddress, 4> NetworkAddressList; ///< Type for a list of addresses.
 
typedef SmallMap<NetworkAddress, SOCKET, 4> SocketList;    ///< Type for a mapping between address and socket.
 

	
 
/**
 
 * Wrapper for (un)resolved network addresses; there's no reason to transform
 
@@ -189,8 +187,7 @@ public:
 
	void Listen(int socktype, SocketList *sockets);
 

	
 
	static const char *SocketTypeAsString(int socktype);
 
	static const char *AddressFamilyAsString(int family);
 
};
 

	
 
#endif /* ENABLE_NETWORK */
 
#endif /* NETWORK_CORE_ADDRESS_H */
src/network/core/core.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/**
 
 * @file core.cpp Functions used to initialize/shut down the core network
 
 */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../../stdafx.h"
 
#include "../../debug.h"
 
#include "os_abstraction.h"
 
#include "packet.h"
 

	
 
#include "../../safeguards.h"
 
@@ -77,8 +75,6 @@ void NetworkSocketHandler::ReceiveGRFIde
 
	uint j;
 
	grf->grfid = p->Recv_uint32();
 
	for (j = 0; j < sizeof(grf->md5sum); j++) {
 
		grf->md5sum[j] = p->Recv_uint8();
 
	}
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/core/core.h
Show inline comments
 
@@ -14,14 +14,12 @@
 
#ifndef NETWORK_CORE_CORE_H
 
#define NETWORK_CORE_CORE_H
 

	
 
#include "../../newgrf_config.h"
 
#include "config.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
bool NetworkCoreInitialize();
 
void NetworkCoreShutdown();
 

	
 
/** Status of a network client; reasons why a client has quit */
 
enum NetworkRecvStatus {
 
	NETWORK_RECV_STATUS_OKAY,             ///< Everything is okay
 
@@ -77,9 +75,7 @@ public:
 

	
 
	void SendGRFIdentifier(Packet *p, const GRFIdentifier *grf);
 
	void ReceiveGRFIdentifier(Packet *p, GRFIdentifier *grf);
 
	void SendCompanyInformation(Packet *p, const struct Company *c, const struct NetworkCompanyStats *stats, uint max_len = NETWORK_COMPANY_NAME_LENGTH);
 
};
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CORE_CORE_H */
src/network/core/game.h
Show inline comments
 
@@ -16,14 +16,12 @@
 
#define NETWORK_CORE_GAME_H
 

	
 
#include "config.h"
 
#include "../../newgrf_config.h"
 
#include "../../date_type.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/**
 
 * The game information that is not generated on-the-fly and has to
 
 * be sent to the clients.
 
 */
 
struct NetworkServerGameInfo {
 
	char map_name[NETWORK_NAME_LENGTH];             ///< Map which is played ["random" for a randomized map]
 
@@ -55,9 +53,7 @@ struct NetworkGameInfo : NetworkServerGa
 
	byte spectators_max;                            ///< Max spectators allowed on server
 
	byte map_set;                                   ///< Graphical set
 
};
 

	
 
const char * GetNetworkRevisionString();
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CORE_GAME_H */
src/network/core/host.cpp
Show inline comments
 
@@ -6,14 +6,12 @@
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file host.cpp Functions related to getting host specific data (IPs). */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../../stdafx.h"
 
#include "../../debug.h"
 
#include "address.h"
 

	
 
#include "../../safeguards.h"
 

	
 
@@ -204,8 +202,6 @@ void NetworkFindBroadcastIPs(NetworkAddr
 
	int i = 0;
 
	for (NetworkAddress *addr = broadcast->Begin(); addr != broadcast->End(); addr++) {
 
		addr->SetPort(NETWORK_DEFAULT_PORT);
 
		DEBUG(net, 3, "%d) %s", i++, addr->GetHostname());
 
	}
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/core/os_abstraction.h
Show inline comments
 
@@ -15,14 +15,12 @@
 

	
 
#ifndef NETWORK_CORE_OS_ABSTRACTION_H
 
#define NETWORK_CORE_OS_ABSTRACTION_H
 

	
 
/* Include standard stuff per OS */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/* Windows stuff */
 
#if defined(_WIN32)
 
#include <errno.h>
 
#include <winsock2.h>
 
#include <ws2tcpip.h>
 
#include <windows.h>
 
@@ -169,9 +167,7 @@ static inline bool SetNoDelay(SOCKET d)
 
}
 

	
 
/* Make sure these structures have the size we expect them to be */
 
assert_compile(sizeof(in_addr)  ==  4); ///< IPv4 addresses should be 4 bytes.
 
assert_compile(sizeof(in6_addr) == 16); ///< IPv6 addresses should be 16 bytes.
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CORE_OS_ABSTRACTION_H */
src/network/core/packet.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/**
 
 * @file packet.cpp Basic functions to create, fill and read packets.
 
 */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../../stdafx.h"
 
#include "../../string_func.h"
 

	
 
#include "packet.h"
 

	
 
#include "../../safeguards.h"
 
@@ -307,8 +305,6 @@ void Packet::Recv_string(char *buffer, s
 
		pos++;
 
	}
 
	this->pos = pos;
 

	
 
	str_validate(bufp, last, settings);
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/core/packet.h
Show inline comments
 
@@ -15,14 +15,12 @@
 
#define NETWORK_CORE_PACKET_H
 

	
 
#include "config.h"
 
#include "core.h"
 
#include "../../string_type.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
typedef uint16 PacketSize; ///< Size of the whole packet.
 
typedef uint8  PacketType; ///< Identifier for the packet
 

	
 
/**
 
 * Internal entity of a packet. As everything is sent as a packet,
 
 * all network communication will need to call the functions that
 
@@ -84,9 +82,7 @@ public:
 
	uint16 Recv_uint16();
 
	uint32 Recv_uint32();
 
	uint64 Recv_uint64();
 
	void   Recv_string(char *buffer, size_t size, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);
 
};
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CORE_PACKET_H */
src/network/core/tcp.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/**
 
 * @file tcp.cpp Basic functions to receive and send TCP packets.
 
 */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../../stdafx.h"
 
#include "../../debug.h"
 

	
 
#include "tcp.h"
 

	
 
#include "../../safeguards.h"
 
@@ -240,8 +238,6 @@ bool NetworkTCPSocketHandler::CanSendRec
 
	tv.tv_sec = tv.tv_usec = 0; // don't block at all.
 
	if (select(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv) < 0) return false;
 

	
 
	this->writable = !!FD_ISSET(this->sock, &write_fd);
 
	return FD_ISSET(this->sock, &read_fd) != 0;
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/core/tcp.h
Show inline comments
 
@@ -14,14 +14,12 @@
 
#ifndef NETWORK_CORE_TCP_H
 
#define NETWORK_CORE_TCP_H
 

	
 
#include "address.h"
 
#include "packet.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/** The states of sending the packets. */
 
enum SendPacketsState {
 
	SPS_CLOSED,      ///< The connection got closed.
 
	SPS_NONE_SENT,   ///< The buffer is still full, so no (parts of) packets could be sent.
 
	SPS_PARTLY_SENT, ///< The packets are partly sent; there are more packets to be sent in the queue.
 
	SPS_ALL_SENT,    ///< All packets in the queue are sent.
 
@@ -96,9 +94,7 @@ public:
 
	virtual void OnFailure() {}
 

	
 
	static void CheckCallbacks();
 
	static void KillAll();
 
};
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CORE_TCP_H */
src/network/core/tcp_admin.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/**
 
 * @file tcp_admin.cpp Basic functions to receive and send TCP packets to and from the admin network.
 
 */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../../stdafx.h"
 

	
 
#include "../network_internal.h"
 
#include "tcp_admin.h"
 
#include "../../debug.h"
 

	
 
@@ -169,8 +167,6 @@ NetworkRecvStatus NetworkAdminSocketHand
 
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_RCON); }
 
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CONSOLE(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CONSOLE); }
 
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_NAMES(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CMD_NAMES); }
 
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_LOGGING(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CMD_LOGGING); }
 
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON_END(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_RCON_END); }
 
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_PONG(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_PONG); }
 

	
 
#endif /* ENABLE_NETWORK */
src/network/core/tcp_admin.h
Show inline comments
 
@@ -16,14 +16,12 @@
 

	
 
#include "os_abstraction.h"
 
#include "tcp.h"
 
#include "../network_type.h"
 
#include "../../core/pool_type.hpp"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/**
 
 * Enum with types of TCP packets specific to the admin network.
 
 * This protocol may only be extended to ensure stability.
 
 */
 
enum PacketAdminType {
 
	ADMIN_PACKET_ADMIN_JOIN,             ///< The admin announces and authenticates itself to the server.
 
@@ -497,9 +495,7 @@ public:
 
	AdminStatus GetAdminStatus() const
 
	{
 
		return this->status;
 
	}
 
};
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CORE_TCP_ADMIN_H */
src/network/core/tcp_connect.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/**
 
 * @file tcp_connect.cpp Basic functions to create connections without blocking.
 
 */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../../stdafx.h"
 
#include "../../thread/thread.h"
 

	
 
#include "tcp.h"
 

	
 
#include "../../safeguards.h"
 
@@ -94,8 +92,6 @@ void TCPConnecter::Connect()
 

	
 
/** Kill all connection attempts. */
 
/* static */ void TCPConnecter::KillAll()
 
{
 
	for (TCPConnecter **iter = _tcp_connecters.Begin(); iter != _tcp_connecters.End(); iter++) (*iter)->killed = true;
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/core/tcp_content.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/**
 
 * @file tcp_content.cpp Basic functions to receive and send Content packets.
 
 */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../../stdafx.h"
 
#ifndef OPENTTD_MSU
 
#include "../../textfile_gui.h"
 
#include "../../newgrf_config.h"
 
#include "../../base_media_base.h"
 
#include "../../ai/ai.hpp"
 
@@ -263,8 +261,6 @@ Subdirectory GetContentInfoSubDir(Conten
 

	
 
		case CONTENT_TYPE_SCENARIO:     return SCENARIO_DIR;
 
		case CONTENT_TYPE_HEIGHTMAP:    return HEIGHTMAP_DIR;
 
	}
 
}
 
#endif /* OPENTTD_MSU */
 

	
 
#endif /* ENABLE_NETWORK */
src/network/core/tcp_content.h
Show inline comments
 
@@ -16,14 +16,12 @@
 

	
 
#include "os_abstraction.h"
 
#include "tcp.h"
 
#include "packet.h"
 
#include "../../debug.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/** The values in the enum are important; they are used as database 'keys' */
 
enum ContentType {
 
	CONTENT_TYPE_BEGIN         = 1, ///< Helper to mark the begin of the types
 
	CONTENT_TYPE_BASE_GRAPHICS = 1, ///< The content consists of base graphics
 
	CONTENT_TYPE_NEWGRF        = 2, ///< The content consists of a NewGRF
 
	CONTENT_TYPE_AI            = 3, ///< The content consists of an AI
 
@@ -210,9 +208,7 @@ public:
 
};
 

	
 
#ifndef OPENTTD_MSU
 
Subdirectory GetContentInfoSubDir(ContentType type);
 
#endif /* OPENTTD_MSU */
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CORE_TCP_CONTENT_H */
src/network/core/tcp_game.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/**
 
 * @file tcp_game.cpp Basic functions to receive and send TCP packets for game purposes.
 
 */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../../stdafx.h"
 

	
 
#include "../network.h"
 
#include "../network_internal.h"
 
#include "../../debug.h"
 
#include "../../error.h"
 
@@ -196,8 +194,6 @@ NetworkRecvStatus NetworkGameSocketHandl
 
NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_CHECK_NEWGRFS); }
 
NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_NEWGRFS_CHECKED(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CLIENT_NEWGRFS_CHECKED); }
 
NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_MOVE(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_MOVE); }
 
NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_MOVE(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CLIENT_MOVE); }
 
NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_COMPANY_UPDATE(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_COMPANY_UPDATE); }
 
NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_CONFIG_UPDATE(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_CONFIG_UPDATE); }
 

	
 
#endif /* ENABLE_NETWORK */
src/network/core/tcp_game.h
Show inline comments
 
@@ -16,14 +16,12 @@
 

	
 
#include "os_abstraction.h"
 
#include "tcp.h"
 
#include "../network_type.h"
 
#include "../../core/pool_type.hpp"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/**
 
 * Enum with all types of TCP packets.
 
 * For the exact meaning, look at #NetworkGameSocketHandler.
 
 */
 
enum PacketGameType {
 
	/*
 
@@ -555,9 +553,7 @@ public:
 
	NetworkRecvStatus ReceivePackets();
 

	
 
	const char *ReceiveCommand(Packet *p, CommandPacket *cp);
 
	void SendCommand(Packet *p, const CommandPacket *cp);
 
};
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CORE_TCP_GAME_H */
src/network/core/tcp_http.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/**
 
 * @file tcp_http.cpp Basic functions to receive and send HTTP TCP packets.
 
 */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../../stdafx.h"
 
#include "../../debug.h"
 
#include "../../rev.h"
 
#include "../network_func.h"
 

	
 
#include "tcp_http.h"
 
@@ -328,8 +326,6 @@ int NetworkHTTPSocketHandler::Receive()
 
				continue;
 
			}
 
		}
 
		iter++;
 
	}
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/core/tcp_http.h
Show inline comments
 
@@ -13,14 +13,12 @@
 

	
 
#ifndef NETWORK_CORE_TCP_HTTP_H
 
#define NETWORK_CORE_TCP_HTTP_H
 

	
 
#include "tcp.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/** Callback for when the HTTP handler has something to tell us. */
 
struct HTTPCallback {
 
	/**
 
	 * An error has occurred and the connection has been closed.
 
	 * @note HTTP socket handler is closed/freed.
 
	 */
 
@@ -119,9 +117,7 @@ public:
 
		new NetworkHTTPSocketHandler(s, this->callback, this->address.GetHostname(), this->url, this->data, this->depth);
 
		/* We've relinquished control of data now. */
 
		this->data = NULL;
 
	}
 
};
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CORE_TCP_HTTP_H */
src/network/core/tcp_listen.h
Show inline comments
 
@@ -17,14 +17,12 @@
 
#include "tcp.h"
 
#include "../network.h"
 
#include "../../core/pool_type.hpp"
 
#include "../../debug.h"
 
#include "table/strings.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/**
 
 * Template for TCP listeners.
 
 * @param Tsocket      The class we create sockets for.
 
 * @param Tfull_packet The packet type to return when we don't allow more sockets.
 
 * @param Tban_packet  The packet type to return when the client is banned.
 
 */
 
@@ -170,9 +168,7 @@ public:
 
		DEBUG(net, 1, "[%s] closed listeners", Tsocket::GetName());
 
	}
 
};
 

	
 
template <class Tsocket, PacketType Tfull_packet, PacketType Tban_packet> SocketList TCPListenHandler<Tsocket, Tfull_packet, Tban_packet>::sockets;
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CORE_TCP_LISTEN_H */
src/network/core/udp.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/**
 
 * @file core/udp.cpp Basic functions to receive and send UDP packets.
 
 */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../../stdafx.h"
 
#include "../../date_func.h"
 
#include "../../debug.h"
 
#include "udp.h"
 

	
 
#include "../../safeguards.h"
 
@@ -344,8 +342,6 @@ void NetworkUDPSocketHandler::Receive_MA
 
void NetworkUDPSocketHandler::Receive_CLIENT_GET_LIST(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_CLIENT_GET_LIST, client_addr); }
 
void NetworkUDPSocketHandler::Receive_MASTER_RESPONSE_LIST(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_MASTER_RESPONSE_LIST, client_addr); }
 
void NetworkUDPSocketHandler::Receive_SERVER_UNREGISTER(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_SERVER_UNREGISTER, client_addr); }
 
void NetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_CLIENT_GET_NEWGRFS, client_addr); }
 
void NetworkUDPSocketHandler::Receive_SERVER_NEWGRFS(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_SERVER_NEWGRFS, client_addr); }
 
void NetworkUDPSocketHandler::Receive_MASTER_SESSION_KEY(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_MASTER_SESSION_KEY, client_addr); }
 

	
 
#endif /* ENABLE_NETWORK */
src/network/core/udp.h
Show inline comments
 
@@ -15,14 +15,12 @@
 
#define NETWORK_CORE_UDP_H
 

	
 
#include "address.h"
 
#include "game.h"
 
#include "packet.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/** Enum with all types of UDP packets. The order MUST not be changed **/
 
enum PacketUDPType {
 
	PACKET_UDP_CLIENT_FIND_SERVER,   ///< Queries a game server for game information
 
	PACKET_UDP_SERVER_RESPONSE,      ///< Reply of the game server with game information
 
	PACKET_UDP_CLIENT_DETAIL_INFO,   ///< Queries a game server about details of the game, such as companies
 
	PACKET_UDP_SERVER_DETAIL_INFO,   ///< Reply of the game server about details of the game, such as companies
 
@@ -243,9 +241,7 @@ public:
 
	void ReceivePackets();
 

	
 
	void SendNetworkGameInfo(Packet *p, const NetworkGameInfo *info);
 
	void ReceiveNetworkGameInfo(Packet *p, NetworkGameInfo *info);
 
};
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CORE_UDP_H */
src/network/network.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/** @file network.cpp Base functions for networking support. */
 

	
 
#include "../stdafx.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../strings_func.h"
 
#include "../command_func.h"
 
#include "../date_func.h"
 
#include "network_admin.h"
 
#include "network_client.h"
 
#include "network_server.h"
 
@@ -1169,8 +1167,6 @@ bool IsNetworkCompatibleVersion(const ch
 
	if (_openttd_revision_tagged) return false;
 

	
 
	const char *hash1 = ExtractNetworkRevisionHash(GetNetworkRevisionString());
 
	const char *hash2 = ExtractNetworkRevisionHash(other);
 
	return hash1 && hash2 && (strncmp(hash1, hash2, GITHASH_SUFFIX_LEN) == 0);
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network.h
Show inline comments
 
@@ -9,36 +9,18 @@
 

	
 
/** @file network.h Basic functions/variables used all over the place. */
 

	
 
#ifndef NETWORK_H
 
#define NETWORK_H
 

	
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
void NetworkStartUp();
 
void NetworkShutDown();
 
void NetworkDrawChatMessage();
 
bool HasClients();
 

	
 
extern bool _networking;         ///< are we in networking mode?
 
extern bool _network_server;     ///< network-server is active
 
extern bool _network_available;  ///< is network mode available?
 
extern bool _network_dedicated;  ///< are we a dedicated server?
 
extern bool _is_network_server;  ///< Does this client wants to be a network-server?
 

	
 
#else /* ENABLE_NETWORK */
 
/* Network function stubs when networking is disabled */
 

	
 
static inline void NetworkStartUp() {}
 
static inline void NetworkShutDown() {}
 
static inline void NetworkDrawChatMessage() {}
 
static inline bool HasClients() { return false; }
 

	
 
#define _networking 0
 
#define _network_server 0
 
#define _network_available 0
 
#define _network_dedicated 0
 
#define _is_network_server 0
 

	
 
#endif /* ENABLE_NETWORK */
 
#endif /* NETWORK_H */
src/network/network_admin.cpp
Show inline comments
 
@@ -6,14 +6,12 @@
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file network_admin.cpp Server part of the admin network protocol. */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../stdafx.h"
 
#include "../strings_func.h"
 
#include "../date_func.h"
 
#include "network_admin.h"
 
#include "network_base.h"
 
#include "network_server.h"
 
@@ -1042,8 +1040,6 @@ void NetworkAdminUpdate(AdminUpdateFrequ
 
					default: NOT_REACHED();
 
				}
 
			}
 
		}
 
	}
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_admin.h
Show inline comments
 
@@ -9,14 +9,12 @@
 

	
 
/** @file network_admin.h Server part of the admin network protocol. */
 

	
 
#ifndef NETWORK_ADMIN_H
 
#define NETWORK_ADMIN_H
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "network_internal.h"
 
#include "core/tcp_listen.h"
 
#include "core/tcp_admin.h"
 

	
 
extern AdminIndex _redirect_console_to_admin;
 

	
 
@@ -121,8 +119,7 @@ void NetworkAdminChat(NetworkAction acti
 
void NetworkAdminUpdate(AdminUpdateFrequency freq);
 
void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const char *string);
 
void NetworkAdminConsole(const char *origin, const char *string);
 
void NetworkAdminGameScript(const char *json);
 
void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket *cp);
 

	
 
#endif /* ENABLE_NETWORK */
 
#endif /* NETWORK_ADMIN_H */
src/network/network_base.h
Show inline comments
 
@@ -9,14 +9,12 @@
 

	
 
/** @file network_base.h Base core network types and some helper functions to access them. */
 

	
 
#ifndef NETWORK_BASE_H
 
#define NETWORK_BASE_H
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "network_type.h"
 
#include "core/address.h"
 
#include "../core/pool_type.hpp"
 
#include "../company_type.h"
 

	
 
/** Type for the pool with client information. */
 
@@ -51,8 +49,7 @@ struct NetworkClientInfo : NetworkClient
 
/**
 
 * Iterate over all the clients.
 
 * @param var The variable to iterate with.
 
 */
 
#define FOR_ALL_CLIENT_INFOS(var) FOR_ALL_CLIENT_INFOS_FROM(var, 0)
 

	
 
#endif /* ENABLE_NETWORK */
 
#endif /* NETWORK_BASE_H */
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/** @file network_chat_gui.cpp GUI for handling chat messages. */
 

	
 
#include <stdarg.h> /* va_list */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../stdafx.h"
 
#include "../strings_func.h"
 
#include "../blitter/factory.hpp"
 
#include "../console_func.h"
 
#include "../video/video_driver.hpp"
 
#include "../querystring_gui.h"
 
@@ -559,8 +557,6 @@ static WindowDesc _chat_window_desc(
 
 */
 
void ShowNetworkChatQueryWindow(DestType type, int dest)
 
{
 
	DeleteWindowByClass(WC_SEND_NETWORK_MSG);
 
	new NetworkChatWindow(&_chat_window_desc, type, dest);
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_client.cpp
Show inline comments
 
@@ -6,14 +6,12 @@
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file network_client.cpp Client part of the network protocol. */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../stdafx.h"
 
#include "network_gui.h"
 
#include "../saveload/saveload.h"
 
#include "../saveload/saveload_filter.h"
 
#include "../command_func.h"
 
#include "../console_func.h"
 
@@ -1317,8 +1315,6 @@ bool NetworkMaxCompaniesReached()
 
 * @return true if the max value has been reached or exceeded, false otherwise.
 
 */
 
bool NetworkMaxSpectatorsReached()
 
{
 
	return NetworkSpectatorCount() >= (_network_server ? _settings_client.network.max_spectators : _network_server_max_spectators);
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_client.h
Show inline comments
 
@@ -9,14 +9,12 @@
 

	
 
/** @file network_client.h Client part of the network protocol. */
 

	
 
#ifndef NETWORK_CLIENT_H
 
#define NETWORK_CLIENT_H
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "network_internal.h"
 

	
 
/** Class for handling the client side of the game connection. */
 
class ClientNetworkGameSocketHandler : public ZeroedMemoryAllocator, public NetworkGameSocketHandler {
 
private:
 
	struct PacketReader *savegame; ///< Packet reader for reading the savegame.
 
@@ -115,9 +113,7 @@ void NetworkClientSetCompanyPassword(con
 

	
 
extern CompanyID _network_join_as;
 

	
 
extern const char *_network_join_server_password;
 
extern const char *_network_join_company_password;
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CLIENT_H */
src/network/network_command.cpp
Show inline comments
 
@@ -6,14 +6,12 @@
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file network_command.cpp Command handling over network connections. */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../stdafx.h"
 
#include "network_admin.h"
 
#include "network_client.h"
 
#include "network_server.h"
 
#include "../command_func.h"
 
#include "../company_func.h"
 
@@ -341,8 +339,6 @@ void NetworkGameSocketHandler::SendComma
 
	if (callback == lengthof(_callback_table)) {
 
		DEBUG(net, 0, "Unknown callback. (Pointer: %p) No callback sent", cp->callback);
 
		callback = 0; // _callback_table[0] == NULL
 
	}
 
	p->Send_uint8 (callback);
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_content.cpp
Show inline comments
 
@@ -6,14 +6,12 @@
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file network_content.cpp Content sending/receiving part of the network protocol. */
 

	
 
#if defined(ENABLE_NETWORK)
 

	
 
#include "../stdafx.h"
 
#include "../rev.h"
 
#include "../ai/ai.hpp"
 
#include "../game/game.hpp"
 
#include "../window_func.h"
 
#include "../error.h"
 
@@ -1087,8 +1085,6 @@ void ClientNetworkContentSocketHandler::
 
	for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
 
		ContentCallback *cb = *iter;
 
		cb->OnDownloadComplete(cid);
 
		if (iter != this->callbacks.End() && *iter == cb) iter++;
 
	}
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_content.h
Show inline comments
 
@@ -12,14 +12,12 @@
 
#ifndef NETWORK_CONTENT_H
 
#define NETWORK_CONTENT_H
 

	
 
#include "core/tcp_content.h"
 
#include "core/tcp_http.h"
 

	
 
#if defined(ENABLE_NETWORK)
 

	
 
/** Vector with content info */
 
typedef SmallVector<ContentInfo *, 16> ContentVector;
 
/** Vector with constant content info */
 
typedef SmallVector<const ContentInfo *, 16> ConstContentVector;
 

	
 
/** Iterator for the content vector */
 
@@ -150,11 +148,7 @@ public:
 
extern ClientNetworkContentSocketHandler _network_content_client;
 

	
 
void ShowNetworkContentListWindow(ContentVector *cv = NULL, ContentType type1 = CONTENT_TYPE_END, ContentType type2 = CONTENT_TYPE_END);
 

	
 
void ShowMissingContentWindow(const struct GRFConfig *list);
 

	
 
#else
 
static inline void ShowNetworkContentListWindow() {}
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CONTENT_H */
src/network/network_content_gui.cpp
Show inline comments
 
@@ -6,13 +6,12 @@
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file network_content_gui.cpp Implementation of the Network Content related GUIs. */
 

	
 
#if defined(ENABLE_NETWORK)
 
#include "../stdafx.h"
 
#include "../strings_func.h"
 
#include "../gfx_func.h"
 
#include "../window_func.h"
 
#include "../error.h"
 
#include "../ai/ai.hpp"
 
@@ -1165,8 +1164,6 @@ void ShowNetworkContentListWindow(Conten
 
	/* Connection failed... clean up the mess */
 
	if (cv != NULL) {
 
		for (ContentIterator iter = cv->Begin(); iter != cv->End(); iter++) delete *iter;
 
	}
 
#endif /* WITH_ZLIB */
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_func.h
Show inline comments
 
@@ -23,14 +23,12 @@
 
#include "network_type.h"
 
#include "../console_type.h"
 
#include "../gfx_type.h"
 
#include "../openttd.h"
 
#include "../company_type.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
extern NetworkServerGameInfo _network_game_info;
 
extern NetworkCompanyState *_network_company_states;
 

	
 
extern ClientID _network_own_client_id;
 
extern ClientID _redirect_console_to_client;
 
extern bool _network_need_advertise;
 
@@ -87,8 +85,7 @@ void NetworkInitChatMessage();
 
void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const char *message, ...) WARN_FORMAT(3, 4);
 
void NetworkUndrawChatMessage();
 
void NetworkChatMessageLoop();
 

	
 
void NetworkAfterNewGRFScan();
 

	
 
#endif /* ENABLE_NETWORK */
 
#endif /* NETWORK_FUNC_H */
src/network/network_gamelist.cpp
Show inline comments
 
@@ -9,14 +9,12 @@
 

	
 
/**
 
 * @file network_gamelist.cpp This file handles the GameList
 
 * Also, it handles the request to a server for data about the server
 
 */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../stdafx.h"
 
#include "../debug.h"
 
#include "../window_func.h"
 
#include "../thread/thread.h"
 
#include "network_internal.h"
 
#include "network_udp.h"
 
@@ -203,8 +201,6 @@ void NetworkAfterNewGRFScan()
 
			}
 
		}
 
	}
 

	
 
	InvalidateWindowClassesData(WC_NETWORK_WINDOW);
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_gui.cpp
Show inline comments
 
@@ -6,13 +6,12 @@
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file network_gui.cpp Implementation of the Network related GUIs. */
 

	
 
#ifdef ENABLE_NETWORK
 
#include "../stdafx.h"
 
#include "../strings_func.h"
 
#include "../date_func.h"
 
#include "../fios.h"
 
#include "network_client.h"
 
#include "network_gui.h"
 
@@ -2238,8 +2237,6 @@ static WindowDesc _network_company_passw
 
void ShowNetworkCompanyPasswordWindow(Window *parent)
 
{
 
	DeleteWindowById(WC_COMPANY_PASSWORD_WINDOW, 0);
 

	
 
	new NetworkCompanyPasswordWindow(&_network_company_password_window_desc, parent);
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_gui.h
Show inline comments
 
@@ -14,14 +14,12 @@
 

	
 
#include "../company_type.h"
 
#include "../economy_type.h"
 
#include "../window_type.h"
 
#include "network_type.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
void ShowNetworkNeedPassword(NetworkPasswordType npt);
 
void ShowNetworkGiveMoneyWindow(CompanyID company);
 
void ShowNetworkChatQueryWindow(DestType type, int dest);
 
void ShowJoinStatusWindow();
 
void ShowNetworkGameWindow();
 
void ShowClientList();
 
@@ -39,17 +37,7 @@ struct NetworkCompanyInfo : NetworkCompa
 
	bool use_password;                              ///< Is there a password
 
	char clients[NETWORK_CLIENTS_LENGTH];           ///< The clients that control this company (Name1, name2, ..)
 
};
 

	
 
NetworkCompanyInfo *GetLobbyCompanyInfo(CompanyID company);
 

	
 
#else /* ENABLE_NETWORK */
 
/* Network function stubs when networking is disabled */
 

	
 
static inline void ShowNetworkChatQueryWindow(byte desttype, int dest) {}
 
static inline void ShowClientList() {}
 
static inline void ShowNetworkGameWindow() {}
 
static inline void ShowNetworkCompanyPasswordWindow(Window *parent) {}
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_GUI_H */
src/network/network_internal.h
Show inline comments
 
@@ -14,14 +14,12 @@
 

	
 
#include "network_func.h"
 
#include "core/tcp_game.h"
 

	
 
#include "../command_type.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#ifdef RANDOM_DEBUG
 
/**
 
 * If this line is enable, every frame will have a sync test
 
 *  this is not needed in normal games. Normal is like 1 sync in 100
 
 *  frames. You can enable this if you have a lot of desyncs on a certain
 
 *  game.
 
@@ -168,8 +166,7 @@ void NetworkError(StringID error_string)
 
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const char *name, const char *str = "", int64 data = 0);
 
uint NetworkCalculateLag(const NetworkClientSocket *cs);
 
StringID GetNetworkErrorMsg(NetworkErrorCode err);
 
bool NetworkFindName(char *new_name, const char *last);
 
const char *GenerateCompanyPasswordHash(const char *password, const char *password_server_id, uint32 password_game_seed);
 

	
 
#endif /* ENABLE_NETWORK */
 
#endif /* NETWORK_INTERNAL_H */
src/network/network_server.cpp
Show inline comments
 
@@ -6,14 +6,12 @@
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file network_server.cpp Server part of the network protocol. */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../stdafx.h"
 
#include "../strings_func.h"
 
#include "../date_func.h"
 
#include "network_admin.h"
 
#include "network_server.h"
 
#include "network_udp.h"
 
@@ -2203,8 +2201,6 @@ void NetworkServerNewCompany(const Compa
 
		/* ci is NULL when replaying, or for AIs. In neither case there is a client.
 
		   We need to send Admin port update here so that they first know about the new company
 
		   and then learn about a possibly joining client (see FS#6025) */
 
		NetworkServerSendChat(NETWORK_ACTION_COMPANY_NEW, DESTTYPE_BROADCAST, 0, "", ci->client_id, c->index + 1);
 
	}
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_server.h
Show inline comments
 
@@ -9,14 +9,12 @@
 

	
 
/** @file network_server.h Server part of the network protocol. */
 

	
 
#ifndef NETWORK_SERVER_H
 
#define NETWORK_SERVER_H
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "network_internal.h"
 
#include "core/tcp_listen.h"
 
#include "../thread/thread.h"
 

	
 
class ServerNetworkGameSocketHandler;
 
/** Make the code look slightly nicer/simpler. */
 
@@ -135,15 +133,7 @@ void NetworkServerUpdateCompanyPassworde
 
/**
 
 * Iterate over all the sockets.
 
 * @param var The variable to iterate with.
 
 */
 
#define FOR_ALL_CLIENT_SOCKETS(var) FOR_ALL_CLIENT_SOCKETS_FROM(var, 0)
 

	
 
#else /* ENABLE_NETWORK */
 
/* Network function stubs when networking is disabled */
 

	
 
static inline void NetworkServerMonthlyLoop() {}
 
static inline void NetworkServerYearlyLoop() {}
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_SERVER_H */
src/network/network_type.h
Show inline comments
 
@@ -11,14 +11,12 @@
 

	
 
#ifndef NETWORK_TYPE_H
 
#define NETWORK_TYPE_H
 

	
 
#include "core/game.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/** How many clients can we have */
 
static const uint MAX_CLIENTS = 255;
 

	
 
/**
 
 * The number of slots; must be at least 1 more than MAX_CLIENTS. It must
 
 * furthermore be less than or equal to 256 as client indices (sent over
 
@@ -127,8 +125,7 @@ enum NetworkErrorCode {
 
	NETWORK_ERROR_TIMEOUT_MAP,
 
	NETWORK_ERROR_TIMEOUT_JOIN,
 

	
 
	NETWORK_ERROR_END,
 
};
 

	
 
#endif /* ENABLE_NETWORK */
 
#endif /* NETWORK_TYPE_H */
src/network/network_udp.cpp
Show inline comments
 
@@ -11,14 +11,12 @@
 
 * @file network_udp.cpp This file handles the UDP related communication.
 
 *
 
 * This is the GameServer <-> MasterServer and GameServer <-> GameClient
 
 * communication before the game is being joined.
 
 */
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../stdafx.h"
 
#include "../date_func.h"
 
#include "../map_func.h"
 
#include "../debug.h"
 
#include "network_gamelist.h"
 
#include "network_internal.h"
 
@@ -711,8 +709,6 @@ void NetworkBackgroundUDPLoop()
 
		_udp_client_socket->ReceivePackets();
 
		if (_network_udp_broadcast > 0) _network_udp_broadcast--;
 
	}
 

	
 
	_network_udp_mutex->EndCritical();
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_udp.h
Show inline comments
 
@@ -9,22 +9,18 @@
 

	
 
/** @file network_udp.h Sending and receiving UDP messages. */
 

	
 
#ifndef NETWORK_UDP_H
 
#define NETWORK_UDP_H
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "core/address.h"
 

	
 
void NetworkUDPInitialize();
 
void NetworkUDPSearchGame();
 
void NetworkUDPQueryMasterServer();
 
void NetworkUDPQueryServer(NetworkAddress address, bool manually = false);
 
void NetworkUDPAdvertise();
 
void NetworkUDPRemoveAdvertise(bool blocking);
 
void NetworkUDPClose();
 
void NetworkBackgroundUDPLoop();
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_UDP_H */
src/newgrf_config.cpp
Show inline comments
 
@@ -754,15 +754,13 @@ void DoScanNewGRFFiles(void *callback)
 
		}
 
		to_sort[num - 1]->next = NULL;
 
		_all_grfs = to_sort[0];
 

	
 
		free(to_sort);
 

	
 
#ifdef ENABLE_NETWORK
 
		NetworkAfterNewGRFScan();
 
#endif
 
	}
 

	
 
	_modal_progress_work_mutex->EndCritical();
 
	_modal_progress_paint_mutex->BeginCritical();
 

	
 
	/* Yes... these are the NewGRF windows */
 
@@ -823,14 +821,12 @@ const GRFConfig *FindGRFConfig(uint32 gr
 
		if (best == NULL || c->version > best->version) best = c;
 
	}
 

	
 
	return best;
 
}
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/** Structure for UnknownGRFs; this is a lightweight variant of GRFConfig */
 
struct UnknownGRF : public GRFIdentifier {
 
	UnknownGRF *next;     ///< The next unknown GRF.
 
	GRFTextWrapper *name; ///< Name of the GRF.
 
};
 

	
 
@@ -874,15 +870,12 @@ GRFTextWrapper *FindUnknownGRFName(uint3
 
	memcpy(grf->md5sum, md5sum, sizeof(grf->md5sum));
 

	
 
	unknown_grfs = grf;
 
	return grf->name;
 
}
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 

	
 
/**
 
 * Retrieve a NewGRF from the current config by its grfid.
 
 * @param grfid grf to look for.
 
 * @param mask  GRFID mask to allow for partial matching.
 
 * @return The grf config, if it exists, else \c NULL.
 
 */
src/newgrf_config.h
Show inline comments
 
@@ -226,16 +226,14 @@ GRFListCompatibility IsGoodGRFConfigList
 
bool FillGRFDetails(GRFConfig *config, bool is_static, Subdirectory subdir = NEWGRF_DIR);
 
char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
 

	
 
/* In newgrf_gui.cpp */
 
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config);
 

	
 
#ifdef ENABLE_NETWORK
 
/** For communication about GRFs over the network */
 
#define UNKNOWN_GRF_NAME_PLACEHOLDER "<Unknown>"
 
GRFTextWrapper *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create);
 
#endif /* ENABLE_NETWORK */
 

	
 
void UpdateNewGRFScanStatus(uint num, const char *name);
 
bool UpdateNewGRFConfigPalette(int32 p1 = 0);
 

	
 
#endif /* NEWGRF_CONFIG_H */
src/newgrf_gui.cpp
Show inline comments
 
@@ -1123,17 +1123,15 @@ struct NewGRFWindow : public Window, New
 

	
 
			case WID_NS_CONTENT_DOWNLOAD:
 
			case WID_NS_CONTENT_DOWNLOAD2:
 
				if (!_network_available) {
 
					ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
 
				} else {
 
#if defined(ENABLE_NETWORK)
 
					this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window
 

	
 
					ShowMissingContentWindow(this->actives);
 
#endif
 
				}
 
				break;
 

	
 
			case WID_NS_RESCAN_FILES:
 
			case WID_NS_RESCAN_FILES2:
 
				ScanNewGRFFiles(this);
 
@@ -1540,13 +1538,12 @@ private:
 
		this->avails.ForceRebuild();
 
		this->InvalidateData(GOID_NEWGRF_LIST_EDITED);
 
		return true;
 
	}
 
};
 

	
 
#if defined(ENABLE_NETWORK)
 
/**
 
 * Show the content list window with all missing grfs from the given list.
 
 * @param list The list of grfs to check for missing / not exactly matching ones.
 
 */
 
void ShowMissingContentWindow(const GRFConfig *list)
 
{
 
@@ -1562,13 +1559,12 @@ void ShowMissingContentWindow(const GRFC
 
		ci->unique_id = BSWAP32(c->ident.grfid);
 
		memcpy(ci->md5sum, HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum, sizeof(ci->md5sum));
 
		*cv.Append() = ci;
 
	}
 
	ShowNetworkContentListWindow(cv.Length() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF);
 
}
 
#endif
 

	
 
Listing NewGRFWindow::last_sorting     = {false, 0};
 
Filtering NewGRFWindow::last_filtering = {false, 0};
 

	
 
NewGRFWindow::GUIGRFConfigList::SortFunction * const NewGRFWindow::sorter_funcs[] = {
 
	&NameSorter,
src/openttd.cpp
Show inline comments
 
@@ -161,22 +161,20 @@ static void ShowHelp()
 
		"  -h                  = Display this help text\n"
 
		"  -t year             = Set starting year\n"
 
		"  -d [[fac=]lvl[,...]]= Debug mode\n"
 
		"  -e                  = Start Editor\n"
 
		"  -g [savegame]       = Start new/save game immediately\n"
 
		"  -G seed             = Set random seed\n"
 
#if defined(ENABLE_NETWORK)
 
		"  -n [ip:port#company]= Join network game\n"
 
		"  -p password         = Password to join server\n"
 
		"  -P password         = Password to join company\n"
 
		"  -D [ip][:port]      = Start dedicated server\n"
 
		"  -l ip[:port]        = Redirect DEBUG()\n"
 
#if !defined(_WIN32)
 
		"  -f                  = Fork into the background (dedicated only)\n"
 
#endif
 
#endif /* ENABLE_NETWORK */
 
		"  -I graphics_set     = Force the graphics set (see below)\n"
 
		"  -S sounds_set       = Force the sounds set (see below)\n"
 
		"  -M music_set        = Force the music set (see below)\n"
 
		"  -c config_file      = Use 'config_file' instead of 'openttd.cfg'\n"
 
		"  -x                  = Do not automatically save to config file on exit\n"
 
		"  -q savegame         = Write some information about the savegame and exit\n"
 
@@ -297,15 +295,13 @@ static void ShutdownGame()
 
	AI::Uninitialize(false);
 
	Game::Uninitialize(false);
 

	
 
	/* Uninitialize variables that are allocated dynamically */
 
	GamelogReset();
 

	
 
#ifdef ENABLE_NETWORK
 
	free(_config_file);
 
#endif
 

	
 
	LinkGraphSchedule::Clear();
 
	PoolBase::Clean(PT_ALL);
 

	
 
	/* No NewGRFs were loaded when it was still bootstrapping. */
 
	if (_game_mode != GM_BOOTSTRAP) ResetNewGRFData();
 
@@ -444,29 +440,26 @@ struct AfterNewGRFScan : NewGRFScanCallb
 
		/* restore saved music volume */
 
		MusicDriver::GetInstance()->SetVolume(_settings_client.music.music_vol);
 

	
 
		if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
 
		if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
 

	
 
#if defined(ENABLE_NETWORK)
 
		if (dedicated_host != NULL) {
 
			_network_bind_list.Clear();
 
			*_network_bind_list.Append() = stredup(dedicated_host);
 
		}
 
		if (dedicated_port != 0) _settings_client.network.server_port = dedicated_port;
 
#endif /* ENABLE_NETWORK */
 

	
 
		/* initialize the ingame console */
 
		IConsoleInit();
 
		InitializeGUI();
 
		IConsoleCmdExec("exec scripts/autoexec.scr 0");
 

	
 
		/* Make sure _settings is filled with _settings_newgame if we switch to a game directly */
 
		if (_switch_mode != SM_NONE) MakeNewgameSettingsLive();
 

	
 
#ifdef ENABLE_NETWORK
 
		if (_network_available && network_conn != NULL) {
 
			const char *port = NULL;
 
			const char *company = NULL;
 
			uint16 rport = NETWORK_DEFAULT_PORT;
 
			CompanyID join_as = COMPANY_NEW_COMPANY;
 

	
 
@@ -486,13 +479,12 @@ struct AfterNewGRFScan : NewGRFScanCallb
 
			if (port != NULL) rport = atoi(port);
 

	
 
			LoadIntroGame();
 
			_switch_mode = SM_NONE;
 
			NetworkClientConnectGame(NetworkAddress(network_conn, rport), join_as, join_server_password, join_company_password);
 
		}
 
#endif /* ENABLE_NETWORK */
 

	
 
		/* After the scan we're not used anymore. */
 
		delete this;
 
	}
 
};
 

	
 
@@ -506,22 +498,20 @@ static const OptionData _options[] = {
 
	 GETOPT_SHORT_VALUE('S'),
 
	 GETOPT_SHORT_VALUE('M'),
 
	 GETOPT_SHORT_VALUE('m'),
 
	 GETOPT_SHORT_VALUE('s'),
 
	 GETOPT_SHORT_VALUE('v'),
 
	 GETOPT_SHORT_VALUE('b'),
 
#if defined(ENABLE_NETWORK)
 
	GETOPT_SHORT_OPTVAL('D'),
 
	GETOPT_SHORT_OPTVAL('n'),
 
	 GETOPT_SHORT_VALUE('l'),
 
	 GETOPT_SHORT_VALUE('p'),
 
	 GETOPT_SHORT_VALUE('P'),
 
#if !defined(_WIN32)
 
	 GETOPT_SHORT_NOVAL('f'),
 
#endif
 
#endif /* ENABLE_NETWORK */
 
	 GETOPT_SHORT_VALUE('r'),
 
	 GETOPT_SHORT_VALUE('t'),
 
	GETOPT_SHORT_OPTVAL('d'),
 
	 GETOPT_SHORT_NOVAL('e'),
 
	GETOPT_SHORT_OPTVAL('g'),
 
	 GETOPT_SHORT_VALUE('G'),
 
@@ -548,19 +538,17 @@ int openttd_main(int argc, char *argv[])
 
	char *sounds_set = NULL;
 
	char *music_set = NULL;
 
	Dimension resolution = {0, 0};
 
	/* AfterNewGRFScan sets save_config to true after scanning completed. */
 
	bool save_config = false;
 
	AfterNewGRFScan *scanner = new AfterNewGRFScan(&save_config);
 
#if defined(ENABLE_NETWORK)
 
	bool dedicated = false;
 
	char *debuglog_conn = NULL;
 

	
 
	extern bool _dedicated_forks;
 
	_dedicated_forks = false;
 
#endif /* ENABLE_NETWORK */
 

	
 
	_game_mode = GM_MENU;
 
	_switch_mode = SM_MENU;
 
	_config_file = NULL;
 

	
 
	GetOptData mgo(argc - 1, argv + 1, _options);
 
@@ -573,13 +561,12 @@ int openttd_main(int argc, char *argv[])
 
		case 'S': free(sounds_set); sounds_set = stredup(mgo.opt); break;
 
		case 'M': free(music_set); music_set = stredup(mgo.opt); break;
 
		case 'm': free(musicdriver); musicdriver = stredup(mgo.opt); break;
 
		case 's': free(sounddriver); sounddriver = stredup(mgo.opt); break;
 
		case 'v': free(videodriver); videodriver = stredup(mgo.opt); break;
 
		case 'b': free(blitter); blitter = stredup(mgo.opt); break;
 
#if defined(ENABLE_NETWORK)
 
		case 'D':
 
			free(musicdriver);
 
			free(sounddriver);
 
			free(videodriver);
 
			free(blitter);
 
			musicdriver = stredup("null");
 
@@ -608,13 +595,12 @@ int openttd_main(int argc, char *argv[])
 
		case 'p':
 
			scanner->join_server_password = mgo.opt;
 
			break;
 
		case 'P':
 
			scanner->join_company_password = mgo.opt;
 
			break;
 
#endif /* ENABLE_NETWORK */
 
		case 'r': ParseResolution(&resolution, mgo.opt); break;
 
		case 't': scanner->startyear = atoi(mgo.opt); break;
 
		case 'd': {
 
#if defined(_WIN32)
 
				CreateConsole();
 
#endif
 
@@ -699,21 +685,19 @@ int openttd_main(int argc, char *argv[])
 
		goto exit_noshutdown;
 
	}
 

	
 
	DeterminePaths(argv[0]);
 
	TarScanner::DoScan(TarScanner::BASESET);
 

	
 
#if defined(ENABLE_NETWORK)
 
	if (dedicated) DEBUG(net, 0, "Starting dedicated version %s", _openttd_revision);
 
	if (_dedicated_forks && !dedicated) _dedicated_forks = false;
 

	
 
#if defined(UNIX)
 
	/* We must fork here, or we'll end up without some resources we need (like sockets) */
 
	if (_dedicated_forks) DedicatedFork();
 
#endif
 
#endif
 

	
 
	LoadFromConfig(true);
 

	
 
	if (resolution.width != 0) _cur_resolution = resolution;
 

	
 
	/*
 
@@ -784,26 +768,24 @@ int openttd_main(int argc, char *argv[])
 

	
 
	/* Initialize the zoom level of the screen to normal */
 
	_screen.zoom = ZOOM_LVL_NORMAL;
 

	
 
	NetworkStartUp(); // initialize network-core
 

	
 
#if defined(ENABLE_NETWORK)
 
	if (debuglog_conn != NULL && _network_available) {
 
		const char *not_used = NULL;
 
		const char *port = NULL;
 
		uint16 rport;
 

	
 
		rport = NETWORK_DEFAULT_DEBUGLOG_PORT;
 

	
 
		ParseConnectionString(&not_used, &port, debuglog_conn);
 
		if (port != NULL) rport = atoi(port);
 

	
 
		NetworkStartDebugLog(NetworkAddress(debuglog_conn, rport));
 
	}
 
#endif /* ENABLE_NETWORK */
 

	
 
	if (!HandleBootstrap()) {
 
		ShutdownGame();
 

	
 
		goto exit_bootstrap;
 
	}
 
@@ -900,18 +882,16 @@ exit_normal:
 
	free(_ini_sounddriver);
 
	free(_ini_videodriver);
 
	free(_ini_blitter);
 

	
 
	delete scanner;
 

	
 
#ifdef ENABLE_NETWORK
 
	extern FILE *_log_fd;
 
	if (_log_fd != NULL) {
 
		fclose(_log_fd);
 
	}
 
#endif /* ENABLE_NETWORK */
 

	
 
	return ret;
 
}
 

	
 
void HandleExitGameRequest()
 
{
 
@@ -954,19 +934,17 @@ static void MakeNewGameDone()
 
	IConsoleCmdExec("exec scripts/game_start.scr 0");
 

	
 
	SetLocalCompany(COMPANY_FIRST);
 

	
 
	InitializeRailGUI();
 

	
 
#ifdef ENABLE_NETWORK
 
	/* We are the server, we start a new company (not dedicated),
 
	 * so set the default password *if* needed. */
 
	if (_network_server && !StrEmpty(_settings_client.network.default_company_pass)) {
 
		NetworkChangeCompanyPassword(_local_company, _settings_client.network.default_company_pass);
 
	}
 
#endif /* ENABLE_NETWORK */
 

	
 
	if (_settings_client.gui.pause_on_newgame) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
 

	
 
	CheckEngines();
 
	CheckIndustries();
 
	MarkWholeScreenDirty();
 
@@ -1016,13 +994,12 @@ bool SafeLoad(const char *filename, Save
 
	_game_mode = newgm;
 

	
 
	switch (lf == NULL ? SaveOrLoad(filename, fop, dft, subdir) : LoadWithFilter(lf)) {
 
		case SL_OK: return true;
 

	
 
		case SL_REINIT:
 
#ifdef ENABLE_NETWORK
 
			if (_network_dedicated) {
 
				/*
 
				 * We need to reinit a network map...
 
				 * We can't simply load the intro game here as that game has many
 
				 * special cases which make clients desync immediately. So we fall
 
				 * back to just generating a new game with the current settings.
 
@@ -1032,13 +1009,12 @@ bool SafeLoad(const char *filename, Save
 
				return false;
 
			}
 
			if (_network_server) {
 
				/* We can't load the intro game as server, so disconnect first. */
 
				NetworkDisconnect();
 
			}
 
#endif /* ENABLE_NETWORK */
 

	
 
			switch (ogm) {
 
				default:
 
				case GM_MENU:   LoadIntroGame();      break;
 
				case GM_EDITOR: MakeNewEditorWorld(); break;
 
			}
 
@@ -1049,13 +1025,12 @@ bool SafeLoad(const char *filename, Save
 
			return false;
 
	}
 
}
 

	
 
void SwitchToMode(SwitchMode new_mode)
 
{
 
#ifdef ENABLE_NETWORK
 
	/* If we are saving something, the network stays in his current state */
 
	if (new_mode != SM_SAVE_GAME) {
 
		/* If the network is active, make it not-active */
 
		if (_networking) {
 
			if (_network_server && (new_mode == SM_LOAD_GAME || new_mode == SM_NEWGAME || new_mode == SM_RESTARTGAME)) {
 
				NetworkReboot();
 
@@ -1078,28 +1053,26 @@ void SwitchToMode(SwitchMode new_mode)
 
			} else {
 
				/* This client no longer wants to be a network-server */
 
				_is_network_server = false;
 
			}
 
		}
 
	}
 
#endif /* ENABLE_NETWORK */
 

	
 
	/* Make sure all AI controllers are gone at quitting game */
 
	if (new_mode != SM_SAVE_GAME) AI::KillAll();
 

	
 
	switch (new_mode) {
 
		case SM_EDITOR: // Switch to scenario editor
 
			MakeNewEditorWorld();
 
			break;
 

	
 
		case SM_RESTARTGAME: // Restart --> 'Random game' with current settings
 
		case SM_NEWGAME: // New Game --> 'Random game'
 
#ifdef ENABLE_NETWORK
 
			if (_network_server) {
 
				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
 
			ResetGRFConfig(true);
 
			ResetWindowSystem();
 
@@ -1116,27 +1089,23 @@ void SwitchToMode(SwitchMode new_mode)
 
				 * company #1 (eg 0) or in the case of a dedicated server a spectator */
 
				SetLocalCompany(_network_dedicated ? COMPANY_SPECTATOR : COMPANY_FIRST);
 
				/* 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) {
 
					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) {
 
				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
 
			SetLocalCompany(OWNER_NONE);
 

	
 
@@ -1448,16 +1417,14 @@ static void DoAutosave()
 
	}
 
}
 

	
 
void GameLoop()
 
{
 
	if (_game_mode == GM_BOOTSTRAP) {
 
#ifdef ENABLE_NETWORK
 
		/* Check for UDP stuff */
 
		if (_network_available) NetworkBackgroundLoop();
 
#endif
 
		InputLoop();
 
		return;
 
	}
 

	
 
	ProcessAsyncSaveFinish();
 

	
 
@@ -1474,13 +1441,12 @@ void GameLoop()
 
		_switch_mode = SM_NONE;
 
	}
 

	
 
	IncreaseSpriteLRU();
 
	InteractiveRandom();
 

	
 
#ifdef ENABLE_NETWORK
 
	/* Check for UDP stuff */
 
	if (_network_available) NetworkBackgroundLoop();
 

	
 
	if (_networking && !HasModalProgress()) {
 
		/* Multiplayer */
 
		NetworkGameLoop();
 
@@ -1490,15 +1456,12 @@ void GameLoop()
 
			 * We do this here, because it means that the network is really closed */
 
			NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), COMPANY_SPECTATOR);
 
		}
 
		/* Singleplayer */
 
		StateGameLoop();
 
	}
 
#else
 
	StateGameLoop();
 
#endif /* ENABLE_NETWORK */
 

	
 
	if (!_pause_mode && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations();
 

	
 
	InputLoop();
 

	
 
	SoundDriver::GetInstance()->MainLoop();
src/order_backup.cpp
Show inline comments
 
@@ -190,17 +190,13 @@ CommandCost CmdClearOrderBackup(TileInde
 
/* static */ void OrderBackup::Reset(TileIndex t, bool from_gui)
 
{
 
	/* The user has CLIENT_ID_SERVER as default when network play is not active,
 
	 * but compiled it. A network client has its own variable for the unique
 
	 * client/user identifier. Finally if networking isn't compiled in the
 
	 * default is just plain and simple: 0. */
 
#ifdef ENABLE_NETWORK
 
	uint32 user = _networking && !_network_server ? _network_own_client_id : CLIENT_ID_SERVER;
 
#else
 
	uint32 user = 0;
 
#endif
 

	
 
	OrderBackup *ob;
 
	FOR_ALL_ORDER_BACKUPS(ob) {
 
		/* If it's not an backup of us, so ignore it. */
 
		if (ob->user != user) continue;
 
		/* If it's not for our chosen tile either, ignore it. */
src/script/api/script_admin.cpp
Show inline comments
 
@@ -132,19 +132,17 @@
 
		return sq_throwerror(vm, "ScriptAdmin::Send requires a table as first parameter. No data sent.");
 
	}
 

	
 
	std::string json;
 
	ScriptAdmin::MakeJSON(vm, -1, SQUIRREL_MAX_DEPTH, json);
 

	
 
#ifdef ENABLE_NETWORK
 
	if (json.length() > NETWORK_GAMESCRIPT_JSON_LENGTH) {
 
		ScriptLog::Error("You are trying to send a table that is too large to the AdminPort. No data sent.");
 
		sq_pushinteger(vm, 0);
 
		return 1;
 
	}
 

	
 
	NetworkAdminGameScript(json.c_str());
 
#endif /* ENABLE_NETWORK */
 

	
 
	sq_pushinteger(vm, 1);
 
	return 1;
 
}
src/script/api/script_client.cpp
Show inline comments
 
@@ -13,62 +13,44 @@
 
#include "script_client.hpp"
 
#include "../../network/network.h"
 
#include "../../network/network_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
#ifdef ENABLE_NETWORK
 
/**
 
 * Finds NetworkClientInfo given client-identifier,
 
 *  is used by other methods to resolve client-identifier.
 
 * @param client The client to get info structure for
 
 * @return A pointer to corresponding CI struct or NULL when not found.
 
 */
 
static NetworkClientInfo *FindClientInfo(ScriptClient::ClientID client)
 
{
 
	if (client == ScriptClient::CLIENT_INVALID) return NULL;
 
	if (!_networking) return NULL;
 
	return NetworkClientInfo::GetByClientID((::ClientID)client);
 
}
 
#endif
 

	
 
/* static */ ScriptClient::ClientID ScriptClient::ResolveClientID(ScriptClient::ClientID client)
 
{
 
#ifdef ENABLE_NETWORK
 
	return (FindClientInfo(client) == NULL ? ScriptClient::CLIENT_INVALID : client);
 
#else
 
	return CLIENT_INVALID;
 
#endif
 
}
 

	
 
/* static */ char *ScriptClient::GetName(ScriptClient::ClientID client)
 
{
 
#ifdef ENABLE_NETWORK
 
	NetworkClientInfo *ci = FindClientInfo(client);
 
	if (ci == NULL) return NULL;
 
	return stredup(ci->client_name);
 
#else
 
	return NULL;
 
#endif
 
}
 

	
 
/* static */ ScriptCompany::CompanyID ScriptClient::GetCompany(ScriptClient::ClientID client)
 
{
 
#ifdef ENABLE_NETWORK
 
	NetworkClientInfo *ci = FindClientInfo(client);
 
	if (ci == NULL) return ScriptCompany::COMPANY_INVALID;
 
	return (ScriptCompany::CompanyID)ci->client_playas;
 
#else
 
	return ScriptCompany::COMPANY_INVALID;
 
#endif
 
}
 

	
 
/* static */ ScriptDate::Date ScriptClient::GetJoinDate(ScriptClient::ClientID client)
 
{
 
#ifdef ENABLE_NETWORK
 
	NetworkClientInfo *ci = FindClientInfo(client);
 
	if (ci == NULL) return ScriptDate::DATE_INVALID;
 
	return (ScriptDate::Date)ci->join_date;
 
#else
 
	return ScriptDate::DATE_INVALID;
 
#endif
 
}
src/script/api/script_clientlist.cpp
Show inline comments
 
@@ -16,24 +16,21 @@
 
#include "../../network/network_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptClientList::ScriptClientList()
 
{
 
#ifdef ENABLE_NETWORK
 
	if (!_networking) return;
 
	NetworkClientInfo *ci;
 
	FOR_ALL_CLIENT_INFOS(ci) {
 
		this->AddItem(ci->client_id);
 
	}
 
#endif
 
}
 

	
 
ScriptClientList_Company::ScriptClientList_Company(ScriptCompany::CompanyID company)
 
{
 
#ifdef ENABLE_NETWORK
 
	if (!_networking) return;
 
	CompanyID c;
 
	if (company == ScriptCompany::COMPANY_SPECTATOR) {
 
		c = ::COMPANY_SPECTATOR;
 
	} else {
 
		company = ScriptCompany::ResolveCompanyID(company);
 
@@ -42,8 +39,7 @@ ScriptClientList_Company::ScriptClientLi
 
	}
 

	
 
	NetworkClientInfo *ci;
 
	FOR_ALL_CLIENT_INFOS(ci) {
 
		if (ci->client_playas == c) this->AddItem(ci->client_id);
 
	}
 
#endif
 
}
src/script/api/script_game.cpp
Show inline comments
 
@@ -36,12 +36,8 @@
 
{
 
	return (ScriptGame::LandscapeType)_settings_game.game_creation.landscape;
 
}
 

	
 
/* static */ bool ScriptGame::IsMultiplayer()
 
{
 
#ifdef ENABLE_NETWORK
 
	return _network_server;
 
#else
 
	return false;
 
#endif
 
}
src/script/api/script_goal.cpp
Show inline comments
 
@@ -134,18 +134,14 @@
 
}
 

	
 
/* static */ bool ScriptGoal::QuestionClient(uint16 uniqueid, ScriptClient::ClientID client, Text *question, QuestionType type, int buttons)
 
{
 
	EnforcePrecondition(false, ScriptGame::IsMultiplayer());
 
	EnforcePrecondition(false, ScriptClient::ResolveClientID(client) != ScriptClient::CLIENT_INVALID);
 
#ifdef ENABLE_NETWORK
 
	ClientIndex c = NetworkClientInfo::GetByClientID((::ClientID)client)->index;
 
	return DoQuestion(uniqueid, c, true, question, type, buttons);
 
#else
 
	return false;
 
#endif
 
}
 

	
 
/* static */ bool ScriptGoal::CloseQuestion(uint16 uniqueid)
 
{
 
	EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
 

	
src/script/api/script_object.cpp
Show inline comments
 
@@ -298,16 +298,14 @@ ScriptObject::ActiveInstance::~ActiveIns
 
	/* Set the default callback to return a true/false result of the DoCommand */
 
	if (callback == NULL) callback = &ScriptInstance::DoCommandReturn;
 

	
 
	/* Are we only interested in the estimate costs? */
 
	bool estimate_only = GetDoCommandMode() != NULL && !GetDoCommandMode()();
 

	
 
#ifdef ENABLE_NETWORK
 
	/* Only set p2 when the command does not come from the network. */
 
	if (GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = UINT32_MAX;
 
#endif
 

	
 
	/* Try to perform the command. */
 
	CommandCost res = ::DoCommandPInternal(tile, p1, p2, cmd, (_networking && !_generating_world) ? ScriptObject::GetActiveInstance()->GetDoCommandCallback() : NULL, text, false, estimate_only);
 

	
 
	/* We failed; set the error and bail out */
 
	if (res.Failed()) {
src/script/script_scanner.cpp
Show inline comments
 
@@ -15,17 +15,15 @@
 
#include "../settings_type.h"
 

	
 
#include "../script/squirrel.hpp"
 
#include "script_scanner.hpp"
 
#include "script_info.hpp"
 

	
 
#if defined(ENABLE_NETWORK)
 
#include "../network/network_content.h"
 
#include "../3rdparty/md5/md5.h"
 
#include "../tar_type.h"
 
#endif /* ENABLE_NETWORK */
 

	
 
#include "../safeguards.h"
 

	
 
bool ScriptScanner::AddFile(const char *filename, size_t basepath_length, const char *tar_filename)
 
{
 
	free(this->main_script);
 
@@ -177,14 +175,12 @@ char *ScriptScanner::GetConsoleList(char
 
	}
 
	p += seprintf(p, last, "\n");
 

	
 
	return p;
 
}
 

	
 
#if defined(ENABLE_NETWORK)
 

	
 
/** Helper for creating a MD5sum of all files within of a script. */
 
struct ScriptFileChecksumCreator : FileScanner {
 
	byte md5sum[16];  ///< The final md5sum.
 
	Subdirectory dir; ///< The directory to look in.
 

	
 
	/**
 
@@ -284,8 +280,6 @@ const char *ScriptScanner::FindMainScrip
 
{
 
	for (ScriptInfoList::iterator it = this->info_list.begin(); it != this->info_list.end(); it++) {
 
		if (IsSameScript(ci, md5sum, (*it).second, this->GetDirectory())) return (*it).second->GetMainScript();
 
	}
 
	return NULL;
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/settings.cpp
Show inline comments
 
@@ -1336,15 +1336,12 @@ static bool InvalidateShipPathCache(int3
 
	FOR_ALL_SHIPS(s) {
 
		s->path.clear();
 
	}
 
	return true;
 
}
 

	
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
static bool UpdateClientName(int32 p1)
 
{
 
	NetworkUpdateClientName();
 
	return true;
 
}
 

	
 
@@ -1370,15 +1367,12 @@ static bool UpdateClientConfigValues(int
 
{
 
	if (_network_server) NetworkServerSendConfigUpdate();
 

	
 
	return true;
 
}
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 

	
 
/* End - Callback Functions */
 

	
 
/**
 
 * Prepare for reading and old diff_custom by zero-ing the memory.
 
 */
 
static void PrepareOldDiffCustom()
 
@@ -1702,17 +1696,15 @@ static void HandleSettingDescs(IniFile *
 

	
 
	if (other_settings) {
 
		proc(ini, _settings,         "patches",  &_settings_newgame);
 
		proc(ini, _currency_settings,"currency", &_custom_currency);
 
		proc(ini, _company_settings, "company",  &_settings_client.company);
 

	
 
#ifdef ENABLE_NETWORK
 
		proc_list(ini, "server_bind_addresses", &_network_bind_list);
 
		proc_list(ini, "servers", &_network_host_list);
 
		proc_list(ini, "bans",    &_network_ban_list);
 
#endif /* ENABLE_NETWORK */
 
	}
 
}
 

	
 
static IniFile *IniLoadConfig()
 
{
 
	IniFile *ini = new IniFile(_list_group_names);
 
@@ -2006,13 +1998,12 @@ void SetDefaultCompanySettings(CompanyID
 
	for (sd = _company_settings; sd->save.cmd != SL_END; sd++) {
 
		void *var = GetVariableAddress(&c->settings, &sd->save);
 
		Write_ValidateSetting(var, sd, (int32)(size_t)sd->desc.def);
 
	}
 
}
 

	
 
#if defined(ENABLE_NETWORK)
 
/**
 
 * Sync all company settings in a multiplayer game.
 
 */
 
void SyncCompanySettings()
 
{
 
	const SettingDesc *sd;
 
@@ -2022,13 +2013,12 @@ void SyncCompanySettings()
 
		const void *new_var = GetVariableAddress(&_settings_client.company, &sd->save);
 
		uint32 old_value = (uint32)ReadValue(old_var, sd->save.conv);
 
		uint32 new_value = (uint32)ReadValue(new_var, sd->save.conv);
 
		if (old_value != new_value) NetworkSendCommand(0, i, new_value, CMD_CHANGE_COMPANY_SETTING, NULL, NULL, _local_company);
 
	}
 
}
 
#endif /* ENABLE_NETWORK */
 

	
 
/**
 
 * Get the index in the _company_settings array of a setting
 
 * @param name The name of the setting
 
 * @return The index in the _company_settings array
 
 */
src/settings_func.h
Show inline comments
 
@@ -37,13 +37,9 @@ struct GRFConfig *LoadGRFPresetFromConfi
 
void SaveGRFPresetToConfig(const char *config_name, struct GRFConfig *config);
 
void DeleteGRFPresetFromConfig(const char *config_name);
 

	
 
uint GetCompanySettingIndex(const char *name);
 
void SetDefaultCompanySettings(CompanyID cid);
 

	
 
#if defined(ENABLE_NETWORK)
 
void SyncCompanySettings();
 
#else /* ENABLE_NETWORK */
 
static inline void SyncCompanySettings() {}
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* SETTINGS_FUNC_H */
src/settings_type.h
Show inline comments
 
@@ -151,17 +151,15 @@ struct GUISettings {
 
	uint16 console_backlog_timeout;          ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity.
 
	uint16 console_backlog_length;           ///< the minimum amount of items in the console backlog before items will be removed.
 

	
 
	uint8  station_gui_group_order;          ///< the order of grouping cargo entries in the station gui
 
	uint8  station_gui_sort_by;              ///< sort cargo entries in the station gui by station name or amount
 
	uint8  station_gui_sort_order;           ///< the sort order of entries in the station gui - ascending or descending
 
#ifdef ENABLE_NETWORK
 
	uint16 network_chat_box_width_pct;       ///< width of the chat box in percent
 
	uint8  network_chat_box_height;          ///< height of the chat box in lines
 
	uint16 network_chat_timeout;             ///< timeout of chat messages in seconds
 
#endif
 

	
 
	uint8  developer;                        ///< print non-fatal warnings in console (>= 1), copy debug output to console (== 2)
 
	bool   show_date_in_logs;                ///< whether to show dates in console logs
 
	bool   newgrf_developer_tools;           ///< activate NewGRF developer tools and allow modifying NewGRFs in an existing game
 
	bool   ai_developer_tools;               ///< activate AI developer tools
 
	bool   scenario_developer;               ///< activate scenario developer: allow modifying NewGRFs in an existing game
 
@@ -234,13 +232,12 @@ struct NewsSettings {
 
	uint8 subsidies;                                      ///< NewsDisplay of changes on subsidies
 
	uint8 general;                                        ///< NewsDisplay of other topics
 
};
 

	
 
/** All settings related to the network. */
 
struct NetworkSettings {
 
#ifdef ENABLE_NETWORK
 
	uint16 sync_freq;                                     ///< how often do we check whether we are still in-sync
 
	uint8  frame_freq;                                    ///< how often do we send commands to the clients
 
	uint16 commands_per_frame;                            ///< how many commands may be sent each frame_freq frames?
 
	uint16 max_commands_in_queue;                         ///< how many commands may there be in the incoming queue before dropping the connection?
 
	uint16 bytes_per_frame;                               ///< how many bytes may, over a long period, be received per frame?
 
	uint16 bytes_per_frame_burst;                         ///< how many bytes may, over a short period, be received?
 
@@ -274,14 +271,12 @@ struct NetworkSettings {
 
	uint8  min_active_clients;                            ///< minimum amount of active clients to unpause the game
 
	uint8  server_lang;                                   ///< language of the server
 
	bool   reload_cfg;                                    ///< reload the config file before restarting
 
	char   last_host[NETWORK_HOSTNAME_LENGTH];            ///< IP address of the last joined server
 
	uint16 last_port;                                     ///< port of the last joined server
 
	bool   no_http_content_downloads;                     ///< do not do content downloads over HTTP
 
#else /* ENABLE_NETWORK */
 
#endif
 
};
 

	
 
/** Settings related to the creation of games. */
 
struct GameCreationSettings {
 
	uint32 generation_seed;                  ///< noise seed for world generation
 
	Year   starting_year;                    ///< starting date
src/strings.cpp
Show inline comments
 
@@ -32,15 +32,13 @@
 
#include "string_func.h"
 
#include "company_base.h"
 
#include "smallmap_gui.h"
 
#include "window_func.h"
 
#include "debug.h"
 
#include "game/game_text.hpp"
 
#ifdef ENABLE_NETWORK
 
#	include "network/network_content_gui.h"
 
#endif /* ENABLE_NETWORK */
 
#include "network/network_content_gui.h"
 
#include <stack>
 

	
 
#include "table/strings.h"
 
#include "table/control_codes.h"
 

	
 
#include "safeguards.h"
 
@@ -1678,17 +1676,13 @@ static char *GetSpecialNameString(char *
 
		return buff;
 
	}
 

	
 
	NOT_REACHED();
 
}
 

	
 
#ifdef ENABLE_NETWORK
 
extern void SortNetworkLanguages();
 
#else /* ENABLE_NETWORK */
 
static inline void SortNetworkLanguages() {}
 
#endif /* ENABLE_NETWORK */
 

	
 
/**
 
 * Check whether the header is a valid header for OpenTTD.
 
 * @return true iff the header is deemed valid.
 
 */
 
bool LanguagePackHeader::IsValid() const
 
@@ -1818,15 +1812,13 @@ bool ReadLanguagePack(const LanguageMeta
 
	/* Some lists need to be sorted again after a language change. */
 
	ReconsiderGameScriptLanguage();
 
	InitializeSortedCargoSpecs();
 
	SortIndustryTypes();
 
	BuildIndustriesLegend();
 
	SortNetworkLanguages();
 
#ifdef ENABLE_NETWORK
 
	BuildContentTypeStringList();
 
#endif /* ENABLE_NETWORK */
 
	InvalidateWindowClassesData(WC_BUILD_VEHICLE);      // Build vehicle window.
 
	InvalidateWindowClassesData(WC_TRAINS_LIST);        // Train group window.
 
	InvalidateWindowClassesData(WC_ROADVEH_LIST);       // Road vehicle group window.
 
	InvalidateWindowClassesData(WC_SHIPS_LIST);         // Ship group window.
 
	InvalidateWindowClassesData(WC_AIRCRAFT_LIST);      // Aircraft group window.
 
	InvalidateWindowClassesData(WC_INDUSTRY_DIRECTORY); // Industry directory window.
src/table/gameopt_settings.ini
Show inline comments
 
@@ -18,15 +18,13 @@ static const char *_locale_currencies = 
 
static const char *_locale_units = "imperial|metric|si";
 
static const char *_town_names = "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovak|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan";
 
static const char *_climates = "temperate|arctic|tropic|toyland";
 
static const char *_autosave_interval = "off|monthly|quarterly|half year|yearly";
 
static const char *_roadsides = "left|right";
 
static const char *_savegame_date = "long|short|iso";
 
#ifdef ENABLE_NETWORK
 
static const char *_server_langs = "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN|AFRIKAANS|CROATIAN|CATALAN|ESTONIAN|GALICIAN|GREEK|LATVIAN";
 
#endif /* ENABLE_NETWORK */
 
static const char *_osk_activation = "disabled|double|single|immediately";
 
static const char *_settings_profiles = "easy|medium|hard";
 
static const char *_news_display = "off|summarized|full";
 

	
 
static const SettingDesc _gameopt_settings[] = {
 
/* In version 4 a new difficulty setting has been added to the difficulty settings,
src/table/settings.ini
Show inline comments
 
@@ -41,18 +41,17 @@ static bool RedrawTownAuthority(int32 p1
 
static bool InvalidateCompanyInfrastructureWindow(int32 p1);
 
static bool InvalidateCompanyWindow(int32 p1);
 
static bool ZoomMinMaxChanged(int32 p1);
 
static bool MaxVehiclesChanged(int32 p1);
 
static bool InvalidateShipPathCache(int32 p1);
 

	
 
#ifdef ENABLE_NETWORK
 
static bool UpdateClientName(int32 p1);
 
static bool UpdateServerPassword(int32 p1);
 
static bool UpdateRconPassword(int32 p1);
 
static bool UpdateClientConfigValues(int32 p1);
 
#endif /* ENABLE_NETWORK */
 

	
 
/* End - Callback Functions for the various settings */
 

	
 
/* Some settings do not need to be synchronised when playing in multiplayer.
 
 * These include for example the GUI settings and will not be saved with the
 
 * savegame.
 
 * It is also a bit tricky since you would think that service_interval
 
@@ -3562,413 +3561,370 @@ max      = 2
 
full     = _news_display
 
str      = STR_CONFIG_SETTING_NEWS_GENERAL_INFORMATION
 
strhelp  = STR_CONFIG_SETTING_NEWS_GENERAL_INFORMATION_HELPTEXT
 
strval   = STR_CONFIG_SETTING_NEWS_MESSAGES_OFF
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = gui.network_chat_box_width_pct
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = 40
 
min      = 10
 
max      = 100
 
cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = gui.network_chat_box_height
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = 25
 
min      = 5
 
max      = 255
 
cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = gui.network_chat_timeout
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = 20
 
min      = 1
 
max      = 65535
 
cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.sync_freq
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NOT_IN_CONFIG | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 100
 
min      = 0
 
max      = 100
 
cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.frame_freq
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NOT_IN_CONFIG | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 0
 
min      = 0
 
max      = 100
 
cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.commands_per_frame
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 2
 
min      = 1
 
max      = 65535
 
cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.max_commands_in_queue
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 16
 
min      = 1
 
max      = 65535
 
cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.bytes_per_frame
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 8
 
min      = 1
 
max      = 65535
 
cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.bytes_per_frame_burst
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 256
 
min      = 1
 
max      = 65535
 
cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.max_init_time
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 100
 
min      = 0
 
max      = 32000
 
cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.max_join_time
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 500
 
min      = 0
 
max      = 32000
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.max_download_time
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 1000
 
min      = 0
 
max      = 32000
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.max_password_time
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 2000
 
min      = 0
 
max      = 32000
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.max_lag_time
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 500
 
min      = 0
 
max      = 32000
 

	
 
[SDTC_BOOL]
 
ifdef    = ENABLE_NETWORK
 
var      = network.pause_on_join
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = true
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.server_port
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = NETWORK_DEFAULT_PORT
 
min      = 0
 
max      = 65535
 
cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.server_admin_port
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = NETWORK_ADMIN_PORT
 
min      = 0
 
max      = 65535
 
cat      = SC_EXPERT
 

	
 
[SDTC_BOOL]
 
ifdef    = ENABLE_NETWORK
 
var      = network.server_admin_chat
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = true
 
cat      = SC_EXPERT
 

	
 
[SDTC_BOOL]
 
ifdef    = ENABLE_NETWORK
 
var      = network.server_advertise
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = false
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.lan_internet
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 0
 
min      = 0
 
max      = 1
 

	
 
[SDTC_STR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.client_name
 
type     = SLE_STRB
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = NULL
 
proc     = UpdateClientName
 
cat      = SC_BASIC
 

	
 
[SDTC_STR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.server_password
 
type     = SLE_STRB
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = NULL
 
proc     = UpdateServerPassword
 
cat      = SC_BASIC
 

	
 
[SDTC_STR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.rcon_password
 
type     = SLE_STRB
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = NULL
 
proc     = UpdateRconPassword
 
cat      = SC_BASIC
 

	
 
[SDTC_STR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.admin_password
 
type     = SLE_STRB
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = NULL
 
cat      = SC_BASIC
 

	
 
[SDTC_STR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.default_company_pass
 
type     = SLE_STRB
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = NULL
 

	
 
[SDTC_STR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.server_name
 
type     = SLE_STRB
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = NULL
 
cat      = SC_BASIC
 

	
 
[SDTC_STR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.connect_to_ip
 
type     = SLE_STRB
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = NULL
 

	
 
[SDTC_STR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.network_id
 
type     = SLE_STRB
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = NULL
 

	
 
[SDTC_BOOL]
 
ifdef    = ENABLE_NETWORK
 
var      = network.autoclean_companies
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = false
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.autoclean_unprotected
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_0ISDISABLED | SGF_NETWORK_ONLY
 
def      = 12
 
min      = 0
 
max      = 240
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.autoclean_protected
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_0ISDISABLED | SGF_NETWORK_ONLY
 
def      = 36
 
min      = 0
 
max      = 240
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.autoclean_novehicles
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_0ISDISABLED | SGF_NETWORK_ONLY
 
def      = 0
 
min      = 0
 
max      = 240
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.max_companies
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 15
 
min      = 1
 
max      = MAX_COMPANIES
 
proc     = UpdateClientConfigValues
 
cat      = SC_BASIC
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.max_clients
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 25
 
min      = 2
 
max      = MAX_CLIENTS
 
cat      = SC_BASIC
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.max_spectators
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 15
 
min      = 0
 
max      = MAX_CLIENTS
 
proc     = UpdateClientConfigValues
 
cat      = SC_BASIC
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.restart_game_year
 
type     = SLE_INT32
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_0ISDISABLED | SGF_NETWORK_ONLY
 
def      = 0
 
min      = MIN_YEAR
 
max      = MAX_YEAR
 
interval = 1
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.min_active_clients
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 0
 
min      = 0
 
max      = MAX_CLIENTS
 

	
 
[SDTC_OMANY]
 
ifdef    = ENABLE_NETWORK
 
var      = network.server_lang
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 0
 
max      = 35
 
full     = _server_langs
 
cat      = SC_BASIC
 

	
 
[SDTC_BOOL]
 
ifdef    = ENABLE_NETWORK
 
var      = network.reload_cfg
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = false
 
cat      = SC_EXPERT
 

	
 
[SDTC_STR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.last_host
 
type     = SLE_STRB
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = """"
 
cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
ifdef    = ENABLE_NETWORK
 
var      = network.last_port
 
type     = SLE_UINT16
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = 0
 
min      = 0
 
max      = UINT16_MAX
 
cat      = SC_EXPERT
 

	
 
[SDTC_BOOL]
 
ifdef    = ENABLE_NETWORK
 
var      = network.no_http_content_downloads
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = false
 
cat      = SC_EXPERT
 

	
 
; Since the network code (CmdChangeSetting and friends) use the index in this array to decide
src/toolbar_gui.cpp
Show inline comments
 
@@ -155,17 +155,15 @@ public:
 

	
 
		int icon_offset = (bottom - top - icon_size.height) / 2;
 
		int text_offset = (bottom - top - FONT_HEIGHT_NORMAL) / 2;
 
		int lock_offset = (bottom - top - lock_size.height) / 2;
 

	
 
		DrawCompanyIcon(company, rtl ? right - this->icon_size.width - WD_FRAMERECT_RIGHT : left + WD_FRAMERECT_LEFT, top + icon_offset);
 
#ifdef ENABLE_NETWORK
 
		if (NetworkCompanyIsPassworded(company)) {
 
			DrawSprite(SPR_LOCK, PAL_NONE, rtl ? left + WD_FRAMERECT_LEFT : right - this->lock_size.width - WD_FRAMERECT_RIGHT, top + lock_offset);
 
		}
 
#endif
 

	
 
		SetDParam(0, company);
 
		SetDParam(1, company);
 
		TextColour col;
 
		if (this->greyed) {
 
			col = (sel ? TC_SILVER : TC_GREY) | TC_NO_SHADE;
 
@@ -220,24 +218,22 @@ static const int CTMN_SPECTATOR   = -4; 
 
static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
 
{
 
	DropDownList *list = new DropDownList();
 

	
 
	switch (widget) {
 
		case WID_TN_COMPANIES:
 
#ifdef ENABLE_NETWORK
 
			if (!_networking) break;
 

	
 
			/* Add the client list button for the companies menu */
 
			*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false);
 

	
 
			if (_local_company == COMPANY_SPECTATOR) {
 
				*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached());
 
			} else {
 
				*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, NetworkMaxSpectatorsReached());
 
			}
 
#endif /* ENABLE_NETWORK */
 
			break;
 

	
 
		case WID_TN_STORY:
 
			*list->Append() = new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false);
 
			break;
 

	
 
@@ -607,13 +603,12 @@ static CallBackFunction ToolbarCompanies
 
 *
 
 * @param index Menu entry to handle.
 
 * @return #CBF_NONE
 
 */
 
static CallBackFunction MenuClickCompany(int index)
 
{
 
#ifdef ENABLE_NETWORK
 
	if (_networking) {
 
		switch (index) {
 
			case CTMN_CLIENT_LIST:
 
				ShowClientList();
 
				return CBF_NONE;
 

	
 
@@ -632,13 +627,12 @@ static CallBackFunction MenuClickCompany
 
				} else {
 
					NetworkClientRequestMove(COMPANY_SPECTATOR);
 
				}
 
				return CBF_NONE;
 
		}
 
	}
 
#endif /* ENABLE_NETWORK */
 
	ShowCompany((CompanyID)index);
 
	return CBF_NONE;
 
}
 

	
 
/* --- Story button menu --- */
 

	
 
@@ -2073,15 +2067,13 @@ struct MainToolbarWindow : Window {
 
			case MTHK_ZOOMEDIN_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_ZOOMEDIN); break;
 
			case MTHK_DEFAULTZOOM_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_DEFAULTZOOM); break;
 
			case MTHK_GIANT_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_WORLD); break;
 
			case MTHK_CHEATS: if (!_networking) ShowCheatWindow(); break;
 
			case MTHK_TERRAFORM: ShowTerraformToolbar(); break;
 
			case MTHK_EXTRA_VIEWPORT: ShowExtraViewPortWindowForTileUnderCursor(); break;
 
#ifdef ENABLE_NETWORK
 
			case MTHK_CLIENT_LIST: if (_networking) ShowClientList(); break;
 
#endif
 
			case MTHK_SIGN_LIST: ShowSignList(); break;
 
			default: return ES_NOT_HANDLED;
 
		}
 
		return ES_HANDLED;
 
	}
 

	
 
@@ -2186,15 +2178,13 @@ static Hotkey maintoolbar_hotkeys[] = {
 
	Hotkey(WKC_CTRL  | 'P', "zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT),
 
	Hotkey(WKC_CTRL  | 'D', "defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT),
 
	Hotkey((uint16)0, "giant_screenshot", MTHK_GIANT_SCREENSHOT),
 
	Hotkey(WKC_CTRL | WKC_ALT | 'C', "cheats", MTHK_CHEATS),
 
	Hotkey('L', "terraform", MTHK_TERRAFORM),
 
	Hotkey('V', "extra_viewport", MTHK_EXTRA_VIEWPORT),
 
#ifdef ENABLE_NETWORK
 
	Hotkey((uint16)0, "client_list", MTHK_CLIENT_LIST),
 
#endif
 
	Hotkey((uint16)0, "sign_list", MTHK_SIGN_LIST),
 
	HOTKEY_LIST_END
 
};
 
HotkeyList MainToolbarWindow::hotkeys("maintoolbar", maintoolbar_hotkeys);
 

	
 
static NWidgetBase *MakeMainToolbar(int *biggest_index)
src/video/dedicated_v.cpp
Show inline comments
 
@@ -8,14 +8,12 @@
 
 */
 

	
 
/** @file dedicated_v.cpp Dedicated server video 'driver'. */
 

	
 
#include "../stdafx.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../gfx_func.h"
 
#include "../network/network.h"
 
#include "../network/network_internal.h"
 
#include "../console_func.h"
 
#include "../genworld.h"
 
#include "../fileio_type.h"
 
@@ -313,8 +311,6 @@ void VideoDriver_Dedicated::MainLoop()
 
			} else {
 
				CSleep(1);
 
			}
 
		}
 
	}
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/viewport.cpp
Show inline comments
 
@@ -3315,18 +3315,14 @@ CommandCost CmdScrollViewport(TileIndex 
 
		case VST_EVERYONE:
 
			break;
 
		case VST_COMPANY:
 
			if (_local_company != (CompanyID)p2) return CommandCost();
 
			break;
 
		case VST_CLIENT:
 
#ifdef ENABLE_NETWORK
 
			if (_network_own_client_id != (ClientID)p2) return CommandCost();
 
			break;
 
#else
 
			return CommandCost();
 
#endif
 
		default:
 
			return CMD_ERROR;
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		ResetObjectToPlace();
src/window.cpp
Show inline comments
 
@@ -3117,19 +3117,17 @@ void UpdateWindows()
 

	
 
	PerformanceMeasurer framerate(PFE_DRAWING);
 
	PerformanceAccumulator::Reset(PFE_DRAWWORLD);
 

	
 
	CallWindowRealtimeTickEvent(delta_ms);
 

	
 
#ifdef ENABLE_NETWORK
 
	static GUITimer network_message_timer = GUITimer(1);
 
	if (network_message_timer.Elapsed(delta_ms)) {
 
		network_message_timer.SetInterval(1000);
 
		NetworkChatMessageLoop();
 
	}
 
#endif
 

	
 
	Window *w;
 

	
 
	static GUITimer window_timer = GUITimer(1);
 
	if (window_timer.Elapsed(delta_ms)) {
 
		if (_network_dedicated) window_timer.SetInterval(MILLISECONDS_PER_TICK);
 
@@ -3440,16 +3438,15 @@ void ReInitAllWindows()
 
	InitDepotWindowBlockSizes();
 

	
 
	Window *w;
 
	FOR_ALL_WINDOWS_FROM_BACK(w) {
 
		w->ReInit();
 
	}
 
#ifdef ENABLE_NETWORK
 

	
 
	void NetworkReInitChatBoxSize();
 
	NetworkReInitChatBoxSize();
 
#endif
 

	
 
	/* Make sure essential parts of all windows are visible */
 
	RelocateAllWindows(_cur_resolution.width, _cur_resolution.height);
 
	MarkWholeScreenDirty();
 
}
 

	
0 comments (0 inline, 0 general)