Changeset - r27400:742251af6ade
src/animated_tile.cpp
Show inline comments
 
@@ -8,7 +8,7 @@
 
/** @file animated_tile.cpp Everything related to animated tiles. */
 

	
 
#include "stdafx.h"
 
#include "core/smallvec_type.hpp"
 
#include "core/container_func.hpp"
 
#include "tile_cmd.h"
 
#include "viewport_func.h"
 
#include "framerate_type.h"
src/core/CMakeLists.txt
Show inline comments
 
@@ -23,7 +23,7 @@ add_files(
 
    random_func.cpp
 
    random_func.hpp
 
    smallstack_type.hpp
 
    smallvec_type.hpp
 
    container_func.hpp
 
    span_type.hpp
 
    strong_typedef_type.hpp
 
)
src/core/container_func.hpp
Show inline comments
 
new file 100644
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file container_func.hpp Some simple functions to help with accessing containers. */
 

	
 
#ifndef CONTAINER_FUNC_HPP
 
#define CONTAINER_FUNC_HPP
 

	
 
/**
 
 * Helper function to append an item to a container if it is not already contained.
 
 * The container must have a \c emplace_back function.
 
 * Consider using std::set, std::unordered_set or std::flat_set in new code.
 
 *
 
 * @param container A reference to the container to be extended
 
 * @param item Reference to the item to be copy-constructed if not found
 
 *
 
 * @return Whether the item was already present
 
 */
 
template <typename Container>
 
inline bool include(Container &container, typename Container::const_reference &item)
 
{
 
	const bool is_member = std::find(container.begin(), container.end(), item) != container.end();
 
	if (!is_member) container.emplace_back(item);
 
	return is_member;
 
}
 

	
 
/**
 
 * Helper function to get the index of an item
 
 * Consider using std::set, std::unordered_set or std::flat_set in new code.
 
 *
 
 * @param container A reference to the container to be searched.
 
 * @param item Reference to the item to be search for
 
 *
 
 * @return Index of element if found, otherwise -1
 
 */
 
template <typename Container>
 
int find_index(Container const &container, typename Container::const_reference item)
 
{
 
	auto const it = std::find(container.begin(), container.end(), item);
 
	if (it != container.end()) return std::distance(container.begin(), it);
 

	
 
	return -1;
 
}
 

	
 
#endif /* CONTAINER_FUNC_HPP */
src/core/pool_type.hpp
Show inline comments
 
@@ -10,7 +10,6 @@
 
#ifndef POOL_TYPE_HPP
 
#define POOL_TYPE_HPP
 

	
 
#include "smallvec_type.hpp"
 
#include "enum_type.hpp"
 

	
 
/** Various types of a pool. */
src/core/smallstack_type.hpp
Show inline comments
 
@@ -10,7 +10,6 @@
 
#ifndef SMALLSTACK_TYPE_HPP
 
#define SMALLSTACK_TYPE_HPP
 

	
 
#include "smallvec_type.hpp"
 
#include <mutex>
 

	
 
/**
src/core/smallvec_type.hpp
Show inline comments
 
deleted file
src/economy.cpp
Show inline comments
 
@@ -41,6 +41,7 @@
 
#include "economy_base.h"
 
#include "core/pool_func.hpp"
 
#include "core/backup_type.hpp"
 
#include "core/container_func.hpp"
 
#include "cargo_type.h"
 
#include "water.h"
 
#include "game/game.hpp"
src/error_gui.cpp
Show inline comments
 
@@ -8,6 +8,7 @@
 
/** @file error_gui.cpp GUI related to errors. */
 

	
 
#include "stdafx.h"
 
#include "core/mem_func.hpp"
 
#include "landscape.h"
 
#include "newgrf_text.h"
 
#include "error.h"
src/game/game_text.hpp
Show inline comments
 
@@ -10,8 +10,6 @@
 
#ifndef GAME_TEXT_HPP
 
#define GAME_TEXT_HPP
 

	
 
#include "../core/smallvec_type.hpp"
 

	
 
struct StringParam {
 
	enum ParamType {
 
		RAW_STRING,
src/gfx.cpp
Show inline comments
 
@@ -22,6 +22,7 @@
 
#include "newgrf_debug.h"
 
#include "thread.h"
 
#include "core/backup_type.hpp"
 
#include "core/container_func.hpp"
 
#include "viewport_func.h"
 

	
 
#include "table/palettes.h"
src/gfx_layout.cpp
Show inline comments
 
@@ -8,6 +8,7 @@
 
/** @file gfx_layout.cpp Handling of laying out text. */
 

	
 
#include "stdafx.h"
 
#include "core/math_func.hpp"
 
#include "gfx_layout.h"
 
#include "string_func.h"
 
#include "debug.h"
src/group_gui.cpp
Show inline comments
 
@@ -22,6 +22,7 @@
 
#include "tilehighlight_func.h"
 
#include "vehicle_gui_base.h"
 
#include "core/geometry_func.hpp"
 
#include "core/container_func.hpp"
 
#include "company_base.h"
 
#include "company_gui.h"
 
#include "gui.h"
src/language.h
Show inline comments
 
@@ -10,7 +10,6 @@
 
#ifndef LANGUAGE_H
 
#define LANGUAGE_H
 

	
 
#include "core/smallvec_type.hpp"
 
#ifdef WITH_ICU_I18N
 
#include <unicode/coll.h>
 
#endif /* WITH_ICU_I18N */
src/music/midifile.cpp
Show inline comments
 
@@ -12,6 +12,7 @@
 
#include "../fileio_type.h"
 
#include "../string_func.h"
 
#include "../core/endian_func.hpp"
 
#include "../core/mem_func.hpp"
 
#include "../base_media_base.h"
 
#include "midi.h"
 

	
src/music/midifile.hpp
Show inline comments
 
@@ -11,7 +11,6 @@
 
#define MUSIC_MIDIFILE_HPP
 

	
 
#include "../stdafx.h"
 
#include "../core/smallvec_type.hpp"
 
#include "midi.h"
 

	
 
struct MusicSongInfo;
src/music/win32_m.cpp
Show inline comments
 
@@ -17,6 +17,7 @@
 
#include "midifile.hpp"
 
#include "midi.h"
 
#include "../base_media_base.h"
 
#include "../core/mem_func.hpp"
 
#include <mutex>
 

	
 
#include "../safeguards.h"
src/music_gui.cpp
Show inline comments
 
@@ -18,6 +18,7 @@
 
#include "gfx_func.h"
 
#include "zoom_func.h"
 
#include "core/random_func.hpp"
 
#include "core/mem_func.hpp"
 
#include "error.h"
 
#include "core/geometry_func.hpp"
 
#include "string_func.h"
src/network/network_content.h
Show inline comments
 
@@ -13,6 +13,7 @@
 
#include "core/tcp_content.h"
 
#include "core/http.h"
 
#include <unordered_map>
 
#include "../core/container_func.hpp"
 

	
 
/** Vector with content info */
 
typedef std::vector<ContentInfo *> ContentVector;
src/newgrf.cpp
Show inline comments
 
@@ -9,6 +9,7 @@
 

	
 
#include "stdafx.h"
 

	
 
#include "core/container_func.hpp"
 
#include "debug.h"
 
#include "fileio_func.h"
 
#include "engine_func.h"
src/newgrf.h
Show inline comments
 
@@ -16,7 +16,7 @@
 
#include "fileio_type.h"
 
#include "core/bitmath_func.hpp"
 
#include "core/alloc_type.hpp"
 
#include "core/smallvec_type.hpp"
 
#include "core/mem_func.hpp"
 

	
 
/**
 
 * List of different canal 'features'.
src/newgrf_commons.h
Show inline comments
 
@@ -15,7 +15,6 @@
 

	
 
#include "sprite.h"
 
#include "core/alloc_type.hpp"
 
#include "core/smallvec_type.hpp"
 
#include "command_type.h"
 
#include "direction_type.h"
 
#include "company_type.h"
src/newgrf_debug.h
Show inline comments
 
@@ -11,7 +11,6 @@
 
#define NEWGRF_DEBUG_H
 

	
 
#include "newgrf.h"
 
#include "core/smallvec_type.hpp"
 
#include "tile_type.h"
 
#include "vehicle_type.h"
 

	
src/newgrf_engine.cpp
Show inline comments
 
@@ -17,6 +17,7 @@
 
#include "timer/timer_game_calendar.h"
 
#include "vehicle_func.h"
 
#include "core/random_func.hpp"
 
#include "core/container_func.hpp"
 
#include "aircraft.h"
 
#include "station_base.h"
 
#include "company_base.h"
src/newgrf_railtype.cpp
Show inline comments
 
@@ -8,6 +8,7 @@
 
/** @file newgrf_railtype.cpp NewGRF handling of rail types. */
 

	
 
#include "stdafx.h"
 
#include "core/container_func.hpp"
 
#include "debug.h"
 
#include "newgrf_railtype.h"
 
#include "timer/timer_game_calendar.h"
src/newgrf_roadtype.cpp
Show inline comments
 
@@ -8,6 +8,7 @@
 
/** @file newgrf_roadtype.cpp NewGRF handling of road types. */
 

	
 
#include "stdafx.h"
 
#include "core/container_func.hpp"
 
#include "debug.h"
 
#include "newgrf_roadtype.h"
 
#include "timer/timer_game_calendar.h"
src/newgrf_text.h
Show inline comments
 
@@ -12,7 +12,6 @@
 

	
 
#include "string_type.h"
 
#include "strings_type.h"
 
#include "core/smallvec_type.hpp"
 
#include "table/control_codes.h"
 
#include <utility>
 

	
src/rail_cmd.cpp
Show inline comments
 
@@ -26,6 +26,7 @@
 
#include "pbs.h"
 
#include "company_base.h"
 
#include "core/backup_type.hpp"
 
#include "core/container_func.hpp"
 
#include "timer/timer_game_calendar.h"
 
#include "strings_func.h"
 
#include "company_gui.h"
src/road_cmd.cpp
Show inline comments
 
@@ -30,6 +30,7 @@
 
#include "town.h"
 
#include "company_base.h"
 
#include "core/random_func.hpp"
 
#include "core/container_func.hpp"
 
#include "newgrf_debug.h"
 
#include "newgrf_railtype.h"
 
#include "newgrf_roadtype.h"
src/saveload/animated_tile_sl.cpp
Show inline comments
 
@@ -13,7 +13,6 @@
 
#include "compat/animated_tile_sl_compat.h"
 

	
 
#include "../tile_type.h"
 
#include "../core/smallvec_type.hpp"
 

	
 
#include "../safeguards.h"
 

	
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -27,7 +27,6 @@
 
#include "../engine_func.h"
 
#include "../company_base.h"
 
#include "../disaster_vehicle.h"
 
#include "../core/smallvec_type.hpp"
 
#include "../timer/timer.h"
 
#include "../timer/timer_game_tick.h"
 
#include "../timer/timer_game_calendar.h"
src/settings_func.h
Show inline comments
 
@@ -10,7 +10,6 @@
 
#ifndef SETTINGS_FUNC_H
 
#define SETTINGS_FUNC_H
 

	
 
#include "core/smallvec_type.hpp"
 
#include "company_type.h"
 
#include "string_type.h"
 

	
src/settingsgen/settingsgen.cpp
Show inline comments
 
@@ -12,7 +12,7 @@
 
#include "../strings_type.h"
 
#include "../misc/getoptdata.h"
 
#include "../ini_type.h"
 
#include "../core/smallvec_type.hpp"
 
#include "../core/mem_func.hpp"
 
#include "../error_func.h"
 

	
 
#if !defined(_WIN32) || defined(__CYGWIN__)
src/sortlist_type.h
Show inline comments
 
@@ -12,7 +12,7 @@
 

	
 
#include "core/enum_type.hpp"
 
#include "core/bitmath_func.hpp"
 
#include "core/smallvec_type.hpp"
 
#include "core/mem_func.hpp"
 
#include "date_type.h"
 

	
 
/** Flags of the sort list. */
src/station_cmd.cpp
Show inline comments
 
@@ -45,6 +45,7 @@
 
#include "pbs.h"
 
#include "debug.h"
 
#include "core/random_func.hpp"
 
#include "core/container_func.hpp"
 
#include "company_base.h"
 
#include "table/airporttile_ids.h"
 
#include "newgrf_airporttiles.h"
src/strgen/strgen.cpp
Show inline comments
 
@@ -9,6 +9,7 @@
 

	
 
#include "../stdafx.h"
 
#include "../core/endian_func.hpp"
 
#include "../core/mem_func.hpp"
 
#include "../error_func.h"
 
#include "../string_func.h"
 
#include "../strings_type.h"
src/strgen/strgen_base.cpp
Show inline comments
 
@@ -10,6 +10,7 @@
 
#include "../stdafx.h"
 
#include "../core/alloc_func.hpp"
 
#include "../core/endian_func.hpp"
 
#include "../core/mem_func.hpp"
 
#include "../error_func.h"
 
#include "../string_func.h"
 
#include "../table/control_codes.h"
src/stringfilter_type.h
Show inline comments
 
@@ -10,7 +10,6 @@
 
#ifndef STRINGFILTER_TYPE_H
 
#define STRINGFILTER_TYPE_H
 

	
 
#include "core/smallvec_type.hpp"
 
#include "strings_type.h"
 

	
 
/**
src/subsidy.cpp
Show inline comments
 
@@ -20,6 +20,7 @@
 
#include "subsidy_func.h"
 
#include "core/pool_func.hpp"
 
#include "core/random_func.hpp"
 
#include "core/container_func.hpp"
 
#include "game/game.hpp"
 
#include "command_func.h"
 
#include "string_func.h"
src/texteff.cpp
Show inline comments
 
@@ -11,7 +11,6 @@
 
#include "texteff.hpp"
 
#include "transparency.h"
 
#include "strings_func.h"
 
#include "core/smallvec_type.hpp"
 
#include "viewport_func.h"
 
#include "settings_type.h"
 
#include "command_type.h"
src/vehicle.cpp
Show inline comments
 
@@ -38,6 +38,7 @@
 
#include "roadstop_base.h"
 
#include "core/random_func.hpp"
 
#include "core/backup_type.hpp"
 
#include "core/container_func.hpp"
 
#include "order_backup.h"
 
#include "sound_func.h"
 
#include "effectvehicle_func.h"
src/vehicle_base.h
Show inline comments
 
@@ -23,6 +23,7 @@
 
#include "network/network.h"
 
#include "saveload/saveload.h"
 
#include "timer/timer_game_calendar.h"
 
#include "core/mem_func.hpp"
 

	
 
const uint TILE_AXIAL_DISTANCE = 192;  // Logical length of the tile in any DiagDirection used in vehicle movement.
 
const uint TILE_CORNER_DISTANCE = 128;  // Logical length of the tile corner crossing in any non-diagonal direction used in vehicle movement.
src/vehicle_gui.cpp
Show inline comments
 
@@ -31,6 +31,7 @@
 
#include "articulated_vehicles.h"
 
#include "spritecache.h"
 
#include "core/geometry_func.hpp"
 
#include "core/container_func.hpp"
 
#include "company_base.h"
 
#include "engine_func.h"
 
#include "station_base.h"
src/vehicle_gui_base.h
Show inline comments
 
@@ -10,7 +10,6 @@
 
#ifndef VEHICLE_GUI_BASE_H
 
#define VEHICLE_GUI_BASE_H
 

	
 
#include "core/smallvec_type.hpp"
 
#include "cargo_type.h"
 
#include "timer/timer_game_calendar.h"
 
#include "economy_type.h"
src/vehiclelist.h
Show inline comments
 
@@ -10,7 +10,6 @@
 
#ifndef VEHICLELIST_H
 
#define VEHICLELIST_H
 

	
 
#include "core/smallvec_type.hpp"
 
#include "vehicle_type.h"
 
#include "company_type.h"
 
#include "tile_type.h"
src/viewport_sprite_sorter.h
Show inline comments
 
@@ -8,7 +8,6 @@
 
/** @file viewport_sprite_sorter.h Types related to sprite sorting. */
 

	
 
#include "stdafx.h"
 
#include "core/smallvec_type.hpp"
 
#include "gfx_type.h"
 

	
 
#ifndef VIEWPORT_SPRITE_SORTER_H
src/widgets/dropdown_type.h
Show inline comments
 
@@ -12,7 +12,6 @@
 

	
 
#include "../window_type.h"
 
#include "../gfx_func.h"
 
#include "../core/smallvec_type.hpp"
 
#include "table/strings.h"
 

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

	
 
/**
0 comments (0 inline, 0 general)