Changeset - r15613:193c12018337
[Not reviewed]
master
! ! !
frosch - 14 years ago 2010-08-01 19:44:49
frosch@openttd.org
(svn r20286) -Codechange: Unify end of doxygen comments.
93 files changed with 424 insertions and 220 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_abstractlist.hpp
Show inline comments
 
@@ -215,13 +215,13 @@ public:
 
	 */
 
	void KeepBetweenValue(int32 start, int32 end);
 

	
 
	/**
 
	 * Keep all items with this value.
 
	 * @param value the value to keep.
 
	 **/
 
	 */
 
	void KeepValue(int32 value);
 

	
 
	/**
 
	 * Keep the first count items, i.e. remove everything except the first count items.
 
	 * @param count the amount of items to keep.
 
	 */
src/aircraft_cmd.cpp
Show inline comments
 
@@ -6,13 +6,14 @@
 
 * 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 aircraft_cmd.cpp
 
 * This file deals with aircraft and airport movements functionalities */
 
 * This file deals with aircraft and airport movements functionalities
 
 */
 

	
 
#include "stdafx.h"
 
#include "aircraft.h"
 
#include "debug.h"
 
#include "landscape.h"
 
#include "news_func.h"
 
@@ -70,13 +71,14 @@ void Aircraft::UpdateDeltaXY(Direction d
 
	this->y_extent      = GB(x, 24, 8);
 
}
 

	
 

	
 
/**
 
 * this maps the terminal to its corresponding state and block flag
 
 *  currently set for 10 terms, 4 helipads */
 
 *  currently set for 10 terms, 4 helipads
 
 */
 
static const byte _airport_terminal_state[] = {2, 3, 4, 5, 6, 7, 19, 20, 0, 0, 8, 9, 21, 22};
 
static const byte _airport_terminal_flag[] =  {0, 1, 2, 3, 4, 5, 22, 23, 0, 0, 6, 7, 24, 25};
 

	
 
static bool AirportMove(Aircraft *v, const AirportFTAClass *apc);
 
static bool AirportSetBlocks(Aircraft *v, const AirportFTA *current_pos, const AirportFTAClass *apc);
 
static bool AirportHasBlock(Aircraft *v, const AirportFTA *current_pos, const AirportFTAClass *apc);
 
@@ -140,13 +142,14 @@ static StationID FindNearestHangar(const
 
}
 

	
 
#if 0
 
/**
 
 * Check if given vehicle has a goto hangar in his orders
 
 * @param v vehicle to inquiry
 
 * @return true if vehicle v has an airport in the schedule, that has a hangar */
 
 * @return true if vehicle v has an airport in the schedule, that has a hangar
 
 */
 
static bool HaveHangarInOrderList(Aircraft *v)
 
{
 
	const Order *order;
 

	
 
	FOR_VEHICLE_ORDERS(v, order) {
 
		const Station *st = Station::Get(order->station);
src/airport.cpp
Show inline comments
 
@@ -227,13 +227,14 @@ AirportFTAClass::~AirportFTAClass()
 
	free(layout);
 
}
 

	
 
/**
 
 * Get the number of elements of a source Airport state automata
 
 * Since it is actually just a big array of AirportFTA types, we only
 
 * know one element from the other by differing 'position' identifiers */
 
 * know one element from the other by differing 'position' identifiers
 
 */
 
static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA)
 
{
 
	uint16 nofelements = 0;
 
	int temp = apFA[0].position;
 

	
 
	for (uint i = 0; i < MAX_ELEMENTS; i++) {
 
@@ -246,13 +247,14 @@ static uint16 AirportGetNofElements(cons
 
	return nofelements;
 
}
 

	
 
/**
 
 * We calculate the terminal/helipod count based on the data passed to us
 
 * This data (terminals) contains an index as a first element as to how many
 
 * groups there are, and then the number of terminals for each group */
 
 * groups there are, and then the number of terminals for each group
 
 */
 
static byte AirportGetTerminalCount(const byte *terminals, byte *groups)
 
{
 
	byte nof_terminals = 0;
 
	*groups = 0;
 

	
 
	if (terminals != NULL) {
src/autoreplace.cpp
Show inline comments
 
@@ -17,13 +17,14 @@
 

	
 
EngineRenewPool _enginerenew_pool("EngineRenew");
 
INSTANTIATE_POOL_METHODS(EngineRenew)
 

	
 
/**
 
 * Retrieves the EngineRenew that specifies the replacement of the given
 
 * engine type from the given renewlist */
 
 * engine type from the given renewlist
 
 */
 
static EngineRenew *GetEngineReplacement(EngineRenewList erl, EngineID engine, GroupID group)
 
{
 
	EngineRenew *er = (EngineRenew *)erl;
 

	
 
	while (er) {
 
		if (er->from == engine && er->group_id == group) return er;
src/core/enum_type.hpp
Show inline comments
 
@@ -78,13 +78,14 @@ struct MakeEnumPropsT {
 
 * In some cases we use byte or uint16 to store values that are defined as enum. It is
 
 *  necessary in order to control the sizeof() such values. Some compilers make enum
 
 *  the same size as int (4 or 8 bytes instead of 1 or 2). As a consequence the strict
 
 *  compiler type - checking causes errors like:
 
 *     'HasPowerOnRail' : cannot convert parameter 1 from 'byte' to 'RailType' when
 
 *  u->u.rail.railtype is passed as argument or type RailType. In such cases it is better
 
 *  to teach the compiler that u->u.rail.railtype is to be treated as RailType. */
 
 *  to teach the compiler that u->u.rail.railtype is to be treated as RailType.
 
 */
 
template <typename Tenum_t> struct TinyEnumT;
 

	
 
/** The general declaration of TinyEnumT<> (above) */
 
template <typename Tenum_t>
 
struct TinyEnumT {
 
	typedef Tenum_t enum_type;                      ///< expose our enumeration type (i.e. Trackdir) to outside
src/currency.cpp
Show inline comments
 
@@ -59,13 +59,13 @@ CurrencySpec _currency_specs[NUM_CURRENC
 

	
 
/**
 
 * These enums are only declared in order to make sens
 
 * out of the TTDPatch_To_OTTDIndex array that will follow
 
 * Every currency used by Ottd is there, just in case TTDPatch will
 
 * add those missing in its code
 
 **/
 
 */
 
enum Currencies {
 
	CURR_GBP,
 
	CURR_USD,
 
	CURR_EUR,
 
	CURR_YEN,
 
	CURR_ATS,
 
@@ -96,13 +96,13 @@ enum Currencies {
 

	
 
/**
 
 * This array represent the position of OpenTTD's currencies,
 
 * compared to TTDPatch's ones.
 
 * When a grf sends currencies, they are based on the order defined by TTDPatch.
 
 * So, we must reindex them to our own order.
 
 **/
 
 */
 
const byte TTDPatch_To_OTTDIndex[] =
 
{
 
	CURR_GBP,
 
	CURR_USD,
 
	CURR_FRF,
 
	CURR_DEM,
 
@@ -127,13 +127,13 @@ const byte TTDPatch_To_OTTDIndex[] =
 
 * Will return the ottd's index correspondance to
 
 * the ttdpatch's id.  If the id is bigger than the array,
 
 * it is a grf written for ottd, thus returning the same id.
 
 * Only called from newgrf.cpp
 
 * @param grfcurr_id currency id coming from newgrf
 
 * @return the corrected index
 
 **/
 
 */
 
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id)
 
{
 
	return (grfcurr_id >= lengthof(TTDPatch_To_OTTDIndex)) ? grfcurr_id : TTDPatch_To_OTTDIndex[grfcurr_id];
 
}
 

	
 
/**
 
@@ -155,13 +155,13 @@ uint GetMaskOfAllowedCurrencies()
 
	mask |= (1 << CUSTOM_CURRENCY_ID); // always allow custom currency
 
	return mask;
 
}
 

	
 
/**
 
 * Verify if the currency chosen by the user is about to be converted to Euro
 
 **/
 
 */
 
void CheckSwitchToEuro()
 
{
 
	if (_currency_specs[_settings_game.locale.currency].to_euro != CF_NOEURO &&
 
			_currency_specs[_settings_game.locale.currency].to_euro != CF_ISEURO &&
 
			_cur_year >= _currency_specs[_settings_game.locale.currency].to_euro) {
 
		_settings_game.locale.currency = 2; // this is the index of euro above.
 
@@ -174,13 +174,13 @@ void CheckSwitchToEuro()
 
 * default values from origin_currency_specs
 
 * Called only from newgrf.cpp and settings.cpp.
 
 * @param preserve_custom will not reset custom currency (the latest one on the list)
 
 *        if ever it is flagged to true. In which case, the total size of the memory to move
 
 *        will be one currency spec less, thus preserving the custom curreny from been
 
 *        overwritten.
 
 **/
 
 */
 
void ResetCurrencies(bool preserve_custom)
 
{
 
	memcpy(&_currency_specs, &origin_currency_specs, sizeof(origin_currency_specs) - (preserve_custom ? sizeof(_custom_currency) : 0));
 
}
 

	
 
/**
src/depot_gui.cpp
Show inline comments
 
@@ -158,13 +158,14 @@ static void TrainDepotMoveVehicle(const 
 

	
 
	DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE));
 
}
 

	
 
/**
 
 * Array containing the cell size in pixels of the #DEPOT_WIDGET_MATRIX widget for each vehicle type.
 
 * @note The train vehicle type uses the entire row for each train. */
 
 * @note The train vehicle type uses the entire row for each train.
 
 */
 
static Dimension _base_block_sizes[4];
 

	
 
static void InitBlocksizeForShipAircraft(VehicleType type)
 
{
 
	uint max_width  = 0;
 
	uint max_height = 0;
 
@@ -194,13 +195,14 @@ static void InitBlocksizeForShipAircraft
 
	}
 
	_base_block_sizes[type].height = max(GetVehicleHeight(type), max_height);
 
}
 

	
 
/**
 
 * Set the size of the blocks in the window so we can be sure that they are big enough for the vehicle sprites in the current game.
 
 * @note Calling this function once for each game is enough. */
 
 * @note Calling this function once for each game is enough.
 
 */
 
void InitDepotWindowBlockSizes()
 
{
 
	_base_block_sizes[VEH_TRAIN].width = 0;
 
	_base_block_sizes[VEH_TRAIN].height = GetVehicleHeight(VEH_TRAIN);
 

	
 
	_base_block_sizes[VEH_ROAD].width = 32;
src/disaster_cmd.cpp
Show inline comments
 
@@ -128,13 +128,14 @@ static void DisasterVehicleUpdateImage(D
 
	if (img == 0) img = _disaster_images[v->subtype][v->direction];
 
	v->cur_image = img;
 
}
 

	
 
/**
 
 * Initialize a disaster vehicle. These vehicles are of type VEH_DISASTER, are unclickable
 
 * and owned by nobody */
 
 * and owned by nobody
 
 */
 
static void InitializeDisasterVehicle(DisasterVehicle *v, int x, int y, byte z, Direction direction, byte subtype)
 
{
 
	v->x_pos = x;
 
	v->y_pos = y;
 
	v->z_pos = z;
 
	v->tile = TileVirtXY(x, y);
 
@@ -671,13 +672,14 @@ bool DisasterVehicle::Tick()
 

	
 
typedef void DisasterInitProc();
 

	
 

	
 
/**
 
 * Zeppeliner which crashes on a small airport if one found,
 
 * otherwise crashes on a random tile */
 
 * otherwise crashes on a random tile
 
 */
 
static void Disaster_Zeppeliner_Init()
 
{
 
	if (!Vehicle::CanAllocateItem(2)) return;
 

	
 
	/* Pick a random place, unless we find a small airport */
 
	int x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
 
@@ -700,13 +702,14 @@ static void Disaster_Zeppeliner_Init()
 
	u->vehstatus |= VS_SHADOW;
 
}
 

	
 

	
 
/**
 
 * Ufo which flies around aimlessly from the middle of the map a bit
 
 * until it locates a road vehicle which it targets and then destroys */
 
 * until it locates a road vehicle which it targets and then destroys
 
 */
 
static void Disaster_Small_Ufo_Init()
 
{
 
	if (!Vehicle::CanAllocateItem(2)) return;
 

	
 
	DisasterVehicle *v = new DisasterVehicle();
 
	int x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
 
@@ -847,13 +850,14 @@ static void Disaster_Big_Submarine_Init(
 
	Disaster_Submarine_Init(ST_BIG_SUBMARINE);
 
}
 

	
 

	
 
/**
 
 * Coal mine catastrophe, destroys a stretch of 30 tiles of
 
 * land in a certain direction */
 
 * land in a certain direction
 
 */
 
static void Disaster_CoalMine_Init()
 
{
 
	int index = GB(Random(), 0, 4);
 
	uint m;
 

	
 
	for (m = 0; m < 15; m++) {
src/economy.cpp
Show inline comments
 
@@ -159,13 +159,14 @@ Money CalculateCompanyValue(const Compan
 
/**
 
 * if update is set to true, the economy is updated with this score
 
 *  (also the house is updated, should only be true in the on-tick event)
 
 * @param update the economy with calculated score
 
 * @param c company been evaluated
 
 * @return actual score of this company
 
 * */
 
 *
 
 */
 
int UpdateCompanyRatingAndValue(Company *c, bool update)
 
{
 
	Owner owner = c->index;
 
	int score = 0;
 

	
 
	memset(_score_part[owner], 0, sizeof(_score_part[owner]));
src/endian_check.cpp
Show inline comments
 
@@ -12,13 +12,14 @@
 
 * This pretty simple file checks if the system is LITTLE_ENDIAN or BIG_ENDIAN
 
 *  it does that by putting a 1 and a 0 in an array, and read it out as one
 
 *  number. If it is 1, it is LITTLE_ENDIAN, if it is 256, it is BIG_ENDIAN
 
 *
 
 * After that it outputs the contents of an include files (endian.h)
 
 *  that says or TTD_LITTLE_ENDIAN, or TTD_BIG_ENDIAN. Makefile takes
 
 *  care of the real writing to the file. */
 
 *  care of the real writing to the file.
 
 */
 

	
 
#include <stdio.h>
 
#include <string.h>
 

	
 
/** Supported endian types */
 
enum Endian {
src/engine.cpp
Show inline comments
 
@@ -37,13 +37,14 @@ EnginePool _engine_pool("Engine");
 
INSTANTIATE_POOL_METHODS(Engine)
 

	
 
EngineOverrideManager _engine_mngr;
 

	
 
/**
 
 * Year that engine aging stops. Engines will not reduce in reliability
 
 * and no more engines will be introduced */
 
 * and no more engines will be introduced
 
 */
 
static Year _year_engine_aging_stops;
 

	
 
/** Number of engines of each vehicle type in original engine data */
 
const uint8 _engine_counts[4] = {
 
	lengthof(_orig_rail_vehicle_info),
 
	lengthof(_orig_road_vehicle_info),
src/fios_gui.cpp
Show inline comments
 
@@ -695,13 +695,14 @@ static const WindowDesc _save_dialog_des
 
	WDF_UNCLICK_BUTTONS,
 
	_nested_save_dialog_widgets, lengthof(_nested_save_dialog_widgets)
 
);
 

	
 
/**
 
 * These values are used to convert the file/operations mode into a corresponding file type.
 
 * So each entry, as expressed by the related comment, is based on the enum   */
 
 * So each entry, as expressed by the related comment, is based on the enum
 
 */
 
static const FileType _file_modetotype[] = {
 
	FT_SAVEGAME,  ///< used for SLD_LOAD_GAME
 
	FT_SCENARIO,  ///< used for SLD_LOAD_SCENARIO
 
	FT_SAVEGAME,  ///< used for SLD_SAVE_GAME
 
	FT_SCENARIO,  ///< used for SLD_SAVE_SCENARIO
 
	FT_HEIGHTMAP, ///< used for SLD_LOAD_HEIGHTMAP
src/fontcache.cpp
Show inline comments
 
@@ -41,13 +41,14 @@ FreeTypeSettings _freetype;
 

	
 
static const byte FACE_COLOUR   = 1;
 
static const byte SHADOW_COLOUR = 2;
 

	
 
/**
 
 * Get the font loaded into a Freetype face by using a font-name.
 
 * If no appropiate font is found, the function returns an error */
 
 * If no appropiate font is found, the function returns an error
 
 */
 
#ifdef WIN32
 
#include <windows.h>
 
#include <shlobj.h> /* SHGetFolderPath */
 
#include "os/windows/win32.h"
 

	
 
/**
src/gfx.cpp
Show inline comments
 
@@ -967,13 +967,14 @@ int DrawStringMultiLine(int left, int ri
 
 * in a single Dimension value. TINYFONT, BIGFONT modifiers are only
 
 * supported as the first character of the string. The returned dimensions
 
 * are therefore a rough estimation correct for all the current strings
 
 * but not every possible combination
 
 * @param str string to calculate pixel-width
 
 * @param start_fontsize Fontsize to start the text with
 
 * @return string width and height in pixels */
 
 * @return string width and height in pixels
 
 */
 
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
 
{
 
	FontSize size = start_fontsize;
 
	Dimension br;
 
	uint max_width;
 
	WChar c;
 
@@ -1723,13 +1724,14 @@ void MarkWholeScreenDirty()
 
 * for drawing
 
 * @param left,top,width,height the relative coordinates of the clipping
 
 * rectangle relative to the current _cur_dpi. This will most likely be the
 
 * offset from the calling window coordinates
 
 * @return return false if the requested rectangle is not possible with the
 
 * current dpi pointer. Only continue of the return value is true, or you'll
 
 * get some nasty results */
 
 * get some nasty results
 
 */
 
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
 
{
 
	Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
 
	const DrawPixelInfo *o = _cur_dpi;
 

	
 
	n->zoom = ZOOM_LVL_NORMAL;
src/highscore_gui.cpp
Show inline comments
 
@@ -217,22 +217,24 @@ static const WindowDesc _endgame_desc(
 
	_nested_highscore_widgets, lengthof(_nested_highscore_widgets)
 
);
 

	
 
/**
 
 * Show the highscore table for a given difficulty. When called from
 
 * endgame ranking is set to the top5 element that was newly added
 
 * and is thus highlighted */
 
 * and is thus highlighted
 
 */
 
void ShowHighscoreTable(int difficulty, int8 ranking)
 
{
 
	DeleteWindowByClass(WC_HIGHSCORE);
 
	new HighScoreWindow(&_highscore_desc, difficulty, ranking);
 
}
 

	
 
/**
 
 * Show the endgame victory screen in 2050. Update the new highscore
 
 * if it was high enough */
 
 * if it was high enough
 
 */
 
void ShowEndGameChart()
 
{
 
	/* Dedicated server doesn't need the highscore window and neither does -v null. */
 
	if (_network_dedicated || (!_networking && !Company::IsValidID(_local_company))) return;
 

	
 
	HideVitalWindows();
src/house.h
Show inline comments
 
@@ -17,23 +17,25 @@
 
#include "economy_type.h"
 
#include "date_type.h"
 
#include "house_type.h"
 

	
 
/**
 
 * Simple value that indicates the house has reached the final stage of
 
 * construction. */
 
 * construction.
 
 */
 
static const byte TOWN_HOUSE_COMPLETED = 3;
 

	
 
static const uint HOUSE_NO_CLASS      = 0;
 
static const HouseID NEW_HOUSE_OFFSET = 110;
 
static const HouseID HOUSE_MAX        = 512;
 
static const HouseID INVALID_HOUSE_ID = 0xFFFF;
 

	
 
/**
 
 * There can only be as many classes as there are new houses, plus one for
 
 * NO_CLASS, as the original houses don't have classes. */
 
 * NO_CLASS, as the original houses don't have classes.
 
 */
 
static const uint HOUSE_CLASS_MAX  = HOUSE_MAX - NEW_HOUSE_OFFSET + 1;
 

	
 
enum BuildingFlags {
 
	TILE_NO_FLAG         =       0,
 
	TILE_SIZE_1x1        = 1U << 0,
 
	TILE_NOT_SLOPED      = 1U << 1,
src/industry_cmd.cpp
Show inline comments
 
@@ -63,13 +63,14 @@ IndustrySpec _industry_specs[NUM_INDUSTR
 
IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES];
 

	
 
/**
 
 * This function initialize the spec arrays of both
 
 * industry and industry tiles.
 
 * It adjusts the enabling of the industry too, based on climate availability.
 
 * This will allow for clearer testings */
 
 * This will allow for clearer testings
 
 */
 
void ResetIndustries()
 
{
 
	memset(&_industry_specs, 0, sizeof(_industry_specs));
 
	memcpy(&_industry_specs, &_origin_industry_specs, sizeof(_origin_industry_specs));
 

	
 
	/* once performed, enable only the current climate industries */
 
@@ -90,13 +91,13 @@ void ResetIndustries()
 
 * Retrieve the type for this industry.  Although it is accessed by a tile,
 
 * it will return the general type of industry, and not the sprite index
 
 * as would do GetIndustryGfx.
 
 * @param tile that is queried
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 * @return general type for this industry, as defined in industry.h
 
 **/
 
 */
 
IndustryType GetIndustryType(TileIndex tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 

	
 
	const Industry *ind = Industry::GetByTile(tile);
 
	assert(ind != NULL);
 
@@ -107,13 +108,13 @@ IndustryType GetIndustryType(TileIndex t
 
 * Accessor for array _industry_specs.
 
 * This will ensure at once : proper access and
 
 * not allowing modifications of it.
 
 * @param thistype of industry (which is the index in _industry_specs)
 
 * @pre thistype < NUM_INDUSTRYTYPES
 
 * @return a pointer to the corresponding industry spec
 
 **/
 
 */
 
const IndustrySpec *GetIndustrySpec(IndustryType thistype)
 
{
 
	assert(thistype < NUM_INDUSTRYTYPES);
 
	return &_industry_specs[thistype];
 
}
 

	
 
@@ -121,13 +122,13 @@ const IndustrySpec *GetIndustrySpec(Indu
 
 * Accessor for array _industry_tile_specs.
 
 * This will ensure at once : proper access and
 
 * not allowing modifications of it.
 
 * @param gfx of industrytile (which is the index in _industry_tile_specs)
 
 * @pre gfx < INVALID_INDUSTRYTILE
 
 * @return a pointer to the corresponding industrytile spec
 
 **/
 
 */
 
const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx)
 
{
 
	assert(gfx < INVALID_INDUSTRYTILE);
 
	return &_industry_tile_specs[gfx];
 
}
 

	
 
@@ -1532,13 +1533,14 @@ static CommandCost CheckIfFarEnoughFromC
 
	return CommandCost();
 
}
 

	
 
/**
 
 * Production level maximum, minimum and default values.
 
 * It is not a value been really used in order to change, but rather an indicator
 
 * of how the industry is behaving. */
 
 * of how the industry is behaving.
 
 */
 
enum ProductionLevels {
 
	PRODLEVEL_CLOSURE = 0x00,  ///< signal set to actually close the industry
 
	PRODLEVEL_MINIMUM = 0x04,  ///< below this level, the industry is set to be closing
 
	PRODLEVEL_DEFAULT = 0x10,  ///< default level set when the industry is created
 
	PRODLEVEL_MAXIMUM = 0x80,  ///< the industry is running at full speed
 
};
src/landscape.cpp
Show inline comments
 
@@ -45,13 +45,14 @@ extern const TileTypeProcs
 
	_tile_type_tunnelbridge_procs,
 
	_tile_type_unmovable_procs;
 

	
 
/**
 
 * Tile callback functions for each type of tile.
 
 * @ingroup TileCallbackGroup
 
 * @see TileType */
 
 * @see TileType
 
 */
 
const TileTypeProcs * const _tile_type_procs[16] = {
 
	&_tile_type_clear_procs,        ///< Callback functions for MP_CLEAR tiles
 
	&_tile_type_rail_procs,         ///< Callback functions for MP_RAILWAY tiles
 
	&_tile_type_road_procs,         ///< Callback functions for MP_ROAD tiles
 
	&_tile_type_town_procs,         ///< Callback functions for MP_HOUSE tiles
 
	&_tile_type_trees_procs,        ///< Callback functions for MP_TREES tiles
 
@@ -72,13 +73,14 @@ extern const byte _slope_to_sprite_offse
 
/**
 
 * Description of the snow line throughout the year.
 
 *
 
 * If it is \c NULL, a static snowline height is used, as set by \c _settings_game.game_creation.snow_line.
 
 * Otherwise it points to a table loaded from a newGRF file, that describes the variable snowline
 
 * @ingroup SnowLineGroup
 
 * @see GetSnowLine() GameCreationSettings */
 
 * @see GetSnowLine() GameCreationSettings
 
 */
 
static SnowLine *_snow_line = NULL;
 

	
 
/**
 
 * Applies a foundation to a slope.
 
 *
 
 * @pre      Foundation and slope must be valid combined.
src/landscape.h
Show inline comments
 
@@ -17,13 +17,14 @@
 

	
 
static const uint SNOW_LINE_MONTHS = 12; ///< Number of months in the snow line table.
 
static const uint SNOW_LINE_DAYS   = 32; ///< Number of days in each month in the snow line table.
 

	
 
/**
 
 * Structure describing the height of the snow line each day of the year
 
 * @ingroup SnowLineGroup */
 
 * @ingroup SnowLineGroup
 
 */
 
struct SnowLine {
 
	byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]; ///< Height of the snow line each day of the year
 
	byte highest_value; ///< Highest snow line of the year
 
	byte lowest_value;  ///< Lowest snow line of the year
 
};
 

	
src/misc/array.hpp
Show inline comments
 
@@ -14,13 +14,14 @@
 

	
 
#include "fixedsizearray.hpp"
 
#include "str.hpp"
 

	
 
/**
 
 * Flexible array with size limit. Implemented as fixed size
 
 *  array of fixed size arrays */
 
 *  array of fixed size arrays
 
 */
 
template <class T, uint B = 1024, uint N = B>
 
class SmallArray {
 
protected:
 
	typedef FixedSizeArray<T, B> SubArray; ///< inner array
 
	typedef FixedSizeArray<SubArray, N> SuperArray; ///< outer array
 

	
src/misc/blob.hpp
Show inline comments
 
@@ -102,13 +102,14 @@ protected:
 
	{
 
		return (BlobHeader*)MallocT<byte>(num_bytes);
 
	}
 

	
 
	/**
 
	 * Return header pointer to the static BlobHeader with
 
	 * both items and capacity containing zero */
 
	 * both items and capacity containing zero
 
	 */
 
	static FORCEINLINE BlobHeader *Zero()
 
	{
 
		return const_cast<BlobHeader *>(&ByteBlob::hdrEmpty[1]);
 
	}
 

	
 
	/** simple allocation policy - can be optimized later */
 
@@ -232,23 +233,25 @@ public:
 
			memcpy(Append(src.Length()), src.Begin(), src.Length());
 
		}
 
	}
 

	
 
	/**
 
	 * Reallocate if there is no free space for num_bytes bytes.
 
	 *  @return pointer to the new data to be added */
 
	 *  @return pointer to the new data to be added
 
	 */
 
	FORCEINLINE byte *Prepare(size_t num_bytes)
 
	{
 
		size_t new_size = Length() + num_bytes;
 
		if (new_size > Capacity()) SmartAlloc(new_size);
 
		return data + Length();
 
	}
 

	
 
	/**
 
	 * Increase Length() by num_bytes.
 
	 *  @return pointer to the new data added */
 
	 *  @return pointer to the new data added
 
	 */
 
	FORCEINLINE byte *Append(size_t num_bytes)
 
	{
 
		byte *pNewData = Prepare(num_bytes);
 
		LengthRef() += num_bytes;
 
		return pNewData;
 
	}
 
@@ -294,13 +297,14 @@ public:
 
 * Blob - simple dynamic T array. T (template argument) is a placeholder for any type.
 
 *  T can be any integral type, pointer, or structure. Using Blob instead of just plain C array
 
 *  simplifies the resource management in several ways:
 
 *  1. When adding new item(s) it automatically grows capacity if needed.
 
 *  2. When variable of type Blob comes out of scope it automatically frees the data buffer.
 
 *  3. Takes care about the actual data size (number of used items).
 
 *  4. Dynamically constructs only used items (as opposite of static array which constructs all items) */
 
 *  4. Dynamically constructs only used items (as opposite of static array which constructs all items)
 
 */
 
template <typename T>
 
class CBlobT : public ByteBlob {
 
	/* make template arguments public: */
 
public:
 
	typedef ByteBlob base;
 

	
 
@@ -384,13 +388,14 @@ public:
 
	{
 
		return (T*)base::Append(num_items * type_size);
 
	}
 

	
 
	/**
 
	 * Ensures that given number of items can be added to the end of Blob. Returns pointer to the
 
	 *  first free (unused) item */
 
	 *  first free (unused) item
 
	 */
 
	FORCEINLINE T *MakeFreeSpace(size_t num_items)
 
	{
 
		return (T*)base::Prepare(num_items * type_size);
 
	}
 

	
 
	FORCEINLINE OnTransfer Transfer()
src/misc/fixedsizearray.hpp
Show inline comments
 
@@ -15,13 +15,14 @@
 
#include "../core/alloc_func.hpp"
 

	
 
/**
 
 * fixed size array
 
 *  Upon construction it preallocates fixed size block of memory
 
 *  for all items, but doesn't construct them. Item's construction
 
 *  is delayed. */
 
 *  is delayed.
 
 */
 
template <class T, uint C>
 
struct FixedSizeArray {
 
protected:
 
	/** header for fixed size array */
 
	struct ArrayHeader
 
	{
 
@@ -32,13 +33,14 @@ protected:
 
	/* make constants visible from outside */
 
	static const uint Tsize = sizeof(T);                // size of item
 
	static const uint HeaderSize = sizeof(ArrayHeader); // size of header
 

	
 
	/**
 
	 * the only member of fixed size array is pointer to the block
 
	 *  of C array of items. Header can be found on the offset -sizeof(ArrayHeader). */
 
	 *  of C array of items. Header can be found on the offset -sizeof(ArrayHeader).
 
	 */
 
	T *data;
 

	
 
	/** return reference to the array header (non-const) */
 
	FORCEINLINE ArrayHeader& Hdr() { return *(ArrayHeader*)(((byte*)data) - HeaderSize); }
 
	/** return reference to the array header (const) */
 
	FORCEINLINE const ArrayHeader& Hdr() const { return *(ArrayHeader*)(((byte*)data) - HeaderSize); }
src/misc/hashtable.hpp
Show inline comments
 
@@ -136,13 +136,14 @@ public:
 
	static const int Thash_bits = Thash_bits_;    // publish num of hash bits
 
	static const int Tcapacity = 1 << Thash_bits; // and num of slots 2^bits
 

	
 
protected:
 
	/**
 
	 * each slot contains pointer to the first item in the list,
 
	 *  Titem contains pointer to the next item - GetHashNext(), SetHashNext() */
 
	 *  Titem contains pointer to the next item - GetHashNext(), SetHashNext()
 
	 */
 
	typedef CHashTableSlotT<Titem_> Slot;
 

	
 
	Slot *m_slots;     // here we store our data (array of blobs)
 
	int   m_num_items; // item counter
 

	
 
public:
src/misc_gui.cpp
Show inline comments
 
@@ -1093,13 +1093,14 @@ bool MoveTextBufferPos(Textbuf *tb, int 
 
 * and the maximum length of this buffer
 
 * @param tb Textbuf type which is getting initialized
 
 * @param buf the buffer that will be holding the data for input
 
 * @param maxsize maximum size in bytes, including terminating '\0'
 
 * @param maxwidth maximum length in pixels of this buffer. If reached, buffer
 
 * cannot grow, even if maxsize would allow because there is space. Width
 
 * of zero '0' means the buffer is only restricted by maxsize */
 
 * of zero '0' means the buffer is only restricted by maxsize
 
 */
 
void InitializeTextBuffer(Textbuf *tb, char *buf, uint16 maxsize, uint16 maxwidth)
 
{
 
	assert(maxsize != 0);
 

	
 
	tb->buf      = buf;
 
	tb->maxsize  = maxsize;
src/music/allegro_m.cpp
Show inline comments
 
@@ -18,13 +18,14 @@
 

	
 
static FMusicDriver_Allegro iFMusicDriver_Allegro;
 
static MIDI *_midi = NULL;
 

	
 
/**
 
 * There are multiple modules that might be using Allegro and
 
 * Allegro can only be initiated once. */
 
 * Allegro can only be initiated once.
 
 */
 
extern int _allegro_instance_count;
 

	
 
const char *MusicDriver_Allegro::Start(const char * const *param)
 
{
 
	if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) {
 
		DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
src/network/core/packet.h
Show inline comments
 
@@ -34,13 +34,14 @@ typedef uint8  PacketType; ///< Identifi
 
struct Packet {
 
	/** The next packet. Used for queueing packets before sending. */
 
	Packet *next;
 
	/**
 
	 * The size of the whole packet for received packets. For packets
 
	 * that will be sent, the value is filled in just before the
 
	 * actual transmission. */
 
	 * actual transmission.
 
	 */
 
	PacketSize size;
 
	/** The current read/write position in the packet */
 
	PacketSize pos;
 
	/** The buffer of this packet */
 
	byte buffer[SEND_MTU];
 
private:
src/network/network.cpp
Show inline comments
 
@@ -474,13 +474,14 @@ static void CheckPauseOnJoin()
 
/**
 
 * Converts a string to ip/port/company
 
 *  Format: IP:port#company
 
 *
 
 * connection_string will be re-terminated to seperate out the hostname, and company and port will
 
 * be set to the company and port strings given by the user, inside the memory area originally
 
 * occupied by connection_string. */
 
 * occupied by connection_string.
 
 */
 
void ParseConnectionString(const char **company, const char **port, char *connection_string)
 
{
 
	bool ipv6 = (strchr(connection_string, ':') != strrchr(connection_string, ':'));
 
	char *p;
 
	for (p = connection_string; *p != '\0'; p++) {
 
		switch (*p) {
src/network/network_gamelist.cpp
Show inline comments
 
@@ -69,13 +69,14 @@ static void NetworkGameListHandleDelayed
 

	
 
/**
 
 * Add a new item to the linked gamelist. If the IP and Port match
 
 * return the existing item instead of adding it again
 
 * @param address the address of the to-be added item
 
 * @param port the port the server is running on
 
 * @return a point to the newly added or already existing item */
 
 * @return a point to the newly added or already existing item
 
 */
 
NetworkGameList *NetworkGameListAddItem(NetworkAddress address)
 
{
 
	const char *hostname = address.GetHostname();
 

	
 
	/* Do not query the 'any' address. */
 
	if (StrEmpty(hostname) ||
 
@@ -107,13 +108,14 @@ NetworkGameList *NetworkGameListAddItem(
 

	
 
	return item;
 
}
 

	
 
/**
 
 * Remove an item from the gamelist linked list
 
 * @param remove pointer to the item to be removed */
 
 * @param remove pointer to the item to be removed
 
 */
 
void NetworkGameListRemoveItem(NetworkGameList *remove)
 
{
 
	NetworkGameList *prev_item = NULL;
 
	for (NetworkGameList *item = _network_game_list; item != NULL; item = item->next) {
 
		if (remove == item) {
 
			if (prev_item == NULL) {
src/network/network_gui.cpp
Show inline comments
 
@@ -64,13 +64,14 @@ void SortNetworkLanguages()
 
	QSortT(_language_dropdown, NETLANG_COUNT - 1, &StringIDSorter);
 
}
 

	
 
/**
 
 * Update the network new window because a new server is
 
 * found on the network.
 
 * @param unselect unselect the currently selected item */
 
 * @param unselect unselect the currently selected item
 
 */
 
void UpdateNetworkGameWindow(bool unselect)
 
{
 
	InvalidateWindowData(WC_NETWORK_WINDOW, 0, unselect ? 1 : 0);
 
}
 

	
 
/** Enum for NetworkGameWindow, referring to _network_game_window_widgets */
 
@@ -280,13 +281,14 @@ protected:
 
		return strcasecmp((*a)->info.server_name, (*b)->info.server_name);
 
	}
 

	
 
	/**
 
	 * Sort servers by the amount of clients online on a
 
	 * server. If the two servers have the same amount, the one with the
 
	 * higher maximum is preferred. */
 
	 * higher maximum is preferred.
 
	 */
 
	static int CDECL NGameClientSorter(NetworkGameList * const *a, NetworkGameList * const *b)
 
	{
 
		/* Reverse as per default we are interested in most-clients first */
 
		int r = (*a)->info.clients_on - (*b)->info.clients_on;
 

	
 
		if (r == 0) r = (*a)->info.clients_max - (*b)->info.clients_max;
 
@@ -318,13 +320,14 @@ protected:
 
		int r = (*a)->info.game_date - (*a)->info.start_date - (*b)->info.game_date + (*b)->info.start_date;
 
		return (r != 0) ? r : NGameDateSorter(a, b);
 
	}
 

	
 
	/**
 
	 * Sort servers by joinability. If both servers are the
 
	 * same, prefer the non-passworded server first. */
 
	 * same, prefer the non-passworded server first.
 
	 */
 
	static int CDECL NGameAllowedSorter(NetworkGameList * const *a, NetworkGameList * const *b)
 
	{
 
		/* The servers we do not know anything about (the ones that did not reply) should be at the bottom) */
 
		int r = StrEmpty((*a)->info.server_revision) - StrEmpty((*b)->info.server_revision);
 

	
 
		/* Reverse default as we are interested in version-compatible clients first */
src/network/network_server.cpp
Show inline comments
 
@@ -1770,13 +1770,13 @@ void NetworkServerUpdateCompanyPassworde
 

	
 
/**
 
 * Handle the tid-bits of moving a client from one company to another.
 
 * @param client_id id of the client we want to move.
 
 * @param company_id id of the company we want to move the client to.
 
 * @return void
 
 **/
 
 */
 
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
 
{
 
	/* Only allow non-dedicated servers and normal clients to be moved */
 
	if (client_id == CLIENT_ID_SERVER && _network_dedicated) return;
 

	
 
	NetworkClientInfo *ci = NetworkFindClientInfoFromClientID(client_id);
src/newgrf.cpp
Show inline comments
 
@@ -227,13 +227,14 @@ static GRFLineToSpriteOverride _grf_line
 
 * Function is essentially the same as DEBUG(grf, severity, ...) with the
 
 * addition of file:line information when parsing grf files.
 
 * NOTE: for the above reason(s) grfmsg() should ONLY be used for
 
 * loading/parsing grf files, not for runtime debug messages as there
 
 * is no file information available during that time.
 
 * @param severity debugging severity level, see debug.h
 
 * @param str message in printf() format */
 
 * @param str message in printf() format
 
 */
 
void CDECL grfmsg(int severity, const char *str, ...)
 
{
 
	char buf[1024];
 
	va_list va;
 

	
 
	va_start(va, str);
 
@@ -6794,13 +6795,14 @@ static void InitNewGRFFile(const GRFConf
 
	*_grf_files.Append() = _cur_grffile = newfile;
 
}
 

	
 

	
 
/**
 
 * List of what cargo labels are refittable for the given the vehicle-type.
 
 * Only currently active labels are applied. */
 
 * Only currently active labels are applied.
 
 */
 
static const CargoLabel _default_refitmasks_rail[] = {
 
	'PASS', 'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD',
 
	'IORE', 'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE',
 
	'WATR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL',
 
	'PLST', 'FZDR',
 
	0 };
 
@@ -6930,13 +6932,14 @@ static void FinaliseCargoArray()
 
}
 

	
 
/**
 
 * Add all new houses to the house array. House properties can be set at any
 
 * time in the GRF file, so we can only add a house spec to the house array
 
 * after the file has finished loading. We also need to check the dates, due to
 
 * the TTDPatch behaviour described below that we need to emulate. */
 
 * the TTDPatch behaviour described below that we need to emulate.
 
 */
 
static void FinaliseHouseArray()
 
{
 
	/* If there are no houses with start dates before 1930, then all houses
 
	 * with start dates of 1930 have them reset to 0. This is in order to be
 
	 * compatible with TTDPatch, where if no houses have start dates before
 
	 * 1930 and the date is before 1930, the game pretends that this is 1930.
 
@@ -6995,13 +6998,14 @@ static void FinaliseHouseArray()
 
	}
 
}
 

	
 
/**
 
 * Add all new industries to the industry array. Industry properties can be set at any
 
 * time in the GRF file, so we can only add a industry spec to the industry array
 
 * after the file has finished loading. */
 
 * after the file has finished loading.
 
 */
 
static void FinaliseIndustriesArray()
 
{
 
	const GRFFile * const *end = _grf_files.End();
 
	for (GRFFile **file = _grf_files.Begin(); file != end; file++) {
 
		IndustrySpec **&industryspec = (*file)->industryspec;
 
		IndustryTileSpec **&indtspec = (*file)->indtspec;
src/newgrf_callbacks.h
Show inline comments
 
@@ -42,13 +42,14 @@ enum CallbackID {
 

	
 
	/** Choose a sprite layout to draw, instead of the standard 0-7 range. */
 
	CBID_STATION_SPRITE_LAYOUT           = 0x14,
 

	
 
	/**
 
	 * Refit capacity, the passed vehicle needs to have its ->cargo_type set to
 
	 * the cargo we are refitting to, returns the new cargo capacity. */
 
	 * the cargo we are refitting to, returns the new cargo capacity.
 
	 */
 
	CBID_VEHICLE_REFIT_CAPACITY          = 0x15, // 15 bit callback
 

	
 
	/** Builds articulated engines for trains and RVs. */
 
	CBID_VEHICLE_ARTIC_ENGINE            = 0x16, // 8 bit callback
 

	
 
	/** Determine whether the house can be built on the specified tile. */
 
@@ -86,13 +87,14 @@ enum CallbackID {
 

	
 
	/** Called to determine if the given industry type is available */
 
	CBID_INDUSTRY_AVAILABLE              = 0x22, // 15 bit callback
 

	
 
	/**
 
	 * This callback is called from vehicle purchase lists. It returns a value to be
 
	 * used as a custom string ID in the 0xD000 range. */
 
	 * used as a custom string ID in the 0xD000 range.
 
	 */
 
	CBID_VEHICLE_ADDITIONAL_TEXT         = 0x23,
 

	
 
	/** Called when building a station to customize the tile layout */
 
	CBID_STATION_TILE_LAYOUT             = 0x24, // 15 bit callback
 

	
 
	/** Called for periodically starting or stopping the animation. */
 
@@ -118,13 +120,14 @@ enum CallbackID {
 

	
 
	/** Called to determine which cargoes an industry should accept. */
 
	CBID_INDTILE_ACCEPT_CARGO            = 0x2C, // 15 bit callback
 

	
 
	/**
 
	 * Called to determine if a specific colour map should be used for a vehicle
 
	 * instead of the default livery. */
 
	 * instead of the default livery.
 
	 */
 
	CBID_VEHICLE_COLOUR_MAPPING          = 0x2D, // 15 bit callback
 

	
 
	/** Called to determine how much cargo a town building produces. */
 
	CBID_HOUSE_PRODUCE_CARGO             = 0x2E, // 15 bit callback
 

	
 
	/** Called to determine if the given industry tile can be built on specific tile. */
 
@@ -132,13 +135,14 @@ enum CallbackID {
 

	
 
	/** Called to determine the type (if any) of foundation to draw for industry tile. */
 
	CBID_INDTILE_DRAW_FOUNDATIONS        = 0x30, // 15 bit callback
 

	
 
	/**
 
	 * Called when the company (or AI) tries to start or stop a vehicle. Mainly
 
	 * used for preventing a vehicle from leaving the depot. */
 
	 * used for preventing a vehicle from leaving the depot.
 
	 */
 
	CBID_VEHICLE_START_STOP_CHECK        = 0x31, // 15 bit callback, but 0xFF test is done with 8 bit
 

	
 
	/** Called for every vehicle every 32 days (not all on same date though). */
 
	CBID_VEHICLE_32DAY_CALLBACK          = 0x32, // 2 bit callback
 

	
 
	/** Called to play a special sound effect */
 
@@ -149,13 +153,14 @@ enum CallbackID {
 

	
 
	/** Called monthly on production changes, so it can be adjusted more frequently */
 
	CBID_INDUSTRY_MONTHLYPROD_CHANGE     = 0x35, // 15 bit callback
 

	
 
	/**
 
	 * Called to modify various vehicle properties. Callback parameter 1
 
	 * specifies the property index, as used in Action 0, to change. */
 
	 * specifies the property index, as used in Action 0, to change.
 
	 */
 
	CBID_VEHICLE_MODIFY_PROPERTY         = 0x36, // 8/15 bit depends on queried property
 

	
 
	/** Called to determine text to display after cargo name */
 
	CBID_INDUSTRY_CARGO_SUFFIX           = 0x37, // 15 bit callback, but 0xFF test is done with 8 bit
 

	
 
	/** Called to determine more text in the fund industry window */
src/newgrf_canal.h
Show inline comments
 
@@ -15,13 +15,14 @@
 
#include "gfx_type.h"
 
#include "tile_type.h"
 
#include "newgrf_generic.h"
 

	
 
/**
 
 * List of different canal 'features'.
 
 * Each feature gets an entry in the canal spritegroup table */
 
 * Each feature gets an entry in the canal spritegroup table
 
 */
 
enum CanalFeature {
 
	CF_WATERSLOPE,
 
	CF_LOCKS,
 
	CF_DIKES,
 
	CF_ICON,
 
	CF_DOCKS,
src/newgrf_commons.cpp
Show inline comments
 
@@ -291,13 +291,14 @@ void IndustryTileOverrideManager::SetEnt
 
/**
 
 * Function used by houses (and soon industries) to get information
 
 * on type of "terrain" the tile it is queries sits on.
 
 * @param tile TileIndex of the tile been queried
 
 * @param upper_halftile If true, query upper halftile in case of rail tiles.
 
 * @return value corresponding to the grf expected format:
 
 *         Terrain type: 0 normal, 1 desert, 2 rainforest, 4 on or above snowline */
 
 *         Terrain type: 0 normal, 1 desert, 2 rainforest, 4 on or above snowline
 
 */
 
uint32 GetTerrainType(TileIndex tile, bool upper_halftile)
 
{
 
	switch (_settings_game.game_creation.landscape) {
 
		case LT_TROPIC: return GetTropicZone(tile);
 
		case LT_ARCTIC: {
 
			bool has_snow;
src/newgrf_config.cpp
Show inline comments
 
@@ -320,13 +320,14 @@ void ClearGRFConfigList(GRFConfig **conf
 

	
 
/**
 
 * Copy a GRF Config list
 
 * @param dst pointer to destination list
 
 * @param src pointer to source list values
 
 * @param init_only the copied GRF will be processed up to GLS_INIT
 
 * @return pointer to the last value added to the destination list */
 
 * @return pointer to the last value added to the destination list
 
 */
 
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only)
 
{
 
	/* Clear destination as it will be overwritten */
 
	ClearGRFConfigList(dst);
 
	for (; src != NULL; src = src->next) {
 
		GRFConfig *c = new GRFConfig(*src);
 
@@ -385,13 +386,14 @@ void AppendStaticGRFConfigs(GRFConfig **
 
	RemoveDuplicatesFromGRFConfigList(*dst);
 
}
 

	
 
/**
 
 * Appends an element to a list of GRFs
 
 * @param dst the head of the list to add to
 
 * @param el the new tail to be */
 
 * @param el the new tail to be
 
 */
 
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el)
 
{
 
	GRFConfig **tail = dst;
 
	while (*tail != NULL) tail = &(*tail)->next;
 
	*tail = el;
 

	
 
@@ -413,13 +415,14 @@ void ResetGRFConfig(bool defaults)
 
 * @return will return any of the following 3 values:<br>
 
 * <ul>
 
 * <li> GLC_ALL_GOOD: No problems occurred, all GRF files were found and loaded
 
 * <li> GLC_COMPATIBLE: For one or more GRF's no exact match was found, but a
 
 *     compatible GRF with the same grfid was found and used instead
 
 * <li> GLC_NOT_FOUND: For one or more GRF's no match was found at all
 
 * </ul> */
 
 * </ul>
 
 */
 
GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
 
{
 
	GRFListCompatibility res = GLC_ALL_GOOD;
 

	
 
	for (GRFConfig *c = grfconfig; c != NULL; c = c->next) {
 
		const GRFConfig *f = FindGRFConfig(c->ident.grfid, c->ident.md5sum);
src/newgrf_gui.cpp
Show inline comments
 
@@ -1528,12 +1528,13 @@ static void NewGRFConfirmationCallback(W
 
/**
 
 * Setup the NewGRF gui
 
 * @param editable allow the user to make changes to the grfconfig in the window
 
 * @param show_params show information about what parameters are set for the grf files
 
 * @param exec_changes if changes are made to the list (editable is true), apply these
 
 *        changes immediately or only update the list
 
 * @param config pointer to a linked-list of grfconfig's that will be shown */
 
 * @param config pointer to a linked-list of grfconfig's that will be shown
 
 */
 
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
 
{
 
	DeleteWindowByClass(WC_GAME_OPTIONS);
 
	new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config);
 
}
src/newgrf_industries.cpp
Show inline comments
 
@@ -158,13 +158,14 @@ static uint32 GetCountAndDistanceOfClose
 
/**
 
 * This function implements the industries variables that newGRF defines.
 
 * @param object the object that we want to query
 
 * @param variable that is queried
 
 * @param parameter unused
 
 * @param available will return false if ever the variable asked for does not exist
 
 * @return the value stored in the corresponding variable*/
 
 * @return the value stored in the corresponding variable
 
 */
 
uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
{
 
	const Industry *industry = object->u.industry.ind;
 
	TileIndex tile = object->u.industry.tile;
 
	IndustryType type = object->u.industry.type;
 
	const IndustrySpec *indspec = GetIndustrySpec(type);
src/newgrf_town.cpp
Show inline comments
 
@@ -16,13 +16,14 @@
 
/**
 
 * This function implements the town variables that newGRF defines.
 
 * @param variable that is queried
 
 * @param parameter unused
 
 * @param available will return false if ever the variable asked for does not exist
 
 * @param t is of course the town we are inquiring
 
 * @return the value stored in the corresponding variable*/
 
 * @return the value stored in the corresponding variable
 
 */
 
uint32 TownGetVariable(byte variable, byte parameter, bool *available, const Town *t)
 
{
 
	switch (variable) {
 
		/* Larger towns */
 
		case 0x40:
 
			if (_settings_game.economy.larger_towns == 0) return 2;
src/news_gui.cpp
Show inline comments
 
@@ -42,13 +42,14 @@ static NewsItem *_oldest_news = NULL;   
 
static NewsItem *_latest_news = NULL;       ///< tail of news items queue
 

	
 
/**
 
 * Forced news item.
 
 * Users can force an item by accessing the history or "last message".
 
 * If the message being shown was forced by the user, a pointer is stored
 
 * in _forced_news. Otherwise, \a _forced_news variable is NULL. */
 
 * in _forced_news. Otherwise, \a _forced_news variable is NULL.
 
 */
 
static const NewsItem *_forced_news = NULL;       ///< item the user has asked for
 

	
 
/** Current news item (last item shown regularly). */
 
static const NewsItem *_current_news = NULL;
 

	
 

	
src/openttd.cpp
Show inline comments
 
@@ -1273,13 +1273,14 @@ void StateGameLoop()
 

	
 
	assert(IsLocalCompany());
 
}
 

	
 
/**
 
 * Create an autosave. The default name is "autosave#.sav". However with
 
 * the setting 'keep_all_autosave' the name defaults to company-name + date */
 
 * the setting 'keep_all_autosave' the name defaults to company-name + date
 
 */
 
static void DoAutosave()
 
{
 
	char buf[MAX_PATH];
 

	
 
#if defined(PSP)
 
	/* Autosaving in networking is too time expensive for the PSP */
src/order_base.h
Show inline comments
 
@@ -311,31 +311,34 @@ public:
 
	 * @return the last order of the chain.
 
	 */
 
	inline Order *GetLastOrder() const { return this->GetOrderAt(this->num_orders - 1); }
 

	
 
	/**
 
	 * Get number of orders in the order list.
 
	 * @return number of orders in the chain. */
 
	 * @return number of orders in the chain.
 
	 */
 
	inline VehicleOrderID GetNumOrders() const { return this->num_orders; }
 

	
 
	/**
 
	 * Insert a new order into the order chain.
 
	 * @param new_order is the order to insert into the chain.
 
	 * @param index is the position where the order is supposed to be inserted. */
 
	 * @param index is the position where the order is supposed to be inserted.
 
	 */
 
	void InsertOrderAt(Order *new_order, int index);
 

	
 
	/**
 
	 * Remove an order from the order list and delete it.
 
	 * @param index is the position of the order which is to be deleted.
 
	 */
 
	void DeleteOrderAt(int index);
 

	
 
	/**
 
	 * Move an order to another position within the order list.
 
	 * @param from is the zero-based position of the order to move.
 
	 * @param to is the zero-based position where the order is moved to. */
 
	 * @param to is the zero-based position where the order is moved to.
 
	 */
 
	void MoveOrder(int from, int to);
 

	
 
	/**
 
	 * Is this a shared order list?
 
	 * @return whether this order list is shared among multiple vehicles
 
	 */
src/os/unix/unix.cpp
Show inline comments
 
@@ -126,13 +126,14 @@ const char *GetCurrentLocale(const char 
 

	
 
#define INTERNALCODE "UTF-8"
 

	
 
/**
 
 * Try and try to decipher the current locale from environmental
 
 * variables. MacOSX is hardcoded, other OS's are dynamic. If no suitable
 
 * locale can be found, don't do any conversion "" */
 
 * locale can be found, don't do any conversion ""
 
 */
 
static const char *GetLocalCode()
 
{
 
#if defined(__APPLE__)
 
	return "UTF-8-MAC";
 
#else
 
	/* Strip locale (eg en_US.UTF-8) to only have UTF-8 */
 
@@ -175,13 +176,14 @@ static const char *convert_tofrom_fs(ico
 
	return buf;
 
}
 

	
 
/**
 
 * Convert from OpenTTD's encoding to that of the local environment
 
 * @param name pointer to a valid string that will be converted
 
 * @return pointer to a new stringbuffer that contains the converted string */
 
 * @return pointer to a new stringbuffer that contains the converted string
 
 */
 
const char *OTTD2FS(const char *name)
 
{
 
	static iconv_t convd = (iconv_t)(-1);
 

	
 
	if (convd == (iconv_t)(-1)) {
 
		const char *env = GetLocalCode();
 
@@ -195,13 +197,14 @@ const char *OTTD2FS(const char *name)
 
	return convert_tofrom_fs(convd, name);
 
}
 

	
 
/**
 
 * Convert to OpenTTD's encoding from that of the local environment
 
 * @param name pointer to a valid string that will be converted
 
 * @return pointer to a new stringbuffer that contains the converted string */
 
 * @return pointer to a new stringbuffer that contains the converted string
 
 */
 
const char *FS2OTTD(const char *name)
 
{
 
	static iconv_t convd = (iconv_t)(-1);
 

	
 
	if (convd == (iconv_t)(-1)) {
 
		const char *env = GetLocalCode();
src/os/windows/win32.cpp
Show inline comments
 
@@ -41,13 +41,14 @@ bool MyShowCursor(bool show)
 
	return !show;
 
}
 

	
 
/**
 
 * Helper function needed by dynamically loading libraries
 
 * XXX: Hurray for MS only having an ANSI GetProcAddress function
 
 * on normal windows and no Wide version except for in Windows Mobile/CE */
 
 * on normal windows and no Wide version except for in Windows Mobile/CE
 
 */
 
bool LoadLibraryList(Function proc[], const char *dll)
 
{
 
	while (*dll != '\0') {
 
		HMODULE lib;
 
		lib = LoadLibrary(MB_TO_WIDE(dll));
 

	
 
@@ -564,13 +565,14 @@ void CSleep(int milliseconds)
 
 * OpenTTD internal encoding is UTF8.
 
 * The returned value's contents can only be guaranteed until the next call to
 
 * this function. So if the value is needed for anything else, use convert_from_fs
 
 * @param name pointer to a valid string that will be converted (local, or wide)
 
 * @return pointer to the converted string; if failed string is of zero-length
 
 * @see the current code-page comes from video\win32_v.cpp, event-notification
 
 * WM_INPUTLANGCHANGE */
 
 * WM_INPUTLANGCHANGE
 
 */
 
const char *FS2OTTD(const TCHAR *name)
 
{
 
	static char utf8_buf[512];
 
#if defined(UNICODE)
 
	return convert_from_fs(name, utf8_buf, lengthof(utf8_buf));
 
#else
 
@@ -601,13 +603,14 @@ const char *FS2OTTD(const TCHAR *name)
 
 * OpenTTD internal encoding is UTF8.
 
 * The returned value's contents can only be guaranteed until the next call to
 
 * this function. So if the value is needed for anything else, use convert_from_fs
 
 * @param name pointer to a valid string that will be converted (UTF8)
 
 * @return pointer to the converted string; if failed string is of zero-length
 
 * @see the current code-page comes from video\win32_v.cpp, event-notification
 
 * WM_INPUTLANGCHANGE */
 
 * WM_INPUTLANGCHANGE
 
 */
 
const TCHAR *OTTD2FS(const char *name)
 
{
 
	static TCHAR system_buf[512];
 
#if defined(UNICODE)
 
	return convert_to_fs(name, system_buf, lengthof(system_buf));
 
#else
 
@@ -635,13 +638,14 @@ const TCHAR *OTTD2FS(const char *name)
 
/**
 
 * Convert to OpenTTD's encoding from that of the environment in
 
 * UNICODE. OpenTTD encoding is UTF8, local is wide
 
 * @param name pointer to a valid string that will be converted
 
 * @param utf8_buf pointer to a valid buffer that will receive the converted string
 
 * @param buflen length in characters of the receiving buffer
 
 * @return pointer to utf8_buf. If conversion fails the string is of zero-length */
 
 * @return pointer to utf8_buf. If conversion fails the string is of zero-length
 
 */
 
char *convert_from_fs(const wchar_t *name, char *utf8_buf, size_t buflen)
 
{
 
	int len = WideCharToMultiByte(CP_UTF8, 0, name, -1, utf8_buf, (int)buflen, NULL, NULL);
 
	if (len == 0) {
 
		DEBUG(misc, 0, "[utf8] W2M error converting wide-string. Errno %lu", GetLastError());
 
		utf8_buf[0] = '\0';
 
@@ -655,13 +659,14 @@ char *convert_from_fs(const wchar_t *nam
 
 * Convert from OpenTTD's encoding to that of the environment in
 
 * UNICODE. OpenTTD encoding is UTF8, local is wide
 
 * @param name pointer to a valid string that will be converted
 
 * @param utf16_buf pointer to a valid wide-char buffer that will receive the
 
 * converted string
 
 * @param buflen length in wide characters of the receiving buffer
 
 * @return pointer to utf16_buf. If conversion fails the string is of zero-length */
 
 * @return pointer to utf16_buf. If conversion fails the string is of zero-length
 
 */
 
wchar_t *convert_to_fs(const char *name, wchar_t *utf16_buf, size_t buflen)
 
{
 
	int len = MultiByteToWideChar(CP_UTF8, 0, name, -1, utf16_buf, (int)buflen);
 
	if (len == 0) {
 
		DEBUG(misc, 0, "[utf8] M2W error converting '%s'. Errno %lu", name, GetLastError());
 
		utf16_buf[0] = '\0';
 
@@ -671,13 +676,14 @@ wchar_t *convert_to_fs(const char *name,
 
}
 

	
 
/**
 
 * Our very own SHGetFolderPath function for support of windows operating
 
 * systems that don't have this function (eg Win9x, etc.). We try using the
 
 * native function, and if that doesn't exist we will try a more crude approach
 
 * of environment variables and hope for the best */
 
 * of environment variables and hope for the best
 
 */
 
HRESULT OTTDSHGetFolderPath(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPTSTR pszPath)
 
{
 
	static HRESULT (WINAPI *SHGetFolderPath)(HWND, int, HANDLE, DWORD, LPTSTR) = NULL;
 
	static bool first_time = true;
 

	
 
	/* We only try to load the library one time; if it fails, it fails */
src/pathfinder/follow_track.hpp
Show inline comments
 
@@ -21,13 +21,14 @@
 
#include "../depot_map.h"
 
#include "pf_performance_timer.hpp"
 

	
 
/**
 
 * Track follower helper template class (can serve pathfinders and vehicle
 
 *  controllers). See 6 different typedefs below for 3 different transport
 
 *  types w/ or w/o 90-deg turns allowed */
 
 *  types w/ or w/o 90-deg turns allowed
 
 */
 
template <TransportType Ttr_type_, typename VehicleType, bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
 
struct CFollowTrackT
 
{
 
	enum ErrorCode {
 
		EC_NONE,
 
		EC_OWNER,
 
@@ -110,13 +111,14 @@ struct CFollowTrackT
 
		}
 
		return INVALID_DIAGDIR;
 
	}
 

	
 
	/**
 
	 * main follower routine. Fills all members and return true on success.
 
	 *  Otherwise returns false if track can't be followed. */
 
	 *  Otherwise returns false if track can't be followed.
 
	 */
 
	inline bool Follow(TileIndex old_tile, Trackdir old_td)
 
	{
 
		m_old_tile = old_tile;
 
		m_old_td = old_td;
 
		m_err = EC_NONE;
 
		assert(((TrackStatusToTrackdirBits(GetTileTrackStatus(m_old_tile, TT(), IsRoadTT() && m_veh != NULL ? RoadVehicle::From(m_veh)->compatible_roadtypes : 0)) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
src/pathfinder/npf/queue.h
Show inline comments
 
@@ -97,13 +97,14 @@ void init_InsSort(Queue *q);
 

	
 
/* The amount of elements that will be malloc'd at a time */
 
#define BINARY_HEAP_BLOCKSIZE_BITS 10
 

	
 
/**
 
 * Initializes a binary heap and allocates internal memory for maximum of
 
 * max_size elements */
 
 * max_size elements
 
 */
 
void init_BinaryHeap(Queue *q, uint max_size);
 

	
 

	
 
/*
 
 * Hash
 
 */
 
@@ -134,28 +135,32 @@ struct Hash {
 

	
 
/* Call these function to manipulate a hash */
 

	
 
/**
 
 * Deletes the value with the specified key pair from the hash and returns
 
 * that value. Returns NULL when the value was not present. The value returned
 
 * is _not_ free()'d! */
 
 * is _not_ free()'d!
 
 */
 
void *Hash_Delete(Hash *h, uint key1, uint key2);
 
/**
 
 * Sets the value associated with the given key pair to the given value.
 
 * Returns the old value if the value was replaced, NULL when it was not yet present. */
 
 * Returns the old value if the value was replaced, NULL when it was not yet present.
 
 */
 
void *Hash_Set(Hash *h, uint key1, uint key2, void *value);
 
/**
 
 * Gets the value associated with the given key pair, or NULL when it is not
 
 * present. */
 
 * present.
 
 */
 
void *Hash_Get(const Hash *h, uint key1, uint key2);
 

	
 
/* Call these function to create/destroy a hash */
 

	
 
/**
 
 * Builds a new hash in an existing struct. Make sure that hash() always
 
 * returns a hash less than num_buckets! Call delete_hash after use */
 
 * returns a hash less than num_buckets! Call delete_hash after use
 
 */
 
void init_Hash(Hash *h, Hash_HashProc *hash, uint num_buckets);
 
/**
 
 * Deletes the hash and cleans up. Only cleans up memory allocated by new_Hash
 
 * & friends. If free is true, it will call free() on all the values that
 
 * are left in the hash.
 
 */
src/pathfinder/opf/opf_ship.cpp
Show inline comments
 
@@ -178,13 +178,14 @@ bad:;
 
	return best_bird_dist;
 
}
 

	
 
/**
 
 * returns the track to choose on the next tile, or -1 when it's better to
 
 * reverse. The tile given is the tile we are about to enter, enterdir is the
 
 * direction in which we are entering the tile */
 
 * direction in which we are entering the tile
 
 */
 
Track OPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
 
{
 
	assert(IsValidDiagDirection(enterdir));
 

	
 
	TileIndex tile2 = TILE_ADD(tile, -TileOffsByDiagDir(enterdir));
 
	Track track;
src/pathfinder/yapf/nodelist.hpp
Show inline comments
 
@@ -16,13 +16,14 @@
 
#include "../../misc/hashtable.hpp"
 
#include "../../misc/binaryheap.hpp"
 

	
 
/**
 
 * Hash table based node list multi-container class.
 
 *  Implements open list, closed list and priority queue for A-star
 
 *  path finder. */
 
 *  path finder.
 
 */
 
template <class Titem_, int Thash_bits_open_, int Thash_bits_closed_>
 
class CNodeList_HashTableT {
 
public:
 
	/** make Titem_ visible from outside of class */
 
	typedef Titem_ Titem;
 
	/** make Titem_::Key a property of HashTable */
src/pathfinder/yapf/yapf_base.hpp
Show inline comments
 
@@ -113,13 +113,14 @@ public:
 
	 * Main pathfinder routine:
 
	 *   - set startup node(s)
 
	 *   - main loop that stops if:
 
	 *      - the destination was found
 
	 *      - or the open list is empty (no route to destination).
 
	 *      - or the maximum amount of loops reached - m_max_search_nodes (default = 10000)
 
	 * @return true if the path was found */
 
	 * @return true if the path was found
 
	 */
 
	inline bool FindPath(const VehicleType *v)
 
	{
 
		m_veh = v;
 

	
 
#ifndef NO_DEBUG_MESSAGES
 
		CPerformanceTimer perf;
 
@@ -220,13 +221,14 @@ public:
 
			Yapf().AddNewNode(n, tf);
 
		}
 
	}
 

	
 
	/**
 
	 * AddNewNode() - called by Tderived::PfFollowNode() for each child node.
 
	 *  Nodes are evaluated here and added into open list */
 
	 *  Nodes are evaluated here and added into open list
 
	 */
 
	void AddNewNode(Node &n, const TrackFollower &tf)
 
	{
 
		/* evaluate the node */
 
		bool bCached = Yapf().PfNodeCacheFetch(n);
 
		if (!bCached) {
 
			m_stats_cost_calcs++;
src/pathfinder/yapf/yapf_common.hpp
Show inline comments
 
@@ -145,13 +145,14 @@ public:
 
		bool bDest = (n.m_key.m_tile == m_destTile) && ((m_destTrackdirs & TrackdirToTrackdirBits(n.GetTrackdir())) != TRACKDIR_BIT_NONE);
 
		return bDest;
 
	}
 

	
 
	/**
 
	 * Called by YAPF to calculate cost estimate. Calculates distance to the destination
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate
 
	 */
 
	inline bool PfCalcEstimate(Node& n)
 
	{
 
		static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
 
		static const int dg_dir_to_y_offs[] = {0, 1, 0, -1};
 
		if (PfDetectDestination(n)) {
 
			n.m_estimate = n.m_cost;
 
@@ -176,13 +177,14 @@ public:
 
};
 

	
 
/**
 
 * YAPF template that uses Ttypes template argument to determine all YAPF
 
 *  components (base classes) from which the actual YAPF is composed.
 
 *  For example classes consult: CYapfRail_TypesT template and its instantiations:
 
 *  CYapfRail1, CYapfRail2, CYapfRail3, CYapfAnyDepotRail1, CYapfAnyDepotRail2, CYapfAnyDepotRail3 */
 
 *  CYapfRail1, CYapfRail2, CYapfRail3, CYapfAnyDepotRail1, CYapfAnyDepotRail2, CYapfAnyDepotRail3
 
 */
 
template <class Ttypes>
 
class CYapfT
 
	: public Ttypes::PfBase         ///< Instance of CYapfBaseT - main YAPF loop and support base class
 
	, public Ttypes::PfCost         ///< Cost calculation provider base class
 
	, public Ttypes::PfCache        ///< Segment cost cache provider
 
	, public Ttypes::PfOrigin       ///< Origin (tile or two-tile origin)
src/pathfinder/yapf/yapf_costcache.hpp
Show inline comments
 
@@ -25,21 +25,23 @@ class CYapfSegmentCostCacheNoneT
 
public:
 
	typedef typename Types::Tpf Tpf;              ///< the pathfinder class (derived from THIS class)
 
	typedef typename Types::NodeList::Titem Node; ///< this will be our node type
 

	
 
	/**
 
	 * Called by YAPF to attach cached or local segment cost data to the given node.
 
	 *  @return true if globally cached data were used or false if local data was used */
 
	 *  @return true if globally cached data were used or false if local data was used
 
	 */
 
	FORCEINLINE bool PfNodeCacheFetch(Node& n)
 
	{
 
		return false;
 
	}
 

	
 
	/**
 
	 * Called by YAPF to flush the cached segment cost data back into cache storage.
 
	 *  Current cache implementation doesn't use that. */
 
	 *  Current cache implementation doesn't use that.
 
	 */
 
	FORCEINLINE void PfNodeCacheFlush(Node& n)
 
	{
 
	}
 
};
 

	
 

	
 
@@ -68,35 +70,38 @@ protected:
 
		return *static_cast<Tpf*>(this);
 
	}
 

	
 
public:
 
	/**
 
	 * Called by YAPF to attach cached or local segment cost data to the given node.
 
	 *  @return true if globally cached data were used or false if local data was used */
 
	 *  @return true if globally cached data were used or false if local data was used
 
	 */
 
	FORCEINLINE bool PfNodeCacheFetch(Node& n)
 
	{
 
		CacheKey key(n.GetKey());
 
		Yapf().ConnectNodeToCachedData(n, *new (m_local_cache.Append()) CachedData(key));
 
		return false;
 
	}
 

	
 
	/**
 
	 * Called by YAPF to flush the cached segment cost data back into cache storage.
 
	 *  Current cache implementation doesn't use that. */
 
	 *  Current cache implementation doesn't use that.
 
	 */
 
	FORCEINLINE void PfNodeCacheFlush(Node& n)
 
	{
 
	}
 
};
 

	
 

	
 
/**
 
 * Base class for segment cost cache providers. Contains global counter
 
 *  of track layout changes and static notification function called whenever
 
 *  the track layout changes. It is implemented as base class because it needs
 
 *  to be shared between all rail YAPF types (one shared counter, one notification
 
 *  function. */
 
 *  function.
 
 */
 
struct CSegmentCostCacheBase
 
{
 
	static int   s_rail_change_counter;
 

	
 
	static void NotifyTrackLayoutChange(TileIndex tile, Track track)
 
	{
 
@@ -110,13 +115,14 @@ struct CSegmentCostCacheBase
 
 *  of Tsegment structures. Each rail node contains pointer to the segment
 
 *  that contains cached (or non-cached) segment cost information. Nodes can
 
 *  differ by key type, but they use the same segment type. Segment key should
 
 *  be always the same (TileIndex + DiagDirection) that represent the beginning
 
 *  of the segment (origin tile and exit-dir from this tile).
 
 *  Different CYapfCachedCostT types can share the same type of CSegmentCostCacheT.
 
 *  Look at CYapfRailSegment (yapf_node_rail.hpp) for the segment example */
 
 *  Look at CYapfRailSegment (yapf_node_rail.hpp) for the segment example
 
 */
 
template <class Tsegment>
 
struct CSegmentCostCacheT
 
	: public CSegmentCostCacheBase
 
{
 
	static const int C_HASH_BITS = 14;
 

	
 
@@ -200,13 +206,14 @@ protected:
 
		return C;
 
	}
 

	
 
public:
 
	/**
 
	 * Called by YAPF to attach cached or local segment cost data to the given node.
 
	 *  @return true if globally cached data were used or false if local data was used */
 
	 *  @return true if globally cached data were used or false if local data was used
 
	 */
 
	FORCEINLINE bool PfNodeCacheFetch(Node& n)
 
	{
 
		if (!Yapf().CanUseGlobalCache(n)) {
 
			return Tlocal::PfNodeCacheFetch(n);
 
		}
 
		CacheKey key(n.GetKey());
 
@@ -215,13 +222,14 @@ public:
 
		Yapf().ConnectNodeToCachedData(n, item);
 
		return found;
 
	}
 

	
 
	/**
 
	 * Called by YAPF to flush the cached segment cost data back into cache storage.
 
	 *  Current cache implementation doesn't use that. */
 
	 *  Current cache implementation doesn't use that.
 
	 */
 
	FORCEINLINE void PfNodeCacheFlush(Node& n)
 
	{
 
	}
 
};
 

	
 
#endif /* YAPF_COSTCACHE_HPP */
src/pathfinder/yapf/yapf_costrail.hpp
Show inline comments
 
@@ -276,13 +276,14 @@ public:
 
		m_max_cost = max_cost;
 
	}
 

	
 
	/**
 
	 * Called by YAPF to calculate the cost from the origin to the given node.
 
	 *  Calculates only the cost of given node, adds it to the parent node cost
 
	 *  and stores the result into Node::m_cost member */
 
	 *  and stores the result into Node::m_cost member
 
	 */
 
	FORCEINLINE bool PfCalcCost(Node &n, const TrackFollower *tf)
 
	{
 
		assert(!n.flags_u.flags_s.m_targed_seen);
 
		assert(tf->m_new_tile == n.m_key.m_tile);
 
		assert((TrackdirToTrackdirBits(n.m_key.m_td) & tf->m_new_td_bits) != TRACKDIR_BIT_NONE);
 

	
src/pathfinder/yapf/yapf_destrail.hpp
Show inline comments
 
@@ -62,13 +62,14 @@ public:
 
		bool bDest = IsRailDepotTile(tile);
 
		return bDest;
 
	}
 

	
 
	/**
 
	 * Called by YAPF to calculate cost estimate. Calculates distance to the destination
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate
 
	 */
 
	FORCEINLINE bool PfCalcEstimate(Node& n)
 
	{
 
		n.m_estimate = n.m_cost;
 
		return true;
 
	}
 
};
 
@@ -102,13 +103,14 @@ public:
 
			IsSafeWaitingPosition(Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns()) &&
 
			IsWaitingPositionFree(Yapf().GetVehicle(), tile, td, !TrackFollower::Allow90degTurns());
 
	}
 

	
 
	/**
 
	 * Called by YAPF to calculate cost estimate. Calculates distance to the destination
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate. */
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate.
 
	 */
 
	FORCEINLINE bool PfCalcEstimate(Node& n)
 
	{
 
		n.m_estimate = n.m_cost;
 
		return true;
 
	}
 
};
 
@@ -182,13 +184,14 @@ public:
 
		}
 
		return bDest;
 
	}
 

	
 
	/**
 
	 * Called by YAPF to calculate cost estimate. Calculates distance to the destination
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate
 
	 */
 
	FORCEINLINE bool PfCalcEstimate(Node& n)
 
	{
 
		static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
 
		static const int dg_dir_to_y_offs[] = {0, 1, 0, -1};
 
		if (PfDetectDestination(n)) {
 
			n.m_estimate = n.m_cost;
src/pathfinder/yapf/yapf_rail.cpp
Show inline comments
 
@@ -201,13 +201,14 @@ protected:
 
	}
 

	
 
public:
 
	/**
 
	 * Called by YAPF to move from the given node to the next tile. For each
 
	 *  reachable trackdir on the new tile creates new node, initializes it
 
	 *  and adds it to the open list by calling Yapf().AddNewNode(n) */
 
	 *  and adds it to the open list by calling Yapf().AddNewNode(n)
 
	 */
 
	inline void PfFollowNode(Node& old_node)
 
	{
 
		TrackFollower F(Yapf().GetVehicle());
 
		if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir())) {
 
			Yapf().AddMultipleNodes(&old_node, F);
 
		}
 
@@ -296,13 +297,14 @@ protected:
 
	}
 

	
 
public:
 
	/**
 
	 * Called by YAPF to move from the given node to the next tile. For each
 
	 *  reachable trackdir on the new tile creates new node, initializes it
 
	 *  and adds it to the open list by calling Yapf().AddNewNode(n) */
 
	 *  and adds it to the open list by calling Yapf().AddNewNode(n)
 
	 */
 
	inline void PfFollowNode(Node& old_node)
 
	{
 
		TrackFollower F(Yapf().GetVehicle(), Yapf().GetCompatibleRailTypes());
 
		if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir()) && F.MaskReservedTracks()) {
 
			Yapf().AddMultipleNodes(&old_node, F);
 
		}
 
@@ -378,13 +380,14 @@ protected:
 
	}
 

	
 
public:
 
	/**
 
	 * Called by YAPF to move from the given node to the next tile. For each
 
	 *  reachable trackdir on the new tile creates new node, initializes it
 
	 *  and adds it to the open list by calling Yapf().AddNewNode(n) */
 
	 *  and adds it to the open list by calling Yapf().AddNewNode(n)
 
	 */
 
	inline void PfFollowNode(Node& old_node)
 
	{
 
		TrackFollower F(Yapf().GetVehicle());
 
		if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir())) {
 
			Yapf().AddMultipleNodes(&old_node, F);
 
		}
src/pathfinder/yapf/yapf_road.cpp
Show inline comments
 
@@ -95,13 +95,14 @@ protected:
 
	}
 

	
 
public:
 
	/**
 
	 * Called by YAPF to calculate the cost from the origin to the given node.
 
	 *  Calculates only the cost of given node, adds it to the parent node cost
 
	 *  and stores the result into Node::m_cost member */
 
	 *  and stores the result into Node::m_cost member
 
	 */
 
	FORCEINLINE bool PfCalcCost(Node& n, const TrackFollower *tf)
 
	{
 
		int segment_cost = 0;
 
		/* start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment */
 
		TileIndex tile = n.m_key.m_tile;
 
		Trackdir trackdir = n.m_key.m_td;
 
@@ -186,13 +187,14 @@ public:
 
	{
 
		return IsRoadDepotTile(tile);
 
	}
 

	
 
	/**
 
	 * Called by YAPF to calculate cost estimate. Calculates distance to the destination
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate
 
	 */
 
	FORCEINLINE bool PfCalcEstimate(Node& n)
 
	{
 
		n.m_estimate = n.m_cost;
 
		return true;
 
	}
 
};
 
@@ -255,13 +257,14 @@ public:
 

	
 
		return tile == m_destTile && ((m_destTrackdirs & TrackdirToTrackdirBits(trackdir)) != TRACKDIR_BIT_NONE);
 
	}
 

	
 
	/**
 
	 * Called by YAPF to calculate cost estimate. Calculates distance to the destination
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate
 
	 */
 
	inline bool PfCalcEstimate(Node& n)
 
	{
 
		static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
 
		static const int dg_dir_to_y_offs[] = {0, 1, 0, -1};
 
		if (PfDetectDestination(n)) {
 
			n.m_estimate = n.m_cost;
 
@@ -305,13 +308,14 @@ protected:
 

	
 
public:
 

	
 
	/**
 
	 * Called by YAPF to move from the given node to the next tile. For each
 
	 *  reachable trackdir on the new tile creates new node, initializes it
 
	 *  and adds it to the open list by calling Yapf().AddNewNode(n) */
 
	 *  and adds it to the open list by calling Yapf().AddNewNode(n)
 
	 */
 
	inline void PfFollowNode(Node& old_node)
 
	{
 
		TrackFollower F(Yapf().GetVehicle());
 
		if (F.Follow(old_node.m_segment_last_tile, old_node.m_segment_last_td)) {
 
			Yapf().AddMultipleNodes(&old_node, F);
 
		}
src/pathfinder/yapf/yapf_ship.cpp
Show inline comments
 
@@ -32,13 +32,14 @@ protected:
 
	}
 

	
 
public:
 
	/**
 
	 * Called by YAPF to move from the given node to the next tile. For each
 
	 *  reachable trackdir on the new tile creates new node, initializes it
 
	 *  and adds it to the open list by calling Yapf().AddNewNode(n) */
 
	 *  and adds it to the open list by calling Yapf().AddNewNode(n)
 
	 */
 
	inline void PfFollowNode(Node& old_node)
 
	{
 
		TrackFollower F(Yapf().GetVehicle());
 
		if (F.Follow(old_node.m_key.m_tile, old_node.m_key.m_td)) {
 
			Yapf().AddMultipleNodes(&old_node, F);
 
		}
 
@@ -116,13 +117,14 @@ protected:
 
	}
 

	
 
public:
 
	/**
 
	 * Called by YAPF to calculate the cost from the origin to the given node.
 
	 *  Calculates only the cost of given node, adds it to the parent node cost
 
	 *  and stores the result into Node::m_cost member */
 
	 *  and stores the result into Node::m_cost member
 
	 */
 
	FORCEINLINE bool PfCalcCost(Node& n, const TrackFollower *tf)
 
	{
 
		/* base tile cost depending on distance */
 
		int c = IsDiagonalTrackdir(n.GetTrackdir()) ? YAPF_TILE_LENGTH : YAPF_TILE_CORNER_LENGTH;
 
		/* additional penalty for curves */
 
		if (n.m_parent != NULL && n.GetTrackdir() != NextTrackdir(n.m_parent->GetTrackdir())) {
src/rail.h
Show inline comments
 
@@ -98,13 +98,14 @@ enum RailFenceOffset {
 
/**
 
 * This struct contains all the info that is needed to draw and construct tracks.
 
 */
 
struct RailtypeInfo {
 
	/**
 
	 * Struct containing the main sprites. @note not all sprites are listed, but only
 
	 *  the ones used directly in the code */
 
	 *  the ones used directly in the code
 
	 */
 
	struct {
 
		SpriteID track_y;      ///< single piece of rail in Y direction, with ground
 
		SpriteID track_ns;     ///< two pieces of rail in North and South corner (East-West direction)
 
		SpriteID ground;       ///< ground sprite for a 3-way switch
 
		SpriteID single_x;     ///< single piece of rail in X direction, without ground
 
		SpriteID single_y;     ///< single piece of rail in Y direction, without ground
 
@@ -116,13 +117,14 @@ struct RailtypeInfo {
 
		SpriteID crossing;     ///< level crossing, rail in X direction
 
		SpriteID tunnel;       ///< tunnel sprites base
 
	} base_sprites;
 

	
 
	/**
 
	 * struct containing the sprites for the rail GUI. @note only sprites referred to
 
	 * directly in the code are listed */
 
	 * directly in the code are listed
 
	 */
 
	struct {
 
		SpriteID build_ns_rail;      ///< button for building single rail in N-S direction
 
		SpriteID build_x_rail;       ///< button for building single rail in X direction
 
		SpriteID build_ew_rail;      ///< button for building single rail in E-W direction
 
		SpriteID build_y_rail;       ///< button for building single rail in Y direction
 
		SpriteID auto_rail;          ///< button for the autorail construction
src/rail_cmd.cpp
Show inline comments
 
@@ -2155,13 +2155,14 @@ static void DrawTrackBits(TileInfo *ti, 
 

	
 
/**
 
 * Enums holding the offsets from base signal sprite,
 
 * according to the side it is representing.
 
 * The addtion of 2 per enum is necessary in order to "jump" over the
 
 * green state sprite, all signal sprites being in pair,
 
 * starting with the off-red state */
 
 * starting with the off-red state
 
 */
 
enum SignalOffsets {
 
	SIGNAL_TO_SOUTHWEST =  0,
 
	SIGNAL_TO_NORTHEAST =  2,
 
	SIGNAL_TO_SOUTHEAST =  4,
 
	SIGNAL_TO_NORTHWEST =  6,
 
	SIGNAL_TO_EAST      =  8,
 
@@ -2717,13 +2718,14 @@ int TicksToLeaveDepot(const Train *v)
 

	
 
	return 0; // make compilers happy
 
}
 

	
 
/**
 
 * Tile callback routine when vehicle enters tile
 
 * @see vehicle_enter_tile_proc */
 
 * @see vehicle_enter_tile_proc
 
 */
 
static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *u, TileIndex tile, int x, int y)
 
{
 
	/* this routine applies only to trains in depot tiles */
 
	if (u->type != VEH_TRAIN || !IsRailDepotTile(tile)) return VETSB_CONTINUE;
 

	
 
	Train *v = Train::From(u);
src/saveload/afterload.cpp
Show inline comments
 
@@ -2156,13 +2156,14 @@ bool AfterLoadGame()
 
/**
 
 * Reload all NewGRF files during a running game. This is a cut-down
 
 * version of AfterLoadGame().
 
 * XXX - We need to reset the vehicle position hash because with a non-empty
 
 * hash AfterLoadVehicles() will loop infinitely. We need AfterLoadVehicles()
 
 * to recalculate vehicle data as some NewGRF vehicle sets could have been
 
 * removed or added and changed statistics */
 
 * removed or added and changed statistics
 
 */
 
void ReloadNewGRFData()
 
{
 
	/* reload grf data */
 
	GfxLoadSprites();
 
	LoadStringWidthTable();
 
	RecomputePrices();
src/saveload/airport_sl.cpp
Show inline comments
 
@@ -13,13 +13,14 @@
 
#include "../newgrf_commons.h"
 

	
 
#include "saveload.h"
 

	
 
/**
 
 * Save and load the mapping between the airport id in the AirportSpec array
 
 * and the grf file it came from. */
 
 * and the grf file it came from.
 
 */
 
static const SaveLoad _airport_id_mapping_desc[] = {
 
	SLE_VAR(EntityIDMapping, grfid,         SLE_UINT32),
 
	SLE_VAR(EntityIDMapping, entity_id,     SLE_UINT8),
 
	SLE_VAR(EntityIDMapping, substitute_id, SLE_UINT8),
 
	SLE_END()
 
};
src/saveload/saveload.cpp
Show inline comments
 
@@ -1249,13 +1249,14 @@ static inline bool SlIsObjectValidInSave
 
	return true;
 
}
 

	
 
/**
 
 * Are we going to load this variable when loading a savegame or not?
 
 * @note If the variable is skipped it is skipped in the savegame
 
 * bytestream itself as well, so there is no need to skip it somewhere else */
 
 * bytestream itself as well, so there is no need to skip it somewhere else
 
 */
 
static inline bool SlSkipVariableOnLoad(const SaveLoad *sld)
 
{
 
	if ((sld->conv & SLF_NETWORK_NO) && _sl.action != SLA_SAVE && _networking && !_network_server) {
 
		SlSkipBytes(SlCalcConvMemLen(sld->conv) * sld->length);
 
		return true;
 
	}
 
@@ -1890,13 +1891,13 @@ static void WriteZlibLoop(z_streamp z, b
 
		/**
 
		 * For the poor next soul who sees many valgrind warnings of the
 
		 * "Conditional jump or move depends on uninitialised value(s)" kind:
 
		 * According to the author of zlib it is not a bug and it won't be fixed.
 
		 * http://groups.google.com/group/comp.compression/browse_thread/thread/b154b8def8c2a3ef/cdf9b8729ce17ee2
 
		 * [Mark Adler, Feb 24 2004, 'zlib-1.2.1 valgrind warnings' in the newgroup comp.compression]
 
		 **/
 
		 */
 
		r = deflate(z, mode);
 

	
 
		/* bytes were emitted? */
 
		if ((n = sizeof(buf) - z->avail_out) != 0) {
 
			if (fwrite(buf, n, 1, _sl.fh) != 1) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE);
 
		}
src/saveload/saveload.h
Show inline comments
 
@@ -97,13 +97,14 @@ enum ChunkType {
 
/**
 
 * VarTypes is the general bitmasked magic type that tells us
 
 * certain characteristics about the variable it refers to. For example
 
 * SLE_FILE_* gives the size(type) as it would be in the savegame and
 
 * SLE_VAR_* the size(type) as it is in memory during runtime. These are
 
 * the first 8 bits (0-3 SLE_FILE, 4-7 SLE_VAR).
 
 * Bits 8-15 are reserved for various flags as explained below */
 
 * Bits 8-15 are reserved for various flags as explained below
 
 */
 
enum VarTypes {
 
	/* 4 bits allocated a maximum of 16 types for NumberType */
 
	SLE_FILE_I8       = 0,
 
	SLE_FILE_U8       = 1,
 
	SLE_FILE_I16      = 2,
 
	SLE_FILE_U16      = 3,
 
@@ -270,13 +271,14 @@ static inline bool CheckSavegameVersion(
 
	extern uint16 _sl_version;
 
	return _sl_version < version;
 
}
 

	
 
/**
 
 * Checks if some version from/to combination falls within the range of the
 
 * active savegame version */
 
 * active savegame version
 
 */
 
static inline bool SlIsObjectCurrentlyValid(uint16 version_from, uint16 version_to)
 
{
 
	extern const uint16 SAVEGAME_VERSION;
 
	if (SAVEGAME_VERSION < version_from || SAVEGAME_VERSION > version_to) return false;
 

	
 
	return true;
 
@@ -315,13 +317,14 @@ static inline bool IsNumericType(VarType
 
}
 

	
 
/**
 
 * Get the address of the variable. Which one to pick depends on the object
 
 * pointer. If it is NULL we are dealing with global variables so the address
 
 * is taken. If non-null only the offset is stored in the union and we need
 
 * to add this to the address of the object */
 
 * to add this to the address of the object
 
 */
 
static inline void *GetVariableAddress(const void *object, const SaveLoad *sld)
 
{
 
	return (byte*)(sld->global ? NULL : object) + (ptrdiff_t)sld->address;
 
}
 

	
 
int64 ReadValue(const void *ptr, VarType conv);
src/settings.cpp
Show inline comments
 
@@ -97,13 +97,14 @@ static const char * const _list_group_na
 

	
 
/**
 
 * Find the index value of a ONEofMANY type in a string seperated by |
 
 * @param many full domain of values the ONEofMANY setting can have
 
 * @param one the current value of the setting for which a value needs found
 
 * @param onelen force calculation of the *one parameter
 
 * @return the integer index of the full-list, or -1 if not found */
 
 * @return the integer index of the full-list, or -1 if not found
 
 */
 
static int LookupOneOfMany(const char *many, const char *one, size_t onelen = 0)
 
{
 
	const char *s;
 
	int idx;
 

	
 
	if (onelen == 0) onelen = strlen(one);
 
@@ -125,13 +126,14 @@ static int LookupOneOfMany(const char *m
 

	
 
/**
 
 * Find the set-integer value MANYofMANY type in a string
 
 * @param many full domain of values the MANYofMANY setting can have
 
 * @param str the current string value of the setting, each individual
 
 * of seperated by a whitespace,tab or | character
 
 * @return the 'fully' set integer, or -1 if a set is not found */
 
 * @return the 'fully' set integer, or -1 if a set is not found
 
 */
 
static uint32 LookupManyOfMany(const char *many, const char *str)
 
{
 
	const char *s;
 
	int r;
 
	uint32 res = 0;
 

	
 
@@ -156,13 +158,14 @@ static uint32 LookupManyOfMany(const cha
 
/**
 
 * Parse an integerlist string and set each found value
 
 * @param p the string to be parsed. Each element in the list is seperated by a
 
 * comma or a space character
 
 * @param items pointer to the integerlist-array that will be filled with values
 
 * @param maxitems the maximum number of elements the integerlist-array has
 
 * @return returns the number of items found, or -1 on an error */
 
 * @return returns the number of items found, or -1 on an error
 
 */
 
int ParseIntList(const char *p, int *items, int maxitems)
 
{
 
	int n = 0; // number of items read so far
 
	bool comma = false; // do we accept comma?
 

	
 
	while (*p != '\0') {
 
@@ -200,13 +203,14 @@ int ParseIntList(const char *p, int *ite
 
/**
 
 * Load parsed string-values into an integer-array (intlist)
 
 * @param str the string that contains the values (and will be parsed)
 
 * @param array pointer to the integer-arrays that will be filled
 
 * @param nelems the number of elements the array holds. Maximum is 64 elements
 
 * @param type the type of elements the array holds (eg INT8, UINT16, etc.)
 
 * @return return true on success and false on error */
 
 * @return return true on success and false on error
 
 */
 
static bool LoadIntList(const char *str, void *array, int nelems, VarType type)
 
{
 
	int items[64];
 
	int i, nitems;
 

	
 
	if (str == NULL) {
 
@@ -241,13 +245,14 @@ static bool LoadIntList(const char *str,
 
 * Convert an integer-array (intlist) to a string representation. Each value
 
 * is seperated by a comma or a space character
 
 * @param buf output buffer where the string-representation will be stored
 
 * @param last last item to write to in the output buffer
 
 * @param array pointer to the integer-arrays that is read from
 
 * @param nelems the number of elements the array holds.
 
 * @param type the type of elements the array holds (eg INT8, UINT16, etc.) */
 
 * @param type the type of elements the array holds (eg INT8, UINT16, etc.)
 
 */
 
static void MakeIntList(char *buf, const char *last, const void *array, int nelems, VarType type)
 
{
 
	int i, v = 0;
 
	byte *p = (byte*)array;
 

	
 
	for (i = 0; i != nelems; i++) {
 
@@ -267,13 +272,14 @@ static void MakeIntList(char *buf, const
 

	
 
/**
 
 * Convert a ONEofMANY structure to a string representation.
 
 * @param buf output buffer where the string-representation will be stored
 
 * @param last last item to write to in the output buffer
 
 * @param many the full-domain string of possible values
 
 * @param id the value of the variable and whose string-representation must be found */
 
 * @param id the value of the variable and whose string-representation must be found
 
 */
 
static void MakeOneOfMany(char *buf, const char *last, const char *many, int id)
 
{
 
	int orig_id = id;
 

	
 
	/* Look for the id'th element */
 
	while (--id >= 0) {
 
@@ -294,13 +300,14 @@ static void MakeOneOfMany(char *buf, con
 
/**
 
 * Convert a MANYofMANY structure to a string representation.
 
 * @param buf output buffer where the string-representation will be stored
 
 * @param last last item to write to in the output buffer
 
 * @param many the full-domain string of possible values
 
 * @param x the value of the variable and whose string-representation must
 
 *        be found in the bitmasked many string */
 
 *        be found in the bitmasked many string
 
 */
 
static void MakeManyOfMany(char *buf, const char *last, const char *many, uint32 x)
 
{
 
	const char *start;
 
	int i = 0;
 
	bool init = true;
 

	
 
@@ -326,13 +333,14 @@ static void MakeManyOfMany(char *buf, co
 
}
 

	
 
/**
 
 * Convert a string representation (external) of a setting to the internal rep.
 
 * @param desc SettingDesc struct that holds all information about the variable
 
 * @param orig_str input string that will be parsed based on the type of desc
 
 * @return return the parsed value of the setting */
 
 * @return return the parsed value of the setting
 
 */
 
static const void *StringToVal(const SettingDescBase *desc, const char *orig_str)
 
{
 
	const char *str = orig_str == NULL ? "" : orig_str;
 
	switch (desc->cmd) {
 
	case SDT_NUMX: {
 
		char *end;
 
@@ -373,13 +381,14 @@ static const void *StringToVal(const Set
 
 * Set the value of a setting and if needed clamp the value to
 
 * the preset minimum and maximum.
 
 * @param ptr the variable itself
 
 * @param sd pointer to the 'information'-database of the variable
 
 * @param val signed long version of the new value
 
 * @pre SettingDesc is of type SDT_BOOLX, SDT_NUMX,
 
 * SDT_ONEOFMANY or SDT_MANYOFMANY. Other types are not supported as of now */
 
 * SDT_ONEOFMANY or SDT_MANYOFMANY. Other types are not supported as of now
 
 */
 
static void Write_ValidateSetting(void *ptr, const SettingDesc *sd, int32 val)
 
{
 
	const SettingDescBase *sdb = &sd->desc;
 

	
 
	if (sdb->cmd != SDT_BOOLX &&
 
			sdb->cmd != SDT_NUMX &&
 
@@ -425,13 +434,14 @@ static void Write_ValidateSetting(void *
 
/**
 
 * Load values from a group of an IniFile structure into the internal representation
 
 * @param ini pointer to IniFile structure that holds administrative information
 
 * @param sd pointer to SettingDesc structure whose internally pointed variables will
 
 *        be given values
 
 * @param grpname the group of the IniFile to search in for the new values
 
 * @param object pointer to the object been loaded */
 
 * @param object pointer to the object been loaded
 
 */
 
static void IniLoadSettings(IniFile *ini, const SettingDesc *sd, const char *grpname, void *object)
 
{
 
	IniGroup *group;
 
	IniGroup *group_def = ini->GetGroup(grpname);
 
	IniItem *item;
 
	const void *p;
 
@@ -1173,13 +1183,14 @@ static void HandleOldDiffCustom(bool sav
 
}
 

	
 
/**
 
 * tries to convert newly introduced news settings based on old ones
 
 * @param name pointer to the string defining name of the old news config
 
 * @param value pointer to the string defining value of the old news config
 
 * @returns true if conversion could have been made */
 
 * @returns true if conversion could have been made
 
 */
 
static bool ConvertOldNewsSetting(const char *name, const char *value)
 
{
 
	if (strcasecmp(name, "openclose") == 0) {
 
		/* openclose has been split in "open" and "close".
 
		 * So the job is now to decrypt the value of the old news config
 
		 * and give it to the two newly introduced ones*/
 
@@ -1917,13 +1928,14 @@ void IConsoleListSettings(const char *pr
 
}
 

	
 
/**
 
 * Save and load handler for settings
 
 * @param osd SettingDesc struct containing all information
 
 * @param object can be either NULL in which case we load global variables or
 
 * a pointer to a struct which is getting saved */
 
 * a pointer to a struct which is getting saved
 
 */
 
static void LoadSettings(const SettingDesc *osd, void *object)
 
{
 
	for (; osd->save.cmd != SL_END; osd++) {
 
		const SaveLoad *sld = &osd->save;
 
		void *ptr = GetVariableAddress(object, sld);
 

	
 
@@ -1933,23 +1945,25 @@ static void LoadSettings(const SettingDe
 
}
 

	
 
/**
 
 * Loadhandler for a list of global variables
 
 * @param sdg pointer for the global variable list SettingDescGlobVarList
 
 * @note this is actually a stub for LoadSettings with the
 
 * object pointer set to NULL */
 
 * object pointer set to NULL
 
 */
 
static inline void LoadSettingsGlobList(const SettingDescGlobVarList *sdg)
 
{
 
	LoadSettings((const SettingDesc*)sdg, NULL);
 
}
 

	
 
/**
 
 * Save and load handler for settings
 
 * @param sd SettingDesc struct containing all information
 
 * @param object can be either NULL in which case we load global variables or
 
 * a pointer to a struct which is getting saved */
 
 * a pointer to a struct which is getting saved
 
 */
 
static void SaveSettings(const SettingDesc *sd, void *object)
 
{
 
	/* We need to write the CH_RIFF header, but unfortunately can't call
 
	 * SlCalcLength() because we have a different format. So do this manually */
 
	const SettingDesc *i;
 
	size_t length = 0;
 
@@ -1964,13 +1978,14 @@ static void SaveSettings(const SettingDe
 
	}
 
}
 

	
 
/**
 
 * Savehandler for a list of global variables
 
 * @note this is actually a stub for SaveSettings with the
 
 * object pointer set to NULL */
 
 * object pointer set to NULL
 
 */
 
static inline void SaveSettingsGlobList(const SettingDescGlobVarList *sdg)
 
{
 
	SaveSettings((const SettingDesc*)sdg, NULL);
 
}
 

	
 
static void Load_OPTS()
src/settings_internal.h
Show inline comments
 
@@ -17,13 +17,14 @@
 
#include "strings_type.h"
 

	
 
/**
 
 * Convention/Type of settings. This is then further specified if necessary
 
 * with the SLE_ (SLE_VAR/SLE_FILE) enums in saveload.h
 
 * @see VarTypes
 
 * @see SettingDescBase */
 
 * @see SettingDescBase
 
 */
 
enum SettingDescTypeLong {
 
	/* 4 bytes allocated a maximum of 16 types for GenericType */
 
	SDT_BEGIN       = 0,
 
	SDT_NUMX        = 0, ///< any number-type
 
	SDT_BOOLX       = 1, ///< a boolean number
 
	SDT_ONEOFMANY   = 2, ///< bitmasked number where only ONE bit may be set
src/ship_cmd.cpp
Show inline comments
 
@@ -374,13 +374,14 @@ static void ShipArrivesAt(const Vehicle 
 
}
 

	
 

	
 
/**
 
 * returns the track to choose on the next tile, or -1 when it's better to
 
 * reverse. The tile given is the tile we are about to enter, enterdir is the
 
 * direction in which we are entering the tile */
 
 * direction in which we are entering the tile
 
 */
 
static Track ChooseShipTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
 
{
 
	assert(IsValidDiagDirection(enterdir));
 

	
 
	switch (_settings_game.pf.pathfinder_for_ships) {
 
		case VPF_OPF: return OPFShipChooseTrack(v, tile, enterdir, tracks);
src/smallmap_gui.cpp
Show inline comments
 
@@ -62,13 +62,14 @@ static int _smallmap_industry_count; ///
 

	
 
/** Macro for end of list marker in arrays of LegendAndColour */
 
#define MKEND() {0, STR_NULL, {INVALID_INDUSTRYTYPE}, true, true, false}
 

	
 
/**
 
 * Macro for break marker in arrays of LegendAndColour.
 
 * It will have valid data, though */
 
 * It will have valid data, though
 
 */
 
#define MS(a, b) {a, b, {INVALID_INDUSTRYTYPE}, true, false, true}
 

	
 
/** Structure for holding relevant data for legends in small map */
 
struct LegendAndColour {
 
	uint8 colour;              ///< Colour of the item on the map.
 
	StringID legend;           ///< String corresponding to the coloured item.
 
@@ -149,13 +150,14 @@ static const LegendAndColour _legend_lan
 
#undef MC
 
#undef MS
 
#undef MKEND
 

	
 
/**
 
 * Allow room for all industries, plus a terminator entry
 
 * This is required in order to have the indutry slots all filled up */
 
 * This is required in order to have the indutry slots all filled up
 
 */
 
static LegendAndColour _legend_from_industries[NUM_INDUSTRYTYPES + 1];
 
/* For connecting industry type to position in industries list(small map legend) */
 
static uint _industry_to_list_pos[NUM_INDUSTRYTYPES];
 
/** Show heightmap in industry mode of smallmap window. */
 
static bool _smallmap_industry_show_heightmap;
 

	
src/sortlist_type.h
Show inline comments
 
@@ -249,13 +249,14 @@ public:
 
	 *  For the first sorting we use quick sort since it is
 
	 *  faster for irregular sorted data. After that we
 
	 *  use gsort.
 
	 *
 
	 * @param compare The function to compare two list items
 
	 * @return true if the list sequence has been altered
 
	 * */
 
	 *
 
	 */
 
	bool Sort(SortFunction *compare)
 
	{
 
		/* Do not sort if the resort bit is not set */
 
		if (!(this->flags & VL_RESORT)) return false;
 

	
 
		CLRBITS(this->flags, VL_RESORT);
src/sound/allegro_s.cpp
Show inline comments
 
@@ -43,13 +43,14 @@ void SoundDriver_Allegro::MainLoop()
 
	/* Tell we've filled the stream */
 
	free_audio_stream_buffer(_stream);
 
}
 

	
 
/**
 
 * There are multiple modules that might be using Allegro and
 
 * Allegro can only be initiated once. */
 
 * Allegro can only be initiated once.
 
 */
 
extern int _allegro_instance_count;
 

	
 
const char *SoundDriver_Allegro::Start(const char * const *parm)
 
{
 
	if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) {
 
		DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
src/spritecache.cpp
Show inline comments
 
@@ -404,13 +404,14 @@ void IncreaseSpriteLRU()
 
		_compact_cache_counter = 0;
 
	}
 
}
 

	
 
/**
 
 * Called when holes in the sprite cache should be removed.
 
 * That is accomplished by moving the cached data. */
 
 * That is accomplished by moving the cached data.
 
 */
 
static void CompactSpriteCache()
 
{
 
	MemBlock *s;
 

	
 
	DEBUG(sprite, 3, "Compacting sprite cache, inuse=" PRINTF_SIZE, GetSpriteCacheUsage());
 

	
 
@@ -527,13 +528,14 @@ static void *AllocSprite(size_t mem_req)
 
 * Handles the case when a sprite of different type is requested than is present in the SpriteCache.
 
 * For ST_FONT sprites, it is normal. In other cases, default sprite is loaded instead.
 
 * @param sprite ID of loaded sprite
 
 * @param requested requested sprite type
 
 * @param sc the currently known sprite cache for the requested sprite
 
 * @return fallback sprite
 
 * @note this function will do usererror() in the case the fallback sprite isn't available */
 
 * @note this function will do usererror() in the case the fallback sprite isn't available
 
 */
 
static void *HandleInvalidSpriteRequest(SpriteID sprite, SpriteType requested, SpriteCache *sc)
 
{
 
	static const char * const sprite_types[] = {
 
		"normal",        // ST_NORMAL
 
		"map generator", // ST_MAPGEN
 
		"character",     // ST_FONT
src/station.cpp
Show inline comments
 
@@ -139,13 +139,14 @@ RoadStop *Station::GetPrimaryRoadStop(co
 

	
 
	return rs;
 
}
 

	
 
/**
 
 * Called when new facility is built on the station. If it is the first facility
 
 * it initializes also 'xy' and 'random_bits' members */
 
 * it initializes also 'xy' and 'random_bits' members
 
 */
 
void Station::AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
 
{
 
	if (this->facilities == FACIL_NONE) {
 
		this->xy = facil_xy;
 
		this->random_bits = Random();
 
	}
src/station_gui.cpp
Show inline comments
 
@@ -1278,13 +1278,13 @@ static bool AddNearbyStation(TileIndex t
 
 * Make sure that only stations are returned where joining wouldn't exceed
 
 * station spread and are our own station.
 
 * @param ta Base tile area of the to-be-built station
 
 * @param distant_join Search for adjacent stations (false) or stations fully
 
 *                     within station spread
 
 * @tparam T the type of station to look for
 
 **/
 
 */
 
template <class T>
 
static const T *FindStationsNearby(TileArea ta, bool distant_join)
 
{
 
	TileArea ctx = ta;
 

	
 
	_stations_nearby_list.Clear();
src/strgen/strgen.cpp
Show inline comments
 
@@ -1191,13 +1191,14 @@ static inline void ottd_mkdir(const char
 
#endif
 
}
 

	
 
/**
 
 * Create a path consisting of an already existing path, a possible
 
 * path seperator and the filename. The seperator is only appended if the path
 
 * does not already end with a seperator */
 
 * does not already end with a seperator
 
 */
 
static inline char *mkpath(char *buf, size_t buflen, const char *path, const char *file)
 
{
 
	ttd_strlcpy(buf, path, buflen); // copy directory into buffer
 

	
 
	char *p = strchr(buf, '\0'); // add path seperator if necessary
 
	if (p[-1] != PATHSEPCHAR && (size_t)(p - buf) + 1 < buflen) *p++ = PATHSEPCHAR;
src/string.cpp
Show inline comments
 
@@ -190,13 +190,14 @@ void str_strip_colours(char *str)
 
 * NOTE: only support ASCII characters, no UTF8 fancy. As currently
 
 * the function is only used to lowercase data-filenames if they are
 
 * not found, this is sufficient. If more, or general functionality is
 
 * needed, look to r7271 where it was removed because it was broken when
 
 * using certain locales: eg in Turkish the uppercase 'I' was converted to
 
 * '?', so just revert to the old functionality
 
 * @param str string to convert */
 
 * @param str string to convert
 
 */
 
void strtolower(char *str)
 
{
 
	for (; *str != '\0'; str++) *str = tolower(*str);
 
}
 

	
 
/**
 
@@ -293,13 +294,14 @@ int CDECL seprintf(char *str, const char
 

	
 
/**
 
 * Convert the md5sum to a hexadecimal string representation
 
 * @param buf buffer to put the md5sum into
 
 * @param last last character of buffer (usually lastof(buf))
 
 * @param md5sum the md5sum itself
 
 * @return a pointer to the next character after the md5sum */
 
 * @return a pointer to the next character after the md5sum
 
 */
 
char *md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
 
{
 
	char *p = buf;
 

	
 
	for (uint i = 0; i < 16; i++) {
 
		p += seprintf(p, last, "%02X", md5sum[i]);
src/strings.cpp
Show inline comments
 
@@ -1384,13 +1384,14 @@ bool ReadLanguagePack(int lang_index)
 
/**
 
 * Determine the current charset based on the environment
 
 * First check some default values, after this one we passed ourselves
 
 * and if none exist return the value for $LANG
 
 * @param param environment variable to check conditionally if default ones are not
 
 *        set. Pass NULL if you don't want additional checks.
 
 * @return return string containing current charset, or NULL if not-determinable */
 
 * @return return string containing current charset, or NULL if not-determinable
 
 */
 
const char *GetCurrentLocale(const char *param)
 
{
 
	const char *env;
 

	
 
	env = getenv("LANGUAGE");
 
	if (env != NULL) return env;
src/table/airporttiles.h
Show inline comments
 
@@ -16,13 +16,14 @@
 
#define AT(num_frames, anim_speed) {(1 << 8) | num_frames, anim_speed, STR_NULL, 0, 0, 0, true, {INVALID_AIRPORTTILE, 0, NULL, NULL, INVALID_AIRPORTTILE}}
 
/** Writes an airport tile without animation in the AirportTile struct */
 
#define AT_NOANIM {0xFFFF, 2, STR_NULL, 0, 0, 0, true, {INVALID_AIRPORTTILE, 0, NULL, NULL, INVALID_AIRPORTTILE}}
 

	
 
/**
 
 * All default airport tiles.
 
 * @see AirportTiles for a list of names. */
 
 * @see AirportTiles for a list of names.
 
 */
 
static const AirportTileSpec _origin_airporttile_specs[] = {
 
	/* 0..9 */
 
	AT_NOANIM,
 
	AT_NOANIM,
 
	AT_NOANIM,
 
	AT_NOANIM,
src/table/elrail_data.h
Show inline comments
 
@@ -6,32 +6,35 @@
 
 * 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 elrail_data.h Stores all the data for overhead wire and pylon drawing.
 
 *  @see elrail.c */
 
 *  @see elrail.c
 
 */
 

	
 
#ifndef ELRAIL_DATA_H
 
#define ELRAIL_DATA_H
 

	
 
/**
 
 * Tile Location group.
 
 * This defines whether the X and or Y coordinate of a tile is even */
 
 * This defines whether the X and or Y coordinate of a tile is even
 
 */
 
enum TLG {
 
	XEVEN_YEVEN = 0,
 
	XEVEN_YODD  = 1,
 
	XODD_YEVEN  = 2,
 
	XODD_YODD   = 3,
 
	TLG_END
 
};
 

	
 
/**
 
 * When determining the pylon configuration on the edge, two tiles are taken
 
 * into account: the tile being drawn itself (the home tile, the one in
 
 * ti->tile), and the neighbouring tile */
 
 * ti->tile), and the neighbouring tile
 
 */
 
enum TileSource {
 
	TS_HOME      = 0,
 
	TS_NEIGHBOUR = 1,
 

	
 
	TS_END
 
};
 
@@ -46,13 +49,14 @@ static const byte AllowedPPPonPCP[DIAGDI
 
	1 << DIR_N | 1 << DIR_NE | 1 << DIR_E  | 1 << DIR_S | 1 << DIR_SW | 1 << DIR_W,
 
};
 

	
 
/**
 
 * Which of the PPPs are inside the tile. For the two PPPs on the tile border
 
 * the following system is used: if you rotate the PCP so that it is in the
 
 * north, the eastern PPP belongs to the tile. */
 
 * north, the eastern PPP belongs to the tile.
 
 */
 
static const byte OwnedPPPonPCP[DIAGDIR_END] = {
 
	1 << DIR_SE | 1 << DIR_S  | 1 << DIR_SW | 1 << DIR_W,
 
	1 << DIR_N  | 1 << DIR_SW | 1 << DIR_W  | 1 << DIR_NW,
 
	1 << DIR_N  | 1 << DIR_NE | 1 << DIR_E  | 1 << DIR_NW,
 
	1 << DIR_NE | 1 << DIR_E  | 1 << DIR_SE | 1 << DIR_S
 
};
 
@@ -69,13 +73,14 @@ static const DiagDirection PCPpositions[
 

	
 
#define PCP_NOT_ON_TRACK 0xFF
 
/**
 
 * Preferred points of each trackbit. Those are the ones perpendicular to the
 
 * track, plus the point in extension of the track (to mark end-of-track). PCPs
 
 * which are not on either end of the track are fully preferred.
 
 * @see PCPpositions */
 
 * @see PCPpositions
 
 */
 
static const byte PreferredPPPofTrackAtPCP[TRACK_END][DIAGDIR_END] = {
 
	{    // X
 
		1 << DIR_NE | 1 << DIR_SE | 1 << DIR_NW, // NE
 
		PCP_NOT_ON_TRACK,                        // SE
 
		1 << DIR_SE | 1 << DIR_SW | 1 << DIR_NW, // SW
 
		PCP_NOT_ON_TRACK                         // NE
 
@@ -111,13 +116,14 @@ static const byte PreferredPPPofTrackAtP
 

	
 
#define NUM_IGNORE_GROUPS 3
 
#define IGNORE_NONE 0xFF
 
/**
 
 * In case we have a staight line, we place pylon only every two tiles,
 
 * so there are certain tiles which we ignore. A straight line is found if
 
 * we have exactly two PPPs. */
 
 * we have exactly two PPPs.
 
 */
 
static const byte IgnoredPCP[NUM_IGNORE_GROUPS][TLG_END][DIAGDIR_END] = {
 
	{   // Ignore group 1, X and Y tracks
 
		{     // X even, Y even
 
			IGNORE_NONE,
 
			1 << DIR_NE | 1 << DIR_SW,
 
			1 << DIR_NW | 1 << DIR_SE,
src/table/industry_land.h
Show inline comments
 
@@ -42,13 +42,14 @@ struct DrawIndustryCoordinates {
 
 * @param sx coordinate x of the sprite
 
 * @param sy coordinate y of the sprite
 
 * @param w width of the sprite
 
 * @param h height of the sprite
 
 * @param dz virtual height of the sprite
 
 * @param p this allows to specify a special drawing procedure.
 
 * @see DrawBuildingsTileStruct */
 
 * @see DrawBuildingsTileStruct
 
 */
 
#define M(s1, p1, s2, p2, sx, sy, w, h, dz, p) { { s1, p1 }, { s2, p2 }, sx, sy, w, h, dz, p }
 

	
 
/** Structure for industry tiles drawing */
 
static const DrawBuildingsTileStruct _industry_draw_tile_data[NEW_INDUSTRYTILEOFFSET * 4] = {
 
	M(     0xf54, PAL_NONE,      0x7db, PAL_NONE,  7,  0,  9,  9,  10, 0),
 
	M(     0xf54, PAL_NONE,      0x7dc, PAL_NONE,  7,  0,  9,  9,  30, 0),
src/table/sprites.h
Show inline comments
 
@@ -1452,13 +1452,14 @@ enum Modifiers {
 
	PALETTE_MODIFIER_COLOUR       = RECOLOUR_BIT,
 
};
 

	
 
/**
 
 * Masks needed for sprite operations.
 
 * @note Do not modify this enum. Alter SpriteSetup instead
 
 * @see SpriteSetup */
 
 * @see SpriteSetup
 
 */
 
enum SpriteMasks {
 
	/** Maximum number of sprites that can be loaded at a given time. */
 
	MAX_SPRITES = 1 << SPRITE_WIDTH,
 
	/** The mask to for the main sprite */
 
	SPRITE_MASK = MAX_SPRITES - 1,
 

	
src/table/town_land.h
Show inline comments
 
@@ -18,13 +18,14 @@
 
 * @param sx The x-position of the sprite within the tile
 
 * @param sy the y-position of the sprite within the tile
 
 * @param w the width of the sprite
 
 * @param h the height of the sprite
 
 * @param dz the virtual height of the sprite
 
 * @param p set to 1 if a lift is present ()
 
 * @see DrawBuildingsTileStruct */
 
 * @see DrawBuildingsTileStruct
 
 */
 
#define M(s1, p1, s2, p2, sx, sy, w, h, dz, p) { { s1, p1 }, { s2, p2 }, sx, sy, w, h, dz, p}
 

	
 
/** structure of houses graphics*/
 
static const DrawBuildingsTileStruct _town_draw_tile_data[] = {
 
	M( SPR_FLAT_BARE_LAND, PAL_NONE,  0x58d, PAL_NONE,  0,  0, 14, 14,   8, 0),
 
	M( SPR_FLAT_BARE_LAND, PAL_NONE,  0x58e, PAL_NONE,  0,  0, 14, 14,  60, 0),
 
@@ -1825,13 +1826,14 @@ static const HouseSpec _original_house_s
 
	 *     |         |    |    |    building_name                                   |    |    |    |    |
 
	 *     |         |    |    |    |                                               |    |    |    |    |
 
	 *     |         |    |    |    |                                               |    |    |    |    |
 
	 * +-building_flags   |    |    |                                               |    |    |    |    |
 
	 * +-building_availability |    |                                               |    |    |    |    |
 
	 * +-cargoID accepted |    |    |                                               |    |    |    |    |
 
	 * |   |         |    |    |    |                                               |    |    |    |    | */
 
	 * |   |         |    |    |    |                                               |    |    |    |    |
 
	 */
 
	MS(1963, MAX_YEAR, 187, 150, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      140,  70,   8,   3,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 00
 
	MS(1957, MAX_YEAR,  85, 140, STR_TOWN_BUILDING_NAME_OFFICE_BLOCK_1,           130,  55,   8,   3,   4,
 
	   TILE_SIZE_1x1,
src/terraform_gui.cpp
Show inline comments
 
@@ -92,13 +92,13 @@ static void GenerateRockyArea(TileIndex 
 
 * @param proc       Procedure related to the dragging
 
 * @param start_tile Begin of the dragging
 
 * @param end_tile   End of the dragging
 
 * @return Returns true if the action was found and handled, and false otherwise. This
 
 * allows for additional implements that are more local. For example X_Y drag
 
 * of convertrail which belongs in rail_gui.cpp and not terraform_gui.cpp
 
 **/
 
 */
 
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
 
{
 
	if (!_settings_game.construction.freeform_edges) {
 
		/* When end_tile is MP_VOID, the error tile will not be visible to the
 
		 * user. This happens when terraforming at the southern border. */
 
		if (TileX(end_tile) == MapMaxX()) end_tile += TileDiffXY(-1, 0);
 
@@ -587,13 +587,14 @@ static OnButtonClick * const _editor_ter
 
};
 

	
 

	
 
/**
 
 * Callback function for the scenario editor 'reset landscape' confirmation window
 
 * @param w Window unused
 
 * @param confirmed boolean value, true when yes was clicked, false otherwise */
 
 * @param confirmed boolean value, true when yes was clicked, false otherwise
 
 */
 
static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
 
{
 
	if (confirmed) {
 
		/* Set generating_world to true to get instant-green grass after removing
 
		 * company property. */
 
		_generating_world = true;
src/tgp.cpp
Show inline comments
 
@@ -203,13 +203,14 @@ static HeightMap _height_map = {NULL, 0,
 

	
 
/** Maximum index into array of noise amplitudes */
 
static const int TGP_FREQUENCY_MAX = 6;
 

	
 
/**
 
 * Noise amplitudes (multiplied by 1024)
 
 * - indexed by "smoothness setting" and log2(frequency) */
 
 * - indexed by "smoothness setting" and log2(frequency)
 
 */
 
static const amplitude_t _amplitudes_by_smoothness_and_frequency[4][TGP_FREQUENCY_MAX + 1] = {
 
	/* lowest frequncy....  ...highest (every corner) */
 
	/* Very smooth */
 
	{16000,  5600,  1968,   688,   240,    16,    16},
 
	/* Smooth */
 
	{16000, 16000,  6448,  3200,  1024,   128,    16},
 
@@ -839,13 +840,14 @@ static void HeightMapSmoothSlopes(height
 

	
 
/**
 
 * Height map terraform post processing:
 
 *  - water level adjusting
 
 *  - coast Smoothing
 
 *  - slope Smoothing
 
 *  - height histogram redistribution by sine wave transform */
 
 *  - height histogram redistribution by sine wave transform
 
 */
 
static void HeightMapNormalize()
 
{
 
	const amplitude_t water_percent = _water_percent[_settings_game.difficulty.quantity_sea_lakes];
 
	const height_t h_max_new = I2H(_max_height[_settings_game.difficulty.terrain_type]);
 
	const height_t roughness = 7 + 3 * _settings_game.game_creation.tgen_smoothness;
 

	
src/tile_cmd.h
Show inline comments
 
@@ -132,13 +132,14 @@ typedef Foundation GetFoundationProc(Til
 
 * @return Error code or extra cost for terraforming (like clearing land, building foundations, etc., but not the terraforming itself.)
 
 */
 
typedef CommandCost TerraformTileProc(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new);
 

	
 
/**
 
 * Set of callback functions for performing tile operations of a given tile type.
 
 * @see TileType */
 
 * @see TileType
 
 */
 
struct TileTypeProcs {
 
	DrawTileProc *draw_tile_proc;                  ///< Called to render the tile and its contents to the screen
 
	GetSlopeZProc *get_slope_z_proc;
 
	ClearTileProc *clear_tile_proc;
 
	AddAcceptedCargoProc *add_accepted_cargo_proc; ///< Adds accepted cargo of the tile to cargo array supplied as parameter
 
	GetTileDescProc *get_tile_desc_proc;           ///< Get a description of a tile (for the 'land area information' tool)
src/tile_map.cpp
Show inline comments
 
@@ -14,13 +14,14 @@
 
#include "core/math_func.hpp"
 

	
 
/**
 
 * Return the slope of a given tile
 
 * @param tile Tile to compute slope of
 
 * @param h    If not \c NULL, pointer to storage of z height
 
 * @return Slope of the tile, except for the HALFTILE part */
 
 * @return Slope of the tile, except for the HALFTILE part
 
 */
 
Slope GetTileSlope(TileIndex tile, uint *h)
 
{
 
	assert(tile < MapSize());
 

	
 
	if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY() ||
 
			(_settings_game.construction.freeform_edges && (TileX(tile) == 0 || TileY(tile) == 0))) {
 
@@ -59,13 +60,14 @@ Slope GetTileSlope(TileIndex tile, uint 
 
	return (Slope)r;
 
}
 

	
 
/**
 
 * Get bottom height of the tile
 
 * @param tile Tile to compute height of
 
 * @return Minimum height of the tile */
 
 * @return Minimum height of the tile
 
 */
 
uint GetTileZ(TileIndex tile)
 
{
 
	if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) return 0;
 

	
 
	uint h = TileHeight(tile); // N corner
 
	h = min(h, TileHeight(tile + TileDiffXY(1, 0))); // W corner
 
@@ -75,13 +77,14 @@ uint GetTileZ(TileIndex tile)
 
	return h * TILE_HEIGHT;
 
}
 

	
 
/**
 
 * Get top height of the tile
 
 * @param t Tile to compute height of
 
 * @return Maximum height of the tile */
 
 * @return Maximum height of the tile
 
 */
 
uint GetTileMaxZ(TileIndex t)
 
{
 
	if (TileX(t) == MapMaxX() || TileY(t) == MapMaxY()) return 0;
 

	
 
	uint h = TileHeight(t); // N corner
 
	h = max(h, TileHeight(t + TileDiffXY(1, 0))); // W corner
src/town.h
Show inline comments
 
@@ -163,13 +163,14 @@ enum TownRatingCheckType {
 
	TOWN_RATING_CHECK_TYPE_COUNT, ///< Number of town checking action types.
 
};
 

	
 
/**
 
 * This is the number of ticks between towns being processed for building new
 
 * houses or roads. This value originally came from the size of the town array
 
 * in TTD. */
 
 * in TTD.
 
 */
 
static const byte TOWN_GROWTH_FREQUENCY = 70;
 

	
 
/**
 
 * This enum is used in conjonction with town->flags.
 
 * IT simply states what bit is used for.
 
 * It is pretty unrealistic (IMHO) to only have one church/stadium
src/town_cmd.cpp
Show inline comments
 
@@ -2014,13 +2014,13 @@ static inline bool TownLayoutAllows2x2Ho
 
 * Also, tests both building positions that occupy this tile
 
 * @param tile tile where the building should be built
 
 * @param t town
 
 * @param maxz all tiles should have the same height
 
 * @param noslope are slopes forbidden?
 
 * @param second diagdir from first tile to second tile
 
 **/
 
 */
 
static bool CheckTownBuild2House(TileIndex *tile, Town *t, uint maxz, bool noslope, DiagDirection second)
 
{
 
	/* 'tile' is already checked in BuildTownHouse() - CanBuildHouseHere() and slope test */
 

	
 
	TileIndex tile2 = *tile + TileOffsByDiagDir(second);
 
	if (TownLayoutAllowsHouseHere(t, tile2) && CheckBuildHouseSameZ(tile2, t->index, maxz, noslope)) return true;
 
@@ -2039,13 +2039,13 @@ static bool CheckTownBuild2House(TileInd
 
 * Checks if 2x2 building is allowed here, also takes into account current town layout
 
 * Also, tests all four building positions that occupy this tile
 
 * @param tile tile where the building should be built
 
 * @param t town
 
 * @param maxz all tiles should have the same height
 
 * @param noslope are slopes forbidden?
 
 **/
 
 */
 
static bool CheckTownBuild2x2House(TileIndex *tile, Town *t, uint maxz, bool noslope)
 
{
 
	TileIndex tile2 = *tile;
 

	
 
	for (DiagDirection d = DIAGDIR_SE;;d++) { // 'd' goes through DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_END
 
		if (TownLayoutAllows2x2HouseHere(t, tile2) && CheckFree2x2Area(tile2, t->index, maxz, noslope)) {
 
@@ -2625,13 +2625,14 @@ static void UpdateTownGrowRate(Town *t)
 

	
 
	ClrBit(t->flags, TOWN_IS_FUNDED);
 
	if (_settings_game.economy.town_growth_rate == 0 && t->fund_buildings_months == 0) return;
 

	
 
	/**
 
	 * Towns are processed every TOWN_GROWTH_FREQUENCY ticks, and this is the
 
	 * number of times towns are processed before a new building is built. */
 
	 * number of times towns are processed before a new building is built.
 
	 */
 
	static const uint16 _grow_count_values[2][6] = {
 
		{ 120, 120, 120, 100,  80,  60 }, // Fund new buildings has been activated
 
		{ 320, 420, 300, 220, 160, 100 }  // Normal values
 
	};
 

	
 
	uint16 m;
src/train_cmd.cpp
Show inline comments
 
@@ -1967,13 +1967,14 @@ CommandCost CmdRefitRailVehicle(TileInde
 

	
 
	return cost;
 
}
 

	
 
/**
 
 * returns the tile of a depot to goto to. The given vehicle must not be
 
 * crashed! */
 
 * crashed!
 
 */
 
static FindDepotData FindClosestTrainDepot(Train *v, int max_distance)
 
{
 
	assert(!(v->vehstatus & VS_CRASHED));
 

	
 
	if (IsRailDepotTile(v->tile)) return FindDepotData(v->tile, 0);
 

	
src/unmovable_cmd.cpp
Show inline comments
 
@@ -39,13 +39,13 @@
 
 * Accessor for array _original_unmovable.
 
 * This will ensure at once : proper access and
 
 * not allowing modifications of it.
 
 * @param type of unmovable (which is the index in _original_unmovable)
 
 * @pre type < UNMOVABLE_MAX
 
 * @return a pointer to the corresponding unmovable spec
 
 **/
 
 */
 
static inline const UnmovableSpec *GetUnmovableSpec(UnmovableType type)
 
{
 
	assert(type < UNMOVABLE_MAX);
 
	return &_original_unmovable[type];
 
}
 

	
src/vehicle.cpp
Show inline comments
 
@@ -1208,13 +1208,14 @@ void MarkSingleVehicleDirty(const Vehicl
 
	MarkAllViewportsDirty(v->coord.left, v->coord.top, v->coord.right + 1, v->coord.bottom + 1);
 
}
 

	
 
/**
 
 * Get position information of a vehicle when moving one pixel in the direction it is facing
 
 * @param v Vehicle to move
 
 * @return Position information after the move */
 
 * @return Position information after the move
 
 */
 
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v)
 
{
 
	static const int8 _delta_coord[16] = {
 
		-1,-1,-1, 0, 1, 1, 1, 0, /* x */
 
		-1, 0, 1, 1, 1, 0,-1,-1, /* y */
 
	};
src/video/allegro_v.cpp
Show inline comments
 
@@ -405,13 +405,14 @@ static void PollEvent()
 
		HandleKeypress(ConvertAllegroKeyIntoMy());
 
	}
 
}
 

	
 
/**
 
 * There are multiple modules that might be using Allegro and
 
 * Allegro can only be initiated once. */
 
 * Allegro can only be initiated once.
 
 */
 
int _allegro_instance_count = 0;
 

	
 
const char *VideoDriver_Allegro::Start(const char * const *parm)
 
{
 
	if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) {
 
		DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
src/video/dedicated_v.cpp
Show inline comments
 
@@ -39,13 +39,14 @@
 
#	include <os2.h>
 

	
 
#	define STDIN 0  /* file descriptor for standard input */
 

	
 
/**
 
 * Switches OpenTTD to a console app at run-time, instead of a PM app
 
 * Necessary to see stdout, etc. */
 
 * Necessary to see stdout, etc.
 
 */
 
static void OS2_SwitchToConsoleMode()
 
{
 
	PPIB pib;
 
	PTIB tib;
 

	
 
	DosGetInfoBlocks(&tib, &pib);
src/viewport.cpp
Show inline comments
 
@@ -362,13 +362,14 @@ ViewPort *IsPtInWindowViewport(const Win
 

	
 
/**
 
 * Translate screen coordinate in a viewport to a tile coordinate
 
 * @param vp  Viewport that contains the (\a x, \a y) screen coordinate
 
 * @param x   Screen x coordinate
 
 * @param y   Screen y coordinate
 
 * @return Tile coordinate */
 
 * @return Tile coordinate
 
 */
 
static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
 
{
 
	Point pt;
 
	int a, b;
 
	uint z;
 

	
 
@@ -453,13 +454,14 @@ Point GetTileZoomCenterWindow(bool in, W
 
/**
 
 * Update the status of the zoom-buttons according to the zoom-level
 
 * of the viewport. This will update their status and invalidate accordingly
 
 * @param w Window pointer to the window that has the zoom buttons
 
 * @param vp pointer to the viewport whose zoom-level the buttons represent
 
 * @param widget_zoom_in widget index for window with zoom-in button
 
 * @param widget_zoom_out widget index for window with zoom-out button */
 
 * @param widget_zoom_out widget index for window with zoom-out button
 
 */
 
void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out)
 
{
 
	w->SetWidgetDisabledState(widget_zoom_in, vp->zoom == ZOOM_LVL_MIN);
 
	w->SetWidgetDirty(widget_zoom_in);
 

	
 
	w->SetWidgetDisabledState(widget_zoom_out, vp->zoom == ZOOM_LVL_MAX);
 
@@ -1423,13 +1425,14 @@ void ViewportDoDraw(const ViewPort *vp, 
 
	_vd.parent_sprites_to_sort.Clear();
 
	_vd.child_screen_sprites_to_draw.Clear();
 
}
 

	
 
/**
 
 * Make sure we don't draw a too big area at a time.
 
 * If we do, the sprite memory will overflow. */
 
 * If we do, the sprite memory will overflow.
 
 */
 
static void ViewportDrawChk(const ViewPort *vp, int left, int top, int right, int bottom)
 
{
 
	if (ScaleByZoom(bottom - top, vp->zoom) * ScaleByZoom(right - left, vp->zoom) > 180000) {
 
		if ((bottom - top) > (right - left)) {
 
			int t = (top + bottom) >> 1;
 
			ViewportDrawChk(vp, left, top, right, t);
 
@@ -2086,13 +2089,14 @@ void VpSetPlaceSizingLimit(int limit)
 
	_thd.sizelimit = limit;
 
}
 

	
 
/**
 
 * Highlights all tiles between a set of two tiles. Used in dock and tunnel placement
 
 * @param from TileIndex of the first tile to highlight
 
 * @param to TileIndex of the last tile to highlight */
 
 * @param to TileIndex of the last tile to highlight
 
 */
 
void VpSetPresizeRange(TileIndex from, TileIndex to)
 
{
 
	uint64 distance = DistanceManhattan(from, to) + 1;
 

	
 
	_thd.selend.x = TileX(to) * TILE_SIZE;
 
	_thd.selend.y = TileY(to) * TILE_SIZE;
 
@@ -2109,13 +2113,14 @@ static void VpStartPreSizing()
 
	_thd.selend.x = -1;
 
	_special_mouse_mode = WSM_PRESIZE;
 
}
 

	
 
/**
 
 * returns information about the 2x1 piece to be build.
 
 * The lower bits (0-3) are the track type. */
 
 * The lower bits (0-3) are the track type.
 
 */
 
static HighLightStyle Check2x1AutoRail(int mode)
 
{
 
	int fxpy = _tile_fract_coords.x + _tile_fract_coords.y;
 
	int sxpy = (_thd.selend.x & TILE_UNIT_MASK) + (_thd.selend.y & TILE_UNIT_MASK);
 
	int fxmy = _tile_fract_coords.x - _tile_fract_coords.y;
 
	int sxmy = (_thd.selend.x & TILE_UNIT_MASK) - (_thd.selend.y & TILE_UNIT_MASK);
 
@@ -2152,13 +2157,14 @@ static HighLightStyle Check2x1AutoRail(i
 
 * For example dragging a rectangle area from south to north should be swapped to
 
 * north-south (DIR_S) to obtain the same results with less code. This is what
 
 * the return value signifies.
 
 * @param style HighLightStyle dragging style
 
 * @param start_tile start tile of drag
 
 * @param end_tile end tile of drag
 
 * @return boolean value which when true means start/end should be swapped */
 
 * @return boolean value which when true means start/end should be swapped
 
 */
 
static bool SwapDirection(HighLightStyle style, TileIndex start_tile, TileIndex end_tile)
 
{
 
	uint start_x = TileX(start_tile);
 
	uint start_y = TileY(start_tile);
 
	uint end_x = TileX(end_tile);
 
	uint end_y = TileY(end_tile);
 
@@ -2508,13 +2514,14 @@ static void CalcRaildirsDrawstyle(TileHi
 

	
 
/**
 
 * Selects tiles while dragging
 
 * @param x X coordinate of end of selection
 
 * @param y Y coordinate of end of selection
 
 * @param method modifies the way tiles are selected. Possible
 
 * methods are VPM_* in viewport.h */
 
 * methods are VPM_* in viewport.h
 
 */
 
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
 
{
 
	int sx, sy;
 
	HighLightStyle style;
 

	
 
	if (x == -1) {
src/viewport_type.h
Show inline comments
 
@@ -81,13 +81,14 @@ enum ViewportPlaceMethod {
 
	VPM_SIGNALDIRS      = 0x80, ///< similiar to VMP_RAILDIRS, but with different cursor
 
};
 
DECLARE_ENUM_AS_BIT_SET(ViewportPlaceMethod)
 

	
 
/**
 
 * Drag and drop selection process, or, what to do with an area of land when
 
 * you've selected it. */
 
 * you've selected it.
 
 */
 
enum ViewportDragDropSelectionProcess {
 
	DDSP_DEMOLISH_AREA,        ///< Clear area
 
	DDSP_RAISE_AND_LEVEL_AREA, ///< Raise / level area
 
	DDSP_LOWER_AND_LEVEL_AREA, ///< Lower / level area
 
	DDSP_LEVEL_AREA,           ///< Level area
 
	DDSP_CREATE_DESERT,        ///< Fill area with desert
src/widget_type.h
Show inline comments
 
@@ -218,13 +218,14 @@ FORCEINLINE void NWidgetBase::StoreSizeP
 
	this->current_y = given_height;
 
}
 

	
 

	
 
/**
 
 * Base class for a resizable nested widget.
 
 * @ingroup NestedWidgets */
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetResizeBase : public NWidgetBase {
 
public:
 
	NWidgetResizeBase(WidgetType tp, uint fill_x, uint fill_y);
 

	
 
	void SetMinimalSize(uint min_x, uint min_y);
 
	void SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size);
 
@@ -257,13 +258,14 @@ enum NWidgetDisplay {
 
	ND_DROPDOWN_ACTIVE = 1 << NDB_DROPDOWN_ACTIVE, ///< Bit value of the 'dropdown active' flag.
 
};
 
DECLARE_ENUM_AS_BIT_SET(NWidgetDisplay)
 

	
 
/**
 
 * Base class for a 'real' widget.
 
 * @ingroup NestedWidgets */
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetCore : public NWidgetResizeBase {
 
public:
 
	NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint16 widget_data, StringID tool_tip);
 

	
 
	void SetIndex(int index);
 
	void SetDataTip(uint16 widget_data, StringID tool_tip);
 
@@ -315,13 +317,14 @@ inline bool NWidgetCore::IsDisabled() co
 
	return HasBit(this->disp_flags, NDB_DISABLED);
 
}
 

	
 

	
 
/**
 
 * Baseclass for container widgets.
 
 * @ingroup NestedWidgets */
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetContainer : public NWidgetBase {
 
public:
 
	NWidgetContainer(WidgetType tp);
 
	~NWidgetContainer();
 

	
 
	void Add(NWidgetBase *wid);
 
@@ -400,46 +403,50 @@ protected:
 
	uint8 pip_inter;          ///< Amount of space between widgets.
 
	uint8 pip_post;           ///< Amount of space after last widget.
 
};
 

	
 
/**
 
 * Horizontal container.
 
 * @ingroup NestedWidgets */
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetHorizontal : public NWidgetPIPContainer {
 
public:
 
	NWidgetHorizontal(NWidContainerFlags flags = NC_NONE);
 

	
 
	void SetupSmallestSize(Window *w, bool init_array);
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
 
};
 

	
 
/**
 
 * Horizontal container that doesn't change the direction of the widgets for RTL languages.
 
 * @ingroup NestedWidgets */
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetHorizontalLTR : public NWidgetHorizontal {
 
public:
 
	NWidgetHorizontalLTR(NWidContainerFlags flags = NC_NONE);
 

	
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
 
};
 

	
 
/**
 
 * Vertical container.
 
 * @ingroup NestedWidgets */
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetVertical : public NWidgetPIPContainer {
 
public:
 
	NWidgetVertical(NWidContainerFlags flags = NC_NONE);
 

	
 
	void SetupSmallestSize(Window *w, bool init_array);
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
 
};
 

	
 

	
 
/**
 
 * Spacer widget.
 
 * @ingroup NestedWidgets */
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetSpacer : public NWidgetResizeBase {
 
public:
 
	NWidgetSpacer(int length, int height);
 

	
 
	void SetupSmallestSize(Window *w, bool init_array);
 
	/* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
 
@@ -448,13 +455,14 @@ public:
 
	/* virtual */ void SetDirty(const Window *w) const;
 
	/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
 
};
 

	
 
/**
 
 * Nested widget with a child.
 
 * @ingroup NestedWidgets */
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetBackground : public NWidgetCore {
 
public:
 
	NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child = NULL);
 
	~NWidgetBackground();
 

	
 
	void Add(NWidgetBase *nwid);
 
@@ -478,13 +486,14 @@ private:
 
 * Nested widget to display a viewport in a window.
 
 * After initializing the nested widget tree, call #InitializeViewport(). After changing the window size,
 
 * call #UpdateViewportCoordinates() eg from Window::OnResize().
 
 * If the #display_flags field contains the #ND_NO_TRANSPARENCY bit, the viewport will disable transparency.
 
 * Shading to grey-scale is controlled with the #ND_SHADE_GREY bit (used for B&W news papers), the #ND_SHADE_DIMMED gives dimmed colours (for colour news papers).
 
 * @todo Class derives from #NWidgetCore, but does not use #colour, #widget_data, or #tool_tip.
 
 * @ingroup NestedWidgets */
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetViewport : public NWidgetCore {
 
public:
 
	NWidgetViewport(int index);
 

	
 
	/* virtual */ void SetupSmallestSize(Window *w, bool init_array);
 
	/* virtual */ void Draw(const Window *w);
 
@@ -493,13 +502,14 @@ public:
 
	void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom);
 
	void UpdateViewportCoordinates(Window *w);
 
};
 

	
 
/**
 
 * Leaf widget.
 
 * @ingroup NestedWidgets */
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetLeaf : public NWidgetCore {
 
public:
 
	NWidgetLeaf(WidgetType tp, Colours colour, int index, uint16 data, StringID tip);
 

	
 
	/* virtual */ void SetupSmallestSize(Window *w, bool init_array);
 
	/* virtual */ void Draw(const Window *w);
 
@@ -578,43 +588,48 @@ static FORCEINLINE uint ComputeMaxSize(u
 
 *
 
 * @see NestedWidgets
 
 */
 

	
 
/**
 
 * Widget part for storing data and tooltip information.
 
 * @ingroup NestedWidgetParts */
 
 * @ingroup NestedWidgetParts
 
 */
 
struct NWidgetPartDataTip {
 
	uint16 data;      ///< Data value of the widget.
 
	StringID tooltip; ///< Tooltip of the widget.
 
};
 

	
 
/**
 
 * Widget part for storing basic widget information.
 
 * @ingroup NestedWidgetParts */
 
 * @ingroup NestedWidgetParts
 
 */
 
struct NWidgetPartWidget {
 
	Colours colour; ///< Widget colour.
 
	int16 index;    ///< Widget index in the widget array.
 
};
 

	
 
/**
 
 * Widget part for storing padding.
 
 * @ingroup NestedWidgetParts */
 
 * @ingroup NestedWidgetParts
 
 */
 
struct NWidgetPartPaddings {
 
	uint8 top, right, bottom, left; ///< Paddings for all directions.
 
};
 

	
 
/**
 
 * Widget part for storing pre/inter/post spaces.
 
 * @ingroup NestedWidgetParts */
 
 * @ingroup NestedWidgetParts
 
 */
 
struct NWidgetPartPIP {
 
	uint8 pre, inter, post; ///< Amount of space before/between/after child widgets.
 
};
 

	
 
/**
 
 * Widget part for storing minimal text line data.
 
 * @ingroup NestedWidgetParts */
 
 * @ingroup NestedWidgetParts
 
 */
 
struct NWidgetPartTextLines {
 
	uint8 lines;   ///< Number of text lines.
 
	uint8 spacing; ///< Extra spacing around lines.
 
	FontSize size; ///< Font size of text lines.
 
};
 

	
 
@@ -625,13 +640,14 @@ struct NWidgetPartTextLines {
 
 * @post \c *biggest_index must contain the value of the biggest index in the returned tree.
 
 */
 
typedef NWidgetBase *NWidgetFunctionType(int *biggest_index);
 

	
 
/**
 
 * Partial widget specification to allow NWidgets to be written nested.
 
 * @ingroup NestedWidgetParts */
 
 * @ingroup NestedWidgetParts
 
 */
 
struct NWidgetPart {
 
	WidgetType type;                         ///< Type of the part. @see NWidgetPartType.
 
	union {
 
		Point xy;                        ///< Part with an x/y size.
 
		NWidgetPartDataTip data_tip;     ///< Part with a data/tooltip.
 
		NWidgetPartWidget widget;        ///< Part with a start of a widget.
src/window.cpp
Show inline comments
 
@@ -761,13 +761,14 @@ restart_search:
 
}
 

	
 
/**
 
 * Delete all windows of a company. We identify windows of a company
 
 * by looking at the caption colour. If it is equal to the company ID
 
 * then we say the window belongs to the company and should be deleted
 
 * @param id company identifier */
 
 * @param id company identifier
 
 */
 
void DeleteCompanyWindows(CompanyID id)
 
{
 
	Window *w;
 

	
 
restart_search:
 
	/* When we find the window to delete, we need to restart the search
 
@@ -786,13 +787,14 @@ restart_search:
 

	
 
/**
 
 * Change the owner of all the windows one company can take over from another
 
 * company in the case of a company merger. Do not change ownership of windows
 
 * that need to be deleted once takeover is complete
 
 * @param old_owner original owner of the window
 
 * @param new_owner the new owner of the window */
 
 * @param new_owner the new owner of the window
 
 */
 
void ChangeWindowOwner(Owner old_owner, Owner new_owner)
 
{
 
	Window *w;
 
	FOR_ALL_WINDOWS_FROM_BACK(w) {
 
		if (w->owner != old_owner) continue;
 

	
 
@@ -819,13 +821,14 @@ static void BringWindowToFront(Window *w
 

	
 
/**
 
 * Find a window and make it the top-window on the screen.
 
 * The window gets unshaded if it was shaded, and a white border is drawn at its edges for a brief period of time to visualize its "activation".
 
 * @param cls WindowClass of the window to activate
 
 * @param number WindowNumber of the window to activate
 
 * @return a pointer to the window thus activated */
 
 * @return a pointer to the window thus activated
 
 */
 
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number)
 
{
 
	Window *w = FindWindowById(cls, number);
 

	
 
	if (w != NULL) {
 
		if (w->IsShaded()) w->SetShaded(false); // Restore original window size if it was shaded.
 
@@ -1319,13 +1322,14 @@ Window::Window() : hscroll(false), vscro
 

	
 
/**
 
 * Do a search for a window at specific coordinates. For this we start
 
 * at the topmost window, obviously and work our way down to the bottom
 
 * @param x position x to query
 
 * @param y position y to query
 
 * @return a pointer to the found window if any, NULL otherwise */
 
 * @return a pointer to the found window if any, NULL otherwise
 
 */
 
Window *FindWindowFromPt(int x, int y)
 
{
 
	Window *w;
 
	FOR_ALL_WINDOWS_FROM_FRONT(w) {
 
		if (IsInsideBS(x, w->left, w->width) && IsInsideBS(y, w->top, w->height)) {
 
			return w;
 
@@ -1929,13 +1933,14 @@ static EventState HandleViewportScroll()
 
 * it. If a window does not obscure any other windows, it will not
 
 * be brought to the foreground. Also if the only obscuring windows
 
 * are so-called system-windows, the window will not be moved.
 
 * The function will return false when a child window of this window is a
 
 * modal-popup; function returns a false and child window gets a white border
 
 * @param w Window to bring on-top
 
 * @return false if the window has an active modal child, true otherwise */
 
 * @return false if the window has an active modal child, true otherwise
 
 */
 
static bool MaybeBringWindowToFront(Window *w)
 
{
 
	bool bring_to_front = false;
 

	
 
	if (w->window_class == WC_MAIN_WINDOW ||
 
			IsVitalWindow(w) ||
 
@@ -2561,13 +2566,14 @@ restart_search:
 

	
 
/**
 
 * It is possible that a stickied window gets to a position where the
 
 * 'close' button is outside the gaming area. You cannot close it then; except
 
 * with this function. It closes all windows calling the standard function,
 
 * then, does a little hacked loop of closing all stickied windows. Note
 
 * that standard windows (status bar, etc.) are not stickied, so these aren't affected */
 
 * that standard windows (status bar, etc.) are not stickied, so these aren't affected
 
 */
 
void DeleteAllNonVitalWindows()
 
{
 
	Window *w;
 

	
 
	/* Delete every window except for stickied ones, then sticky ones as well */
 
	DeleteNonVitalWindows();
0 comments (0 inline, 0 general)