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

zedd
Engineer
Engineer
Posts: 74
Joined: 13 Mar 2007 02:38

Re: Howto apply a patch/diff file

Post by zedd »

The stuff is all in the right place according to what your write.

I made a new SVN checkout and moved the patch file into trunk. (I can't use patch anywhere in cmd just where the patch.exe actually is)

I have attached screenshots of the process

EDIT: clutter screenshots removed as issue is resolved
Last edited by zedd on 31 Oct 2009 23:20, edited 1 time in total.
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Howto apply a patch/diff file

Post by fonso »

The files and folders look quite good, but your patch.exe is broken. It crashes and throws an assertion. Obviously this is not the one which will accept patches from git.
The guy on the picture is not me, it's Alonso.
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Howto apply a patch/diff file

Post by petert »

And if you need one, then try MinGW and MSYS.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Howto apply a patch/diff file

Post by Terkhen »

Gnuwin32 patch can apply patches from git correctly (I use it for smallmap zoom out), but is very picky regarding end of line characters. To use patches created in UNIX, you must convert them to Windows format first. Any good text editor (which of course excludes Notepad) will allow you to change the EOL format to Windows: for example Notepad++.

Edit: Also you can use the Gnuwin32 version of unix2dos called u2d, that can be found at the Cygutils package.

Code: Select all

u2d patch.diff
patch -p[0|1] -i patch.diff
zedd
Engineer
Engineer
Posts: 74
Joined: 13 Mar 2007 02:38

Re: Howto apply a patch/diff file

Post by zedd »

Terkhen wrote:unix2dos
Finally there is the problem. I should have remembered that from my 1 credit UNIX usage class at uni :)

Thanks a lot.
Now lets just hope this stuff compiles too...
griffin71
Traffic Manager
Traffic Manager
Posts: 142
Joined: 31 Mar 2007 13:11
Location: Amsterdam

Re: Howto apply a patch/diff file

Post by griffin71 »

Hi, I'm lost applying a patch.

Wiki sais:
Windows: Make sure you have TortoiseSVN installed.
Right-click on the folder with the OpenTTD source code, open the TortoiseSVN submenu and select 'Apply Patch...'. Browse to the patch file and select it. Then, right click on the 'File Patches' window and click on 'Patch All'. After you're done, close the TortoiseMerge window.
OK, so I right-click on trunk-capacities.diff
Popop menu appears, I select TortoiseSVN --> Apply patch...
The following menu appears:
SVN menu 1
SVN menu 1
SVN popup1.jpg (24.39 KiB) Viewed 2749 times
Then what? I cannot choose a file here, it asks for a directory.
Choosing the trunk directory, the window disappears, and I'm left with
Mainscreen
Mainscreen
Uhhhh... I guess I completely miss the hang of how patches are applied ::deep sigh::

Anyone, please?
A game worth playing is a game worth modding :-)
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Howto apply a patch/diff file

Post by Yexo »

griffin71 wrote:Wiki sais:
Windows: Make sure you have TortoiseSVN installed.
Right-click on the folder with the OpenTTD source code, open the TortoiseSVN submenu and select 'Apply Patch...'. Browse to the patch file and select it. Then, right click on the 'File Patches' window and click on 'Patch All'. After you're done, close the TortoiseMerge window.
Highlighted the important part for you.
OK, so I right-click on trunk-capacities.diff
That's not a folder but the patch file.

Hope this helps.
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Howto apply a patch/diff file

Post by petert »

You can start by using a proper patch program, TortoiseSVN can't patch git patches.
griffin71
Traffic Manager
Traffic Manager
Posts: 142
Joined: 31 Mar 2007 13:11
Location: Amsterdam

Re: Howto apply a patch/diff file

Post by griffin71 »

Yexo, thanks. Indeed quite a stupidity of mine -- one should right-click on the directory holding the source files. Unfortunately, this won't help me in this case, see through.

Petert, thanks to you too. I hadn't noticed this, but the cargo distribution branch uses git, and SVN does not support that.
It seems that git is primarily unix based, which forces me to use an emulator. Do you have any suggestions which program running under winxp directly will apply the git-style patch?
A game worth playing is a game worth modding :-)
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Howto apply a patch/diff file

Post by petert »

See this tutorial: http://wiki.openttd.org/MSYS#Setting_up_MinGW

Note: if you only want to patch with MinGW, you only need to follow these steps:
  • Setting up MinGW
  • Setting up MSYS
  • Install SVN
  • Testing the MinGW installation
The rest isn't really needed. After you are done, change dirs to your source "cd /c/<path_to_source>". Patch with: "patch -p1 -i <patchfile>.diff
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Howto apply a patch/diff file

Post by Yexo »

griffin71 wrote:It seems that git is primarily unix based,
Not true, and also not relevant.
Do you have any suggestions which program running under winxp directly will apply the git-style patch?
The program "patch" will apply git patches just fine. There is a gnuwin32 patch but I think it crashes on unix newlines, so it's better to install the one from msys or cygwin (just install msys or cygwin itself). The wiki page petert linked should get you started.

Before you're trying to apply a patch, try compiling OpenTTD without any patches first. If that succeeds only then add a patch and try to compile that.
griffin71
Traffic Manager
Traffic Manager
Posts: 142
Joined: 31 Mar 2007 13:11
Location: Amsterdam

Re: Howto apply a patch/diff file

Post by griffin71 »

Hello again,

Thanks for the suggestions. Patching and compiling succeeded. I followed the steps Petert suggested.
I'm now much enjoying the cargodist patch.
I'm considering to develop an AI fot it.

Edit: [offtopic]Can it be that with the cargodist patch the game is significantly slower?[/offtopic]

Thanks
A game worth playing is a game worth modding :-)
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Howto apply a patch/diff file

Post by Yexo »

griffin71 wrote:Edit: [offtopic]Can it be that with the cargodist patch the game is significantly slower?[/offtopic]
That's possible, but it's just as likely that you build a debug build and not a release build. Are you compiling with msvc or with msys/cygwin? In case of msvc set the solution configuration at the top (it's a dropdown box) from "Debug" to "Release". In case of cygwin/msys you you should build a release binary by default,just don't configure with --enable-debug=x.
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Howto apply a patch/diff file

Post by fonso »

griffin71 wrote:Edit: [offtopic]Can it be that with the cargodist patch the game is significantly slower?[/offtopic]Thanks
If Yexo's suggestions don't help, please post a report with a savegame in the cargodist thread. Slowness is a bug and I'll fix it.
The guy on the picture is not me, it's Alonso.
griffin71
Traffic Manager
Traffic Manager
Posts: 142
Joined: 31 Mar 2007 13:11
Location: Amsterdam

Re: Howto apply a patch/diff file

Post by griffin71 »

Aha, thanks again.

Yesterday I found cargodist is now available for nightly 18748, so I recompiled everything (as release), and it's got the speed which is normal for my system.

I use MSVC. Why would a debug compile be much slower?
A game worth playing is a game worth modding :-)
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Howto apply a patch/diff file

Post by petert »

griffin71 wrote:I use MSVC. Why would a debug compile be much slower?
A debug build is built for debugging, not playing. It (probably) checks everything, makes logs and so-on.
User avatar
neob
Chief Executive
Chief Executive
Posts: 687
Joined: 29 Dec 2009 02:56

Re: Howto apply a patch/diff file

Post by neob »

after following this guide,in the last step how do you make that bundle in VS2008?

installed all the required software.
got the required svn branch and the DIFF and successfully applied it.
add the aditional library's to the project as shown.

compiled, build successful, now how do i make the bundle or where is that excitable i built?

(sorry for all the questions but its been almost a decade since i touched VS last)
Image
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Howto apply a patch/diff file

Post by petert »

Open MSYS, type "cd <dir_of_trunk>", then type the code given at that section. The bundle will be in /bundle, so you can make a zip.
User avatar
neob
Chief Executive
Chief Executive
Posts: 687
Joined: 29 Dec 2009 02:56

Re: Howto apply a patch/diff file

Post by neob »

yes i read this part but its also says "The purpose of this article is to get the equivalent of a "make bundle" for MSVC builds. "
which implies that there is a "make bundle" option in VS itself, so if i got the full version and not the express version is it there or do i still need to get MSYS?
Image
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Howto apply a patch/diff file

Post by petert »

I should've rephrased that. I meant "The equivalent of a 'make bundle' for binaries created with MSVC". You will still need MSYS no matter what to obtain a bundle feature.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 16 guests