--- a/src/station_cmd.cpp Mon Mar 19 09:33:17 2007 +0000
+++ b/src/station_cmd.cpp Mon Mar 19 12:38:16 2007 +0000
@@ -330,7 +330,7 @@
}
// Update the virtual coords needed to draw the station sign for all stations.
-void UpdateAllStationVirtCoord(void)
+void UpdateAllStationVirtCoord()
{
Station* st;
@@ -449,12 +449,12 @@
}
}
-typedef struct ottd_Rectangle {
+struct ottd_Rectangle {
uint min_x;
uint min_y;
uint max_x;
uint max_y;
-} ottd_Rectangle;
+};
static inline void MergePoint(ottd_Rectangle* rect, TileIndex tile)
{
@@ -529,8 +529,9 @@
uint amt = min(accepts[i], 15);
// Make sure the station can accept the goods type.
- if ((i != CT_PASSENGERS && !(st->facilities & (byte)~FACIL_BUS_STOP)) ||
- (i == CT_PASSENGERS && !(st->facilities & (byte)~FACIL_TRUCK_STOP)))
+ bool is_passengers = IsCargoInClass(i, CC_PASSENGERS);
+ if ((!is_passengers && !(st->facilities & (byte)~FACIL_BUS_STOP)) ||
+ (is_passengers && !(st->facilities & (byte)~FACIL_TRUCK_STOP)))
amt = 0;
SB(st->goods[i].waiting_acceptance, 12, 4, amt);
@@ -1401,7 +1402,7 @@
// Intercontinental Airport (vlarge) - 4 runways
static const byte _airport_sections_intercontinental[] = {
102, 120, 89, 89, 89, 89, 89, 89, 118,
- 120, 22, 22, 22, 22, 22, 22, 119, 117,
+ 120, 23, 23, 23, 23, 23, 23, 119, 117,
87, 54, 87, 8, 8, 8, 8, 51, 117,
87, 162, 87, 85, 116, 116, 8, 9, 10,
87, 8, 8, 11, 31, 11, 8, 160, 32,
@@ -1410,7 +1411,7 @@
87, 142, 8, 11, 29, 11, 10, 163, 10,
87, 164, 87, 8, 8, 8, 10, 37, 117,
87, 120, 89, 89, 89, 89, 89, 89, 119,
- 121, 22, 22, 22, 22, 22, 22, 119, 37
+ 121, 23, 23, 23, 23, 23, 23, 119, 37
};
@@ -1629,6 +1630,7 @@
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
if (!IsClearWaterTile(tile) || tile == 0) return_cmd_error(STR_304B_SITE_UNSUITABLE);
+ if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
/* allocate and initialize new station */
Station *st = new Station(tile);
@@ -1670,7 +1672,7 @@
{
const Vehicle *v;
FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_Ship) {
+ if (v->type == VEH_SHIP) {
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
if (order->type == OT_GOTO_STATION && order->dest == st->index) {
@@ -1748,6 +1750,8 @@
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR;
+ if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
+
cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(cost)) return CMD_ERROR;
@@ -1757,6 +1761,8 @@
return_cmd_error(STR_304B_SITE_UNSUITABLE);
}
+ if (MayHaveBridgeAbove(tile_cur) && IsBridgeAbove(tile_cur)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
+
cost = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(cost)) return CMD_ERROR;
@@ -2071,11 +2077,11 @@
static void AnimateTile_Station(TileIndex tile)
{
- typedef struct AnimData {
+ struct AnimData {
StationGfx from; // first sprite
StationGfx to; // last sprite
byte delay;
- } AnimData;
+ };
static const AnimData data[] = {
{ GFX_RADAR_LARGE_FIRST, GFX_RADAR_LARGE_LAST, 3 },
@@ -2103,7 +2109,7 @@
static void ClickTile_Station(TileIndex tile)
{
if (IsHangar(tile)) {
- ShowDepotWindow(tile, VEH_Aircraft);
+ ShowDepotWindow(tile, VEH_AIRCRAFT);
} else {
ShowStationViewWindow(GetStationIndex(tile));
}
@@ -2115,7 +2121,7 @@
static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
{
- if (v->type == VEH_Train) {
+ if (v->type == VEH_TRAIN) {
if (IsRailwayStation(tile) && IsFrontEngine(v) &&
!IsCompatibleTrainStationTile(tile + TileOffsByDiagDir(DirToDiagDir(v->direction)), tile)) {
StationID station_id = GetStationIndex(tile);
@@ -2145,7 +2151,7 @@
}
}
}
- } else if (v->type == VEH_Road) {
+ } else if (v->type == VEH_ROAD) {
if (v->u.road.state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)v->u.road.state) && v->u.road.frame == 0) {
if (IsRoadStop(tile)) {
/* Attempt to allocate a parking bay in a road stop */
@@ -2158,7 +2164,7 @@
if (!rs->IsFreeBay(side)) return VETSB_CANNOT_ENTER;
/* Check if the vehicle is stopping at this road stop */
- if (GetRoadStopType(tile) == ((v->cargo_type == CT_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK) &&
+ if (GetRoadStopType(tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK) &&
v->current_order.dest == GetStationIndex(tile)) {
SETBIT(v->u.road.state, RVS_IS_STOPPING);
rs->AllocateDriveThroughBay(side);
@@ -2210,6 +2216,12 @@
GoodsEntry *ge = st->goods;
do {
+ /* Slowly increase the rating back to his original level in the case we
+ * didn't deliver cargo yet to this station. This happens when a bribe
+ * failed while you didn't moved that cargo yet to a station. */
+ if (ge->enroute_from == INVALID_STATION && ge->rating < INITIAL_STATION_RATING)
+ ge->rating++;
+ /* Only change the rating if we are moving this cargo */
if (ge->enroute_from != INVALID_STATION) {
byte_inc_sat(&ge->enroute_time);
byte_inc_sat(&ge->days_since_pickup);
@@ -2234,7 +2246,7 @@
{
byte days = ge->days_since_pickup;
- if (st->last_vehicle_type == VEH_Ship)
+ if (st->last_vehicle_type == VEH_SHIP)
days >>= 2;
(days > 21) ||
(rating += 25, days > 12) ||
@@ -2299,7 +2311,7 @@
if (b == 0) UpdateStationRating(st);
}
-void OnTick_Station(void)
+void OnTick_Station()
{
if (_game_mode == GM_EDITOR) return;
@@ -2312,7 +2324,7 @@
FOR_ALL_STATIONS(st) StationHandleSmallTick(st);
}
-void StationMonthlyLoop(void)
+void StationMonthlyLoop()
{
}
@@ -2414,8 +2426,8 @@
(st->town->exclusive_counter == 0 || st->town->exclusivity == st->owner) && // check exclusive transport rights
st->goods[type].rating != 0 &&
(!_patches.selectgoods || st->goods[type].last_speed > 0) && // if last_speed is 0, no vehicle has been there.
- ((st->facilities & ~FACIL_BUS_STOP) != 0 || type == CT_PASSENGERS) && // if we have other fac. than a bus stop, or the cargo is passengers
- ((st->facilities & ~FACIL_TRUCK_STOP) != 0 || type != CT_PASSENGERS)) { // if we have other fac. than a cargo bay or the cargo is not passengers
+ ((st->facilities & ~FACIL_BUS_STOP) != 0 || IsCargoInClass(type, CC_PASSENGERS)) && // if we have other fac. than a bus stop, or the cargo is passengers
+ ((st->facilities & ~FACIL_TRUCK_STOP) != 0 || !IsCargoInClass(type, CC_PASSENGERS))) { // if we have other fac. than a cargo bay or the cargo is not passengers
if (_patches.modified_catchment) {
// min and max coordinates of the producer relative
const int x_min_prod = 9;
@@ -2537,7 +2549,7 @@
st->time_since_load = 255;
st->time_since_unload = 255;
st->delete_ctr = 0;
- st->last_vehicle_type = VEH_Invalid;
+ st->last_vehicle_type = VEH_INVALID;
st->facilities = FACIL_AIRPORT | FACIL_DOCK;
st->build_date = _date;
@@ -2546,7 +2558,7 @@
st->goods[j].days_since_pickup = 0;
st->goods[j].enroute_from = INVALID_STATION;
st->goods[j].enroute_from_xy = INVALID_TILE;
- st->goods[j].rating = 175;
+ st->goods[j].rating = INITIAL_STATION_RATING;
st->goods[j].last_speed = 0;
st->goods[j].last_age = 255;
}
@@ -2643,7 +2655,7 @@
return CMD_ERROR;
}
-void InitializeStations(void)
+void InitializeStations()
{
/* Clean the station pool and create 1 block in it */
CleanPool(&_Station_pool);
@@ -2658,7 +2670,7 @@
}
-void AfterLoadStations(void)
+void AfterLoadStations()
{
/* Update the speclists of all stations to point to the currently loaded custom stations. */
Station *st;
@@ -2791,18 +2803,6 @@
SlObject(st, _station_desc);
for (uint i = 0; i != NUM_CARGO; i++) {
SlObject(&st->goods[i], _goods_desc);
-
- /* In older versions, enroute_from had 0xFF as INVALID_STATION, is now 0xFFFF */
- if (CheckSavegameVersion(7) && st->goods[i].enroute_from == 0xFF) {
- st->goods[i].enroute_from = INVALID_STATION;
- }
- if (CheckSavegameVersion(44)) {
- /* Store position of the station where the goods come from, so there are no
- * very high payments when stations get removed. However, if the station
- * where the goods came from is already removed, the source information is
- * lost. In that case we set it to the position of this station */
- st->goods[i].enroute_from_xy = IsValidStationID(st->goods[i].enroute_from) ? GetStation(st->goods[i].enroute_from)->xy : st->xy;
- }
}
if (st->num_specs != 0) {
@@ -2814,7 +2814,7 @@
}
}
-static void Save_STNS(void)
+static void Save_STNS()
{
Station *st;
// Write the stations
@@ -2824,7 +2824,7 @@
}
}
-static void Load_STNS(void)
+static void Load_STNS()
{
int index;
while ((index = SlIterateArray()) != -1) {
@@ -2847,7 +2847,7 @@
if (_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0;
}
-static void Save_ROADSTOP(void)
+static void Save_ROADSTOP()
{
RoadStop *rs;
@@ -2857,7 +2857,7 @@
}
}
-static void Load_ROADSTOP(void)
+static void Load_ROADSTOP()
{
int index;