Posted: . At: 10:11 AM. This was 7 months ago. Post ID: 18602
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to use a patch file generated by the diff command on Linux.


I recently downloaded a very old Linux program in a tarball and it also has a *.diff file that needed to be applied to it. This is how to do it.

(jcartwright@localhost) 192.168.1.5 yadex-1.7.0  $ patch -p1 < Yadex_170_ALL.diff 
patching file atclib/al_adigits.c
patching file docsrc/index.html
patching file docsrc/preview.html
patching file GNUmakefile
patching file src/editloop.cc
patching file src/editloop.h
patching file src/gcolour1.cc
patching file src/gcolour2.cc
patching file src/gcolour2.h
patching file src/l_prop.cc
patching file src/r_images.cc
patching file src/r_images.h
patching file src/r_render.cc
patching file src/r_render.h
patching file src/s_misc.cc
patching file src/s_prop.cc
patching file src/s_split.cc
patching file src/t_prop.cc
patching file src/yadex.h

This applies all of the changes in the patch file to all the files in the source tree.

This is how to easily update a source tree with various changes. Below is a sample of the patch file. This shows how it works.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
diff -u -r -N yadex-1.7.0/atclib/al_adigits.c yadex-1.7.0-all/atclib/al_adigits.c
--- yadex-1.7.0/atclib/al_adigits.c	1999-08-02 00:52:00.000000000 +1000
+++ yadex-1.7.0-all/atclib/al_adigits.c	2005-01-10 14:30:53.000000000 +1100
@@ -29,5 +29,11 @@
 #include "atclib.h"
 
 
-const char al_adigits[36] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+const char al_adigits[36] =
+{
+'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
+'U', 'V', 'W', 'X', 'Y', 'Z'
+};
 
diff -u -r -N yadex-1.7.0/docsrc/index.html yadex-1.7.0-all/docsrc/index.html
--- yadex-1.7.0/docsrc/index.html	2002-05-09 23:36:06.000000000 +1000
+++ yadex-1.7.0-all/docsrc/index.html	2005-01-10 14:30:53.000000000 +1100
@@ -34,6 +34,7 @@
 
 <ul>
 <li><a href="palette.html">Palette viewer</a>
+<li><a href="preview.html">3D Level Preview</a>
 <li><a href="advanced.html">Advanced user's guide</a>
 <li><a href="../TODO"><code>TODO</code></a>
 <li><a href="yadex.6">The man page for Yadex</a>
diff -u -r -N yadex-1.7.0/docsrc/preview.html yadex-1.7.0-all/docsrc/preview.html
--- yadex-1.7.0/docsrc/preview.html	1970-01-01 10:00:00.000000000 +1000
+++ yadex-1.7.0-all/docsrc/preview.html	2005-01-10 14:34:20.000000000 +1100
@@ -0,0 +1,108 @@
+<html>
+<head>
+<title>Yadex 3D level preview</title>
+</head>
+<body>
+
+<div align="center">
+<img src="logo_small.png" alt="Fancy logo">
+<br>Yadex $VERSION ($SOURCE_DATE)
+<h1>3D Level Preview</h1>
+</div>
+<br>
+<br>
+<br>
+
+	<h2>What's it for</h2>
+
+<p>The 3D level preview function lets you get a rough idea of what
+your level looks like, quickly, without all the hassle of saving,
+building nodes and starting DOOM. It is activated by pressing the
+`R' key while editing a level, and draws the player's view that
+you would see within DOOM (with some limitations). While the
+rendering window is up, you can move around the level using the
+cursor keys and toggle things like texturing and sprites on/off.
+
+	<h2>Key bindings</h2>
+
+<dl>
+<dt>[<kbd>Left</kbd>]
+<br>[<kbd>Right</kbd>]
+<dd>Turn the view left or right. Use the SHIFT key to
+turn a greater amount.
+
+<dt>[<kbd>Up</kbd>]
+<br>[<kbd>Down</kbd>]
+<dd>Move the view forward or back. Use the SHIFT key to
+move a greater distance.
+
+<dt>[<kbd>n</kbd>]
+<br>[<kbd>m</kbd>]
+<dd>Move the view sideways left or right (strafing). Uppercase `N'
+and `M' (i.e. with the SHIFT key) will move a greater distance.
+
+<dt>[<kbd>c</kbd>]
+<br>[<kbd>d</kbd>]
+<dd>Move the view upwards or downwards (flying). Uppercase `C' and
+`D' (i.e. with the SHIFT key) will move a greater distance. Note
+that you cannot move up or down when "walking" mode is enabled.
+
+<dt>[<kbd>t</kbd>]
+<dd>Toggle texture mapping. When disabled (the default), all walls,
+ceilings and floors are drawn with solid (somewhat random) colours.
+
+<dt>[<kbd>s</kbd>]
+<dd>Toggle sprites.
+
+<dt>[<kbd>w</kbd>]
+<dd>Toggle walking mode. When enabled, the view height is always
+above the current floor. For example, if you move forward over a
+cliff, the view will drop down.  When disabled (the default), you can
+fly about the level at any height.
+
+<dt>[<kbd>Esc</kbd>]
+<br>[<kbd>q</kbd>]
+<dd>Exit the 3D level preview. The current viewing state (position,
+direction, etc) are remembered, and will be used next time the 3D
+preview is activated (unless the player object has been moved, or a
+different level was loaded).
+
+</dl>
+
+	<h2>Features</h2>
+
+<ul>
+<li>No BSP (nodes) required !
+<li>Textures and flats are drawn exactly like DOOM, including X/Y
+offsets and upper/lower unpegging flags.
+<li>Sky is handled just like in DOOM (but drawn in solid blue).
+</ul>
+
+	<h2>Limitations</h2>
+
+<ul>
+<li>No lighting, the level appears full-bright all the time.
+<li>No mid-masked textures (rails, gratings) are drawn.
+<li>Thing sprites (especially monsters) are always drawn facing
+you, even when their direction is away from you.
+<li>Sprite positioning may be inaccurate, because their X and
+Y offsets are not honoured.
+<li>Things that are supposed to hang from the ceiling
+(hanging body parts, chandeliers, etc) will appear on the floor.
+<li>There are some glitches in the current renderer, which look like
+"slimetrails" (vertical lines).
+</ul>
+
+	<h2>Caveats</h2>
+
+One last thing. The 3D preview function can use a huge amount of
+memory when texturing and sprites are both enabled (and a large amount
+even when texturing and sprites are both disabled). If your computer
+has a very low amount of memory (e.g. less than 16 MB), then Yadex may
+crash with an out of memory error. I think you are unlikely to hit
+this problem, but if in doubt, save your work first.
+
+
+<p><hr>AJA $SELF_DATE
+</body>
+</html>
diff -u -r -N yadex-1.7.0/GNUmakefile yadex-1.7.0-all/GNUmakefile
--- yadex-1.7.0/GNUmakefile	2003-12-29 04:23:56.000000000 +1100
+++ yadex-1.7.0-all/GNUmakefile	2005-01-10 14:30:53.000000000 +1100
@@ -160,6 +160,7 @@
 	s_swapf		s_vertices	sanity		scrnshot	\
 	selbox		selectn		selpath		selrect		\
 	serialnum	spritdir	sticker		swapmem		\
+ 	r_render	r_images					\
 	t_centre	t_flags		t_prop		t_spin		\
 	textures	things		trace		v_centre	\
 	v_merge		v_polyg		vectext		verbmsg		\
@@ -237,6 +238,7 @@
 	docsrc/legal.html		\
 	docsrc/packagers_guide.html	\
 	docsrc/palette.html		\
+	docsrc/preview.html		\
 	docsrc/reporting.html		\
 	docsrc/tips.html		\
 	docsrc/trivia.html		\
@@ -609,8 +611,9 @@
 #
 ########################################################################

This example compares two files in different source trees. yadex-1.7.0/ and yadex-1.7.0-all.

diff -u -r -N yadex-1.7.0/src/r_render.h yadex-1.7.0-all/src/r_render.h
--- yadex-1.7.0/src/r_render.h	1970-01-01 10:00:00.000000000 +1000
+++ yadex-1.7.0-all/src/r_render.h	2005-01-10 14:30:53.000000000 +1100
@@ -0,0 +1,14 @@
+/*
+ *	r_render.h
+ *	AJA 2002-04-27
+ */
+
+
+#ifndef YH_R_RENDER  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#define YH_R_RENDER
+
+
+void Render3D ();
+
+
+#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */

To create a patch file yourself, do it like this. I had two source trees, an older version from 2000 and one from 2011. This is how I created a patch file to update the older source tree to the newer version.

(jcartwright@localhost) 192.168.1.5 Documents  $ diff -u -r -N xwadtools xwadtools-all/ > xwadtools.diff

Then I could easily patch the older files to the newer version.

(jcartwright@localhost) 192.168.1.5 xwadtools  $ patch -p1 < xwadtools.diff 
patching file Makefile.lin
patching file idbsp/buildbsp.c
patching file include/strfunc.h
patching file wadflat/wadflat.c
patching file wadpat/wadpat.c
patching file wadsprit/wadsprit.c
patching file wadtex/wadtex.c
patching file xew/xew_f.h

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.