mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-23 12:14:11 +01:00
Codechange: strongly type StationID
This commit is contained in:
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
class ScriptBaseStation : public ScriptObject {
|
||||
public:
|
||||
static const StationID STATION_NEW = ::NEW_STATION; ///< Build a new station
|
||||
static const StationID STATION_JOIN_ADJACENT = ::ADJACENT_STATION; ///< Join an neighbouring station if one exists
|
||||
static const StationID STATION_INVALID = ::INVALID_STATION; ///< Invalid station id.
|
||||
static constexpr StationID STATION_NEW = ::NEW_STATION; ///< Build a new station
|
||||
static constexpr StationID STATION_JOIN_ADJACENT = ::ADJACENT_STATION; ///< Join an neighbouring station if one exists
|
||||
static constexpr StationID STATION_INVALID = ::INVALID_STATION; ///< Invalid station id.
|
||||
|
||||
/**
|
||||
* Checks whether the given basestation is valid and owned by you.
|
||||
|
||||
@@ -44,7 +44,7 @@ static NewsReference CreateReference(ScriptNews::NewsReferenceType ref_type, SQI
|
||||
EnforcePrecondition(false, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
|
||||
EnforcePrecondition(false, (ref_type == NR_NONE) ||
|
||||
(ref_type == NR_TILE && ScriptMap::IsValidTile(::TileIndex(reference))) ||
|
||||
(ref_type == NR_STATION && ScriptStation::IsValidStation(reference)) ||
|
||||
(ref_type == NR_STATION && ScriptStation::IsValidStation(static_cast<StationID>(reference))) ||
|
||||
(ref_type == NR_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast<IndustryID>(reference))) ||
|
||||
(ref_type == NR_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(reference))));
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
|
||||
#include "script_tile.hpp"
|
||||
#include "../squirrel_helper_type.hpp"
|
||||
#include "../../../road.h"
|
||||
#include "../../station_type.h"
|
||||
#include "../../road.h"
|
||||
|
||||
/**
|
||||
* Class that handles all road related functions.
|
||||
|
||||
@@ -35,7 +35,7 @@ ScriptStationList_Vehicle::ScriptStationList_Vehicle(VehicleID vehicle_id)
|
||||
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||
|
||||
for (Order *o = v->GetFirstOrder(); o != nullptr; o = o->next) {
|
||||
if (o->IsType(OT_GOTO_STATION)) this->AddItem(o->GetDestination().ToStationID());
|
||||
if (o->IsType(OT_GOTO_STATION)) this->AddItem(o->GetDestination().ToStationID().base());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,11 +137,11 @@ CargoCollector::~CargoCollector()
|
||||
void CargoCollector::SetValue()
|
||||
{
|
||||
if (this->amount > 0) {
|
||||
if (this->list->HasItem(this->last_key)) {
|
||||
this->list->SetValue(this->last_key,
|
||||
this->list->GetValue(this->last_key) + this->amount);
|
||||
if (this->list->HasItem(this->last_key.base())) {
|
||||
this->list->SetValue(this->last_key.base(),
|
||||
this->list->GetValue(this->last_key.base()) + this->amount);
|
||||
} else {
|
||||
this->list->AddItem(this->last_key, this->amount);
|
||||
this->list->AddItem(this->last_key.base(), this->amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,6 @@ ScriptWaypointList_Vehicle::ScriptWaypointList_Vehicle(VehicleID vehicle_id)
|
||||
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||
|
||||
for (const Order *o = v->GetFirstOrder(); o != nullptr; o = o->next) {
|
||||
if (o->IsType(OT_GOTO_WAYPOINT)) this->AddItem(o->GetDestination().ToStationID());
|
||||
if (o->IsType(OT_GOTO_WAYPOINT)) this->AddItem(o->GetDestination().ToStationID().base());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user