Mercurial > hg > forks > yadex
annotate src/lumpdir.cc @ 93:5652866f31eb
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 06 Oct 2014 00:33:26 +0300 |
parents | 99242b34e6dc |
children |
rev | line source |
---|---|
0 | 1 /* |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
2 * lumpdir.cc |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
3 * Lump_dir class |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
4 * AYM 1999-11-25 |
0 | 5 */ |
6 | |
7 | |
8 /* | |
9 This file is part of Yadex. | |
10 | |
11 Yadex incorporates code from DEU 5.21 that was put in the public domain in | |
12 1994 by Raphaël Quinet and Brendon Wyber. | |
13 | |
14 The rest of Yadex is Copyright © 1997-2003 André Majorel and others. | |
15 | |
16 This program is free software; you can redistribute it and/or modify it under | |
17 the terms of the GNU General Public License as published by the Free Software | |
18 Foundation; either version 2 of the License, or (at your option) any later | |
19 version. | |
20 | |
21 This program is distributed in the hope that it will be useful, but WITHOUT | |
22 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
23 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |
24 | |
25 You should have received a copy of the GNU General Public License along with | |
26 this program; if not, write to the Free Software Foundation, Inc., 59 Temple | |
27 Place, Suite 330, Boston, MA 02111-1307, USA. | |
28 */ | |
29 | |
30 | |
31 #include "yadex.h" | |
32 #include "dependcy.h" | |
33 #include "lumpdir.h" | |
34 #include "wadname.h" | |
35 #include "wadnamec.h" | |
36 #include "wadfile.h" | |
37 | |
38 | |
39 | |
40 /* | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
41 * Lump_dir::Lump_dir - ctor |
0 | 42 * |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
43 * <md> is a pointer to the master directory on which the |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
44 * lump directory is based. |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
45 * <l> is the first character of the label. |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
46 * <sn> is a pointer to the Serial_num of the master |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
47 * directory. |
0 | 48 */ |
49 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
50 Lump_dir::Lump_dir(MDirPtr * md, char l, Serial_num * sn) |
0 | 51 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
52 have_prev = false; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
53 dependency = new Dependency(sn); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
54 master_dir = md; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
55 label = l; |
0 | 56 } |
57 | |
58 | |
59 /* | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
60 * Lump_dir::~Lump_dir - dtor |
0 | 61 */ |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
62 Lump_dir::~Lump_dir() |
0 | 63 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
64 if (dependency) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
65 delete dependency; |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
66 if (!lump_map.empty()) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
67 lump_map.clear(); |
0 | 68 } |
69 | |
70 | |
71 /* | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
72 * Lump_dir::loc_by_name - find a lump by name |
0 | 73 * |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
74 * Return the (wad, offset, length) location of the lump |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
75 * named <name>. If not found, set loc.wad to 0. |
0 | 76 */ |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
77 void Lump_dir::loc_by_name(const char *name, Lump_loc & loc) |
0 | 78 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
79 if (dependency->outdated()) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
80 refresh(); |
0 | 81 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
82 /* Caller asked for same lump twice in a row. Save us a second |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
83 search. */ |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
84 if (have_prev && !y_strnicmp(name, name_prev, WAD_NAME)) |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
85 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
86 loc = loc_prev; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
87 return; |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
88 } |
0 | 89 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
90 Lump_map::const_iterator i = lump_map.find(name); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
91 have_prev = true; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
92 if (i == lump_map.end()) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
93 loc.wad = loc_prev.wad = 0; |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
94 else |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
95 loc = loc_prev = i->second; |
0 | 96 } |
97 | |
98 | |
99 /* | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
100 * Lump_dir::list - return an array of lump names |
0 | 101 * |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
102 * Put a list of all lumps in the list, sorted by name and |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
103 * with duplicates removed, in <l>. |
0 | 104 */ |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
105 void Lump_dir::list(Lump_list & l) |
0 | 106 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
107 if (dependency->outdated()) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
108 refresh(); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
109 l.set(lump_map); |
0 | 110 } |
111 | |
112 | |
113 /* | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
114 * Lump_dir::refresh - update the lump dir. wrt to the master dir. |
0 | 115 * |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
116 * This is called automatically if the master directory has |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
117 * changed since the last refresh. |
0 | 118 */ |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
119 void Lump_dir::refresh() |
0 | 120 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
121 /* refresh() can be called more than once one the same object. |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
122 And usually is ! */ |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
123 have_prev = false; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
124 if (!lump_map.empty()) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
125 lump_map.clear(); |
0 | 126 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
127 /* Get list of lumps in the master directory. Everything |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
128 that is between X_START/X_END or XX_START/XX_END and that |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
129 is not a label is supposed to be added to the Lump_dir. */ |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
130 Wad_name_c x_start("%c_START", label); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
131 Wad_name_c x_end("%c_END", label); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
132 Wad_name_c xx_start("%c%c_START", label, label); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
133 Wad_name_c xx_end("%c%c_END", label, label); |
89
99242b34e6dc
Fix some cosmetics and warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
134 for (MDirPtr dir = *master_dir; dir && (dir = FindMasterDir(dir, x_start.name, xx_start.name));) |
0 | 135 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
136 MDirPtr start_label = dir; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
137 const char *end_label = 0; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
138 if (!x_start.cmp(dir->dir.name)) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
139 end_label = x_end.name; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
140 else if (!xx_start.cmp(dir->dir.name)) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
141 end_label = xx_end.name; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
142 else |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
143 fatal_error("Bad start label \"%.*s\"", (int) WAD_NAME, |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
144 dir->dir.name); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
145 dir = dir->next; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
146 for (;; dir = dir->next) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
147 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
148 if (!dir) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
149 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
150 warn("%.128s: no matching %s for %.*s\n", |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
151 start_label->wadfile->pathname(), |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
152 end_label, (int) WAD_NAME, start_label->dir.name); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
153 break; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
154 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
155 // Ended by X_END or, if started by XX_START, XX_END. |
89
99242b34e6dc
Fix some cosmetics and warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
156 if (!x_end.cmp(dir->dir.name) || |
99242b34e6dc
Fix some cosmetics and warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
157 (end_label == xx_end.name && !xx_end.cmp(dir->dir.name))) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
158 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
159 if (dir->dir.size != 0) |
89
99242b34e6dc
Fix some cosmetics and warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
160 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
161 warn("%.128s: label %.*s has non-zero size %ld\n", |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
162 dir->wadfile->pathname(), |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
163 (int) WAD_NAME, dir->dir.name, (long) dir->dir.size); |
89
99242b34e6dc
Fix some cosmetics and warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
164 } |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
165 dir = dir->next; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
166 break; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
167 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
168 // Ignore inner labels (X[123]_START, X[123]_END) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
169 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
|
170 { |
93 | 171 if (!(toupper(dir->dir.name[0]) == label && |
172 (dir->dir.name[1] == '1' || dir->dir.name[1] == '2' || dir->dir.name[1] == '3') | |
173 && dir->dir.name[2] == '_' && | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
174 (!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
|
175 || !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
|
176 WAD_NAME - 3)))) |
89
99242b34e6dc
Fix some cosmetics and warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
177 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
178 warn("%.128s: unexpected label \"%.*s\" in %s group\n", |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
179 dir->wadfile->pathname(), (int) WAD_NAME, |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
180 dir->dir.name, start_label->dir.name); |
89
99242b34e6dc
Fix some cosmetics and warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
181 } |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
182 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
183 } |
89
99242b34e6dc
Fix some cosmetics and warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
184 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
185 wad_flat_name_t name; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
186 memcpy(name, dir->dir.name, sizeof name); |
89
99242b34e6dc
Fix some cosmetics and warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
187 lump_map[name] = Lump_loc(dir->wadfile, dir->dir.start, dir->dir.size); |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
188 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
189 if (dir) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
190 dir = dir->next; |
0 | 191 } |
192 #ifdef DEBUG | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
193 for (Lump_lumps_map::const_iterator i = lump_map.begin(); |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
194 i != lump_map.end(); i++) |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
195 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
196 printf("%-8.8s %p %08lX %ld\n", |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
197 i->first._name, i->second.wad, i->second.ofs, i->second.len); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
198 } |
0 | 199 #endif |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
200 dependency->update(); |
0 | 201 } |
202 | |
203 | |
204 /*-------------------------- Lump_list --------------------------*/ | |
205 | |
206 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
207 Lump_list::Lump_list() |
0 | 208 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
209 array = 0; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
210 nelements = 0; |
0 | 211 } |
212 | |
213 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
214 Lump_list::~Lump_list() |
0 | 215 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
216 clear(); |
0 | 217 } |
218 | |
219 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
220 void Lump_list::set(Lump_map & lump_map) |
0 | 221 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
222 clear(); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
223 nelements = lump_map.size(); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
224 array = new char *[nelements]; |
0 | 225 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
226 Lump_map::const_iterator i = lump_map.begin(); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
227 for (size_t n = 0; n < nelements; n++) |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
228 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
229 array[n] = new char[WAD_NAME + 1]; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
230 *array[n] = '\0'; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
231 strncat(array[n], i++->first.name, WAD_NAME); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
232 } |
0 | 233 } |
234 | |
235 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
236 void Lump_list::clear() |
0 | 237 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
238 if (array != 0) |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
239 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
240 for (size_t n = 0; n < nelements; n++) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
241 delete[]array[n]; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
242 delete[]array; |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
243 } |
0 | 244 } |
245 | |
246 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
247 const char **Lump_list::data() |
0 | 248 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
249 return (const char **) array; |
0 | 250 } |
251 | |
252 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
253 size_t Lump_list::size() |
0 | 254 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
255 return nelements; |
0 | 256 } |
257 | |
258 | |
259 /*------------------------- Lump_map_key -------------------------*/ | |
260 | |
261 | |
262 //Lump_map_key::Lump_map_key (const char *name) | |
263 //{ | |
264 // memcpy (_name, name, sizeof _name); | |
265 //} | |
266 | |
267 | |
268 /*------------------------ Lump_map_less -------------------------*/ | |
269 | |
270 | |
271 bool Lump_map_less::operator () | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
272 (const Wad_name & name1, const Wad_name & name2) |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
273 const |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
274 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
275 return name1.less(name2); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
276 //return y_strnicmp ((const char *) &p1, (const char *) &p2, WAD_NAME) < 0; |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
277 } |