Copy & Paste patch, reworked

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
davidc
Engineer
Engineer
Posts: 25
Joined: 25 Jan 2005 20:31

Copy & Paste patch, reworked

Post by davidc »

Here's a rework of the Copy & Paste (or "Build Templates") patch that Frostregen started a while back. Since making it work with trunk, a few bugs have been fixed. Thanks should go mostly to yorick who has done much of the coding.

I'll keep this post updated for as long as I am looking at it. Please post any bugs or requests in this thread, don't bother developers with them :)

The patch is currently known to work with r16050. You can get Windows builds which will be generated when there are enough changes to test. If you build from source you will still need copypaste.grf from the original thread.

Windows build last updated: 13th April 2009 (r16050)

The patch has currently not been tested with cargodest (perhaps in future, or try it yourself!).

You can track development progress on my site. You can checkout and build using Mercurial from the same address, this is advised if you want the latest build on Linux.

Important note: The format for saved templates is currently changing constantly, so templates saved with one build may not load in future builds until a stable patch is finished.
Attachments
copypaste-r14781.diff
(120.73 KiB) Downloaded 757 times
copypaste-r14952.diff
(131.16 KiB) Downloaded 1122 times
Last edited by davidc on 13 Apr 2009 18:58, edited 6 times in total.
davidc
Engineer
Engineer
Posts: 25
Joined: 25 Jan 2005 20:31

Re: Copy & Paste patch, reworked

Post by davidc »

Features which need adding:
  • Compression for saved templates
  • Copying train stations (including newgrf tiles)
Features added:
  • Dynamic size for copy/paste area (can reduce memory usage)
  • Rotation of one-way roads
  • Versions for saved templates, to stop old builds loading new templates
  • Copying of bus stations
Known bugs:
  • Tram tracks on roads apparently aren't copied properly (reported by Roest)
  • Doesn't integrate fully with distant-joint stations
Fixed bugs:
  • Improve the command queue after this update
  • All types of signal can now be copied and pasted
  • No longer possible to bulldoze water and build on it before it floods
  • Error handling when loading templates needs improving
  • Bridge rotation fixed
Last edited by davidc on 13 Apr 2009 18:59, edited 3 times in total.
User avatar
nulio
Traffic Manager
Traffic Manager
Posts: 157
Joined: 23 Aug 2007 21:20
Location: Portugal

Re: Copy & Paste patch, reworked

Post by nulio »

200+ views and no comments? :S

I haven't tried it yet because since reinstalling Leopard I haven't being able to compile stuff (I have to work on this).

I only tried copy & paste with 0.6.1 a few months ago.

When using it in a multiplayer game I noticed that if the paste was too big it was pasted with some problems. The terrain was badly "redone" making some bridges/tunnels being built wrongly and many signals would have wrong directions and/or types. The solution was to copy things in different parts having smaller pastes. Offline singleplayer had none of this problems.

Do you thing that "Features added: Dynamic size for copy/paste area (can reduce memory usage)" would resolve this?

Thanks
davidc
Engineer
Engineer
Posts: 25
Joined: 25 Jan 2005 20:31

Re: Copy & Paste patch, reworked

Post by davidc »

Windows build and the patch itself updated to r14952. This includes distant-joint stations, but the patch doesn't yet make full use of them (e.g. to copy a spread out station). This will hopefully be worked on. Pasting rail stations doesn't work yet either, there are newgrf related things to think about (what happens if you only copy half of a station which has a roof spanning 2 tiles?).

Please report any problems here if you test it.

nulio: The reduced memory usage will not affect multiplayer pasting. Two things have been changed: less arrays are used to hold the data and the size is dynamic. Using less arrays helps with memory usage and makes saved templates smaller. Making the size dynamic may help with machines will less memory (e.g. you set the max copy paste area to be 16x16, not 256x256).

If you can show exactly what you mean by your problem then it may be possible to fix. However, pasting terrain will never work exactly the way everybody wants. Personally I don't like pasting terrain as invariably it makes a mess of things!

And please, only use on multiplayer servers that allow it :)
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Copy & Paste patch, reworked

Post by Gremnon »

I attempted to patch it in on my build.... the only patches I have, don't affect any files it does.
I got an error about CommandStruct in command_type.h being a redefenition, and after a few various attempts to solve that, I can't paste anything copied.
davidc
Engineer
Engineer
Posts: 25
Joined: 25 Jan 2005 20:31

Re: Copy & Paste patch, reworked

Post by davidc »

Gremnon wrote:I attempted to patch it in on my build.... the only patches I have, don't affect any files it does.
I got an error about CommandStruct in command_type.h being a redefenition, and after a few various attempts to solve that, I can't paste anything copied.
Are you using the older patch? I have just pulled from the Mercurial trunk and patched using copypaste-r14952.diff. It compiles fine.

The older patch will definitely fail with trunk as the distant-joint stations patch introducted the CommandStruct (distant-joint and copypaste were both written by Frostregen). Pasting will fail because CMD_NO_WATER is no longer used (yorick fixed that). So it definitely sounds like you're using the older patch :)
PhilSophus
Chairman
Chairman
Posts: 776
Joined: 20 Jan 2007 12:08
Location: Germany

Re: Copy & Paste patch, reworked

Post by PhilSophus »

davidc wrote:as the distant-joint stations patch introducted the CommandStruct (distant-joint and copypaste were both written by Frostregen)
It is CommandContainer in distant join and current trunk.
Last edited by PhilSophus on 10 Jan 2009 15:19, edited 1 time in total.
"The bigger the island of our knowledge, the longer the shore of our ignorance" - John A. Wheeler, Physicist, 1911-2008
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Copy & Paste patch, reworked

Post by Gremnon »

Yeah, I forgot to get the new version... my bad... and yes, it was container, I misremembered it, sorry bout that
davidc
Engineer
Engineer
Posts: 25
Joined: 25 Jan 2005 20:31

Re: Copy & Paste patch, reworked

Post by davidc »

Gremnon wrote:Yeah, I forgot to get the new version... my bad... and yes, it was container, I misremembered it, sorry bout that
Glad you got it working, any feedback would be great :D
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Copy & Paste patch, reworked

Post by Gremnon »

I'm getting there... I keep forgetting it's there actually, I'm used to not having it...
One question though, before I try it and possibly break something... I use the routemarkers patch too, does it copy the routemarkers?
davidc
Engineer
Engineer
Posts: 25
Joined: 25 Jan 2005 20:31

Re: Copy & Paste patch, reworked

Post by davidc »

Gremnon wrote:I'm getting there... I keep forgetting it's there actually, I'm used to not having it...
One question though, before I try it and possibly break something... I use the routemarkers patch too, does it copy the routemarkers?
If it's not in trunk, it wont be copied. I haven't seen the routemarkers patch, so I don't know quite how it works. If it provides sensible interfaces (e.g. GetTileType and CMD_BUILD_XX) then it would be very easy to add.
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Copy & Paste patch, reworked

Post by Gremnon »

Ah.... useful...
Right, back to playing my game... and possibly breaking it again if I patched it wrong.
User avatar
nulio
Traffic Manager
Traffic Manager
Posts: 157
Joined: 23 Aug 2007 21:20
Location: Portugal

Re: Copy & Paste patch, reworked

Post by nulio »

davidc wrote:Features which need adding:
(...)
  • Copying train stations (including newgrf tiles)
(...)

Known bugs:
  • Doesn't integrate fully with distant-joint stations
(...)
I'm looking forward to see it! :D
User avatar
Roest
Traffic Manager
Traffic Manager
Posts: 215
Joined: 03 Apr 2008 08:18

Re: Copy & Paste patch, reworked

Post by Roest »

update to current rev
Attachments
copypaste_r15338.diff
(128.94 KiB) Downloaded 434 times
deDied
Engineer
Engineer
Posts: 2
Joined: 13 Feb 2009 17:43

Re: Copy & Paste patch, reworked

Post by deDied »

hey there,

is it possible to make this work in the scenario editor? so i can copy industries?
User avatar
wil86
Engineer
Engineer
Posts: 27
Joined: 27 Feb 2008 17:26
Location: Rostock, Germany

Re: Copy & Paste patch, reworked

Post by wil86 »

hey, nice patch :D
i'd love to see this in trunk!!
User avatar
toast
Engineer
Engineer
Posts: 9
Joined: 01 Mar 2008 21:16
Location: Victoria, BC

Re: Copy & Paste patch, reworked

Post by toast »

Hello Folks!

i'm using Mac OS X 10.5.6 - is there someone nice who can compile a running Openttd with copy and paste functionality for me?? I'm not sure how to patch the r14953 :? It would be great if there someone who could help me!!

Thanks!
toast
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Copy & Paste patch, reworked

Post by planetmaker »

With MacOS it should be quite easy: Install xcode from your DVD, install svn and you can compile yourself. An extensive walk-through is found in the sticky thread in this forum.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: Copy & Paste patch, reworked

Post by SirkoZ »

Would someone pretty please update this patch to 0.7.0 ß1? ;-)
User avatar
Roest
Traffic Manager
Traffic Manager
Posts: 215
Joined: 03 Apr 2008 08:18

Re: Copy & Paste patch, reworked

Post by Roest »

That one still applies to current trunk (r15541), didn't test it tho.
Attachments
copypaste_r15495.diff
(128.7 KiB) Downloaded 481 times
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 7 guests