Debian Codegraph @

manage/soundpage.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/manage/soundpage.cpp $
21 * $Revision: 23 $
22 * $Date: 10/08/01 4:20p $
23 * $Author: Matt $
24 *
25 *
26 * $Log: /DescentIII/Main/manage/soundpage.cpp $
27 *
28 * 23 10/08/01 4:20p Matt
29 * Added system to check for errors when reading in add-on data.
30 *
31 * 21 10/26/99 3:31p Jeff
32 * handle extra.gam addon tablefile
33 *
34 * 20 9/18/99 8:49p Jeff
35 * fixed bug with addon pages that have dependencies on other pages in the
36 * addon tablefile
37 *
38 * 19 8/11/99 5:32p Jeff
39 * changes to fix addon tablefile support so it works correctly
40 *
41 * 18 7/28/99 2:24p Kevin
42 * Macintosh Fixes!
43 *
44 * 17 4/19/99 7:37p 3dsmax
45 * more demo explosion fixes
46 *
47 * 16 4/19/99 5:42p Jason
48 * fixes for explosions in the demo
49 *
50 * 15 4/14/99 1:34a Jeff
51 * fixed case mismatched #includes
52 *
53 * 14 3/04/99 4:47p Jason
54 * temp fix (ie BAD HACK) for OEM table file woes
55 *
56 * 13 1/13/99 7:05a Jeff
57 * put #ifdef around #include <windows.h>
58 *
59 * 12 12/29/98 4:30p Jason
60 * added add-on data functionality
61 *
62 * 11 11/06/98 12:35p Jason
63 * more speedups for manage system
64 *
65 * 10 11/05/98 7:55p Jason
66 * changes for new manage system
67 *
68 * 9 11/02/98 6:02p Jason
69 * made yes network updates much faster
70 *
71 * 8 10/19/98 11:57a Chris
72 * Update the sound system to use the import volume
73 *
74 * 7 10/09/98 2:27p Jason
75 * reorganized table file system
76 *
77 * 6 10/08/98 10:03p Jason
78 * more filtered table file stuff
79 *
80 * 5 8/24/98 2:37p Jason
81 * made table file more efficient with regards to invalid names
82 *
83 * 4 6/12/98 1:06p Jason
84 * added smart loading from local table file
85 *
86 * 3 2/23/98 1:22p Jason
87 * made FindSpecific* read from the local drive, not the net drive - when
88 * starting the editor
89 *
90 * 2 1/15/98 6:22p Jason
91 * added safety checks so the network won't copy over a primitive you have
92 * held locally
93 *
94 * 7 5/08/97 12:41p Jason
95 * made manage system work with device dependant path names
96 *
97 * 6 4/29/97 7:26a Chris
98 * Improved the sound code. It is healthy.
99 *
100 * 5 4/25/97 6:16p Jason
101 * added switcheroo function
102 *
103 * 4 4/22/97 3:24p Jason
104 * added more code for recursive page loading
105 *
106 * 3 4/08/97 2:25a Chris
107 * Fixed a problem with uninitialized data. In addition it
108 * fixed a problem with the .used flag that would happen
109 * 1 out of 2^(sizeof(used_flag)) times (it would be zero
110 * when it was supposed to be non-zero)
111 *
112 * 2 4/01/97 2:13p Jason
113 * changes for sound page functionality
114 *
115 * 1 4/01/97 1:48p Jason
116 *
117 *
118 * $NoKeywords: $
119 */
120
121 #include <cstring>
122 #include <filesystem>
123
124 #include "cfile.h"cxx . . $ `<file>/cfile/cfile.h`/
125 #include "manage.h"cxx . . $ `<file>/lib/manage.h`/
126 #include "soundpage.h"cxx . . $ `<file>/manage/soundpage.h`/
127 #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/
128 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
129 #include "soundload.h"cxx . . $ `<file>/sndlib/soundload.h`/
130 #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/
131 #include "args.h"cxx . . $ `<file>/Descent3/args.h`/
132
133 // soundpage commands that are read/written
134 // A command is followed by a byte count describing how many bytes
135 // are in the data for the command
136 #define SOUNDPAGE_COMMAND_NAMEcxx . . $ `manage/soundpage.cpp:136:9`! 1
137 #define SOUNDPAGE_COMMAND_ENDcxx . . $ `manage/soundpage.cpp:137:9`! 2
138 #define SOUNDPAGE_COMMAND_RAW_NAMEcxx . . $ `manage/soundpage.cpp:138:9`! 3
139 #define SOUNDPAGE_COMMAND_VERSIONcxx . . $ `manage/soundpage.cpp:139:9`! 4
140 #define SOUNDPAGE_COMMAND_FLAGScxx . . $ `manage/soundpage.cpp:140:9`! 5
141 #define SOUNDPAGE_COMMAND_INNER_CONE_ANGLEcxx . . $ `manage/soundpage.cpp:141:9`! 6
142 #define SOUNDPAGE_COMMAND_OUTER_CONE_ANGLEcxx . . $ `manage/soundpage.cpp:142:9`! 7
143 #define SOUNDPAGE_COMMAND_OUTER_CONE_VOLUMEcxx . . $ `manage/soundpage.cpp:143:9`! 8
144 #define SOUNDPAGE_COMMAND_MAX_DISTcxx . . $ `manage/soundpage.cpp:144:9`! 9
145 #define SOUNDPAGE_COMMAND_MIN_DISTcxx . . $ `manage/soundpage.cpp:145:9`! 10
146 #define SOUNDPAGE_COMMAND_LOOP_STARTcxx . . $ `manage/soundpage.cpp:146:9`! 11
147 #define SOUNDPAGE_COMMAND_LOOP_ENDcxx . . $ `manage/soundpage.cpp:147:9`! 12
148 #define SOUNDPAGE_COMMAND_IMPORT_VOLUMEcxx . . $ `manage/soundpage.cpp:148:9`! 13
149 #define SOUNDPAGE_VERSIONcxx . . $ `manage/soundpage.cpp:149:9`! 1
150
151 extern char *TablefileNameOverridecxx . . $ TablefileNameOverride.;
152
153 // Given an open file pointer and a sound_page struct, writes that sound page out
154 void mng_WriteSoundPagecxx . . $ mng_WriteSoundPage(43d39fc2bcaa809).(CFILEcxx . . $ CFILE# *outfile, mngs_sound_pagecxx . . $ mngs_sound_page# *soundpage) {
155 int i;
156 ASSERTcxx . . $ `misc/pserror.h:246:9`!(outfile != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
157 ASSERTcxx . . $ `misc/pserror.h:246:9`!(soundpage != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
158
159 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`!);
160
161 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, SOUNDPAGE_COMMAND_NAMEcxx . . $ `manage/soundpage.cpp:136:9`!); // write out sound name
162 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!);
163 for (i = 0; i < PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!; i++)
164 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name.[i]);
165 // Write out its rawfile name
166 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, SOUNDPAGE_COMMAND_RAW_NAMEcxx . . $ `manage/soundpage.cpp:138:9`!); // get ready to write out name
167 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!);
168 for (i = 0; i < PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!; i++)
169 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, soundpage->raw_namecxx . . $ mngs_sound_page#raw_name.[i]);
170
171 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, SOUNDPAGE_COMMAND_FLAGScxx . . $ `manage/soundpage.cpp:140:9`!);
172 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, 4);
173 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..flagscxx . . $ sound_info#flags.);
174 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, SOUNDPAGE_COMMAND_LOOP_STARTcxx . . $ `manage/soundpage.cpp:146:9`!);
175 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, 4);
176 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..loop_startcxx . . $ sound_info#loop_start.);
177 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, SOUNDPAGE_COMMAND_LOOP_ENDcxx . . $ `manage/soundpage.cpp:147:9`!);
178 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, 4);
179 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..loop_endcxx . . $ sound_info#loop_end.);
180 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, SOUNDPAGE_COMMAND_OUTER_CONE_VOLUMEcxx . . $ `manage/soundpage.cpp:143:9`!);
181 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, 4);
182 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..outer_cone_volumecxx . . $ sound_info#outer_cone_volume.);
183 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, SOUNDPAGE_COMMAND_INNER_CONE_ANGLEcxx . . $ `manage/soundpage.cpp:141:9`!);
184 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, 4);
185 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..inner_cone_anglecxx . . $ sound_info#inner_cone_angle.);
186 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, SOUNDPAGE_COMMAND_OUTER_CONE_ANGLEcxx . . $ `manage/soundpage.cpp:142:9`!);
187 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, 4);
188 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..outer_cone_anglecxx . . $ sound_info#outer_cone_angle.);
189 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, SOUNDPAGE_COMMAND_MAX_DISTcxx . . $ `manage/soundpage.cpp:144:9`!);
190 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, 4);
191 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..max_distancecxx . . $ sound_info#max_distance.);
192 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, SOUNDPAGE_COMMAND_MIN_DISTcxx . . $ `manage/soundpage.cpp:145:9`!);
193 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, 4);
194 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..min_distancecxx . . $ sound_info#min_distance.);
195 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, SOUNDPAGE_COMMAND_IMPORT_VOLUMEcxx . . $ `manage/soundpage.cpp:148:9`!);
196 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, 4);
197 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..import_volumecxx . . $ sound_info#import_volume.);
198 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, SOUNDPAGE_COMMAND_ENDcxx . . $ `manage/soundpage.cpp:137:9`!); // we're all done
199 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, 0);
200 }
201 // Given an open file pointer and a sound_page struct, writes that sound page out
202 void mng_WriteNewSoundPagecxx . . $ mng_WriteNewSoundPage(43d39fc2bcaa809).(CFILEcxx . . $ CFILE# *outfile, mngs_sound_pagecxx . . $ mngs_sound_page# *soundpage) {
203 ASSERTcxx . . $ `misc/pserror.h:246:9`!(outfile != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
204 ASSERTcxx . . $ `misc/pserror.h:246:9`!(soundpage != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
205
206 int offset = StartManagePagecxx . . $ StartManagePage(d1801a78c3072b68).(outfile, PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`!);
207 cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(outfile, SOUNDPAGE_VERSIONcxx . . $ `manage/soundpage.cpp:149:9`!);
208 // Write out name,rawfile name
209 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name.);
210 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(outfile, soundpage->raw_namecxx . . $ mngs_sound_page#raw_name.);
211 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..flagscxx . . $ sound_info#flags.);
212 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..loop_startcxx . . $ sound_info#loop_start.);
213 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..loop_endcxx . . $ sound_info#loop_end.);
214 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..outer_cone_volumecxx . . $ sound_info#outer_cone_volume.);
215 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..inner_cone_anglecxx . . $ sound_info#inner_cone_angle.);
216 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..outer_cone_anglecxx . . $ sound_info#outer_cone_angle.);
217 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..max_distancecxx . . $ sound_info#max_distance.);
218 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..min_distancecxx . . $ sound_info#min_distance.);
219 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(outfile, soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..import_volumecxx . . $ sound_info#import_volume.);
220 EndManagePagecxx . . $ EndManagePage(966989f25543eb13).(outfile, offset);
221 }
222 // Reads a sound page from an open file. Returns 0 on error.
223 int mng_ReadNewSoundPagecxx . . $ mng_ReadNewSoundPage(155713602bc6d21).(CFILEcxx . . $ CFILE# *infile, mngs_sound_pagecxx . . $ mngs_sound_page# *soundpage) {
224 ASSERTcxx . . $ `misc/pserror.h:246:9`!(infile != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
225 int version = cf_ReadShortcxx . . $ cf_ReadShort(30b00389b433b379).(infile);
226 // read in name,rawfile name
227 cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name., PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!, infile);
228 cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(soundpage->raw_namecxx . . $ mngs_sound_page#raw_name., PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!, infile);
229 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..flagscxx . . $ sound_info#flags. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
230
231 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..loop_startcxx . . $ sound_info#loop_start. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
232 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..loop_endcxx . . $ sound_info#loop_end. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
233 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..outer_cone_volumecxx . . $ sound_info#outer_cone_volume. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
234 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..inner_cone_anglecxx . . $ sound_info#inner_cone_angle. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
235 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..outer_cone_anglecxx . . $ sound_info#outer_cone_angle. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
236 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..max_distancecxx . . $ sound_info#max_distance. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
237 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..min_distancecxx . . $ sound_info#min_distance. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
238 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..import_volumecxx . . $ sound_info#import_volume. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
239 #ifdef DEMO
240 if (!stricmp("DefaultBuildingExplode", soundpage->sound_struct.name)) {
241 soundpage->sound_struct.import_volume = 1.0;
242 soundpage->sound_struct.flags &= ~(SPF_OBJ_UPDATE | SPF_FIXED_FREQ);
243 }
244 if (!stricmp("DefaultRobotExplode1", soundpage->sound_struct.name)) {
245 soundpage->sound_struct.import_volume = 1.0;
246 soundpage->sound_struct.flags &= ~(SPF_OBJ_UPDATE | SPF_FIXED_FREQ);
247 }
248 if (!stricmp("DefaultRobotExplode2", soundpage->sound_struct.name)) {
249 soundpage->sound_struct.import_volume = 1.0;
250 soundpage->sound_struct.flags &= ~(SPF_OBJ_UPDATE | SPF_FIXED_FREQ);
251 }
252 #endif
253 // This is a valid new page
254 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..usedcxx . . $ sound_info#used. = 1;
255 return 1; // successfully read
256 }
257 // Reads a sound page from an open file. Returns 0 on error.
258 int mng_ReadSoundPagecxx . . $ mng_ReadSoundPage(155713602bc6d21).(CFILEcxx . . $ CFILE# *infile, mngs_sound_pagecxx . . $ mngs_sound_page# *soundpage) {
259 int done = 0;
260 char command;
261 uint8_tcxx . . $ uint8_t# len;
262 int i;
263 if (!Old_table_methodcxx . . $ Old_table_method.)
264 return mng_ReadNewSoundPagecxx . . $ mng_ReadNewSoundPage(155713602bc6d21).(infile, soundpage);
265 ASSERTcxx . . $ `misc/pserror.h:246:9`!(infile != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
266 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..import_volumecxx . . $ sound_info#import_volume. = 1.0f;
267 while (!done) {
268 // Read in command byte then read in the length of that commands data
269
270 command = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile);
271 len = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile);
272 switch (command) {
273 case SOUNDPAGE_COMMAND_ENDcxx . . $ `manage/soundpage.cpp:137:9`!:
274 done = 1;
275 break;
276 case SOUNDPAGE_COMMAND_RAW_NAMEcxx . . $ `manage/soundpage.cpp:138:9`!: // the name of the sound sample
277 for (i = 0; i < PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!; i++)
278 soundpage->raw_namecxx . . $ mngs_sound_page#raw_name.[i] = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile);
279 break;
280 case SOUNDPAGE_COMMAND_NAMEcxx . . $ `manage/soundpage.cpp:136:9`!:
281 for (i = 0; i < PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!; i++)
282 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name.[i] = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile);
283 break;
284 case SOUNDPAGE_COMMAND_FLAGScxx . . $ `manage/soundpage.cpp:140:9`!:
285 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..flagscxx . . $ sound_info#flags. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
286 break;
287 case SOUNDPAGE_COMMAND_LOOP_STARTcxx . . $ `manage/soundpage.cpp:146:9`!:
288 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..loop_startcxx . . $ sound_info#loop_start. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
289 break;
290 case SOUNDPAGE_COMMAND_LOOP_ENDcxx . . $ `manage/soundpage.cpp:147:9`!:
291 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..loop_endcxx . . $ sound_info#loop_end. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
292 break;
293 case SOUNDPAGE_COMMAND_OUTER_CONE_VOLUMEcxx . . $ `manage/soundpage.cpp:143:9`!:
294 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..outer_cone_volumecxx . . $ sound_info#outer_cone_volume. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
295 break;
296 case SOUNDPAGE_COMMAND_INNER_CONE_ANGLEcxx . . $ `manage/soundpage.cpp:141:9`!:
297 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..inner_cone_anglecxx . . $ sound_info#inner_cone_angle. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
298 break;
299 case SOUNDPAGE_COMMAND_OUTER_CONE_ANGLEcxx . . $ `manage/soundpage.cpp:142:9`!:
300 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..outer_cone_anglecxx . . $ sound_info#outer_cone_angle. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
301 break;
302 case SOUNDPAGE_COMMAND_MAX_DISTcxx . . $ `manage/soundpage.cpp:144:9`!:
303 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..max_distancecxx . . $ sound_info#max_distance. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
304 break;
305 case SOUNDPAGE_COMMAND_MIN_DISTcxx . . $ `manage/soundpage.cpp:145:9`!:
306 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..min_distancecxx . . $ sound_info#min_distance. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
307 break;
308 case SOUNDPAGE_COMMAND_IMPORT_VOLUMEcxx . . $ `manage/soundpage.cpp:148:9`!:
309 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..import_volumecxx . . $ sound_info#import_volume. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
310 break;
311 default:
312 // Ignore the ones we don't know
313 for (i = 0; i < len; i++)
314 cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile);
315 break;
316 }
317 }
318 // This is a valid new page
319 soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..usedcxx . . $ sound_info#used. = 1;
320 return 1; // successfully read
321 }
322 // Reads in the sound named "name" into soundpage struct
323 // Returns 0 on error or couldn't find, else 1 if all is good
324 int mng_FindSpecificSoundPagecxx . . $ mng_FindSpecificSoundPage(c64564f188fd7954).(char *name, mngs_sound_pagecxx . . $ mngs_sound_page# *soundpage, int offset) {
325 CFILEcxx . . $ CFILE# *infile;
326 uint8_tcxx . . $ uint8_t# pagetype;
327 int done = 0, found = 0;
328 stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# tablenamecxx . . $ std/filesystem/__cxx11/path#path(ced63f7c635d850d).;
329 if (Loading_localscxx . . $ Loading_locals.) {
330 infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(LocalTableFilenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "rb");
331 } else if (Loading_addon_tablecxx . . $ Loading_addon_table. != -1) {
332 infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(AddOnDataTablescxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).[Loading_addon_tablecxx . . $ Loading_addon_table.].AddOnTableFilenamecxx . . $ AddOnTablefile#AddOnTableFilename., "rb");
333 } else {
334 if (Network_upcxx . . $ Network_up. && Starting_editorcxx . . $ Starting_editor.) {
335 int farg = FindArgcxx . . $ FindArg(5c4306d8553b3696).("-filter");
336 if (farg)
337 tablename =cxx . . $ std/filesystem/__cxx11/path#`operator=`(d30197541d75bb9a). GameArgscxx . . $ GameArgs.[farg + 1];
338 else
339 tablename =cxx . . $ std/filesystem/__cxx11/path#`operator=`(9c9aa2f17f237d0f). LocalTableDircxx . . $ LocalTableDir. /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). NET_TABLEcxx . . $ `lib/manage.h:36:9`!;
340 infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(tablename, "rb");
341 } else {
342 infile = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
343 if (TablefileNameOverridecxx . . $ TablefileNameOverride.) {
344 infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(TablefileNameOverridecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "rb");
345 }
346
347 if (!infile)
348 infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(TableFilenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "rb");
349 }
350 }
351 if (!infile) {
352 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Couldn't open table file to find sound!\n");
353 Int3cxx . . $ `misc/pserror.h:247:9`!();
354 return 0;
355 }
356 if (offset)
357 cfseekcxx . . $ cfseek(f9992d249f032805).(infile, offset, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!);
358
359 // Read in the entire page file until we find the page we want
360 while (!done) {
361 if (cfeofcxx . . $ cfeof(413716a422df0036).(infile)) {
362 done = 1;
363 continue;
364 }
365 pagetype = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile);
366 int len = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
367 // If not a sound page, just read it in and ignore it
368 if (pagetype != PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`!) {
369 cfseekcxx . . $ cfseek(f9992d249f032805).(infile, len - 4, SEEK_CURcxx . . $ `<external>/232824719582829767/stdio.h:111:9`!);
370 continue;
371 }
372 mng_ReadNewSoundPagecxx . . $ mng_ReadNewSoundPage(155713602bc6d21).(infile, soundpage);
373
374 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(name, soundpage->sound_struct.name)) {
375 // This is the page we want
376 found = 1;
377 done = 1;
378 }
379 }
380 cfclosecxx . . $ cfclose(3639e799710acb68).(infile);
381
382 return found; // successful!
383 }
384 // Given a sound page, allocs a sound and calls AssignSoundPageToSound to actually
385 // load raws and values. Rturns sound handle on success, -1 if fail
386 int mng_SetAndLoadSoundcxx . . $ mng_SetAndLoadSound(f26746c9e0ec0a6e).(mngs_sound_pagecxx . . $ mngs_sound_page# *soundpage) {
387 int n;
388
389 n = AllocSoundcxx . . $ AllocSound(b126dc7c1de90089).();
390 if (n < 0)
391 return -1;
392 if (!mng_AssignSoundPageToSoundcxx . . $ mng_AssignSoundPageToSound(cdeba9935b75dec1).(soundpage, n))
393 return -1;
394
395 return n;
396 }
397 // Given a soundpage and a sound handle, attempts to make sound n correspond to
398 // to the soundpage.
399 // Returns 1 on success, 0 otherwise
400 int mng_AssignSoundPageToSoundcxx . . $ mng_AssignSoundPageToSound(cdeba9935b75dec1).(mngs_sound_pagecxx . . $ mngs_sound_page# *soundpage, int n) {
401 sound_infocxx . . $ sound_info# *soundpointer = &Soundscxx . . $ Sounds.[n];
402 int raw_handle;
403 // copy our values
404 memcpy(soundpointer, &soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct., sizeof(sound_infocxx . . $ sound_info#));
405 strcpy(soundpointer->namecxx . . $ sound_info#name., soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name.);
406 // First see if our raw differs from the one on the net
407 // If it is, make a copy
408 // If its a release version, don't do any of this
409 #ifndef RELEASE
410 if (Network_upcxx . . $ Network_up.) {
411 UpdatePrimitivecxx . . $ UpdatePrimitive(563e7f6fc320b4cb).(LocalSoundsDircxx . . $ LocalSoundsDir. /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). soundpagecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).->raw_namecxx . . $ mngs_sound_page#raw_name., NetSoundsDircxx . . $ NetSoundsDir. /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). soundpagecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).->raw_namecxx . . $ mngs_sound_page#raw_name., soundpage->raw_namecxx . . $ mngs_sound_page#raw_name.,
412 PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`!, soundpointer->namecxx . . $ sound_info#name.);
413 }
414 #endif
415 // Try and load our sound raw from the disk
416 raw_handle = LoadSoundFilecxx . . $ LoadSoundFile(e629f44b83d433dc).(soundpage->raw_namecxx . . $ mngs_sound_page#raw_name., Soundscxx . . $ Sounds.[n].import_volumecxx . . $ sound_info#import_volume., false);
417 if (raw_handle < 0) {
418 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Couldn't load file '%s' in AssignSoundPage...\n", soundpage->raw_name);
419 soundpointer->sample_indexcxx . . $ sound_info#sample_index. = -1;
420 return 0;
421 } else
422 soundpointer->sample_indexcxx . . $ sound_info#sample_index. = raw_handle;
423 return 1;
424 }
425 // Copies values from a sound into a sound_page
426 void mng_AssignSoundToSoundPagecxx . . $ mng_AssignSoundToSoundPage(c2846f5ad1cf7394).(int n, mngs_sound_pagecxx . . $ mngs_sound_page# *soundpage) {
427 sound_infocxx . . $ sound_info# *soundpointer = &Soundscxx . . $ Sounds.[n];
428 // Assign the values
429 memcpy(&soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct., soundpointer, sizeof(sound_infocxx . . $ sound_info#));
430
431 strcpy(soundpage->sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name., soundpointer->namecxx . . $ sound_info#name.);
432 if (soundpointer->sample_indexcxx . . $ sound_info#sample_index. != -1)
433 strcpy(soundpage->raw_namecxx . . $ mngs_sound_page#raw_name., SoundFilescxx . . $ SoundFiles.[soundpointer->sample_indexcxx . . $ sound_info#sample_index.].namecxx . . $ sound_file_info#name.);
434 else
435 strcpy(soundpage->raw_namecxx . . $ mngs_sound_page#raw_name., "");
436 }
437 // Loads a sound found in the net table file. It then allocs a sound and
438 // then calls SetAndLoadSound to actually load in any raws associated
439 // with it
440 void mng_LoadNetSoundPagecxx . . $ mng_LoadNetSoundPage(5a5441f2f69caf20).(CFILEcxx . . $ CFILE# *infile, bool overlay) {
441 mngs_sound_pagecxx . . $ mngs_sound_page# soundpage;
442 memset(&soundpage, 0, sizeof(mngs_sound_pagecxx . . $ mngs_sound_page#));
443
444 if (mng_ReadNewSoundPagecxx . . $ mng_ReadNewSoundPage(155713602bc6d21).(infile, &soundpage)) {
445 int n = FindSoundNamecxx . . $ FindSoundName(5c4306d8553b3696).(soundpage.sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name.);
446 if (n != -1) {
447 if (overlay) {
448 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OVERLAYING SOUND %s\n", soundpage.sound_struct.name);
449 mng_FreePagetypePrimitivescxx . . $ mng_FreePagetypePrimitives(99469d7ff9a1485a).(PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`!, soundpage.sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name., 0);
450 mng_AssignSoundPageToSoundcxx . . $ mng_AssignSoundPageToSound(cdeba9935b75dec1).(&soundpage, n);
451 }
452 return; // already in memory
453 }
454 int ret = mng_SetAndLoadSoundcxx . . $ mng_SetAndLoadSound(f26746c9e0ec0a6e).(&soundpage);
455 ASSERTcxx . . $ `misc/pserror.h:246:9`!(ret >= 0);
456 } else
457 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Could not load soundpage named %s!\n", soundpage.sound_struct.name);
458 }
459 // Reads a sound page from a local table file. It then allocs a sound and
460 // loads any raws associated with that sound
461 void mng_LoadLocalSoundPagecxx . . $ mng_LoadLocalSoundPage(3639e799710acb68).(CFILEcxx . . $ CFILE# *infile) {
462 mngs_sound_pagecxx . . $ mngs_sound_page# soundpage;
463 int ok = 0;
464 memset(&soundpage, 0, sizeof(mngs_sound_pagecxx . . $ mngs_sound_page#));
465 if (mng_ReadNewSoundPagecxx . . $ mng_ReadNewSoundPage(155713602bc6d21).(infile, &soundpage)) {
466 // Check to see if this is a local copy that is supposed
467 // to go over a network copy (supersede the net copy)
468 int i = FindSoundNamecxx . . $ FindSoundName(5c4306d8553b3696).(soundpage.sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name.);
469 if (i != -1) {
470 // Make sure we really have this page checked out
471 mngs_Pagelockcxx . . $ mngs_Pagelock# pl;
472
473 strcpy(pl.namecxx . . $ mngs_Pagelock#name., soundpage.sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name.);
474 pl.pagetypecxx . . $ mngs_Pagelock#pagetype. = PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`!;
475
476 /*if (Network_up && Stand_alone==0)
477 {
478 int locked=mng_CheckIfPageOwned(&pl,TableUser);
479 if (locked!=1)
480 Int3(); // Your local vs net copies of the lock file do not match
481 }*/
482
483 ok = 1;
484 bool need_to_load_page = true;
485
486 if (Loading_addon_tablecxx . . $ Loading_addon_table. != -1) {
487 AddOnTablefilecxx . . $ AddOnTablefile# *addon;
488 int tidx;
489
490 // see if we really need to load this page
491 // check to see if we already have loaded this page (because it was
492 // a dependancy of another)
493 addon = &AddOnDataTablescxx . . $ AddOnDataTables.[Loading_addon_tablecxx . . $ Loading_addon_table.];
494 for (tidx = 0; tidx < addon->Num_addon_tracklockscxx . . $ AddOnTablefile#Num_addon_tracklocks.; tidx++) {
495 if (addon->Addon_tracklockscxx . . $ AddOnTablefile#Addon_tracklocks.[tidx].pagetypecxx . . $ mngs_track_lock#pagetype. == PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`! &&
496 !stricmpcxx . . $ `linux/linux_fix.h:43:9`!(addon->Addon_tracklocks[tidx].name, soundpage.sound_struct.name)) {
497 // found it!!
498 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "SoundPage: %s previously loaded\n", soundpage.sound_struct.name);
499 need_to_load_page = false;
500 break;
501 }
502 }
503 }
504
505 if (need_to_load_page) {
506 mng_FreePagetypePrimitivescxx . . $ mng_FreePagetypePrimitives(99469d7ff9a1485a).(PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`!, soundpage.sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name., 0);
507 mng_AssignSoundPageToSoundcxx . . $ mng_AssignSoundPageToSound(cdeba9935b75dec1).(&soundpage, i);
508
509 // For addon data
510 if (Loading_addon_tablecxx . . $ Loading_addon_table. != -1) {
511 int overlay = 1;
512 int addidx, tidx;
513 bool found = false;
514 AddOnTablefilecxx . . $ AddOnTablefile# *addon;
515
516 // this is an overlay of some sort..see which we are overlaying
517 for (addidx = Num_addon_tablescxx . . $ Num_addon_tables. - 1; addidx >= 0; addidx--) {
518 if (addidx == Loading_addon_tablecxx . . $ Loading_addon_table.)
519 continue;
520 addon = &AddOnDataTablescxx . . $ AddOnDataTables.[addidx];
521
522 // look for the page in this table file
523 for (tidx = 0; tidx < addon->Num_addon_tracklockscxx . . $ AddOnTablefile#Num_addon_tracklocks.; tidx++) {
524 if (addon->Addon_tracklockscxx . . $ AddOnTablefile#Addon_tracklocks.[tidx].pagetypecxx . . $ mngs_track_lock#pagetype. == PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`! &&
525 !stricmpcxx . . $ `linux/linux_fix.h:43:9`!(addon->Addon_tracklocks[tidx].name, soundpage.sound_struct.name)) {
526 // found it!!
527 found = true;
528 overlay = addidx + 2;
529 break;
530 }
531 }
532
533 if (found)
534 break;
535 }
536
537 mng_PushAddonPagecxx . . $ mng_PushAddonPage(99469d7ff9a1485a).(PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`!, soundpage.sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name., overlay);
538 }
539 }
540 } else {
541 // This is a local sound that has never been checked in
542 if ((i = mng_SetAndLoadSoundcxx . . $ mng_SetAndLoadSound(f26746c9e0ec0a6e).(&soundpage)) < 0)
543 ok = 0;
544 else
545 ok = 1;
546 // For addon data
547 if (ok && Loading_addon_tablecxx . . $ Loading_addon_table. != -1)
548 mng_PushAddonPagecxx . . $ mng_PushAddonPage(99469d7ff9a1485a).(PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`!, soundpage.sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name., 0);
549 }
550
551 ASSERTcxx . . $ `misc/pserror.h:246:9`!(ok == 1);
552 if (Loading_addon_tablecxx . . $ Loading_addon_table. == -1)
553 mng_AllocTrackLockcxx . . $ mng_AllocTrackLock(6abd07ddb1a912f0).(soundpage.sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name., PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`!);
554 } else
555 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Could not load soundpage named %s!\n", soundpage.sound_struct.name);
556 }
557 // First searches through the sound index to see if the sound is already
558 // loaded. If not, searches in the table file and loads it.
559 // Returns index of sound found, -1 if not
560 int mng_GetGuaranteedSoundPagecxx . . $ mng_GetGuaranteedSoundPage(a1d8d01c9983cd45).(char *name, CFILEcxx . . $ CFILE# *infile) {
561 int i;
562 mngs_sound_pagecxx . . $ mngs_sound_page# soundpage;
563 // See if its in memory
564 i = FindSoundNamecxx . . $ FindSoundName(5c4306d8553b3696).(name);
565 if (i != -1)
566 return i;
567 // Not in memory. Load it from the table file. Start searching from the
568 // current spot in the open table file
569 int ret = mng_FindSpecificSoundPagecxx . . $ mng_FindSpecificSoundPage(c64564f188fd7954).(name, &soundpage, infile ? infile->positioncxx . . $ CFILE#position. : 0);
570 if (!ret)
571 return -1;
572 // We've found it in the table file, now load it.
573 ret = mng_SetAndLoadSoundcxx . . $ mng_SetAndLoadSound(f26746c9e0ec0a6e).(&soundpage);
574 // ASSERT (ret>=0);
575 if (ret < 0)
576 DataErrorcxx . . $ DataError(326aeb464d16410c).("Cannot load sound <%s>, wav file <%s>\n", soundpage.sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name., soundpage.raw_namecxx . . $ mngs_sound_page#raw_name.);
577
578 if (Loading_addon_tablecxx . . $ Loading_addon_table. != -1) {
579 // we're loading addon table pages, this will not overlay anything
580 mng_PushAddonPagecxx . . $ mng_PushAddonPage(99469d7ff9a1485a).(PAGETYPE_SOUNDcxx . . $ `lib/manage.h:55:9`!, soundpage.sound_structcxx . . $ mngs_sound_page#sound_struct..namecxx . . $ sound_info#name., 0);
581 }
582 return ret;
583 }