I'm working on
The Clipboard.
I took a new approach. Many problems you noticed will be resolved. Old approach builds a new logic on top of the OTTD. Now I'm trying to integrate as much as possible. I also resigned with compatibility with unpatched servers. Server maintainers should decide whether to allow to copy-pasting.
Firstly I generalized map accessors to work not only with the main map, but with other maps too - with contents of the the clipboard in this case. Basically I templatized the TileIndex to differentiate which map to operate on, i.e. instead of
Code: Select all
static inline uint TileHeight(TileIndex tile)
{
assert(tile < MapSize());
return GB(_m[tile].type_height, 0, 4);
}
we have
Code: Select all
template <typename Tmap>
static inline uint TileHeight(TileIndexT<Tmap> tile)
{
assert(tile < MapSize<Tmap>());
return GB(Tmap::m[tile].type_height, 0, 4);
}
Secondly I'm writing new command handlers. Similarly to TerraformTile_XXX functions I created a set of CopyPasteTile_XXX functions to operate on tiles. These handlers integrate with other handlers API. I'm also "upgrading" some existing handlers. Copy-pasting is a single command. In a network game it is possible to copy-paste instantly one piece of map into other location. In single play we can also copy to clipboard or paste from it.
in progress:
- Copy&paste railroads, roads, signals, depots. (Canals? Land purchases?):
NOTE: Cannals? Yes. Land purchases? Rather not. Surely not in multiplayer.
- Copy&paste bridges and tunnels, but only if the entire object is contained within the selection
- Paste modifies the terrain to accomodate the copied layout. The top-most corners determines the overall level difference.
NOTE: three modes - 1. full terraforming, 2. minimal terraforming (as much as needed), 3. no terraforming
- Rotate a layout by 90, 180, or 270 degrees.
NOTE: also reflecting is possible
- Only copy items which belong to the player.
- Shift+Paste displays a cost estimate instead of pasting.
NOTE: cost estimation will be quite precise
- (?) Doesn't paste anything if the copied layout couldn't be reproduced completely (e.g. industry in the way, not enough money, parts would end up below sea level).
- (Optionally?) paste as much as possible if a complete paste isn't possible.
NOTE: two modes: 1. paste as much as possible, 2. paste all or nothing (something near that)
- A server-side option to disable Copy&paste, as some consider it cheating.
NOTE: patch will be built in the way that without major rewrite (nearly writing a new implementation
) cheating will be impossible
- Optionally toggle copying of roads/railroads[/canals].
- Convert rail type.
planned (far feature):
- Preview railroads, roads, tunnels, bridges before Paste.
- Copy diagonal region with Shift.
NOTE: maybe, I'm not much convinced
- Save and load copied layouts to and from files -> Problems: File version management, upgrade old files to new version, unfairness in multi-player. Must be a server setting.
NOTE: It will not be possible in multiplayer mode, only single play. Besides this feature may be rejected because of the game philosophy.
- Convert bridge types to max speed.
NOTE: maybe, but only when save/loading is possible
other approach:
- Shouldn't copy any stations or waypoints because they either couldn't be joined with other, preexisting stations, or the solution would be overcomplicated
NOTE: that's not a problem, pasting will behave in the same like build a platform
- Optionally modify the terrain in the entire pasted region, not just the tiles neccessary to reproduce the track layout.
NOTE: only terraforming
rejected:
- Mirror layout -> Problems: One way signals possibly shouldn't be mirrored.
NOTE: Why not? They should.
- Optionally copy from competitors. Must be a server setting.
NOTE: No. No. No.
OK. I must go now. I will show the new code tomorrow (watch
The Clipboard topic). Actually it is in Alpha stage. A lot works already.