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

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: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.
Repairing a car with exactly one kind of wrench is also a lot easier than having to use the required tools in the required order. Right.
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 don't need to learn those programs, you need to install them and set them up. It is not our fault that Windows does not come with a complete development environment out of the box.

It's just like you need to install office before you can read and write documents.


Learning how those programs actually work and can be used for development is a very different problem, and it takes a much longer time to do.
MisterX
Engineer
Engineer
Posts: 36
Joined: 25 Mar 2013 18:24

Re: Howto apply a patch/diff file

Post by MisterX »

planetmaker wrote:
MisterX wrote: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.
Repairing a car with exactly one kind of wrench is also a lot easier than having to use the required tools in the required order. Right.
If you have a specialized dealer, he has specific tools with work better and faster for that kind of cars. Maybe as back-up he has the universal tools, but mostly he don't need them. The programs that are listed are some universal tools, in my eyes. They will work in every case, but are a lot harder.
Alberth wrote:You don't need to learn those programs, you need to install them and set them up. It is not our fault that Windows does not come with a complete development environment out of the box.

It's just like you need to install office before you can read and write documents.


Learning how those programs actually work and can be used for development is a very different problem, and it takes a much longer time to do.
As sais in previeus post: 3/6 of the tools are not clear to me / not available / ... So it is also impossible for me to try the way that's described...
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Howto apply a patch/diff file

Post by Eddi »

MisterX wrote:If you have a specialized dealer, he has specific tools with work better and faster for that kind of cars. Maybe as back-up he has the universal tools, but mostly he don't need them. The programs that are listed are some universal tools, in my eyes. They will work in every case, but are a lot harder.
yes, you do have a specialized dealer, he's called openttd.org and he has all the tools in a ready-to-use fashion to provide you with a "just pick it up and go" version of the game.

but you don't want the off-the-shelves version, instead you want to tamper with it yourself, and then you bother us with the complaint that you need tools to work on it?
User avatar
kamnet
Moderator
Moderator
Posts: 8548
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: Howto apply a patch/diff file

Post by kamnet »

And now you start to understand all of the hard work that goes into developing software!

I am pretty lazy when it comes to having to do things, but earlier this year I decided to learn how to install patches. I hit a few bumps as well, but if you carefully read the instructions, you can install all the various programs and learn how to compile the patches. And once you have the software installed, the most difficult part is over, and you never have to deal with that again.
MisterX
Engineer
Engineer
Posts: 36
Joined: 25 Mar 2013 18:24

Re: Howto apply a patch/diff file

Post by MisterX »

Eddi wrote:yes, you do have a specialized dealer, he's called openttd.org and he has all the tools in a ready-to-use fashion to provide you with a "just pick it up and go" version of the game.

but you don't want the off-the-shelves version, instead you want to tamper with it yourself, and then you bother us with the complaint that you need tools to work on it?
I see openttd as the factory, not as dealer. But i think, we will continu disagree with this and don't come to a agreement.

As i said, not all tools are clear / available, so i can't give it i try by my self.
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.
Is Microsoft Visual C++ 2012 also okay and can it run on windows 7? Will it works the samen as 2008/2010?
What is the link to the source, at the wiki is a dead link. And have I download the openttd-usefil.zip and the source, or only opentt-usefull.zip?
Where can I found Subversion command line version, since the link is broken.
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 »

MisterX wrote:Is Microsoft Visual C++ 2012 also okay and can it run on windows 7? Will it works the samen as 2008/2010?
VS 2012 has added some new restrictions that breaks the build. You have to delete some lines, as shown in the attachment of http://bugs.openttd.org/task/5375#comment12071
MisterX wrote:What is the link to the source, at the wiki is a dead link.
What link are you talking about? Please be more precise in your statements. "link does not work" is difficult to decode when there are several links at many wiki pages, and where some of those links are not supposed to be viewed with a browser.

For now, I assume you mean "svn://svn.openttd.org/trunk". That link is not dead, you need subversion (svn == subversion) to access it, your browser does not speak "svn:". When you click at the link it is telling you that.

MisterX wrote:And have I download the openttd-usefil.zip and the source, or only opentt-usefull.zip?
The source is useful if you want to build the libraries from source code. If you don't want to do that, use the zip with the pre-build libraries (at least I hope that's it, I never looked in the file).
MisterX wrote:Where can I found Subversion command line version, since the link is broken.
You know of this thing called Internet right?
It has very nice services to find sites, if you don't mind telling commercial companies what you kind of commercials you want to view.

Anyway, if you had used such a service, you could have found the new home of the subversion project, namely http://subversion.apache.org/

Good luck with continuing your adventure.
It may be useful to join the #openttd irc channel for help, there are several people there that know about windows and compiling OpenTTD. It's often easier to interactively talk someone through the process.
MisterX
Engineer
Engineer
Posts: 36
Joined: 25 Mar 2013 18:24

Re: Howto apply a patch/diff file

Post by MisterX »

Alberth wrote:
MisterX wrote:Is Microsoft Visual C++ 2012 also okay and can it run on windows 7? Will it works the samen as 2008/2010?
VS 2012 has added some new restrictions that breaks the build. You have to delete some lines, as shown in the attachment of http://bugs.openttd.org/task/5375#comment12071
Will have a look at it.
MisterX wrote:What is the link to the source, at the wiki is a dead link.
What link are you talking about? Please be more precise in your statements. "link does not work" is difficult to decode when there are several links at many wiki pages, and where some of those links are not supposed to be viewed with a browser.
Bjarni wrote:Patching (applying a patch/diff file) is done to OpenTTD's sources. This implies that you have to get the sources to apply the patch/diff and compile OpenTTD yourself.
From first post of this topic. Since I run on windows, i clicked on Compiling on Windows using Microsoft Visual C++ 2005 and Compiling on Windows using Microsoft Visual C++ 2008/2010. For both, a list of some programs is listed. I'm talking about that list. Compiling on Windows using MinGW was also a option, but that list is way bigger, so it seems to me much difficult to do.

For now, I assume you mean "svn://svn.openttd.org/trunk". That link is not dead, you need subversion (svn == subversion) to access it, your browser does not speak "svn:". When you click at the link it is telling you that.

MisterX wrote:And have I download the openttd-usefil.zip and the source, or only opentt-usefull.zip?
The source is useful if you want to build the libraries from source code. If you don't want to do that, use the zip with the pre-build libraries (at least I hope that's it, I never looked in the file).
I only want to patch the game. So the answer is in that case only openttd-usefil.zip?
MisterX wrote:Where can I found Subversion command line version, since the link is broken.
You know of this thing called Internet right?
It has very nice services to find sites, if you don't mind telling commercial companies what you kind of commercials you want to view.

Anyway, if you had used such a service, you could have found the new home of the subversion project, namely http://subversion.apache.org/
It seems to me some general name and i wasn't sure that I take the right program.
Good luck with continuing your adventure.
It may be useful to join the #openttd irc channel for help, there are several people there that know about windows and compiling OpenTTD. It's often easier to interactively talk someone through the process.
Thanks. I think, tonight i will have a closer look. So maybe i join that irc channel.
User avatar
Ethereal
Engineer
Engineer
Posts: 16
Joined: 16 Sep 2012 22:37

Re: Howto apply a patch/diff file

Post by Ethereal »

Ok i dont like to necro.. but i'm lost. What do i do after i patch with the SVN ? I mean.. i got the headers (the .c/f files) what's the next step?
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 compile the source code to an executable :)
The collection of .h and .cpp files are the human-readable form of the program, commonly referred to as "source code". A computer cannot execute it in this form. To make it executable by a computer, you need to convert the source code to binary form, ie a .exe file.

How to do that depends on your system. http://wiki.openttd.org/FAQ_development ... pile_it.3F gives some options and explanations how to do this.

If you have never done this before, it is recommended to do this with an unmodified version (that is, without applying a patch) first. That code is known to compile, so any errors you get are in your setup, and not in the modifications introduced by the patch.

Once you've got the setup working, you can apply a patch, and run the procedure again.
User avatar
Ethereal
Engineer
Engineer
Posts: 16
Joined: 16 Sep 2012 22:37

Re: Howto apply a patch/diff file

Post by Ethereal »

Oh yes.. that reminds me, i got several errors while compiling it.. i was trying to add the Huge airports http://www.tt-forums.net/viewtopic.php?f=33&t=56933 into this version svn://svn.openttd.org/trunk , but idk if those errors were expected .. hmm
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 »

Ethereal wrote:Oh yes.. that reminds me, i got several errors while compiling it.. i was trying to add the Huge airports http://www.tt-forums.net/viewtopic.php?f=33&t=56933 into this version svn://svn.openttd.org/trunk , but idk if those errors were expected .. hmm
Probably; That topic says "v6: Updated against r23729.", while "svn://svn.openttd.org/trunk" is at this moment r25266, if you don't specify a revision while getting the source code from svn.
Since each change in the source code increments the number by 1, you try to apply a patch written for OpenTTD about 1500 changes earlier. That may give some trouble :)

A way that should work is to specify to svn that you are interested in revision 23729 (svn update -r 23729). The patch should apply cleanly to that set of sources.
AlexKM
Engineer
Engineer
Posts: 1
Joined: 09 Apr 2014 18:46

Re: Howto apply a patch/diff file

Post by AlexKM »

Hi, hopefully someone may be able to help with this. New poster, though been lurking a while.

I've tried to compile the trunk version (r 26446) with a view to trying out a couple of patches. I'm on Windows 7 and have followed the instructions for compiling with MinGW at http://wiki.openttd.org/Compiling_on_Wi ... sing_MinGW

Initially it worked fine, I was able to compile trunk, installed OpenGFX and everything ran fine.

I played around with some patches figuring out how to get them to compile, all looked good, tried running, hit a few errors, tried to debug, failed. So thought I'd be better off starting from scratch.

So, completely deleted my trunk download folder and did another get with SVN. Compiled ok (no patches, vanilla trunk), but now when I run the executable it immediately crashes on load. I've tried reboots, and I've tried cleaning out my MinGW install and re-starting the entire thing from scratch, but still no luck.

It crashes immediately with the following error. I don't know if this is the right information for anyone to deduce what the issue might be, or if there's any different info/logs that might shed a bit more light on this.

Thanks to anyone who might be able to help :)

Code: Select all

*** OpenTTD Crash Report ***

Crash at: Wed Apr 09 19:06:13 2014
In game date: 0-01-01 (0)

Crash reason:
 Exception: E1212012
 Location:  753FC41F
 Message:   <none>

OpenTTD version:
 Version:    r26451 (0)
 NewGRF ver: 15006753
 Bits:       32
 Endian:     little
 Dedicated:  no
 Build date: Apr  8 2014 23:14:45

Registers:
 EAX: 0028D5A4 EBX: 00000016 ECX: 00000000 EDX: 0008E3C8
 ESI: 75143180 EDI: 00000000 EBP: 0028D5F4 ESP: 0028D5A4
 EIP: 753FC41F EFLAGS: 00000246

 Bytes at instruction pointer:
 C9 C2 10 00 CC CC CC CC CC 8B FF 55 8B EC 56 8B 75 08 83 FE F4 72 18 83

Stack trace:
 E1212012 00000000 00000000 753FC41F 00000000 0028D5D8 7535FCF1 000606C4
 751464A8 750F03E0 00012010 00000000 FFFFFFFF 0028D5F4 7535FD36 000606C4
 76FFFAEA 77021092 FFFFFFFF 00000024 0028D614 00528DEA E1212012 00000000
 00000000 00000000 75140290 0028D660 0028D660 75105E8F 00000016 E7964188
 0091FD88 75142940 75142900 76FFFAEA 77019DEC 00000000 00000024 00528DC0
 00000001 0028D620 0028D148 0028FFC4 750C8CD5 92AEC950 FFFFFFFE 0028D998
 75108EA2 00000016 75142940 0028D834 00000000 0028D838 0028D83C 00000000
 0028D848 0028D840 0028D844 0028D84C 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 0028D850 006668ED 00000000
 00000000 00000000 00666600 40000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 0028D964 00000000 0028D968 0028D998 0028D63C
 0028D978 0028D970 0028D974 0028D99C 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 0028D9A0 0074327C 007F9638
 00000000 00000000 00743170 40000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 FFFFFFEC 00000001 00000000 00000000 FFFFFFF8 00000001 FFFFFFF0
 00000001 FFFFFFF4 00000001 FFFFFFFC 00000001 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000040 00000004 00000000 00000001 00743177 00770470 FFFFFFFC 00000001
 00000008 0001001B 00000000 77013CFE 00F72110 00000002 75142900 75142940
 0091FD88 00F7C7B8 0074323B 00F72110 0028DA18 0028DA10 0028DA14 0028DA1C
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 0028DA20 0077037F 00000000 00000000 00000000 00666600 00000003

Operating system:
 Name:     Windows
 Release:  6.1.7601 (Service Pack 1)
 Compiler: GCC 4.8.1 "4.8.1"

Configuration:
 Blitter:      8bpp-optimized
 Graphics set: OpenGFX (5203)
 Language:     C:\MinGW\msys\1.0\home\Alex\trunk\bin\lang\english.lng
 Music driver: none
 Music set:    NoMusic (0)
 Network:      no
 Sound driver: none
 Sound set:    NoSound (2)
 Video driver: win32

Fonts:
 Small:  sprite
 Medium: sprite
 Large:  sprite
 Mono:   sprite

AI Configuration (local: 0):

Libraries:
 LZMA:       5.0.4
 LZO:        2.06
 PNG:        1.5.16
 Zlib:       1.2.8

Module information:
 C:\MinGW\msys\1.0\home\Alex\trunk\bin\openttd.exe handle: 00400000 size: 9323817 crc: 7D4440EB date: 2014-04-08 22:20:56
 C:\Windows\SysWOW64\ntdll.dll handle: 76fe0000 size: 1292192 crc: 87C3B42F date: 2013-12-11 03:02:34
 C:\Windows\syswow64\kernel32.dll handle: 74a60000 size: 1114112 crc: 8F4ED6D1 date: 2014-03-04 09:16:17
 C:\Windows\syswow64\KERNELBASE.dll handle: 753f0000 size: 274944 crc: C96F6E3E date: 2013-08-02 01:50:42
 C:\Windows\syswow64\advapi32.dll handle: 751e0000 size: 640512 crc: 939A0B41 date: 2013-12-11 03:02:34
 C:\Windows\syswow64\msvcrt.dll handle: 750a0000 size: 690688 crc: DAB48B3A date: 2011-12-16 07:52:58
 C:\Windows\SysWOW64\sechost.dll handle: 751a0000 size: 92160 crc: B624B29A date: 2009-07-14 01:16:13
 C:\Windows\syswow64\RPCRT4.dll handle: 76510000 size: 663552 crc: A34B30BE date: 2013-07-09 04:52:33
 C:\Windows\syswow64\SspiCli.dll handle: 74a00000 size: 96768 crc: 60665434 date: 2013-09-25 01:58:17
 C:\Windows\syswow64\CRYPTBASE.dll handle: 749f0000 size: 36864 crc: 00308E17 date: 2009-07-14 01:15:07
 C:\Windows\syswow64\gdi32.dll handle: 75440000 size: 311808 crc: 156F979F date: 2013-10-03 02:00:44
 C:\Windows\syswow64\USER32.dll handle: 752f0000 size: 833024 crc: 9EFE504D date: 2010-11-20 12:08:57
 C:\Windows\syswow64\LPK.dll handle: 74bd0000 size: 25600 crc: 3A7246AE date: 2013-06-06 04:57:01
 C:\Windows\syswow64\USP10.dll handle: 76830000 size: 626176 crc: A5ECB486 date: 2010-11-20 12:21:33
 C:\Windows\syswow64\imm32.dll handle: 74b70000 size: 119808 crc: 38DB5163 date: 2010-11-20 12:08:51
 C:\Windows\syswow64\MSCTF.dll handle: 75770000 size: 828928 crc: DFE09EEB date: 2009-07-14 01:15:43
 C:\Windows\syswow64\shell32.dll handle: 75870000 size: 12872704 crc: C9774862 date: 2013-07-26 01:55:59
 C:\Windows\syswow64\SHLWAPI.dll handle: 76600000 size: 350208 crc: 23E05F73 date: 2010-11-20 12:21:19
 C:\Windows\system32\winmm.dll handle: 748b0000 size: 194048 crc: 849223C7 date: 2010-11-20 12:21:36
 C:\Windows\syswow64\ws2_32.dll handle: 75150000 size: 206848 crc: FD00A753 date: 2010-11-20 12:21:38
 C:\Windows\syswow64\NSI.dll handle: 751c0000 size: 8704 crc: 2ACE9671 date: 2009-07-14 01:16:11
 C:\Windows\system32\AirfoilInject3.dll handle: 748f0000 size: 175176 crc: 3618D8AB date: 2013-11-09 07:55:30
 C:\Windows\syswow64\ole32.dll handle: 74be0000 size: 1414144 crc: 74A1E844 date: 2010-11-20 12:20:49
 C:\Windows\system32\uxtheme.dll handle: 70370000 size: 245760 crc: 60C5C746 date: 2009-07-14 01:11:24
 C:\Program Files (x86)\O2\bin\sprthook.dll handle: 62980000 size: 116000 crc: 88EE1C70 date: 2009-03-04 14:52:40
 C:\Windows\system32\OLEACC.dll handle: 74070000 size: 233472 crc: 6B296DD6 date: 2011-08-27 04:26:27
 C:\Windows\syswow64\OLEAUT32.dll handle: 74d40000 size: 571904 crc: 2B85E126 date: 2011-08-27 04:26:27
 C:\Program Files (x86)\Common Files\microsoft shared\ink\tiptsf.dll handle: 6cdf0000 size: 348160 crc: 7D193B81 date: 2009-07-14 01:16:16
 C:\Windows\system32\version.dll handle: 74330000 size: 21504 crc: 88D9D0F1 date: 2009-07-14 01:16:17
 C:\Windows\system32\dwmapi.dll handle: 6de00000 size: 67072 crc: FC7CA4B8 date: 2009-07-14 01:15:13
 C:\Windows\syswow64\CLBCatQ.DLL handle: 75660000 size: 522240 crc: 6C130B8A date: 2009-07-14 01:15:03
 C:\Windows\system32\mswsock.dll handle: 73650000 size: 231424 crc: 2A2905A9 date: 2013-12-11 03:02:09
 C:\Windows\System32\wshtcpip.dll handle: 73240000 size: 9216 crc: BA963A19 date: 2009-07-14 01:16:20
 C:\Windows\system32\MMDevAPI.DLL handle: 6f580000 size: 213504 crc: 93C0AA4F date: 2010-11-20 12:19:39
 C:\Windows\system32\PROPSYS.dll handle: 70440000 size: 988160 crc: 888D0BCB date: 2010-11-20 12:20:57
 C:\Windows\system32\wdmaud.drv handle: 6ffc0000 size: 172032 crc: D5B9F5FA date: 2010-11-20 12:16:50
 C:\Windows\system32\ksuser.dll handle: 6ffb0000 size: 4608 crc: EBE07232 date: 2009-07-14 01:15:35
 C:\Windows\system32\AVRT.dll handle: 6aee0000 size: 14336 crc: 9818237B date: 2009-07-14 01:14:58
 C:\Windows\syswow64\SETUPAPI.dll handle: 74f00000 size: 1667584 crc: 1D0104E8 date: 2010-11-20 12:21:14
 C:\Windows\syswow64\CFGMGR32.dll handle: 76bb0000 size: 145920 crc: 377B5190 date: 2011-05-24 10:39:38
 C:\Windows\syswow64\DEVOBJ.dll handle: 75600000 size: 64512 crc: 66B02A5A date: 2011-05-24 10:40:05
 C:\Windows\system32\AUDIOSES.DLL handle: 6f6b0000 size: 195584 crc: 0A7E52B1 date: 2010-11-20 12:18:05
 C:\Windows\system32\msacm32.drv handle: 6ff50000 size: 20992 crc: 73923147 date: 2009-07-14 01:14:08
 C:\Windows\system32\MSACM32.dll handle: 6fc10000 size: 72192 crc: ABA25814 date: 2009-07-14 01:15:42
 C:\Windows\system32\midimap.dll handle: 6ff30000 size: 16896 crc: C000494C date: 2009-07-14 01:15:40
 C:\Windows\syswow64\psapi.dll handle: 76fb0000 size: 6144 crc: 25B988F9 date: 2009-07-14 01:16:12

---- gamelog start ----
---- gamelog end ----

*** End of OpenTTD Crash Report ***
Gigigonzalez
Engineer
Engineer
Posts: 91
Joined: 12 Jun 2014 14:24

Re: Howto apply a patch/diff file

Post by Gigigonzalez »

Hi all. Im trying to patch older/newer revision patches versus a trunk version, and Its going fairly well. I kind of use notepad ++ (side by side) to compare and try to find the exact spot on where the new lines should be, or which ones should be removed.

Is there some easier way to do this? Or am i doing it right? Is this the proper way to do it?
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: Howto apply a patch/diff file

Post by keoz »

Gigigonzalez wrote:Hi all. Im trying to patch older/newer revision patches versus a trunk version, and Its going fairly well. I kind of use notepad ++ (side by side) to compare and try to find the exact spot on where the new lines should be, or which ones should be removed.

Is there some easier way to do this? Or am i doing it right? Is this the proper way to do it?
If by "patching" you mean, apply a *.patch or *.diff file (which is basically the same), the process is far more straightforward and you can do that automatically, without even opening your source code. At least under linux environment (but there probably is some way to do similar thing under windows): you just go in the base directory of your source (here: openttd's trunk directory) and you issue the command:

Code: Select all

patch -p0 < file.patch
(the choice of -p0 or -p1, or eventually more, depending by the way the patch is built)

With that, all the modifications are automatically applied on your source, without you needing to even touch to the source file.

BUT: also note that - depending on the respective version (actual trunk version and trunk version against which the patch has been built) - the patch will or will not apply (or, will or will not apply correctly). If you apply an old patch on a recent version of OTTD, there is a chance that the new code just doesn't work.

So, if you apply several different patches, and specially for old ones, you should check if OTTD still behaves normally (by compiling and testing).
Last edited by keoz on 25 Aug 2014 21:52, edited 1 time in total.
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
Gigigonzalez
Engineer
Engineer
Posts: 91
Joined: 12 Jun 2014 14:24

Re: Howto apply a patch/diff file

Post by Gigigonzalez »

keoz wrote:
Gigigonzalez wrote:Hi all. Im trying to patch older/newer revision patches versus a trunk version, and Its going fairly well. I kind of use notepad ++ (side by side) to compare and try to find the exact spot on where the new lines should be, or which ones should be removed.

Is there some easier way to do this? Or am i doing it right? Is this the proper way to do it?
If by "patching" you mean, apply a *.patch or *.diff file (which is basically the same), the process is far more straightforward and you can do that automatically. At least under linux environment (but there probably is some way to do similar thing under windows): you just go in the base directory of your source (here: openttd's trunk directory) and you issue the command:

Code: Select all

patch -p0 < file.patch
(the choice of -p0 or -p1, or eventually more, depending by the way the patch is built)

With that, all the modifications are automatically applied on your source, without you needing to even touch to the source file.
But thati snt the case if a patch isnt made for a specific revision other then the one it was made for. I can patch fine, i mean the actual editing because lines shift up or down because source got slightly changed etc. My question was based on that really, do I do it the right way when editing, or is there an easier way other then having two notepads open and manually insert/remove lines
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Howto apply a patch/diff file

Post by Eddi »

there are also programs for "three-way diffs", which also compare the current trunk version with the trunk version the patch was made for, which can save you from doing some of the editing. but eventually you probably have to touch some code manually, when updating or combining patches.
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 »

Gigigonzalez wrote:Hi all. Im trying to patch older/newer revision patches versus a trunk version, and Its going fairly well. I kind of use notepad ++ (side by side) to compare and try to find the exact spot on where the new lines should be, or which ones should be removed.

Is there some easier way to do this? Or am i doing it right? Is this the proper way to do it?
No, probably not, mostly.

Assuming those answers made little sense, a somewhat longer answer :)

A source file is "a work under construction". A revision is a point in time for the work. A patch is a proposed change for the work under construction, at a given revision.
It is pretty likely that the patch will work for the given revision.

When you change the revision, the work under construction changes. 'Physically', lines of text get added, moved, changed, or even removed. The more important changes are the semantical changes. These are however not always visible in the file that you change. The set of allowed values in a variable gets smaller or bigger. Enumerations get additional values. New variables are added that have to be taken into account as well. Variables change meaning, or its unit changes.

To make it more concrete, a somewhat contrived example

Code: Select all

 int f(int x, y) {
     y = x + y;
+  y /= x;
     return y;
 }
The patch line (indicated with "+") scales y w.r.t x. In one revision this works. Say that in the next revision, variable 'x' is extended with the value "0", meaning "x is not relevant". In the unpatched version, nothing has to change, y+x == y when x == 0, which nicely matches "x does not play".
However if you add the patch line in the new revision, you will cause a crash of the program.

So conceptually, to apply a line with a change, you have to check that the change will work under every condition in the current revision, in particular taking all changes since the patch was created, into account.
This is pretty close to actually programming the patch again.

Your approach of just finding the point to insert the changed line will thus fail in the general case, if you don't take care of the semantical changes that happen with each change.
However, if you look at the changes made from revision to revision, and they do not touch the area of your patch (say your patch is about towns, and the revisions do stuff in cargo packets), it is fairly safe to assume the patch will still work. (Often it will even apply cleanly in such a case.)

There is thus no easier way, in fact the really proper way is like normal programming the patch again.
Your approach is more risky, but may work in a lot of cases.
Being a retired OpenTTD developer does not mean I know what I am doing.
bitterdevil
Engineer
Engineer
Posts: 8
Joined: 07 Feb 2016 17:53

Re: Howto apply a patch/diff file

Post by bitterdevil »

i think i don't have the compiler gene :( i've tried both ways, msys and svn....and every time, after i finish patching, i can't find the openttd exe :( what am i doing wrong?
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 tried compiling too?
In other words, the steps are

1. Install compiler
2. Download openttd source code

# Compile the source code in the following 2 (or 3) steps
3. Configure
4. Make
5. (optional) Make install
6. Test the created binary
# If it runs, you know the compiler setup is fine

# Patching is best post-poned until this point. If you patch before the first compile test, you don't know if your compiler setup is wrong, or the patch is wrong.
7. Patch the source code
8. Compile again (like steps 3, 4, 5)
Being a retired OpenTTD developer does not mean I know what I am doing.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 8 guests