annotate src/l_align.cc @ 69:12b6553c057e

Logic cleanup in aligning textures x offset.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 26 Sep 2011 11:23:01 +0300
parents df543ecd0746
children dd9e9b980eb9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
2 * l_align.cc
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
3 * Linedef/sidedef texture alignment
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
4 * AYM 1998-02-03
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 This file is part of Yadex.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 Yadex incorporates code from DEU 5.21 that was put in the public domain in
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 1994 by Raphaël Quinet and Brendon Wyber.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 The rest of Yadex is Copyright © 1997-2003 André Majorel and others.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 This program is free software; you can redistribute it and/or modify it under
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 the terms of the GNU General Public License as published by the Free Software
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 Foundation; either version 2 of the License, or (at your option) any later
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 version.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 This program is distributed in the hope that it will be useful, but WITHOUT
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 You should have received a copy of the GNU General Public License along with
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 Place, Suite 330, Boston, MA 02111-1307, USA.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 #include "yadex.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 #include "dialog.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 #include "entry.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 #include "gfx.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 #include "levels.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 #include "objid.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 #include "oldmenus.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 #include "selectn.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 #include "textures.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 get the absolute height from which the textures are drawn
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
46 int GetTextureRefHeight(int sidedef)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
48 int l, sector;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
49 int otherside = OBJ_NO_NONE;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50
48
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
51 /* find the sidedef on the other side of the LineDef, if any */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
52 for (l = 0; l < NumLineDefs; l++)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
54 if (LineDefs[l].sidedef1 == sidedef)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
55 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
56 otherside = LineDefs[l].sidedef2;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
57 break;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
58 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
59 if (LineDefs[l].sidedef2 == sidedef)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
60 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
61 otherside = LineDefs[l].sidedef1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
62 break;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
63 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 }
48
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
65
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
66 /* get the Sector number */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
67 sector = SideDefs[sidedef].sector;
48
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
68
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
69 /* if the upper texture is displayed, then the reference
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
70 * is taken from the other Sector */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
71 if (otherside >= 0)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
73 l = SideDefs[otherside].sector;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
74 if (l > 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
75 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
76 if (Sectors[l].ceilh < Sectors[sector].ceilh
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
77 && Sectors[l].ceilh > Sectors[sector].floorh)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
78 sector = l;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
79 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 }
48
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
81
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
82 /* return the altitude of the ceiling */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
83 if (sector >= 0)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
84 return Sectors[sector].ceilh; /* textures are drawn from the ceiling down */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
85 else
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
86 return 0; /* yuck! */
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 Align all textures for the given SideDefs
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 Note from RQ:
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 This function should be improved!
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 But what should be improved first is the way the SideDefs are selected.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 It is stupid to change both sides of a wall when only one side needs
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 to be changed. But with the current selection method, there is no
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 way to select only one side of a two-sided wall.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
103 void AlignTexturesY(SelPtr * sdlist, int opt_sdef, bool opt_check)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
105 int h, refh;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
107 if (!*sdlist)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
108 return;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109
48
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
110 /* get the reference height from the first sidedef */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
111 refh = GetTextureRefHeight((*sdlist)->objnum);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
112 SideDefs[(*sdlist)->objnum].yoff = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
113 UnSelectObject(sdlist, (*sdlist)->objnum);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114
48
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
115 /* adjust Y offset in all other SideDefs */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
116 while (*sdlist)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
117 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
118 h = GetTextureRefHeight((*sdlist)->objnum);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
119 SideDefs[(*sdlist)->objnum].yoff = (refh - h) % 128;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
120 UnSelectObject(sdlist, (*sdlist)->objnum);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
121 }
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
122
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
123 MadeChanges = 1;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 Function is to align all highlighted textures in the X-axis
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 Note from RJH:
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 LineDefs highlighted are read off in reverse order of highlighting.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 The '*sdlist' is in the reverse order of the above mentioned LineDefs
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 i.e. the first linedef sidedefs you highlighted will be processed first.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 Note from RQ:
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 See also the note for the previous function.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 Note from RJH:
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 For the menu for aligning textures 'X' NOW operates upon the fact that
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 ALL the SIDEDEFS from the selected LINEDEFS are in the *SDLIST, 2nd
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 sidedef is first, 1st sidedef is 2nd). Aligning textures X now does
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 SIDEDEF 1's and SIDEDEF 2's. If the selection process is changed,
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 the following needs to be altered radically.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
147 void AlignTexturesX(SelPtr * sdlist, int opt_sdef, bool opt_check, bool opt_offset, int opt_mode)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
149 /* FIRST texture name used in the highlited objects */
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
150 char texname[WAD_TEX_NAME + 1];
48
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
151 char errormessage[128]; /* area to hold the error messages produced */
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
152 int ldef; /* linedef number */
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
153 int sdef; /* current sidedef in *sdlist */
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
154 int vert1, vert2; /* vertex 1 and 2 for the linedef under scrutiny */
48
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
155 int xoffset; /* xoffset accumulator */
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
156 int useroffset; /* user input offset for first input */
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
157 i16 texlength; /* the length of texture to format to */
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
158 int length; /* length of linedef under scrutiny */
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
159 i16 dummy; /* holds useless data */
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
161 vert1 = -1;
48
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
162 vert2 = -1; /* 1st time round the while loop the -1 value is needed */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
163 texlength = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
164 xoffset = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
165 useroffset = 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166
68
df543ecd0746 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
167 if (*sdlist == NULL)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
169 Notify(-1, -1, "Error in AlignTexturesX: list is empty", 0);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
170 return;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 }
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
172
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
173 if (opt_mode == -1)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 {
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
175 /* No defined mode, we will try to "guess" which texture
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
176 * the user wants to align ... and choose the operating mode
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
177 * based on that.
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
178 */
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
179 SDPtr pdef = &SideDefs[(*sdlist)->objnum];
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
180 if (ValidTextureName(pdef->tex3))
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
181 {
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
182 strncpy(texname, pdef->tex3, WAD_TEX_NAME);
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
183 opt_mode = 3;
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
184 }
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
185 else if (ValidTextureName(pdef->tex2))
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
186 {
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
187 strncpy(texname, pdef->tex2, WAD_TEX_NAME);
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
188 opt_mode = 2;
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
189 }
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
190 else if (ValidTextureName(pdef->tex1))
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
191 {
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
192 strncpy(texname, pdef->tex1, WAD_TEX_NAME);
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
193 opt_mode = 1;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
194 }
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
195 else
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
196 {
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
197 sprintf(errormessage, "No texture(s) for sidedef #%d.",
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
198 (*sdlist)->objnum);
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
199 Notify(-1, -1, errormessage, 0);
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
200 return;
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
201 }
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
202 }
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
203 else
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
204 {
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
205 /* Find first sidedef that has desired texture set */
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
206
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
207 // FIXME! Not implemented yet ... -ccr
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
208 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
210 /* Get texture width, do some sanity checking as the
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
211 * WAD reading may fail.
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
212 */
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
213 GetWallTextureSize(&texlength, &dummy, texname);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
215 if (texlength < 4)
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
216 {
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
217 sprintf(errormessage, "Texture length for texture '%s' is %d. Not continuing.",
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
218 texname, texlength);
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
219 Notify(-1, -1, errormessage, 0);
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
220 return;
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
221 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
223 /* Get initial offset to use, if requested */
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
224 if (opt_offset)
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
225 {
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
226 int x0, y0, key;
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
227 char prompt[80];
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
228
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
229 sprintf(prompt, "Enter initial offset between 0 and %d:", texlength);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
231 x0 = (ScrMaxX - 25 - 8 * strlen(prompt)) / 2;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
232 y0 = (ScrMaxY - 55) / 2;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
234 DrawScreenBox3D(x0, y0, x0 + 25 + 8 * strlen(prompt), y0 + 55);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
235 set_colour(WHITE);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
236 DrawScreenText(x0 + 10, y0 + 8, prompt);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
238 while ((key = InputInteger(x0 + 10, y0 + 28, &useroffset, 0,
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
239 (int) texlength)) != YK_RETURN && key != YK_ESC)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
240 Beep();
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
242 if (key == YK_ESC)
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
243 return;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
244 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
246 /* Main processing loop */
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
247 while (*sdlist)
69
12b6553c057e Logic cleanup in aligning textures x offset.
Matti Hamalainen <ccr@tnsp.org>
parents: 68
diff changeset
248 xoffset = opt_offset ? useroffset : 0;
68
df543ecd0746 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
249 while (*sdlist != NULL)
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
250 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
251 ldef = 0;
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
252 sdef = (*sdlist)->objnum;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
254 if (opt_sdef == 1) /* throw out all 2nd SideDefs untill a 1st is found */
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
255 {
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
256 while (LineDefs[ldef].sidedef1 != sdef && ldef <= NumLineDefs)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
257 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
258 ldef++;
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
259 if (LineDefs[ldef].sidedef2 == sdef)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
260 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
261 UnSelectObject(sdlist, (*sdlist)->objnum);
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
262 if (*sdlist == NULL)
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
263 {
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
264 sprintf(errormessage, "Error in opt_sdef==1, *sdlist == NULL");
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
265 Notify(-1, -1, errormessage, 0);
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
266 return;
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
267 }
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
268 sdef = (*sdlist)->objnum;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
269 ldef = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
270 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
271 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
272 }
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
273 else
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
274 if (opt_sdef == 2) /* throw out all 1st SideDefs untill a 2nd is found */
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
275 {
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
276 while (LineDefs[ldef].sidedef2 != sdef && ldef <= NumLineDefs)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
277 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
278 ldef++;
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
279 if (LineDefs[ldef].sidedef1 == sdef)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
280 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
281 UnSelectObject(sdlist, (*sdlist)->objnum);
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
282 if (*sdlist == NULL)
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
283 {
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
284 sprintf(errormessage, "Error in opt_sdef==2, *sdlist == NULL");
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
285 Notify(-1, -1, errormessage, 0);
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
286 return;
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
287 }
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
288 sdef = (*sdlist)->objnum;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
289 ldef = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
290 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
291 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
292 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
294 /* do we test for same textures for the sidedef in question?? */
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
295 sdef = (*sdlist)->objnum;
68
df543ecd0746 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
296 /* Check for contiguous textures, if required */
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
297 if (opt_check)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
298 {
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
299 SDPtr pdef = &SideDefs[sdef];
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
300 if ((opt_mode == 3 && strncmp(pdef->tex3, texname, WAD_TEX_NAME)) ||
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
301 (opt_mode == 2 && strncmp(pdef->tex2, texname, WAD_TEX_NAME)) ||
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
302 (opt_mode == 1 && strncmp(pdef->tex1, texname, WAD_TEX_NAME)))
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
303 {
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
304 sprintf(errormessage, "No texture or discontinuous texture on sidedef #%d.",
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
305 sdef);
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
306 Notify(-1, -1, errormessage, 0);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
307 return;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
308 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
309 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310
68
df543ecd0746 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
311 /* Find out which linedef owns this sidedef */
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
312 int n;
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
313 for (ldef = -1, n = 0; n < NumLineDefs; n++)
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
314 if ((opt_sdef == 1 && LineDefs[n].sidedef1 == sdef) ||
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
315 (opt_sdef == 2 && LineDefs[n].sidedef2 == sdef))
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
316 {
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
317 ldef = n;
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
318 break;
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
319 }
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
320
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
321 if (ldef < 0)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
322 {
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
323 sprintf(errormessage, "Linedef for sidedef #%d not found?!",
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
324 sdef);
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
325 Notify(-1, -1, errormessage, 0);
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
326 return;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
327 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328
68
df543ecd0746 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
329 /* Test for linedef continuity */
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
330 vert1 = LineDefs[ldef].start;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
331 if (vert1 != vert2 && vert2 != -1)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
332 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
333 sprintf(errormessage, "Linedef #%d is not contiguous"
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
334 " with the previous linedef, please reselect.",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
335 (*sdlist)->objnum);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
336 Notify(-1, -1, errormessage, 0);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
337 return;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
338 }
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
339
68
df543ecd0746 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
340 /* Set offset */
66
794b7bb40d7f Initial work on cleaning up and improving the texture alignment functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
341 SideDefs[sdef].xoff = xoffset;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342
68
df543ecd0746 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
343 /* Calculate length of linedef */
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
344 vert2 = LineDefs[ldef].end;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
345 length = ComputeDist(Vertices[vert2].x - Vertices[vert1].x,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
346 Vertices[vert2].y - Vertices[vert1].y);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
348 xoffset += length;
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
349
68
df543ecd0746 Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
350 /* Remove multiples of texlength from xoffset */
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
351 xoffset = xoffset % texlength;
56
2898afb3c9a0 Cleanup the texture alignment code, also cosmetically. Add more informative
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
352
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
353 /* move to next object in selected list */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
354 UnSelectObject(sdlist, (*sdlist)->objnum);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
355 }
48
42dfed6e6efb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
356
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
357 MadeChanges = 1;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358 }