Changeset - r27384:b919ab98bb53
src/base_media_base.h
Show inline comments
 
@@ -11,7 +11,6 @@
 
#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"
src/core/CMakeLists.txt
Show inline comments
 
@@ -22,7 +22,6 @@ add_files(
 
    pool_type.hpp
 
    random_func.cpp
 
    random_func.hpp
 
    smallmap_type.hpp
 
    smallstack_type.hpp
 
    smallvec_type.hpp
 
    span_type.hpp
src/core/smallmap_type.hpp
Show inline comments
 
deleted file
src/fios.h
Show inline comments
 
@@ -25,7 +25,7 @@ enum SaveLoadInvalidateWindowData {
 
	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.
src/fontcache/truetypefontcache.cpp
Show inline comments
 
@@ -167,14 +167,14 @@ const Sprite *TrueTypeFontCache::GetGlyp
 

	
 
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
 
@@ -10,7 +10,6 @@
 
#ifndef TRUETYPEFONTCACHE_H
 
#define TRUETYPEFONTCACHE_H
 

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

	
 

	
 
@@ -28,7 +27,7 @@ protected:
 
	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. */
src/gamelog.cpp
Show inline comments
 
@@ -233,25 +233,25 @@ void Gamelog::Print(std::function<void(c
 
	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);
 
		}
 
	}
 
}
 
@@ -262,38 +262,38 @@ void Gamelog::Print(std::function<void(c
 
	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)
src/gamelog_internal.h
Show inline comments
 
@@ -19,14 +19,14 @@
 
 * 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) {}
src/gfx_layout.cpp
Show inline comments
 
@@ -103,8 +103,8 @@ static inline void GetLayouter(Layouter:
 
			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);
 
	}
 
@@ -112,8 +112,8 @@ static inline void GetLayouter(Layouter:
 
	/* 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;
 
@@ -296,12 +296,11 @@ ptrdiff_t Layouter::GetCharAtPosition(in
 
 */
 
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];
 
}
 

	
 
/**
src/gfx_layout.h
Show inline comments
 
@@ -12,7 +12,7 @@
 

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

	
 
#include <stack>
 
#include <string_view>
 
@@ -81,7 +81,7 @@ public:
 
};
 

	
 
/** 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.
 
@@ -169,7 +169,7 @@ private:
 

	
 
	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);
src/gfx_layout_fallback.cpp
Show inline comments
 
@@ -266,7 +266,7 @@ const ParagraphLayouter::VisualRun &Fall
 
 */
 
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);
 
}
 

	
 
/**
 
@@ -295,15 +295,15 @@ std::unique_ptr<const ParagraphLayouter:
 
	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;
 
@@ -325,8 +325,8 @@ std::unique_ptr<const ParagraphLayouter:
 
		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;
src/linkgraph/linkgraph.h
Show inline comments
 
@@ -11,7 +11,6 @@
 
#define LINKGRAPH_H
 

	
 
#include "../core/pool_type.hpp"
 
#include "../core/smallmap_type.hpp"
 
#include "../station_base.h"
 
#include "../cargotype.h"
 
#include "../date_type.h"
src/network/core/address.h
Show inline comments
 
@@ -14,12 +14,11 @@
 
#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
src/newgrf.cpp
Show inline comments
 
@@ -8372,13 +8372,13 @@ static bool ChangeGRFParamValueNames(Byt
 
		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();
src/newgrf_config.cpp
Show inline comments
 
@@ -264,7 +264,7 @@ 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
 
@@ -12,7 +12,6 @@
 

	
 
#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"
 
@@ -143,7 +142,7 @@ struct GRFParameterInfo {
 
	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;
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -818,7 +818,7 @@ struct SpriteAlignerWindow : Window {
 

	
 
	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;
 
@@ -854,7 +854,7 @@ struct SpriteAlignerWindow : Window {
 
				/* 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);
 
@@ -992,8 +992,8 @@ struct SpriteAlignerWindow : Window {
 
				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. */
 
@@ -1010,7 +1010,7 @@ struct SpriteAlignerWindow : Window {
 

	
 
			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;
 

	
src/newgrf_gui.cpp
Show inline comments
 
@@ -283,8 +283,9 @@ struct NewGRFParametersWindow : public W
 
				}
 
				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);
 
@@ -380,7 +381,7 @@ struct NewGRFParametersWindow : public W
 

	
 
							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);
src/newgrf_text.cpp
Show inline comments
 
@@ -26,7 +26,6 @@
 
#include "date_type.h"
 
#include "debug.h"
 
#include "core/alloc_type.hpp"
 
#include "core/smallmap_type.hpp"
 
#include "language.h"
 
#include <sstream>
 

	
src/os/macosx/font_osx.cpp
Show inline comments
 
@@ -10,6 +10,7 @@
 
#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"
src/os/macosx/string_osx.cpp
Show inline comments
 
@@ -102,8 +102,7 @@ public:
 

	
 
				/* 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);
 
			}
src/os/windows/font_win32.cpp
Show inline comments
 
@@ -12,6 +12,7 @@
 
#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"
src/osk_gui.cpp
Show inline comments
 
@@ -50,8 +50,8 @@ struct OskWindow : public Window {
 
		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;
src/saveload/company_sl.cpp
Show inline comments
 
@@ -548,7 +548,11 @@ struct PLYRChunkHandler : ChunkHandler {
 
				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;
 
			}
 
		}
 
	}
 

	
src/script/script_config.hpp
Show inline comments
 
@@ -10,7 +10,6 @@
 
#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"
src/town_cmd.cpp
Show inline comments
 
@@ -3645,7 +3645,7 @@ Town *ClosestTownFromTile(TileIndex tile
 
}
 

	
 
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.
 
@@ -3675,8 +3675,8 @@ void SetTownRatingTestMode(bool mode)
 
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;
 
		}
 
	}
src/vehicle.cpp
Show inline comments
 
@@ -678,13 +678,12 @@ 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();
 
}
 

	
 
@@ -2357,13 +2356,13 @@ 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
 
@@ -10,7 +10,6 @@
 
#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"
 
@@ -391,7 +390,7 @@ public:
 

	
 
	void HandleLoading(bool mode = false);
 

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

	
 
	uint GetConsistTotalCapacity() const;
 

	
src/window.cpp
Show inline comments
 
@@ -340,7 +340,7 @@ Scrollbar *Window::GetScrollbar(uint wid
 
 */
 
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;
 
}
 

	
 
@@ -351,8 +351,8 @@ const QueryString *Window::GetQueryStrin
 
 */
 
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;
 
}
 

	
 
/**
 
@@ -360,8 +360,7 @@ QueryString *Window::GetQueryString(uint
 
 */
 
void Window::UpdateQueryStringSize()
 
{
 
	for (auto &qs : this->querystrings)
 
	{
 
	for (auto &qs : this->querystrings) {
 
		qs.second->text.UpdateSize();
 
	}
 
}
 
@@ -1912,7 +1911,7 @@ static void DecreaseWindowCounters()
 
		}
 

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

	
src/window_gui.h
Show inline comments
 
@@ -17,7 +17,6 @@
 
#include "tile_type.h"
 
#include "widget_type.h"
 
#include "core/smallvec_type.hpp"
 
#include "core/smallmap_type.hpp"
 
#include "string_type.h"
 

	
 
/**
 
@@ -250,7 +249,7 @@ public:
 

	
 
	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.
0 comments (0 inline, 0 general)