Changeset - r27384:b919ab98bb53
src/base_media_base.h
Show inline comments
 
@@ -8,13 +8,12 @@
 
/** @file base_media_base.h Generic functions for replacing base data (graphics, sounds). */
 

	
 
#ifndef BASE_MEDIA_BASE_H
 
#define BASE_MEDIA_BASE_H
 

	
 
#include "fileio_func.h"
 
#include "core/smallmap_type.hpp"
 
#include "gfx_type.h"
 
#include "textfile_type.h"
 
#include "textfile_gui.h"
 
#include <unordered_map>
 

	
 
/* Forward declare these; can't do 'struct X' in functions as older GCCs barf on that */
src/core/CMakeLists.txt
Show inline comments
 
@@ -19,12 +19,11 @@ add_files(
 
    overflowsafe_type.hpp
 
    pool_func.cpp
 
    pool_func.hpp
 
    pool_type.hpp
 
    random_func.cpp
 
    random_func.hpp
 
    smallmap_type.hpp
 
    smallstack_type.hpp
 
    smallvec_type.hpp
 
    span_type.hpp
 
    strong_typedef_type.hpp
 
)
src/core/smallmap_type.hpp
Show inline comments
 
deleted file
src/fios.h
Show inline comments
 
@@ -22,13 +22,13 @@
 
enum SaveLoadInvalidateWindowData {
 
	SLIWD_RESCAN_FILES,          ///< Rescan all files (when changed directory, ...)
 
	SLIWD_SELECTION_CHANGES,     ///< File selection has changed (user click, ...)
 
	SLIWD_FILTER_CHANGES,        ///< The filename filter has changed (via the editbox)
 
};
 

	
 
typedef SmallMap<uint, CompanyProperties *> CompanyPropertiesMap;
 
using CompanyPropertiesMap = std::map<uint, CompanyProperties *>;
 

	
 
/**
 
 * Container for loading in mode SL_LOAD_CHECK.
 
 */
 
struct LoadCheckData {
 
	bool checkable;     ///< True if the savegame could be checked by SL_LOAD_CHECK. (Old savegames are not checkable.)
src/fontcache/truetypefontcache.cpp
Show inline comments
 
@@ -164,17 +164,17 @@ const Sprite *TrueTypeFontCache::GetGlyp
 

	
 
	return this->InternalGetGlyph(key, GetFontAAState(this->fs));
 
}
 

	
 
const void *TrueTypeFontCache::GetFontTable(uint32 tag, size_t &length)
 
{
 
	const FontTable::iterator iter = this->font_tables.Find(tag);
 
	if (iter != this->font_tables.data() + this->font_tables.size()) {
 
	const auto iter = this->font_tables.find(tag);
 
	if (iter != this->font_tables.end()) {
 
		length = iter->second.first;
 
		return iter->second.second;
 
	}
 

	
 
	const void *result = this->InternalGetFontTable(tag, length);
 

	
 
	this->font_tables.Insert(tag, std::pair<size_t, const void *>(length, result));
 
	this->font_tables[tag] = std::pair<size_t, const void *>(length, result);
 
	return result;
 
}
src/fontcache/truetypefontcache.h
Show inline comments
 
@@ -7,13 +7,12 @@
 

	
 
/** @file truetypefontcache.h Common base definition for font file based font caches. */
 

	
 
#ifndef TRUETYPEFONTCACHE_H
 
#define TRUETYPEFONTCACHE_H
 

	
 
#include "../core/smallmap_type.hpp"
 
#include "../fontcache.h"
 

	
 

	
 
static const int MAX_FONT_SIZE = 72; ///< Maximum font size.
 

	
 
static const byte FACE_COLOUR = 1;
 
@@ -25,13 +24,13 @@ protected:
 
	static constexpr int MAX_GLYPH_DIM = 256;          ///< Maximum glyph dimensions.
 
	static constexpr uint MAX_FONT_MIN_REC_SIZE = 20u; ///< Upper limit for the recommended font size in case a font file contains nonsensical values.
 

	
 
	int req_size;  ///< Requested font size.
 
	int used_size; ///< Used font size.
 

	
 
	typedef SmallMap<uint32, std::pair<size_t, const void *> > FontTable; ///< Table with font table cache
 
	using FontTable = std::map<uint32_t, std::pair<size_t, const void *>>; ///< Table with font table cache
 
	FontTable font_tables; ///< Cached font tables.
 

	
 
	/** Container for information about a glyph. */
 
	struct GlyphEntry {
 
		Sprite *sprite; ///< The loaded sprite.
 
		byte width;     ///< The width of the glyph.
src/gamelog.cpp
Show inline comments
 
@@ -230,73 +230,73 @@ void Gamelog::Print(std::function<void(c
 
/* virtual */ void LoggedChangeGRFAdd::FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type)
 
{
 
	/* A NewGRF got added to the game, either at the start of the game (never an issue), or later on when it could be an issue. */
 
	const GRFConfig *gc = FindGRFConfig(this->grfid, FGCM_EXACT, this->md5sum);
 
	fmt::format_to(output_iterator, "Added NewGRF: ");
 
	AddGrfInfo(output_iterator, this->grfid, this->md5sum, gc);
 
	GrfIDMapping::Pair *gm = grf_names.Find(this->grfid);
 
	if (gm != grf_names.End() && !gm->second.was_missing) fmt::format_to(output_iterator, ". Gamelog inconsistency: GrfID was already added!");
 
	auto gm = grf_names.find(this->grfid);
 
	if (gm != grf_names.end() && !gm->second.was_missing) fmt::format_to(output_iterator, ". Gamelog inconsistency: GrfID was already added!");
 
	grf_names[this->grfid] = gc;
 
}
 

	
 
/* virtual */ void LoggedChangeGRFRemoved::FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type)
 
{
 
	/* A NewGRF got removed from the game, either manually or by it missing when loading the game. */
 
	GrfIDMapping::Pair *gm = grf_names.Find(this->grfid);
 
	auto gm = grf_names.find(this->grfid);
 
	fmt::format_to(output_iterator, action_type == GLAT_LOAD ? "Missing NewGRF: " : "Removed NewGRF: ");
 
	AddGrfInfo(output_iterator, this->grfid, nullptr, gm != grf_names.End() ? gm->second.gc : nullptr);
 
	if (gm == grf_names.End()) {
 
	AddGrfInfo(output_iterator, this->grfid, nullptr, gm != grf_names.end() ? gm->second.gc : nullptr);
 
	if (gm == grf_names.end()) {
 
		fmt::format_to(output_iterator, ". Gamelog inconsistency: GrfID was never added!");
 
	} else {
 
		if (action_type == GLAT_LOAD) {
 
			/* Missing grfs on load are not removed from the configuration */
 
			gm->second.was_missing = true;
 
		} else {
 
			grf_names.Erase(gm);
 
			grf_names.erase(gm);
 
		}
 
	}
 
}
 

	
 
/* virtual */ void LoggedChangeGRFChanged::FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type)
 
{
 
	/* Another version of the same NewGRF got loaded. */
 
	const GRFConfig *gc = FindGRFConfig(this->grfid, FGCM_EXACT, this->md5sum);
 
	fmt::format_to(output_iterator, "Compatible NewGRF loaded: ");
 
	AddGrfInfo(output_iterator, this->grfid, this->md5sum, gc);
 
	if (!grf_names.Contains(this->grfid)) fmt::format_to(output_iterator, ". Gamelog inconsistency: GrfID was never added!");
 
	if (grf_names.count(this->grfid) == 0) fmt::format_to(output_iterator, ". Gamelog inconsistency: GrfID was never added!");
 
	grf_names[this->grfid] = gc;
 
}
 

	
 
/* virtual */ void LoggedChangeGRFParameterChanged::FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type)
 
{
 
	/* A parameter of a NewGRF got changed after the game was started. */
 
	GrfIDMapping::Pair *gm = grf_names.Find(this->grfid);
 
	auto gm = grf_names.find(this->grfid);
 
	fmt::format_to(output_iterator, "GRF parameter changed: ");
 
	AddGrfInfo(output_iterator, this->grfid, nullptr, gm != grf_names.End() ? gm->second.gc : nullptr);
 
	if (gm == grf_names.End()) fmt::format_to(output_iterator, ". Gamelog inconsistency: GrfID was never added!");
 
	AddGrfInfo(output_iterator, this->grfid, nullptr, gm != grf_names.end() ? gm->second.gc : nullptr);
 
	if (gm == grf_names.end()) fmt::format_to(output_iterator, ". Gamelog inconsistency: GrfID was never added!");
 
}
 

	
 
/* virtual */ void LoggedChangeGRFMoved::FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type)
 
{
 
	/* The order of NewGRFs got changed, which might cause some other NewGRFs to behave differently. */
 
	GrfIDMapping::Pair *gm = grf_names.Find(this->grfid);
 
	auto gm = grf_names.find(this->grfid);
 
	fmt::format_to(output_iterator, "GRF order changed: {:08X} moved {} places {}",
 
		BSWAP32(this->grfid), abs(this->offset), this->offset >= 0 ? "down" : "up" );
 
	AddGrfInfo(output_iterator, this->grfid, nullptr, gm != grf_names.End() ? gm->second.gc : nullptr);
 
	if (gm == grf_names.End()) fmt::format_to(output_iterator, ". Gamelog inconsistency: GrfID was never added!");
 
	AddGrfInfo(output_iterator, this->grfid, nullptr, gm != grf_names.end() ? gm->second.gc : nullptr);
 
	if (gm == grf_names.end()) fmt::format_to(output_iterator, ". Gamelog inconsistency: GrfID was never added!");
 
}
 

	
 
/* virtual */ void LoggedChangeGRFBug::FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type)
 
{
 
	/* A specific bug in a NewGRF, that could cause wide spread problems, has been noted during the execution of the game. */
 
	GrfIDMapping::Pair *gm = grf_names.Find(this->grfid);
 
	auto gm = grf_names.find(this->grfid);
 
	assert(this->bug == GBUG_VEH_LENGTH);
 

	
 
	fmt::format_to(output_iterator, "Rail vehicle changes length outside a depot: GRF ID {:08X}, internal ID 0x{:X}", BSWAP32(this->grfid), this->data);
 
	AddGrfInfo(output_iterator, this->grfid, nullptr, gm != grf_names.End() ? gm->second.gc : nullptr);
 
	if (gm == grf_names.End()) fmt::format_to(output_iterator, ". Gamelog inconsistency: GrfID was never added!");
 
	AddGrfInfo(output_iterator, this->grfid, nullptr, gm != grf_names.end() ? gm->second.gc : nullptr);
 
	if (gm == grf_names.end()) fmt::format_to(output_iterator, ". Gamelog inconsistency: GrfID was never added!");
 
}
 

	
 
/* virtual */ void LoggedChangeEmergencySave::FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type)
 
{
 
	/* At one point the savegame was made during the handling of a game crash.
 
	 * The generic code already mentioned the emergency savegame, and there is no extra information to log. */
src/gamelog_internal.h
Show inline comments
 
@@ -16,20 +16,20 @@
 
 * Information about the presence of a Grf at a certain point during gamelog history
 
 * Note about missing Grfs:
 
 * Changes to missing Grfs are not logged including manual removal of the Grf.
 
 * So if the gamelog tells a Grf is missing we do not know whether it was readded or completely removed
 
 * at some later point.
 
 */
 
struct GRFPresence{
 
struct GRFPresence {
 
	const GRFConfig *gc;  ///< GRFConfig, if known
 
	bool was_missing;     ///< Grf was missing during some gameload in the past
 

	
 
	GRFPresence(const GRFConfig *gc) : gc(gc), was_missing(false) {}
 
	GRFPresence() = default;
 
};
 
typedef SmallMap<uint32_t, GRFPresence> GrfIDMapping;
 
using GrfIDMapping = std::map<uint32_t, GRFPresence>;
 

	
 
struct LoggedChange {
 
	LoggedChange(GamelogChangeType type = GLCT_NONE) : ct(type) {}
 
	virtual ~LoggedChange() {}
 
	virtual void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) = 0;
 

	
src/gfx_layout.cpp
Show inline comments
 
@@ -100,23 +100,23 @@ static inline void GetLayouter(Layouter:
 
			 * needed for RTL languages which need more proper shaping support. */
 
			if (!T::SUPPORTS_RTL && IsTextDirectionChar(c)) continue;
 
			buff += T::AppendToBuffer(buff, buffer_last, c);
 
			continue;
 
		}
 

	
 
		if (!fontMapping.Contains(buff - buff_begin)) {
 
			fontMapping.Insert(buff - buff_begin, f);
 
		if (fontMapping.count(buff - buff_begin) == 0) {
 
			fontMapping[buff - buff_begin] = f;
 
		}
 
		f = Layouter::GetFont(state.fontsize, state.cur_colour);
 
	}
 

	
 
	/* Better safe than sorry. */
 
	*buff = '\0';
 

	
 
	if (!fontMapping.Contains(buff - buff_begin)) {
 
		fontMapping.Insert(buff - buff_begin, f);
 
	if (fontMapping.count(buff - buff_begin) == 0) {
 
		fontMapping[buff - buff_begin] = f;
 
	}
 
	line.layout = T::GetParagraphLayout(buff_begin, buff, fontMapping);
 
	line.state_after = state;
 
}
 

	
 
/**
 
@@ -293,18 +293,17 @@ ptrdiff_t Layouter::GetCharAtPosition(in
 

	
 
/**
 
 * Get a static font instance.
 
 */
 
Font *Layouter::GetFont(FontSize size, TextColour colour)
 
{
 
	FontColourMap::iterator it = fonts[size].Find(colour);
 
	if (it != fonts[size].End()) return it->second;
 
	FontColourMap::iterator it = fonts[size].find(colour);
 
	if (it != fonts[size].end()) return it->second;
 

	
 
	Font *f = new Font(size, colour);
 
	fonts[size].emplace_back(colour, f);
 
	return f;
 
	fonts[size][colour] = new Font(size, colour);
 
	return fonts[size][colour];
 
}
 

	
 
/**
 
 * Reset cached font information.
 
 * @param size Font size to reset.
 
 */
src/gfx_layout.h
Show inline comments
 
@@ -9,13 +9,13 @@
 

	
 
#ifndef GFX_LAYOUT_H
 
#define GFX_LAYOUT_H
 

	
 
#include "fontcache.h"
 
#include "gfx_func.h"
 
#include "core/smallmap_type.hpp"
 
#include "core/math_func.hpp"
 

	
 
#include <stack>
 
#include <string_view>
 

	
 
/**
 
 * Text drawing parameters, which can change while drawing a line, but are kept between multiple parts
 
@@ -78,13 +78,13 @@ public:
 
	TextColour colour; ///< The colour this font has to be.
 

	
 
	Font(FontSize size, TextColour colour);
 
};
 

	
 
/** Mapping from index to font. */
 
typedef SmallMap<int, Font *> FontMap;
 
using FontMap = std::map<int, Font *>;
 

	
 
/**
 
 * Interface to glue fallback and normal layouter into one.
 
 */
 
class ParagraphLayouter {
 
public:
 
@@ -166,13 +166,13 @@ public:
 
private:
 
	typedef std::map<LineCacheKey, LineCacheItem, LineCacheCompare> LineCache;
 
	static LineCache *linecache;
 

	
 
	static LineCacheItem &GetCachedParagraphLayout(std::string_view str, const FontState &state);
 

	
 
	typedef SmallMap<TextColour, Font *> FontColourMap;
 
	using FontColourMap = std::map<TextColour, Font *>;
 
	static FontColourMap fonts[FS_END];
 
public:
 
	static Font *GetFont(FontSize size, TextColour colour);
 

	
 
	Layouter(std::string_view str, int maxw = INT32_MAX, TextColour colour = TC_FROMSTRING, FontSize fontsize = FS_NORMAL);
 
	Dimension GetBounds();
src/gfx_layout_fallback.cpp
Show inline comments
 
@@ -263,13 +263,13 @@ const ParagraphLayouter::VisualRun &Fall
 
 * @param buffer The characters of the paragraph.
 
 * @param length The length of the paragraph.
 
 * @param runs   The font mapping of this paragraph.
 
 */
 
FallbackParagraphLayout::FallbackParagraphLayout(WChar *buffer, int length, FontMap &runs) : buffer_begin(buffer), buffer(buffer), runs(runs)
 
{
 
	assert(runs.End()[-1].first == length);
 
	assert(runs.rbegin()->first == length);
 
}
 

	
 
/**
 
 * Reset the position to the start of the paragraph.
 
 */
 
void FallbackParagraphLayout::Reflow()
 
@@ -292,21 +292,21 @@ std::unique_ptr<const ParagraphLayouter:
 

	
 
	std::unique_ptr<FallbackLine> l(new FallbackLine());
 

	
 
	if (*this->buffer == '\0') {
 
		/* Only a newline. */
 
		this->buffer = nullptr;
 
		l->emplace_back(this->runs.front().second, this->buffer, 0, 0);
 
		l->emplace_back(this->runs.begin()->second, this->buffer, 0, 0);
 
		return l;
 
	}
 

	
 
	int offset = this->buffer - this->buffer_begin;
 
	FontMap::iterator iter = this->runs.data();
 
	FontMap::iterator iter = this->runs.begin();
 
	while (iter->first <= offset) {
 
		iter++;
 
		assert(iter != this->runs.End());
 
		++iter;
 
		assert(iter != this->runs.end());
 
	}
 

	
 
	const FontCache *fc = iter->second->fc;
 
	const WChar *next_run = this->buffer_begin + iter->first;
 

	
 
	const WChar *begin = this->buffer;
 
@@ -322,14 +322,14 @@ std::unique_ptr<const ParagraphLayouter:
 
			break;
 
		}
 

	
 
		if (this->buffer == next_run) {
 
			int w = l->GetWidth();
 
			l->emplace_back(iter->second, begin, this->buffer - begin, w);
 
			iter++;
 
			assert(iter != this->runs.End());
 
			++iter;
 
			assert(iter != this->runs.end());
 

	
 
			next_run = this->buffer_begin + iter->first;
 
			begin = this->buffer;
 
		}
 

	
 
		if (IsWhitespace(c)) last_space = this->buffer;
src/linkgraph/linkgraph.h
Show inline comments
 
@@ -8,13 +8,12 @@
 
/** @file linkgraph.h Declaration of link graph classes used for cargo distribution. */
 

	
 
#ifndef LINKGRAPH_H
 
#define LINKGRAPH_H
 

	
 
#include "../core/pool_type.hpp"
 
#include "../core/smallmap_type.hpp"
 
#include "../station_base.h"
 
#include "../cargotype.h"
 
#include "../date_type.h"
 
#include "../timer/timer_game_calendar.h"
 
#include "../saveload/saveload.h"
 
#include "linkgraph_type.h"
src/network/core/address.h
Show inline comments
 
@@ -11,18 +11,17 @@
 
#define NETWORK_CORE_ADDRESS_H
 

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

	
 

	
 
class NetworkAddress;
 
typedef std::vector<NetworkAddress> NetworkAddressList; ///< Type for a list of addresses.
 
typedef SmallMap<SOCKET, NetworkAddress> SocketList;    ///< Type for a mapping between address and socket.
 
using SocketList = std::map<SOCKET, NetworkAddress>;    ///< 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/newgrf.cpp
Show inline comments
 
@@ -8369,19 +8369,19 @@ static bool ChangeGRFParamValueNames(Byt
 
			continue;
 
		}
 

	
 
		byte langid = buf->ReadByte();
 
		const char *name_string = buf->ReadString();
 

	
 
		std::pair<uint32, GRFTextList> *val_name = _cur_parameter->value_names.Find(id);
 
		if (val_name != _cur_parameter->value_names.End()) {
 
		auto val_name = _cur_parameter->value_names.find(id);
 
		if (val_name != _cur_parameter->value_names.end()) {
 
			AddGRFTextToList(val_name->second, langid, _cur.grfconfig->ident.grfid, false, name_string);
 
		} else {
 
			GRFTextList list;
 
			AddGRFTextToList(list, langid, _cur.grfconfig->ident.grfid, false, name_string);
 
			_cur_parameter->value_names.Insert(id, list);
 
			_cur_parameter->value_names[id] = list;
 
		}
 

	
 
		type = buf->ReadByte();
 
	}
 
	return true;
 
}
src/newgrf_config.cpp
Show inline comments
 
@@ -261,13 +261,13 @@ void GRFParameterInfo::SetValue(struct G
 
 * Finalize Action 14 info after file scan is finished.
 
 */
 
void GRFParameterInfo::Finalize()
 
{
 
	this->complete_labels = true;
 
	for (uint32 value = this->min_value; value <= this->max_value; value++) {
 
		if (!this->value_names.Contains(value)) {
 
		if (this->value_names.count(value) == 0) {
 
			this->complete_labels = false;
 
			break;
 
		}
 
	}
 
}
 

	
src/newgrf_config.h
Show inline comments
 
@@ -9,13 +9,12 @@
 

	
 
#ifndef NEWGRF_CONFIG_H
 
#define NEWGRF_CONFIG_H
 

	
 
#include "strings_type.h"
 
#include "core/alloc_type.hpp"
 
#include "core/smallmap_type.hpp"
 
#include "misc/countedptr.hpp"
 
#include "fileio_type.h"
 
#include "textfile_type.h"
 
#include "newgrf_text.h"
 

	
 
/** GRF config bit flags */
 
@@ -140,13 +139,13 @@ struct GRFParameterInfo {
 
	uint32 min_value;      ///< The minimal value this parameter can have
 
	uint32 max_value;      ///< The maximal value of this parameter
 
	uint32 def_value;      ///< Default value of this parameter
 
	byte param_nr;         ///< GRF parameter to store content in
 
	byte first_bit;        ///< First bit to use in the GRF parameter
 
	byte num_bit;          ///< Number of bits to use for this parameter
 
	SmallMap<uint32, GRFTextList> value_names; ///< Names for each value.
 
	std::map<uint32_t, GRFTextList> value_names; ///< Names for each value.
 
	bool complete_labels;  ///< True if all values have a label.
 

	
 
	uint32 GetValue(struct GRFConfig *config) const;
 
	void SetValue(struct GRFConfig *config, uint32 value);
 
	void Finalize();
 
};
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -815,13 +815,13 @@ GrfSpecFeature GetGrfSpecFeature(Vehicle
 
/** Window used for aligning sprites. */
 
struct SpriteAlignerWindow : Window {
 
	typedef std::pair<int16, int16> XyOffs;    ///< Pair for x and y offsets of the sprite before alignment. First value contains the x offset, second value y offset.
 

	
 
	SpriteID current_sprite;                   ///< The currently shown sprite.
 
	Scrollbar *vscroll;
 
	SmallMap<SpriteID, XyOffs> offs_start_map; ///< Mapping of starting offsets for the sprites which have been aligned in the sprite aligner window.
 
	std::map<SpriteID, XyOffs> offs_start_map; ///< Mapping of starting offsets for the sprites which have been aligned in the sprite aligner window.
 

	
 
	static bool centre;
 
	static bool crosshair;
 

	
 
	SpriteAlignerWindow(WindowDesc *desc, WindowNumber wno) : Window(desc)
 
	{
 
@@ -851,13 +851,13 @@ struct SpriteAlignerWindow : Window {
 
				break;
 

	
 
			case WID_SA_OFFSETS_REL: {
 
				/* Relative offset is new absolute offset - starting absolute offset.
 
				 * Show 0, 0 as the relative offsets if entry is not in the map (meaning they have not been changed yet).
 
				 */
 
				const auto key_offs_pair = this->offs_start_map.Find(this->current_sprite);
 
				const auto key_offs_pair = this->offs_start_map.find(this->current_sprite);
 
				if (key_offs_pair != this->offs_start_map.end()) {
 
					SetDParam(0, spr->x_offs - key_offs_pair->second.first);
 
					SetDParam(1, spr->y_offs - key_offs_pair->second.second);
 
				} else {
 
					SetDParam(0, 0);
 
					SetDParam(1, 0);
 
@@ -989,14 +989,14 @@ struct SpriteAlignerWindow : Window {
 
				 * used by someone and the sprite cache isn't big enough for that
 
				 * particular NewGRF developer.
 
				 */
 
				Sprite *spr = const_cast<Sprite *>(GetSprite(this->current_sprite, SpriteType::Normal));
 

	
 
				/* Remember the original offsets of the current sprite, if not already in mapping. */
 
				if (!(this->offs_start_map.Contains(this->current_sprite))) {
 
					this->offs_start_map.Insert(this->current_sprite, XyOffs(spr->x_offs, spr->y_offs));
 
				if (this->offs_start_map.count(this->current_sprite) == 0) {
 
					this->offs_start_map[this->current_sprite] = XyOffs(spr->x_offs, spr->y_offs);
 
				}
 
				switch (widget) {
 
					/* Move eight units at a time if ctrl is pressed. */
 
					case WID_SA_UP:    spr->y_offs -= _ctrl_pressed ? 8 : 1; break;
 
					case WID_SA_DOWN:  spr->y_offs += _ctrl_pressed ? 8 : 1; break;
 
					case WID_SA_LEFT:  spr->x_offs -= _ctrl_pressed ? 8 : 1; break;
 
@@ -1007,13 +1007,13 @@ struct SpriteAlignerWindow : Window {
 
				MarkWholeScreenDirty();
 
				break;
 
			}
 

	
 
			case WID_SA_RESET_REL:
 
				/* Reset the starting offsets for the current sprite. */
 
				this->offs_start_map.Erase(this->current_sprite);
 
				this->offs_start_map.erase(this->current_sprite);
 
				this->SetDirty();
 
				break;
 

	
 
			case WID_SA_CENTRE:
 
				SpriteAlignerWindow::centre = !SpriteAlignerWindow::centre;
 
				this->SetWidgetLoweredState(widget, SpriteAlignerWindow::centre);
src/newgrf_gui.cpp
Show inline comments
 
@@ -280,14 +280,15 @@ struct NewGRFParametersWindow : public W
 
					DrawDropDownButton(buttons_left, ir.top + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, this->editable);
 
				} else {
 
					DrawArrowButtons(buttons_left, ir.top + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, this->editable && current_value > par_info->min_value, this->editable && current_value < par_info->max_value);
 
				}
 
				SetDParam(2, STR_JUST_INT);
 
				SetDParam(3, current_value);
 
				if (par_info->value_names.Contains(current_value)) {
 
					const char *label = GetGRFStringFromGRFText(par_info->value_names.Find(current_value)->second);
 
				auto it = par_info->value_names.find(current_value);
 
				if (it != par_info->value_names.end()) {
 
					const char *label = GetGRFStringFromGRFText(it->second);
 
					if (label != nullptr) {
 
						SetDParam(2, STR_JUST_RAW_STRING);
 
						SetDParamStr(3, label);
 
					}
 
				}
 
			}
 
@@ -377,13 +378,13 @@ struct NewGRFParametersWindow : public W
 
						if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
 
							this->clicked_dropdown = true;
 
							this->closing_dropdown = false;
 

	
 
							DropDownList list;
 
							for (uint32 i = par_info->min_value; i <= par_info->max_value; i++) {
 
								list.emplace_back(new DropDownListCharStringItem(GetGRFStringFromGRFText(par_info->value_names.Find(i)->second), i, false));
 
								list.emplace_back(new DropDownListCharStringItem(GetGRFStringFromGRFText(par_info->value_names.find(i)->second), i, false));
 
							}
 

	
 
							ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE);
 
						}
 
					}
 
				} else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) {
src/newgrf_text.cpp
Show inline comments
 
@@ -23,13 +23,12 @@
 
#include "newgrf_text.h"
 
#include "newgrf_cargo.h"
 
#include "string_func.h"
 
#include "date_type.h"
 
#include "debug.h"
 
#include "core/alloc_type.hpp"
 
#include "core/smallmap_type.hpp"
 
#include "language.h"
 
#include <sstream>
 

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

	
src/os/macosx/font_osx.cpp
Show inline comments
 
@@ -7,12 +7,13 @@
 

	
 
/** @file font_osx.cpp Functions related to font handling on MacOS. */
 

	
 
#include "../../stdafx.h"
 
#include "../../debug.h"
 
#include "font_osx.h"
 
#include "../../core/math_func.hpp"
 
#include "../../blitter/factory.hpp"
 
#include "../../error_func.h"
 
#include "../../fileio_func.h"
 
#include "../../fontdetection.h"
 
#include "../../string_func.h"
 
#include "../../strings_func.h"
src/os/macosx/string_osx.cpp
Show inline comments
 
@@ -99,14 +99,13 @@ public:
 
			CFArrayRef runs = CTLineGetGlyphRuns(line.get());
 
			for (CFIndex i = 0; i < CFArrayGetCount(runs); i++) {
 
				CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runs, i);
 

	
 
				/* Extract font information for this run. */
 
				CFRange chars = CTRunGetStringRange(run);
 
				auto map = fontMapping.begin();
 
				while (map < fontMapping.end() - 1 && map->first <= chars.location) map++;
 
				auto map = fontMapping.upper_bound(chars.location);
 

	
 
				this->emplace_back(run, map->second, buff);
 
			}
 
		}
 

	
 
		int GetLeading() const override;
src/os/windows/font_win32.cpp
Show inline comments
 
@@ -9,12 +9,13 @@
 

	
 
#include "../../stdafx.h"
 
#include "../../debug.h"
 
#include "../../blitter/factory.hpp"
 
#include "../../core/alloc_func.hpp"
 
#include "../../core/math_func.hpp"
 
#include "../../core/mem_func.hpp"
 
#include "../../error_func.h"
 
#include "../../fileio_func.h"
 
#include "../../fontdetection.h"
 
#include "../../fontcache.h"
 
#include "../../fontcache/truetypefontcache.h"
 
#include "../../string_func.h"
src/osk_gui.cpp
Show inline comments
 
@@ -47,14 +47,14 @@ struct OskWindow : public Window {
 
		this->parent = parent;
 
		assert(parent != nullptr);
 

	
 
		NWidgetCore *par_wid = parent->GetWidget<NWidgetCore>(button);
 
		assert(par_wid != nullptr);
 

	
 
		assert(parent->querystrings.Contains(button));
 
		this->qs         = parent->querystrings.Find(button)->second;
 
		assert(parent->querystrings.count(button) != 0);
 
		this->qs         = parent->querystrings.find(button)->second;
 
		this->caption = (par_wid->widget_data != STR_NULL) ? par_wid->widget_data : this->qs->caption;
 
		this->text_btn   = button;
 
		this->text       = &this->qs->text;
 
		this->querystrings[WID_OSK_TEXT] = this->qs;
 

	
 
		/* make a copy in case we need to reset later */
src/saveload/company_sl.cpp
Show inline comments
 
@@ -545,13 +545,17 @@ struct PLYRChunkHandler : ChunkHandler {
 
				cprops->name_1 != STR_GAME_SAVELOAD_NOT_AVAILABLE && cprops->name_1 != STR_SV_UNNAMED &&
 
				cprops->name_1 != SPECSTR_ANDCO_NAME && cprops->name_1 != SPECSTR_PRESIDENT_NAME &&
 
				cprops->name_1 != SPECSTR_SILLY_NAME) {
 
				cprops->name_1 = STR_GAME_SAVELOAD_NOT_AVAILABLE;
 
			}
 

	
 
			if (!_load_check_data.companies.Insert(index, cprops)) delete cprops;
 
			if (_load_check_data.companies.count(index) == 0) {
 
				_load_check_data.companies[index] = cprops;
 
			} else {
 
				delete cprops;
 
			}
 
		}
 
	}
 

	
 
	void FixPointers() const override
 
	{
 
		for (Company *c : Company::Iterate()) {
src/script/script_config.hpp
Show inline comments
 
@@ -7,13 +7,12 @@
 

	
 
/** @file script_config.hpp ScriptConfig stores the configuration settings of every Script. */
 

	
 
#ifndef SCRIPT_CONFIG_HPP
 
#define SCRIPT_CONFIG_HPP
 

	
 
#include "../core/smallmap_type.hpp"
 
#include "../company_type.h"
 
#include "../textfile_gui.h"
 
#include "script_instance.hpp"
 

	
 
/** Maximum of 10 digits for MIN / MAX_INT32, 1 for the sign and 1 for '\0'. */
 
static const int INT32_DIGITS_WITH_SIGN_AND_TERMINATION = 10 + 1 + 1;
src/town_cmd.cpp
Show inline comments
 
@@ -3642,13 +3642,13 @@ Town *ClosestTownFromTile(TileIndex tile
 
		default:
 
			return CalcClosestTownFromTile(tile, threshold);
 
	}
 
}
 

	
 
static bool _town_rating_test = false; ///< If \c true, town rating is in test-mode.
 
static SmallMap<const Town *, int> _town_test_ratings; ///< Map of towns to modified ratings, while in town rating test-mode.
 
static std::map<const Town *, int> _town_test_ratings; ///< Map of towns to modified ratings, while in town rating test-mode.
 

	
 
/**
 
 * Switch the town rating to test-mode, to allow commands to be tested without affecting current ratings.
 
 * The function is safe to use in nested calls.
 
 * @param mode Test mode switch (\c true means go to test-mode, \c false means leave test-mode).
 
 */
 
@@ -3672,14 +3672,14 @@ void SetTownRatingTestMode(bool mode)
 
 * @param t Town to get the rating from.
 
 * @return Rating of the current company in the given town.
 
 */
 
static int GetRating(const Town *t)
 
{
 
	if (_town_rating_test) {
 
		SmallMap<const Town *, int>::iterator it = _town_test_ratings.Find(t);
 
		if (it != _town_test_ratings.End()) {
 
		auto it = _town_test_ratings.find(t);
 
		if (it != _town_test_ratings.end()) {
 
			return it->second;
 
		}
 
	}
 
	return t->ratings[_current_company];
 
}
 

	
src/vehicle.cpp
Show inline comments
 
@@ -675,19 +675,18 @@ void ResetVehicleColourMap()
 
}
 

	
 
/**
 
 * List of vehicles that should check for autoreplace this tick.
 
 * Mapping of vehicle -> leave depot immediately after autoreplace.
 
 */
 
typedef SmallMap<Vehicle *, bool> AutoreplaceMap;
 
using AutoreplaceMap = std::map<Vehicle *, bool>;
 
static AutoreplaceMap _vehicles_to_autoreplace;
 

	
 
void InitializeVehicles()
 
{
 
	_vehicles_to_autoreplace.clear();
 
	_vehicles_to_autoreplace.shrink_to_fit();
 
	ResetVehicleHash();
 
}
 

	
 
uint CountVehiclesInChain(const Vehicle *v)
 
{
 
	uint count = 0;
 
@@ -2354,19 +2353,19 @@ void Vehicle::HandleLoading(bool mode)
 
}
 

	
 
/**
 
 * Get a map of cargoes and free capacities in the consist.
 
 * @param capacities Map to be filled with cargoes and capacities.
 
 */
 
void Vehicle::GetConsistFreeCapacities(SmallMap<CargoID, uint> &capacities) const
 
void Vehicle::GetConsistFreeCapacities(std::map<CargoID, uint> &capacities) const
 
{
 
	for (const Vehicle *v = this; v != nullptr; v = v->Next()) {
 
		if (v->cargo_cap == 0) continue;
 
		std::pair<CargoID, uint> *pair = capacities.Find(v->cargo_type);
 
		if (pair == capacities.End()) {
 
			capacities.push_back({v->cargo_type, v->cargo_cap - v->cargo.StoredCount()});
 
		auto pair = capacities.find(v->cargo_type);
 
		if (pair == capacities.end()) {
 
			capacities[v->cargo_type] = v->cargo_cap - v->cargo.StoredCount();
 
		} else {
 
			pair->second += v->cargo_cap - v->cargo.StoredCount();
 
		}
 
	}
 
}
 

	
src/vehicle_base.h
Show inline comments
 
@@ -7,13 +7,12 @@
 

	
 
/** @file  vehicle_base.h Base class for all vehicles. */
 

	
 
#ifndef VEHICLE_BASE_H
 
#define VEHICLE_BASE_H
 

	
 
#include "core/smallmap_type.hpp"
 
#include "track_type.h"
 
#include "command_type.h"
 
#include "order_base.h"
 
#include "cargopacket.h"
 
#include "texteff.hpp"
 
#include "engine_type.h"
 
@@ -388,13 +387,13 @@ public:
 
	const uint16 &GetGroundVehicleFlags() const;
 

	
 
	void DeleteUnreachedImplicitOrders();
 

	
 
	void HandleLoading(bool mode = false);
 

	
 
	void GetConsistFreeCapacities(SmallMap<CargoID, uint> &capacities) const;
 
	void GetConsistFreeCapacities(std::map<CargoID, uint> &capacities) const;
 

	
 
	uint GetConsistTotalCapacity() const;
 

	
 
	/**
 
	 * Marks the vehicles to be redrawn and updates cached variables
 
	 *
src/window.cpp
Show inline comments
 
@@ -337,34 +337,33 @@ Scrollbar *Window::GetScrollbar(uint wid
 
 * Return the querystring associated to a editbox.
 
 * @param widnum Editbox widget index
 
 * @return QueryString or nullptr.
 
 */
 
const QueryString *Window::GetQueryString(uint widnum) const
 
{
 
	auto query = this->querystrings.Find(widnum);
 
	auto query = this->querystrings.find(widnum);
 
	return query != this->querystrings.end() ? query->second : nullptr;
 
}
 

	
 
/**
 
 * Return the querystring associated to a editbox.
 
 * @param widnum Editbox widget index
 
 * @return QueryString or nullptr.
 
 */
 
QueryString *Window::GetQueryString(uint widnum)
 
{
 
	SmallMap<int, QueryString*>::Pair *query = this->querystrings.Find(widnum);
 
	return query != this->querystrings.End() ? query->second : nullptr;
 
	auto query = this->querystrings.find(widnum);
 
	return query != this->querystrings.end() ? query->second : nullptr;
 
}
 

	
 
/**
 
 * Update size of all QueryStrings of this window.
 
 */
 
void Window::UpdateQueryStringSize()
 
{
 
	for (auto &qs : this->querystrings)
 
	{
 
	for (auto &qs : this->querystrings) {
 
		qs.second->text.UpdateSize();
 
	}
 
}
 

	
 
/**
 
 * Get the current input text if an edit box has the focus.
 
@@ -1909,13 +1908,13 @@ static void DecreaseWindowCounters()
 
					}
 
				}
 
			}
 
		}
 

	
 
		/* Handle editboxes */
 
		for (SmallMap<int, QueryString*>::Pair &pair : w->querystrings) {
 
		for (auto &pair : w->querystrings) {
 
			pair.second->HandleEditBox(w, pair.first);
 
		}
 

	
 
		w->OnMouseLoop();
 
	}
 

	
src/window_gui.h
Show inline comments
 
@@ -14,13 +14,12 @@
 
#include "vehicle_type.h"
 
#include "viewport_type.h"
 
#include "company_type.h"
 
#include "tile_type.h"
 
#include "widget_type.h"
 
#include "core/smallvec_type.hpp"
 
#include "core/smallmap_type.hpp"
 
#include "string_type.h"
 

	
 
/**
 
 * Flags to describe the look of the frame
 
 */
 
enum FrameFlags {
 
@@ -247,13 +246,13 @@ public:
 
	ResizeInfo resize;  ///< Resize information
 

	
 
	Owner owner;        ///< The owner of the content shown in this window. Company colour is acquired from this variable.
 

	
 
	ViewportData *viewport;          ///< Pointer to viewport data, if present.
 
	const NWidgetCore *nested_focus; ///< Currently focused nested widget, or \c nullptr if no nested widget has focus.
 
	SmallMap<int, QueryString*> querystrings; ///< QueryString associated to WWT_EDITBOX widgets.
 
	std::map<int, QueryString*> querystrings; ///< QueryString associated to WWT_EDITBOX widgets.
 
	NWidgetBase *nested_root;        ///< Root of the nested tree.
 
	NWidgetBase **nested_array;      ///< Array of pointers into the tree. Do not access directly, use #Window::GetWidget() instead.
 
	uint nested_array_size;          ///< Size of the nested array.
 
	NWidgetStacked *shade_select;    ///< Selection widget (#NWID_SELECTION) to use for shading the window. If \c nullptr, window cannot shade.
 
	Dimension unshaded_size;         ///< Last known unshaded size (only valid while shaded).
 

	
0 comments (0 inline, 0 general)