(svn r16736) -Codechange: give some station enums a name and use that instead of 'byte'.

pull/155/head
rubidium 15 years ago
parent e56535fda5
commit c5a44ce99e

@ -145,6 +145,20 @@ struct SimpleTinyEnumT {
this->m_val = (storage_type)u;
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 */

@ -112,7 +112,7 @@ Money CalculateCompanyValue(const Company *c)
uint num = 0;
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;
@ -184,7 +184,7 @@ int UpdateCompanyRatingAndValue(Company *c, bool update)
const Station *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;
}

@ -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
* 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) {
xy = facil_xy;

@ -110,13 +110,13 @@ public:
ViewportSign sign;
byte had_vehicle_of_type;
StationHadVehicleOfTypeByte had_vehicle_of_type;
byte time_since_load;
byte time_since_unload;
byte delete_ctr;
OwnerByte owner;
byte facilities;
StationFacilityByte facilities;
byte airport_type;
/* trainstation width/height */
@ -145,7 +145,7 @@ public:
Station(TileIndex tile = INVALID_TILE);
~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.

@ -5,6 +5,8 @@
#ifndef STATION_TYPE_H
#define STATION_TYPE_H
#include "core/enum_type.hpp"
typedef uint16 StationID;
typedef uint16 RoadStopID;
@ -32,15 +34,17 @@ enum RoadStopType {
ROADSTOP_TRUCK ///< A standard stop for trucks
};
enum {
enum StationFacility {
FACIL_TRAIN = 0x01,
FACIL_TRUCK_STOP = 0x02,
FACIL_BUS_STOP = 0x04,
FACIL_AIRPORT = 0x08,
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_TRAIN = 1 << 1,
HVOT_BUS = 1 << 2,
@ -51,6 +55,8 @@ enum {
* can we do? ;-) */
HVOT_BUOY = 1 << 6
};
DECLARE_ENUM_AS_BIT_SET(StationHadVehicleOfType);
typedef SimpleTinyEnumT<StationHadVehicleOfType, byte> StationHadVehicleOfTypeByte;
enum CatchmentArea {
CA_NONE = 0,

Loading…
Cancel
Save