Page 1 of 1

Installing a patch/diff file

Posted: 15 Dec 2020 22:11
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)

Re: Installing a patch/diff file

Posted: 16 Dec 2020 00:38
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

Re: Installing a patch/diff file

Posted: 16 Dec 2020 07:13
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

Re: Installing a patch/diff file

Posted: 16 Dec 2020 16:00
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.

Re: Installing a patch/diff file

Posted: 16 Dec 2020 16:53
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?

Re: Installing a patch/diff file

Posted: 17 Dec 2020 07:43
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.

Re: Installing a patch/diff file

Posted: 17 Dec 2020 13:39
by JGR
Which patch file, specifically, are you looking to use?

Re: Installing a patch/diff file

Posted: 17 Dec 2020 20:07
by MsKeesha
I wanted to use this one: viewtopic.php?f=33&t=56933

Re: Installing a patch/diff file

Posted: 17 Dec 2020 22:20
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.

Re: Installing a patch/diff file

Posted: 17 Dec 2020 23:23
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