mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-07 06:46:43 +00:00
(svn r8449) -Fix
-Codechange: Remove the superfluous attribute RoadStop::prev
This commit is contained in:
parent
39a50e3723
commit
e3b63e6d83
@ -365,8 +365,7 @@ RoadStop::RoadStop(TileIndex tile) :
|
|||||||
xy(tile),
|
xy(tile),
|
||||||
status(3), // stop is free
|
status(3), // stop is free
|
||||||
num_vehicles(0),
|
num_vehicles(0),
|
||||||
next(NULL),
|
next(NULL)
|
||||||
prev(NULL)
|
|
||||||
{
|
{
|
||||||
DEBUG(ms, cDebugCtorLevel, "I+ at %d[0x%x]", tile, tile);
|
DEBUG(ms, cDebugCtorLevel, "I+ at %d[0x%x]", tile, tile);
|
||||||
}
|
}
|
||||||
@ -386,9 +385,6 @@ RoadStop::~RoadStop()
|
|||||||
}
|
}
|
||||||
assert(num_vehicles == 0);
|
assert(num_vehicles == 0);
|
||||||
|
|
||||||
if (prev != NULL) prev->next = next;
|
|
||||||
if (next != NULL) next->prev = prev;
|
|
||||||
|
|
||||||
DEBUG(ms, cDebugCtorLevel , "I- at %d[0x%x]", xy, xy);
|
DEBUG(ms, cDebugCtorLevel , "I- at %d[0x%x]", xy, xy);
|
||||||
|
|
||||||
xy = INVALID_TILE;
|
xy = INVALID_TILE;
|
||||||
|
@ -51,7 +51,6 @@ struct RoadStop {
|
|||||||
byte status; ///< Current status of the Stop. Like which spot is taken. TODO - enumify this
|
byte status; ///< Current status of the Stop. Like which spot is taken. TODO - enumify this
|
||||||
byte num_vehicles; ///< Number of vehicles currently slotted to this stop
|
byte num_vehicles; ///< Number of vehicles currently slotted to this stop
|
||||||
struct RoadStop *next; ///< Next stop of the given type at this station
|
struct RoadStop *next; ///< Next stop of the given type at this station
|
||||||
struct RoadStop *prev; ///< Previous stop of the given type at this station
|
|
||||||
|
|
||||||
RoadStop(TileIndex tile);
|
RoadStop(TileIndex tile);
|
||||||
~RoadStop();
|
~RoadStop();
|
||||||
|
@ -1287,7 +1287,7 @@ int32 DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
|
|||||||
|
|
||||||
/** Heavy wizardry used to add a roadstop to a station.
|
/** Heavy wizardry used to add a roadstop to a station.
|
||||||
* To understand the function, lets first look at what is passed around,
|
* To understand the function, lets first look at what is passed around,
|
||||||
* especially the last two parameters. CmdBuildRoadStop allocates a road
|
* especially the last parameter. CmdBuildRoadStop allocates a road
|
||||||
* stop and needs to put that stop into the linked list of road stops.
|
* stop and needs to put that stop into the linked list of road stops.
|
||||||
* It (CmdBuildRoadStop) has a **currstop pointer which points to element
|
* It (CmdBuildRoadStop) has a **currstop pointer which points to element
|
||||||
* in the linked list of stops (each element in this list being a pointer
|
* in the linked list of stops (each element in this list being a pointer
|
||||||
@ -1295,28 +1295,23 @@ int32 DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
|
|||||||
* modify this pointer (**currstop) thus we need to pass by reference,
|
* modify this pointer (**currstop) thus we need to pass by reference,
|
||||||
* obtaining a triple pointer (***currstop). When finished, **currstop
|
* obtaining a triple pointer (***currstop). When finished, **currstop
|
||||||
* in CmdBuildRoadStop will contain the address of the pointer which will
|
* in CmdBuildRoadStop will contain the address of the pointer which will
|
||||||
* then point into the global roadstop array. *prev (in CmdBuildRoadStop)
|
* then point into the global roadstop array.
|
||||||
* is the pointer tino the global roadstop array which has *currstop in
|
|
||||||
* its ->next element.
|
|
||||||
* @param[in] truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK
|
* @param[in] truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK
|
||||||
* @param[in] station The station to do the whole procedure for
|
* @param[in] station The station to do the whole procedure for
|
||||||
* @param[out] currstop See the detailed function description
|
* @param[out] currstop See the detailed function description
|
||||||
* @param prev See the detailed function description
|
* @param prev See the detailed function description
|
||||||
*/
|
*/
|
||||||
static void FindRoadStopSpot(bool truck_station, Station* st, RoadStop*** currstop, RoadStop** prev)
|
static void FindRoadStopSpot(bool truck_station, Station* st, RoadStop*** currstop)
|
||||||
{
|
{
|
||||||
RoadStop **primary_stop = (truck_station) ? &st->truck_stops : &st->bus_stops;
|
RoadStop **primary_stop = (truck_station) ? &st->truck_stops : &st->bus_stops;
|
||||||
assert(*prev == NULL);
|
|
||||||
|
|
||||||
if (*primary_stop == NULL) {
|
if (*primary_stop == NULL) {
|
||||||
//we have no roadstop of the type yet, so write a "primary stop"
|
//we have no roadstop of the type yet, so write a "primary stop"
|
||||||
*currstop = primary_stop;
|
*currstop = primary_stop;
|
||||||
} else {
|
} else {
|
||||||
//there are stops already, so append to the end of the list
|
//there are stops already, so append to the end of the list
|
||||||
*prev = *primary_stop;
|
|
||||||
*currstop = &(*primary_stop)->next;
|
*currstop = &(*primary_stop)->next;
|
||||||
while (**currstop != NULL) {
|
while (**currstop != NULL) {
|
||||||
*prev = (*prev)->next;
|
|
||||||
*currstop = &(**currstop)->next;
|
*currstop = &(**currstop)->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1332,7 +1327,6 @@ int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
Station *st;
|
Station *st;
|
||||||
RoadStop *road_stop;
|
RoadStop *road_stop;
|
||||||
RoadStop **currstop;
|
RoadStop **currstop;
|
||||||
RoadStop *prev = NULL;
|
|
||||||
int32 cost;
|
int32 cost;
|
||||||
int32 ret;
|
int32 ret;
|
||||||
bool type = !!p2;
|
bool type = !!p2;
|
||||||
@ -1383,7 +1377,7 @@ int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
|
|
||||||
if (!st->rect.BeforeAddTile(tile, StationRect::ADD_TEST)) return CMD_ERROR;
|
if (!st->rect.BeforeAddTile(tile, StationRect::ADD_TEST)) return CMD_ERROR;
|
||||||
|
|
||||||
FindRoadStopSpot(type, st, &currstop, &prev);
|
FindRoadStopSpot(type, st, &currstop);
|
||||||
} else {
|
} else {
|
||||||
/* allocate and initialize new station */
|
/* allocate and initialize new station */
|
||||||
st = new Station(tile);
|
st = new Station(tile);
|
||||||
@ -1396,7 +1390,7 @@ int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
Town *t = st->town = ClosestTownFromTile(tile, (uint)-1);
|
Town *t = st->town = ClosestTownFromTile(tile, (uint)-1);
|
||||||
if (!GenerateStationName(st, tile, 0)) return CMD_ERROR;
|
if (!GenerateStationName(st, tile, 0)) return CMD_ERROR;
|
||||||
|
|
||||||
FindRoadStopSpot(type, st, &currstop, &prev);
|
FindRoadStopSpot(type, st, &currstop);
|
||||||
|
|
||||||
if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) {
|
if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) {
|
||||||
SETBIT(t->have_ratings, _current_player);
|
SETBIT(t->have_ratings, _current_player);
|
||||||
@ -1412,7 +1406,6 @@ int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
*currstop = road_stop;
|
*currstop = road_stop;
|
||||||
|
|
||||||
//initialize an empty station
|
//initialize an empty station
|
||||||
road_stop->prev = prev;
|
|
||||||
st->AddFacility((type) ? FACIL_TRUCK_STOP : FACIL_BUS_STOP, tile);
|
st->AddFacility((type) ? FACIL_TRUCK_STOP : FACIL_BUS_STOP, tile);
|
||||||
|
|
||||||
st->rect.BeforeAddTile(tile, StationRect::ADD_TRY);
|
st->rect.BeforeAddTile(tile, StationRect::ADD_TRY);
|
||||||
@ -1454,15 +1447,18 @@ static int32 RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
|
|||||||
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
|
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
//we only had one stop left
|
if (*primary_stop == cur_stop) {
|
||||||
if (cur_stop->next == NULL && cur_stop->prev == NULL) {
|
// removed the first stop in the list
|
||||||
//so we remove ALL stops
|
*primary_stop = cur_stop->next;
|
||||||
*primary_stop = NULL;
|
// removed the only stop?
|
||||||
st->facilities &= (is_truck) ? ~FACIL_TRUCK_STOP : ~FACIL_BUS_STOP;
|
if (*primary_stop == NULL) {
|
||||||
} else if (cur_stop == *primary_stop) {
|
st->facilities &= (is_truck ? ~FACIL_TRUCK_STOP : ~FACIL_BUS_STOP);
|
||||||
//removed the first stop in the list
|
}
|
||||||
//need to set the primary element to the next stop
|
} else {
|
||||||
*primary_stop = (*primary_stop)->next;
|
// tell the predecessor in the list to skip this stop
|
||||||
|
RoadStop *pred = *primary_stop;
|
||||||
|
while (pred->next != cur_stop) pred = pred->next;
|
||||||
|
pred->next = cur_stop->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete cur_stop;
|
delete cur_stop;
|
||||||
@ -2845,7 +2841,7 @@ static const SaveLoad _roadstop_desc[] = {
|
|||||||
SLE_CONDNULL(1, 0, 25),
|
SLE_CONDNULL(1, 0, 25),
|
||||||
|
|
||||||
SLE_REF(RoadStop,next, REF_ROADSTOPS),
|
SLE_REF(RoadStop,next, REF_ROADSTOPS),
|
||||||
SLE_REF(RoadStop,prev, REF_ROADSTOPS),
|
SLE_CONDNULL(2, 0, 44),
|
||||||
|
|
||||||
SLE_CONDNULL(4, 0, 24),
|
SLE_CONDNULL(4, 0, 24),
|
||||||
SLE_CONDNULL(1, 25, 25),
|
SLE_CONDNULL(1, 25, 25),
|
||||||
|
Loading…
Reference in New Issue
Block a user