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

MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Frostregen, have you tested it in multiplayer game?
I'm afraid sending many commands may clog the connections, so I came up with idea to change the internal behaviour of your patch.

I know this may be a big change, but it would greatly reduce amount of commands sent to minimum. Read: 1.

I imagine player sending a command "copy" with parameters "from x y width height" and "to x y width height". This way every client would receive only one command, and all the copypasting work would be done on client's machine.
Keep in mind that if your patch makes multiplayer play impossible, both players and developers won't be happy merging it. Read: it wouldn't get committed.
Frostregen
Transport Coordinator
Transport Coordinator
Posts: 340
Joined: 06 Feb 2006 23:58

Post by Frostregen »

@Mr.X:
Would be nice indeed, but this has to wait until the rest works ;)

@gigajum:
This would not prevent the single Prices from being displayed.
But I'll see what I can do.

Current Status:
Roads implemented, different railtypes implemented.
Attachments
Nindinghattan Transport, 25. Feb 2023.png
Nindinghattan Transport, 25. Feb 2023.png (48.62 KiB) Viewed 9865 times
DeletedUser21
Tycoon
Tycoon
Posts: 11501
Joined: 20 Sep 2004 22:45

Post by DeletedUser21 »

Okay, that looks very nice, indeed work at your own peace, I will not rush you! :P

This will be great! :D
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

MeusH wrote:Frostregen, have you tested it in multiplayer game?
I'm afraid sending many commands may clog the connections, so I came up with idea to change the internal behaviour of your patch.

I know this may be a big change, but it would greatly reduce amount of commands sent to minimum. Read: 1.

I imagine player sending a command "copy" with parameters "from x y width height" and "to x y width height". This way every client would receive only one command, and all the copypasting work would be done on client's machine.
Keep in mind that if your patch makes multiplayer play impossible, both players and developers won't be happy merging it. Read: it wouldn't get committed.
Yeah MeusH, your right. :)
Frostregen wrote:@gigajum:
This would not prevent the single Prices from being displayed.
But I'll see what I can do.
According to Meus: i think he calls every build command seperated. So he can't prevent the textoutput. That is the wrong way to to the job. If you post a current diff file someone can help, but without you get it done but it's useless due to the wrong usage of the openttd internal DoCommand system. (imo)
User avatar
Brianetta
Tycoon
Tycoon
Posts: 2566
Joined: 15 Oct 2003 22:00
Location: Jarrow, UK
Contact:

Post by Brianetta »

What happens if you try to copy a competitor's layout, and you don't have access to the railtype yet?
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
User avatar
Wolf01
Tycoon
Tycoon
Posts: 2016
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Post by Wolf01 »

Brianetta wrote:What happens if you try to copy a competitor's layout, and you don't have access to the railtype yet?
but railtypes doesn't come for all players at the same time?
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

No, they don't. Railtype comes whenever the first engine of that type does, and that can happen a year early for one player.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Frostregen
Transport Coordinator
Transport Coordinator
Posts: 340
Joined: 06 Feb 2006 23:58

Post by Frostregen »

What happens if you try to copy a competitor's layout, and you don't have access to the railtype yet?
I did not test it, if a DoCommandP may build it, it is possible.
But it should be useless anyway, since you dont have a train to run on it ;)
Should be 1 line of code to prevent it.

@MeusH:
I did not test it with mutliplayer.
There are some problems with the "one command" approach:

-You could only supply the selection (starttile - endtile) parameters.
If someone changes something within this area, your copy would change too.
Currently I store the changes in some array's, so they are independent from the map, after copy. (See next point)

-May work for a copy&paste feature, but I started this with the Template feature in my mind. (Save+Load your copied areas)

If there is a possibility to delay the execution (like AI), this should not clog a network game.
It should be not much work to move it from the current implementation to a network friendly version. I'll try both.

At the moment the code is a bit messy, since i have to figure out how to access the map, and how the DoCommands work. (Signals are strange...)
When this is cleaned up a bit, i will post a diff file.

I guess I need some help later anyway. I tried to move the code into a new sourcefile, but got only header/compilation problems... So currently it stays in terraform_gui.c which is not nice.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

If you're using make to build:
grep -n terraform_gui.c Makefile
You'll get output that starts with a line number. Add the new source file somewhere near that line number.

If you're using basically anything else, add the new source file to the project file.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Wolf01
Tycoon
Tycoon
Posts: 2016
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Post by Wolf01 »

DaleStan wrote:No, they don't. Railtype comes whenever the first engine of that type does, and that can happen a year early for one player.
sure, also i tought this, but on a multiplayer game, one player accepted the first monorail engine in the blue popup, but i also had the monorail without engines for a year (i'm sure of this because this player was playing on the pc that is about at 1meter of distance from my pc :D )
User avatar
gkirilov
Chief Executive
Chief Executive
Posts: 696
Joined: 03 May 2005 09:32
Location: Othala

Post by gkirilov »

Frostregen, can you include this also to the scenario editor?
OTTDCoop NewGRF Pack|Different sets of GRFs for TTDPatch (some of them work in OTTD) - 1|- 2|GRF sets for OTTD|OTTD nightly
Image
I hooked up my accelerator to my brake lights. I hit the gas, people behind me stop, and I'm gone.
Understeer is when you hit the wall with the front of the car. Oversteer is when you hit the wall with the rear of the car. Horsepower is how fast you hit the wall. Torque is how far you take the wall with you. Spoilers and bodykits are how much of the wall you take with you. Rollcages and windownets are how much of a mess you leave on the wall.
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

gkirilov wrote:Frostregen, can you include this also to the scenario editor?
If the button exists in the scenario editor it should not be any problem. He only needs to move the two buttons from the rail construction to the landscaping menu and you can use it in the editor, since rail construction is not available in the editor (better place for them IMO).
User avatar
gkirilov
Chief Executive
Chief Executive
Posts: 696
Joined: 03 May 2005 09:32
Location: Othala

Post by gkirilov »

I need it for the road constuction.
But anyway it can copy only the things you can build and you can not build rails in the editor.
I also think that the position of this is in the landscaping bar.

I shortcut key would also be nice :D
OTTDCoop NewGRF Pack|Different sets of GRFs for TTDPatch (some of them work in OTTD) - 1|- 2|GRF sets for OTTD|OTTD nightly
Image
I hooked up my accelerator to my brake lights. I hit the gas, people behind me stop, and I'm gone.
Understeer is when you hit the wall with the front of the car. Oversteer is when you hit the wall with the rear of the car. Horsepower is how fast you hit the wall. Torque is how far you take the wall with you. Spoilers and bodykits are how much of the wall you take with you. Rollcages and windownets are how much of a mess you leave on the wall.
Frostregen
Transport Coordinator
Transport Coordinator
Posts: 340
Joined: 06 Feb 2006 23:58

Post by Frostregen »

The Buttons already moved to the landscaping toolbar.
I'll include it in the scenario editor too. (Only for landscape height there)

Latest addition:
Signals implemented *finally*

Implemented:
-Landscape (Height)
-Rail
-Road (+Rail/Road Crossings)
-Tunnels (Rail+Road)
-Signals

Missing:
-Bridges
-Stations
-Depots
-Waypoints
Attachments
Copying a large 4way crossing
Copying a large 4way crossing
Frost Transport, 21. Mär 2005.png (147.5 KiB) Viewed 1261 times
User avatar
gkirilov
Chief Executive
Chief Executive
Posts: 696
Joined: 03 May 2005 09:32
Location: Othala

Post by gkirilov »

Frostregen wrote: I'll include it in the scenario editor too. (Only for landscape height there)
Implemented:
-Landscape (Height)
-Rail
-Road (+Rail/Road Crossings)
-Tunnels (Rail+Road)
-Signals
Can you make it also for duplicating roads in the scenario editor?
OTTDCoop NewGRF Pack|Different sets of GRFs for TTDPatch (some of them work in OTTD) - 1|- 2|GRF sets for OTTD|OTTD nightly
Image
I hooked up my accelerator to my brake lights. I hit the gas, people behind me stop, and I'm gone.
Understeer is when you hit the wall with the front of the car. Oversteer is when you hit the wall with the rear of the car. Horsepower is how fast you hit the wall. Torque is how far you take the wall with you. Spoilers and bodykits are how much of the wall you take with you. Rollcages and windownets are how much of a mess you leave on the wall.
Frostregen
Transport Coordinator
Transport Coordinator
Posts: 340
Joined: 06 Feb 2006 23:58

Post by Frostregen »

@gkirilov: Sure, just forgot about roads ;)
Drummer_si
Engineer
Engineer
Posts: 34
Joined: 10 May 2006 14:09

Post by Drummer_si »

I like idea?

I assume copy/ pasting is kinda instant :)

Do u think that realistic? Especially in multiplayer games?

Would it be a viable option to add a delay to the pasting?

So each tile gets created at which the computer compettitor builds their stuff?
Frostregen
Transport Coordinator
Transport Coordinator
Posts: 340
Joined: 06 Feb 2006 23:58

Post by Frostregen »

@Drummer:
This delay, like the AI would be my favorite way to do it:
->Looks nice
->Reduced network traffic

But first i have to get it working for all possible buildable things.

News:
Bridges done.

Next:
-Stations
-Depots
-Waypoints
Attachments
Lutown Transport, 27. Jun 2023.png
Lutown Transport, 27. Jun 2023.png (55.77 KiB) Viewed 9373 times
Hazelrah
Traffic Manager
Traffic Manager
Posts: 196
Joined: 13 Apr 2005 05:41

Post by Hazelrah »

Frostgen,

Looking pretty sweet here.

About delaying, wouldn't it just be possible to use a standard C timer which would trigger the next build event when the time is up. It has the advantage that the speed could also be set. Or is there some sort of syncronization problem I'm not aware of?

Oh and a couple of suggestions to keep in mind for future versions:

1) Rotation. Allow what's in your buffer to be rotated 90 degress in either direction or 180 degrees.

2) A "ghost" image of what you have copied so you can see the outcome before you past.

Not commenting on the difficulty of these options and I certainly think they are extras rather than the main course. ;)

Keep up the good work! Oh, and keep your work updated to the trunk. That thing seems to be updated more and more every day.

-Hazelrah
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

Hazelrah wrote: About delaying, wouldn't it just be possible to use a standard C timer which would trigger the next build event when the time is up. It has the advantage that the speed could also be set. Or is there some sort of syncronization problem I'm not aware of?
Why not use the game internal timer (_tick_counter)?
Hazelrah wrote: 1) Rotation. Allow what's in your buffer to be rotated 90 degress in either direction or 180 degrees.
An array should not be hard to rotate, equal if a 1D or 2D array is used
Hazelrah wrote: 2) A "ghost" image of what you have copied so you can see the outcome before you past.
i think this is not possible currently, since there is no where a preview mode. But nice suggestion for a own patch :)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 24 guests