mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
(svn r16736) -Codechange: give some station enums a name and use that instead of 'byte'.
This commit is contained in:
parent
65f77a7bee
commit
571dfb9055
@ -145,6 +145,20 @@ struct SimpleTinyEnumT {
|
|||||||
this->m_val = (storage_type)u;
|
this->m_val = (storage_type)u;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Bit math (or) assignment operator (from enum_type) */
|
||||||
|
FORCEINLINE 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) */
|
||||||
|
FORCEINLINE SimpleTinyEnumT &operator &= (enum_type e)
|
||||||
|
{
|
||||||
|
this->m_val = (storage_type)((enum_type)this->m_val & e);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* ENUM_TYPE_HPP */
|
#endif /* ENUM_TYPE_HPP */
|
||||||
|
@ -112,7 +112,7 @@ Money CalculateCompanyValue(const Company *c)
|
|||||||
uint num = 0;
|
uint num = 0;
|
||||||
|
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
if (st->owner == owner) num += CountBits(st->facilities);
|
if (st->owner == owner) num += CountBits((byte)st->facilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
value += num * _price.station_value * 25;
|
value += num * _price.station_value * 25;
|
||||||
@ -184,7 +184,7 @@ int UpdateCompanyRatingAndValue(Company *c, bool update)
|
|||||||
const Station *st;
|
const Station *st;
|
||||||
|
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
if (st->owner == owner) num += CountBits(st->facilities);
|
if (st->owner == owner) num += CountBits((byte)st->facilities);
|
||||||
}
|
}
|
||||||
_score_part[owner][SCORE_STATIONS] = num;
|
_score_part[owner][SCORE_STATIONS] = num;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ RoadStop *Station::GetPrimaryRoadStop(const RoadVehicle *v) const
|
|||||||
|
|
||||||
/** Called when new facility is built on the station. If it is the first facility
|
/** Called when new facility is built on the station. If it is the first facility
|
||||||
* it initializes also 'xy' and 'random_bits' members */
|
* it initializes also 'xy' and 'random_bits' members */
|
||||||
void Station::AddFacility(byte new_facility_bit, TileIndex facil_xy)
|
void Station::AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
|
||||||
{
|
{
|
||||||
if (facilities == 0) {
|
if (facilities == 0) {
|
||||||
xy = facil_xy;
|
xy = facil_xy;
|
||||||
|
@ -110,13 +110,13 @@ public:
|
|||||||
|
|
||||||
ViewportSign sign;
|
ViewportSign sign;
|
||||||
|
|
||||||
byte had_vehicle_of_type;
|
StationHadVehicleOfTypeByte had_vehicle_of_type;
|
||||||
|
|
||||||
byte time_since_load;
|
byte time_since_load;
|
||||||
byte time_since_unload;
|
byte time_since_unload;
|
||||||
byte delete_ctr;
|
byte delete_ctr;
|
||||||
OwnerByte owner;
|
OwnerByte owner;
|
||||||
byte facilities;
|
StationFacilityByte facilities;
|
||||||
byte airport_type;
|
byte airport_type;
|
||||||
|
|
||||||
/* trainstation width/height */
|
/* trainstation width/height */
|
||||||
@ -145,7 +145,7 @@ public:
|
|||||||
Station(TileIndex tile = INVALID_TILE);
|
Station(TileIndex tile = INVALID_TILE);
|
||||||
~Station();
|
~Station();
|
||||||
|
|
||||||
void AddFacility(byte new_facility_bit, TileIndex facil_xy);
|
void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark the sign of a station dirty for repaint.
|
* Mark the sign of a station dirty for repaint.
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#ifndef STATION_TYPE_H
|
#ifndef STATION_TYPE_H
|
||||||
#define STATION_TYPE_H
|
#define STATION_TYPE_H
|
||||||
|
|
||||||
|
#include "core/enum_type.hpp"
|
||||||
|
|
||||||
typedef uint16 StationID;
|
typedef uint16 StationID;
|
||||||
typedef uint16 RoadStopID;
|
typedef uint16 RoadStopID;
|
||||||
|
|
||||||
@ -32,15 +34,17 @@ enum RoadStopType {
|
|||||||
ROADSTOP_TRUCK ///< A standard stop for trucks
|
ROADSTOP_TRUCK ///< A standard stop for trucks
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum StationFacility {
|
||||||
FACIL_TRAIN = 0x01,
|
FACIL_TRAIN = 0x01,
|
||||||
FACIL_TRUCK_STOP = 0x02,
|
FACIL_TRUCK_STOP = 0x02,
|
||||||
FACIL_BUS_STOP = 0x04,
|
FACIL_BUS_STOP = 0x04,
|
||||||
FACIL_AIRPORT = 0x08,
|
FACIL_AIRPORT = 0x08,
|
||||||
FACIL_DOCK = 0x10,
|
FACIL_DOCK = 0x10,
|
||||||
};
|
};
|
||||||
|
DECLARE_ENUM_AS_BIT_SET(StationFacility);
|
||||||
|
typedef SimpleTinyEnumT<StationFacility, byte> StationFacilityByte;
|
||||||
|
|
||||||
enum {
|
enum StationHadVehicleOfType {
|
||||||
// HVOT_PENDING_DELETE = 1 << 0, // not needed anymore
|
// HVOT_PENDING_DELETE = 1 << 0, // not needed anymore
|
||||||
HVOT_TRAIN = 1 << 1,
|
HVOT_TRAIN = 1 << 1,
|
||||||
HVOT_BUS = 1 << 2,
|
HVOT_BUS = 1 << 2,
|
||||||
@ -51,6 +55,8 @@ enum {
|
|||||||
* can we do? ;-) */
|
* can we do? ;-) */
|
||||||
HVOT_BUOY = 1 << 6
|
HVOT_BUOY = 1 << 6
|
||||||
};
|
};
|
||||||
|
DECLARE_ENUM_AS_BIT_SET(StationHadVehicleOfType);
|
||||||
|
typedef SimpleTinyEnumT<StationHadVehicleOfType, byte> StationHadVehicleOfTypeByte;
|
||||||
|
|
||||||
enum CatchmentArea {
|
enum CatchmentArea {
|
||||||
CA_NONE = 0,
|
CA_NONE = 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user