Howto apply a patch/diff file

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

Creat
Traffic Manager
Traffic Manager
Posts: 141
Joined: 26 Oct 2009 16:33

Re: Howto apply a patch/diff file

Post by Creat »

planetmaker wrote:TortoiseSVN doesn't understand all kind of diff files, though.
I know that it is recommended by the Wiki for compiling on Windows to install TortoiseSVN to get the source. I was wondering if it wasn't time to change that. After all afaik it still can't handle git/hg patches, and most 'freelance' developers seem to use either one nowadays (and for good reason). To me the most obvious reason for compiling your own binaries is to incorporate patches (otherwise you could just use binaries, right?), which isn't going to work if a significant percentage of patches can't be applied with the suggested program. Even if someone uses the opportunity to implement something himself (and get into programming) a solid/modern version management surely would have to be favored...

I haven't personally used it, but wouldn't TortoiseGit be a better suggestion, if keeping the easy-to-use GUI is a requirement, which I would assume it is? After all the source is also available as a git repo and bigger patches themselves are published in git repos as well (CargoDist, YACD). Also I'm sure it is much more tolerant towards various patch formats (as git itself is more tolerant in that regard).
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Howto apply a patch/diff file

Post by Alberth »

The master repository is still in subversion. Also, git has such nice, completely unreadable revision numbers. Hg is a bit better (incrementing decimal numbers, except the numbering is not the same as in subversion).

In my view, replacement is a step too far, but mentioning as alternative is certainly viable.
Please also explain how to get a given subversion revision number then. Most patches have a subversion revision number to patch against, so you must be able to update the git working copy to a given subversion revision number.
User avatar
Flowdy87
Engineer
Engineer
Posts: 10
Joined: 12 Feb 2012 20:26
Location: England

Re: Howto apply a patch/diff file

Post by Flowdy87 »

Hi.
I'm new and having some trouble applying a patch, im following the guide posted in this thread for using tortoiseSVN, The first part of the guide worked but when it came to applying the actual patch i right clicked on it and hit apply patch then i get a browse for folder screen which im assuming is the folder for OPENtt or am i wrong. if not when i link the open tt directory and click on i get a message saying

"This is not a working copy of open tt"

Now i don't know what else to do, im just to apply the patch to get the huge airports working.. Any help would be great. :)
Image

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

Re: Howto apply a patch/diff file

Post by planetmaker »

Flowdy87 wrote:Hi.
I'm new and having some trouble applying a patch, im following the guide posted in this thread for using tortoiseSVN, The first part of the guide worked but when it came to applying the actual patch i right clicked on it and hit apply patch then i get a browse for folder screen which im assuming is the folder for OPENtt or am i wrong. if not when i link the open tt directory and click on i get a message saying

"This is not a working copy of open tt"

Now i don't know what else to do, im just to apply the patch to get the huge airports working.. Any help would be great. :)
A "working copy" is in this context the source code of OpenTTD which you need / want to apply the patch to. It is NOT the binary you may have downloaded somewhere nor even from the official page.
User avatar
Flowdy87
Engineer
Engineer
Posts: 10
Joined: 12 Feb 2012 20:26
Location: England

Re: Howto apply a patch/diff file

Post by Flowdy87 »

Sorry i was doing it wrong :roll:

Although i do have another question as the first time round didnt work, im following MeusH tutorial on using tortoise svn, on attachment one when it says, x - location to your directory, which directory does this mean, the new folder your ment to make or the open ttd directory.

if so the open ttd directory didnt work and if its ment to be to the new folder where do i transfer the download and patches files to.

thanks
Image

Image
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Howto apply a patch/diff file

Post by Alberth »

You patch against a directory with OpenTTD source code.

http://wiki.openttd.org/FAQ_development#Source_code explains what source code is, how to compile source code to an executable program, and then (and only then imho) you can start thinking about patching.

(Getting the source, and compiling the unmodified sources first is a good way to test your compiler setup. If you also apply patches before the first compile and it does not work, it becomes very hard to find the cause by remote help through a forum like this.)
Eisenbaehr
Engineer
Engineer
Posts: 62
Joined: 29 May 2006 06:59
Location: Germany

Re: Howto apply a patch/diff file

Post by Eisenbaehr »

Bjarni wrote:...

on most systems:

Code: Select all

patch -p0 -i file.diff
the -p option means how many leading dirs that you skip when patching. ... this would be 1, because you need to skip the trunk part of it to get to the root dir of your local source folder

...
Many thanks, for this help!
User avatar
JacobD88
Chief Executive
Chief Executive
Posts: 708
Joined: 16 Aug 2008 17:51
Location: Long Eaton, Nottinghamshire. UK
Contact:

Re: Howto apply a patch/diff file

Post by JacobD88 »

Hi all,

Having a few problems installing the unzip package under MSYS
Error
Error
MinGWUnzipError1.png (14.85 KiB) Viewed 9216 times
Any help would be appreciated

Regards

Jacob
Last edited by JacobD88 on 22 Jan 2013 11:39, edited 1 time in total.
User avatar
cirdan
Director
Director
Posts: 539
Joined: 07 Apr 2007 18:08

Re: Howto apply a patch/diff file

Post by cirdan »

Could the package be called msys-unzip instead?
User avatar
JacobD88
Chief Executive
Chief Executive
Posts: 708
Joined: 16 Aug 2008 17:51
Location: Long Eaton, Nottinghamshire. UK
Contact:

Re: Howto apply a patch/diff file

Post by JacobD88 »

Yep, that's the one :rolleyes:

Dunno where i got MySYS from :lol:

Thanks Cirdan, been a while since i compiled anything; only doing for your patch in fact :mrgreen:
iconstil
Engineer
Engineer
Posts: 6
Joined: 05 Jul 2011 15:07

Re: Howto apply a patch/diff file

Post by iconstil »

Hi, I applied a simple diff file (town rating colors), but after that I cant play multiplayer games anymore. It says 'version mismatch' (red circle). Sorry for this noob question but is there any solution for this?
Or, if the patch only modifies the interface a bit (locally), it still says version mismatch so i cant play multiplayer games anymore. Do I need to reinstall, or is there any workaround for this issue?
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Howto apply a patch/diff file

Post by Eddi »

you can only play multiplayer with people who have the exact same patch applied. there is no way around this, since we cannot know whether the patch is really "display only" or not.
iconstil
Engineer
Engineer
Posts: 6
Joined: 05 Jul 2011 15:07

Re: Howto apply a patch/diff file

Post by iconstil »

But this is an open source program, so you can theoretically fake the version number, or anything is possible. I saw peaple who are playing with these patches in multiplayer.. (for example this colored town rating patch)

How the server knows for sure that I'm using the proper version, and not faking it..?
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Howto apply a patch/diff file

Post by Eddi »

Even if that is possible, it is not supported, so we will not give any advice how to do it.
jakob
Engineer
Engineer
Posts: 40
Joined: 10 Jan 2010 13:07

Re: Howto apply a patch/diff file

Post by jakob »

Can anyone please tell me how i install patch files or diff files easy, and step by step, so i don't get confused :)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Howto apply a patch/diff file

Post by planetmaker »

The very first posting of this thread explains it quite thoroughly...

Yes, it needs understanding of how to compile the complete game from source code. But there is no other way. Source code patches don't work like "click, apply and play".
Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: Howto apply a patch/diff file

Post by Supercheese »

jakob wrote:Can anyone please tell me how i install patch files or diff files easy, and step by step, so i don't get confused :)
1a) Follow these instructions: http://wiki.openttd.org/Microsoft_Visua ... s_Editions (They are very good instructions!)

Even if you have a 64-bit system, it's easier just to compile 32-bit binaries, so don't bother with the 64-bit stuff unless you really, really want to.

1b) Make sure you can successfully compile trunk OTTD

2) Download a patch file

3) Update the OTTD source to the revision specified by the patch (in Windows, right click > TortoiseSVN > Update to revision)

4) Right click patch, select TortoiseSVN > Apply Patch

5) Patch all the files and compile OTTD.

Bing boom, you've applied a patch. It might seem hard, but believe me, it is not excessively difficult. At least if you're running Windows 7 I can speak from experience. I used to think it was too hard, and now I can compile patched win32 binaries no prob. :)
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
MisterX
Engineer
Engineer
Posts: 36
Joined: 25 Mar 2013 18:24

Re: Howto apply a patch/diff file

Post by MisterX »

Is there an easy way to patch the game? The first post of this thread means nothing to me. patch -p0 -i file.diff? Where is that about? etc. I clicked on the link and then on the two option for windows. Before you start to patch the game, you need to download a program of 5-10? Non of them mean anything to mean. Isn't there an easier way for them who are not study something in the ict? There must be an easier way then use first 5-10 programs before patching is finished...
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Howto apply a patch/diff file

Post by planetmaker »

MisterX wrote:Is there an easy way to patch the game?
Patching the game yourself means you must be willing to get aquainted with the basics of compilation and programming. No easier way. There is not and will not be a one-click patch and play way ever.

Some (proprietary) games sometimes refer to download updates as patches which then simply can be applied. But that's actually wrong semantics.
MisterX
Engineer
Engineer
Posts: 36
Joined: 25 Mar 2013 18:24

Re: Howto apply a patch/diff file

Post by MisterX »

1 click is also over the top. But now you need 6-7 tools?! For me, that's the other end... There must exist one program, so you can patch a game with one program? That's a lot easier. Now you have to learn 6-7 programs before you can patch a game. That must be a joke?!

Just looked at the programs:
Microsoft Visual C++ 2008/2010 -> Link to Microsoft Visual C++ 2012 for windows 8?! Sorry, but i'm running at windows 7...
The link to the source doesn't works and for me is it not clear if you have to download openttd-useful.zip or openttd-useful.zip and the source.
Subversion command line version -> Broken link.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 9 guests