1
0
Fork 0

Compare commits

...

9 Commits

Author SHA1 Message Date
Rubidium c6411168d8 Cleanup: missing spaces before continuation * in some comments 2023-11-01 22:56:11 +01:00
Peter Nelson c687b59efc Codechange: Use unique_ptr for SmallMapWindow's overlay. 2023-11-01 21:49:06 +00:00
Peter Nelson 53845bc024 Codechange: Move includes to correct place.
Some other source file inadvertently included things via smallmap_gui.h
2023-11-01 21:49:06 +00:00
Peter Nelson ed8df72c49 Revert 6b68956: Move declaration of SmallMapWindow out of header file.
This split needlessly complicates `SmallMapWindow` for the sake of one method (no longer) used by `LinkGraphOverlay`.
2023-11-01 21:49:06 +00:00
Peter Nelson f91462f54b Codechange: Don't access SmallMapWindow method directly from LinkGraphOverlay. 2023-11-01 21:49:06 +00:00
Peter Nelson ff5e8bb9a3 Fix #11413: Incorrect sorting by industry production.
Error caused by single character mistake. However this algorithm was inefficent if a filter was specified, and clearly the flow was error-prone.

Now using separately-scoped loops to avoid similar.
2023-11-01 21:37:53 +00:00
Peter Nelson 278b42d078 Codechange: Document Industry::GetCargoProduced/Accepted and add const-variant. 2023-11-01 21:37:53 +00:00
Peter Nelson 4f3adc038a Cleanup: Use standard comment codestyle. 2023-11-01 21:37:53 +00:00
Tyler Trahan 49d53c41ab
Doc: Don't use other names for road vehicle bay stops (#11418) 2023-11-01 21:19:31 +00:00
34 changed files with 1329 additions and 1338 deletions

View File

@ -457,7 +457,7 @@ void IConsoleGUIPrint(TextColour colour_code, const std::string &str)
* all lines in the buffer are aged by one. When a line exceeds both the maximum position
* and also the maximum age, it gets removed.
* @return true if any lines were removed
*/
*/
static bool TruncateBuffer()
{
bool need_truncation = false;

View File

@ -324,7 +324,7 @@ static inline T ROR(const T x, const uint8_t n)
* Iterable ensemble of each set bit in a value.
* @tparam Tbitpos Type of the position variable.
* @tparam Tbitset Type of the bitset value.
*/
*/
template <typename Tbitpos = uint, typename Tbitset = uint>
struct SetBitIterator {
struct Iterator {

View File

@ -447,14 +447,14 @@ public:
}
/**
* Find all items contained within the given rectangle.
* @note Start coordinates are inclusive, end coordinates are exclusive. x1<x2 && y1<y2 is a precondition.
* @param x1 Start first coordinate, points found are greater or equals to this.
* @param y1 Start second coordinate, points found are greater or equals to this.
* @param x2 End first coordinate, points found are less than this.
* @param y2 End second coordinate, points found are less than this.
* @param outputter Callback used to return values from the search.
*/
* Find all items contained within the given rectangle.
* @note Start coordinates are inclusive, end coordinates are exclusive. x1<x2 && y1<y2 is a precondition.
* @param x1 Start first coordinate, points found are greater or equals to this.
* @param y1 Start second coordinate, points found are greater or equals to this.
* @param x2 End first coordinate, points found are less than this.
* @param y2 End second coordinate, points found are less than this.
* @param outputter Callback used to return values from the search.
*/
template <typename Outputter>
void FindContained(CoordT x1, CoordT y1, CoordT x2, CoordT y2, const Outputter &outputter) const
{

View File

@ -719,7 +719,7 @@ void ScanScenarios()
/**
* Constructs FiosNumberedSaveName. Initial number is the most recent save, or -1 if not found.
* @param prefix The prefix to use to generate a filename.
*/
*/
FiosNumberedSaveName::FiosNumberedSaveName(const std::string &prefix) : prefix(prefix), number(-1)
{
static std::optional<std::string> _autosave_path;
@ -756,7 +756,7 @@ FiosNumberedSaveName::FiosNumberedSaveName(const std::string &prefix) : prefix(p
/**
* Generate a savegame name and number according to _settings_client.gui.max_num_autosaves.
* @return A filename in format "<prefix><number>.sav".
*/
*/
std::string FiosNumberedSaveName::Filename()
{
if (++this->number >= _settings_client.gui.max_num_autosaves) this->number = 0;
@ -766,7 +766,7 @@ std::string FiosNumberedSaveName::Filename()
/**
* Generate an extension for a savegame name.
* @return An extension in format "-<prefix>.sav".
*/
*/
std::string FiosNumberedSaveName::Extension()
{
return fmt::format("-{}.sav", this->prefix);

View File

@ -1,9 +1,9 @@
/*
* 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/>.
*/
* 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 framerate_gui.cpp GUI for displaying framerate/game speed information. */
@ -802,7 +802,7 @@ struct FrametimeGraphWindow : Window {
void SelectHorizontalScale(TimingMeasurement range)
{
/* Determine horizontal scale based on period covered by 60 points
* (slightly less than 2 seconds at full game speed) */
* (slightly less than 2 seconds at full game speed) */
struct ScaleDef { TimingMeasurement range; int scale; };
static const ScaleDef hscales[] = {
{ 120, 60 },

View File

@ -1,9 +1,9 @@
/*
* 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/>.
*/
* 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 framerate_type.h
* Types for recording game performance data.

View File

@ -138,35 +138,60 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
return IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == this->index;
}
/**
* Get produced cargo slot for a specific cargo type.
* @param cargo CargoID to find.
* @return Iterator pointing to produced cargo slot if it exists, or the end iterator.
*/
inline ProducedCargoArray::iterator GetCargoProduced(CargoID cargo)
{
if (!IsValidCargoID(cargo)) return std::end(this->produced);
return std::find_if(std::begin(this->produced), std::end(this->produced), [&cargo](const auto &p) { return p.cargo == cargo; });
}
/**
* Get produced cargo slot for a specific cargo type (const-variant).
* @param cargo CargoID to find.
* @return Iterator pointing to produced cargo slot if it exists, or the end iterator.
*/
inline ProducedCargoArray::const_iterator GetCargoProduced(CargoID cargo) const
{
if (!IsValidCargoID(cargo)) return std::end(this->produced);
return std::find_if(std::begin(this->produced), std::end(this->produced), [&cargo](const auto &p) { return p.cargo == cargo; });
}
/**
* Get accepted cargo slot for a specific cargo type.
* @param cargo CargoID to find.
* @return Iterator pointing to accepted cargo slot if it exists, or the end iterator.
*/
inline AcceptedCargoArray::iterator GetCargoAccepted(CargoID cargo)
{
if (!IsValidCargoID(cargo)) return std::end(this->accepted);
return std::find_if(std::begin(this->accepted), std::end(this->accepted), [&cargo](const auto &a) { return a.cargo == cargo; });
}
/** Test if this industry accepts any cargo.
/**
* Test if this industry accepts any cargo.
* @return true iff the industry accepts any cargo.
*/
bool IsCargoAccepted() const { return std::any_of(std::begin(this->accepted), std::end(this->accepted), [](const auto &a) { return IsValidCargoID(a.cargo); }); }
/** Test if this industry produces any cargo.
/**
* Test if this industry produces any cargo.
* @return true iff the industry produces any cargo.
*/
bool IsCargoProduced() const { return std::any_of(std::begin(this->produced), std::end(this->produced), [](const auto &p) { return IsValidCargoID(p.cargo); }); }
/** Test if this industry accepts a specific cargo.
/**
* Test if this industry accepts a specific cargo.
* @param cargo Cargo type to test.
* @return true iff the industry accepts the given cargo type.
*/
bool IsCargoAccepted(CargoID cargo) const { return std::any_of(std::begin(this->accepted), std::end(this->accepted), [&cargo](const auto &a) { return a.cargo == cargo; }); }
/** Test if this industry produces a specific cargo.
/**
* Test if this industry produces a specific cargo.
* @param cargo Cargo type to test.
* @return true iff the industry produces the given cargo types.
*/

View File

@ -1509,14 +1509,16 @@ protected:
if (filter == CF_NONE) return IndustryTypeSorter(a, b);
uint prod_a = 0, prod_b = 0;
for (auto ita = std::begin(a->produced), itb = std::begin(b->produced); ita != std::end(a->produced) && itb != std::end(b->produced); ++ita, ++itb) {
if (filter == CF_ANY) {
if (IsValidCargoID(ita->cargo)) prod_a += ita->history[LAST_MONTH].production;
if (IsValidCargoID(itb->cargo)) prod_b += ita->history[LAST_MONTH].production;
} else {
if (ita->cargo == filter) prod_a += ita->history[LAST_MONTH].production;
if (itb->cargo == filter) prod_b += itb->history[LAST_MONTH].production;
if (filter == CF_ANY) {
for (const auto &pa : a->produced) {
if (IsValidCargoID(pa.cargo)) prod_a += pa.history[LAST_MONTH].production;
}
for (const auto &pb : b->produced) {
if (IsValidCargoID(pb.cargo)) prod_b += pb.history[LAST_MONTH].production;
}
} else {
if (auto ita = a->GetCargoProduced(filter); ita != std::end(a->produced)) prod_a = ita->history[LAST_MONTH].production;
if (auto itb = b->GetCargoProduced(filter); itb != std::end(b->produced)) prod_b = itb->history[LAST_MONTH].production;
}
int r = prod_a - prod_b;

View File

@ -19,6 +19,8 @@
#include "../smallmap_gui.h"
#include "../core/geometry_func.hpp"
#include "../widgets/link_graph_legend_widget.h"
#include "../strings_func.h"
#include "linkgraph_gui.h"
#include "table/strings.h"
@ -425,7 +427,7 @@ Point LinkGraphOverlay::GetStationMiddle(const Station *st) const
return GetViewportStationMiddle(this->window->viewport, st);
} else {
/* assume this is a smallmap */
return static_cast<const SmallMapWindow *>(this->window)->GetStationMiddle(st);
return GetSmallMapStationMiddle(this->window, st);
}
}

View File

@ -1,9 +1,9 @@
/*
* 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/>.
*/
* 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 midi.h Declarations for MIDI data */

View File

@ -1,9 +1,9 @@
/*
* 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/>.
*/
* 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 midifile.cpp Parser for standard MIDI files */

View File

@ -1,9 +1,9 @@
/*
* 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/>.
*/
* 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 midifile.hpp Parser for standard MIDI files */

View File

@ -171,9 +171,9 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::CloseConnection(NetworkRecvSta
this->SendPackets(true);
/* Wait a number of ticks so our leave message can reach the server.
* This is especially needed for Windows servers as they seem to get
* the "socket is closed" message before receiving our leave message,
* which would trigger the server to close the connection as well. */
* This is especially needed for Windows servers as they seem to get
* the "socket is closed" message before receiving our leave message,
* which would trigger the server to close the connection as well. */
CSleep(3 * MILLISECONDS_PER_TICK);
}

View File

@ -219,7 +219,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentType type)
p->Send_string("patchpack"); // Or what-ever the name of your patchpack is.
p->Send_string(_openttd_content_version_patchpack);
*/
*/
this->SendPacket(p);
}

View File

@ -3591,12 +3591,12 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop,
it.ti.y = (int8_t)GB(it.ti.y, 0, 8);
/* When there were only 256x256 maps, TileIndex was a uint16_t and
* it.ti was just a TileIndexDiff that was added to it.
* As such negative "x" values were shifted into the "y" position.
* x = -1, y = 1 -> x = 255, y = 0
* Since GRF version 8 the position is interpreted as pair of independent int8.
* For GRF version < 8 we need to emulate the old shifting behaviour.
*/
* it.ti was just a TileIndexDiff that was added to it.
* As such negative "x" values were shifted into the "y" position.
* x = -1, y = 1 -> x = 255, y = 0
* Since GRF version 8 the position is interpreted as pair of independent int8.
* For GRF version < 8 we need to emulate the old shifting behaviour.
*/
if (_cur.grffile->grf_version < 8 && it.ti.x < 0) it.ti.y += 1;
}
}
@ -9348,8 +9348,8 @@ static void FinaliseIndustriesArray()
StringID strid;
/* process the conversion of text at the end, so to be sure everything will be fine
* and available. Check if it does not return undefind marker, which is a very good sign of a
* substitute industry who has not changed the string been examined, thus using it as such */
* and available. Check if it does not return undefind marker, which is a very good sign of a
* substitute industry who has not changed the string been examined, thus using it as such */
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->name);
if (strid != STR_UNDEFINED) indsp->name = strid;
@ -9367,7 +9367,7 @@ static void FinaliseIndustriesArray()
if (indsp->station_name != STR_NULL) {
/* STR_NULL (0) can be set by grf. It has a meaning regarding assignation of the
* station's name. Don't want to lose the value, therefore, do not process. */
* station's name. Don't want to lose the value, therefore, do not process. */
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->station_name);
if (strid != STR_UNDEFINED) indsp->station_name = strid;
}

View File

@ -294,7 +294,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec,
}
}
} else {
/* Drive-in stop */
/* Bay stop */
if ((spec->draw_mode & ROADSTOP_DRAW_MODE_ROAD) && rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_ROADSTOP);
DrawSprite(ground + view, PAL_NONE, x, y);

View File

@ -21,12 +21,12 @@ struct RoadTypeScopeResolver : public ScopeResolver {
const RoadTypeInfo *rti;
/**
* Constructor of the roadtype scope resolvers.
* @param ro Surrounding resolver.
* @param rti Associated RoadTypeInfo.
* @param tile %Tile containing the track. For track on a bridge this is the southern bridgehead.
* @param context Are we resolving sprites for the upper halftile, or on a bridge?
*/
* Constructor of the roadtype scope resolvers.
* @param ro Surrounding resolver.
* @param rti Associated RoadTypeInfo.
* @param tile %Tile containing the track. For track on a bridge this is the southern bridgehead.
* @param context Are we resolving sprites for the upper halftile, or on a bridge?
*/
RoadTypeScopeResolver(ResolverObject &ro, const RoadTypeInfo *rti, TileIndex tile, TileContext context)
: ScopeResolver(ro), tile(tile), context(context), rti(rti)
{

View File

@ -79,8 +79,8 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
if (!font_style.empty() && !StrEqualsIgnoreCase(font_style, (char *)style)) continue;
/* Font config takes the best shot, which, if the family name is spelled
* wrongly a 'random' font, so check whether the family name is the
* same as the supplied name */
* wrongly a 'random' font, so check whether the family name is the
* same as the supplied name */
if (StrEqualsIgnoreCase(font_family, (char *)family)) {
err = FT_New_Face(_library, (char *)file, index, face);
}

View File

@ -28,21 +28,21 @@ public:
static const bool SUPPORTS_RTL = true;
/**
* Get the actual ParagraphLayout for the given buffer.
* @param buff The begin of the buffer.
* @param buff_end The location after the last element in the buffer.
* @param fontMapping THe mapping of the fonts.
* @return The ParagraphLayout instance.
*/
* Get the actual ParagraphLayout for the given buffer.
* @param buff The begin of the buffer.
* @param buff_end The location after the last element in the buffer.
* @param fontMapping THe mapping of the fonts.
* @return The ParagraphLayout instance.
*/
static ParagraphLayouter *GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping);
/**
* Append a wide character to the internal buffer.
* @param buff The buffer to append to.
* @param buffer_last The end of the buffer.
* @param c The character to add.
* @return The number of buffer spaces that were used.
*/
* Append a wide character to the internal buffer.
* @param buff The buffer to append to.
* @param buffer_last The end of the buffer.
* @param c The character to add.
* @return The number of buffer spaces that were used.
*/
static size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, char32_t c)
{
assert(buff < buffer_last);

View File

@ -64,7 +64,7 @@ enum RoadTypeSpriteGroup {
ROTSG_reserved2, ///< Placeholder, if we need specific level crossing sprites.
ROTSG_DEPOT, ///< Optional: Depot images
ROTSG_reserved3, ///< Placeholder, if we add road fences (for highways).
ROTSG_ROADSTOP, ///< Required: Drive-in stop surface
ROTSG_ROADSTOP, ///< Required: Bay stop surface
ROTSG_ONEWAY, ///< Optional: One-way indicator images
ROTSG_END,
};

View File

@ -31,7 +31,7 @@
* If changing the call paths into the scripting engine, define this symbol to enable full debugging of allocations.
* This lets you track whether the allocator context is being switched correctly in all call paths.
#define SCRIPT_DEBUG_ALLOCATIONS
*/
*/
struct ScriptAllocator {
size_t allocated_size; ///< Sum of allocated data size

View File

@ -413,7 +413,7 @@ size_t OneOfManySettingDesc::ParseValue(const char *str) const
{
size_t r = OneOfManySettingDesc::ParseSingleValue(str, strlen(str), this->many);
/* if the first attempt of conversion from string to the appropriate value fails,
* look if we have defined a converter from old value to new value. */
* look if we have defined a converter from old value to new value. */
if (r == (size_t)-1 && this->many_cnvt != nullptr) r = this->many_cnvt(str);
if (r != (size_t)-1) return r; // and here goes converted value

View File

@ -46,6 +46,8 @@
#include "vehicle_func.h"
#include "viewport_func.h"
#include "void_map.h"
#include "station_func.h"
#include "station_base.h"
#include "table/strings.h"
#include "table/settings.h"

File diff suppressed because it is too large Load Diff

View File

@ -10,15 +10,10 @@
#ifndef SMALLMAP_GUI_H
#define SMALLMAP_GUI_H
#include "industry_type.h"
#include "company_base.h"
#include "window_gui.h"
#include "strings_func.h"
#include "blitter/factory.hpp"
#include "linkgraph/linkgraph_gui.h"
#include "widgets/smallmap_widget.h"
#include "timer/timer.h"
#include "timer/timer_window.h"
#include "core/geometry_type.hpp"
#include "station_type.h"
#include "tile_type.h"
#include "window_type.h"
/* set up the cargos to be displayed in the smallmap's route legend */
void BuildLinkStatsLegend();
@ -37,179 +32,6 @@ enum class IncludeHeightmap {
uint32_t GetSmallMapOwnerPixels(TileIndex tile, TileType t, IncludeHeightmap include_heightmap);
/** Structure for holding relevant data for legends in small map */
struct LegendAndColour {
uint8_t colour; ///< Colour of the item on the map.
StringID legend; ///< String corresponding to the coloured item.
IndustryType type; ///< Type of industry. Only valid for industry entries.
uint8_t height; ///< Height in tiles. Only valid for height legend entries.
CompanyID company; ///< Company to display. Only valid for company entries of the owner legend.
bool show_on_map; ///< For filtering industries, if \c true, industry is shown on the map in colour.
bool end; ///< This is the end of the list.
bool col_break; ///< Perform a column break and go further at the next column.
};
/** Class managing the smallmap window. */
class SmallMapWindow : public Window {
protected:
/** Types of legends in the #WID_SM_LEGEND widget. */
enum SmallMapType {
SMT_CONTOUR,
SMT_VEHICLES,
SMT_INDUSTRY,
SMT_LINKSTATS,
SMT_ROUTES,
SMT_VEGETATION,
SMT_OWNER,
};
/** Available kinds of zoomlevel changes. */
enum ZoomLevelChange {
ZLC_INITIALIZE, ///< Initialize zoom level.
ZLC_ZOOM_OUT, ///< Zoom out.
ZLC_ZOOM_IN, ///< Zoom in.
};
static SmallMapType map_type; ///< Currently displayed legends.
static bool show_towns; ///< Display town names in the smallmap.
static int map_height_limit; ///< Currently used/cached map height limit.
static const uint INDUSTRY_MIN_NUMBER_OF_COLUMNS = 2; ///< Minimal number of columns in the #WID_SM_LEGEND widget for the #SMT_INDUSTRY legend.
uint min_number_of_columns; ///< Minimal number of columns in legends.
uint min_number_of_fixed_rows; ///< Minimal number of rows in the legends for the fixed layouts only (all except #SMT_INDUSTRY).
uint column_width; ///< Width of a column in the #WID_SM_LEGEND widget.
uint legend_width; ///< Width of legend 'blob'.
int32_t scroll_x; ///< Horizontal world coordinate of the base tile left of the top-left corner of the smallmap display.
int32_t scroll_y; ///< Vertical world coordinate of the base tile left of the top-left corner of the smallmap display.
int32_t subscroll; ///< Number of pixels (0..3) between the right end of the base tile and the pixel at the top-left corner of the smallmap display.
int zoom; ///< Zoom level. Bigger number means more zoom-out (further away).
LinkGraphOverlay *overlay;
static void BreakIndustryChainLink();
Point SmallmapRemapCoords(int x, int y) const;
/**
* Draws vertical part of map indicator
* @param x X coord of left/right border of main viewport
* @param y Y coord of top border of main viewport
* @param y2 Y coord of bottom border of main viewport
*/
static inline void DrawVertMapIndicator(int x, int y, int y2)
{
GfxFillRect(x, y, x, y + 3, PC_VERY_LIGHT_YELLOW);
GfxFillRect(x, y2 - 3, x, y2, PC_VERY_LIGHT_YELLOW);
}
/**
* Draws horizontal part of map indicator
* @param x X coord of left border of main viewport
* @param x2 X coord of right border of main viewport
* @param y Y coord of top/bottom border of main viewport
*/
static inline void DrawHorizMapIndicator(int x, int x2, int y)
{
GfxFillRect(x, y, x + 3, y, PC_VERY_LIGHT_YELLOW);
GfxFillRect(x2 - 3, y, x2, y, PC_VERY_LIGHT_YELLOW);
}
/**
* Compute minimal required width of the legends.
* @return Minimally needed width for displaying the smallmap legends in pixels.
*/
inline uint GetMinLegendWidth() const
{
return WidgetDimensions::scaled.framerect.left + this->min_number_of_columns * this->column_width;
}
/**
* Return number of columns that can be displayed in \a width pixels.
* @return Number of columns to display.
*/
inline uint GetNumberColumnsLegend(uint width) const
{
return width / this->column_width;
}
/**
* Compute height given a number of columns.
* @param num_columns Number of columns.
* @return Needed height for displaying the smallmap legends in pixels.
*/
inline uint GetLegendHeight(uint num_columns) const
{
return WidgetDimensions::scaled.framerect.Vertical() +
this->GetNumberRowsLegend(num_columns) * FONT_HEIGHT_SMALL;
}
/**
* Get a bitmask for company links to be displayed. Usually this will be
* the _local_company. Spectators get to see all companies' links.
* @return Company mask.
*/
inline CompanyMask GetOverlayCompanyMask() const
{
return Company::IsValidID(_local_company) ? 1U << _local_company : MAX_UVALUE(CompanyMask);
}
/** Blink the industries (if selected) on a regular interval. */
IntervalTimer<TimerWindow> blink_interval = {std::chrono::milliseconds(450), [this](auto) {
Blink();
}};
/** Update the whole map on a regular interval. */
IntervalTimer<TimerWindow> refresh_interval = {std::chrono::milliseconds(930), [this](auto) {
ForceRefresh();
}};
void RebuildColourIndexIfNecessary();
uint GetNumberRowsLegend(uint columns) const;
void SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item = 0);
void SwitchMapType(SmallMapType map_type);
void SetNewScroll(int sx, int sy, int sub);
void DrawMapIndicators() const;
void DrawSmallMapColumn(void *dst, uint xc, uint yc, int pitch, int reps, int start_pos, int end_pos, Blitter *blitter) const;
void DrawVehicles(const DrawPixelInfo *dpi, Blitter *blitter) const;
void DrawTowns(const DrawPixelInfo *dpi) const;
void DrawSmallMap(DrawPixelInfo *dpi) const;
Point RemapTile(int tile_x, int tile_y) const;
Point PixelToTile(int px, int py, int *sub, bool add_sub = true) const;
Point ComputeScroll(int tx, int ty, int x, int y, int *sub);
void SetZoomLevel(ZoomLevelChange change, const Point *zoom_pt);
void SetOverlayCargoMask();
void SetupWidgetData();
uint32_t GetTileColours(const TileArea &ta) const;
int GetPositionOnLegend(Point pt);
void UpdateLinks();
void Blink();
void ForceRefresh();
public:
friend class NWidgetSmallmapDisplay;
SmallMapWindow(WindowDesc *desc, int window_number);
virtual ~SmallMapWindow();
void SmallMapCenterOnCurrentPos();
Point GetStationMiddle(const Station *st) const;
void Close([[maybe_unused]] int data = 0) override;
void SetStringParameters(int widget) const override;
void OnInit() override;
void OnPaint() override;
void DrawWidget(const Rect &r, int widget) const override;
void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override;
void OnInvalidateData(int data = 0, bool gui_scope = true) override;
bool OnRightClick(Point pt, int widget) override;
void OnMouseWheel(int wheel) override;
void OnScroll(Point delta) override;
void OnMouseOver([[maybe_unused]] Point pt, int widget) override;
};
Point GetSmallMapStationMiddle(const Window *w, const Station *st);
#endif /* SMALLMAP_GUI_H */

View File

@ -41,9 +41,9 @@ typedef HRESULT(__stdcall *API_XAudio2Create)(_Outptr_ IXAudio2** ppXAudio2, UIN
static FSoundDriver_XAudio2 iFSoundDriver_XAudio2;
/**
* Implementation of the IXAudio2VoiceCallback interface.
* Provides buffered audio to XAudio2 from the OpenTTD mixer.
*/
* Implementation of the IXAudio2VoiceCallback interface.
* Provides buffered audio to XAudio2 from the OpenTTD mixer.
*/
class StreamingVoiceContext : public IXAudio2VoiceCallback
{
private:
@ -132,12 +132,12 @@ static HRESULT CreateXAudio(API_XAudio2Create xAudio2Create)
}
/**
* Initialises the XAudio2 driver.
*
* @param parm Driver parameters.
* @return An error message if unsuccessful, or nullptr otherwise.
*
*/
* Initialises the XAudio2 driver.
*
* @param parm Driver parameters.
* @return An error message if unsuccessful, or nullptr otherwise.
*
*/
const char *SoundDriver_XAudio2::Start(const StringList &parm)
{
HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
@ -261,8 +261,8 @@ const char *SoundDriver_XAudio2::Start(const StringList &parm)
}
/**
* Terminates the XAudio2 driver.
*/
* Terminates the XAudio2 driver.
*/
void SoundDriver_XAudio2::Stop()
{
// Clean up XAudio2

View File

@ -3246,7 +3246,7 @@ void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, Ro
DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y);
}
} else {
/* Drive-in stop */
/* Bay stop */
if (RoadTypeIsRoad(roadtype) && roadtype_info->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(roadtype_info, INVALID_TILE, ROTSG_ROADSTOP);
DrawSprite(ground + image, PAL_NONE, x, y);

View File

@ -279,7 +279,7 @@ struct TerraformToolbarWindow : Window {
case DDSP_BUILD_OBJECT:
if (!_settings_game.construction.freeform_edges) {
/* When end_tile is MP_VOID, the error tile will not be visible to the
* user. This happens when terraforming at the southern border. */
* user. This happens when terraforming at the southern border. */
if (TileX(end_tile) == Map::MaxX()) end_tile += TileDiffXY(-1, 0);
if (TileY(end_tile) == Map::MaxY()) end_tile += TileDiffXY(0, -1);
}

View File

@ -51,7 +51,7 @@ static std::optional<std::string> TestScriptAdminMakeJSON(std::string_view squir
{
auto vm = sq_open(1024);
/* sq_compile creates a closure with our snipper, which is a table.
* Add "return " to get the table on the stack. */
* Add "return " to get the table on the stack. */
std::string buffer = fmt::format("return {}", squirrel);
/* Insert an (empty) class for testing. */

View File

@ -106,10 +106,10 @@ public:
static void SetDate(Date date, DateFract fract);
/**
* Calculate the year of a given date.
* @param date The date to consider.
* @return the year.
*/
* Calculate the year of a given date.
* @param date The date to consider.
* @return the year.
*/
static constexpr Year DateToYear(Date date)
{
/* Hardcode the number of days in a year because we can't access CalendarTime from here. */
@ -117,10 +117,10 @@ public:
}
/**
* Calculate the date of the first day of a given year.
* @param year the year to get the first day of.
* @return the date.
*/
* Calculate the date of the first day of a given year.
* @param year the year to get the first day of.
* @return the date.
*/
static constexpr Date DateAtStartOfYear(Year year)
{
int32_t year_as_int = static_cast<int32_t>(year);

View File

@ -1609,7 +1609,7 @@ void Vehicle::UpdatePosition()
/**
* Update the bounding box co-ordinates of the vehicle
* @param update_cache Update the cached values for previous co-ordinate values
*/
*/
void Vehicle::UpdateBoundingBoxCoordinates(bool update_cache) const
{
Rect new_coord;

View File

@ -336,7 +336,7 @@ void VideoDriver_Cocoa::GameSizeChanged()
::GameSizeChanged();
/* We need to store the window size as non-Retina size in
* the config file to get same windows size on next start. */
* the config file to get same windows size on next start. */
_cur_resolution.width = [ this->cocoaview frame ].size.width;
_cur_resolution.height = [ this->cocoaview frame ].size.height;
}

View File

@ -1391,8 +1391,8 @@ static void ViewportAddKdtreeSigns(DrawPixelInfo *dpi)
const Sign *si = Sign::Get(item.id.sign);
/* Don't draw if sign is owned by another company and competitor signs should be hidden.
* Note: It is intentional that also signs owned by OWNER_NONE are hidden. Bankrupt
* companies can leave OWNER_NONE signs after them. */
* Note: It is intentional that also signs owned by OWNER_NONE are hidden. Bankrupt
* companies can leave OWNER_NONE signs after them. */
if (!show_competitors && _local_company != si->owner && si->owner != OWNER_DEITY) break;
signs.push_back(si);

View File

@ -1,9 +1,9 @@
/*
* 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/>.
*/
* 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 town_kdtree.h Declarations for accessing the k-d tree of towns */