Fix copy-pasting block signals
This commit is contained in:
@@ -74,6 +74,16 @@ This is usable for any OpenTTD servers
|
|||||||
|
|
||||||
== CHANGELOG ==
|
== CHANGELOG ==
|
||||||
|
|
||||||
|
*** 12.0 (4 Oct 2021) ***
|
||||||
|
- Added rail copy-paste tool.
|
||||||
|
- Added client list overlay (toggleable with a button in the regular client list window title).
|
||||||
|
- Added back "New company" option to the company toolbar dropdown menu.
|
||||||
|
- Fixed crash when closing order window with a hotkey.
|
||||||
|
- Fixed crash when building airports outsize the map.
|
||||||
|
- Fixed minimap crash in imba mode.
|
||||||
|
- Fixed cargo selection in income/cargo graphs.
|
||||||
|
- Fixed watch window excessive scaling with interface size.
|
||||||
|
|
||||||
*** 12.0-beta2 (19 Aug 2021) ***
|
*** 12.0-beta2 (19 Aug 2021) ***
|
||||||
- Fixed crash when building airport with no valid airport type selected.
|
- Fixed crash when building airport with no valid airport type selected.
|
||||||
- Renamed a bunch of setttings in the config file adding cm_* prefix to distinguish them from vanilla ones.
|
- Renamed a bunch of setttings in the config file adding cm_* prefix to distinguish them from vanilla ones.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "cm_highlight.hpp"
|
#include "cm_highlight.hpp"
|
||||||
|
|
||||||
#include "../command_func.h"
|
#include "../command_func.h"
|
||||||
|
#include "../debug.h"
|
||||||
#include "../direction_type.h"
|
#include "../direction_type.h"
|
||||||
#include "../rail_map.h"
|
#include "../rail_map.h"
|
||||||
#include "../station_map.h"
|
#include "../station_map.h"
|
||||||
@@ -119,6 +120,11 @@ CommandContainer GetBlueprintCommand(TileIndex start, const Blueprint::Item &ite
|
|||||||
TRACK_UPPER, TRACK_UPPER, TRACK_LOWER, TRACK_LOWER,
|
TRACK_UPPER, TRACK_UPPER, TRACK_LOWER, TRACK_LOWER,
|
||||||
TRACK_X, TRACK_X, TRACK_Y, TRACK_Y,
|
TRACK_X, TRACK_X, TRACK_Y, TRACK_Y,
|
||||||
};
|
};
|
||||||
|
static const uint SIGNAL_POS_NUM[] = {
|
||||||
|
1, 0, 1, 0,
|
||||||
|
0, 1, 0, 1,
|
||||||
|
0, 1, 0, 1,
|
||||||
|
};
|
||||||
|
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
case Blueprint::Item::Type::RAIL_TRACK: {
|
case Blueprint::Item::Type::RAIL_TRACK: {
|
||||||
@@ -184,10 +190,14 @@ CommandContainer GetBlueprintCommand(TileIndex start, const Blueprint::Item &ite
|
|||||||
nullptr, ""
|
nullptr, ""
|
||||||
};
|
};
|
||||||
case Blueprint::Item::Type::RAIL_SIGNAL:
|
case Blueprint::Item::Type::RAIL_SIGNAL:
|
||||||
|
Debug(misc, 0, "SIGNAL: pos={} var={} type={} 2way={}", item.u.rail.signal.pos, item.u.rail.signal.variant, item.u.rail.signal.type, item.u.rail.signal.twoway);
|
||||||
return CommandContainer {
|
return CommandContainer {
|
||||||
AddTileIndexDiffCWrap(start, item.tdiff),
|
AddTileIndexDiffCWrap(start, item.tdiff),
|
||||||
SIGNAL_POS_TRACK[item.u.rail.signal.pos] | (item.u.rail.signal.variant << 4) | (item.u.rail.signal.type << 5)
|
SIGNAL_POS_TRACK[item.u.rail.signal.pos]
|
||||||
| ((item.u.rail.signal.pos % 2) << 15),
|
| (item.u.rail.signal.variant << 4)
|
||||||
|
| (item.u.rail.signal.type << 5)
|
||||||
|
| (SIGNAL_POS_NUM[item.u.rail.signal.pos] + (item.u.rail.signal.type <= SIGTYPE_LAST_NOPBS && !item.u.rail.signal.twoway ? 1 : 0)) << 15
|
||||||
|
| 1 << 17,
|
||||||
0,
|
0,
|
||||||
CMD_BUILD_SIGNALS,
|
CMD_BUILD_SIGNALS,
|
||||||
nullptr, ""
|
nullptr, ""
|
||||||
@@ -256,6 +266,8 @@ std::multimap<TileIndex, ObjectTileHighlight> Blueprint::GetTiles(TileIndex tile
|
|||||||
}
|
}
|
||||||
case Item::Type::RAIL_SIGNAL:
|
case Item::Type::RAIL_SIGNAL:
|
||||||
add_tile(otile, ObjectTileHighlight::make_rail_signal(CM_PALETTE_TINT_WHITE, o.u.rail.signal.pos, o.u.rail.signal.type, o.u.rail.signal.variant));
|
add_tile(otile, ObjectTileHighlight::make_rail_signal(CM_PALETTE_TINT_WHITE, o.u.rail.signal.pos, o.u.rail.signal.type, o.u.rail.signal.variant));
|
||||||
|
if (o.u.rail.signal.twoway)
|
||||||
|
add_tile(otile, ObjectTileHighlight::make_rail_signal(CM_PALETTE_TINT_WHITE, o.u.rail.signal.pos | 1, o.u.rail.signal.type, o.u.rail.signal.variant));
|
||||||
break;
|
break;
|
||||||
case Item::Type::RAIL_STATION:
|
case Item::Type::RAIL_STATION:
|
||||||
break;
|
break;
|
||||||
@@ -350,39 +362,29 @@ static void BlueprintAddSignals(sp<Blueprint> &blueprint, TileIndex tile, TileIn
|
|||||||
// reference: DrawSignals @ rail_cmd.cpp
|
// reference: DrawSignals @ rail_cmd.cpp
|
||||||
|
|
||||||
auto add = [&](Track track, uint x, uint pos) {
|
auto add = [&](Track track, uint x, uint pos) {
|
||||||
if (!IsSignalPresent(tile, x)) return;
|
auto a = IsSignalPresent(tile, x);
|
||||||
|
auto b = IsSignalPresent(tile, x ^ 1);
|
||||||
|
if (!a && !b) return;
|
||||||
|
if (!a) pos = pos | 1;
|
||||||
Blueprint::Item bi(Blueprint::Item::Type::RAIL_SIGNAL, tdiff);
|
Blueprint::Item bi(Blueprint::Item::Type::RAIL_SIGNAL, tdiff);
|
||||||
bi.u.rail.signal.pos = pos;
|
bi.u.rail.signal.pos = pos;
|
||||||
bi.u.rail.signal.type = GetSignalType(tile, track);
|
bi.u.rail.signal.type = GetSignalType(tile, track);
|
||||||
bi.u.rail.signal.variant = GetSignalVariant(tile, track);
|
bi.u.rail.signal.variant = GetSignalVariant(tile, track);
|
||||||
|
bi.u.rail.signal.twoway = a && b;
|
||||||
blueprint->Add(tile, bi);
|
blueprint->Add(tile, bi);
|
||||||
};
|
};
|
||||||
auto rails = GetTrackBits(tile);
|
auto rails = GetTrackBits(tile);
|
||||||
if (!(rails & TRACK_BIT_Y)) {
|
if (!(rails & TRACK_BIT_Y)) {
|
||||||
if (!(rails & TRACK_BIT_X)) {
|
if (!(rails & TRACK_BIT_X)) {
|
||||||
if (rails & TRACK_BIT_LEFT) {
|
if (rails & TRACK_BIT_LEFT) add(TRACK_LEFT, 2, 0);
|
||||||
add(TRACK_LEFT, 2, 0);
|
if (rails & TRACK_BIT_RIGHT) add(TRACK_RIGHT, 0, 2);
|
||||||
add(TRACK_LEFT, 3, 1);
|
if (rails & TRACK_BIT_UPPER) add(TRACK_UPPER, 3, 4);
|
||||||
}
|
if (rails & TRACK_BIT_LOWER) add(TRACK_LOWER, 1, 6);
|
||||||
if (rails & TRACK_BIT_RIGHT) {
|
|
||||||
add(TRACK_RIGHT, 0, 2);
|
|
||||||
add(TRACK_RIGHT, 1, 3);
|
|
||||||
}
|
|
||||||
if (rails & TRACK_BIT_UPPER) {
|
|
||||||
add(TRACK_UPPER, 3, 4);
|
|
||||||
add(TRACK_UPPER, 2, 5);
|
|
||||||
}
|
|
||||||
if (rails & TRACK_BIT_LOWER) {
|
|
||||||
add(TRACK_LOWER, 1, 6);
|
|
||||||
add(TRACK_LOWER, 0, 7);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
add(TRACK_X, 3, 8);
|
add(TRACK_X, 3, 8);
|
||||||
add(TRACK_X, 2, 9);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
add(TRACK_Y, 3, 10);
|
add(TRACK_Y, 3, 10);
|
||||||
add(TRACK_Y, 2, 11);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ public:
|
|||||||
uint pos;
|
uint pos;
|
||||||
SignalType type;
|
SignalType type;
|
||||||
SignalVariant variant;
|
SignalVariant variant;
|
||||||
|
bool twoway;
|
||||||
} signal;
|
} signal;
|
||||||
struct {
|
struct {
|
||||||
DiagDirection ddir;
|
DiagDirection ddir;
|
||||||
|
|||||||
Reference in New Issue
Block a user