Build Templates (Copy&Paste) (r13911 + 0.6.3 + 0.6.2)

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

User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Build Templates (Copy&Paste) (r11874 + 0.5.3 + 0.6.0-beta3)

Post by Bilbo »

I wonder whether the patch could be enhanced to copy buildings, trees, industries, etc ... well, of course these extra things would be copied only in the scenario editor, not in the game. Is this realistic?
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Frostregen
Transport Coordinator
Transport Coordinator
Posts: 340
Joined: 06 Feb 2006 23:58

Re: Build Templates (Copy&Paste) (r11874 + 0.5.3 + 0.6.0-beta3)

Post by Frostregen »

Sure, It is possible,
but would require additional GUI features.
When copying buildings you need to specify the town they belong to.
Same with industries.

Trees are simple, and could even make it into normal gameplay ;)
Starbud
Traffic Manager
Traffic Manager
Posts: 211
Joined: 05 Mar 2007 00:48
Location: Sweden
Contact:

Re: Build Templates (Copy&Paste) (r11946 + 0.5.3 + 0.6.0-beta3)

Post by Starbud »

I dont mind copying all the industries too, would be expensive as hell but it would stop that tideous work of adding industries, but i guess i'm one of the few who need that feature tho.

Anyone for another idea?
Making it really expensive to remove towns so that the magic buldozer wont be needed?
Industries too :)
http://openttd.org - i love building stuff :)
Someones play with pics http://dimalimsliv.blogg.se
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Build Templates (Copy&Paste) (r11946 + 0.5.3 + 0.6.0-beta3)

Post by Bilbo »

Starbud wrote:I dont mind copying all the industries too, would be expensive as hell but it would stop that tideous work of adding industries, but i guess i'm one of the few who need that feature tho.
Won't work well, as som,e industries comes in multiple shapes, randomlyu selected upon placement. So it may be impossible to reproduce industry layout in game. But in scenario editor you can directly manipulate the map array, thus having more possibilities to modify the map.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Starbud
Traffic Manager
Traffic Manager
Posts: 211
Joined: 05 Mar 2007 00:48
Location: Sweden
Contact:

Re: Build Templates (Copy&Paste) (r11946 + 0.5.3 + 0.6.0-beta3)

Post by Starbud »

Bilbo wrote:..... But in scenario editor you can directly manipulate the map array, thus having more possibilities to modify the map.
When magic buldozer is enabeld you can modify the map "directly" too.
From placing industries i have noticed that the industry take up the space it needs or smaller depending on the space avaliable.
I bet that all that would happen is that it might not be built if there is a problem with space or slopes.
http://openttd.org - i love building stuff :)
Someones play with pics http://dimalimsliv.blogg.se
Guckemal
Engineer
Engineer
Posts: 2
Joined: 01 Feb 2008 11:13
Location: Germany

Re: Build Templates (Copy&Paste) (r12002+ 0.5.3 + 0.6.0-beta3)

Post by Guckemal »

PMFJI - I have a technical question (suggestion?), concerning the memory usage of the c&p-feature.

Frostregen said some time ago:
To avoid ram fragmentation, the copy-arrays are pre-allocated.
This means:
64 * 64 * 10Bytes = 40kb
...


Hmm. Is it really necessary to create an array (containing tile information I suppose) for copying/pasting?
How about storing just the two defining corners of the selected area (e. g. top left/bottom right coordinates, plus the target tile coordinates), and then handling the copy/paste-actions in a nested loop tile by tile ( foreach x1..x2 {foreach y1..y2 { handle tile x|y }} )?

Shouldn't this get us rid of any memory usage issues?

mfg, Guckemal
Frostregen
Transport Coordinator
Transport Coordinator
Posts: 340
Joined: 06 Feb 2006 23:58

Re: Build Templates (Copy&Paste) (r12002+ 0.5.3 + 0.6.0-beta3)

Post by Frostregen »

It is necessary to have a map independet storage because:

-After specifying the copy-area, someone could modify your copy
-You could not Load Templates anymore (you would have to build something at least once manually, before you could copy it)
-no copying from one savegame into another

I thought of this idea too, but mainly for multiplayer reasons:
-For multiplayer it would allow copy&paste to be handled easily with only 1 command
(As every client already has a local copy, and could reconstruct the whole area inside the command)
(Currently the proper way would be to send the array data to each client, then reconstruct it at once with one command)

I dropped the idea, because loading is way too important.
Guckemal
Engineer
Engineer
Posts: 2
Joined: 01 Feb 2008 11:13
Location: Germany

Re: Build Templates (Copy&Paste) (r12002+ 0.5.3 + 0.6.0-beta3)

Post by Guckemal »

Frostregen wrote: It is necessary to have a map independet storage because:

-After specifying the copy-area, someone could modify your copy
-You could not Load Templates anymore (you would have to build something at least once manually, before you could copy it)
-no copying from one savegame into another
Hmm. How about using a local temp file instead of RAM? This would surely work slower than plain memory activity, OTOH, storage capacity, i.e. area size, should not be an issue any more.

I wouldn't mind if copying my fine tuned crossings takes 2 seconds instead of 50 ms - still saves me lots of clicks (and errors)...

mfg, Guckemal
Last edited by Guckemal on 16 Feb 2008 08:28, edited 1 time in total.
Grolsch
Transport Coordinator
Transport Coordinator
Posts: 283
Joined: 08 May 2004 07:48
Location: Alkmaar, The Netherlands

Re: Build Templates (Copy&Paste) (r12002+ 0.5.3 + 0.6.0-beta3)

Post by Grolsch »

Guckemal wrote:
Frostregen wrote: It is necessary to have a map independet storage because:

-After specifying the copy-area, someone could modify your copy
-You could not Load Templates anymore (you would have to build something at least once manually, before you could copy it)
-no copying from one savegame into another
Hmm. How about using a local temp file instead of RAM? This would shurely work slower than plain memory activity, OTOH, storage capacity, i.e. area size, should not be an issue any more.

I wouldn't mind if copying my fine tuned crossings takes 2 seconds instead of 50 ms - still saves me lots of clicks (and errors)...

mfg, Guckemal
Isn't it possible to check the free amount of RAM, and if it isn't enough, use a temp-file? I have 4GB RAM, can't imagine I need a temp file, however others may need it though.
Beer equals power
User avatar
jez
Traffic Manager
Traffic Manager
Posts: 158
Joined: 23 Aug 2003 21:24

Re: Build Templates (Copy&Paste) (r12347+ 0.5.3 + 0.6.0-beta5)

Post by jez »

There seems to be some problem with the patch for r12347.

Visual studio 2005 gives me 3 errors when I try to build:
Error 1 error C3083: '{ctor}': the symbol to the left of a '::' must be a type c:\Checkout\OpenTTD-copypaste\src\copy_paste.cpp 202
Error 2 error C2533: 'CopyPaste::CP_PlaceRail_Depot' : constructors not allowed a return type c:\Checkout\OpenTTD-copypaste\src\copy_paste.cpp 203
Error 3 error C2264: 'CopyPaste::CP_PlaceRail_Depot' : error in function definition or declaration; function not called c:\Checkout\OpenTTD-copypaste\src\copy_paste.cpp 400


:-(
=== Jez ===
User avatar
jez
Traffic Manager
Traffic Manager
Posts: 158
Joined: 23 Aug 2003 21:24

Re: Build Templates (Copy&Paste) (r12347+ 0.5.3 + 0.6.0-beta5)

Post by jez »

OK, I found the problem; there is a problem with the r12347 patch.

On line 1564:

Code: Select all

+void CopyPaste::CopyPaste::CP_PlaceRail_Depot(TileIndex tile, uint8 railtype, uint8 direction)
Should be:

Code: Select all

+void CopyPaste::CP_PlaceRail_Depot(TileIndex tile, uint8 railtype, uint8 direction)
How did this mistake get in? Surely it wouldn't compile on your machine like this. :-)
=== Jez ===
Iguanna
Engineer
Engineer
Posts: 100
Joined: 21 Nov 2007 00:06

Re: Build Templates (Copy&Paste) (r12347+ 0.5.3 + 0.6.0-beta5)

Post by Iguanna »

Often when there is more than 1 signal on a tile, the pasted signal type is often wrong.
0.6.0-beta5
0.6.0-beta5
Incorrect signal type.PNG (17.24 KiB) Viewed 3393 times
One thing that would be a great improvement would be to make the dynamite not demolish over tunnels when the land is high enough and it does not need to. Things like bridges over the tunnels, city buildings, roads etc. I often don't want destroyed.
0.6.0-beta5
0.6.0-beta5
Tunnel needlessly destroying bridge.PNG (48.84 KiB) Viewed 3393 times
Thanks for this great patch. I use it all the time to build thing that would otherwise be practically impossible.
Frostregen
Transport Coordinator
Transport Coordinator
Posts: 340
Joined: 06 Feb 2006 23:58

Re: Build Templates (Copy&Paste) (r12347+ 0.5.3 + 0.6.0-beta5)

Post by Frostregen »

@jez: Seems like a copy&paste error ;)
Strange enough it DID compile. (Not only for me, because this error was there quite long)

@IguannaB:
Signals: This is because when creating the patch it was not possible to have different signal-types on one tile.
Now there are not enough free bits to store the second signal type whithout a change to the template file format.
This will be fixed sometime.

Dynamite: I guess you could just disable dynamite manually, when pasting such layouts.


Thx for using this patch.
User avatar
Indiana
Engineer
Engineer
Posts: 36
Joined: 07 Feb 2008 09:15

Re: Build Templates (Copy&Paste) (r12347+ 0.5.3 + 0.6.0-beta5)

Post by Indiana »

Hi,

found a small bug.
If I try to save a template as "Con" openttd dies :shock:
Workaround: Just choose another name.
Have a N.I.C.E. day!
Indiana
as
Transport Coordinator
Transport Coordinator
Posts: 281
Joined: 07 Mar 2007 20:13

Re: Build Templates (Copy&Paste) (r12347+ 0.5.3 + 0.6.0-beta5)

Post by as »

Indiana wrote:
Workaround: Just choose another name.
Like PRN, LPT1 or COM1 for example. :p
Frostregen
Transport Coordinator
Transport Coordinator
Posts: 340
Joined: 06 Feb 2006 23:58

Re: Build Templates (Copy&Paste) (r12347+ 0.5.3 + 0.6.0-beta5)

Post by Frostregen »

or AUX

Theese are special reserved filenames. (since DOS times)
You can not create files/folders with those names.
Even files named CON.xxx are not allowed.

On the other hand, i should check if file-creation was successful, before trying to write to it ;)
Will be fixed in next release.

EDIT:
OpenTTD crashes/hangs when trying to save a savegame with those names too.
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Build Templates (Copy&Paste) (r12347+ 0.5.3 + 0.6.0-beta5)

Post by Bilbo »

Frostregen wrote:On the other hand, i should check if file-creation was successful, before trying to write to it ;)
There are more reasons why opening file could fail (like lack of write permission in the directory where you want to write for example) What is a bit worse, if you try to save to some special files, like LPT1 not only that opening that file won't fail but you start copying the savegame to your printer (in case you have one connected to LPT1 - most printer nowadays are ethernet or USBV connected anyways :)
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
User avatar
jez
Traffic Manager
Traffic Manager
Posts: 158
Joined: 23 Aug 2003 21:24

Re: Build Templates (Copy&Paste) (r12347+ 0.5.3 + 0.6.0-beta5)

Post by jez »

Frostregen: One problem I've noticed with this patch:

I copy my templates late in the game, when I have the best bridges available (tubular steel) and I make the bridges with them, so I have the best possible juntion. Trouble is, when I go to paste them in a game where I don't have those bridges available, I get a 'can't build bridge' message. Is there a way you could, if the bridge to be built isn't available, make it paste the best bridge available at the current time?
=== Jez ===
Frostregen
Transport Coordinator
Transport Coordinator
Posts: 340
Joined: 06 Feb 2006 23:58

Re: Build Templates (Copy&Paste) (r12347+ 0.5.3 + 0.6.0-beta5)

Post by Frostregen »

Hmm, i never use bridges, so i did not notice this problem.

Hmm, could be some work though,
because bridges have different minimum, and maximum length constraints.
(But i guess those constraints are stored somewhere...)
Starbud
Traffic Manager
Traffic Manager
Posts: 211
Joined: 05 Mar 2007 00:48
Location: Sweden
Contact:

Re: Build Templates (Copy&Paste) (r12347+ 0.5.3 + 0.6.0-beta5)

Post by Starbud »

Not using bridges?
Can we have a look at your designs to learn from them?
Sonds intresting to use concepts without bridges. :)
http://openttd.org - i love building stuff :)
Someones play with pics http://dimalimsliv.blogg.se
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 13 guests