Installing a patch/diff file

Got a problem with OpenTTD? Find some help here.

Moderator: OpenTTD Developers

Post Reply
MsKeesha
Engineer
Engineer
Posts: 5
Joined: 15 Dec 2020 21:54

Installing a patch/diff file

Post by MsKeesha »

I have read many forum posts regarding installing a patch/diff file but I still don't understand how to do it or how it works. What type of knowledge, programs and files do I need? How to do it, step by step? If someone could help me understand it, from start to an end, I will really appreciate it (Also please describe this as you're explaining it to a 5 year old kid, 'cause most of the time while reading posts regarding these topics I find myself very confused)
_dp_
Transport Coordinator
Transport Coordinator
Posts: 278
Joined: 18 Dec 2013 12:32

Re: Installing a patch/diff file

Post by _dp_ »

Patches are a tool for programmers to share code modifications with other programmers. And while with some luck you may be able to apply patch without having to understand C++ code it's still a somewhat complicated process for a 5 y/o :p

So, basically, first question you should ask yourself when trying to apply a patch is do you really need it. There are plenty of patchpacks that include a lot of useful patches and provide a compiled binary that you can just run without having to do all the hard work yourself. Main two patchpacks atm are:
JGR's (more features, can't be used in mp with vanilla servers): viewtopic.php?f=33&t=73469
CityMania (mostly ui features, can be used in mp): https://citymania.org/downloads
MsKeesha
Engineer
Engineer
Posts: 5
Joined: 15 Dec 2020 21:54

Re: Installing a patch/diff file

Post by MsKeesha »

I actually have been already playing on JGR's pack, but I've also found a really nice patch that isn't included in this pack, so maybe I should've asked if it's possible to install an additional patch to it
User avatar
odisseus
Director
Director
Posts: 564
Joined: 01 Nov 2017 21:19

Re: Installing a patch/diff file

Post by odisseus »

A patch is just a suggested change to a program's source code. It is formatted in such a way that special tools can apply this change automatically, but you can also edit the source files manually to the same effect.

Importantly, there is no guarantee that:
  • the patched program will work as intended;
  • the patched source code can be compiled into an executable file;
  • the patch can be applied to your version of source code at all.
The patch will usually work right if applied to the unchanged (vanilla) source code, because this was (hopefully) tested by the author of the patch. However, if you try to apply another patch on top of the first one, these three uncertainties kick in. The more patches you apply, the more likely you'll encounter some issues, and you will need programming skills to resolve them. That's why maintaining a patch pack is much harder than preparing a single patch.
MsKeesha
Engineer
Engineer
Posts: 5
Joined: 15 Dec 2020 21:54

Re: Installing a patch/diff file

Post by MsKeesha »

I suppose that with my coding skill (which are non existent), I will not be able to add a patch to a pack, but what if I want to patch a vanilla version of OTTD? How to do it?
User avatar
kamnet
Moderator
Moderator
Posts: 8579
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: Installing a patch/diff file

Post by kamnet »

Most of the time a patch is created and based against a specific version of the nightly OpenTTD source code. This source code is updated very regularly (sometimes every day), so whatever was written at a particular point in time may no longer work on a future version of the code, even if it's just a day old. And, unfortunately, often times a patch file is written by an individual who doesn't stick around forever and keeps the patch updated.

The patch/diff file is a set of instructions that boils down to "find line [x], add/remove this string of text". That's the easy part. The hard part is know what to fix, and how to fix it, if the new code doesn't compile into a binary, or if the new binary doesn't work correctly.
User avatar
JGR
Tycoon
Tycoon
Posts: 2557
Joined: 08 Aug 2005 13:46
Location: Ipswich

Re: Installing a patch/diff file

Post by JGR »

Which patch file, specifically, are you looking to use?
Ex TTDPatch Coder
Patch Pack, Github
MsKeesha
Engineer
Engineer
Posts: 5
Joined: 15 Dec 2020 21:54

Re: Installing a patch/diff file

Post by MsKeesha »

I wanted to use this one: viewtopic.php?f=33&t=56933
User avatar
JGR
Tycoon
Tycoon
Posts: 2557
Joined: 08 Aug 2005 13:46
Location: Ipswich

Re: Installing a patch/diff file

Post by JGR »

MsKeesha wrote: 17 Dec 2020 20:07 I wanted to use this one: viewtopic.php?f=33&t=56933
There is a fork of my patchpack here which appears to already include this patch and is quite up to date.
It may be easier to try using that instead of doing the integration yourself.

I haven't actually tried that fork, so can't make any guarantees, etc.
Ex TTDPatch Coder
Patch Pack, Github
MsKeesha
Engineer
Engineer
Posts: 5
Joined: 15 Dec 2020 21:54

Re: Installing a patch/diff file

Post by MsKeesha »

JGR wrote: 17 Dec 2020 22:20
MsKeesha wrote: 17 Dec 2020 20:07 I wanted to use this one: viewtopic.php?f=33&t=56933
There is a fork of my patchpack here which appears to already include this patch and is quite up to date.
It may be easier to try using that instead of doing the integration yourself.

I haven't actually tried that fork, so can't make any guarantees, etc.
Thank you! I appreciate it
Post Reply

Return to “OpenTTD Problems”

Who is online

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