Changeset - r23538:8df50944b27a
[Not reviewed]
master
! ! !
Henry Wilson - 5 years ago 2019-03-03 17:30:09
m3henry@googlemail.com
Codechange: Removed SmallVector completely
69 files changed with 109 insertions and 127 deletions:
0 comments (0 inline, 0 general)
src/animated_tile.cpp
Show inline comments
 
@@ -16,13 +16,13 @@
 
#include "viewport_func.h"
 
#include "framerate_type.h"
 

	
 
#include "safeguards.h"
 

	
 
/** The table/list with animated tiles. */
 
SmallVector<TileIndex, 256> _animated_tiles;
 
std::vector<TileIndex> _animated_tiles;
 

	
 
/**
 
 * Removes the given tile from the animated tile table.
 
 * @param tile the tile to remove
 
 */
 
void DeleteAnimatedTile(TileIndex tile)
src/company_gui.cpp
Show inline comments
 
@@ -559,13 +559,13 @@ private:
 
	uint32 sel;
 
	LiveryClass livery_class;
 
	Dimension square;
 
	uint rows;
 
	uint line_height;
 
	GUIGroupList groups;
 
	SmallVector<int, 32> indents;
 
	std::vector<int> indents;
 
	Scrollbar *vscroll;
 

	
 
	void ShowColourDropDownMenu(uint32 widget)
 
	{
 
		uint32 used_colours = 0;
 
		const Company *c;
src/core/pool_type.hpp
Show inline comments
 
@@ -23,13 +23,13 @@ enum PoolType {
 
	PT_NADMIN  = 0x04, ///< Network admin pool.
 
	PT_DATA    = 0x08, ///< NewGRF or other data, that is not reset together with normal pools.
 
	PT_ALL     = 0x0F, ///< All pool types.
 
};
 
DECLARE_ENUM_AS_BIT_SET(PoolType)
 

	
 
typedef SmallVector<struct PoolBase *, 4> PoolVector; ///< Vector of pointers to PoolBase
 
typedef std::vector<struct PoolBase *> PoolVector; ///< Vector of pointers to PoolBase
 

	
 
/** Base class for base of all pools. */
 
struct PoolBase {
 
	const PoolType type; ///< Type of this pool.
 

	
 
	/**
src/core/smallmap_type.hpp
Show inline comments
 
@@ -37,13 +37,13 @@ struct SmallPair {
 
 * @tparam U Value type.
 
 * @tparam S Unit of allocation.
 
 *
 
 * @see SmallVector
 
 */
 
template <typename T, typename U, uint S = 16>
 
struct SmallMap : SmallVector<SmallPair<T, U>, S> {
 
struct SmallMap : std::vector<SmallPair<T, U> > {
 
	typedef ::SmallPair<T, U> Pair;
 
	typedef Pair *iterator;
 
	typedef const Pair *const_iterator;
 

	
 
	/** Creates new SmallMap. Data are initialized in SmallVector constructor */
 
	inline SmallMap() { }
src/core/smallstack_type.hpp
Show inline comments
 
@@ -84,13 +84,13 @@ private:
 
	};
 

	
 
	Tindex first_unused;
 
	Tindex first_free;
 

	
 
	ThreadMutex *mutex;
 
	SmallVector<SimplePoolPoolItem, Tgrowth_step> data;
 
	std::vector<SimplePoolPoolItem> data;
 
};
 

	
 
/**
 
 * Base class for SmallStack. We cannot add this into SmallStack itself as
 
 * certain compilers don't like it.
 
 */
src/core/smallvec_type.hpp
Show inline comments
 
@@ -31,28 +31,12 @@ inline bool include(std::vector<T>& vec,
 
{
 
	const bool is_member = std::find(vec.begin(), vec.end(), item) != vec.end();
 
	if (!is_member) vec.emplace_back(item);
 
	return is_member;
 
}
 

	
 

	
 
/**
 
 * Simple vector template class.
 
 *
 
 * @note There are no asserts in the class so you have
 
 *       to care about that you grab an item which is
 
 *       inside the list.
 
 *
 
 * @tparam T The type of the items stored
 
 * @tparam S The steps of allocation
 
 */
 

	
 

	
 
template <typename T, uint S>
 
using SmallVector = std::vector<T>;
 

	
 
/**
 
 * Helper function to get the index of an item
 
 * Consider using std::set, std::unordered_set or std::flat_set in new code
 
 *
 
 * @param vec A reference to the vector to be extended
 
 * @param item Reference to the item to be search for
 
@@ -70,37 +54,36 @@ int find_index(std::vector<T> const& vec
 

	
 
/**
 
 * Helper function to append N default-constructed elements and get a pointer to the first new element
 
 * Consider using std::back_inserter in new code
 
 *
 
 * @param vec A reference to the vector to be extended
 
 * @param num The number of elements to default-construct
 
 * @param num Number of elements to be default-constructed
 
 *
 
 * @return Pointer to the first new element
 
 */
 
template <typename T>
 
inline T* grow(std::vector<T>& vec, std::size_t num)
 
T* grow(std::vector<T>& vec, std::size_t num)
 
{
 
	const std::size_t pos = vec.size();
 
	std::size_t const pos = vec.size();
 
	vec.resize(pos + num);
 
	return vec.data() + pos;
 
}
 

	
 

	
 
/**
 
 * Simple vector template class, with automatic free.
 
 *
 
 * @note There are no asserts in the class so you have
 
 *       to care about that you grab an item which is
 
 *       inside the list.
 
 *
 
 * @param T The type of the items stored, must be a pointer
 
 * @param S The steps of allocation
 
 */
 
template <typename T, uint S>
 
class AutoFreeSmallVector : public SmallVector<T, S> {
 
class AutoFreeSmallVector : public std::vector<T> {
 
public:
 
	~AutoFreeSmallVector()
 
	{
 
		this->Clear();
 
	}
 

	
 
@@ -125,13 +108,13 @@ public:
 
 *       inside the list.
 
 *
 
 * @param T The type of the items stored, must be a pointer
 
 * @param S The steps of allocation
 
 */
 
template <typename T, uint S>
 
class AutoDeleteSmallVector : public SmallVector<T, S> {
 
class AutoDeleteSmallVector : public std::vector<T> {
 
public:
 
	~AutoDeleteSmallVector()
 
	{
 
		this->Clear();
 
	}
 

	
src/economy.cpp
Show inline comments
 
@@ -74,13 +74,13 @@ INSTANTIATE_POOL_METHODS(CargoPayment)
 
 */
 
static inline int32 BigMulS(const int32 a, const int32 b, const uint8 shift)
 
{
 
	return (int32)((int64)a * (int64)b >> shift);
 
}
 

	
 
typedef SmallVector<Industry *, 16> SmallIndustryList;
 
typedef std::vector<Industry *> SmallIndustryList;
 

	
 
/**
 
 * Score info, values used for computing the detailed performance rating.
 
 */
 
const ScoreInfo _score_info[] = {
 
	{     120, 100}, // SCORE_VEHICLES
src/engine_base.h
Show inline comments
 
@@ -153,13 +153,13 @@ struct EngineIDMapping {
 
};
 

	
 
/**
 
 * Stores the mapping of EngineID to the internal id of newgrfs.
 
 * Note: This is not part of Engine, as the data in the EngineOverrideManager and the engine pool get resetted in different cases.
 
 */
 
struct EngineOverrideManager : SmallVector<EngineIDMapping, 256> {
 
struct EngineOverrideManager : std::vector<EngineIDMapping> {
 
	static const uint NUM_DEFAULT_ENGINES; ///< Number of default entries
 

	
 
	void ResetToDefaultMapping();
 
	EngineID GetID(VehicleType type, uint16 grf_local_id, uint32 grfid);
 

	
 
	static bool ResetToCurrentNewGRFConfig();
src/fios.cpp
Show inline comments
 
@@ -652,13 +652,13 @@ struct ScenarioIdentifier {
 
	}
 
};
 

	
 
/**
 
 * Scanner to find the unique IDs of scenarios
 
 */
 
class ScenarioScanner : protected FileScanner, public SmallVector<ScenarioIdentifier, 8> {
 
class ScenarioScanner : protected FileScanner, public std::vector<ScenarioIdentifier> {
 
	bool scanned; ///< Whether we've already scanned
 
public:
 
	/** Initialise */
 
	ScenarioScanner() : scanned(false) {}
 

	
 
	/**
src/fios.h
Show inline comments
 
@@ -195,13 +195,13 @@ public:
 
		this->files.shrink_to_fit();
 
	}
 

	
 
	void BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop);
 
	const FiosItem *FindItem(const char *file);
 

	
 
	SmallVector<FiosItem, 32> files; ///< The list of files.
 
	std::vector<FiosItem> files; ///< The list of files.
 
};
 

	
 
enum SortingBits {
 
	SORT_ASCENDING  = 0,
 
	SORT_DESCENDING = 1,
 
	SORT_BY_DATE    = 0,
src/group_gui.cpp
Show inline comments
 
@@ -118,13 +118,13 @@ private:
 
	GroupID group_over;    ///< Group over which a vehicle is dragged, INVALID_GROUP if none
 
	GroupID group_confirm; ///< Group awaiting delete confirmation
 
	GUIGroupList groups;   ///< List of groups
 
	uint tiny_step_height; ///< Step height for the group list
 
	Scrollbar *group_sb;
 

	
 
	SmallVector<int, 16> indents; ///< Indentation levels
 
	std::vector<int> indents; ///< Indentation levels
 

	
 
	Dimension column_size[VGC_END]; ///< Size of the columns in the group list.
 

	
 
	void AddChildren(GUIGroupList *source, GroupID parent, int indent)
 
	{
 
		for (const Group *g : *source) {
src/hotkeys.cpp
Show inline comments
 
@@ -21,13 +21,13 @@
 
char *_hotkeys_file;
 

	
 
/**
 
 * List of all HotkeyLists.
 
 * This is a pointer to ensure initialisation order with the various static HotkeyList instances.
 
 */
 
static SmallVector<HotkeyList*, 16> *_hotkey_lists = NULL;
 
static std::vector<HotkeyList*> *_hotkey_lists = NULL;
 

	
 
/** String representation of a keycode */
 
struct KeycodeNames {
 
	const char *name;       ///< Name of the keycode
 
	WindowKeyCodes keycode; ///< The keycode
 
};
 
@@ -251,13 +251,13 @@ void Hotkey::AddKeycode(uint16 keycode)
 
	include(this->keycodes, keycode);
 
}
 

	
 
HotkeyList::HotkeyList(const char *ini_group, Hotkey *items, GlobalHotkeyHandlerFunc global_hotkey_handler) :
 
	global_hotkey_handler(global_hotkey_handler), ini_group(ini_group), items(items)
 
{
 
	if (_hotkey_lists == NULL) _hotkey_lists = new SmallVector<HotkeyList*, 16>();
 
	if (_hotkey_lists == NULL) _hotkey_lists = new std::vector<HotkeyList*>();
 
	_hotkey_lists->push_back(this);
 
}
 

	
 
HotkeyList::~HotkeyList()
 
{
 
	_hotkey_lists->erase(std::find(_hotkey_lists->begin(), _hotkey_lists->end(), this));
src/hotkeys.h
Show inline comments
 
@@ -26,13 +26,13 @@ struct Hotkey {
 
	Hotkey(const uint16 *default_keycodes, const char *name, int num);
 

	
 
	void AddKeycode(uint16 keycode);
 

	
 
	const char *name;
 
	int num;
 
	SmallVector<uint16, 1> keycodes;
 
	std::vector<uint16> keycodes;
 
};
 

	
 
#define HOTKEY_LIST_END Hotkey((uint16)0, NULL, -1)
 

	
 
struct IniFile;
 

	
src/industry_cmd.cpp
Show inline comments
 
@@ -1881,13 +1881,13 @@ static CommandCost CreateNewIndustryHelp
 
	assert(itspec_index < indspec->num_table);
 
	const IndustryTileTable *it = indspec->table[itspec_index];
 
	bool custom_shape_check = false;
 

	
 
	*ip = NULL;
 

	
 
	SmallVector<ClearedObjectArea, 1> object_areas(_cleared_object_areas);
 
	std::vector<ClearedObjectArea> object_areas(_cleared_object_areas);
 
	CommandCost ret = CheckIfIndustryTilesAreFree(tile, it, itspec_index, type, random_initial_bits, founder, creation_type, &custom_shape_check);
 
	_cleared_object_areas = object_areas;
 
	if (ret.Failed()) return ret;
 

	
 
	if (HasBit(GetIndustrySpec(type)->callback_mask, CBM_IND_LOCATION)) {
 
		ret = CheckIfCallBackAllowsCreation(tile, type, itspec_index, random_var8f, random_initial_bits, founder, creation_type);
src/industry_gui.cpp
Show inline comments
 
@@ -2152,13 +2152,13 @@ next_cargo: ;
 
 * produced cargoes, customer industries). Displaying the industries around a cargo needs three columns (supplying industries, the cargo,
 
 * customer industries). The remaining two columns are set to #CFT_EMPTY with a width equal to the average of a cargo and an industry column.
 
 */
 
struct IndustryCargoesWindow : public Window {
 
	static const int HOR_TEXT_PADDING, VERT_TEXT_PADDING;
 

	
 
	typedef SmallVector<CargoesRow, 4> Fields;
 
	typedef std::vector<CargoesRow> Fields;
 

	
 
	Fields fields;  ///< Fields to display in the #WID_IC_PANEL.
 
	uint ind_cargo; ///< If less than #NUM_INDUSTRYTYPES, an industry type, else a cargo id + NUM_INDUSTRYTYPES.
 
	Dimension cargo_textsize; ///< Size to hold any cargo text, as well as STR_INDUSTRY_CARGOES_SELECT_CARGO.
 
	Dimension ind_textsize;   ///< Size to hold any industry type text, as well as STR_INDUSTRY_CARGOES_SELECT_INDUSTRY.
 
	Scrollbar *vscroll;
src/language.h
Show inline comments
 
@@ -93,13 +93,13 @@ assert_compile(sizeof(LanguagePackHeader
 
/** Metadata about a single language. */
 
struct LanguageMetadata : public LanguagePackHeader {
 
	char file[MAX_PATH]; ///< Name of the file we read this data from.
 
};
 

	
 
/** Type for the list of language meta data. */
 
typedef SmallVector<LanguageMetadata, 4> LanguageList;
 
typedef std::vector<LanguageMetadata> LanguageList;
 

	
 
/** The actual list of language meta data. */
 
extern LanguageList _languages;
 

	
 
/** The currently loaded language. */
 
extern const LanguageMetadata *_current_language;
src/linkgraph/linkgraph.h
Show inline comments
 
@@ -432,13 +432,13 @@ public:
 

	
 
		void AddEdge(NodeID to, uint capacity, uint usage, EdgeUpdateMode mode);
 
		void UpdateEdge(NodeID to, uint capacity, uint usage, EdgeUpdateMode mode);
 
		void RemoveEdge(NodeID to);
 
	};
 

	
 
	typedef SmallVector<BaseNode, 16> NodeVector;
 
	typedef std::vector<BaseNode> NodeVector;
 
	typedef SmallMatrix<BaseEdge> EdgeMatrix;
 

	
 
	/** Minimum effective distance for timeout calculation. */
 
	static const uint MIN_TIMEOUT_DISTANCE = 32;
 

	
 
	/** Minimum number of days between subsequent compressions of a LG. */
src/linkgraph/linkgraphjob.h
Show inline comments
 
@@ -47,13 +47,13 @@ private:
 
		uint undelivered_supply; ///< Amount of supply that hasn't been distributed yet.
 
		PathList paths;          ///< Paths through this node, sorted so that those with flow == 0 are in the back.
 
		FlowStatMap flows;       ///< Planned flows to other nodes.
 
		void Init(uint supply);
 
	};
 

	
 
	typedef SmallVector<NodeAnnotation, 16> NodeAnnotationVector;
 
	typedef std::vector<NodeAnnotation> NodeAnnotationVector;
 
	typedef SmallMatrix<EdgeAnnotation> EdgeAnnotationMatrix;
 

	
 
	friend const SaveLoad *GetLinkGraphJobDesc();
 
	friend class LinkGraphSchedule;
 

	
 
protected:
src/music/midifile.hpp
Show inline comments
 
@@ -21,13 +21,13 @@
 
struct MusicSongInfo;
 

	
 
struct MidiFile {
 
	struct DataBlock {
 
		uint32 ticktime;           ///< tick number since start of file this block should be triggered at
 
		uint32 realtime;           ///< real-time (microseconds) since start of file this block should be triggered at
 
		SmallVector<byte, 8> data; ///< raw midi data contained in block
 
		std::vector<byte> data; ///< raw midi data contained in block
 
		DataBlock(uint32 _ticktime = 0) : ticktime(_ticktime) { }
 
	};
 
	struct TempoChange {
 
		uint32 ticktime; ///< tick number since start of file this tempo change occurs at
 
		uint32 tempo;    ///< new tempo in microseconds per tick
 
		TempoChange(uint32 _ticktime, uint32 _tempo) : ticktime(_ticktime), tempo(_tempo) { }
src/network/core/address.h
Show inline comments
 
@@ -15,13 +15,13 @@
 
#include "os_abstraction.h"
 
#include "config.h"
 
#include "../../string_func.h"
 
#include "../../core/smallmap_type.hpp"
 

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

	
 
/**
 
 * Wrapper for (un)resolved network addresses; there's no reason to transform
 
 * a numeric IP to a string and then back again to pass it to functions. It
 
 * furthermore allows easier delaying of the hostname lookup.
src/network/core/tcp_connect.cpp
Show inline comments
 
@@ -16,13 +16,13 @@
 

	
 
#include "tcp.h"
 

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

	
 
/** List of connections that are currently being created */
 
static SmallVector<TCPConnecter *,  1> _tcp_connecters;
 
static std::vector<TCPConnecter *> _tcp_connecters;
 

	
 
/**
 
 * Create a new connecter for the given address
 
 * @param address the (un)resolved address to connect to
 
 */
 
TCPConnecter::TCPConnecter(const NetworkAddress &address) :
src/network/core/tcp_http.cpp
Show inline comments
 
@@ -18,13 +18,13 @@
 

	
 
#include "tcp_http.h"
 

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

	
 
/** List of open HTTP connections. */
 
static SmallVector<NetworkHTTPSocketHandler *, 1> _http_connections;
 
static std::vector<NetworkHTTPSocketHandler *> _http_connections;
 

	
 
/**
 
 * Start the querying
 
 * @param s        the socket of this connection
 
 * @param callback the callback for HTTP retrieval
 
 * @param host     the hostname of the server to connect to
src/network/network_content.h
Show inline comments
 
@@ -13,15 +13,15 @@
 
#define NETWORK_CONTENT_H
 

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

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

	
 
/** Iterator for the content vector */
 
typedef ContentInfo **ContentIterator;
 
/** Iterator for the constant content vector */
 
typedef const ContentInfo * const * ConstContentIterator;
 

	
 
@@ -63,17 +63,17 @@ struct ContentCallback {
 

	
 
/**
 
 * Socket handler for the content server connection
 
 */
 
class ClientNetworkContentSocketHandler : public NetworkContentSocketHandler, ContentCallback, HTTPCallback {
 
protected:
 
	typedef SmallVector<ContentID, 4> ContentIDList; ///< List of content IDs to (possibly) select.
 
	SmallVector<ContentCallback *, 2> callbacks; ///< Callbacks to notify "the world"
 
	typedef std::vector<ContentID> ContentIDList; ///< List of content IDs to (possibly) select.
 
	std::vector<ContentCallback *> callbacks; ///< Callbacks to notify "the world"
 
	ContentIDList requested;                     ///< ContentIDs we already requested (so we don't do it again)
 
	ContentVector infos;                         ///< All content info we received
 
	SmallVector<char, 1024> http_response;       ///< The HTTP response to the requests we've been doing
 
	std::vector<char> http_response;       ///< The HTTP response to the requests we've been doing
 
	int http_response_index;                     ///< Where we are, in the response, with handling it
 

	
 
	FILE *curFile;        ///< Currently downloaded file
 
	ContentInfo *curInfo; ///< Information about the currently downloaded file
 
	bool isConnecting;    ///< Whether we're connecting
 
	uint32 lastActivity;  ///< The last time there was network activity
src/network/network_content_gui.cpp
Show inline comments
 
@@ -157,13 +157,13 @@ void BaseNetworkContentDownloadStatusWin
 
}
 

	
 

	
 
/** Window for showing the download status of content */
 
struct NetworkContentDownloadStatusWindow : public BaseNetworkContentDownloadStatusWindow {
 
private:
 
	SmallVector<ContentType, 4> receivedTypes;     ///< Types we received so we can update their cache
 
	std::vector<ContentType> receivedTypes;     ///< Types we received so we can update their cache
 

	
 
public:
 
	/**
 
	 * Create a new download window based on a list of content information
 
	 * with flags whether to download them or not.
 
	 */
src/network/network_gui.cpp
Show inline comments
 
@@ -1725,13 +1725,13 @@ struct NetworkClientListPopupWindow : Wi
 
		ClientList_Action_Proc *proc; ///< Action to execute
 
	};
 

	
 
	uint sel_index;
 
	ClientID client_id;
 
	Point desired_location;
 
	SmallVector<ClientListAction, 2> actions; ///< Actions to execute
 
	std::vector<ClientListAction> actions; ///< Actions to execute
 

	
 
	/**
 
	 * Add an action to the list of actions to execute.
 
	 * @param name the name of the action
 
	 * @param proc the procedure to execute for the action
 
	 */
src/newgrf.cpp
Show inline comments
 
@@ -62,13 +62,13 @@
 
 * Contains portions of documentation by TTDPatch team.
 
 * Thanks especially to Josef Drexler for the documentation as well as a lot
 
 * of help at #tycoon. Also thanks to Michael Blunck for his GRF files which
 
 * served as subject to the initial testing of this codec. */
 

	
 
/** List of all loaded GRF files */
 
static SmallVector<GRFFile *, 16> _grf_files;
 
static std::vector<GRFFile *> _grf_files;
 

	
 
/** Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E */
 
byte _misc_grf_features = 0;
 

	
 
/** 32 * 8 = 256 flags. Apparently TTDPatch uses this many.. */
 
static uint32 _ttdpatch_flags[8];
 
@@ -456,13 +456,13 @@ static GRFError *DisableGrf(StringID mes
 
 */
 
struct StringIDMapping {
 
	uint32 grfid;     ///< Source NewGRF.
 
	StringID source;  ///< Source StringID (GRF local).
 
	StringID *target; ///< Destination for mapping result.
 
};
 
typedef SmallVector<StringIDMapping, 16> StringIDMappingVector;
 
typedef std::vector<StringIDMapping> StringIDMappingVector;
 
static StringIDMappingVector _string_to_grf_mapping;
 

	
 
/**
 
 * Record a static StringID for getting translated later.
 
 * @param source Source StringID (GRF local).
 
 * @param target Destination for the mapping result.
 
@@ -1898,13 +1898,13 @@ static ChangeInfoResult StationChangeInf
 
					}
 

	
 
					ReadSpriteLayoutSprite(buf, false, false, false, GSF_STATIONS, &dts->ground);
 
					/* On error, bail out immediately. Temporary GRF data was already freed */
 
					if (_cur.skip_sprites < 0) return CIR_DISABLED;
 

	
 
					static SmallVector<DrawTileSeqStruct, 8> tmp_layout;
 
					static std::vector<DrawTileSeqStruct> tmp_layout;
 
					tmp_layout.clear();
 
					for (;;) {
 
						/* no relative bounding box support */
 
						/*C++17: DrawTileSeqStruct &dtss = */ tmp_layout.emplace_back();
 
						DrawTileSeqStruct &dtss = tmp_layout.back();
 
						MemSetT(&dtss, 0);
 
@@ -4784,13 +4784,13 @@ static void NewSpriteGroup(ByteReader *b
 
				default: NOT_REACHED();
 
				case 0: group->size = DSG_SIZE_BYTE;  varsize = 1; break;
 
				case 1: group->size = DSG_SIZE_WORD;  varsize = 2; break;
 
				case 2: group->size = DSG_SIZE_DWORD; varsize = 4; break;
 
			}
 

	
 
			static SmallVector<DeterministicSpriteGroupAdjust, 16> adjusts;
 
			static std::vector<DeterministicSpriteGroupAdjust> adjusts;
 
			adjusts.clear();
 

	
 
			/* Loop through the var adjusts. Unfortunately we don't know how many we have
 
			 * from the outset, so we shall have to keep reallocing. */
 
			do {
 
				/*C++17: DeterministicSpriteGroupAdjust &adjust = */ adjusts.emplace_back();
src/newgrf.h
Show inline comments
 
@@ -119,16 +119,16 @@ struct GRFFile : ZeroedMemoryAllocator {
 

	
 
	uint32 param[0x80];
 
	uint param_end;  ///< one more than the highest set parameter
 

	
 
	GRFLabel *label; ///< Pointer to the first label. This is a linked list, not an array.
 

	
 
	SmallVector<CargoLabel, 4> cargo_list;          ///< Cargo translation table (local ID -> label)
 
	std::vector<CargoLabel> cargo_list;          ///< Cargo translation table (local ID -> label)
 
	uint8 cargo_map[NUM_CARGO];                     ///< Inverse cargo translation table (CargoID -> local ID)
 

	
 
	SmallVector<RailTypeLabel, 4> railtype_list;    ///< Railtype translation table
 
	std::vector<RailTypeLabel> railtype_list;    ///< Railtype translation table
 
	RailTypeByte railtype_map[RAILTYPE_END];
 

	
 
	CanalProperties canal_local_properties[CF_END]; ///< Canal properties as set by this NewGRF
 

	
 
	struct LanguageMap *language_map; ///< Mappings related to the languages.
 

	
src/newgrf_commons.cpp
Show inline comments
 
@@ -576,13 +576,13 @@ bool Convert8bitBooleanCallback(const GR
 

	
 
	if (cb_res > 1) ErrorUnknownCallbackResult(grffile->grfid, cbid, cb_res);
 
	return cb_res != 0;
 
}
 

	
 

	
 
/* static */ SmallVector<DrawTileSeqStruct, 8> NewGRFSpriteLayout::result_seq;
 
/* static */ std::vector<DrawTileSeqStruct> NewGRFSpriteLayout::result_seq;
 

	
 
/**
 
 * Clone the building sprites of a spritelayout.
 
 * @param source The building sprites to copy.
 
 */
 
void NewGRFSpriteLayout::Clone(const DrawTileSeqStruct *source)
src/newgrf_commons.h
Show inline comments
 
@@ -167,13 +167,13 @@ struct NewGRFSpriteLayout : ZeroedMemory
 
		DrawTileSeqStruct *front = result_seq.data();
 
		*ground = front->image;
 
		return front + 1;
 
	}
 

	
 
private:
 
	static SmallVector<DrawTileSeqStruct, 8> result_seq; ///< Temporary storage when preprocessing spritelayouts.
 
	static std::vector<DrawTileSeqStruct> result_seq; ///< Temporary storage when preprocessing spritelayouts.
 
};
 

	
 
/**
 
 * Maps an entity id stored on the map to a GRF file.
 
 * Entities are objects used ingame (houses, industries, industry tiles) for
 
 * which we need to correlate the ids from the grf files with the ones in the
src/newgrf_config.h
Show inline comments
 
@@ -169,13 +169,13 @@ struct GRFConfig : ZeroedMemoryAllocator
 
	GRFStatus status;                              ///< NOSAVE: GRFStatus, enum
 
	uint32 grf_bugs;                               ///< NOSAVE: bugs in this GRF in this run, @see enum GRFBugs
 
	uint32 param[0x80];                            ///< GRF parameters
 
	uint8 num_params;                              ///< Number of used parameters
 
	uint8 num_valid_params;                        ///< NOSAVE: Number of valid parameters (action 0x14)
 
	uint8 palette;                                 ///< GRFPalette, bitset
 
	SmallVector<GRFParameterInfo *, 4> param_info; ///< NOSAVE: extra information about the parameters
 
	std::vector<GRFParameterInfo *> param_info; ///< NOSAVE: extra information about the parameters
 
	bool has_param_defaults;                       ///< NOSAVE: did this newgrf specify any defaults for it's parameters
 

	
 
	struct GRFConfig *next;                        ///< NOSAVE: Next item in the linked list
 

	
 
	void CopyParams(const GRFConfig &src);
 

	
src/newgrf_debug.h
Show inline comments
 
@@ -26,13 +26,13 @@ enum NewGrfDebugSpritePickerMode {
 

	
 
/** Spritepicker of SpriteAligner */
 
struct NewGrfDebugSpritePicker {
 
	NewGrfDebugSpritePickerMode mode;   ///< Current state
 
	void *clicked_pixel;                ///< Clicked pixel (pointer to blitter buffer)
 
	uint32 click_time;                  ///< Realtime tick when clicked to detect next frame
 
	SmallVector<SpriteID, 256> sprites; ///< Sprites found
 
	std::vector<SpriteID> sprites; ///< Sprites found
 
};
 

	
 
extern NewGrfDebugSpritePicker _newgrf_debug_sprite_picker;
 

	
 
bool IsNewGRFInspectable(GrfSpecFeature feature, uint index);
 
void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32 grfid = 0);
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -44,13 +44,13 @@
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/** The sprite picker. */
 
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, NULL, 0, SmallVector<SpriteID, 256>() };
 
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, NULL, 0, std::vector<SpriteID>() };
 

	
 
/**
 
 * Get the feature index related to the window number.
 
 * @param window_number The window to get the feature index from.
 
 * @return the feature index
 
 */
 
@@ -891,13 +891,13 @@ struct SpriteAlignerWindow : Window {
 
			}
 

	
 
			case WID_SA_LIST: {
 
				const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget);
 
				int step_size = nwid->resize_y;
 

	
 
				SmallVector<SpriteID, 256> &list = _newgrf_debug_sprite_picker.sprites;
 
				std::vector<SpriteID> &list = _newgrf_debug_sprite_picker.sprites;
 
				int max = min<int>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), list.size());
 

	
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				for (int i = this->vscroll->GetPosition(); i < max; i++) {
 
					SetDParam(0, list[i]);
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_BLACK_COMMA, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
src/newgrf_engine.cpp
Show inline comments
 
@@ -1182,13 +1182,13 @@ void TriggerVehicle(Vehicle *v, VehicleT
 

	
 
struct ListOrderChange {
 
	EngineID engine;
 
	uint target;      ///< local ID
 
};
 

	
 
static SmallVector<ListOrderChange, 16> _list_order_changes;
 
static std::vector<ListOrderChange> _list_order_changes;
 

	
 
/**
 
 * Record a vehicle ListOrderChange.
 
 * @param engine Engine to move
 
 * @param target Local engine ID to move \a engine in front of
 
 * @note All sorting is done later in CommitVehicleListOrderChanges
 
@@ -1223,13 +1223,13 @@ static int CDECL EnginePreSort(const Eng
 
/**
 
 * Deternine default engine sorting and execute recorded ListOrderChanges from AlterVehicleListOrder.
 
 */
 
void CommitVehicleListOrderChanges()
 
{
 
	/* Pre-sort engines by scope-grfid and local index */
 
	SmallVector<EngineID, 16> ordering;
 
	std::vector<EngineID> ordering;
 
	Engine *e;
 
	FOR_ALL_ENGINES(e) {
 
		ordering.push_back(e->index);
 
	}
 
	QSortT(ordering.data(), ordering.size(), EnginePreSort);
 

	
src/newgrf_sound.cpp
Show inline comments
 
@@ -19,13 +19,13 @@
 
#include "fileio_func.h"
 
#include "debug.h"
 
#include "settings_type.h"
 

	
 
#include "safeguards.h"
 

	
 
static SmallVector<SoundEntry, 8> _sounds;
 
static std::vector<SoundEntry> _sounds;
 

	
 

	
 
/**
 
 * Allocate sound slots.
 
 * @param num Number of slots to allocate.
 
 * @return First allocated slot.
src/newgrf_text.cpp
Show inline comments
 
@@ -164,13 +164,13 @@ static byte _currentLangID = GRFLX_ENGLI
 
 * @param newgrf_id The NewGRF ID to map.
 
 * @param gender    Whether to map genders or cases.
 
 * @return The, to OpenTTD's internal ID, mapped index, or -1 if there is no mapping.
 
 */
 
int LanguageMap::GetMapping(int newgrf_id, bool gender) const
 
{
 
	const SmallVector<Mapping, 1> &map = gender ? this->gender_map : this->case_map;
 
	const std::vector<Mapping> &map = gender ? this->gender_map : this->case_map;
 
	for (const Mapping &m : map) {
 
		if (m.newgrf_id == newgrf_id) return m.openttd_id;
 
	}
 
	return -1;
 
}
 

	
 
@@ -179,13 +179,13 @@ int LanguageMap::GetMapping(int newgrf_i
 
 * @param openttd_id The OpenTTD ID to map.
 
 * @param gender     Whether to map genders or cases.
 
 * @return The, to the NewGRF supplied ID, mapped index, or -1 if there is no mapping.
 
 */
 
int LanguageMap::GetReverseMapping(int openttd_id, bool gender) const
 
{
 
	const SmallVector<Mapping, 1> &map = gender ? this->gender_map : this->case_map;
 
	const std::vector<Mapping> &map = gender ? this->gender_map : this->case_map;
 
	for (const Mapping &m : map) {
 
		if (m.openttd_id == openttd_id) return m.newgrf_id;
 
	}
 
	return -1;
 
}
 

	
src/newgrf_text.h
Show inline comments
 
@@ -54,14 +54,14 @@ struct LanguageMap {
 
	/* We need a vector and can't use SmallMap due to the fact that for "setting" a
 
	 * gender of a string or requesting a case for a substring we want to map from
 
	 * the NewGRF's internal ID to OpenTTD's ID whereas for the choice lists we map
 
	 * the genders/cases/plural OpenTTD IDs to the NewGRF's internal IDs. In this
 
	 * case a NewGRF developer/translator might want a different translation for
 
	 * both cases. Thus we are basically implementing a multi-map. */
 
	SmallVector<Mapping, 1> gender_map; ///< Mapping of NewGRF and OpenTTD IDs for genders.
 
	SmallVector<Mapping, 1> case_map;   ///< Mapping of NewGRF and OpenTTD IDs for cases.
 
	std::vector<Mapping> gender_map; ///< Mapping of NewGRF and OpenTTD IDs for genders.
 
	std::vector<Mapping> case_map;   ///< Mapping of NewGRF and OpenTTD IDs for cases.
 
	int plural_form;                    ///< The plural form used for this language.
 

	
 
	int GetMapping(int newgrf_id, bool gender) const;
 
	int GetReverseMapping(int openttd_id, bool gender) const;
 
	static const LanguageMap *GetLanguageMap(uint32 grfid, uint8 language_id);
 
};
src/object_base.h
Show inline comments
 
@@ -89,9 +89,9 @@ protected:
 
struct ClearedObjectArea {
 
	TileIndex first_tile;  ///< The first tile being cleared, which then causes the whole object to be cleared.
 
	TileArea area;         ///< The area of the object.
 
};
 

	
 
ClearedObjectArea *FindClearedObject(TileIndex tile);
 
extern SmallVector<ClearedObjectArea, 4> _cleared_object_areas;
 
extern std::vector<ClearedObjectArea> _cleared_object_areas;
 

	
 
#endif /* OBJECT_BASE_H */
src/object_cmd.cpp
Show inline comments
 
@@ -439,13 +439,13 @@ static void ReallyClearObjectTile(Object
 

	
 
		MakeWaterKeepingClass(tile_cur, GetTileOwner(tile_cur));
 
	}
 
	delete o;
 
}
 

	
 
SmallVector<ClearedObjectArea, 4> _cleared_object_areas;
 
std::vector<ClearedObjectArea> _cleared_object_areas;
 

	
 
/**
 
 * Find the entry in _cleared_object_areas which occupies a certain tile.
 
 * @param tile Tile of interest
 
 * @return Occupying entry, or NULL if none
 
 */
src/openttd.cpp
Show inline comments
 
@@ -1171,13 +1171,13 @@ static void CheckCaches()
 
{
 
	/* Return here so it is easy to add checks that are run
 
	 * always to aid testing of caches. */
 
	if (_debug_desync_level <= 1) return;
 

	
 
	/* Check the town caches. */
 
	SmallVector<TownCache, 4> old_town_caches;
 
	std::vector<TownCache> old_town_caches;
 
	Town *t;
 
	FOR_ALL_TOWNS(t) {
 
		old_town_caches.push_back(t->cache);
 
	}
 

	
 
	extern void RebuildTownCaches();
 
@@ -1190,13 +1190,13 @@ static void CheckCaches()
 
			DEBUG(desync, 2, "town cache mismatch: town %i", (int)t->index);
 
		}
 
		i++;
 
	}
 

	
 
	/* Check company infrastructure cache. */
 
	SmallVector<CompanyInfrastructure, 4> old_infrastructure;
 
	std::vector<CompanyInfrastructure> old_infrastructure;
 
	Company *c;
 
	FOR_ALL_COMPANIES(c) old_infrastructure.push_back(c->infrastructure);
 

	
 
	extern void AfterLoadCompanyStats();
 
	AfterLoadCompanyStats();
 

	
src/rail.h
Show inline comments
 
@@ -115,13 +115,13 @@ enum RailFenceOffset {
 
	RFO_SLOPE_SE_SW,   //!< Slope SE,   Track Y,     Fence SW
 
	RFO_SLOPE_NE_SE,   //!< Slope NE,   Track X,     Fence SE
 
	RFO_SLOPE_NW_SW,   //!< Slope NW,   Track Y,     Fence SW
 
};
 

	
 
/** List of rail type labels. */
 
typedef SmallVector<RailTypeLabel, 4> RailTypeLabelList;
 
typedef std::vector<RailTypeLabel> RailTypeLabelList;
 

	
 
/**
 
 * This struct contains all the info that is needed to draw and construct tracks.
 
 */
 
class RailtypeInfo {
 
public:
src/rail_cmd.cpp
Show inline comments
 
@@ -38,13 +38,13 @@
 
#include "table/railtypes.h"
 
#include "table/track_land.h"
 

	
 
#include "safeguards.h"
 

	
 
/** Helper type for lists/vectors of trains */
 
typedef SmallVector<Train *, 16> TrainList;
 
typedef std::vector<Train *> TrainList;
 

	
 
RailtypeInfo _railtypes[RAILTYPE_END];
 
RailType _sorted_railtypes[RAILTYPE_END];
 
uint8 _sorted_railtypes_size;
 
RailTypes _railtypes_hidden_mask;
 

	
 
@@ -1600,13 +1600,13 @@ CommandCost CmdConvertRail(TileIndex til
 
		CommandCost ret = CheckTileOwnership(tile);
 
		if (ret.Failed()) {
 
			error = ret;
 
			continue;
 
		}
 

	
 
		SmallVector<Train *, 2> vehicles_affected;
 
		std::vector<Train *> vehicles_affected;
 

	
 
		/* Vehicle on the tile when not converting Rail <-> ElRail
 
		 * Tunnels and bridges have special check later */
 
		if (tt != MP_TUNNELBRIDGE) {
 
			if (!IsCompatibleRail(type, totype)) {
 
				CommandCost ret = IsPlainRailTile(tile) ? EnsureNoTrainOnTrackBits(tile, GetTrackBits(tile)) : EnsureNoVehicleOnGround(tile);
src/saveload/afterload.cpp
Show inline comments
 
@@ -2192,13 +2192,13 @@ bool AfterLoadGame()
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_122)) {
 
		/* Animated tiles would sometimes not be actually animated or
 
		 * in case of old savegames duplicate. */
 

	
 
		extern SmallVector<TileIndex, 256> _animated_tiles;
 
		extern std::vector<TileIndex> _animated_tiles;
 

	
 
		for (auto tile = _animated_tiles.begin(); tile < _animated_tiles.end(); /* Nothing */) {
 
			/* Remove if tile is not animated */
 
			bool remove = _tile_type_procs[GetTileType(*tile)]->animate_tile_proc == NULL;
 

	
 
			/* and remove if duplicate */
 
@@ -2936,13 +2936,13 @@ bool AfterLoadGame()
 
		 * Some curves were shorter than other curves.
 
		 * Now they have the same length, but that means that trailing articulated parts will
 
		 * take longer to go through the curve than the parts in front which already left the courve.
 
		 * So, make articulated parts catch up. */
 
		RoadVehicle *v;
 
		bool roadside = _settings_game.vehicle.road_side == 1;
 
		SmallVector<uint, 16> skip_frames;
 
		std::vector<uint> skip_frames;
 
		FOR_ALL_ROADVEHICLES(v) {
 
			if (!v->IsFrontEngine()) continue;
 
			skip_frames.clear();
 
			TileIndex prev_tile = v->tile;
 
			uint prev_tile_skip = 0;
 
			uint cur_skip = 0;
src/saveload/animated_tile_sl.cpp
Show inline comments
 
@@ -15,13 +15,13 @@
 
#include "../core/smallvec_type.hpp"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
extern SmallVector<TileIndex, 256> _animated_tiles;
 
extern std::vector<TileIndex> _animated_tiles;
 

	
 
/**
 
 * Save the ANIT chunk.
 
 */
 
static void Save_ANIT()
 
{
src/saveload/labelmaps_sl.cpp
Show inline comments
 
@@ -14,13 +14,13 @@
 
#include "../tunnelbridge_map.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
static SmallVector<RailTypeLabel, RAILTYPE_END> _railtype_list;
 
static std::vector<RailTypeLabel> _railtype_list;
 

	
 
/**
 
 * Test if any saved rail type labels are different to the currently loaded
 
 * rail types, which therefore requires conversion.
 
 * @return true if (and only if) conversion due to rail type changes is needed.
 
 */
 
@@ -39,13 +39,13 @@ static bool NeedRailTypeConversion()
 
	return false;
 
}
 

	
 
void AfterLoadLabelMaps()
 
{
 
	if (NeedRailTypeConversion()) {
 
		SmallVector<RailType, RAILTYPE_END> railtype_conversion_map;
 
		std::vector<RailType> railtype_conversion_map;
 

	
 
		for (uint i = 0; i < _railtype_list.size(); i++) {
 
			RailType r = GetRailTypeByLabel(_railtype_list[i]);
 
			if (r == INVALID_RAILTYPE) r = RAILTYPE_BEGIN;
 

	
 
			railtype_conversion_map.push_back(r);
src/saveload/linkgraph_sl.cpp
Show inline comments
 
@@ -48,13 +48,13 @@ const SaveLoad *GetLinkGraphDesc()
 
 * change the settings while in-game and still not mess with current link graph runs.
 
 * Of course the settings have to be saved and loaded, too, to avoid desyncs.
 
 * @return Array of SaveLoad structs.
 
 */
 
const SaveLoad *GetLinkGraphJobDesc()
 
{
 
	static SmallVector<SaveLoad, 16> saveloads;
 
	static std::vector<SaveLoad> saveloads;
 
	static const char *prefix = "linkgraph.";
 

	
 
	/* Build the SaveLoad array on first call and don't touch it later on */
 
	if (saveloads.size() == 0) {
 
		size_t offset_gamesettings = cpp_offsetof(GameSettings, linkgraph);
 
		size_t offset_component = cpp_offsetof(LinkGraphJob, settings);
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -488,13 +488,13 @@ static inline uint RemapTownIndex(uint x
 

	
 
static inline uint RemapOrderIndex(uint x)
 
{
 
	return _savegame_type == SGT_TTO ? (x - 0x1AC4) / 2 : (x - 0x1C18) / 2;
 
}
 

	
 
extern SmallVector<TileIndex, 256> _animated_tiles;
 
extern std::vector<TileIndex> _animated_tiles;
 
extern char *_old_name_array;
 

	
 
static uint32 _old_town_index;
 
static uint16 _old_string_id;
 
static uint16 _old_string_id_2;
 

	
src/saveload/waypoint_sl.cpp
Show inline comments
 
@@ -39,13 +39,13 @@ struct OldWaypoint {
 
	OwnerByte owner;
 

	
 
	size_t new_index;
 
};
 

	
 
/** Temporary array with old waypoints. */
 
static SmallVector<OldWaypoint, 16> _old_waypoints;
 
static std::vector<OldWaypoint> _old_waypoints;
 

	
 
/**
 
 * Update the waypoint orders to get the new waypoint ID.
 
 * @param o the order 'list' to check.
 
 */
 
static void UpdateWaypointOrder(Order *o)
src/script/squirrel_helper.hpp
Show inline comments
 
@@ -26,13 +26,13 @@ template <class CL, ScriptType ST> const
 
namespace SQConvert {
 
	/**
 
	 * Pointers assigned to this class will be free'd when this instance
 
	 *  comes out of scope. Useful to make sure you can use stredup(),
 
	 *  without leaking memory.
 
	 */
 
	struct SQAutoFreePointers : SmallVector<void *, 1> {
 
	struct SQAutoFreePointers : std::vector<void *> {
 
		~SQAutoFreePointers()
 
		{
 
			for (uint i = 0; i < std::vector<void *>::size(); i++) free(std::vector<void *>::operator[](i));
 
		}
 
	};
 

	
 
@@ -129,13 +129,13 @@ namespace SQConvert {
 

	
 
		SQObject obj;
 
		sq_getstackobj(vm, index, &obj);
 
		sq_pushobject(vm, obj);
 
		sq_pushnull(vm);
 

	
 
		SmallVector<int32, 2> data;
 
		std::vector<int32> data;
 

	
 
		while (SQ_SUCCEEDED(sq_next(vm, -2))) {
 
			SQInteger tmp;
 
			if (SQ_SUCCEEDED(sq_getinteger(vm, -1, &tmp))) {
 
				data.push_back((int32)tmp);
 
			} else {
src/settingsgen/settingsgen.cpp
Show inline comments
 
@@ -149,13 +149,13 @@ private:
 
	bool BufferHasRoom() const
 
	{
 
		uint num_blocks = this->output_buffer.size();
 
		return num_blocks > 0 && this->output_buffer[num_blocks - 1].HasRoom();
 
	}
 

	
 
	typedef SmallVector<OutputBuffer, 2> OutputBufferVector; ///< Vector type for output buffers.
 
	typedef std::vector<OutputBuffer> OutputBufferVector; ///< Vector type for output buffers.
 
	OutputBufferVector output_buffer; ///< Vector of blocks containing the stored output.
 
};
 

	
 

	
 
/** Derived class for loading INI files without going through Fio stuff. */
 
struct SettingsIniFile : IniLoadFile {
src/sortlist_type.h
Show inline comments
 
@@ -44,13 +44,13 @@ struct Filtering {
 
/**
 
 * List template of 'things' \p T to sort in a GUI.
 
 * @tparam T Type of data stored in the list to represent each item.
 
 * @tparam F Type of data fed as additional value to the filter function. @see FilterFunction
 
 */
 
template <typename T, typename F = const char*>
 
class GUIList : public SmallVector<T, 32> {
 
class GUIList : public std::vector<T> {
 
public:
 
	typedef int CDECL SortFunction(const T*, const T*); ///< Signature of sort function.
 
	typedef bool CDECL FilterFunction(const T*, F);     ///< Signature of filter function.
 

	
 
protected:
 
	SortFunction * const *sort_func_list;     ///< the sort criteria functions
src/station_cmd.cpp
Show inline comments
 
@@ -884,13 +884,13 @@ static CommandCost CheckFlatLandAirport(
 
 * @param spec_class Station class.
 
 * @param spec_index Index into the station class.
 
 * @param plat_len Platform length.
 
 * @param numtracks Number of platforms.
 
 * @return The cost in case of success, or an error code if it failed.
 
 */
 
static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, SmallVector<Train *, 4> &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks)
 
static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector<Train *> &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks)
 
{
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	int allowed_z = -1;
 
	uint invalid_dirs = 5 << axis;
 

	
 
	const StationSpec *statspec = StationClass::Get(spec_class)->GetSpec(spec_index);
 
@@ -1307,13 +1307,13 @@ CommandCost CmdBuildRailStation(TileInde
 

	
 
	/* these values are those that will be stored in train_tile and station_platforms */
 
	TileArea new_location(tile_org, w_org, h_org);
 

	
 
	/* Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station) */
 
	StationID est = INVALID_STATION;
 
	SmallVector<Train *, 4> affected_vehicles;
 
	std::vector<Train *> affected_vehicles;
 
	/* Clear the land below the station. */
 
	CommandCost cost = CheckFlatLandRailStation(new_location, flags, axis, &est, rt, affected_vehicles, spec_class, spec_index, plat_len, numtracks);
 
	if (cost.Failed()) return cost;
 
	/* Add construction expenses. */
 
	cost.AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len);
 
	cost.AddCost(numtracks * plat_len * RailBuildCost(rt));
 
@@ -1544,13 +1544,13 @@ restart:
 
 * @param removal_cost the cost for removing the tile, including the rail.
 
 * @param keep_rail whether to keep the rail of the station.
 
 * @tparam T the type of station to remove.
 
 * @return the number of cleared tiles or an error.
 
 */
 
template <class T>
 
CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected_stations, DoCommandFlag flags, Money removal_cost, bool keep_rail)
 
CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector<T *> &affected_stations, DoCommandFlag flags, Money removal_cost, bool keep_rail)
 
{
 
	/* Count of the number of tiles removed */
 
	int quantity = 0;
 
	CommandCost total_cost(EXPENSES_CONSTRUCTION);
 
	/* Accumulator for the errors seen during clearing. If no errors happen,
 
	 * and the quantity is 0 there is no station. Otherwise it will be one
 
@@ -1657,13 +1657,13 @@ CommandCost RemoveFromRailBaseStation(Ti
 
CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	TileIndex end = p1 == 0 ? start : p1;
 
	if (start >= MapSize() || end >= MapSize()) return CMD_ERROR;
 

	
 
	TileArea ta(start, end);
 
	SmallVector<Station *, 4> affected_stations;
 
	std::vector<Station *> affected_stations;
 

	
 
	CommandCost ret = RemoveFromRailBaseStation(ta, affected_stations, flags, _price[PR_CLEAR_STATION_RAIL], HasBit(p2, 0));
 
	if (ret.Failed()) return ret;
 

	
 
	/* Do all station specific functions here. */
 
	for (Station *st : affected_stations) {
 
@@ -1691,13 +1691,13 @@ CommandCost CmdRemoveFromRailStation(Til
 
CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	TileIndex end = p1 == 0 ? start : p1;
 
	if (start >= MapSize() || end >= MapSize()) return CMD_ERROR;
 

	
 
	TileArea ta(start, end);
 
	SmallVector<Waypoint *, 4> affected_stations;
 
	std::vector<Waypoint *> affected_stations;
 

	
 
	return RemoveFromRailBaseStation(ta, affected_stations, flags, _price[PR_CLEAR_WAYPOINT_RAIL], HasBit(p2, 0));
 
}
 

	
 

	
 
/**
 
@@ -1724,13 +1724,13 @@ CommandCost RemoveRailStation(T *st, DoC
 

	
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	/* clear all areas of the station */
 
	TILE_AREA_LOOP(tile, ta) {
 
		/* only remove tiles that are actually train station tiles */
 
		if (st->TileBelongsToRailStation(tile)) {
 
			SmallVector<T*, 4> affected_stations; // dummy
 
			std::vector<T*> affected_stations; // dummy
 
			CommandCost ret = RemoveFromRailBaseStation(TileArea(tile, 1, 1), affected_stations, flags, removal_cost, false);
 
			if (ret.Failed()) return ret;
 
			cost.AddCost(ret);
 
		}
 
	}
 

	
 
@@ -3518,13 +3518,13 @@ void DeleteStaleLinks(Station *from)
 
				bool updated = false;
 

	
 
				if (auto_distributed) {
 
					/* Have all vehicles refresh their next hops before deciding to
 
					 * remove the node. */
 
					OrderList *l;
 
					SmallVector<Vehicle *, 32> vehicles;
 
					std::vector<Vehicle *> vehicles;
 
					FOR_ALL_ORDER_LISTS(l) {
 
						bool found_from = false;
 
						bool found_to = false;
 
						for (Order *order = l->GetFirstOrder(); order != NULL; order = order->next) {
 
							if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_IMPLICIT)) continue;
 
							if (order->GetDestination() == from->index) {
src/station_gui.cpp
Show inline comments
 
@@ -2113,14 +2113,14 @@ void ShowStationViewWindow(StationID sta
 
/** Struct containing TileIndex and StationID */
 
struct TileAndStation {
 
	TileIndex tile;    ///< TileIndex
 
	StationID station; ///< StationID
 
};
 

	
 
static SmallVector<TileAndStation, 8> _deleted_stations_nearby;
 
static SmallVector<StationID, 8> _stations_nearby_list;
 
static std::vector<TileAndStation> _deleted_stations_nearby;
 
static std::vector<StationID> _stations_nearby_list;
 

	
 
/**
 
 * Add station on this tile to _stations_nearby_list if it's fully within the
 
 * station spread.
 
 * @param tile Tile just being checked
 
 * @param user_data Pointer to TileArea context
src/strgen/strgen_base.cpp
Show inline comments
 
@@ -232,13 +232,13 @@ struct ParsedCommandStruct {
 

	
 
/* Used when generating some advanced commands. */
 
static ParsedCommandStruct _cur_pcs;
 
static int _cur_argidx;
 

	
 
/** The buffer for writing a single string. */
 
struct Buffer : SmallVector<byte, 256> {
 
struct Buffer : std::vector<byte> {
 
	/**
 
	 * Convenience method for adding a byte.
 
	 * @param value The value to add.
 
	 */
 
	void AppendByte(byte value)
 
	{
src/string.cpp
Show inline comments
 
@@ -621,14 +621,14 @@ int strnatcmp(const char *s1, const char
 
/** String iterator using ICU as a backend. */
 
class IcuStringIterator : public StringIterator
 
{
 
	icu::BreakIterator *char_itr; ///< ICU iterator for characters.
 
	icu::BreakIterator *word_itr; ///< ICU iterator for words.
 

	
 
	SmallVector<UChar, 32> utf16_str;      ///< UTF-16 copy of the string.
 
	SmallVector<size_t, 32> utf16_to_utf8; ///< Mapping from UTF-16 code point position to index in the UTF-8 source string.
 
	std::vector<UChar> utf16_str;      ///< UTF-16 copy of the string.
 
	std::vector<size_t> utf16_to_utf8; ///< Mapping from UTF-16 code point position to index in the UTF-8 source string.
 

	
 
public:
 
	IcuStringIterator() : char_itr(NULL), word_itr(NULL)
 
	{
 
		UErrorCode status = U_ZERO_ERROR;
 
		this->char_itr = icu::BreakIterator::createCharacterInstance(icu::Locale(_current_language != NULL ? _current_language->isocode : "en"), status);
src/stringfilter_type.h
Show inline comments
 
@@ -36,13 +36,13 @@ private:
 
	struct WordState {
 
		const char *start;                         ///< Word to filter for.
 
		bool match;                                ///< Already matched?
 
	};
 

	
 
	const char *filter_buffer;                     ///< Parsed filter string. Words separated by 0.
 
	SmallVector<WordState, 4> word_index;          ///< Word index and filter state.
 
	std::vector<WordState> word_index;          ///< Word index and filter state.
 
	uint word_matches;                             ///< Summary of filter state: Number of words matched.
 

	
 
	const bool *case_sensitive;                    ///< Match case-sensitively (usually a static variable).
 

	
 
public:
 
	/**
src/subsidy.cpp
Show inline comments
 
@@ -561,13 +561,13 @@ bool CheckSubsidised(CargoID cargo_type,
 
			break;
 
		default: return false;
 
	}
 

	
 
	/* Remember all towns near this station (at least one house in its catchment radius)
 
	 * which are destination of subsidised path. Do that only if needed */
 
	SmallVector<const Town *, 2> towns_near;
 
	std::vector<const Town *> towns_near;
 
	if (!st->rect.IsEmpty()) {
 
		Subsidy *s;
 
		FOR_ALL_SUBSIDIES(s) {
 
			/* Don't create the cache if there is no applicable subsidy with town as destination */
 
			if (s->dst_type != ST_TOWN) continue;
 
			if (s->cargo_type != cargo_type || s->src_type != src_type || s->src != src) continue;
src/texteff.cpp
Show inline comments
 
@@ -34,13 +34,13 @@ struct TextEffect : public ViewportSign 
 
		this->MarkDirty();
 
		this->width_normal = 0;
 
		this->string_id = INVALID_STRING_ID;
 
	}
 
};
 

	
 
static SmallVector<struct TextEffect, 32> _text_effects; ///< Text effects are stored there
 
static std::vector<struct TextEffect> _text_effects; ///< Text effects are stored there
 

	
 
/* Text Effects */
 
TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, TextEffectMode mode)
 
{
 
	if (_game_mode == GM_MENU) return INVALID_TE_ID;
 

	
src/textfile_gui.h
Show inline comments
 
@@ -18,18 +18,18 @@
 
#include "window_gui.h"
 

	
 
const char *GetTextfile(TextfileType type, Subdirectory dir, const char *filename);
 

	
 
/** Window for displaying a textfile */
 
struct TextfileWindow : public Window, MissingGlyphSearcher {
 
	TextfileType file_type;              ///< Type of textfile to view.
 
	Scrollbar *vscroll;                  ///< Vertical scrollbar.
 
	Scrollbar *hscroll;                  ///< Horizontal scrollbar.
 
	char *text;                          ///< Lines of text from the NewGRF's textfile.
 
	SmallVector<const char *, 64> lines; ///< #text, split into lines in a table with lines.
 
	uint search_iterator;                ///< Iterator for the font check search.
 
	TextfileType file_type;          ///< Type of textfile to view.
 
	Scrollbar *vscroll;              ///< Vertical scrollbar.
 
	Scrollbar *hscroll;              ///< Horizontal scrollbar.
 
	char *text;                      ///< Lines of text from the NewGRF's textfile.
 
	std::vector<const char *> lines; ///< #text, split into lines in a table with lines.
 
	uint search_iterator;            ///< Iterator for the font check search.
 

	
 
	static const int TOP_SPACING    = WD_FRAMETEXT_TOP;    ///< Additional spacing at the top of the #WID_TF_BACKGROUND widget.
 
	static const int BOTTOM_SPACING = WD_FRAMETEXT_BOTTOM; ///< Additional spacing at the bottom of the #WID_TF_BACKGROUND widget.
 

	
 
	TextfileWindow(TextfileType file_type);
 
	~TextfileWindow();
src/timetable_cmd.cpp
Show inline comments
 
@@ -278,13 +278,13 @@ CommandCost CmdSetTimetableStart(TileInd
 
	if (start_date < 0 || start_date > MAX_DAY) return CMD_ERROR;
 
	if (start_date - _date > 15 * DAYS_IN_LEAP_YEAR) return CMD_ERROR;
 
	if (_date - start_date > DAYS_IN_LEAP_YEAR) return CMD_ERROR;
 
	if (timetable_all && !v->orders.list->IsCompleteTimetable()) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		SmallVector<Vehicle *, 8> vehs;
 
		std::vector<Vehicle *> vehs;
 

	
 
		if (timetable_all) {
 
			for (Vehicle *w = v->orders.list->GetFirstSharedVehicle(); w != NULL; w = w->NextShared()) {
 
				vehs.push_back(w);
 
			}
 
		} else {
src/train_cmd.cpp
Show inline comments
 
@@ -811,13 +811,13 @@ static Train *FindGoodVehiclePos(const T
 
	}
 

	
 
	return NULL;
 
}
 

	
 
/** Helper type for lists/vectors of trains */
 
typedef SmallVector<Train *, 16> TrainList;
 
typedef std::vector<Train *> TrainList;
 

	
 
/**
 
 * Make a backup of a train into a train list.
 
 * @param list to make the backup in
 
 * @param t    the train to make the backup of
 
 */
src/train_gui.cpp
Show inline comments
 
@@ -183,13 +183,13 @@ struct CargoSummaryItem {
 
};
 

	
 
static const uint TRAIN_DETAILS_MIN_INDENT = 32; ///< Minimum indent level in the train details window
 
static const uint TRAIN_DETAILS_MAX_INDENT = 72; ///< Maximum indent level in the train details window; wider than this and we start on a new line
 

	
 
/** Container for the cargo summary information. */
 
typedef SmallVector<CargoSummaryItem, 2> CargoSummary;
 
typedef std::vector<CargoSummaryItem> CargoSummary;
 
/** Reused container of cargo details */
 
static CargoSummary _cargo_summary;
 

	
 
/**
 
 * Draw the details cargo tab for the given vehicle at the given position
 
 *
src/vehicle_cmd.cpp
Show inline comments
 
@@ -343,14 +343,13 @@ static CommandCost RefitVehicle(Vehicle 
 
	if (!only_this) {
 
		GetVehicleSet(vehicles_to_refit, v, num_vehicles);
 
		/* In this case, we need to check the whole chain. */
 
		v = v->First();
 
	}
 

	
 
	static SmallVector<RefitResult, 16> refit_result;
 
	refit_result.clear();
 
	std::vector<RefitResult> refit_result;
 

	
 
	v->InvalidateNewGRFCacheOfChain();
 
	byte actual_subtype = new_subtype;
 
	for (; v != NULL; v = (only_this ? NULL : v->Next())) {
 
		/* Reset actual_subtype for every new vehicle */
 
		if (!v->IsArticulatedPart()) actual_subtype = new_subtype;
src/vehicle_func.h
Show inline comments
 
@@ -172,12 +172,12 @@ extern uint16 _returned_mail_refit_capac
 

	
 
bool CanVehicleUseStation(EngineID engine_type, const struct Station *st);
 
bool CanVehicleUseStation(const Vehicle *v, const struct Station *st);
 

	
 
void ReleaseDisastersTargetingVehicle(VehicleID vehicle);
 

	
 
typedef SmallVector<VehicleID, 2> VehicleSet;
 
typedef std::vector<VehicleID> VehicleSet;
 
void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles);
 

	
 
void CheckCargoCapacity(Vehicle *v);
 

	
 
#endif /* VEHICLE_FUNC_H */
src/vehicle_gui.cpp
Show inline comments
 
@@ -230,13 +230,13 @@ static const uint MAX_REFIT_CYCLE = 256;
 
byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_type)
 
{
 
	v_from = v_from->GetFirstEnginePart();
 
	v_for = v_for->GetFirstEnginePart();
 

	
 
	/* Create a list of subtypes used by the various parts of v_for */
 
	static SmallVector<StringID, 4> subtypes;
 
	static std::vector<StringID> subtypes;
 
	subtypes.clear();
 
	for (; v_from != NULL; v_from = v_from->HasArticulatedPart() ? v_from->GetNextArticulatedPart() : NULL) {
 
		const Engine *e_from = v_from->GetEngine();
 
		if (!e_from->CanCarryCargo() || !HasBit(e_from->info.callback_mask, CBM_VEHICLE_CARGO_SUFFIX)) continue;
 
		include(subtypes, GetCargoSubtypeText(v_from));
 
	}
 
@@ -314,13 +314,13 @@ struct RefitOption {
 
	inline bool operator == (const RefitOption &other) const
 
	{
 
		return other.cargo == this->cargo && other.string == this->string;
 
	}
 
};
 

	
 
typedef SmallVector<RefitOption, 32> SubtypeList; ///< List of refit subtypes associated to a cargo.
 
typedef std::vector<RefitOption> SubtypeList; ///< List of refit subtypes associated to a cargo.
 

	
 
/**
 
 * Draw the list of available refit options for a consist and highlight the selected refit option (if any).
 
 * @param list  List of subtype options for each (sorted) cargo.
 
 * @param sel   Selected refit cargo-type in the window
 
 * @param pos   Position of the selected item in caller widow
src/vehiclelist.h
Show inline comments
 
@@ -49,13 +49,13 @@ struct VehicleListIdentifier {
 
		type(type), vtype(vtype), company(company), index(index) {}
 

	
 
	VehicleListIdentifier() : type(), vtype(), company(), index() {}
 
};
 

	
 
/** A list of vehicles. */
 
typedef SmallVector<const Vehicle *, 32> VehicleList;
 
typedef std::vector<const Vehicle *> VehicleList;
 

	
 
bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &identifier);
 
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine_list, VehicleList *wagon_list, bool individual_wagons = false);
 
uint GetUnitNumberDigits(VehicleList &vehicles);
 

	
 
#endif /* VEHICLELIST_H */
src/viewport.cpp
Show inline comments
 
@@ -150,16 +150,16 @@ enum FoundationPart {
 
enum SpriteCombineMode {
 
	SPRITE_COMBINE_NONE,     ///< Every #AddSortableSpriteToDraw start its own bounding box
 
	SPRITE_COMBINE_PENDING,  ///< %Sprite combining will start with the next unclipped sprite.
 
	SPRITE_COMBINE_ACTIVE,   ///< %Sprite combining is active. #AddSortableSpriteToDraw outputs child sprites.
 
};
 

	
 
typedef SmallVector<TileSpriteToDraw, 64> TileSpriteToDrawVector;
 
typedef SmallVector<StringSpriteToDraw, 4> StringSpriteToDrawVector;
 
typedef SmallVector<ParentSpriteToDraw, 64> ParentSpriteToDrawVector;
 
typedef SmallVector<ChildScreenSpriteToDraw, 16> ChildScreenSpriteToDrawVector;
 
typedef std::vector<TileSpriteToDraw> TileSpriteToDrawVector;
 
typedef std::vector<StringSpriteToDraw> StringSpriteToDrawVector;
 
typedef std::vector<ParentSpriteToDraw> ParentSpriteToDrawVector;
 
typedef std::vector<ChildScreenSpriteToDraw> ChildScreenSpriteToDrawVector;
 

	
 
/** Data structure storing rendering information */
 
struct ViewportDrawer {
 
	DrawPixelInfo dpi;
 

	
 
	StringSpriteToDrawVector string_sprites_to_draw;
src/viewport_sprite_sorter.h
Show inline comments
 
@@ -38,13 +38,13 @@ struct ParentSpriteToDraw {
 
	int32 top;                      ///< minimal screen Y coordinate of sprite (= y + sprite->y_offs), reference point for child sprites
 

	
 
	int32 first_child;              ///< the first child to draw.
 
	bool comparison_done;           ///< Used during sprite sorting: true if sprite has been compared with all other sprites
 
};
 

	
 
typedef SmallVector<ParentSpriteToDraw*, 64> ParentSpriteToSortVector;
 
typedef std::vector<ParentSpriteToDraw*> ParentSpriteToSortVector;
 

	
 
/** Type for method for checking whether a viewport sprite sorter exists. */
 
typedef bool (*VpSorterChecker)();
 
/** Type for the actual viewport sprite sorter. */
 
typedef void (*VpSpriteSorter)(ParentSpriteToSortVector *psd);
 

	
src/window.cpp
Show inline comments
 
@@ -82,13 +82,13 @@ bool _mouse_hovering;      ///< The mous
 
SpecialMouseMode _special_mouse_mode; ///< Mode of the mouse.
 

	
 
/**
 
 * List of all WindowDescs.
 
 * This is a pointer to ensure initialisation order with the various static WindowDesc instances.
 
 */
 
static SmallVector<WindowDesc*, 16> *_window_descs = NULL;
 
static std::vector<WindowDesc*> *_window_descs = NULL;
 

	
 
/** Config file to store WindowDesc */
 
char *_windows_file;
 

	
 
/** Window description constructor. */
 
WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad,
 
@@ -105,13 +105,13 @@ WindowDesc::WindowDesc(WindowPosition de
 
	pref_sticky(false),
 
	pref_width(0),
 
	pref_height(0),
 
	default_width_trad(def_width_trad),
 
	default_height_trad(def_height_trad)
 
{
 
	if (_window_descs == NULL) _window_descs = new SmallVector<WindowDesc*, 16>();
 
	if (_window_descs == NULL) _window_descs = new std::vector<WindowDesc*>();
 
	_window_descs->push_back(this);
 
}
 

	
 
WindowDesc::~WindowDesc()
 
{
 
	_window_descs->erase(std::find(_window_descs->begin(), _window_descs->end(), this));
src/window_gui.h
Show inline comments
 
@@ -278,13 +278,13 @@ enum TooltipCloseCondition {
 
struct Window : ZeroedMemoryAllocator {
 
protected:
 
	void InitializeData(WindowNumber window_number);
 
	void InitializePositionSize(int x, int y, int min_width, int min_height);
 
	virtual void FindWindowPlacementAndResize(int def_width, int def_height);
 

	
 
	SmallVector<int, 4> scheduled_invalidation_data;  ///< Data of scheduled OnInvalidateData() calls.
 
	std::vector<int> scheduled_invalidation_data;  ///< Data of scheduled OnInvalidateData() calls.
 

	
 
public:
 
	Window(WindowDesc *desc);
 

	
 
	virtual ~Window();
 

	
0 comments (0 inline, 0 general)