Fix crash when copying bridges
This commit is contained in:
@@ -74,11 +74,12 @@ This is usable for any OpenTTD servers
|
|||||||
|
|
||||||
== CHANGELOG ==
|
== CHANGELOG ==
|
||||||
|
|
||||||
*** 12.0 (?? Oct 2021) ***
|
*** 12.0 (17 Oct 2021) ***
|
||||||
- Automatically search servers when opening multiplayer window.
|
- Automatically search servers when opening multiplayer window.
|
||||||
- Added TeamGame server filtering button.
|
- Added TeamGame server filtering button.
|
||||||
- Show town population instead of name in IMBA minimap mode.
|
- Show town population instead of name in IMBA minimap mode.
|
||||||
- In polyrail mode placing rail while holding Fn modifier will automatically flatten the land for it.
|
- In polyrail mode placing rail while holding Fn modifier will automatically flatten the land for it.
|
||||||
|
- Fixed crash when copying rail bridges.
|
||||||
|
|
||||||
*** 12.0-RC1 (5 Oct 2021) ***
|
*** 12.0-RC1 (5 Oct 2021) ***
|
||||||
- Added experimental rail copy-paste tool.
|
- Added experimental rail copy-paste tool.
|
||||||
|
|||||||
@@ -100,9 +100,13 @@ void Blueprint::Add(TileIndex source_tile, Blueprint::Item item) {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case Item::Type::RAIL_BRIDGE:
|
case Item::Type::RAIL_BRIDGE:
|
||||||
|
this->source_tiles.insert(TILE_ADDXY(source_tile, item.u.rail.bridge.other_end.x, item.u.rail.bridge.other_end.y));
|
||||||
|
this->source_tiles.insert(source_tile);
|
||||||
|
break;
|
||||||
case Item::Type::RAIL_TUNNEL:
|
case Item::Type::RAIL_TUNNEL:
|
||||||
this->source_tiles.insert(TILE_ADDXY(source_tile, item.u.rail.tunnel.other_end.x, item.u.rail.tunnel.other_end.y));
|
this->source_tiles.insert(TILE_ADDXY(source_tile, item.u.rail.tunnel.other_end.x, item.u.rail.tunnel.other_end.y));
|
||||||
FALLTHROUGH;
|
this->source_tiles.insert(source_tile);
|
||||||
|
break;
|
||||||
case Item::Type::RAIL_DEPOT:
|
case Item::Type::RAIL_DEPOT:
|
||||||
case Item::Type::RAIL_STATION:
|
case Item::Type::RAIL_STATION:
|
||||||
this->source_tiles.insert(source_tile);
|
this->source_tiles.insert(source_tile);
|
||||||
@@ -399,7 +403,6 @@ static void BlueprintAddTracks(sp<Blueprint> &blueprint, TileIndex tile, TileInd
|
|||||||
uint16 length = 0;
|
uint16 length = 0;
|
||||||
Track c_track = track;
|
Track c_track = track;
|
||||||
Trackdir c_tdir = _track_iterate_dir[track];
|
Trackdir c_tdir = _track_iterate_dir[track];
|
||||||
// fprintf(stderr, "TTTTTT %u %u %u\n", c_tile, c_track, GetTrackBits(c_tile));
|
|
||||||
while (IsPlainRailTile(c_tile) && HasBit(GetTrackBits(c_tile), c_track)) {
|
while (IsPlainRailTile(c_tile) && HasBit(GetTrackBits(c_tile), c_track)) {
|
||||||
if (HasBit(track_tiles[c_tile], c_track)) break;
|
if (HasBit(track_tiles[c_tile], c_track)) break;
|
||||||
length++;
|
length++;
|
||||||
@@ -409,13 +412,11 @@ static void BlueprintAddTracks(sp<Blueprint> &blueprint, TileIndex tile, TileInd
|
|||||||
if (!area.Contains(c_tile)) break;
|
if (!area.Contains(c_tile)) break;
|
||||||
c_tdir = NextTrackdir(c_tdir);
|
c_tdir = NextTrackdir(c_tdir);
|
||||||
c_track = TrackdirToTrack(c_tdir);
|
c_track = TrackdirToTrack(c_tdir);
|
||||||
// fprintf(stderr, "TTTTTTI %u %u %u\n", c_tile, c_track, GetTrackBits(c_tile));
|
|
||||||
}
|
}
|
||||||
if (end_tile == INVALID_TILE) continue;
|
if (end_tile == INVALID_TILE) continue;
|
||||||
Blueprint::Item bi(Blueprint::Item::Type::RAIL_TRACK, tdiff);
|
Blueprint::Item bi(Blueprint::Item::Type::RAIL_TRACK, tdiff);
|
||||||
bi.u.rail.track.length = length;
|
bi.u.rail.track.length = length;
|
||||||
bi.u.rail.track.start_dir = _track_iterate_dir[track];
|
bi.u.rail.track.start_dir = _track_iterate_dir[track];
|
||||||
// fprintf(stderr, "TTTTTTEE %u %u %u\n", tdiff, bi.u.rail.track.end_diff, bi.u.rail.track.start_dir);
|
|
||||||
blueprint->Add(tile, bi);
|
blueprint->Add(tile, bi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -597,9 +598,7 @@ void SetBlueprintHighlight(const TileInfo *ti, TileHighlight &th) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BuildBlueprint(sp<Blueprint> &blueprint, TileIndex start) {
|
void BuildBlueprint(sp<Blueprint> &blueprint, TileIndex start) {
|
||||||
TileIndex last_tile;
|
CommandContainer last_rail = {INVALID_TILE, 0, 0, CMD_END, nullptr, ""};
|
||||||
// uint32 last_p1, last_p2, last_cmd = CMD_END;
|
|
||||||
CommandContainer last_rail = {INVALID_TILE, 0, 0, CMD_END};
|
|
||||||
for (auto &item : blueprint->items) {
|
for (auto &item : blueprint->items) {
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
case Blueprint::Item::Type::RAIL_TRACK:
|
case Blueprint::Item::Type::RAIL_TRACK:
|
||||||
|
|||||||
@@ -400,9 +400,11 @@ void ObjectHighlight::MarkDirty() {
|
|||||||
}
|
}
|
||||||
if (this->type == ObjectHighlight::Type::BLUEPRINT && this->blueprint) { // TODO why && blueprint check is needed?
|
if (this->type == ObjectHighlight::Type::BLUEPRINT && this->blueprint) { // TODO why && blueprint check is needed?
|
||||||
for (auto tile : this->blueprint->source_tiles) {
|
for (auto tile : this->blueprint->source_tiles) {
|
||||||
|
// fprintf(stderr, "D %d\n", (int)tile);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// fprintf(stderr, "E\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user