Merge branch 'master' into jgrpp

# Conflicts:
#	src/bridge_map.h
#	src/crashlog.cpp
#	src/industry.h
#	src/linkgraph/linkgraph_type.h
#	src/order_type.h
#	src/saveload/afterload.cpp
#	src/settings.cpp
#	src/settings_type.h
#	src/smallmap_gui.cpp
#	src/spritecache.cpp
#	src/stdafx.h
#	src/table/settings.h.preamble
#	src/train.h
#	src/vehicle.cpp
#	src/viewport.cpp
#	src/viewport_func.h
#	src/widgets/station_widget.h
#	src/zoom_func.h
#	src/zoom_type.h
pull/104/head
Jonathan G Rennison 5 years ago
commit 36eb4165b8

@ -54,7 +54,7 @@
}
config->AnchorUnchangeableSettings();
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
Company *c = Company::Get(company);
c->ai_info = info;
@ -78,7 +78,7 @@
assert(_settings_game.difficulty.competitor_speed <= 4);
if ((AI::frame_counter & ((1 << (4 - _settings_game.difficulty.competitor_speed)) - 1)) != 0) return;
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
const Company *c;
FOR_ALL_COMPANIES(c) {
if (c->is_ai) {
@ -110,7 +110,7 @@
if (_networking && !_network_server) return;
PerformanceMeasurer::SetInactive((PerformanceElement)(PFE_AI0 + company));
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
Company *c = Company::Get(company);
delete c->ai_instance;
@ -130,7 +130,7 @@
* for the server owner to unpause the script again. */
if (_network_dedicated) return;
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
Company::Get(company)->ai_instance->Pause();
cur_company.Restore();
@ -138,7 +138,7 @@
/* static */ void AI::Unpause(CompanyID company)
{
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
Company::Get(company)->ai_instance->Unpause();
cur_company.Restore();
@ -146,7 +146,7 @@
/* static */ bool AI::IsPaused(CompanyID company)
{
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
bool paused = Company::Get(company)->ai_instance->IsPaused();
cur_company.Restore();
@ -256,7 +256,7 @@
}
/* Queue the event */
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
Company::Get(_current_company)->ai_instance->InsertEvent(event);
cur_company.Restore();
@ -288,7 +288,7 @@
Company *c = Company::GetIfValid(company);
assert(c != nullptr && c->ai_instance != nullptr);
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
c->ai_instance->Save();
cur_company.Restore();
} else {
@ -302,7 +302,7 @@
Company *c = Company::GetIfValid(company);
assert(c != nullptr && c->ai_instance != nullptr);
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
c->ai_instance->Load(version);
cur_company.Restore();
} else {

@ -810,7 +810,7 @@ struct AIConfigWindow : public Window {
if (_game_mode != GM_NORMAL) {
return slot > 0 && slot <= GetGameSettings().difficulty.max_no_competitors;
}
if (Company::IsValidID(slot) || slot < 0) return false;
if (Company::IsValidID(slot)) return false;
int max_slot = GetGameSettings().difficulty.max_no_competitors;
for (CompanyID cid = COMPANY_FIRST; cid < (CompanyID)max_slot && cid < MAX_COMPANIES; cid++) {

@ -80,7 +80,7 @@ struct Aircraft FINAL : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
byte previous_pos; ///< Previous desired position of the aircraft.
StationID targetairport; ///< Airport to go to next.
byte state; ///< State of the airport. @see AirportMovementStates
DirectionByte last_direction;
Direction last_direction;
byte number_consecutive_turns; ///< Protection to prevent the aircraft of making a lot of turns in order to reach a specific point.
byte turn_counter; ///< Ticks between each turn to prevent > 45 degree turns.
byte flags; ///< Aircraft flags. @see AirVehicleFlags

@ -1294,7 +1294,7 @@ void HandleMissingAircraftOrders(Aircraft *v)
*/
const Station *st = GetTargetAirportIfValid(v);
if (st == nullptr) {
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
CommandCost ret = DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
cur_company.Restore();
@ -1663,7 +1663,7 @@ static void AircraftEventHandler_HeliTakeOff(Aircraft *v, const AirportFTAClass
/* Send the helicopter to a hangar if needed for replacement */
if (v->NeedsAutomaticServicing()) {
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
DoCommand(v->tile, v->index | DEPOT_SERVICE | DEPOT_LOCATE_HANGAR, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
cur_company.Restore();
}
@ -1714,7 +1714,7 @@ static void AircraftEventHandler_Landing(Aircraft *v, const AirportFTAClass *apc
/* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed */
if (v->NeedsAutomaticServicing()) {
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
DoCommand(v->tile, v->index | DEPOT_SERVICE, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
cur_company.Restore();
}

@ -130,10 +130,10 @@ static const uint64
/** A single location on an airport where aircraft can move to. */
struct AirportMovingData {
int16 x; ///< x-coordinate of the destination.
int16 y; ///< y-coordinate of the destination.
uint16 flag; ///< special flags when moving towards the destination.
DirectionByte direction; ///< Direction to turn the aircraft after reaching the destination.
int16 x; ///< x-coordinate of the destination.
int16 y; ///< y-coordinate of the destination.
uint16 flag; ///< special flags when moving towards the destination.
Direction direction; ///< Direction to turn the aircraft after reaching the destination.
};
AirportMovingData RotateAirportMovingData(const AirportMovingData *orig, Direction rotation, uint num_tiles_x, uint num_tiles_y);

@ -79,6 +79,7 @@ struct BuildAirToolbarWindow : Window {
~BuildAirToolbarWindow()
{
if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true);
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
}
@ -143,6 +144,8 @@ struct BuildAirToolbarWindow : Window {
void OnPlaceObjectAbort() override
{
if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true);
this->RaiseButtons();
DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR);

@ -64,8 +64,8 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
std::unique_ptr<const char, FreeDeleter> cached_name; ///< NOSAVE: Cache of the resolved name of the station, if not using a custom name
Town *town; ///< The town this station is associated with
OwnerByte owner; ///< The owner of this station
StationFacilityByte facilities; ///< The facilities that this station has
Owner owner; ///< The owner of this station
StationFacility facilities; ///< The facilities that this station has
uint8 num_specs; ///< Number of specs in the speclist
StationSpecList *speclist; ///< List of station specs of this station

@ -123,10 +123,9 @@ static inline void SetBridgeMiddle(TileIndex t, Axis a)
* @param bridgetype the type of bridge this bridge ramp belongs to
* @param d the direction this ramp must be facing
* @param tt the transport type of the bridge
* @param rt the road or rail type
* @note this function should not be called directly.
*/
static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt, uint rt)
static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt)
{
SetTileType(t, MP_TUNNELBRIDGE);
SetTileOwner(t, o);
@ -136,7 +135,7 @@ static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, D
_m[t].m5 = 1 << 7 | tt << 2 | d;
SB(_me[t].m6, 2, 4, bridgetype);
_me[t].m7 = 0;
_me[t].m8 = rt;
_me[t].m8 = 0;
}
/**
@ -147,18 +146,18 @@ static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, D
* @param owner_tram the new owner of the tram on the bridge
* @param bridgetype the type of bridge this bridge ramp belongs to
* @param d the direction this ramp must be facing
* @param r the road type of the bridge
* @param rts the road types of the bridge
* @param upgrade whether the bridge is an upgrade instead of a totally new bridge
*/
static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadTypes r, bool upgrade)
static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadTypes rts, bool upgrade)
{
// Backup custom bridgehead data.
uint custom_bridge_head_backup = GB(_m[t].m2, 0, 8);
MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD, 0);
MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD);
SetRoadOwner(t, ROADTYPE_ROAD, owner_road);
if (owner_tram != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, owner_tram);
SetRoadTypes(t, r);
SetRoadTypes(t, rts);
// Restore custom bridgehead data if we're upgrading an existing bridge.
if (upgrade) SB(_m[t].m2, 0, 8, custom_bridge_head_backup);
@ -170,10 +169,10 @@ static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, Owner owner_road, Ow
* @param o the new owner of the bridge ramp
* @param bridgetype the type of bridge this bridge ramp belongs to
* @param d the direction this ramp must be facing
* @param r the rail type of the bridge
* @param rt the rail type of the bridge
* @param upgrade whether the bridge is an upgrade instead of a totally new bridge
*/
static inline void MakeRailBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RailType r, bool upgrade)
static inline void MakeRailBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RailType rt, bool upgrade)
{
/* Backup bridge signal and custom bridgehead data. */
auto m2_backup = _m[t].m2;
@ -182,7 +181,8 @@ static inline void MakeRailBridgeRamp(TileIndex t, Owner o, BridgeType bridgetyp
auto m6_backup = _me[t].m6;
auto m8_backup = _me[t].m8;
MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_RAIL, r);
MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_RAIL);
_me[t].m8 = rt;
if (upgrade) {
/* Restore bridge signal and custom bridgehead data if we're upgrading an existing bridge. */
@ -206,7 +206,7 @@ static inline void MakeRailBridgeRamp(TileIndex t, Owner o, BridgeType bridgetyp
*/
static inline void MakeAqueductBridgeRamp(TileIndex t, Owner o, DiagDirection d)
{
MakeBridgeRamp(t, o, 0, d, TRANSPORT_WATER, 0);
MakeBridgeRamp(t, o, 0, d, TRANSPORT_WATER);
}
/**

@ -1015,8 +1015,8 @@ void DisplayVehicleSortDropDown(Window *w, VehicleType vehicle_type, int selecte
struct BuildVehicleWindow : Window {
VehicleType vehicle_type; ///< Type of vehicles shown in the window.
union {
RailTypeByte railtype; ///< Rail type to show, or #RAILTYPE_END.
RoadTypes roadtypes; ///< Road type to show, or #ROADTYPES_ALL.
RailType railtype; ///< Rail type to show, or #RAILTYPE_END.
RoadTypes roadtypes; ///< Road type to show, or #ROADTYPES_ALL.
} filter; ///< Filter to apply.
bool descending_sort_order; ///< Sort direction, @see _engine_sort_direction
byte sort_criteria; ///< Current sort criterium.

@ -145,12 +145,11 @@ public:
/** Types of cargo source and destination */
enum SourceType {
enum SourceType : byte {
ST_INDUSTRY, ///< Source/destination is an industry
ST_TOWN, ///< Source/destination is a town
ST_HEADQUARTERS, ///< Source/destination are company headquarters
};
typedef SimpleTinyEnumT<SourceType, byte> SourceTypeByte; ///< The SourceType packed into a byte for savegame purposes.
typedef uint16 SourceID; ///< Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
static const SourceID INVALID_SOURCE = 0xFFFF; ///< Invalid/unknown index of source

@ -249,7 +249,7 @@ void CargoPacket::PayDeferredPayments()
{
if (this->flags & CPF_HAS_DEFERRED_PAYMENT) {
IterateCargoPacketDeferredPayments(this->index, true, [&](Money &payment, CompanyID cid, VehicleType type) {
Backup<CompanyByte> cur_company(_current_company, cid, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, cid, FILE_LINE);
ExpensesType exp;
switch (type) {

@ -47,13 +47,13 @@ void ChangeOwnershipOfCargoPacketDeferredPayments(Owner old_owner, Owner new_own
*/
struct CargoPacket : CargoPacketPool::PoolItem<&_cargopacket_pool> {
private:
Money feeder_share; ///< Value of feeder pickup to be paid for on delivery of cargo.
uint16 count; ///< The amount of cargo in this packet.
byte days_in_transit; ///< Amount of days this packet has been in transit.
SourceTypeByte source_type; ///< Type of \c source_id.
SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid.
StationID source; ///< The station where the cargo came from first.
TileIndex source_xy; ///< The origin of the cargo (first station in feeder chain).
Money feeder_share; ///< Value of feeder pickup to be paid for on delivery of cargo.
uint16 count; ///< The amount of cargo in this packet.
byte days_in_transit; ///< Amount of days this packet has been in transit.
SourceType source_type; ///< Type of \c source_id.
SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid.
StationID source; ///< The station where the cargo came from first.
TileIndex source_xy; ///< The origin of the cargo (first station in feeder chain).
union {
TileOrStationID loaded_at_xy; ///< Location where this cargo has been loaded into the vehicle.
TileOrStationID next_station; ///< Station where the cargo wants to go next.

@ -482,7 +482,7 @@ static const Command _command_proc_table[] = {
/**
* List of flags for a command log entry
*/
enum CommandLogEntryFlagEnum {
enum CommandLogEntryFlag : byte {
CLEF_NONE = 0x00, ///< no flag is set
CLEF_CMD_FAILED = 0x01, ///< command failed
CLEF_GENERATING_WORLD = 0x02, ///< generating world
@ -493,8 +493,7 @@ enum CommandLogEntryFlagEnum {
CLEF_BINARY = 0x40, ///< binary_length is > 0
CLEF_SCRIPT = 0x80, ///< command run by AI/game script
};
DECLARE_ENUM_AS_BIT_SET(CommandLogEntryFlagEnum)
typedef SimpleTinyEnumT<CommandLogEntryFlagEnum, byte> CommandLogEntryFlag;
DECLARE_ENUM_AS_BIT_SET(CommandLogEntryFlag)
struct CommandLogEntry {
TileIndex tile;
@ -504,8 +503,8 @@ struct CommandLogEntry {
Date date;
DateFract date_fract;
uint8 tick_skip_counter;
CompanyByte current_company;
CompanyByte local_company;
CompanyID current_company;
CompanyID local_company;
CommandLogEntryFlag log_flags;
CommandLogEntry() { }
@ -544,7 +543,7 @@ char *DumpCommandLog(char *buffer, const char *last)
}
const CommandLogEntry &entry = command_log[log_index];
auto fc = [&](CommandLogEntryFlagEnum flag, char c) -> char {
auto fc = [&](CommandLogEntryFlag flag, char c) -> char {
return entry.log_flags & flag ? c : '-';
};
@ -917,7 +916,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
return_dcpi(CMD_ERROR);
}
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
if (exec_as_spectator) cur_company.Change(COMPANY_SPECTATOR);
bool test_and_exec_can_differ = (cmd_flags & CMD_NO_TEST) != 0;

@ -74,7 +74,7 @@ struct CompanyProperties {
TileIndex location_of_HQ; ///< Northern tile of HQ; #INVALID_TILE when there is none.
TileIndex last_build_coordinate; ///< Coordinate of the last build thing by this company.
OwnerByte share_owners[4]; ///< Owners of the 4 shares of the company. #INVALID_OWNER if nobody has bought them yet.
Owner share_owners[4]; ///< Owners of the 4 shares of the company. #INVALID_OWNER if nobody has bought them yet.
Year inaugurated_year; ///< Year of starting the company.

@ -44,8 +44,8 @@
void ClearEnginesHiddenFlagOfCompany(CompanyID cid);
CompanyByte _local_company; ///< Company controlled by the human player at this client. Can also be #COMPANY_SPECTATOR.
CompanyByte _current_company; ///< Company currently doing an action.
CompanyID _local_company; ///< Company controlled by the human player at this client. Can also be #COMPANY_SPECTATOR.
CompanyID _current_company; ///< Company currently doing an action.
Colours _company_colours[MAX_COMPANIES]; ///< NOSAVE: can be determined from company structs.
CompanyManagerFace _company_manager_face; ///< for company manager face storage in openttd.cfg
uint _next_competitor_start; ///< the number of ticks before the next AI is started

@ -32,8 +32,8 @@ void SubtractMoneyFromCompanyFract(CompanyID company, CommandCost cost);
CommandCost CheckOwnership(Owner owner, TileIndex tile = 0);
CommandCost CheckTileOwnership(TileIndex tile);
extern CompanyByte _local_company;
extern CompanyByte _current_company;
extern CompanyID _local_company;
extern CompanyID _current_company;
extern Colours _company_colours[MAX_COMPANIES];
extern CompanyManagerFace _company_manager_face;

@ -2630,7 +2630,7 @@ struct CompanyWindow : Window
MarkWholeScreenDirty();
} else if (NetworkCompanyIsPassworded(company)) {
/* ask for the password */
ShowQueryString(STR_EMPTY, STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION, NETWORK_PASSWORD_LENGTH, this, CS_ALPHANUMERAL, QSF_NONE);
ShowQueryString(STR_EMPTY, STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION, NETWORK_PASSWORD_LENGTH, this, CS_ALPHANUMERAL, QSF_PASSWORD);
} else {
/* just send the join command */
NetworkClientRequestMove(company);

@ -17,7 +17,7 @@
/**
* Enum for all companies/owners.
*/
enum Owner {
enum Owner : byte {
/* All companies below MAX_COMPANIES are playable
* companies, above, they are special, computer controlled 'companies' */
OWNER_BEGIN = 0x00, ///< First owner
@ -45,10 +45,8 @@ static const uint MAX_HISTORY_QUARTERS = 24; ///< The maximum number
/** Define basic enum properties */
template <> struct EnumPropsT<Owner> : MakeEnumPropsT<Owner, byte, OWNER_BEGIN, OWNER_END, INVALID_OWNER> {};
typedef TinyEnumT<Owner> OwnerByte;
typedef Owner CompanyID;
typedef OwnerByte CompanyByte;
typedef uint16 CompanyMask;

@ -914,8 +914,7 @@ DEF_CONSOLE_CMD(ConNetworkReconnect)
default:
/* From a user pov 0 is a new company, internally it's different and all
* companies are offset by one to ease up on users (eg companies 1-8 not 0-7) */
playas--;
if (playas < COMPANY_FIRST || playas >= MAX_COMPANIES) return false;
if (playas < COMPANY_FIRST + 1 || playas > MAX_COMPANIES + 1) return false;
break;
}

@ -46,8 +46,6 @@
* we will create specialization derived from MakeEnumPropsT<>.
* i.e.:
* template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {};
* followed by:
* typedef TinyEnumT<Track> TrackByte;
*/
template <typename Tenum_t> struct EnumPropsT;
@ -72,106 +70,4 @@ struct MakeEnumPropsT {
static const uint num_bits = Tnum_bits; ///< Number of bits for storing the enum in command parameters
};
/**
* In some cases we use byte or uint16 to store values that are defined as enum. It is
* necessary in order to control the sizeof() such values. Some compilers make enum
* the same size as int (4 or 8 bytes instead of 1 or 2). As a consequence the strict
* compiler type - checking causes errors like:
* 'HasPowerOnRail' : cannot convert parameter 1 from 'byte' to 'RailType' when
* u->u.rail.railtype is passed as argument or type RailType. In such cases it is better
* to teach the compiler that u->u.rail.railtype is to be treated as RailType.
*/
template <typename Tenum_t> struct TinyEnumT;
/** The general declaration of TinyEnumT<> (above) */
template <typename Tenum_t>
struct TinyEnumT {
typedef Tenum_t enum_type; ///< expose our enumeration type (i.e. Trackdir) to outside
typedef EnumPropsT<Tenum_t> Props; ///< make easier access to our enumeration properties
typedef typename Props::storage storage_type; ///< small storage type
static const enum_type begin = Props::begin; ///< enum beginning (i.e. TRACKDIR_BEGIN)
static const enum_type end = Props::end; ///< enum end (i.e. TRACKDIR_END)
static const enum_type invalid = Props::invalid;///< invalid value (i.e. INVALID_TRACKDIR)
storage_type m_val; ///< here we hold the actual value in small (i.e. byte) form
/** Cast operator - invoked then the value is assigned to the Tenum_t type */
inline operator enum_type () const
{
return (enum_type)m_val;
}
/** Assignment operator (from Tenum_t type) */
inline TinyEnumT& operator = (enum_type e)
{
m_val = (storage_type)e;
return *this;
}
/** Assignment operator (from Tenum_t type) */
inline TinyEnumT& operator = (uint u)
{
m_val = (storage_type)u;
return *this;
}
/** postfix ++ operator on tiny type */
inline TinyEnumT operator ++ (int)
{
TinyEnumT org = *this;
if (++m_val >= end) m_val -= (storage_type)(end - begin);
return org;
}
/** prefix ++ operator on tiny type */
inline TinyEnumT& operator ++ ()
{
if (++m_val >= end) m_val -= (storage_type)(end - begin);
return *this;
}
};
/** Template of struct holding enum types (on most archs, enums are stored in an int32). No math operators are provided. */
template <typename enum_type, typename storage_type>
struct SimpleTinyEnumT {
storage_type m_val; ///< here we hold the actual value in small (i.e. byte) form
/** Cast operator - invoked then the value is assigned to the storage_type */
inline operator enum_type () const
{
return (enum_type)this->m_val;
}
/** Assignment operator (from enum_type) */
inline SimpleTinyEnumT &operator = (enum_type e)
{
this->m_val = (storage_type)e;
return *this;
}
/** Assignment operator (from general uint) */
inline SimpleTinyEnumT &operator = (uint u)
{
this->m_val = (storage_type)u;
return *this;
}
/** Bit math (or) assignment operator (from enum_type) */
inline SimpleTinyEnumT &operator |= (enum_type e)
{
this->m_val = (storage_type)((enum_type)this->m_val | e);
return *this;
}
/** Bit math (and) assignment operator (from enum_type) */
inline SimpleTinyEnumT &operator &= (enum_type e)
{
this->m_val = (storage_type)((enum_type)this->m_val & e);
return *this;
}
};
#endif /* ENUM_TYPE_HPP */

@ -335,7 +335,7 @@ char *CrashLog::LogGamelog(char *buffer, const char *last) const
}
/**
* Writes any recent news messages to the buffer.
* Writes up to 32 recent news messages to the buffer, with the most recent first.
* @param buffer The begin where to write at.
* @param last The last position in the buffer to write to.
* @return the position of the \c '\0' character after the buffer.
@ -343,18 +343,14 @@ char *CrashLog::LogGamelog(char *buffer, const char *last) const
char *CrashLog::LogRecentNews(char *buffer, const char *last) const
{
uint total = 0;
for (NewsItem *news = _oldest_news; news != nullptr; news = news->next) {
for (NewsItem *news = _latest_news; news != nullptr; news = news->next) {
total++;
}
uint show = min<uint>(total, 32);
buffer += seprintf(buffer, last, "Recent news messages (%u of %u):\n", show, total);
uint skip = total - show;
for (NewsItem *news = _oldest_news; news != nullptr; news = news->next) {
if (skip) {
skip--;
continue;
}
int i = 0;
for (NewsItem *news = _latest_news; i < 32 && news != nullptr; news = news->prev, i++) {
YearMonthDay ymd;
ConvertDateToYMD(news->date, &ymd);
buffer += seprintf(buffer, last, "(%i-%02i-%02i) StringID: %u, Type: %u, Ref1: %u, %u, Ref2: %u, %u\n",

@ -23,7 +23,7 @@
* your viewport and not rotated by 45 degrees left or right to get
* a "north" used in you games.
*/
enum Direction {
enum Direction : byte {
DIR_BEGIN = 0, ///< Used to iterate
DIR_N = 0, ///< North
DIR_NE = 1, ///< Northeast
@ -42,7 +42,6 @@ DECLARE_POSTFIX_INCREMENT(Direction)
/** Define basic enum properties */
template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, byte, DIR_BEGIN, DIR_END, INVALID_DIR, 3> {};
typedef TinyEnumT<Direction> DirectionByte; ///< typedefing-enumification of Direction
/**
@ -77,7 +76,7 @@ enum DirDiff {
*
* This enumeration is used for the 4 direction of the tile-edges.
*/
enum DiagDirection {
enum DiagDirection : byte {
DIAGDIR_BEGIN = 0, ///< Used for iterations
DIAGDIR_NE = 0, ///< Northeast, upper right on your monitor
DIAGDIR_SE = 1, ///< Southeast
@ -92,7 +91,6 @@ DECLARE_POSTFIX_INCREMENT(DiagDirection)
/** Define basic enum properties */
template <> struct EnumPropsT<DiagDirection> : MakeEnumPropsT<DiagDirection, byte, DIAGDIR_BEGIN, DIAGDIR_END, INVALID_DIAGDIR, 2> {};
typedef TinyEnumT<DiagDirection> DiagDirectionByte; ///< typedefing-enumification of DiagDirection
/**

@ -62,7 +62,7 @@ static void DisasterClearSquare(TileIndex tile)
switch (GetTileType(tile)) {
case MP_RAILWAY:
if (Company::IsHumanID(GetTileOwner(tile)) && !IsRailDepot(tile)) {
Backup<CompanyByte> cur_company(_current_company, OWNER_WATER, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_WATER, FILE_LINE);
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
cur_company.Restore();
@ -72,7 +72,7 @@ static void DisasterClearSquare(TileIndex tile)
break;
case MP_HOUSE: {
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
cur_company.Restore();
break;

@ -106,6 +106,7 @@ struct BuildDocksToolbarWindow : Window {
~BuildDocksToolbarWindow()
{
if (_game_mode != GM_EDITOR && this->IsWidgetLowered(WID_DT_STATION)) SetViewportCatchmentStation(nullptr, true);
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
}
@ -249,6 +250,8 @@ struct BuildDocksToolbarWindow : Window {
void OnPlaceObjectAbort() override
{
if (_game_mode != GM_EDITOR && this->IsWidgetLowered(WID_DT_STATION)) SetViewportCatchmentStation(nullptr, true);
this->RaiseButtons();
DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER);

@ -297,14 +297,14 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
/* We need to set _current_company to old_owner before we try to move
* the client. This is needed as it needs to know whether "you" really
* are the current local company. */
Backup<CompanyByte> cur_company(_current_company, old_owner, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, old_owner, FILE_LINE);
/* In all cases, make spectators of clients connected to that company */
if (_networking) NetworkClientsToSpectators(old_owner);
if (old_owner == _local_company) {
/* Single player cheated to AI company.
* There are no spectators in single player, so we must pick some other company. */
assert(!_networking);
Backup<CompanyByte> cur_company2(_current_company, FILE_LINE);
Backup<CompanyID> cur_company2(_current_company, FILE_LINE);
Company *c;
FOR_ALL_COMPANIES(c) {
if (c->index != old_owner) {
@ -340,7 +340,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
}
/* Sell all the shares that people have on this company */
Backup<CompanyByte> cur_company2(_current_company, FILE_LINE);
Backup<CompanyID> cur_company2(_current_company, FILE_LINE);
c = Company::Get(old_owner);
for (i = 0; i < 4; i++) {
cur_company2.Change(c->share_owners[i]);
@ -709,7 +709,7 @@ static void CompaniesGenStatistics()
CompanyCheckBankrupt(c);
}
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
if (!_settings_game.economy.infrastructure_maintenance) {
Station *st;
@ -879,7 +879,7 @@ static void CompaniesPayInterest()
{
const Company *c;
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
FOR_ALL_COMPANIES(c) {
cur_company.Change(c->index);
@ -1235,7 +1235,7 @@ CargoPayment::~CargoPayment()
if (this->visual_profit == 0 && this->visual_transfer == 0) return;
Backup<CompanyByte> cur_company(_current_company, this->front->owner, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, this->front->owner, FILE_LINE);
SubtractMoneyFromCompany(CommandCost(this->front->GetExpenseType(true), -this->route_profit));
this->front->profit_this_year += (this->visual_profit + this->visual_transfer) << 8;
@ -1578,7 +1578,7 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
if (!IterateVehicleParts(v_start, IsEmptyAction())) return;
if (v->type == VEH_TRAIN && !IterateVehicleParts(v_start, ThroughLoadTrainInPlatformAction())) return;
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
CargoTypes refit_mask = v->GetEngine()->info.refit_mask;
@ -2287,7 +2287,7 @@ CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1,
cost.AddCost(CalculateCompanyValue(c) >> 2);
if (flags & DC_EXEC) {
OwnerByte *b = c->share_owners;
Owner *b = c->share_owners;
while (*b != COMPANY_SPECTATOR) b++; // share owners is guaranteed to contain at least one COMPANY_SPECTATOR
*b = _current_company;
@ -2334,7 +2334,7 @@ CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1
cost = -(cost - (cost >> 7));
if (flags & DC_EXEC) {
OwnerByte *b = c->share_owners;
Owner *b = c->share_owners;
while (*b != _current_company) b++; // share owners is guaranteed to contain company
*b = COMPANY_SPECTATOR;
InvalidateWindowData(WC_COMPANY, target_company);

@ -147,7 +147,7 @@ typedef Money Prices[PR_END]; ///< Prices of everything. @see Price
typedef int8 PriceMultipliers[PR_END];
/** Types of expenses. */
enum ExpensesType {
enum ExpensesType : byte {
EXPENSES_CONSTRUCTION = 0, ///< Construction costs.
EXPENSES_NEW_VEHICLES, ///< New vehicles.
EXPENSES_TRAIN_RUN, ///< Running costs trains.
@ -169,7 +169,6 @@ enum ExpensesType {
/** Define basic enum properties for ExpensesType */
template <> struct EnumPropsT<ExpensesType> : MakeEnumPropsT<ExpensesType, byte, EXPENSES_CONSTRUCTION, EXPENSES_END, INVALID_EXPENSES, 8> {};
typedef TinyEnumT<ExpensesType> ExpensesTypeByte; ///< typedefing-enumification of ExpensesType
/**
* Categories of a price bases.

@ -80,8 +80,8 @@ static inline TLG GetTLG(TileIndex t)
}
struct DualTrackBits {
TrackBitsByte primary;
TrackBitsByte secondary;
TrackBits primary;
TrackBits secondary;
};
/**
@ -177,7 +177,7 @@ static TrackBits MaskWireBits(TileIndex t, TrackBits tracks)
/* If the tracks from either a diagonal crossing or don't overlap, both
* trackdirs have to be marked to mask the corresponding track bit. Else
* one marked trackdir is enough the mask the track bit. */
TrackBitsByte mask;
TrackBits mask;
if (tracks == TRACK_BIT_CROSS || !TracksOverlap(tracks)) {
/* If the tracks form either a diagonal crossing or don't overlap, both
* trackdirs have to be marked to mask the corresponding track bit. */

@ -34,7 +34,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
uint16 duration_phase_3; ///< Third reliability phase on months, decaying to #reliability_final.
byte flags; ///< Flags of the engine. @see EngineFlags
CompanyMask preview_asked; ///< Bit for each company which has already been offered a preview.
CompanyByte preview_company;///< Company which is currently being offered a preview \c INVALID_COMPANY means no company.
CompanyID preview_company; ///< Company which is currently being offered a preview \c INVALID_COMPANY means no company.
byte preview_wait; ///< Daily countdown timer for timeout of offering the engine to the #preview_company company.
CompanyMask company_avail; ///< Bit for each company whether the engine is available for that company.
CompanyMask company_hidden; ///< Bit for each company whether the engine is normally hidden in the build gui for that company.
@ -119,7 +119,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
* @param c Company to check.
* @return \c true iff the engine is hidden in the GUI for the given company.
*/
inline bool IsHidden(CompanyByte c) const
inline bool IsHidden(CompanyID c) const
{
return c < MAX_COMPANIES && HasBit(this->company_hidden, c);
}
@ -149,7 +149,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
struct EngineIDMapping {
uint32 grfid; ///< The GRF ID of the file the entity belongs to
uint16 internal_id; ///< The internal ID within the GRF file
VehicleTypeByte type; ///< The engine type
VehicleType type; ///< The engine type
uint8 substitute_id; ///< The (original) entity ID to use if this GRF is not available (currently not used)
};

@ -44,7 +44,7 @@ struct RailVehicleInfo {
byte image_index;
RailVehicleTypes railveh_type;
byte cost_factor; ///< Purchase cost factor; For multiheaded engines the sum of both engine prices.
RailTypeByte railtype;
RailType railtype;
uint16 max_speed; ///< Maximum speed (1 unit = 1/1.6 mph = 1 km-ish/h)
uint16 power; ///< Power of engine (hp); For multiheaded engines the sum of both engine powers.
uint16 weight; ///< Weight of vehicle (tons); For multiheaded engines the weight of each single engine.

@ -45,7 +45,7 @@
Game::frame_counter++;
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
cur_company.Change(OWNER_DEITY);
Game::instance->GameLoop();
cur_company.Restore();
@ -84,7 +84,7 @@
config->AnchorUnchangeableSettings();
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
cur_company.Change(OWNER_DEITY);
Game::info = info;
@ -98,7 +98,7 @@
/* static */ void Game::Uninitialize(bool keepConfig)
{
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
delete Game::instance;
Game::instance = nullptr;
@ -158,7 +158,7 @@
}
/* Queue the event */
Backup<CompanyByte> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
Game::instance->InsertEvent(event);
cur_company.Restore();
@ -207,7 +207,7 @@
/* static */ void Game::Save()
{
if (Game::instance != nullptr && (!_networking || _network_server)) {
Backup<CompanyByte> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
Game::instance->Save();
cur_company.Restore();
} else {
@ -218,7 +218,7 @@
/* static */ void Game::Load(int version)
{
if (Game::instance != nullptr && (!_networking || _network_server)) {
Backup<CompanyByte> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
Game::instance->Load(version);
cur_company.Restore();
} else {

@ -97,7 +97,7 @@ static void CleanupGeneration()
static void _GenerateWorld()
{
/* Make sure everything is done via OWNER_NONE. */
Backup<CompanyByte> _cur_company(_current_company, OWNER_NONE, FILE_LINE);
Backup<CompanyID> _cur_company(_current_company, OWNER_NONE, FILE_LINE);
std::unique_lock<std::mutex> lock(_modal_progress_work_mutex, std::defer_lock);
try {

@ -46,7 +46,7 @@ bool _screen_disable_anim = false; ///< Disable palette animation (important f
bool _exit_game;
GameMode _game_mode;
SwitchMode _switch_mode; ///< The next mainloop command.
PauseModeByte _pause_mode;
PauseMode _pause_mode;
Palette _cur_palette;
static byte _stringwidth_table[FS_END][224]; ///< Cache containing width of often used characters. @see GetCharacterWidth()
@ -58,8 +58,8 @@ static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode,
static ReusableBuffer<uint8> _cursor_backup;
ZoomLevelByte _gui_zoom; ///< GUI Zoom level
ZoomLevelByte _font_zoom; ///< Font Zoom level
ZoomLevel _gui_zoom; ///< GUI Zoom level
ZoomLevel _font_zoom; ///< Font Zoom level
/**
* The rect for repaint.

@ -294,7 +294,7 @@ enum PaletteType {
};
/** Types of sprites that might be loaded */
enum SpriteType {
enum SpriteType : byte {
ST_NORMAL = 0, ///< The most basic (normal) sprite
ST_MAPGEN = 1, ///< Special sprite for the map generator
ST_FONT = 2, ///< A sprite used for fonts

@ -79,7 +79,7 @@ CommandCost CmdCreateGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
case GT_STORY_PAGE: {
if (!StoryPage::IsValidID(p2)) return CMD_ERROR;
CompanyByte story_company = StoryPage::Get(p2)->company;
CompanyID story_company = StoryPage::Get(p2)->company;
if (company == INVALID_COMPANY ? story_company != INVALID_COMPANY : story_company != INVALID_COMPANY && story_company != company) return CMD_ERROR;
break;
}

@ -21,12 +21,12 @@ extern GoalPool _goal_pool;
/** Struct about goals, current and completed */
struct Goal : GoalPool::PoolItem<&_goal_pool> {
CompanyByte company; ///< Goal is for a specific company; INVALID_COMPANY if it is global
GoalTypeByte type; ///< Type of the goal
GoalTypeID dst; ///< Index of type
char *text; ///< Text of the goal.
char *progress; ///< Progress text of the goal.
bool completed; ///< Is the goal completed or not?
CompanyID company; ///< Goal is for a specific company; INVALID_COMPANY if it is global
GoalType type; ///< Type of the goal
GoalTypeID dst; ///< Index of type
char *text; ///< Text of the goal.
char *progress; ///< Progress text of the goal.
bool completed; ///< Is the goal completed or not?
/**
* We need an (empty) constructor so struct isn't zeroed (as C++ standard states)

@ -18,7 +18,7 @@ static const uint32 GOAL_QUESTION_BUTTON_COUNT = 18; ///< Amount of buttons avai
static const byte GOAL_QUESTION_TYPE_COUNT = 4; ///< Amount of question types.
/** Types of goal destinations */
enum GoalType {
enum GoalType : byte {
GT_NONE, ///< Destination is not linked
GT_TILE, ///< Destination is a tile
GT_INDUSTRY, ///< Destination is an industry
@ -26,7 +26,6 @@ enum GoalType {
GT_COMPANY, ///< Destination is a company
GT_STORY_PAGE, ///< Destination is a story page
};
typedef SimpleTinyEnumT<GoalType, byte> GoalTypeByte; ///< The GoalType packed into a byte for savegame purposes.
typedef uint32 GoalTypeID; ///< Contains either tile, industry ID, town ID or company ID (or INVALID_GOALTYPE)
static const GoalTypeID INVALID_GOALTYPE = 0xFFFFFFFF; ///< Invalid/unknown index of GoalType

@ -65,17 +65,17 @@ struct GroupStatistics {
/** Group data. */
struct Group : GroupPool::PoolItem<&_group_pool> {
char *name; ///< Group Name
OwnerByte owner; ///< Group Owner
VehicleTypeByte vehicle_type; ///< Vehicle type of the group
char *name; ///< Group Name
Owner owner; ///< Group Owner
VehicleType vehicle_type; ///< Vehicle type of the group
bool replace_protection; ///< If set to true, the global autoreplace have no effect on the group
Livery livery; ///< Custom colour scheme for vehicles in this group
GroupStatistics statistics; ///< NOSAVE: Statistics and caches on the vehicles in the group.
bool replace_protection; ///< If set to true, the global autoreplace have no effect on the group
Livery livery; ///< Custom colour scheme for vehicles in this group
GroupStatistics statistics; ///< NOSAVE: Statistics and caches on the vehicles in the group.
bool folded; ///< NOSAVE: Is this group folded in the group view?
bool folded; ///< NOSAVE: Is this group folded in the group view?
GroupID parent; ///< Parent group
GroupID parent; ///< Parent group
Group(CompanyID owner = INVALID_COMPANY);
~Group();

@ -57,16 +57,16 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
uint16 counter; ///< used for animation and/or production (if available cargo)
IndustryType type; ///< type of industry.
OwnerByte owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE
Owner owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE
byte random_colour; ///< randomized colour of the industry, for display purpose
Year last_prod_year; ///< last year of production
byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry
PartOfSubsidyByte part_of_subsidy; ///< NOSAVE: is this industry a source/destination of a subsidy?
PartOfSubsidy part_of_subsidy; ///< NOSAVE: is this industry a source/destination of a subsidy?
StationList stations_near; ///< NOSAVE: List of nearby stations.
std::unique_ptr<const char, FreeDeleter> cached_name; ///< NOSAVE: Cache of the resolved name of the industry
OwnerByte founder; ///< Founder of the industry
Owner founder; ///< Founder of the industry
Date construction_date; ///< Date of the construction of the industry
uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType)
Date last_cargo_accepted_at[INDUSTRY_NUM_INPUTS]; ///< Last day each cargo type was accepted by this industry

@ -1078,7 +1078,7 @@ static bool SearchLumberMillTrees(TileIndex tile, void *user_data)
if (IsTileType(tile, MP_TREES) && GetTreeGrowth(tile) > 2) { ///< 3 and up means all fully grown trees
/* found a tree */
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
_industry_sound_ctr = 1;
_industry_sound_tile = tile;
@ -1437,7 +1437,7 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
}
/* Clear the tiles as OWNER_TOWN to not affect town rating, and to not clear protected buildings */
Backup<CompanyByte> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
CommandCost ret = DoCommand(cur_tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
cur_company.Restore();
@ -1549,7 +1549,7 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags,
/* _current_company is OWNER_NONE for randomly generated industries and in editor, or the company who funded or prospected the industry.
* Perform terraforming as OWNER_TOWN to disable autoslope and town ratings. */
Backup<CompanyByte> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
TILE_AREA_LOOP(tile_walk, ta) {
uint curh = TileHeight(tile_walk);
@ -1974,7 +1974,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (deity_prospect || (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY && _settings_game.construction.raw_industry_construction == 2 && indspec->IsRawIndustry())) {
if (flags & DC_EXEC) {
/* Prospected industries are build as OWNER_TOWN to not e.g. be build on owned land of the founder */
Backup<CompanyByte> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
/* Prospecting has a chance to fail, however we cannot guarantee that something can
* be built on the map, so the chance gets lower when the map is fuller, but there
* is nothing we can really do about that. */
@ -2136,7 +2136,7 @@ static Industry *PlaceIndustry(IndustryType type, IndustryAvailabilityCallType c
*/
static void PlaceInitialIndustry(IndustryType type, bool try_hard)
{
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
IncreaseGeneratingWorldProgress(GWP_INDUSTRY);
PlaceIndustry(type, IACT_MAPGENERATION, try_hard);
@ -2787,7 +2787,7 @@ void IndustryDailyLoop()
return; // Nothing to do? get out
}
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
/* perform the required industry changes for the day */
@ -2815,7 +2815,7 @@ void IndustryDailyLoop()
void IndustryMonthlyLoop()
{
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
_industry_builder.MonthlyLoop();

@ -655,7 +655,7 @@ public:
return;
}
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
_generating_world = true;
_ignore_restrictions = true;

@ -333,6 +333,8 @@ STR_TOOLTIP_FILTER_CRITERIA :{BLACK}Odaberi
STR_BUTTON_SORT_BY :{BLACK}Sortiraj prema
STR_BUTTON_LOCATION :{BLACK}Lokacija
STR_BUTTON_RENAME :{BLACK}Preimenuj
STR_BUTTON_CATCHMENT :{BLACK}Područje pokrivanja
STR_TOOLTIP_CATCHMENT :{BLACK}Uključi prikaz područja pokrivanja
STR_TOOLTIP_CLOSE_WINDOW :{BLACK}Zatvori prozor
STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS :{BLACK}Naslov prozora - povuci ovo za micanje prozora
@ -361,6 +363,7 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP :{BLACK}Uključi
STR_BUTTON_DEFAULT :{BLACK}Zadano
STR_BUTTON_CANCEL :{BLACK}Odustani
STR_BUTTON_OK :{BLACK}OK
STR_WARNING_PASSWORD_SECURITY :{YELLOW}Upozorenje: Administratori servera mogu pročitati bilo koji tekst upisan ovdje.
# On screen keyboard window
STR_OSK_KEYBOARD_LAYOUT :`1234567890-=\qwertyuiop[]asdfghjkl;' zxcvbnm,./ .

@ -237,6 +237,8 @@ STR_TOOLTIP_FILTER_CRITERIA :{BLACK}Selectee
STR_BUTTON_SORT_BY :{BLACK}Sorteren op
STR_BUTTON_LOCATION :{BLACK}Locatie
STR_BUTTON_RENAME :{BLACK}Hernoemen
STR_BUTTON_CATCHMENT :{BLACK}Dekking
STR_TOOLTIP_CATCHMENT :{BLACK}Schakelt weergave van dekkingsgebied om
STR_TOOLTIP_CLOSE_WINDOW :{BLACK}Venster sluiten
STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS :{BLACK}Vensternaam - sleep om venster te verplaatsen
@ -265,6 +267,7 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP :{BLACK}Wanneer
STR_BUTTON_DEFAULT :{BLACK}Standaard
STR_BUTTON_CANCEL :{BLACK}Annuleren
STR_BUTTON_OK :{BLACK}OK
STR_WARNING_PASSWORD_SECURITY :{YELLOW}Waarschuwing: het kan zijn dat serverbeheerders tekst niet kunnen lezen die hier wordt ingevoerd.
# On screen keyboard window
STR_OSK_KEYBOARD_LAYOUT :`1234567890-=\qwertyuiop[]asdfghjkl;' zxcvbnm,./ .

@ -237,6 +237,8 @@ STR_TOOLTIP_FILTER_CRITERIA :{BLACK}Select f
STR_BUTTON_SORT_BY :{BLACK}Sort by
STR_BUTTON_LOCATION :{BLACK}Location
STR_BUTTON_RENAME :{BLACK}Rename
STR_BUTTON_CATCHMENT :{BLACK}Coverage
STR_TOOLTIP_CATCHMENT :{BLACK}Toggle coverage area display
STR_TOOLTIP_CLOSE_WINDOW :{BLACK}Close window
STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS :{BLACK}Window title - drag this to move window
@ -265,6 +267,7 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP :{BLACK}By enabl
STR_BUTTON_DEFAULT :{BLACK}Default
STR_BUTTON_CANCEL :{BLACK}Cancel
STR_BUTTON_OK :{BLACK}OK
STR_WARNING_PASSWORD_SECURITY :{YELLOW}Warning: Server administrators may be able to read any text entered here.
# On screen keyboard window
STR_OSK_KEYBOARD_LAYOUT :`1234567890-=\qwertyuiop[]asdfghjkl;' zxcvbnm,./ .

@ -237,6 +237,8 @@ STR_TOOLTIP_FILTER_CRITERIA :{BLACK}Valitse
STR_BUTTON_SORT_BY :{BLACK}Lajittele
STR_BUTTON_LOCATION :{BLACK}Sijainti
STR_BUTTON_RENAME :{BLACK}Nimeä uudelleen
STR_BUTTON_CATCHMENT :{BLACK}Vaikutusalue
STR_TOOLTIP_CATCHMENT :{BLACK}Valitse, näytetäänkö vaikutusalue
STR_TOOLTIP_CLOSE_WINDOW :{BLACK}Sulje ikkuna
STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS :{BLACK}Ikkunan otsake siirrä ikkunaa vetämällä tästä
@ -265,6 +267,7 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP :{BLACK}Kun otat
STR_BUTTON_DEFAULT :{BLACK}Oletus
STR_BUTTON_CANCEL :{BLACK}Peruuta
STR_BUTTON_OK :{BLACK}OK
STR_WARNING_PASSWORD_SECURITY :{YELLOW}Varoitus: Palvelimen ylläpitäjät saattavat nähdä kaiken tähän kirjoittamasi.
# On screen keyboard window
STR_OSK_KEYBOARD_LAYOUT :§1234567890+´ qwertyuiopå¨asdfghjklöä' zxcvbnm,.- .

@ -476,6 +476,7 @@ STR_ABOUT_MENU_SCREENSHOT :Ambil gambar
STR_ABOUT_MENU_ZOOMIN_SCREENSHOT :Ambil gambar dengan diperbesar
STR_ABOUT_MENU_DEFAULTZOOM_SCREENSHOT :Ambil gambar dengan perbesaran normal
STR_ABOUT_MENU_GIANT_SCREENSHOT :Ambil gambar keseluruhan peta
STR_ABOUT_MENU_SHOW_FRAMERATE :Tampilkan laju bingkai
STR_ABOUT_MENU_ABOUT_OPENTTD :Tentang 'OpenTTD'
STR_ABOUT_MENU_SPRITE_ALIGNER :Penjajar Sprite
STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Hidup/Matikan kotak batas
@ -1572,6 +1573,7 @@ STR_CONFIG_SETTING_TOWN_FOUNDING_HELPTEXT :Mengaktifkan se
STR_CONFIG_SETTING_TOWN_FOUNDING_FORBIDDEN :Dilarang
STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED :Diijinkan
STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED_CUSTOM_LAYOUT :Diijinkan, layout kota sendiri
STR_CONFIG_SETTING_TOWN_CARGOGENMODE_HELPTEXT :Seberapa banyak kargo dihasilkan oleh rumah di kota , relatif terhadap keseluruhan populasi kota.{}Pertumbuhan kuadrat: Kota yang membesar dua kali menghasilkan penumpang empat kali lipat.{}Pertumbuhan linier: Kota yang membesar dua kali menghasilkan penumpang dua kali lipat.
STR_CONFIG_SETTING_TOWN_CARGOGENMODE_BITCOUNT :Linier
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT :Penempatan pohon dalam permainan: {STRING}
@ -3149,11 +3151,11 @@ STR_STATION_VIEW_ACCEPTS_TOOLTIP :{BLACK}Tampilka
STR_STATION_VIEW_ACCEPTS_CARGO :{BLACK}Menerima: {WHITE}{CARGO_LIST}
STR_STATION_VIEW_EXCLUSIVE_RIGHTS_SELF :{BLACK}Stasiun memiliki hak transportasi eksklusif di kota ini
STR_STATION_VIEW_EXCLUSIVE_RIGHTS_COMPANY :{YELLOW}{COMPANY}{BLACK} beli hak transportasi eksklusif di kota ini
STR_STATION_VIEW_EXCLUSIVE_RIGHTS_COMPANY :{YELLOW}{COMPANY}{BLACK} memiliki hak transportasi eksklusif di kota ini
STR_STATION_VIEW_RATINGS_BUTTON :{BLACK}Peringkat
STR_STATION_VIEW_RATINGS_TOOLTIP :{BLACK}Tampilkna peringkat dari stasiun
STR_STATION_VIEW_SUPPLY_RATINGS_TITLE :{BLACK}Asupan bulanan dan penilaian tempatan:
STR_STATION_VIEW_SUPPLY_RATINGS_TITLE :{BLACK}Asupan bulanan dan peringkat layanan:
STR_STATION_VIEW_CARGO_SUPPLY_RATING :{WHITE}{STRING}: {YELLOW}{COMMA} / {STRING} ({COMMA}%)
STR_STATION_VIEW_GROUP :{BLACK}Pengelompokkan
@ -3376,6 +3378,7 @@ STR_GROUP_DEFAULT_ROAD_VEHICLES :Kendaraan tanpa
STR_GROUP_DEFAULT_SHIPS :Kapal tanpa kelompok
STR_GROUP_DEFAULT_AIRCRAFTS :Pesawat tanpa kelompok
STR_GROUP_COUNT_WITH_SUBGROUP :{TINY_FONT}{COMMA} (+{COMMA})
STR_GROUPS_CLICK_ON_GROUP_FOR_TOOLTIP :{BLACK}Kelompok - Klik salah satu untuk melihat daftar kendaraan pada kelompok tersebut
STR_GROUP_CREATE_TOOLTIP :{BLACK}Klik untuk membuat kelompok

@ -239,6 +239,8 @@ STR_TOOLTIP_FILTER_CRITERIA :{BLACK}Selezion
STR_BUTTON_SORT_BY :{BLACK}Ordina per
STR_BUTTON_LOCATION :{BLACK}Posizione
STR_BUTTON_RENAME :{BLACK}Rinomina
STR_BUTTON_CATCHMENT :{BLACK}Copertura
STR_TOOLTIP_CATCHMENT :{BLACK}Attiva/disattiva la visualizzazione dell'area di copertura
STR_TOOLTIP_CLOSE_WINDOW :{BLACK}Chiude la finestra
STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS :{BLACK}Titolo della finestra - trascinarlo per muovere la finestra
@ -267,6 +269,7 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP :{BLACK}Mostra a
STR_BUTTON_DEFAULT :{BLACK}Predefinito
STR_BUTTON_CANCEL :{BLACK}Annulla
STR_BUTTON_OK :{BLACK}OK
STR_WARNING_PASSWORD_SECURITY :{YELLOW}Attenzione: gli amministratori del server potrebbero leggere il testo inserito qui.
# On screen keyboard window
STR_OSK_KEYBOARD_LAYOUT :\1234567890'ì qwertyuiopè+asdfghjklòàù<zxcvbnm,.- .

@ -237,6 +237,8 @@ STR_TOOLTIP_FILTER_CRITERIA :{BLACK}검색
STR_BUTTON_SORT_BY :{BLACK}정렬
STR_BUTTON_LOCATION :{BLACK}위치
STR_BUTTON_RENAME :{BLACK}이름 바꾸기
STR_BUTTON_CATCHMENT :{BLACK}역세권
STR_TOOLTIP_CATCHMENT :{BLACK}이 역의 역세권을 표시하거나 끕니다.
STR_TOOLTIP_CLOSE_WINDOW :{BLACK}창을 닫습니다.
STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS :{BLACK}창 제목 - 창을 움직이려면 여기를 드래그하세요.
@ -265,6 +267,7 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP :{BLACK}이 버
STR_BUTTON_DEFAULT :{BLACK}기본값
STR_BUTTON_CANCEL :{BLACK}취소
STR_BUTTON_OK :{BLACK}확인
STR_WARNING_PASSWORD_SECURITY :{YELLOW}경고: 서버 관리자가 여기에 입력되는 모든 텍스트를 읽을 수 있습니다.
# On screen keyboard window
STR_OSK_KEYBOARD_LAYOUT :`1234567890-=\ㅂㅈㄷㄱㅅㅛㅕㅑㅐㅔ[]ㅁㄴㅇㄹㅎㅗㅓㅏㅣ;' ㅋㅌㅊㅍㅠㅜㅡ,./ .

@ -363,6 +363,8 @@ STR_TOOLTIP_FILTER_CRITERIA :{BLACK}Выбе
STR_BUTTON_SORT_BY :{BLACK}Сортировка
STR_BUTTON_LOCATION :{BLACK}Обзор
STR_BUTTON_RENAME :{BLACK}Переименовать
STR_BUTTON_CATCHMENT :{BLACK}Покрытие
STR_TOOLTIP_CATCHMENT :{BLACK}Переключить видимость области покрытия
STR_TOOLTIP_CLOSE_WINDOW :{BLACK}Закрыть окно
STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS :{BLACK}Окна можно перетаскивать, схватив за заголовок
@ -391,6 +393,7 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP :{BLACK}Если
STR_BUTTON_DEFAULT :{BLACK}По умолчанию
STR_BUTTON_CANCEL :{BLACK}Отмена
STR_BUTTON_OK :{BLACK}OK
STR_WARNING_PASSWORD_SECURITY :{YELLOW}Внимание: администраторы сервера могут увидеть ваш пароль.
# On screen keyboard window
STR_OSK_KEYBOARD_LAYOUT :`1234567890-=\qwertyuiop[]asdfghjkl;' zxcvbnm,./ .

@ -238,6 +238,8 @@ STR_TOOLTIP_FILTER_CRITERIA :{BLACK}Elegir c
STR_BUTTON_SORT_BY :{BLACK}Ordenar por
STR_BUTTON_LOCATION :{BLACK}Ubicación
STR_BUTTON_RENAME :{BLACK}Cambiar nombre
STR_BUTTON_CATCHMENT :{BLACK}Cobertura
STR_TOOLTIP_CATCHMENT :{BLACK}Mostrar u ocultar área de cobertura
STR_TOOLTIP_CLOSE_WINDOW :{BLACK}Cerrar ventana
STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS :{BLACK}Título de la ventana (arrastrar para mover)
@ -266,6 +268,7 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP :{BLACK}Activar
STR_BUTTON_DEFAULT :{BLACK}Predeterminado
STR_BUTTON_CANCEL :{BLACK}Cancelar
STR_BUTTON_OK :{BLACK}Aceptar
STR_WARNING_PASSWORD_SECURITY :{YELLOW}Advertencia: los administradores del servidor tienen acceso al texto escrito aquí
# On screen keyboard window
STR_OSK_KEYBOARD_LAYOUT :|1234567890'¿\qwertyuiop´+asdfghjklñ{}<zxcvbnm,.- .

@ -177,6 +177,16 @@ void ZoomInOrOutToCursorWindow(bool in, Window *w)
}
}
void FixTitleGameZoom()
{
if (_game_mode != GM_MENU) return;
ViewPort *vp = FindWindowByClass(WC_MAIN_WINDOW)->viewport;
vp->zoom = _gui_zoom;
vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
}
static const struct NWidgetPart _nested_main_window_widgets[] = {
NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_M_VIEWPORT), SetResize(1, 1),
};

@ -174,9 +174,9 @@ CommandCost CmdPause(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2,
PauseMode prev_mode = _pause_mode;
if (p2 == 0) {
_pause_mode = _pause_mode & ~p1;
_pause_mode = static_cast<PauseMode>(_pause_mode & (byte)~p1);
} else {
_pause_mode = _pause_mode | p1;
_pause_mode = static_cast<PauseMode>(_pause_mode | (byte)p1);
}
NetworkHandlePauseChange(prev_mode, (PauseMode)p1);
@ -224,7 +224,7 @@ CommandCost CmdChangeBankBalance(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (flags & DC_EXEC) {
/* Change company bank balance of company. */
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
SubtractMoneyFromCompany(CommandCost(expenses_type, -delta));
cur_company.Restore();
}
@ -260,7 +260,7 @@ CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (flags & DC_EXEC) {
/* Add money to company */
Backup<CompanyByte> cur_company(_current_company, dest_company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, dest_company, FILE_LINE);
SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, -amount.GetCost()));
cur_company.Restore();
}

@ -1003,6 +1003,7 @@ struct QueryStringWindow : public Window
{
QueryString editbox; ///< Editbox.
QueryStringFlags flags; ///< Flags controlling behaviour of the window.
Dimension warning_size; ///< How much space to use for the warning text
QueryStringWindow(StringID str, StringID caption, uint max_bytes, uint max_chars, WindowDesc *desc, Window *parent, CharSetFilter afilter, QueryStringFlags flags) :
Window(desc), editbox(max_bytes, max_chars)
@ -1031,12 +1032,27 @@ struct QueryStringWindow : public Window
this->flags = flags;
this->InitNested(WN_QUERY_STRING);
this->UpdateWarningStringSize();
this->parent = parent;
this->SetFocusedWidget(WID_QS_TEXT);
}
void UpdateWarningStringSize()
{
if (this->flags & QSF_PASSWORD) {
assert(this->nested_root->smallest_x > 0);
this->warning_size.width = this->nested_root->current_x - (WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT);
this->warning_size.height = GetStringHeight(STR_WARNING_PASSWORD_SECURITY, this->warning_size.width);
this->warning_size.height += WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
} else {
this->warning_size = Dimension{ 0, 0 };
}
this->ReInit();
}
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget == WID_QS_DEFAULT && (this->flags & QSF_ENABLE_DEFAULT) == 0) {
@ -1045,6 +1061,21 @@ struct QueryStringWindow : public Window
resize->width = 0;
size->width = 0;
}
if (widget == WID_QS_WARNING) {
*size = this->warning_size;
}
}
void DrawWidget(const Rect &r, int widget) const override
{
if (widget != WID_QS_WARNING) return;
if (this->flags & QSF_PASSWORD) {
DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT - WD_FRAMERECT_RIGHT,
r.top + WD_FRAMERECT_TOP + WD_FRAMETEXT_TOP, r.bottom - WD_FRAMERECT_BOTTOM - WD_FRAMETEXT_BOTTOM,
STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
}
}
void SetStringParameters(int widget) const override
@ -1101,6 +1132,7 @@ static const NWidgetPart _nested_query_string_widgets[] = {
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QS_TEXT), SetMinimalSize(256, 12), SetFill(1, 1), SetPadding(2, 2, 2, 2),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_QS_WARNING), EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_DEFAULT), SetMinimalSize(87, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_DEFAULT, STR_NULL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_CANCEL), SetMinimalSize(86, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),

@ -1266,7 +1266,7 @@ void NetworkClientRequestMove(CompanyID company_id, const char *pass)
*/
void NetworkClientsToSpectators(CompanyID cid)
{
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
/* If our company is changing owner, go to spectators */
if (cid == _local_company) SetLocalCompany(COMPANY_SPECTATOR);

@ -2146,15 +2146,17 @@ void ShowNetworkNeedPassword(NetworkPasswordType npt)
case NETWORK_GAME_PASSWORD: caption = STR_NETWORK_NEED_GAME_PASSWORD_CAPTION; break;
case NETWORK_COMPANY_PASSWORD: caption = STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION; break;
}
ShowQueryString(STR_EMPTY, caption, NETWORK_PASSWORD_LENGTH, w, CS_ALPHANUMERAL, QSF_NONE);
ShowQueryString(STR_EMPTY, caption, NETWORK_PASSWORD_LENGTH, w, CS_ALPHANUMERAL, QSF_PASSWORD);
}
struct NetworkCompanyPasswordWindow : public Window {
QueryString password_editbox; ///< Password editbox.
Dimension warning_size; ///< How much space to use for the warning text
NetworkCompanyPasswordWindow(WindowDesc *desc, Window *parent) : Window(desc), password_editbox(lengthof(_settings_client.network.default_company_pass))
{
this->InitNested(0);
this->UpdateWarningStringSize();
this->parent = parent;
this->querystrings[WID_NCP_PASSWORD] = &this->password_editbox;
@ -2163,6 +2165,32 @@ struct NetworkCompanyPasswordWindow : public Window {
this->SetFocusedWidget(WID_NCP_PASSWORD);
}
void UpdateWarningStringSize()
{
assert(this->nested_root->smallest_x > 0);
this->warning_size.width = this->nested_root->current_x - (WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT);
this->warning_size.height = GetStringHeight(STR_WARNING_PASSWORD_SECURITY, this->warning_size.width);
this->warning_size.height += WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
this->ReInit();
}
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget == WID_NCP_WARNING) {
*size = this->warning_size;
}
}
void DrawWidget(const Rect &r, int widget) const override
{
if (widget != WID_NCP_WARNING) return;
DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT,
r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM,
STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
}
void OnOk()
{
if (this->IsWidgetLowered(WID_NCP_SAVE_AS_DEFAULT_PASSWORD)) {
@ -2209,6 +2237,7 @@ static const NWidgetPart _nested_network_company_password_window_widgets[] = {
EndContainer(),
EndContainer(),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_NCP_WARNING), EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_CANCEL), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_COMPANY_PASSWORD_CANCEL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_OK), SetFill(1, 0), SetDataTip(STR_BUTTON_OK, STR_COMPANY_PASSWORD_OK),

@ -662,7 +662,7 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern
_engine_mngr.push_back({
scope_grfid, // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation
internal_id,
{static_cast<byte>(type)},
type,
static_cast<uint8>(min(internal_id, _engine_counts[type])) // substitute_id == _engine_counts[subtype] means "no substitute"
});

@ -238,7 +238,7 @@ struct GRFFile : ZeroedMemoryAllocator {
uint8 cargo_map[NUM_CARGO]; ///< Inverse cargo translation table (CargoID -> local ID)
std::vector<RailTypeLabel> railtype_list; ///< Railtype translation table
RailTypeByte railtype_map[RAILTYPE_END];
RailType railtype_map[RAILTYPE_END];
CanalProperties canal_local_properties[CF_END]; ///< Canal properties as set by this NewGRF

@ -81,13 +81,12 @@ struct StationResolverObject : public ResolverObject {
const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
};
enum StationClassID {
enum StationClassID : byte {
STAT_CLASS_BEGIN = 0, ///< the lowest valid value
STAT_CLASS_DFLT = 0, ///< Default station class.
STAT_CLASS_WAYP, ///< Waypoint class.
STAT_CLASS_MAX = 256, ///< Maximum number of classes.
STAT_CLASS_MAX = 255, ///< Maximum number of classes.
};
typedef SimpleTinyEnumT<StationClassID, byte> StationClassIDByte;
template <> struct EnumPropsT<StationClassID> : MakeEnumPropsT<StationClassID, byte, STAT_CLASS_BEGIN, STAT_CLASS_MAX, STAT_CLASS_MAX, 8> {};
/** Allow incrementing of StationClassID variables */

@ -43,10 +43,10 @@
const NewsItem *_statusbar_news_item = nullptr;
static uint MIN_NEWS_AMOUNT = 30; ///< preferred minimum amount of news messages
static uint _total_news = 0; ///< current number of news items
NewsItem *_oldest_news = nullptr; ///< head of news items queue
static NewsItem *_latest_news = nullptr; ///< tail of news items queue
static uint MIN_NEWS_AMOUNT = 30; ///< preferred minimum amount of news messages
static uint _total_news = 0; ///< current number of news items
static NewsItem *_oldest_news = nullptr; ///< head of news items queue
NewsItem *_latest_news = nullptr; ///< tail of news items queue
/**
* Forced news item.
@ -54,7 +54,7 @@ static NewsItem *_latest_news = nullptr; ///< tail of news items queue
* If the message being shown was forced by the user, a pointer is stored
* in _forced_news. Otherwise, \a _forced_news variable is nullptr.
*/
static const NewsItem *_forced_news = nullptr; ///< item the user has asked for
static const NewsItem *_forced_news = nullptr;
/** Current news item (last item shown regularly). */
static const NewsItem *_current_news = nullptr;
@ -331,6 +331,11 @@ struct NewsWindow : Window {
*size = maxdim(*size, GetSpriteSize(SPR_GRADIENT));
break;
case WID_N_MGR_NAME:
SetDParamStr(0, static_cast<const CompanyNewsInformation *>(this->ni->free_data)->president_name);
str = STR_JUST_RAW_STRING;
break;
case WID_N_MESSAGE:
CopyInDParam(0, this->ni->params, lengthof(this->ni->params));
str = this->ni->string_id;

@ -17,6 +17,6 @@
void ShowLastNewsMessage();
void ShowMessageHistory();
extern NewsItem *_oldest_news;
extern NewsItem *_latest_news;
#endif /* NEWS_GUI_H */

@ -63,6 +63,7 @@
#include "town.h"
#include "subsidy_func.h"
#include "gfx_layout.h"
#include "viewport_func.h"
#include "viewport_sprite_sorter.h"
#include "framerate_type.h"
#include "programmable_signals.h"
@ -419,6 +420,7 @@ static void LoadIntroGame(bool load_newgrfs = true)
SetLocalCompany(COMPANY_FIRST);
}
FixTitleGameZoom();
_pause_mode = PM_UNPAUSED;
_cursor.fix_at = false;
@ -1707,7 +1709,7 @@ void StateGameLoop()
/* All these actions has to be done from OWNER_NONE
* for multiplayer compatibility */
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP);
_tick_skip_counter++;

@ -68,7 +68,7 @@ inline bool InEventLoopPostCrash()
#endif
/** Modes of pausing we've got */
enum PauseMode {
enum PauseMode : byte {
PM_UNPAUSED = 0, ///< A normal unpaused game
PM_PAUSED_NORMAL = 1 << 0, ///< A game normally paused
PM_PAUSED_SAVELOAD = 1 << 1, ///< A game paused for saving/loading
@ -82,10 +82,9 @@ enum PauseMode {
PMB_PAUSED_NETWORK = PM_PAUSED_ACTIVE_CLIENTS | PM_PAUSED_JOIN,
};
DECLARE_ENUM_AS_BIT_SET(PauseMode)
typedef SimpleTinyEnumT<PauseMode, byte> PauseModeByte;
/** The current pause mode */
extern PauseModeByte _pause_mode;
extern PauseMode _pause_mode;
enum GameEventFlags : uint32 {
GEF_COMPANY_DELETE = 1 << 0, ///< (d) A company has been deleted

@ -1846,7 +1846,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
* whether we are not going to a depot as there are three
* cases where the full load flag can be active and only
* one case where the flag is used for depot orders. In the
* other cases for the OrderTypeByte the flags are not used,
* other cases for the OrderType the flags are not used,
* so do not care and those orders should not be active
* when this function is called.
*/

@ -34,8 +34,8 @@ static const OrderID INVALID_ORDER = 0xFFFFFF;
*/
static const uint IMPLICIT_ORDER_ONLY_CAP = 32;
/** Order types */
enum OrderType {
/** Order types. It needs to be 8bits, because we save and load it as such */
enum OrderType : byte {
OT_BEGIN = 0,
OT_NOTHING = 0,
OT_GOTO_STATION = 1,
@ -45,16 +45,12 @@ enum OrderType {
OT_DUMMY = 5,
OT_GOTO_WAYPOINT = 6,
OT_CONDITIONAL = 7,
OT_IMPLICIT = 8,
OT_WAITING = 9,
OT_IMPLICIT = 8,
OT_WAITING = 9,
OT_LOADING_ADVANCE = 10,
OT_END
};
/** It needs to be 8bits, because we save and load it as such */
typedef SimpleTinyEnumT<OrderType, byte> OrderTypeByte;
/**
* Flags related to the unloading order.
*/

@ -1127,7 +1127,7 @@ FindDepotData NPFRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_penal
{
Trackdir trackdir = v->GetVehicleTrackdir();
AyStarUserData user = { v->owner, TRANSPORT_ROAD, INVALID_RAILTYPES, v->compatible_roadtypes };
AyStarUserData user = { v->owner, TRANSPORT_ROAD, RAILTYPES_NONE, v->compatible_roadtypes };
NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, false, INVALID_TILE, INVALID_TRACKDIR, false, nullptr, &user, 0, max_penalty);
if (ftd.best_bird_dist != 0) return FindDepotData();
@ -1147,7 +1147,7 @@ Trackdir NPFRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDir
NPFFillWithOrderData(&fstd, v);
Trackdir trackdir = DiagDirToDiagTrackdir(enterdir);
AyStarUserData user = { v->owner, TRANSPORT_ROAD, INVALID_RAILTYPES, v->compatible_roadtypes };
AyStarUserData user = { v->owner, TRANSPORT_ROAD, RAILTYPES_NONE, v->compatible_roadtypes };
NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, true, &fstd, &user);
assert(ftd.best_trackdir != INVALID_TRACKDIR);
@ -1170,7 +1170,7 @@ Track NPFShipChooseTrack(const Ship *v, bool &path_found)
NPFFillWithOrderData(&fstd, v);
AyStarUserData user = { v->owner, TRANSPORT_WATER, INVALID_RAILTYPES, ROADTYPES_NONE };
AyStarUserData user = { v->owner, TRANSPORT_WATER, RAILTYPES_NONE, ROADTYPES_NONE };
NPFFoundTargetData ftd = NPFRouteToStationOrTile(v->tile, trackdir, true, &fstd, &user);
/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
@ -1194,7 +1194,7 @@ bool NPFShipCheckReverse(const Ship *v)
assert(trackdir != INVALID_TRACKDIR);
assert(trackdir_rev != INVALID_TRACKDIR);
AyStarUserData user = { v->owner, TRANSPORT_WATER, INVALID_RAILTYPES, ROADTYPES_NONE };
AyStarUserData user = { v->owner, TRANSPORT_WATER, RAILTYPES_NONE, ROADTYPES_NONE };
ftd = NPFRouteToStationOrTileTwoWay(v->tile, trackdir, false, v->tile, trackdir_rev, false, &fstd, &user);
/* If we didn't find anything, just keep on going straight ahead, otherwise take the reverse flag */
return ftd.best_bird_dist == 0 && NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE);

@ -409,9 +409,7 @@ public:
while (pNode->m_parent != nullptr) {
steps--;
if (pNode->GetIsChoice() && steps < YAPF_ROADVEH_PATH_CACHE_SEGMENTS) {
TrackdirByte td;
td = pNode->GetTrackdir();
path_cache.td.push_front(td);
path_cache.td.push_front(pNode->GetTrackdir());
path_cache.tile.push_front(pNode->GetTile());
}
pNode = pNode->m_parent;

@ -96,9 +96,7 @@ public:
while (pNode->m_parent != nullptr) {
steps--;
if (steps > 0 && steps < YAPF_SHIP_PATH_CACHE_LENGTH) {
TrackdirByte td;
td = pNode->GetTrackdir();
path_cache.push_front(td);
path_cache.push_front(pNode->GetTrackdir());
}
pPrevNode = pNode;
pNode = pNode->m_parent;

@ -158,7 +158,7 @@ struct PlanLine {
};
struct Plan : PlanPool::PoolItem<&_plan_pool> {
OwnerByte owner;
Owner owner;
PlanLineVector lines;
PlanLine *temp_line;
bool visible;

@ -982,7 +982,7 @@ bool FloodHalftile(TileIndex t)
TrackBits to_remove = lower_track & rail_bits;
if (to_remove != 0) {
Backup<CompanyByte> cur_company(_current_company, OWNER_WATER, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, OWNER_WATER, FILE_LINE);
flooded = DoCommand(t, 0, FIND_FIRST_BIT(to_remove), DC_EXEC, CMD_REMOVE_SINGLE_RAIL).Succeeded();
cur_company.Restore();
if (!flooded) return flooded; // not yet floodable

@ -490,6 +490,7 @@ struct BuildRailToolbarWindow : Window {
~BuildRailToolbarWindow()
{
if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) SetViewportCatchmentStation(nullptr, true);
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
}
@ -855,6 +856,8 @@ struct BuildRailToolbarWindow : Window {
void OnPlaceObjectAbort() override
{
if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) SetViewportCatchmentStation(nullptr, true);
this->RaiseButtons();
this->DisableWidget(WID_RAT_REMOVE);
this->SetWidgetDirty(WID_RAT_REMOVE);

@ -26,7 +26,7 @@ static const RailTypeLabel RAILTYPE_MAGLEV_LABEL = 'MGLV';
*
* This enumeration defines all 4 possible railtypes.
*/
enum RailType {
enum RailType : byte {
RAILTYPE_BEGIN = 0, ///< Used for iterations
RAILTYPE_RAIL = 0, ///< Standard non-electric rails
RAILTYPE_ELECTRIC = 1, ///< Electric rails
@ -44,7 +44,6 @@ enum RailType {
DECLARE_POSTFIX_INCREMENT(RailType)
/** Define basic enum properties */
template <> struct EnumPropsT<RailType> : MakeEnumPropsT<RailType, byte, RAILTYPE_BEGIN, RAILTYPE_END, INVALID_RAILTYPE, 6> {};
typedef TinyEnumT<RailType> RailTypeByte;
/**
* The different railtypes we support, but then a bitmask of them.

@ -327,6 +327,7 @@ struct BuildRoadToolbarWindow : Window {
~BuildRoadToolbarWindow()
{
if (_game_mode != GM_EDITOR && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
}
@ -545,6 +546,8 @@ struct BuildRoadToolbarWindow : Window {
void OnPlaceObjectAbort() override
{
if (_game_mode != GM_EDITOR && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
this->RaiseButtons();
this->SetWidgetsDisabledState(true,
WID_ROT_REMOVE,

@ -35,7 +35,7 @@ template <> struct EnumPropsT<RoadType> : MakeEnumPropsT<RoadType, byte, ROADTYP
* The different roadtypes we support, but then a bitmask of them
* @note currently only roadtypes with ROADTYPE_ROAD and ROADTYPE_TRAM are supported.
*/
enum RoadTypes {
enum RoadTypes : byte {
ROADTYPES_NONE = 0, ///< No roadtypes
ROADTYPES_ROAD = 1 << ROADTYPE_ROAD, ///< Road
ROADTYPES_TRAM = 1 << ROADTYPE_TRAM, ///< Trams
@ -45,7 +45,6 @@ enum RoadTypes {
};
DECLARE_ENUM_AS_BIT_SET(RoadTypes)
template <> struct EnumPropsT<RoadTypes> : MakeEnumPropsT<RoadTypes, byte, ROADTYPES_NONE, ROADTYPES_END, INVALID_ROADTYPES, 2> {};
typedef SimpleTinyEnumT<RoadTypes, byte> RoadTypesByte;
/**

@ -84,7 +84,7 @@ void RoadVehUpdateCache(RoadVehicle *v, bool same_length = false);
void GetRoadVehSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
struct RoadVehPathCache {
std::deque<TrackdirByte> td;
std::deque<Trackdir> td;
std::deque<TileIndex> tile;
uint32 layout_ctr;

@ -1200,7 +1200,7 @@ static Trackdir FollowPreviousRoadVehicle(const RoadVehicle *v, const RoadVehicl
static bool CanBuildTramTrackOnTile(CompanyID c, TileIndex t, RoadBits r)
{
/* The 'current' company is not necessarily the owner of the vehicle. */
Backup<CompanyByte> cur_company(_current_company, c, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, c, FILE_LINE);
CommandCost ret = DoCommand(t, ROADTYPE_TRAM << 4 | r, 0, DC_NO_WATER, CMD_BUILD_ROAD);

@ -2038,7 +2038,7 @@ bool AfterLoadGame()
if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
Owner o = GetTileOwner(t);
if (o < MAX_COMPANIES && !Company::IsValidID(o)) {
Backup<CompanyByte> cur_company(_current_company, o, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, o, FILE_LINE);
ChangeTileOwner(t, o, INVALID_OWNER);
cur_company.Restore();
}
@ -2339,7 +2339,7 @@ bool AfterLoadGame()
_settings_game.economy.town_layout = TL_BETTER_ROADS;
} else {
_settings_game.economy.allow_town_roads = true;
_settings_game.economy.town_layout = _settings_game.economy.town_layout - 1;
_settings_game.economy.town_layout = static_cast<TownLayout>(_settings_game.economy.town_layout - 1);
}
/* Initialize layout of all towns. Older versions were using different
@ -2358,7 +2358,7 @@ bool AfterLoadGame()
case 5: layout = 1; break;
case 0: layout = 2; break;
}
t->layout = layout - 1;
t->layout = static_cast<TownLayout>(layout - 1);
}
}
@ -3083,7 +3083,7 @@ bool AfterLoadGame()
if (IsSavegameVersionBefore(SLV_165)) {
/* Adjust zoom level to account for new levels */
_saved_scrollpos_zoom = _saved_scrollpos_zoom + ZOOM_LVL_SHIFT;
_saved_scrollpos_zoom = static_cast<ZoomLevel>(_saved_scrollpos_zoom + ZOOM_LVL_SHIFT);
_saved_scrollpos_x *= ZOOM_LVL_BASE;
_saved_scrollpos_y *= ZOOM_LVL_BASE;
}

@ -31,7 +31,7 @@ extern byte _trees_tick_ctr;
/* Keep track of current game position */
int _saved_scrollpos_x;
int _saved_scrollpos_y;
ZoomLevelByte _saved_scrollpos_zoom;
ZoomLevel _saved_scrollpos_zoom;
void SaveViewportBeforeSaveGame()
{

@ -315,7 +315,7 @@ bool LoadOldSaveGame(const char *file)
return false;
}
_pause_mode = 2;
_pause_mode = PM_PAUSED_SAVELOAD;
return true;
}

@ -1276,7 +1276,8 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
};
if (v->spritenum / 2 >= lengthof(spriteset_rail)) return false;
v->spritenum = spriteset_rail[v->spritenum / 2]; // adjust railway sprite set offset
Train::From(v)->railtype = type == 0x25 ? 1 : 0; // monorail / rail
/* Should be the original values for monorail / rail, can't use RailType constants */
Train::From(v)->railtype = static_cast<RailType>(type == 0x25 ? 1 : 0);
break;
}

@ -3169,36 +3169,3 @@ void FileToSaveLoad::SetTitle(const char *title)
{
strecpy(this->title, title, lastof(this->title));
}
#if 0
/**
* Function to get the type of the savegame by looking at the file header.
* NOTICE: Not used right now, but could be used if extensions of savegames are garbled
* @param file Savegame to be checked
* @return SL_OLD_LOAD or SL_LOAD of the file
*/
int GetSavegameType(char *file)
{
const SaveLoadFormat *fmt;
uint32 hdr;
FILE *f;
int mode = SL_OLD_LOAD;
f = fopen(file, "rb");
if (fread(&hdr, sizeof(hdr), 1, f) != 1) {
DEBUG(sl, 0, "Savegame is obsolete or invalid format");
mode = SL_LOAD; // don't try to get filename, just show name as it is written
} else {
/* see if we have any loader for this type. */
for (fmt = _saveload_formats; fmt != endof(_saveload_formats); fmt++) {
if (fmt->tag == hdr) {
mode = SL_LOAD; // new type of savegame
break;
}
}
}
fclose(f);
return mode;
}
#endif

@ -53,7 +53,7 @@ void AfterLoadTemplateVehiclesUpdateImage();
extern int32 _saved_scrollpos_x;
extern int32 _saved_scrollpos_y;
extern ZoomLevelByte _saved_scrollpos_zoom;
extern ZoomLevel _saved_scrollpos_zoom;
extern SavegameType _savegame_type;
extern uint32 _ttdp_version;

@ -120,7 +120,7 @@ void AfterLoadTemplateVehiclesUpdateImage()
FOR_ALL_TEMPLATES(tv) {
if (tv->Prev() == nullptr) {
Backup<CompanyByte> cur_company(_current_company, tv->owner, FILE_LINE);
Backup<CompanyID> cur_company(_current_company, tv->owner, FILE_LINE);
StringID err;
Train* t = VirtualTrainFromTemplateVehicle(tv, err);
if (t != nullptr) {

@ -36,7 +36,7 @@ struct OldWaypoint {
uint8 localidx;
uint32 grfid;
const StationSpec *spec;
OwnerByte owner;
Owner owner;
size_t new_index;
};

@ -638,6 +638,7 @@ void SQGSWindow_Register(Squirrel *engine)
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_A_WEBSITE, "WID_A_WEBSITE");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_CAPTION, "WID_QS_CAPTION");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_TEXT, "WID_QS_TEXT");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_WARNING, "WID_QS_WARNING");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_DEFAULT, "WID_QS_DEFAULT");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_CANCEL, "WID_QS_CANCEL");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_OK, "WID_QS_OK");
@ -782,6 +783,7 @@ void SQGSWindow_Register(Squirrel *engine)
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_LABEL, "WID_NCP_LABEL");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_PASSWORD, "WID_NCP_PASSWORD");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_SAVE_AS_DEFAULT_PASSWORD, "WID_NCP_SAVE_AS_DEFAULT_PASSWORD");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_WARNING, "WID_NCP_WARNING");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_CANCEL, "WID_NCP_CANCEL");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_OK, "WID_NCP_OK");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NGRFI_CAPTION, "WID_NGRFI_CAPTION");
@ -1118,6 +1120,7 @@ void SQGSWindow_Register(Squirrel *engine)
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_ROADVEHS, "WID_SV_ROADVEHS");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_SHIPS, "WID_SV_SHIPS");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_PLANES, "WID_SV_PLANES");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_CATCHMENT, "WID_SV_CATCHMENT");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_STL_CAPTION, "WID_STL_CAPTION");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_STL_LIST, "WID_STL_LIST");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_STL_SCROLLBAR, "WID_STL_SCROLLBAR");
@ -1262,6 +1265,7 @@ void SQGSWindow_Register(Squirrel *engine)
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TV_CENTER_VIEW, "WID_TV_CENTER_VIEW");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TV_SHOW_AUTHORITY, "WID_TV_SHOW_AUTHORITY");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TV_CHANGE_NAME, "WID_TV_CHANGE_NAME");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TV_CATCHMENT, "WID_TV_CATCHMENT");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TV_EXPAND, "WID_TV_EXPAND");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TV_DELETE, "WID_TV_DELETE");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TF_NEW_TOWN, "WID_TF_NEW_TOWN");

@ -20,7 +20,7 @@
/* static */ int32 ScriptCargoMonitor::GetTownDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
{
CompanyID cid = static_cast<CompanyID>(company);
if (cid < OWNER_BEGIN || cid >= MAX_COMPANIES) return -1;
if (cid >= MAX_COMPANIES) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
if (!::Town::IsValidID(town_id)) return -1;
@ -31,7 +31,7 @@
/* static */ int32 ScriptCargoMonitor::GetIndustryDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring)
{
CompanyID cid = static_cast<CompanyID>(company);
if (cid < OWNER_BEGIN || cid >= MAX_COMPANIES) return -1;
if (cid >= MAX_COMPANIES) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
if (!::Industry::IsValidID(industry_id)) return -1;
@ -42,7 +42,7 @@
/* static */ int32 ScriptCargoMonitor::GetTownPickupAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
{
CompanyID cid = static_cast<CompanyID>(company);
if (cid < OWNER_BEGIN || cid >= MAX_COMPANIES) return -1;
if (cid >= MAX_COMPANIES) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
if (!::Town::IsValidID(town_id)) return -1;
@ -53,7 +53,7 @@
/* static */ int32 ScriptCargoMonitor::GetIndustryPickupAmount(ScriptCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring)
{
CompanyID cid = static_cast<CompanyID>(company);
if (cid < OWNER_BEGIN || cid >= MAX_COMPANIES) return -1;
if (cid >= MAX_COMPANIES) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
if (!::Industry::IsValidID(industry_id)) return -1;

@ -68,7 +68,7 @@
/* static */ bool ScriptRail::IsRailTypeAvailable(RailType rail_type)
{
if ((::RailType)rail_type < RAILTYPE_BEGIN || (::RailType)rail_type >= RAILTYPE_END) return false;
if ((::RailType)rail_type >= RAILTYPE_END) return false;
return ScriptObject::GetCompany() == OWNER_DEITY || ::HasRailtypeAvail(ScriptObject::GetCompany(), (::RailType)rail_type);
}

@ -1622,6 +1622,7 @@ public:
enum QueryStringWidgets {
WID_QS_CAPTION = ::WID_QS_CAPTION, ///< Caption of the window.
WID_QS_TEXT = ::WID_QS_TEXT, ///< Text of the query.
WID_QS_WARNING = ::WID_QS_WARNING, ///< Warning label about password security
WID_QS_DEFAULT = ::WID_QS_DEFAULT, ///< Default button.
WID_QS_CANCEL = ::WID_QS_CANCEL, ///< Cancel button.
WID_QS_OK = ::WID_QS_OK, ///< OK button.
@ -1841,6 +1842,7 @@ public:
WID_NCP_LABEL = ::WID_NCP_LABEL, ///< Label in front of the password field.
WID_NCP_PASSWORD = ::WID_NCP_PASSWORD, ///< Input field for the password.
WID_NCP_SAVE_AS_DEFAULT_PASSWORD = ::WID_NCP_SAVE_AS_DEFAULT_PASSWORD, ///< Toggle 'button' for saving the current password as default password.
WID_NCP_WARNING = ::WID_NCP_WARNING, ///< Warning text about password security
WID_NCP_CANCEL = ::WID_NCP_CANCEL, ///< Close the window without changing anything.
WID_NCP_OK = ::WID_NCP_OK, ///< Safe the password etc.
};
@ -2328,6 +2330,7 @@ public:
WID_SV_ROADVEHS = ::WID_SV_ROADVEHS, ///< List of scheduled road vehs button.
WID_SV_SHIPS = ::WID_SV_SHIPS, ///< List of scheduled ships button.
WID_SV_PLANES = ::WID_SV_PLANES, ///< List of scheduled planes button.
WID_SV_CATCHMENT = ::WID_SV_CATCHMENT, ///< Toggle catchment area highlight.
};
/** Widgets of the #CompanyStationsWindow class. */
@ -2539,6 +2542,7 @@ public:
WID_TV_CENTER_VIEW = ::WID_TV_CENTER_VIEW, ///< Center the main view on this town.
WID_TV_SHOW_AUTHORITY = ::WID_TV_SHOW_AUTHORITY, ///< Show the town authority window.
WID_TV_CHANGE_NAME = ::WID_TV_CHANGE_NAME, ///< Change the name of this town.
WID_TV_CATCHMENT = ::WID_TV_CATCHMENT, ///< Toggle catchment area highlight.
WID_TV_EXPAND = ::WID_TV_EXPAND, ///< Expand this town (scenario editor only).
WID_TV_DELETE = ::WID_TV_DELETE, ///< Delete this town (scenario editor only).
};

@ -37,6 +37,7 @@
#include "stringfilter_type.h"
#include "querystring_gui.h"
#include "fontcache.h"
#include "zoom_func.h"
#include <vector>
@ -543,6 +544,7 @@ struct GameOptionsWindow : Window {
_gui_zoom = (ZoomLevel)(ZOOM_LVL_OUT_4X - index);
UpdateCursorSize();
UpdateAllVirtCoords();
FixTitleGameZoom();
ReInitAllWindows();
break;

@ -20,7 +20,7 @@
* @see VarTypes
* @see SettingDescBase
*/
enum SettingDescTypeLong {
enum SettingDescType : byte {
/* 4 bytes allocated a maximum of 16 types for GenericType */
SDT_BEGIN = 0,
SDT_NUMX = 0, ///< any number-type
@ -32,10 +32,9 @@ enum SettingDescTypeLong {
SDT_END,
/* 10 more possible primitives */
};
typedef SimpleTinyEnumT<SettingDescTypeLong, byte> SettingDescType;
enum SettingGuiFlagLong {
enum SettingGuiFlag : uint16 {
/* 1 byte allocated for a maximum of 8 flags
* Flags directing saving/loading of a variable */
SGF_NONE = 0,
@ -52,8 +51,7 @@ enum SettingGuiFlagLong {
SGF_ENUM = 1 << 10,///< the setting can take one of the values given by an array of struct SettingDescEnumEntry
SGF_NO_NEWGAME = 1 << 11,///< the setting does not apply and is not shown in a new game context
};
DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong)
typedef SimpleTinyEnumT<SettingGuiFlagLong, uint16> SettingGuiFlag;
DECLARE_ENUM_AS_BIT_SET(SettingGuiFlag)
/**
* A SettingCategory defines a grouping of the settings.

@ -108,8 +108,8 @@ struct GUISettings {
uint8 statusbar_pos; ///< position of statusbar, 0=left, 1=center, 2=right
uint8 window_snap_radius; ///< windows snap at each other if closer than this
uint8 window_soft_limit; ///< soft limit of maximum number of non-stickied non-vital windows (0 = no limit)
ZoomLevelByte zoom_min; ///< minimum zoom out level
ZoomLevelByte zoom_max; ///< maximum zoom out level
ZoomLevel zoom_min; ///< minimum zoom out level
ZoomLevel zoom_max; ///< maximum zoom out level
bool disable_unsuitable_building; ///< disable infrastructure building when no suitable vehicles are available
byte autosave; ///< how often should we do autosaves?
bool threaded_saves; ///< should we do threaded saves?
@ -563,11 +563,11 @@ struct EconomySettings {
uint8 town_growth_cargo_transported; ///< percentage of town growth rate which depends on proportion of transported cargo in the last month
uint8 larger_towns; ///< the number of cities to build. These start off larger and grow twice as fast
uint8 initial_city_size; ///< multiplier for the initial size of the cities compared to towns
TownLayoutByte town_layout; ///< select town layout, @see TownLayout
TownLayout town_layout; ///< select town layout, @see TownLayout
TownCargoGenMode town_cargogen_mode; ///< algorithm for generating cargo from houses, @see TownCargoGenMode
bool allow_town_roads; ///< towns are allowed to build roads (always allowed when generating world / in SE)
uint16 town_min_distance; ///< minimum distance between towns
TownFoundingByte found_town; ///< town founding, @see TownFounding
TownFounding found_town; ///< town founding.
bool station_noise_level; ///< build new airports when the town noise level is still within accepted limits
uint16 town_noise_population[3]; ///< population to base decision on noise evaluation (@see town_council_tolerance)
bool infrastructure_sharing[4]; ///< enable infrastructure sharing for rail/road/water/air

@ -22,17 +22,17 @@ extern const DiagDirection _ship_search_directions[TRACK_END][DIAGDIR_END];
void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
WaterClass GetEffectiveWaterClass(TileIndex tile);
typedef std::deque<TrackdirByte> ShipPathCache;
typedef std::deque<Trackdir> ShipPathCache;
/**
* All ships have this type.
*/
struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
TrackBitsByte state; ///< The "track" the ship is following.
ShipPathCache path; ///< Cached path.
DirectionByte rotation; ///< Visible direction.
int16 rotation_x_pos; ///< NOSAVE: X Position before rotation.
int16 rotation_y_pos; ///< NOSAVE: Y Position before rotation.
TrackBits state; ///< The "track" the ship is following.
ShipPathCache path; ///< Cached path.
Direction rotation; ///< Visible direction.
int16 rotation_x_pos; ///< NOSAVE: X Position before rotation.
int16 rotation_y_pos; ///< NOSAVE: Y Position before rotation.
/** We don't want GCC to zero our struct! It already is zeroed and has an index! */
Ship() : SpecializedVehicleBase() {}

@ -26,7 +26,7 @@ struct Sign : SignPool::PoolItem<&_sign_pool> {
int32 x;
int32 y;
int32 z;
OwnerByte owner; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games.
Owner owner; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games.
Sign(Owner owner = INVALID_OWNER);
~Sign();

@ -472,7 +472,7 @@ static void NotifyAllViewports(ViewportMapType map_type)
}
}
/** Vehicle colours in #SMT_VEHICLES mode. Indexed by #VehicleTypeByte. */
/** Vehicle colours in #SMT_VEHICLES mode. Indexed by #VehicleType. */
static const byte _vehicle_type_colours[6] = {
PC_RED, PC_YELLOW, PC_LIGHT_BLUE, PC_WHITE, PC_BLACK, PC_RED
};

@ -36,8 +36,6 @@
/* Default of 4MB spritecache */
uint _sprite_cache_size = 4;
typedef SimpleTinyEnumT<SpriteType, byte> SpriteTypeByte;
static size_t _spritecache_bytes_used = 0;
PACK_N(class SpriteDataBuffer {

@ -315,7 +315,7 @@ struct Airport : public TileArea {
uint64 flags; ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32
byte type; ///< Type of this airport, @see AirportTypes
byte layout; ///< Airport layout number.
DirectionByte rotation; ///< How this airport is rotated.
Direction rotation; ///< How this airport is rotated.
PersistentStorage *psa; ///< Persistent storage for NewGRF airports.
@ -476,7 +476,7 @@ public:
BitmapTileArea catchment_tiles; ///< NOSAVE: Set of individual tiles covered by catchment area
StationHadVehicleOfTypeByte had_vehicle_of_type;
StationHadVehicleOfType had_vehicle_of_type;
byte time_since_load;
byte time_since_unload;

@ -83,6 +83,46 @@ int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageTyp
return DrawStringMultiLine(left, right, top, INT32_MAX, supplies ? STR_STATION_BUILD_SUPPLIES_CARGO : STR_STATION_BUILD_ACCEPTS_CARGO);
}
/**
* Find stations adjacent to the current tile highlight area, so that existing coverage
* area can be drawn.
*/
static void FindStationsAroundSelection()
{
/* With distant join we don't know which station will be selected, so don't show any */
if (_ctrl_pressed) {
SetViewportCatchmentStation(nullptr, true);
return;
}
/* Tile area for TileHighlightData */
TileArea location(TileVirtXY(_thd.pos.x, _thd.pos.y), _thd.size.x / TILE_SIZE - 1, _thd.size.y / TILE_SIZE - 1);
/* Extended area by one tile */
uint x = TileX(location.tile);
uint y = TileY(location.tile);
int max_c = 1;
TileArea ta(TileXY(max<int>(0, x - max_c), max<int>(0, y - max_c)), TileXY(min<int>(MapMaxX(), x + location.w + max_c), min<int>(MapMaxY(), y + location.h + max_c)));
Station *adjacent = nullptr;
/* Direct loop instead of FindStationsAroundTiles as we are not interested in catchment area */
TILE_AREA_LOOP(tile, ta) {
if (IsTileType(tile, MP_STATION) && GetTileOwner(tile) == _local_company) {
Station *st = Station::GetByTile(tile);
if (st == nullptr) continue;
if (adjacent != nullptr && st != adjacent) {
/* Multiple nearby, distant join is required. */
adjacent = nullptr;
break;
}
adjacent = st;
}
}
SetViewportCatchmentStation(adjacent, true);
}
/**
* Check whether we need to redraw the station coverage text.
* If it is needed actually make the window for redrawing.
@ -90,9 +130,20 @@ int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageTyp
*/
void CheckRedrawStationCoverage(const Window *w)
{
/* Test if ctrl state changed */
static bool _last_ctrl_pressed;
if (_ctrl_pressed != _last_ctrl_pressed) {
_thd.dirty = 0xff;
_last_ctrl_pressed = _ctrl_pressed;
}
if (_thd.dirty & 1) {
_thd.dirty &= ~1;
w->SetDirty();
if (_settings_client.gui.station_show_coverage && _thd.drawstyle == HT_RECT) {
FindStationsAroundSelection();
}
}
}
@ -779,6 +830,7 @@ static const NWidgetPart _nested_station_view_widgets[] = {
EndContainer(),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SV_CLOSE_AIRPORT), SetMinimalSize(45, 12), SetResize(1, 0), SetFill(1, 1),
SetDataTip(STR_STATION_VIEW_CLOSE_AIRPORT, STR_STATION_VIEW_CLOSE_AIRPORT_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SV_CATCHMENT), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_BUTTON_CATCHMENT, STR_TOOLTIP_CATCHMENT),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SV_TRAINS), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_TRAIN, STR_STATION_VIEW_SCHEDULED_TRAINS_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SV_ROADVEHS), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_LORRY, STR_STATION_VIEW_SCHEDULED_ROAD_VEHICLES_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SV_SHIPS), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_SHIP, STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP),
@ -1301,6 +1353,8 @@ struct StationViewWindow : public Window {
DeleteWindowById(WC_ROADVEH_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_ROAD, this->owner, this->window_number).Pack(), false);
DeleteWindowById(WC_SHIPS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_SHIP, this->owner, this->window_number).Pack(), false);
DeleteWindowById(WC_AIRCRAFT_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_AIRCRAFT, this->owner, this->window_number).Pack(), false);
SetViewportCatchmentStation(Station::Get(this->window_number), false);
}
/**
@ -1396,6 +1450,10 @@ struct StationViewWindow : public Window {
this->SetWidgetDisabledState(WID_SV_CLOSE_AIRPORT, !(st->facilities & FACIL_AIRPORT) || st->owner != _local_company || st->owner == OWNER_NONE); // Also consider SE, where _local_company == OWNER_NONE
this->SetWidgetLoweredState(WID_SV_CLOSE_AIRPORT, (st->facilities & FACIL_AIRPORT) && (st->airport.flags & AIRPORT_CLOSED_block) != 0);
extern const Station *_viewport_highlight_station;
this->SetWidgetDisabledState(WID_SV_CATCHMENT, st->facilities == FACIL_NONE);
this->SetWidgetLoweredState(WID_SV_CATCHMENT, _viewport_highlight_station == st);
this->DrawWidgets();
if (!this->IsShaded()) {
@ -1877,6 +1935,10 @@ struct StationViewWindow : public Window {
this->HandleCargoWaitingClick(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SV_WAITING, WD_FRAMERECT_TOP, FONT_HEIGHT_NORMAL) - this->vscroll->GetPosition());
break;
case WID_SV_CATCHMENT:
SetViewportCatchmentStation(Station::Get(this->window_number), !this->IsWidgetLowered(WID_SV_CATCHMENT));
break;
case WID_SV_LOCATION:
if (_ctrl_pressed) {
ShowExtraViewPortWindow(Station::Get(this->window_number)->xy);
@ -2254,6 +2316,15 @@ struct SelectStationWindow : Window {
this->GetWidget<NWidgetCore>(WID_JS_CAPTION)->widget_data = T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CAPTION : STR_JOIN_STATION_CAPTION;
this->FinishInitNested(0);
this->OnInvalidateData(0);
_thd.freeze = true;
}
~SelectStationWindow()
{
if (_settings_client.gui.station_show_coverage) SetViewportCatchmentStation(nullptr, true);
_thd.freeze = false;
}
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
@ -2343,6 +2414,23 @@ struct SelectStationWindow : Window {
this->vscroll->SetCount((uint)_stations_nearby_list.size() + 1);
this->SetDirty();
}
void OnMouseOver(Point pt, int widget) override
{
if (widget != WID_JS_PANEL || T::EXPECTED_FACIL == FACIL_WAYPOINT) {
SetViewportCatchmentStation(nullptr, true);
return;
}
/* Show coverage area of station under cursor */
uint st_index = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_JS_PANEL, WD_FRAMERECT_TOP);
if (st_index == 0 || st_index > _stations_nearby_list.size()) {
SetViewportCatchmentStation(nullptr, true);
} else {
st_index--;
SetViewportCatchmentStation(Station::Get(_stations_nearby_list[st_index]), true);
}
}
};
static WindowDesc _select_station_desc(

@ -51,7 +51,7 @@ enum RoadStopType {
};
/** The facilities a station might be having */
enum StationFacility {
enum StationFacility : byte {
FACIL_NONE = 0, ///< The station has no facilities at all
FACIL_TRAIN = 1 << 0, ///< Station with train station
FACIL_TRUCK_STOP = 1 << 1, ///< Station with truck stops
@ -61,10 +61,9 @@ enum StationFacility {
FACIL_WAYPOINT = 1 << 7, ///< Station is a waypoint
};
DECLARE_ENUM_AS_BIT_SET(StationFacility)
typedef SimpleTinyEnumT<StationFacility, byte> StationFacilityByte;
/** The vehicles that may have visited a station */
enum StationHadVehicleOfType {
enum StationHadVehicleOfType : byte {
HVOT_NONE = 0, ///< Station has seen no vehicles
HVOT_TRAIN = 1 << 1, ///< Station has seen a train
HVOT_BUS = 1 << 2, ///< Station has seen a bus
@ -75,7 +74,6 @@ enum StationHadVehicleOfType {
HVOT_WAYPOINT = 1 << 6, ///< Station is a waypoint (NewGRF only!)
};
DECLARE_ENUM_AS_BIT_SET(StationHadVehicleOfType)
typedef SimpleTinyEnumT<StationHadVehicleOfType, byte> StationHadVehicleOfTypeByte;
/** The different catchment areas used */
enum CatchmentArea {

@ -27,6 +27,7 @@
#include "toolbar_gui.h"
#include "core/geometry_func.hpp"
#include "guitimer_func.h"
#include "zoom_func.h"
#include "widgets/statusbar_widget.h"
@ -167,7 +168,7 @@ struct StatusBarWindow : Window {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, msg, TC_FROMSTRING, SA_HOR_CENTER);
} else if (this->ticker_scroll < TICKER_STOP && FindWindowById(WC_NEWS_WINDOW, 0) == nullptr && _statusbar_news_item != nullptr && _statusbar_news_item->string_id != 0) {
/* Draw the scrolling news text */
if (!DrawScrollingStatusText(_statusbar_news_item, this->ticker_scroll, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom)) {
if (!DrawScrollingStatusText(_statusbar_news_item, ScaleGUITrad(this->ticker_scroll), r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom)) {
InvalidateWindowData(WC_STATUS_BAR, 0, SBI_NEWS_DELETED);
if (Company::IsValidID(_local_company)) {
/* This is the default text */

@ -280,17 +280,17 @@
/* MSVCRT of course has to have a different syntax for long long *sigh* */
#if defined(_MSC_VER) || defined(__MINGW32__)
#define OTTD_PRINTF64 "%I64d"
#define OTTD_PRINTF64U "%I64u"
#define OTTD_PRINTFHEX64 "%I64x"
#define PRINTF_SIZE "%Iu"
#define PRINTF_SIZEX "%IX"
# define OTTD_PRINTF64 "%I64d"
# define OTTD_PRINTF64U "%I64u"
# define OTTD_PRINTFHEX64 "%I64x"
# define PRINTF_SIZE "%Iu"
# define PRINTF_SIZEX "%IX"
#else
#define OTTD_PRINTF64 "%lld"
#define OTTD_PRINTF64U "%llu"
#define OTTD_PRINTFHEX64 "%llx"
#define PRINTF_SIZE "%zu"
#define PRINTF_SIZEX "%zX"
# define OTTD_PRINTF64 "%lld"
# define OTTD_PRINTF64U "%llu"
# define OTTD_PRINTFHEX64 "%llx"
# define PRINTF_SIZE "%zu"
# define PRINTF_SIZEX "%zX"
#endif
typedef unsigned char byte;

@ -27,7 +27,7 @@ extern uint32 _story_page_next_sort_value;
/*
* Each story page element is one of these types.
*/
enum StoryPageElementType {
enum StoryPageElementType : byte {
SPET_TEXT = 0, ///< A text element.
SPET_LOCATION, ///< An element that references a tile along with a one-line text.
SPET_GOAL, ///< An element that references a goal.
@ -37,7 +37,6 @@ enum StoryPageElementType {
/** Define basic enum properties */
template <> struct EnumPropsT<StoryPageElementType> : MakeEnumPropsT<StoryPageElementType, byte, SPET_TEXT, SPET_END, INVALID_SPET, 8> {};
typedef TinyEnumT<StoryPageElementType> StoryPageElementTypeByte; ///< typedefing-enumification of Direction
/**
* Struct about story page elements.
@ -47,7 +46,7 @@ typedef TinyEnumT<StoryPageElementType> StoryPageElementTypeByte; ///< typedefin
struct StoryPageElement : StoryPageElementPool::PoolItem<&_story_page_element_pool> {
uint32 sort_value; ///< A number that increases for every created story page element. Used for sorting. The id of a story page element is the pool index.
StoryPageID page; ///< Id of the page which the page element belongs to
StoryPageElementTypeByte type; ///< Type of page element
StoryPageElementType type; ///< Type of page element
uint32 referenced_id; ///< Id of referenced object (location, goal etc.)
char *text; ///< Static content text of page element
@ -70,7 +69,7 @@ struct StoryPageElement : StoryPageElementPool::PoolItem<&_story_page_element_po
struct StoryPage : StoryPagePool::PoolItem<&_story_page_pool> {
uint32 sort_value; ///< A number that increases for every created story page. Used for sorting. The id of a story page is the pool index.
Date date; ///< Date when the page was created.
CompanyByte company; ///< StoryPage is for a specific company; INVALID_COMPANY if it is global
CompanyID company; ///< StoryPage is for a specific company; INVALID_COMPANY if it is global
char *title; ///< Title of story page

@ -22,13 +22,13 @@ extern SubsidyPool _subsidy_pool;
/** Struct about subsidies, offered and awarded */
struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
CargoID cargo_type; ///< Cargo type involved in this subsidy, CT_INVALID for invalid subsidy
byte remaining; ///< Remaining months when this subsidy is valid
CompanyByte awarded; ///< Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone
SourceTypeByte src_type; ///< Source of subsidised path (ST_INDUSTRY or ST_TOWN)
SourceTypeByte dst_type; ///< Destination of subsidised path (ST_INDUSTRY or ST_TOWN)
SourceID src; ///< Index of source. Either TownID or IndustryID
SourceID dst; ///< Index of destination. Either TownID or IndustryID
CargoID cargo_type; ///< Cargo type involved in this subsidy, CT_INVALID for invalid subsidy
byte remaining; ///< Remaining months when this subsidy is valid
CompanyID awarded; ///< Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone
SourceType src_type; ///< Source of subsidised path (ST_INDUSTRY or ST_TOWN)
SourceType dst_type; ///< Destination of subsidised path (ST_INDUSTRY or ST_TOWN)
SourceID src; ///< Index of source. Either TownID or IndustryID
SourceID dst; ///< Index of destination. Either TownID or IndustryID
/**
* We need an (empty) constructor so struct isn't zeroed (as C++ standard states)

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save