Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Oct 18, 2017 4:34 pm

All times are UTC




Post new topic  Reply to topic  [ 790 posts ]  Go to page Previous 134 35 36 37 3840 Next
Author Message
PostPosted: Tue Aug 16, 2011 8:38 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 21, 2007 11:47 am
Posts: 6559
Location: The Netherlands
Check again. Or just click that link. :P

_________________
FooBar's Tram Tracks | TransRapid Track Set | Metro Track Set | OpenGFX base graphics set | FIRS Industry Replacement Set
Dutch Tram Set | Dutch Trainset 2 | Dutch Road Furniture


Top
   
PostPosted: Wed Aug 24, 2011 10:54 am 
Offline
Traffic Manager
Traffic Manager

Joined: Tue May 27, 2008 8:33 pm
Posts: 153
Hi all!

After spending untill way too late at night yesterday I finally managed to compile Openttd myself.
I'm using MinGW to do this, and even though I got it to work I would like to understand what I'm actually doing so therefor a few questions:

- To apply the patch to the source I started by using this code:
Code:
svn update -r(Version number)

Can anybody explain me exactly what this line of code does?

- Second line to apply the patch to the source:
Code:
patch -p0 -i name.diff

I've tried the help command but can't seem to find what -p0 and -i do as attributes...
Does anybody have the answer? :-)

- Lastly: When compiling you should change directory to source folder and execute './configure' and 'make'
I found a very small file named configure (6kb), what exactly does this point to, or execute?
And I assume the make command created the exe file?

I know it's lots of question at once which are more or less irrelevant, but some help in understanding the process would be very much appreciated!!


Top
   
PostPosted: Wed Aug 24, 2011 11:12 am 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
kotssmurf wrote:
Code:
svn update -r(Version number)
Can anybody explain me exactly what this line of code does?
It updates your local copy of the source code to a specific version. Every time one of the developers makes a commit (=changes something to the official source) the revision number is increased by one. A source code patch is basically a file that lists a number of changes compared to some specific version. That's why you have to get that specific version first before applying a patch. Versions that are close enough might work if the official changes don't conflict with the changes made in the patch, but there is no way to guarantee that.

Quote:
- Second line to apply the patch to the source:
Code:
patch -p0 -i name.diff
I've tried the help command but can't seem to find what -p0 and -i do as attributes...
-p0 tells the program patch to strip 0 leading directories from each path found in the diff. -i is just an indication that the next argument will be the filename of the diff to apply.

Quote:
- Lastly: When compiling you should change directory to source folder and execute './configure' and 'make'
I found a very small file named configure (6kb), what exactly does this point to, or execute?
You can open that file in a text editor and see for yourself, it's a shell script.
Quote:
And I assume the make command created the exe file?
Yes, but indirectly. make is a program that helps in compiling by determining which files have to be rebuild. If after compiling the first time you only change one file and execute make again, it'll only recompile that file to see you a lot of time. The actual compiling is done by a compiler, in your case gnu g++.


Top
   
PostPosted: Wed Aug 24, 2011 11:17 am 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 6918
kotssmurf wrote:
- To apply the patch to the source I started by using this code:
Code:
svn update -r(Version number)

Can anybody explain me exactly what this line of code does?

A patch file contains information like "change line XXX from AAA to BBB", when there were too many changes to the code since the patch was created, it might not cleanly apply anymore, so this command makes you get an older version of the code. you might miss some new features of the past few weeks, but the patch should apply correctly.

Quote:
- Second line to apply the patch to the source:
Code:
patch -p0 -i name.diff

I've tried the help command but can't seem to find what -p0 and -i do as attributes...
Does anybody have the answer? :-)

"-i <name.diff>" means "input file", otherwise patch reads from the console, i.e. you have to type in everything by hand.
"-p 0" means "strip 0 sections from paths", i.e. when you are in the "trunk" directory, and the patch file has paths like "src/blah.cpp", then use "-p 0" (use the whole path), if it has "a/src/blah.cpp" then use "-p 1" (strip the "a/" from path), if you omit "-p" completely, then only the filename is used, without any paths.
using the wrong option here will get you notices like "file blah.cpp not found, enter correct path:"

Quote:
- Lastly: When compiling you should change directory to source folder and execute './configure' and 'make'
I found a very small file named configure (6kb), what exactly does this point to, or execute?
And I assume the make command created the exe file?

"configure" is a script that detects your operating system, position of some required programs, libraries, etc. and other options, and creates a file called "Makefile" taking these things into account.
"make" takes this "Makefile", which now contains information how to compile all parts of the program, and usually creates the .exe for you
"make" can take parameters like "make install" to copy the program to a previously defined install location (check "./configure --help"), "make run" to execute the program directly after compiling, "make run-gdb" to start a debug session, or many more

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
PostPosted: Wed Aug 24, 2011 11:19 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 21, 2007 11:47 am
Posts: 6559
Location: The Netherlands
Darn. I was typing something nice and now Yexo beat me to it :(
I'm not going to throw out a perfectly good reply, but you can ignore it as Yexo said the same :)
Well I'll be darned again, now Eddi has written the same as well.
Still not throwing it out... :P


kotssmurf wrote:
svn update -r(Version number)

This changes the souce files to the state of that particular revision number.
So if you have a patch against say r18000, chances are it doesn't apply any more to r21000 because there are too many changes to OpenTTD since the patch was written. The svn update command gives you the OpenTTD source of an older revision so you can build an older version with the patch.

kotssmurf wrote:
patch -p0 -i name.diff

If you look inside a diff/patch file, you see the paths and filenames of the files that are changed. Usually, these will be A/path/to/file.ex and B/path/to/file.ext (first for the original version, second for the changes). Because your source doesn't have a folder A or B, you need to strip this from the path. The -p option does that for you and you specify how many folders to strip from the front. -p0 doesn't strip anything; -p1 strips in this case the A/ and B/. -p2 would strip A/path/ and B/path/ etc. It is common that you need to specify -p1.

-i says that the input for the patch program should be taken from the file specified after -i. By default, patch wants input from stdin (e.g. the commandline if you run patch from there), which isn't very useful as that means you have to type the diff file in by hand.

_________________
FooBar's Tram Tracks | TransRapid Track Set | Metro Track Set | OpenGFX base graphics set | FIRS Industry Replacement Set
Dutch Tram Set | Dutch Trainset 2 | Dutch Road Furniture


Top
   
PostPosted: Wed Aug 24, 2011 11:23 am 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 6918
FooBar wrote:
Darn. I was typing something nice and now Yexo beat me to it :(
I'm not going to throw out a perfectly good reply

that was my thought as well :p

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
PostPosted: Wed Aug 24, 2011 11:59 am 
Offline
Traffic Manager
Traffic Manager

Joined: Tue May 27, 2008 8:33 pm
Posts: 153
Wow thank you all for the quick reply full of usefull information! :-)

So if I understand it correctly the -i attribute just executes the code in the patch.
So if I were to start creating a patch and would know the nested code by heart I could just type it in the shell?
(Theoretically, I do not have the intention of ever doing this :-) )

Secondly, if the source version should allways be updated I assume that patches written to be compatible with different source codes will (in most cases) not work together? Then how are patchpacks possible? A complete manual rewrite of the code is inevitable, no?


Top
   
PostPosted: Wed Aug 24, 2011 12:19 pm 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 6918
kotssmurf wrote:
I could just type it in the shell?

yes, but the typical use case is pipes, to use the output of another program

e.g.
Code:
curl -L <URL> | patch -p0
directly downloads the patch file and applies it. ("-L" here basically means "follow redirects")

Quote:
Secondly, if the source version should allways be updated I assume that patches written to be compatible with different source codes will (in most cases) not work together? Then how are patchpacks possible? A complete manual rewrite of the code is inevitable, no?

that depends, if only few revisions are inbetween, then there are likely no conflicts, or they can be usually be resolved manually without a lot of effort, if you know what the patch does. a "complete rewrite" is only necessary if the patch is very old, or contradicts another patch (like "grass growth" and "stuck counter" patches are incompatible, because they use the same map bits, one of them would have to be rewritten to use other map bits, if the other one were to be included in trunk. they cannot be in the same patchpack either this way)

nevertheless, keeping a patchpack together is a lot of effort, and persons who manage this surely are to be admired.

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
PostPosted: Wed Aug 24, 2011 12:22 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
Heh, now Eddi beat me to it. Same as above, not going to throw it away :)

kotssmurf wrote:
So if I were to start creating a patch and would know the nested code by heart I could just type it in the shell?
(Theoretically, I do not have the intention of ever doing this :-) )
Theoretically yes. In practice all patches are made by editing the source code and letting svn figure out what exactly changed between the version in the repository and the version on your harddisk.

[quoteSecondly, if the source version should allways be updated I assume that patches written to be compatible with different source codes will (in most cases) not work together?[/quote]Correct. Even when multiple patches are written for the same version they might conflict because they change the same lines. Imagine patch 1 saying change the AA on line 3 to BB and patch 2 saying change the AA on line 3 to CC. A computer program can't solve that automatically.

Quote:
Then how are patchpacks possible? A complete manual rewrite of the code is inevitable, no?
It's usually not that much work to update a patch to apply to a different revision. Merging multiple conflicting patches (as explained above) is more work. That requires some programming knowledge and understanding of both patches and the original code.


Top
   
PostPosted: Wed Aug 24, 2011 12:33 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Tue May 27, 2008 8:33 pm
Posts: 153
Yexo wrote:
Correct. Even when multiple patches are written for the same version they might conflict because they change the same lines. Imagine patch 1 saying change the AA on line 3 to BB and patch 2 saying change the AA on line 3 to CC. A computer program can't solve that automatically.


This i figured out already, but say we are talking about 2 patches which are compatible, but one is made with a very old source code and another is new. Can I then execute svn update -r(Very old version) and when this is done execute the same code the update to a newer source for the newer patch? Won't this overwrite the patch already executed?

BTW Thanks for you reply-war answers :-) Very informative,quick and complete!


Top
   
PostPosted: Wed Aug 24, 2011 12:45 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
kotssmurf wrote:
This i figured out already, but say we are talking about 2 patches which are compatible, but one is made with a very old source code and another is new. Can I then execute svn update -r(Very old version) and when this is done execute the same code the update to a newer source for the newer patch? Won't this overwrite the patch already executed?!
You can try, but if the difference in version is quite big you'll most likely get errors when trying to update from the old version with patch applied to a newer version. These conflicts will be marked in the source code files and will have to be solved by you before compiling or applying another patch.


Top
   
PostPosted: Wed Aug 24, 2011 12:49 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 21, 2007 11:47 am
Posts: 6559
Location: The Netherlands
That won't work. you either end up overwriting the first changes with the second svn update. Or if you choose not to update the patched file, you end up with a very old source file amongst a new source that most likely will not work together.

So if you want to apply multiple patches, you must apply them to the same revision. So for a very old patch and a very new one, you almost certainly need to update the old patch for it to work with the new revision.

_________________
FooBar's Tram Tracks | TransRapid Track Set | Metro Track Set | OpenGFX base graphics set | FIRS Industry Replacement Set
Dutch Tram Set | Dutch Trainset 2 | Dutch Road Furniture


Top
   
PostPosted: Wed Aug 24, 2011 12:52 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Tue May 27, 2008 8:33 pm
Posts: 153
Aha so that means that when you perform 'SVN update -r(version number)' it does not just overwrite current source, but verifies the changes?
EDIT: nvm :-) I replied to quick


Top
   
PostPosted: Wed Aug 24, 2011 1:17 pm 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 6918
kotssmurf wrote:
Aha so that means that when you perform 'SVN update -r(version number)' it does not just overwrite current source, but verifies the changes?
EDIT: nvm :-) I replied to quick

the second "svn update" will try to keep your changes, but it may detect "conflicts" when your patch changed lines that also were changed in one of the updates.

your files will then contain lines like
Code:
<<< mine
aaaa
======
bbbb
>>> r12345

or similar.

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
PostPosted: Thu Sep 29, 2011 1:29 pm 
Offline
Moderator
Moderator
User avatar

Joined: Mon Dec 26, 2005 8:19 pm
Posts: 17042
Location: Harringay, North London
I'm following MeusH's method from page 1 using Tortoise. All of the files are shown in red, it says to speak to a patch developer. Can someone enlighten me as to what might be going wrong? Ta.

EDIT: Am trying to patch IS to the trunk.

EDIT2: Waitaminute...

EDIT3: I thought I might have the wrong revision as the IS patch is built for r22944, but this also returns the same behaviour. Am I being a complete dunce here? :\


Attachments:
Capture.PNG [35.45 KiB]
Downloaded 1 time

_________________
Albion: A fictional Britain

Official TT-Dave Fan Club
Dave's Screenshot Thread! - Flickr


Why be a song when you can be a symphony? r is a...
Top
   
PostPosted: Thu Sep 29, 2011 5:03 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 21, 2007 11:47 am
Posts: 6559
Location: The Netherlands
What "patch" tool are you using? Be aware that the one that comes with Tortoise is silly and mustn't be used. Better use the one from MSYS (get it here if you don't have it: http://sourceforge.net/projects/mingw/f ... a/download)

Furthermore it might be good to "update" to a clean r22944, discarding all local changes.

_________________
FooBar's Tram Tracks | TransRapid Track Set | Metro Track Set | OpenGFX base graphics set | FIRS Industry Replacement Set
Dutch Tram Set | Dutch Trainset 2 | Dutch Road Furniture


Top
   
PostPosted: Thu Sep 29, 2011 10:21 pm 
Offline
Moderator
Moderator
User avatar

Joined: Mon Dec 26, 2005 8:19 pm
Posts: 17042
Location: Harringay, North London
Okay I've got MSYS; do I follow the instructions on the wiki? I've tested the installation and I get outputs as the wiki states. Now do I just go down that list and install the stuff?

_________________
Albion: A fictional Britain

Official TT-Dave Fan Club
Dave's Screenshot Thread! - Flickr


Why be a song when you can be a symphony? r is a...


Top
   
PostPosted: Fri Sep 30, 2011 9:34 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jun 25, 2009 4:42 pm
Posts: 2364
Location: Location, Location
yes, follow the wiki instructions as closely as possible

_________________
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra


Top
   
PostPosted: Tue Nov 08, 2011 12:27 pm 
Offline
Engineer
Engineer

Joined: Mon Feb 15, 2010 12:03 pm
Posts: 58
Location: Germany, Berlin
Hallo,

my first try to compile a Version with a diff file. I have token introduction from 4 post of this threas (for windows users)

First: Downloaded TortoiseSVN and installed it:
than: Downloaded source files from here: http://www.openttd.org/en/download-stable
than: extractet sourcefiles to a folder
than: right click on this folder to check out, than don`t know

Is there any step by step introduction for those people without programming experiences?


Top
   
PostPosted: Tue Nov 08, 2011 12:32 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
Follow either http://wiki.openttd.org/Compiling_on_MinGW or http://wiki.openttd.org/Microsoft_Visua ... s_Editions to compile the source code you got. I'd strongly recommend trying to compile a clean version of the code (without any patch applied first) so you know that works for you.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 790 posts ]  Go to page Previous 134 35 36 37 3840 Next

All times are UTC


Who is online

Users browsing this forum: ino and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.