annotate src/levels.cc @ 84:c518e08d5961

More logic cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 26 Sep 2011 18:17:57 +0300
parents 002bc70a3982
children 093497110727
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 * levels.cc
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
3 * Level loading and saving routines,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
4 * global variables used to hold the level data.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
5 * BW & RQ sometime in 1993 or 1994.
0
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 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 This file is part of Yadex.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 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
13 1994 by Raphaël Quinet and Brendon Wyber.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 The rest of Yadex is Copyright © 1997-2003 André Majorel and others.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 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
18 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
19 Foundation; either version 2 of the License, or (at your option) any later
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 version.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 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
23 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 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
27 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 Place, Suite 330, Boston, MA 02111-1307, USA.
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
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 #include "yadex.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 #include "bitvec.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 #include "dialog.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 #include "game.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 #include "levels.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 #include "objid.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 #include "wstructs.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 #include "things.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 #include "wadfile.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 #include "wads.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 #include "wads2.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
46 FIXME
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
47 All these variables should be turned
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
48 into members of a "Level" class.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 */
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
50 MDirPtr Level; /* master dictionary entry for the level */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
51 int NumThings; /* number of things */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
52 TPtr Things; /* things data */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
53 int NumLineDefs; /* number of line defs */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
54 LDPtr LineDefs; /* line defs data */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
55 int NumSideDefs; /* number of side defs */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
56 SDPtr SideDefs; /* side defs data */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
57 int NumVertices; /* number of vertexes */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
58 VPtr Vertices; /* vertex data */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
59 int NumSectors; /* number of sectors */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
60 SPtr Sectors; /* sectors data */
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 // FIXME should be somewhere else
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
63 int NumWTexture; /* number of wall textures */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
64 char **WTexture; /* array of wall texture names */
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 // FIXME all the flat list stuff should be put in a separate class
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
67 size_t NumFTexture; /* number of floor/ceiling textures */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
68 flat_list_entry_t *flat_list; // List of all flats in the directory
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
70 int MapMaxX = -32767; /* maximum X value of map */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
71 int MapMaxY = -32767; /* maximum Y value of map */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
72 int MapMinX = 32767; /* minimum X value of map */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
73 int MapMinY = 32767; /* minimum Y value of map */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
74 bool MadeChanges; /* made changes? */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
75 bool MadeMapChanges; /* made changes that need rebuilding? */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
76 unsigned long things_angles; // See levels.h for description.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
77 unsigned long things_types; // See levels.h for description.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
78 char Level_name[WAD_NAME + 1]; /* The name of the level (E.G.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
79 "MAP01" or "E1M1"), followed by a
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
80 NUL. If the Level has been created as
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
81 the result of a "c" command with no
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
82 argument, an empty string. The name
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
83 is not necesarily in upper case but
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
84 it always a valid lump name, not a
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
85 command line shortcut like "17". */
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
87 y_file_name_t Level_file_name; /* The name of the file in which
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
88 the level would be saved. If the
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
89 level has been created as the result
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
90 of a "c" command, with or without
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
91 argument, an empty string. */
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
93 y_file_name_t Level_file_name_saved; /* The name of the file in
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
94 which the level was last saved. If
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
95 the Level has never been saved yet,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
96 an empty string. */
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
98 void EmptyLevelData(const char *levelname)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
100 Things = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
101 NumThings = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
102 things_angles++;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
103 things_types++;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
104 LineDefs = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
105 NumLineDefs = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
106 SideDefs = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
107 NumSideDefs = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
108 Sectors = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
109 NumSectors = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
110 Vertices = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
111 NumVertices = 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
116 * texno_texname
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
117 * A convenience function when loading Doom alpha levels
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 static char *tex_list = 0;
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 static size_t ntex = 0;
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 static char tex_name[WAD_TEX_NAME + 1];
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
122 inline const char *texno_texname(i16 texno)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
124 if (texno < 0)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
125 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
126 else if (yg_texture_format == YGTF_NAMELESS)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
127 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
128 sprintf(tex_name, "TEX%04u", (unsigned) texno);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
129 return tex_name;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
130 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
131 else
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
132 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
133 if (texno < (i16) ntex)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
134 return tex_list + WAD_TEX_NAME * texno;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
135 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
136 return "unknown";
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
137 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 read in the level data
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
145 int ReadLevelData(const char *levelname) /* SWAP! */
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
147 int rc = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
148 MDirPtr dir;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
149 int OldNumVertices;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 /* Find the various level information from the master directory */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
152 DisplayMessage(-1, -1, "Reading data for level %s...", levelname);
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
153 Level = FindMasterDir(cfg.MasterDir, levelname);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
154 if (!Level)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
155 fatal_error("level data not found");
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 /* Get the number of vertices */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
158 i32 v_offset = 42;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
159 i32 v_length = 42;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
160 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
161 const char *lump_name = "BUG";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
162 if (yg_level_format == YGLF_ALPHA) // Doom alpha
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
163 lump_name = "POINTS";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
164 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
165 lump_name = "VERTEXES";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
166 dir = FindMasterDir(Level, lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
167 if (dir == 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
168 OldNumVertices = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
169 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
170 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
171 v_offset = dir->dir.start;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
172 v_length = dir->dir.size;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
173 if (yg_level_format == YGLF_ALPHA) // Doom alpha: skip leading count
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
174 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
175 v_offset += 4;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
176 v_length -= 4;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
177 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
178 OldNumVertices = (int) (v_length / WAD_VERTEX_BYTES);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
179 if ((i32) (OldNumVertices * WAD_VERTEX_BYTES) != v_length)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
180 warn("the %s lump has a weird size."
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
181 " The wad might be corrupt.\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
182 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
183 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 // Read THINGS
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
186 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
187 const char *lump_name = "THINGS";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
188 verbmsg("Reading %s things", levelname);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
189 i32 offset = 42;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
190 i32 length;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
191 dir = FindMasterDir(Level, lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
192 if (dir == 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
193 NumThings = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
194 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
195 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
196 offset = dir->dir.start;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
197 length = dir->dir.size;
84
c518e08d5961 More logic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 83
diff changeset
198 if (cfg.GameId == IWAD_HEXEN) // Hexen mode
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
199 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
200 NumThings = (int) (length / WAD_HEXEN_THING_BYTES);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
201 if ((i32) (NumThings * WAD_HEXEN_THING_BYTES) != length)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
202 warn("the %s lump has a weird size."
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
203 " The wad might be corrupt.\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
204 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
205 else // Doom/Heretic/Strife mode
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
206 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
207 if (yg_level_format == YGLF_ALPHA) // Doom alpha: skip leading count
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
208 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
209 offset += 4;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
210 length -= 4;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
211 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
212 size_t thing_size =
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
213 yg_level_format == YGLF_ALPHA ? 12 : WAD_THING_BYTES;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
214 NumThings = (int) (length / thing_size);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
215 if ((i32) (NumThings * thing_size) != length)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
216 warn("the %s lump has a weird size."
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
217 " The wad might be corrupt.\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
218 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
219 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
220 things_angles++;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
221 things_types++;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
222 if (NumThings > 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
223 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
224 Things = (TPtr) GetMemory((unsigned long) NumThings
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
225 * sizeof(struct Thing));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
226 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
227 wf->seek(offset);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
228 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
229 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
230 err("%s: seek error", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
231 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
232 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
233 }
84
c518e08d5961 More logic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 83
diff changeset
234 if (cfg.GameId == IWAD_HEXEN) // Hexen mode
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
235 for (long n = 0; n < NumThings; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
236 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
237 u8 dummy2[6];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
238 wf->read_i16(); // Tid
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
239 wf->read_i16(&Things[n].xpos);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
240 wf->read_i16(&Things[n].ypos);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
241 wf->read_i16(); // Height
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
242 wf->read_i16(&Things[n].angle);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
243 wf->read_i16(&Things[n].type);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
244 wf->read_i16(&Things[n].when);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
245 wf->read_bytes(dummy2, sizeof dummy2);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
246 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
247 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
248 err("%s: error reading thing #%ld", lump_name, n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
249 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
250 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
251 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
252 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
253 else // Doom/Heretic/Strife mode
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
254 for (long n = 0; n < NumThings; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
255 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
256 wf->read_i16(&Things[n].xpos);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
257 wf->read_i16(&Things[n].ypos);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
258 wf->read_i16(&Things[n].angle);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
259 wf->read_i16(&Things[n].type);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
260 if (yg_level_format == YGLF_ALPHA)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
261 wf->read_i16(); // Alpha. Don't know what it's for.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
262 wf->read_i16(&Things[n].when);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
263 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
264 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
265 err("%s: error reading thing #%ld", lump_name, n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
266 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
267 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
268 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
269 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
270 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
271 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273 // Read LINEDEFS
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
274 if (yg_level_format != YGLF_ALPHA)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
275 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
276 const char *lump_name = "LINEDEFS";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
277 verbmsg(" linedefs");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
278 dir = FindMasterDir(Level, lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
279 if (dir == 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
280 NumLineDefs = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
281 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
282 {
84
c518e08d5961 More logic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 83
diff changeset
283 if (cfg.GameId == IWAD_HEXEN) // Hexen mode
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
284 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
285 NumLineDefs = (int) (dir->dir.size / WAD_HEXEN_LINEDEF_BYTES);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
286 if ((i32) (NumLineDefs * WAD_HEXEN_LINEDEF_BYTES) !=
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
287 dir->dir.size)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
288 warn("the %s lump has a weird size."
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
289 " The wad might be corrupt.\n", lump_name);
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 else // Doom/Heretic/Strife mode
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
292 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
293 NumLineDefs = (int) (dir->dir.size / WAD_LINEDEF_BYTES);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
294 if ((i32) (NumLineDefs * WAD_LINEDEF_BYTES) != dir->dir.size)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
295 warn("the %s lump has a weird size."
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
296 " The wad might be corrupt.\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
297 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
298 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
299 if (NumLineDefs > 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
300 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
301 LineDefs = (LDPtr) GetMemory((unsigned long) NumLineDefs
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
302 * sizeof(struct LineDef));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
303 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
304 wf->seek(dir->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
305 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
306 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
307 err("%s: seek error", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
308 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
309 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
310 }
84
c518e08d5961 More logic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 83
diff changeset
311 if (cfg.GameId == IWAD_HEXEN) // Hexen mode
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
312 for (long n = 0; n < NumLineDefs; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
313 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
314 u8 dummy[6];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
315 wf->read_i16(&LineDefs[n].start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
316 wf->read_i16(&LineDefs[n].end);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
317 wf->read_i16(&LineDefs[n].flags);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
318 wf->read_bytes(dummy, sizeof dummy);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
319 wf->read_i16(&LineDefs[n].sidedef1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
320 wf->read_i16(&LineDefs[n].sidedef2);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
321 LineDefs[n].type = dummy[0];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
322 LineDefs[n].tag = dummy[1]; // arg1 often contains a tag
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
323 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
324 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
325 err("%s: error reading linedef #%ld", lump_name, n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
326 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
327 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
328 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
329 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
330 else // Doom/Heretic/Strife mode
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
331 for (long n = 0; n < NumLineDefs; n++)
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 wf->read_i16(&LineDefs[n].start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
334 wf->read_i16(&LineDefs[n].end);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
335 wf->read_i16(&LineDefs[n].flags);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
336 wf->read_i16(&LineDefs[n].type);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
337 wf->read_i16(&LineDefs[n].tag);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
338 wf->read_i16(&LineDefs[n].sidedef1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
339 wf->read_i16(&LineDefs[n].sidedef2);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
340 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
341 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
342 err("%s: error reading linedef #%ld", lump_name, n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
343 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
344 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
345 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
346 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
347 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
348 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 // Read 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
351 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
352 const char *lump_name = "SIDEDEFS";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
353 verbmsg(" sidedefs");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
354 dir = FindMasterDir(Level, lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
355 if (dir)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
356 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
357 NumSideDefs = (int) (dir->dir.size / WAD_SIDEDEF_BYTES);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
358 if ((i32) (NumSideDefs * WAD_SIDEDEF_BYTES) != dir->dir.size)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
359 warn("the SIDEDEFS lump has a weird size."
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
360 " The wad might be corrupt.\n");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
361 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
362 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
363 NumSideDefs = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
364 if (NumSideDefs > 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
365 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
366 SideDefs = (SDPtr) GetMemory((unsigned long) NumSideDefs
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
367 * sizeof(struct SideDef));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
368 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
369 wf->seek(dir->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
370 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
371 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
372 err("%s: seek error", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
373 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
374 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
375 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
376 for (long n = 0; n < NumSideDefs; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
377 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
378 wf->read_i16(&SideDefs[n].xoff);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
379 wf->read_i16(&SideDefs[n].yoff);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
380 wf->read_bytes(&SideDefs[n].tex1, WAD_TEX_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
381 wf->read_bytes(&SideDefs[n].tex2, WAD_TEX_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
382 wf->read_bytes(&SideDefs[n].tex3, WAD_TEX_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
383 wf->read_i16(&SideDefs[n].sector);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
384 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
385 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
386 err("%s: error reading sidedef #%ld", lump_name, n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
387 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
388 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
389 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
390 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
391 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
392 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394 /* Sanity checkings on linedefs: the 1st and 2nd vertices
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 must exist. The 1st and 2nd sidedefs must exist or be
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396 set to -1. */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
397 for (long n = 0; n < NumLineDefs; n++)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
398 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
399 if (LineDefs[n].sidedef1 != -1
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
400 && outside(LineDefs[n].sidedef1, 0, NumSideDefs - 1))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
401 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
402 err("linedef %ld has bad 1st sidedef number %d, giving up",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
403 n, LineDefs[n].sidedef1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
404 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
405 if (cfg.error_res <= 2) goto byebye;
44
a862fd9906ec Introduce error resilience feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
406 LineDefs[n].sidedef1 = 0;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
407 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
408 if (LineDefs[n].sidedef2 != -1
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
409 && outside(LineDefs[n].sidedef2, 0, NumSideDefs - 1))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
410 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
411 err("linedef %ld has bad 2nd sidedef number %d, giving up",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
412 n, LineDefs[n].sidedef2);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
413 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
414 if (cfg.error_res <= 2) goto byebye;
44
a862fd9906ec Introduce error resilience feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
415 LineDefs[n].sidedef2 = 0;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
416 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
417 if (outside(LineDefs[n].start, 0, OldNumVertices - 1))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
418 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
419 err("linedef %ld has bad 1st vertex number %d, giving up",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
420 n, LineDefs[n].start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
421 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
422 if (cfg.error_res <= 2) goto byebye;
44
a862fd9906ec Introduce error resilience feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
423 LineDefs[n].start = 0;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
424 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
425 if (outside(LineDefs[n].end, 0, OldNumVertices - 1))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
426 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
427 err("linedef %ld has bad 2nd vertex number %d, giving up",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
428 n, LineDefs[n].end);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
429 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
430 if (cfg.error_res <= 2) goto byebye;
44
a862fd9906ec Introduce error resilience feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
431 LineDefs[n].end = 0;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
432 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
433 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
434
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
435 // Read LINES (Doom alpha only)
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
436 if (yg_level_format == YGLF_ALPHA)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
437 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
438 const char *lump_name = "LINES";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
439 verbmsg(" lines");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
440 dir = FindMasterDir(Level, lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
441 if (dir)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
442 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
443 if ((dir->dir.size - 4) % 36)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
444 warn("the %s lump has a weird size. The wad might be corrupt.\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
445 const size_t nlines = dir->dir.size / 36;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
446 NumLineDefs = nlines;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
447 NumSideDefs = 2 * nlines; // Worst case. We'll adjust later.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
448 LineDefs = (LDPtr) GetMemory((unsigned long) NumLineDefs
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
449 * sizeof(struct LineDef));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
450 SideDefs = (SDPtr) GetMemory((unsigned long) NumSideDefs
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
451 * sizeof(struct SideDef));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
452 // Read TEXTURES
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
453 if (yg_texture_format != YGTF_NAMELESS)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
454 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
455 const char *lump_name = "TEXTURES";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
456 bool success = false;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
457 ntex = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
458 i32 *offset_table = 0;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
459 MDirPtr d = FindMasterDir(cfg.MasterDir, lump_name);
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
460 if (!d)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
461 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
462 warn("%s: lump not found in directory\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
463 goto textures_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
464 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
465 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
466 const Wad_file *wf = d->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
467 wf->seek(d->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
468 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
469 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
470 warn("%s: seek error\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
471 goto textures_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
472 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
473 i32 num;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
474 wf->read_i32(&num);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
475 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
476 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
477 warn("%s: error reading texture count\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
478 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
479 if (num < 0 || num > 32767)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
480 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
481 warn("%s: bad texture count, giving up\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
482 goto textures_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
483 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
484 ntex = num;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
485 offset_table = new i32[ntex];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
486 for (size_t n = 0; n < ntex; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
487 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
488 wf->read_i32(offset_table + n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
489 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
490 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
491 warn("%s: error reading offsets table\n");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
492 goto textures_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
493 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
494 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
495 tex_list = (char *) GetMemory(ntex * WAD_TEX_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
496 for (size_t n = 0; n < ntex; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
497 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
498 const long offset = d->dir.start + offset_table[n];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
499 wf->seek(offset);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
500 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
501 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
502 warn("%s: seek error\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
503 goto textures_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
504 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
505 wf->read_bytes(tex_list + WAD_TEX_NAME * n,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
506 WAD_TEX_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
507 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
508 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
509 warn("%s: error reading texture names\n",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
510 lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
511 goto textures_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
512 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
513 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
514 success = true;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
515 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
516
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
517 textures_done:
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
518 if (offset_table != 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
519 delete[]offset_table;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
520 if (!success)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
521 warn("%s: errors found, won't be able to import texture names\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
522 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
523
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
524 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
525 wf->seek(dir->dir.start + 4);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
526 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
527 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
528 err("%s: seek error", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
529 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
530 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
531 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
532 size_t s = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
533 for (size_t n = 0; n < nlines; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
534 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
535 LDPtr ld = LineDefs + n;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
536 ld->start = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
537 ld->end = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
538 ld->flags = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
539 wf->read_i16(); // Unused ?
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
540 ld->type = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
541 ld->tag = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
542 wf->read_i16(); // Unused ?
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
543 i16 sector1 = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
544 i16 xofs1 = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
545 i16 tex1m = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
546 i16 tex1u = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
547 i16 tex1l = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
548 wf->read_i16(); // Unused ?
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
549 i16 sector2 = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
550 i16 xofs2 = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
551 i16 tex2m = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
552 i16 tex2u = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
553 i16 tex2l = wf->read_i16();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
554 if (sector1 >= 0) // Create first sidedef
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
555 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
556 ld->sidedef1 = s;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
557 SDPtr sd = SideDefs + s;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
558 sd->xoff = xofs1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
559 sd->yoff = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
560 memcpy(sd->tex1, texno_texname(tex1u), sizeof sd->tex1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
561 memcpy(sd->tex2, texno_texname(tex1l), sizeof sd->tex2);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
562 memcpy(sd->tex3, texno_texname(tex1m), sizeof sd->tex3);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
563 sd->sector = sector1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
564 s++;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
565 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
566 else // No first sidedef !
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
567 ld->sidedef1 = -1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
568 if (ld->flags & 0x04) // Create second sidedef
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
569 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
570 ld->sidedef2 = s;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
571 SDPtr sd = SideDefs + s;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
572 sd->xoff = xofs2;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
573 sd->yoff = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
574 memcpy(sd->tex1, texno_texname(tex2u), sizeof sd->tex1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
575 memcpy(sd->tex2, texno_texname(tex2l), sizeof sd->tex2);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
576 memcpy(sd->tex3, texno_texname(tex2m), sizeof sd->tex3);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
577 sd->sector = sector2;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
578 s++;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
579 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
580 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
581 ld->sidedef2 = -1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
582 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
583 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
584 err("%s: error reading line #%d", lump_name, int (n));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
585 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
586 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
587 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
588 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
589 // (size_t) to silence GCC warning
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
590 if ((size_t) NumSideDefs > s) // Almost always true.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
591 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
592 NumSideDefs = s;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
593 SideDefs = (SDPtr) ResizeMemory(SideDefs,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
594 (unsigned long) NumSideDefs *
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
595 sizeof(struct SideDef));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
596 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
597 if (tex_list)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
598 FreeMemory(tex_list);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
599 tex_list = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
600 ntex = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
601 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
602 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
603
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
604 /* Read the vertices. If the wad has been run through a nodes
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
605 builder, there is a bunch of vertices at the end that are not
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
606 used by any linedefs. Those vertices have been created by the
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
607 nodes builder for the segs. We ignore them, because they're
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
608 useless to the level designer. However, we do NOT ignore
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
609 unused vertices in the middle because that's where the
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
610 "string art" bug came from.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
611
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
612 Note that there is absolutely no guarantee that the nodes
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
613 builders add their own vertices at the end, instead of at the
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
614 beginning or right in the middle, AFAIK. It's just that they
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
615 all seem to do that (1). What if some don't ? Well, we would
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
616 end up with many unwanted vertices in the level data. Nothing
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
617 that a good CheckCrossReferences() couldn't take care of. */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
618 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
619 verbmsg(" vertices");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
620 int last_used_vertex = -1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
621 for (long n = 0; n < NumLineDefs; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
622 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
623 last_used_vertex = y_max(last_used_vertex, LineDefs[n].start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
624 last_used_vertex = y_max(last_used_vertex, LineDefs[n].end);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
625 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
626 NumVertices = last_used_vertex + 1;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
627 // This block is only here to warn me if (1) is false.
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
628 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
629 bitvec_c vertex_used(OldNumVertices);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
630 for (long n = 0; n < NumLineDefs; n++)
44
a862fd9906ec Introduce error resilience feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
631 if (LineDefs[n].start != -1 && LineDefs[n].end != -1)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
632 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
633 vertex_used.set(LineDefs[n].start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
634 vertex_used.set(LineDefs[n].end);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
635 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
636 int unused = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
637 for (long n = 0; n <= last_used_vertex; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
638 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
639 if (!vertex_used.get(n))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
640 unused++;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
641 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
642 if (unused > 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
643 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
644 warn("this level has unused vertices in the middle.\n");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
645 warn("total %d, tail %d (%d%%), unused %d (",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
646 OldNumVertices,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
647 OldNumVertices - NumVertices,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
648 NumVertices - unused
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
649 ? 100 * (OldNumVertices - NumVertices) / (NumVertices -
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
650 unused) : 0,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
651 unused);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
652 int first = 1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
653 for (int n = 0; n <= last_used_vertex; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
654 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
655 if (!vertex_used.get(n))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
656 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
657 if (n == 0 || vertex_used.get(n - 1))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
658 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
659 if (first)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
660 first = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
661 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
662 warn(", ");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
663 warn("%d", n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
664 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
665 else if (n == last_used_vertex
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
666 || vertex_used.get(n + 1))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
667 warn("-%d", n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
668 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
669 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
670 warn(")\n");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
671 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
672 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
673 // Now load all the vertices except the unused ones at the end.
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
674 if (NumVertices > 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
675 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
676 const char *lump_name = "BUG";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
677 Vertices = (VPtr) GetMemory((unsigned long) NumVertices
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
678 * sizeof(struct Vertex));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
679 if (yg_level_format == YGLF_ALPHA) // Doom alpha
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
680 lump_name = "POINTS";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
681 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
682 lump_name = "VERTEXES";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
683 dir = FindMasterDir(Level, lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
684 if (dir == 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
685 goto vertexes_done; // FIXME isn't that fatal ?
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
686 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
687 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
688 wf->seek(v_offset);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
689 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
690 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
691 err("%s: seek error", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
692 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
693 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
694 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
695 MapMaxX = -32767;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
696 MapMaxY = -32767;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
697 MapMinX = 32767;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
698 MapMinY = 32767;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
699 for (long n = 0; n < NumVertices; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
700 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
701 i16 val;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
702 wf->read_i16(&val);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
703 if (val < MapMinX)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
704 MapMinX = val;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
705 if (val > MapMaxX)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
706 MapMaxX = val;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
707 Vertices[n].x = val;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
708 wf->read_i16(&val);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
709 if (val < MapMinY)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
710 MapMinY = val;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
711 if (val > MapMaxY)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
712 MapMaxY = val;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
713 Vertices[n].y = val;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
714 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
715 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
716 err("%s: error reading vertex #%ld", lump_name, n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
717 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
718 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
719 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
720 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
721 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
722 vertexes_done:
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
723 ;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
724 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
725 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
726
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
727 // Ignore SEGS, SSECTORS and NODES
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
728
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
729 // Read SECTORS
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
730 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
731 const char *lump_name = "SECTORS";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
732 verbmsg(" sectors\n");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
733 dir = FindMasterDir(Level, lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
734 if (yg_level_format != YGLF_ALPHA)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
735 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
736 if (dir)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
737 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
738 NumSectors = (int) (dir->dir.size / WAD_SECTOR_BYTES);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
739 if ((i32) (NumSectors * WAD_SECTOR_BYTES) != dir->dir.size)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
740 warn("the %s lump has a weird size."
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
741 " The wad might be corrupt.\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
742 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
743 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
744 NumSectors = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
745 if (NumSectors > 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
746 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
747 Sectors = (SPtr) GetMemory((unsigned long) NumSectors
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
748 * sizeof(struct Sector));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
749 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
750 wf->seek(dir->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
751 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
752 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
753 err("%s: seek error", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
754 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
755 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
756 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
757 for (long n = 0; n < NumSectors; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
758 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
759 wf->read_i16(&Sectors[n].floorh);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
760 wf->read_i16(&Sectors[n].ceilh);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
761 wf->read_bytes(&Sectors[n].floort, WAD_FLAT_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
762 wf->read_bytes(&Sectors[n].ceilt, WAD_FLAT_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
763 wf->read_i16(&Sectors[n].light);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
764 wf->read_i16(&Sectors[n].special);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
765 wf->read_i16(&Sectors[n].tag);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
766 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
767 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
768 err("%s: error reading sector #%ld", lump_name, n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
769 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
770 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
771 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
772 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
773 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
774 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
775 else // Doom alpha--a wholly different SECTORS format
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
776 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
777 i32 *offset_table = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
778 i32 nsectors = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
779 i32 nflatnames = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
780 char *flatnames = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
781 if (dir == 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
782 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
783 warn("%s: lump not found in directory\n", lump_name); // FIXME fatal ?
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
784 goto sectors_alpha_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
785 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
786 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
787 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
788 wf->seek(dir->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
789 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
790 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
791 err("%s: seek error", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
792 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
793 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
794 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
795 wf->read_i32(&nsectors);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
796 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
797 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
798 err("%s: error reading sector count", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
799 rc = 1;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
800 if (cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
801 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
802 if (nsectors < 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
803 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
804 warn("Negative sector count. Clamping to 0.\n");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
805 nsectors = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
806 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
807 NumSectors = nsectors;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
808 Sectors = (SPtr) GetMemory((unsigned long) NumSectors
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
809 * sizeof(struct Sector));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
810 offset_table = new i32[nsectors];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
811 for (size_t n = 0; n < (size_t) nsectors; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
812 wf->read_i32(offset_table + n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
813 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
814 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
815 err("%s: error reading offsets table", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
816 rc = 1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
817 goto sectors_alpha_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
818 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
819 // Load FLATNAME
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
820 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
821 const char *lump_name = "FLATNAME";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
822 bool success = false;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
823 MDirPtr dir2 = FindMasterDir(Level, lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
824 if (dir2 == 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
825 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
826 warn("%s: lump not found in directory\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
827 goto flatname_done; // FIXME warn ?
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
828 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
829 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
830 const Wad_file *wf = dir2->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
831 wf->seek(dir2->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
832 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
833 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
834 warn("%s: seek error\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
835 goto flatname_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
836 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
837 wf->read_i32(&nflatnames);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
838 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
839 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
840 warn("%s: error reading flat name count\n",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
841 lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
842 nflatnames = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
843 goto flatname_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
844 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
845 if (nflatnames < 0 || nflatnames > 32767)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
846 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
847 warn("%s: bad flat name count, giving up\n",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
848 lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
849 nflatnames = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
850 goto flatname_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
851 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
852 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
853 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
854 flatnames = new char[WAD_FLAT_NAME * nflatnames];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
855 wf->read_bytes(flatnames,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
856 WAD_FLAT_NAME * nflatnames);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
857 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
858 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
859 warn("%s: error reading flat names\n",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
860 lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
861 nflatnames = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
862 goto flatname_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
863 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
864 success = true;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
865 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
866 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
867 flatname_done:
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
868 if (!success)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
869 warn("%s: errors found, you'll have to do without flat names\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
870 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
871 for (size_t n = 0; n < (size_t) nsectors; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
872 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
873 wf->seek(dir->dir.start + offset_table[n]);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
874 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
875 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
876 err("%s: seek error", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
877 rc = 1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
878 goto sectors_alpha_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
879 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
880 i16 index;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
881 wf->read_i16(&Sectors[n].floorh);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
882 wf->read_i16(&Sectors[n].ceilh);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
883 wf->read_i16(&index);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
884 if (nflatnames && flatnames && index >= 0
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
885 && index < nflatnames)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
886 memcpy(Sectors[n].floort,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
887 flatnames + WAD_FLAT_NAME * index,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
888 WAD_FLAT_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
889 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
890 strcpy(Sectors[n].floort, "unknown");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
891 wf->read_i16(&index);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
892 if (nflatnames && flatnames && index >= 0
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
893 && index < nflatnames)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
894 memcpy(Sectors[n].ceilt,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
895 flatnames + WAD_FLAT_NAME * index,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
896 WAD_FLAT_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
897 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
898 strcpy(Sectors[n].ceilt, "unknown");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
899 wf->read_i16(&Sectors[n].light);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
900 wf->read_i16(&Sectors[n].special);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
901 wf->read_i16(&Sectors[n].tag);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
902 // Don't know what the tail is for. Ignore it.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
903 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
904 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
905 err("%s: error reading sector #%ld", lump_name,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
906 long (n));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
907 rc = 1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
908 goto sectors_alpha_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
909 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
910 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
911 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
912
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
913 sectors_alpha_done:
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
914 if (offset_table != 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
915 delete[]offset_table;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
916 if (flatnames != 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
917 delete[]flatnames;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
918 if (rc != 0 && cfg.error_res <= 3) goto byebye;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
919 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
920 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
921
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
922 /* Sanity checking on sidedefs: the sector must exist. I don't
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
923 make this a fatal error, though, because it's not exceptional
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
924 to find wads with unused sidedefs with a sector# of -1. Well
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
925 known ones include dyst3 (MAP06, MAP07, MAP08), mm (MAP16),
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
926 mm2 (MAP13, MAP28) and requiem (MAP03, MAP08, ...). */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
927 for (long n = 0; n < NumSideDefs; n++)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
928 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
929 if (outside(SideDefs[n].sector, 0, NumSectors - 1))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
930 warn("sidedef %ld has bad sector number %d\n",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
931 n, SideDefs[n].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
932 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
933
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
934 // Ignore REJECT and BLOCKMAP
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
935
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
936 // Silly statistics
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
937 verbmsg
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
938 (" %d things, %d vertices, %d linedefs, %d sidedefs, %d sectors\n",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
939 (int) NumThings, (int) NumVertices, (int) NumLineDefs,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
940 (int) NumSideDefs, (int) NumSectors);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
941 verbmsg(" Map: (%d,%d)-(%d,%d)\n", MapMinX, MapMinY, MapMaxX, MapMaxY);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
942
44
a862fd9906ec Introduce error resilience feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
943 byebye:
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
944 if (rc != 0)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
945 err("%s: errors found, giving up", levelname);
44
a862fd9906ec Introduce error resilience feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
946
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
947 return (cfg.error_res > 0) ? 0 : rc;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
948 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
949
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
950
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
951
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
952 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
953 forget the level data
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
954 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
955
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
956 void ForgetLevelData() /* SWAP! */
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
957 {
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
958 /* forget the things */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
959 NumThings = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
960 if (Things != 0)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
961 FreeMemory(Things);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
962 Things = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
963 things_angles++;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
964 things_types++;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
965
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
966 /* forget the vertices */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
967 NumVertices = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
968 if (Vertices != 0)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
969 FreeMemory(Vertices);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
970 Vertices = 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
971
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
972 /* forget the linedefs */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
973 NumLineDefs = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
974 if (LineDefs != 0)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
975 FreeMemory(LineDefs);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
976 LineDefs = 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
977
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
978 /* forget the 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
979 NumSideDefs = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
980 if (SideDefs != 0)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
981 FreeMemory(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
982 SideDefs = 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
983
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
984 /* forget the sectors */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
985 NumSectors = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
986 if (Sectors != 0)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
987 FreeMemory(Sectors);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
988 Sectors = 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
989 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
990
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
991
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
992 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
993 * Save the level data to a pwad file
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
994 * The name of the level is always obtained from
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
995 * <level_name>, whether or not the level was created from
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
996 * scratch.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
997 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
998 * The previous contents of the pwad file are lost. Yes, it
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
999 * sucks but it's not easy to fix.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1000 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1001 * The lumps are always written in the same order, the same
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1002 * as the one in the Doom iwad. The length field of the
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1003 * marker lump is always set to 0. Its offset field is
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1004 * always set to the offset of the first lump of the level
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1005 * (THINGS).
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1006 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1007 * If the level has been created by editing an existing
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1008 * level and has not been changed in a way that calls for a
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1009 * rebuild of the nodes, the VERTEXES, SEGS, SSECTORS,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1010 * NODES, REJECT and BLOCKMAP lumps are copied from the
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1011 * original level. Otherwise, they are created with a
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1012 * length of 0 bytes and an offset equal to the offset of
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1013 * the previous lump plus its length.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1014 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1015 * Returns 0 on success and non-zero on failure (see errno).
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1016 */
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1017 int SaveLevelData(const char *outfile, const char *level_name) /* SWAP! */
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1018 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1019 FILE *file;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1020 MDirPtr dir;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1021 int n;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1022 long lump_offset[WAD_LL__];
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1023 size_t lump_size[WAD_LL__];
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1024 wad_level_lump_no_t l;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1025
84
c518e08d5961 More logic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 83
diff changeset
1026 if (yg_level_format == YGLF_HEXEN || cfg.GameId == IWAD_HEXEN)
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1027 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1028 Notify(-1, -1, "I refuse to save. Hexen mode is still",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1029 "too badly broken. You would lose data.");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1030 return 1;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1031 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1032 if (!level_name || !levelname2levelno(level_name))
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1033 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1034 nf_bug
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1035 ("SaveLevelData: bad level_name \"%s\", using \"E1M1\" instead.",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1036 level_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1037 level_name = "E1M1";
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1038 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1039 DisplayMessage(-1, -1, "Saving data to \"%s\"...", outfile);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1040 LogMessage(": Saving data to \"%s\"...\n", outfile);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1041 if ((file = fopen(outfile, "wb")) == NULL)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1042 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1043 char buf1[81];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1044 char buf2[81];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1045 y_snprintf(buf1, sizeof buf1, "Can't open \"%.64s\"", outfile);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1046 y_snprintf(buf2, sizeof buf1, "for writing (%.64s)", strerror(errno));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1047 Notify(-1, -1, buf1, buf2);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1048 return 1;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1049 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1050
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1051 /* Can we reuse the old nodes ? Not if this is a new level from
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1052 scratch or if the structure of the level has changed. If the
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1053 level comes from an alpha version of Doom, we can't either
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1054 because that version of Doom didn't have SEGS, NODES, etc. */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1055 bool reuse_nodes = Level
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1056 && !MadeMapChanges && yg_level_format != YGLF_ALPHA;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1057
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1058 // Write the pwad header
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1059 WriteBytes(file, "PWAD", 4); // Pwad file
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1060 file_write_i32(file, WAD_LL__); // Number of entries = 11
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1061 file_write_i32(file, 0); // Fix this up later
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1062 if (Level)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1063 dir = Level->next;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1064 else
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1065 dir = 0; // Useless except to trap accidental dereferences
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1066
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1067 // The label (EnMm or MAPnm)
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1068 l = WAD_LL_LABEL;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1069 lump_offset[l] = ftell(file); // By definition
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1070 lump_size[l] = 0; // By definition
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1071
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1072 // Write the THINGS lump
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1073 l = WAD_LL_THINGS;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1074 lump_offset[l] = ftell(file);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1075 for (n = 0; n < NumThings; n++)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1076 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1077 file_write_i16(file, Things[n].xpos);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1078 file_write_i16(file, Things[n].ypos);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1079 file_write_i16(file, Things[n].angle);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1080 file_write_i16(file, Things[n].type);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1081 file_write_i16(file, Things[n].when);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1082 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1083 lump_size[l] = ftell(file) - lump_offset[l];
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1084 if (Level)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1085 dir = dir->next;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1086
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1087 // Write the LINEDEFS lump
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1088 l = WAD_LL_LINEDEFS;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1089 lump_offset[WAD_LL_LINEDEFS] = ftell(file);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1090 for (n = 0; n < NumLineDefs; n++)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1091 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1092 file_write_i16(file, LineDefs[n].start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1093 file_write_i16(file, LineDefs[n].end);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1094 file_write_i16(file, LineDefs[n].flags);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1095 file_write_i16(file, LineDefs[n].type);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1096 file_write_i16(file, LineDefs[n].tag);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1097 file_write_i16(file, LineDefs[n].sidedef1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1098 file_write_i16(file, LineDefs[n].sidedef2);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1099 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1100 lump_size[l] = ftell(file) - lump_offset[l];
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1101 if (Level)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1102 dir = dir->next;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1103
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1104 // Write the SIDEDEFS lump
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1105 l = WAD_LL_SIDEDEFS;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1106 lump_offset[l] = ftell(file);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1107 for (n = 0; n < NumSideDefs; n++)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1108 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1109 file_write_i16(file, SideDefs[n].xoff);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1110 file_write_i16(file, SideDefs[n].yoff);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1111 WriteBytes(file, &(SideDefs[n].tex1), WAD_TEX_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1112 WriteBytes(file, &(SideDefs[n].tex2), WAD_TEX_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1113 WriteBytes(file, &(SideDefs[n].tex3), WAD_TEX_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1114 file_write_i16(file, SideDefs[n].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
1115 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1116 lump_size[l] = ftell(file) - lump_offset[l];
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1117 if (Level)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1118 dir = dir->next;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1119
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1120 // Write the VERTEXES lump
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1121 l = WAD_LL_VERTEXES;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1122 lump_offset[WAD_LL_VERTEXES] = ftell(file);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1123 if (reuse_nodes)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1124 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1125 /* Copy the vertices */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1126 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1127 wf->seek(dir->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1128 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1129 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1130 warn("%s: seek error\n", wad_level_lump[l]);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1131 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1132 copy_bytes(file, wf->fp, dir->dir.size);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1133 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1134 else
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1135 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1136 /* Write the vertices */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1137 for (n = 0; n < NumVertices; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1138 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1139 file_write_i16(file, Vertices[n].x);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1140 file_write_i16(file, Vertices[n].y);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1141 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1142 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1143 lump_size[l] = ftell(file) - lump_offset[l];
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1144 if (Level)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1145 dir = dir->next;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1146
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1147 // Write the SEGS, SSECTORS and NODES lumps
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1148 for (n = 0; n < 3; n++)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1149 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1150 if (n == 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1151 l = WAD_LL_SEGS;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1152 else if (n == 1)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1153 l = WAD_LL_SSECTORS;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1154 else if (n == 2)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1155 l = WAD_LL_NODES;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1156 lump_offset[l] = ftell(file);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1157 if (reuse_nodes)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1158 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1159 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1160 wf->seek(dir->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1161 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1162 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1163 warn("%s: seek error\n", wad_level_lump[l]);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1164 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1165 copy_bytes(file, wf->fp, dir->dir.size);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1166 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1167 lump_size[l] = ftell(file) - lump_offset[l];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1168 if (Level)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1169 dir = dir->next;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1170 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1171
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1172 // Write the SECTORS lump
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1173 l = WAD_LL_SECTORS;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1174 lump_offset[l] = ftell(file);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1175 for (n = 0; n < NumSectors; n++)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1176 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1177 file_write_i16(file, Sectors[n].floorh);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1178 file_write_i16(file, Sectors[n].ceilh);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1179 WriteBytes(file, Sectors[n].floort, WAD_FLAT_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1180 WriteBytes(file, Sectors[n].ceilt, WAD_FLAT_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1181 file_write_i16(file, Sectors[n].light);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1182 file_write_i16(file, Sectors[n].special);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1183 file_write_i16(file, Sectors[n].tag);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1184 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1185 lump_size[l] = ftell(file) - lump_offset[l];
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1186 if (Level)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1187 dir = dir->next;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1188
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1189 // Write the REJECT lump
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1190 l = WAD_LL_REJECT;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1191 lump_offset[l] = ftell(file);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1192 if (reuse_nodes)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1193 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1194 /* Copy the REJECT data */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1195 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1196 wf->seek(dir->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1197 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1198 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1199 warn("%s: seek error\n", wad_level_lump[l]);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1200 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1201 copy_bytes(file, wf->fp, dir->dir.size);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1202 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1203 lump_size[l] = ftell(file) - lump_offset[l];
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1204 if (Level)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1205 dir = dir->next;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1206
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1207 // Write the BLOCKMAP lump
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1208 l = WAD_LL_BLOCKMAP;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1209 lump_offset[l] = ftell(file);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1210 if (reuse_nodes)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1211 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1212 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1213 wf->seek(dir->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1214 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1215 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1216 warn("%s: seek error\n", wad_level_lump[l]);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1217 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1218 copy_bytes(file, wf->fp, dir->dir.size);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1219 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1220 lump_size[l] = ftell(file) - lump_offset[l];
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1221 if (Level)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1222 dir = dir->next;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1223
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1224 // Write the actual directory
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1225 long dir_offset = ftell(file);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1226 for (int L = 0; L < (int) WAD_LL__; L++)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1227 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1228 file_write_i32(file, lump_offset[L]);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1229 file_write_i32(file, lump_size[L]);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1230 if (L == (int) WAD_LL_LABEL)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1231 file_write_name(file, level_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1232 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1233 file_write_name(file, wad_level_lump[L].name);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1234 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1235
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1236 /* Fix up the directory start information */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1237 if (fseek(file, 8, SEEK_SET))
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1238 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1239 char buf1[81];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1240 char buf2[81];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1241 y_snprintf(buf1, sizeof buf1, "%.64s: seek error", outfile);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1242 y_snprintf(buf2, sizeof buf2, "(%.64s)", strerror(errno));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1243 Notify(-1, -1, buf1, buf2);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1244 fclose(file);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1245 return 1;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1246 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1247 file_write_i32(file, dir_offset);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1248
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1249 /* Close the file */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1250 if (fclose(file))
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1251 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1252 char buf1[81];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1253 char buf2[81];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1254 y_snprintf(buf1, sizeof buf1, "%.64s: write error", outfile);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1255 y_snprintf(buf2, sizeof buf2, "(%.64s)", strerror(errno));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1256 Notify(-1, -1, buf1, buf2);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1257 return 1;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1258 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1259
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1260 /* The file is now up to date */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1261 if (!Level || MadeMapChanges)
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1262 cfg.remind_to_build_nodes = 1;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1263 MadeChanges = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1264 MadeMapChanges = 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1265
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1266 /* Update pointers in Master Directory */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1267 OpenPatchWad(outfile);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1268
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1269 /* This should free the old "*.bak" file */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1270 CloseUnusedWadFiles();
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1271
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1272 /* Update MapMinX, MapMinY, MapMaxX, MapMaxY */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1273 // Probably not necessary anymore -- AYM 1999-04-05
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1274 update_level_bounds();
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1275 return 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1276 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1277
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1278
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1279 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1280 * flat_list_entry_cmp
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1281 * Function used by qsort() to sort the flat_list_entry array
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1282 * by ascending flat name.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1283 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1284 static int flat_list_entry_cmp(const void *a, const void *b)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1285 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1286 return y_strnicmp(((const flat_list_entry_t *) a)->name,
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1287 ((const flat_list_entry_t *) b)->name, WAD_FLAT_NAME);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1288 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1289
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1290
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1291 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1292 function used by qsort to sort the texture names
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1293 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1294 static int SortTextures(const void *a, const void *b)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1295 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1296 return y_strnicmp(*((const char *const *) a), *((const char *const *) b),
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1297 WAD_TEX_NAME);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1298 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1299
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1300
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1301 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1302 read the texture names
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1303 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1304 void ReadWTextureNames()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1305 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1306 MDirPtr dir;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1307 int n;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1308 i32 val;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1309
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1310 verbmsg("Reading texture names\n");
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1311
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1312 // Doom alpha 0.4 : "TEXTURES", no names
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1313 if (yg_texture_lumps == YGTL_TEXTURES
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1314 && yg_texture_format == YGTF_NAMELESS)
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1315 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1316 const char *lump_name = "TEXTURES";
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1317 dir = FindMasterDir(cfg.MasterDir, lump_name);
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1318 if (dir == NULL)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1319 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1320 warn("%s: lump not found in directory\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1321 goto textures04_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1322 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1323 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1324 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1325 wf->seek(dir->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1326 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1327 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1328 warn("%s: seek error\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1329 goto textures04_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1330 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1331 wf->read_i32(&val);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1332 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1333 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1334 warn("%s: error reading texture count\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1335 goto textures04_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1336 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1337 NumWTexture = (int) val + 1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1338 WTexture =
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1339 (char **) GetMemory((long) NumWTexture * sizeof *WTexture);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1340 WTexture[0] = (char *) GetMemory(WAD_TEX_NAME + 1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1341 strcpy(WTexture[0], "-");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1342 if (WAD_TEX_NAME < 7)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1343 nf_bug("WAD_TEX_NAME too small"); // Sanity
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1344 for (long n = 0; n < val; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1345 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1346 WTexture[n + 1] = (char *) GetMemory(WAD_TEX_NAME + 1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1347 if (n > 9999)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1348 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1349 warn("more than 10,000 textures. Ignoring excess.\n");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1350 break;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1351 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1352 sprintf(WTexture[n + 1], "TEX%04ld", n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1353 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1354 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1355 textures04_done:
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1356 ;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1357 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1358
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1359 // Doom alpha 0.5 : only "TEXTURES"
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1360 else if (yg_texture_lumps == YGTL_TEXTURES
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1361 && (yg_texture_format == YGTF_NORMAL
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1362 || yg_texture_format == YGTF_STRIFE11))
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1363 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1364 const char *lump_name = "TEXTURES";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1365 i32 *offsets = 0;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1366 dir = FindMasterDir(cfg.MasterDir, lump_name);
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1367 if (dir == NULL) // In theory it always exists, though
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1368 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1369 warn("%s: lump not found in directory\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1370 goto textures05_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1371 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1372 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1373 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1374 wf->seek(dir->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1375 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1376 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1377 warn("%s: seek error\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1378 goto textures05_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1379 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1380 wf->read_i32(&val);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1381 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1382 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1383 warn("%s: error reading texture count\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1384 goto textures05_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1385 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1386 NumWTexture = (int) val + 1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1387 /* read in the offsets for texture1 names */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1388 offsets = (i32 *) GetMemory((long) NumWTexture * 4);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1389 wf->read_i32(offsets + 1, NumWTexture - 1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1390 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1391 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1392 warn("%s: error reading offsets table\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1393 goto textures05_done;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1394 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1395 /* read in the actual names */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1396 WTexture =
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1397 (char **) GetMemory((long) NumWTexture * sizeof(char *));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1398 WTexture[0] = (char *) GetMemory(WAD_TEX_NAME + 1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1399 strcpy(WTexture[0], "-");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1400 for (n = 1; n < NumWTexture; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1401 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1402 WTexture[n] = (char *) GetMemory(WAD_TEX_NAME + 1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1403 long offset = dir->dir.start + offsets[n];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1404 wf->seek(offset);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1405 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1406 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1407 warn("%s: error seeking to error\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1408 goto textures05_done; // FIXME cleanup
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1409 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1410 wf->read_bytes(WTexture[n], WAD_TEX_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1411 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1412 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1413 warn("%s: error reading texture names\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1414 goto textures05_done; // FIXME cleanup
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1415 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1416 WTexture[n][WAD_TEX_NAME] = '\0';
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1417 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1418 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1419 textures05_done:
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1420 if (offsets != 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1421 FreeMemory(offsets);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1422 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1423 // Other iwads : "TEXTURE1" and possibly "TEXTURE2"
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1424 else if (yg_texture_lumps == YGTL_NORMAL
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1425 && (yg_texture_format == YGTF_NORMAL
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1426 || yg_texture_format == YGTF_STRIFE11))
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1427 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1428 const char *lump_name = "TEXTURE1";
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1429 i32 *offsets = 0;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1430 dir = FindMasterDir(cfg.MasterDir, lump_name);
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1431 if (dir != NULL) // In theory it always exists, though
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1432 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1433 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1434 wf->seek(dir->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1435 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1436 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1437 warn("%s: seek error\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1438 // FIXME
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1439 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1440 wf->read_i32(&val);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1441 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1442 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1443 // FIXME
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1444 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1445 NumWTexture = (int) val + 1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1446 /* read in the offsets for texture1 names */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1447 offsets = (i32 *) GetMemory((long) NumWTexture * 4);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1448 wf->read_i32(offsets + 1, NumWTexture - 1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1449 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1450 // FIXME
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1451 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1452 /* read in the actual names */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1453 WTexture =
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1454 (char **) GetMemory((long) NumWTexture * sizeof(char *));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1455 WTexture[0] = (char *) GetMemory(WAD_TEX_NAME + 1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1456 strcpy(WTexture[0], "-");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1457 for (n = 1; n < NumWTexture; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1458 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1459 WTexture[n] = (char *) GetMemory(WAD_TEX_NAME + 1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1460 wf->seek(dir->dir.start + offsets[n]);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1461 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1462 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1463 warn("%s: seek error\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1464 // FIXME
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1465 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1466 wf->read_bytes(WTexture[n], WAD_TEX_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1467 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1468 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1469 // FIXME
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1470 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1471 WTexture[n][WAD_TEX_NAME] = '\0';
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1472 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1473 FreeMemory(offsets);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1474 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1475 {
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1476 dir = FindMasterDir(cfg.MasterDir, "TEXTURE2");
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1477 if (dir) /* Doom II has no TEXTURE2 */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1478 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1479 const Wad_file *wf = dir->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1480 wf->seek(dir->dir.start);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1481 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1482 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1483 warn("%s: seek error\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1484 // FIXME
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1485 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1486 wf->read_i32(&val);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1487 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1488 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1489 // FIXME
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1490 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1491 /* read in the offsets for texture2 names */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1492 offsets = (i32 *) GetMemory((long) val * 4);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1493 wf->read_i32(offsets, val);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1494 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1495 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1496 // FIXME
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1497 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1498 /* read in the actual names */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1499 WTexture = (char **) ResizeMemory(WTexture,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1500 (NumWTexture +
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1501 val) * sizeof(char *));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1502 for (n = 0; n < val; n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1503 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1504 WTexture[NumWTexture + n] =
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1505 (char *) GetMemory(WAD_TEX_NAME + 1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1506 wf->seek(dir->dir.start + offsets[n]);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1507 if (wf->error())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1508 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1509 warn("%s: seek error\n", lump_name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1510 // FIXME
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1511 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1512 wf->read_bytes(WTexture[NumWTexture + n], WAD_TEX_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1513 if (wf->error())
44
a862fd9906ec Introduce error resilience feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
1514 {
a862fd9906ec Introduce error resilience feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
1515 warn("%s: read error for texture %d / %d\n", lump_name, n, NumWTexture + n);
a862fd9906ec Introduce error resilience feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
1516 }
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1517 WTexture[NumWTexture + n][WAD_TEX_NAME] = '\0';
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1518 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1519 NumWTexture += val;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1520 FreeMemory(offsets);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1521 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1522 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1523 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1524 else
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1525 nf_bug("Invalid texture_format/texture_lumps combination.");
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1526
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1527 /* sort the names */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1528 qsort(WTexture, NumWTexture, sizeof(char *), SortTextures);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1529 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1530
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1531
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1532
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1533 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1534 forget the texture names
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1535 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1536
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1537 void ForgetWTextureNames()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1538 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1539 int n;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1540
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1541 /* forget all names */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1542 for (n = 0; n < NumWTexture; n++)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1543 FreeMemory(WTexture[n]);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1544
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1545 /* forget the array */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1546 NumWTexture = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1547 FreeMemory(WTexture);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1548 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1549
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1550
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1551
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1552 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1553 read the flat names
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1554 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1555
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1556 void ReadFTextureNames()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1557 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1558 MDirPtr dir;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1559 int n;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1560
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1561 verbmsg("Reading flat names");
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1562 NumFTexture = 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1563
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1564 for (dir = cfg.MasterDir; (dir = FindMasterDir(dir, "F_START", "FF_START"));)
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1565 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1566 bool ff_start = !y_strnicmp(dir->dir.name, "FF_START", WAD_NAME);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1567 MDirPtr dir0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1568 /* count the names */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1569 dir = dir->next;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1570 dir0 = dir;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1571 for (n = 0; dir && y_strnicmp(dir->dir.name, "F_END", WAD_NAME)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1572 && (!ff_start || y_strnicmp(dir->dir.name, "FF_END", WAD_NAME));
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1573 dir = dir->next)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1574 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1575 if (dir->dir.start == 0 || dir->dir.size == 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1576 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1577 if (!(toupper(dir->dir.name[0]) == 'F'
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1578 && (dir->dir.name[1] == '1'
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1579 || dir->dir.name[1] == '2'
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1580 || dir->dir.name[1] == '3'
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1581 || toupper(dir->dir.name[1]) == 'F')
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1582 && dir->dir.name[2] == '_'
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1583 &&
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1584 (!y_strnicmp(dir->dir.name + 3, "START", WAD_NAME - 3)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1585 || !y_strnicmp(dir->dir.name + 3, "END",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1586 WAD_NAME - 3))))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1587 warn("unexpected label \"%.*s\" among flats.\n", WAD_NAME,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1588 dir->dir.name);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1589 continue;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1590 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1591 if (dir->dir.size != 4096)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1592 warn("flat \"%.*s\" has weird size %lu."
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1593 " Using 4096 instead.\n",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1594 WAD_NAME, dir->dir.name, (unsigned long) dir->dir.size);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1595 n++;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1596 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1597 /* If FF_START/FF_END followed by F_END (mm2.wad), advance
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1598 past F_END. In fact, this does not work because the F_END
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1599 that follows has been snatched by OpenPatchWad(), that
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1600 thinks it replaces the F_END from the iwad. OpenPatchWad()
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1601 needs to be kludged to take this special case into
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1602 account. Fortunately, the only consequence is a useless
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1603 "this wad uses FF_END" warning. -- AYM 1999-07-10 */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1604 if (ff_start && dir && !y_strnicmp(dir->dir.name, "FF_END", WAD_NAME))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1605 if (dir->next
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1606 && !y_strnicmp(dir->next->dir.name, "F_END", WAD_NAME))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1607 dir = dir->next;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1608
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1609 verbmsg(" FF_START/%s %d", dir->dir.name, n);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1610 if (dir && !y_strnicmp(dir->dir.name, "FF_END", WAD_NAME))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1611 warn("this wad uses FF_END. That won't work with Doom."
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1612 " Use F_END instead.\n");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1613 /* get the actual names from master dir. */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1614 flat_list = (flat_list_entry_t *) ResizeMemory(flat_list,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1615 (NumFTexture +
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1616 n) *
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1617 sizeof *flat_list);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1618 for (size_t m = NumFTexture; m < NumFTexture + n; dir0 = dir0->next)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1619 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1620 // Skip all labels.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1621 if (dir0->dir.start == 0
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1622 || dir0->dir.size == 0
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1623 || (toupper(dir0->dir.name[0]) == 'F'
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1624 && (dir0->dir.name[1] == '1'
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1625 || dir0->dir.name[1] == '2'
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1626 || dir0->dir.name[1] == '3'
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1627 || toupper(dir0->dir.name[1]) == 'F')
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1628 && dir0->dir.name[2] == '_'
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1629 && (!y_strnicmp(dir0->dir.name + 3, "START", WAD_NAME - 3)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1630 || !y_strnicmp(dir0->dir.name + 3, "END",
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1631 WAD_NAME - 3))))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1632 continue;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1633 *flat_list[m].name = '\0';
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1634 strncat(flat_list[m].name, dir0->dir.name,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1635 sizeof flat_list[m].name - 1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1636 flat_list[m].wadfile = dir0->wadfile;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1637 flat_list[m].offset = dir0->dir.start;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1638 m++;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1639 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1640 NumFTexture += n;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1641 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1642
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1643 verbmsg("\n");
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1644
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1645 /* sort the flats by names */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1646 qsort(flat_list, NumFTexture, sizeof *flat_list, flat_list_entry_cmp);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1647
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1648 /* Eliminate all but the last duplicates of a flat. Suboptimal.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1649 Would be smarter to start by the end. */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1650 for (size_t n = 0; n < NumFTexture; n++)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1651 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1652 size_t m = n;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1653 while (m + 1 < NumFTexture
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1654 && !flat_list_entry_cmp(flat_list + n, flat_list + m + 1))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1655 m++;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1656 // m now contains the index of the last duplicate
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1657 int nduplicates = m - n;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1658 if (nduplicates > 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1659 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1660 memmove(flat_list + n, flat_list + m,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1661 (NumFTexture - m) * sizeof *flat_list);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1662 NumFTexture -= nduplicates;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1663 // Note that I'm too lazy to resize flat_list...
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1664 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1665 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1666 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1667
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1668
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1669 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1670 * is_flat_name_in_list
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1671 * FIXME should use bsearch()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1672 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1673 int is_flat_name_in_list(const char *name)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1674 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1675 if (!flat_list)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1676 return 0;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1677 for (size_t n = 0; n < NumFTexture; n++)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1678 if (!y_strnicmp(name, flat_list[n].name, WAD_FLAT_NAME))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1679 return 1;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1680 return 0;
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1681 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1682
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1683
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1684 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1685 forget the flat names
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1686 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1687
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1688 void ForgetFTextureNames()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1689 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1690 NumFTexture = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1691 FreeMemory(flat_list);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1692 flat_list = 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1693 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1694
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1695
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1696 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1697 * update_level_bounds - update Map{Min,Max}{X,Y}
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1698 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1699 void update_level_bounds()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1700 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1701 MapMaxX = -32767;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1702 MapMaxY = -32767;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1703 MapMinX = 32767;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1704 MapMinY = 32767;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1705 for (obj_no_t n = 0; n < NumVertices; n++)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1706 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1707 int x = Vertices[n].x;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1708 if (x < MapMinX)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1709 MapMinX = x;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1710 if (x > MapMaxX)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1711 MapMaxX = x;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1712 int y = Vertices[n].y;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1713 if (y < MapMinY)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1714 MapMinY = y;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1715 if (y > MapMaxY)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1716 MapMaxY = y;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
1717 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1718 }