[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
Anon
Engineer
Engineer
Posts: 16
Joined: 20 Jun 2010 19:20

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

Post by Anon »

Updated against 1.0.2
Attachments
clipboard_1.0.2.diff
(252.55 KiB) Downloaded 394 times
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

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

Post by belugas »

Currently? The sun.
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

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

Post by Kogut »

belugas wrote:Currently? The sun.
It is probably spambot.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

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

Post by Lord Aro »

Made me lol.

Basically, people got all huffy that the developers wouldn't include it, even though it obviously wasn't finished. Then development and support sort of dried up

The thread with the latest version has v3 in its name, i think
Or you could try chillcore's patchpack
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
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 all! I'm getting back to work on the patch. I don't promise anything but there should be beta in next few months if I find enough time.
:] don't worry, be happy and checkout my patches
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 »

I for one apreciate it :)
I love the function of copy and paste :)
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 »

Thank you, adf88, for developing this feature. I'm happy to see it is developing in good hands. I have always found it useful in it's earlier forms. When i was creating larger networks, there was building of several hours without this feature, and that was annoying, because time for OTTD is limited (at least on my side). It is much more creative to spend time to handle traffic and plan for extensions etc, etc. on OTTD than spend time to repeat everything (for example, the station areas) when building new branch lines. This feature cuts network building times to maybe 1/10th of which it is without it, and still does not make the game too dumb copy-pasting, because you always have other things than manual building to do. That's why it is one of my favorite requested features. :)
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 approach:
adf88 wrote: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...

...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.
read more --> http://www.tt-forums.net/viewtopic.php?p=945067#p945067 <--

And that's the code:
TheClipboard_0.1alpha-r22441.diff
(416.04 KiB) Downloaded 198 times
// EDIT
press Ctrl+C or Ctrl+V to show the clipboard toolbar
Attachments
copypaste.grf
(4.63 KiB) Downloaded 248 times
:] don't worry, be happy and checkout my patches
ndh
Engineer
Engineer
Posts: 13
Joined: 30 Apr 2011 11:09

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

Post by ndh »

Code: Select all

-typedef uint32 TileIndex;    ///< The ID of a tile (just named differently).
+typedef uint32 RawTileIndex; ///< The ID of a tile (just named differently).
Why? It makes the patch kinda unreadable. Refactorings and features don't go well together in diffs. I suggest you undo that.
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 »

That's not just a new name. RawTileIndex is a new type with new meaning. Basically tile index handling changed. TileIndex is a class now. The code you quoted comes from the AI API. It have to be RawTileIndex there instead of TileIndex because Squirrel doesn't handle custom types, just those built-in.

The goal was to generalize map accessors to work not only with the main tile map, but also with other maps. Originally map accessors take just a tile index - a 32 bit integer pointing to a certain tile. In the patch I had also to point which map to operate on. I had two choices - pass map pointer on run time (as an additional argument) or bind to a certain map on compile time using templates. I decided to use templates. This solution requires less modifications and is more flexible. I don't have to change bodies of functions but just define tile index differently in their declarations. A lot of functions stayed unchanged or almost unchanged. It's also safer - it's hard to point a wrong map.

So now we have...

Tile index not bounded to any map:

Code: Select all

typedef uint32 RawTileIndex; 
Tile index bounded to a map.

Code: Select all

template <typename Tmap>
struct TileIndexT {
public:
    static TileIndexT<Tmap> INVALID;

    RawTileIndex index;

public:
    FORCEINLINE TileIndexT() { }
    FORCEINLINE TileIndexT(const TileIndexT<Tmap> &tile) : index(tile.index) { }
    FORCEINLINE TileIndexT(RawTileIndex index) : index(index) { }

private:
    template <typename Tother_map>
    TileIndexT(const TileIndexT<Tother_map> &tile) { NOT_REACHED(); }

public:
    FORCEINLINE operator const RawTileIndex& () const { return this->index; }
    FORCEINLINE operator RawTileIndex& () { return this->index; }
}; 
Tile index bounded to the main map, it's named "TileIndex" like the original:

Code: Select all

typedef TileIndexT<Map> TileIndex; 
Exemplar map accessor:

Code: Select all

template <typename Tmap>
static inline bool IsPlainRailTile(TileIndexT<Tmap> t)
{
    return IsTileType(t, MP_RAILWAY) && IsPlainRail(t);
} 
:] 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 »

The Clipboard 0.1 Beta 1 is ready!

What does not work (and won't work until v0.2 or later):
  • - Condition: non-allow-partial-paste mode (when you depress the button with a broken wall image), terraforming is on (either full or minimal)
    - Expected result: Whole template is successfully pasted.
    - Possible result: Nothing is pasted, you get an error message that says the paste operation is impossible because of improperly terraformed land. These errors are "site unsuitable", "land slope in wrong direction", "flat land required" etc.
  • - Condition: non-allow-partial-paste mode
    - Expected result: Nothing is pasted (because the land cannot be terraformed or because of local authorities or you don't have enough money etc.)
    - Possible result: The template is pasted partially.
  • copy/pasting stations (and waypoints)
  • precise cost estimation
Some features you've never met:
  • Minimal terraforming
  • Instant copy/pasting in multiplayer (requires patched server)
  • Cannals support
Attachments
the_clipboard_0.1beta1_r22752.diff
(261.46 KiB) Downloaded 176 times
:] don't worry, be happy and checkout my patches
User avatar
JacobD88
Chief Executive
Chief Executive
Posts: 708
Joined: 16 Aug 2008 17:51
Location: Long Eaton, Nottinghamshire. UK
Contact:

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

Post by JacobD88 »

adf88 wrote:The Clipboard 0.1 Beta 1 is ready!
Fantastic work adf88, downloading now :bow:
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 »

Beta 2.
- fixed compilation errors in "release" configuration
- fixed pasting on water (DC_NO_WATER flag was omitted)
- fixed road depot pasting (we had a piece of road instead of a depot)
Attachments
the_clipboard_0.1beta2_r22758.diff
on MSVC build "generate" project first
(321.86 KiB) Downloaded 241 times
:] don't worry, be happy and checkout my patches
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 »

A friend of mine made a playable version for windows (i tried myself but it seems i have things to learn because i was unsuccessful).
He mentioned that the function "EmptyClipboard" was duplicated on windows version since there already are such a function in some windows related thingie, he also said the programmer most likely didnt use windows.

Then we couldnt find the proper grf that was asked for during compilation i think so we used some old copypaste.grf from frostregens version we found somewhere.
I'll update this post when i have talked with my friend again.

It works really nice when it works but we have noticed during play that it crash under some circumstances.
Like sometimes when pasting with minimal terraforming or a part of the layout ending up under the waterlevel, or pasting directly on water even tho the original is taken from waterlevel, like an island with something on it.

Here is the compiled game om my webserver, tho the ip might change making this link unuseful, i hope it wont happen anytime soon tho.
http://85.229.12.253/intermundi/ottdcp.zip
http://openttd.org - i love building stuff :)
Someones play with pics http://dimalimsliv.blogg.se
lordwurst
Engineer
Engineer
Posts: 10
Joined: 30 Oct 2008 08:00

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

Post by lordwurst »

could someone just tell me what to do to use this patch?? read some stuff in the net but I don't really get it... so pleas try to explain it for a total noob
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 »

The general idea is that one take the pach and apply it to the sourcecode of the official version of openttd, this patch was supposed to be used with one particular nigtly build i think, not a release like 1.1.3 for example.

Then when you get it to work youre supposed have new tools so you can copy and paste tracks instead of building them by hand.
When i use it i save A LOT of time building big and efficient networks, i find this particular patch very useful and i apreciate the work that has been put down to code it :)

At the moment that link is down so noone can download it due to a crashed 30GB harddrive named Hitatchi deskstar.
http://openttd.org - i love building stuff :)
Someones play with pics http://dimalimsliv.blogg.se
dbncoold
Engineer
Engineer
Posts: 11
Joined: 22 Aug 2009 22:04

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

Post by dbncoold »

Great job, adf88!

This needs to get into trunk ASAP. This feature has been a "patch" for a very long time, and I would argue that it should be the #1 priority for a new feature. It makes OpenTTD so much more fun, and lets you build complicated stuff within minutes that will normally take hours.

Anyways, here it is diff-ed and compiled for Windows. Enjoy!
Attachments
the_clipboard_0.1beta2_r22758_Windows.diff
(323.12 KiB) Downloaded 154 times
OpenTTD.zip
r22758MClipboard
(2.76 MiB) Downloaded 171 times
Last edited by dbncoold on 01 Nov 2011 17:16, edited 3 times in total.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

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

Post by planetmaker »

Please include the necessary license and copyright information or we'll have to remove the build. Best build a complete bundle as that includes all required files, including the version-specific language files and base set complements as well.
dbncoold
Engineer
Engineer
Posts: 11
Joined: 22 Aug 2009 22:04

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

Post by dbncoold »

Hi planetmaker,

I have added COPYING to the zip file.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

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

Post by ChillCore »

dbncoold wrote: I have added COPYING to the zip file.
Unfortunately your zip is still missing a LOT of needed files; the executable alone is not a complete binary even if you include COPYING.

Instead of listing everything that is missing ... just use the "make bundle" command after compilation, a bundle folder will be created next to the bin folder with all files that need to be included in your zip.

Also, please do not name the zip OpenTTD to not confuse people and take it for an official (read: not modified) release but instead rename it to something more usefull; using the same name as the diff might be a good idea? ;)


ps:
@The four other downloaders:
Why do you not speak up if you downloaded a binary that is:
a. Not complete :? and
b. Not functional :roll:
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google Adsense [Bot] and 12 guests