[patch] Clipboard (a/k/a "Copy and Paste")

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
Starbud
Traffic Manager
Traffic Manager
Posts: 211
Joined: 05 Mar 2007 00:48
Location: Sweden
Contact:

Re: Clipboard (a/k/a "Copy and Paste")

Post by Starbud »

Yes:
Whenever someone takes the time to make it work with that specific version and compile it and put in this thread :)
I'm just waiting until i get my new apartment so i can place all my computers there that i have stored in my parents garage.
http://openttd.org - i love building stuff :)
Someones play with pics http://dimalimsliv.blogg.se
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: Clipboard (a/k/a "Copy and Paste")

Post by adf88 »

Hi folks. Recently I was intensively working on the patch and accomplished some nice new features like preview, copy/pasting stations and heights adjustment. I'll publish the patch when OTTD 1.3.0 will be released.

For now, I have a question to devs. Could you give me some advice please? I'm struggling with a way how to alter the commands system.

Some tile contents can't be pasted by a single command. Rail waypoints for example. We have to place a track in order to build a waypoint. Also docks, ship depots and buoys come with the same problem - if not on water, canal has to be placed before we build them (it's the way the patch works). While I could just run one command after another, it sucks when it's about cost calculations (shift+click). We will get inaccurate results because the second command can fail (e.g building a rail waypoint will fail if the track is not yet there).

I would like to do something with this imperfection. There are 6 solutions coming to my mind:
  1. Do nothing. Let the cost calculation be inaccurate (I really dislike this approach).
  2. Add totally new commands doing the work in a single step (e.g. "build a waypoint along with the track")
  3. Add new switches (some p1/p2 bits) to existing commands directing them to do the work in a single step (e.g. p2 bit 16 of the CMD_BUILD_RAIL_WAYPOINT could direct the command to build the track if it's not present already)
  4. Make a new DoCommandFlag and pass it to commands when pasting. The flag would alter the way the command works:
    1. ignore some hindrances when not DC_EXEC'ing (e.g. ignore that there is no track when building a waypoint)
    2. do the work in a single step (e.g. place the track when building waypoint)
  5. Do cost calculations without calling commands (just reuse some pieces of commands code)
2, 3 and 4b is about making the work in a single step (by a single command) while 4a is not (4a is hack-ish a bit).
2 and 3 do alter "normal" command system (new features can be used even when not pasting) while 4a and 4b don't.
3 does alter current commands protocol, 2 doesn't (it just adds new commands).
5 seems to me not being the way it should be done

I'm wondering which way is the best. Any thoughts? Any new ideas?
:] don't worry, be happy and checkout my patches
J0anJosep
Traffic Manager
Traffic Manager
Posts: 139
Joined: 06 Aug 2011 15:51
Location: Spain

Re: Clipboard (a/k/a "Copy and Paste")

Post by J0anJosep »

As no dev answered, my guess is that the best option is 4.

If it is possible to add a new flag for commands (let's say FLAG_LAX - maybe a similar flag already exists...), you could rewrite all commands like build waypoint, buoy or whatever so:
- Commands do exactly the same as original commands when no FLAG_LAX.
- If FLAG_LAX is passed and when no EXEC, just ignore some preconditions (isdiagonalrail for waypoints, iswatertile, flat tile... for buoys and docks). If EXEC and FLAG_LAX, then execute isdiagonalrail,... when necessary.

I think that doing like this you could get an estimated cost.

Anyway, I would go with just being able to copy/paste rail and signals tiles, not copying station tiles except for their tracks. This would make the patch smaller, easier to maintain and easier to use.

Hope it helps.

Edit: I didn't think about things like "can allocate all buoys for copy/paste"... This is too complex for me :(
Formerly known as Juanjo
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Clipboard (a/k/a "Copy and Paste")

Post by Zuu »

I would say it depends on the composite command.

If it is natural for a command to exist in different variations, using a bit in p2 (or p1 if unused) for this would work. If the command is like "buy truck", then "take loan", that sounds however not like a natural composition and adding a parameter to "buy truck" or "take loan" to do the other sounds silly.

To my understanding we are not in short in number of possible commands. However, if the thing you want to add is very similar to an existing command, the amount of code duplication can probably be lower by adding a flag to the existing command.

(However, I only speak out of my knowledge and experience of OpenTTD. Other devs may have a different opinion.)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Starbud
Traffic Manager
Traffic Manager
Posts: 211
Joined: 05 Mar 2007 00:48
Location: Sweden
Contact:

Re: Clipboard (a/k/a "Copy and Paste")

Post by Starbud »

Lovely, i really like this patch :)
http://openttd.org - i love building stuff :)
Someones play with pics http://dimalimsliv.blogg.se
User avatar
kyosuke1989
Transport Coordinator
Transport Coordinator
Posts: 273
Joined: 24 Mar 2008 13:04
Location: Finland

Re: Clipboard (a/k/a "Copy and Paste")

Post by kyosuke1989 »

I like this patch very much too. This patch should help to make shift from current micromanagement of infrastructure developing in games played to macromanagement of building infrastructure lines (you know, it's very frustating to build the same type of railyards and line over and over again manually), and that way encourage players to build larger transportation networks with less work. And then the micromanagement level should be shifting to finding the "nodes" for transportable passengers and goods, when using for example, FIRS as industry set. The shared orders did save unseen amounts of micromanagement on developing vehicles, and this patch should do same for infrastructure.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Clipboard (a/k/a "Copy and Paste")

Post by Alberth »

For me it doesn't help much.
I build on top of, and around the obstacles on the map (ie go around a mountain, or zig-zag up a hill), so each junction and track layout that I make is unique.
long_way_up.png
long_way_up.png (426.17 KiB) Viewed 1045 times
User avatar
kyosuke1989
Transport Coordinator
Transport Coordinator
Posts: 273
Joined: 24 Mar 2008 13:04
Location: Finland

Re: Clipboard (a/k/a "Copy and Paste")

Post by kyosuke1989 »

Alberth wrote:For me it doesn't help much.
I build on top of, and around the obstacles on the map (ie go around a mountain, or zig-zag up a hill), so each junction and track layout that I make is unique.
long_way_up.png
In that case, copy-paste does not help. But when there is long, wide lines with heavy traffic, many many track-changing crossings on line and not very much obstacles around, copy-paste is a must.
Starbud
Traffic Manager
Traffic Manager
Posts: 211
Joined: 05 Mar 2007 00:48
Location: Sweden
Contact:

Re: Clipboard (a/k/a "Copy and Paste")

Post by Starbud »

Alberth wrote:For me it doesn't help much.
I build on top of, and around the obstacles on the map (ie go around a mountain, or zig-zag up a hill), so each junction and track layout that I make is unique.
long_way_up.png
It sure do look pretty and it give a certain quality and calmness when i see your tracks Alberth :)

But for those of us that like to enable magic bulldozer and then bulldoze towns and objects to make way for 16 straight lines in each direction, i'd say we are looking for maximum efficiency, getting A LOT of satisfaction from knowing that the network is as efficient as it can be, it simply give another type of satisfaction, it depends on the moond of the day what i build, pretty eyecandy or efficiency :)
http://openttd.org - i love building stuff :)
Someones play with pics http://dimalimsliv.blogg.se
reuben005
Engineer
Engineer
Posts: 13
Joined: 09 Jan 2005 08:50

Re: Clipboard (a/k/a "Copy and Paste")

Post by reuben005 »

Guys i've gone through all 3 topics but i still cant figure out how to play the game with the clipboard features. I would really appreciate if someone can guide me to the download pages to either the patch or the version which has this feature. Also, and help on how to select the squares to copy while in the game would be much appreciated.
Thanks to everyone who contributed in this project!
oberhümer
Tycoon
Tycoon
Posts: 1283
Joined: 23 Oct 2009 19:35
Location: Here and there, sometime or another

Re: Clipboard (a/k/a "Copy and Paste")

Post by oberhümer »

Downloads: first post. Selecting: Landscaping -> click rightmost icon -> click leftmost icon in the window that pops up -> drag and drop. Pasting: Click second icon from left in Copy toolbar, click anywhere on landscape.
--- Licenses: GNU LGPL, version 2 or newer, code and graphics. CC-By-SA, graphics, alternatively. If you're using any, I'd like to hear about it --- Call them "track types" ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---

--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
reuben005
Engineer
Engineer
Posts: 13
Joined: 09 Jan 2005 08:50

Re: Clipboard (a/k/a "Copy and Paste")

Post by reuben005 »

I am able to run the game without the patch (the music, sound and graphics are also running ok) I'm using openttd-1.2.3-windows-win32 (zipped, not installer) on my 64 bit windows 7 laptop.
but after i overwrite the openttd.exe file with the patched openttd.exe, and run the openttd.exe, i get this error: failed to find a sound set, please acquire a sounds set for openttd. see section 4.1 of readme.txt.

please can somebody guide me on this?
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Clipboard (a/k/a "Copy and Paste")

Post by Zuu »

OpenTTD is more than just the .exe file. You can unpack the binary into a separate directory or you must overwrite all old files when there are new files provided by the new build.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
reuben005
Engineer
Engineer
Posts: 13
Joined: 09 Jan 2005 08:50

Re: Clipboard (a/k/a "Copy and Paste")

Post by reuben005 »

Yes after overwriting all the files in my openttd-1.2.3-windows-win32 folder with the files in the the_clipboard_0.1beta3_win32 folder, i double clicked on the new replaced openttd.exe file. That is when i got this error.
Any ideas?
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Clipboard (a/k/a "Copy and Paste")

Post by Eddi »

the version provided in the first post is likely older than 1.2.3, so it uses the old directory structure where the graphics/sound/etc. set need to be under "data" instead of "baseset", so try renaming that folder
reuben005
Engineer
Engineer
Posts: 13
Joined: 09 Jan 2005 08:50

Re: Clipboard (a/k/a "Copy and Paste")

Post by reuben005 »

thank you. i tried with openttd-1.1.2-windows-win32 and it worked.
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: Clipboard (a/k/a "Copy and Paste")

Post by adf88 »

New version is available - The Clipboard 0.2 (see the first page).
Main features:
- now you can copy/paste stations
- nice preview before you paste
- height adjustment (ctrl+scroll)

The patch is split into smaller pieces now (mq).
:] don't worry, be happy and checkout my patches
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: Clipboard (a/k/a "Copy and Paste")

Post by adf88 »

Minor update - 0.2.1. Win32 binaries for OpenTTD 1.3.0 now available. See the first page.
:] don't worry, be happy and checkout my patches
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: Clipboard (a/k/a "Copy and Paste")

Post by adf88 »

Mini patch pack (source code patch) for OpenTTD 1.3.0:
Attachments
clipboard_0.2.1_and_polyline_v8a_for_ottd_1.3.0.zip
Single unidiff. [1.] Get OpenTTD 1.3.0 source code. [2.] Apply the ".patch" file with "svn patch" or "patch -p0" or TortoiseSVN or whatever else. [3.] Copy "clipboard.grf" file into "bin/baseset" folder.
(116.75 KiB) Downloaded 194 times
:] don't worry, be happy and checkout my patches
bugmenotbaby
Engineer
Engineer
Posts: 10
Joined: 01 Jun 2012 11:49
Contact:

Re: Clipboard (a/k/a "Copy and Paste")

Post by bugmenotbaby »

Hi,

T tried to compile my own OpenTTD-Version with your patch. I used the current trunk and Visual Studio 2008.
But I have an error.

I only had apply the patch with TortoiseSVN, but I think that I have to change some things in the source of OpenTTD, havent I?

My programming skills are really bad, so your solution should be simple.
I you dont have a simple solution, I will have really bad luck.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest