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"
125 #include "manage.h"
126 #include "soundpage.h"
127 #include "mono.h"
128 #include "pserror.h"
129 #include "soundload.h"
130 #include "ddio.h"
131 #include "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_NAME 1
137 #define SOUNDPAGE_COMMAND_END 2
138 #define SOUNDPAGE_COMMAND_RAW_NAME 3
139 #define SOUNDPAGE_COMMAND_VERSION 4
140 #define SOUNDPAGE_COMMAND_FLAGS 5
141 #define SOUNDPAGE_COMMAND_INNER_CONE_ANGLE 6
142 #define SOUNDPAGE_COMMAND_OUTER_CONE_ANGLE 7
143 #define SOUNDPAGE_COMMAND_OUTER_CONE_VOLUME 8
144 #define SOUNDPAGE_COMMAND_MAX_DIST 9
145 #define SOUNDPAGE_COMMAND_MIN_DIST 10
146 #define SOUNDPAGE_COMMAND_LOOP_START 11
147 #define SOUNDPAGE_COMMAND_LOOP_END 12
148 #define SOUNDPAGE_COMMAND_IMPORT_VOLUME 13
149 #define SOUNDPAGE_VERSION 1
150
151 extern char *TablefileNameOverride;
152
153 // Given an open file pointer and a sound_page struct, writes that sound page out
154 void mng_WriteSoundPage(CFILE *outfile, mngs_sound_page *soundpage) {
155 int i;
156 ASSERT(outfile != NULL);
157 ASSERT(soundpage != NULL);
158
159 cf_WriteByte(outfile, PAGETYPE_SOUND);
160
161 cf_WriteByte(outfile, SOUNDPAGE_COMMAND_NAME); // write out sound name
162 cf_WriteByte(outfile, PAGENAME_LEN);
163 for (i = 0; i < PAGENAME_LEN; i++)
164 cf_WriteByte(outfile, soundpage->sound_struct.name[i]);
165 // Write out its rawfile name
166 cf_WriteByte(outfile, SOUNDPAGE_COMMAND_RAW_NAME); // get ready to write out name
167 cf_WriteByte(outfile, PAGENAME_LEN);
168 for (i = 0; i < PAGENAME_LEN; i++)
169 cf_WriteByte(outfile, soundpage->raw_name[i]);
170
171 cf_WriteByte(outfile, SOUNDPAGE_COMMAND_FLAGS);
172 cf_WriteByte(outfile, 4);
173 cf_WriteInt(outfile, soundpage->sound_struct.flags);
174 cf_WriteByte(outfile, SOUNDPAGE_COMMAND_LOOP_START);
175 cf_WriteByte(outfile, 4);
176 cf_WriteInt(outfile, soundpage->sound_struct.loop_start);
177 cf_WriteByte(outfile, SOUNDPAGE_COMMAND_LOOP_END);
178 cf_WriteByte(outfile, 4);
179 cf_WriteInt(outfile, soundpage->sound_struct.loop_end);
180 cf_WriteByte(outfile, SOUNDPAGE_COMMAND_OUTER_CONE_VOLUME);
181 cf_WriteByte(outfile, 4);
182 cf_WriteFloat(outfile, soundpage->sound_struct.outer_cone_volume);
183 cf_WriteByte(outfile, SOUNDPAGE_COMMAND_INNER_CONE_ANGLE);
184 cf_WriteByte(outfile, 4);
185 cf_WriteInt(outfile, soundpage->sound_struct.inner_cone_angle);
186 cf_WriteByte(outfile, SOUNDPAGE_COMMAND_OUTER_CONE_ANGLE);
187 cf_WriteByte(outfile, 4);
188 cf_WriteInt(outfile, soundpage->sound_struct.outer_cone_angle);
189 cf_WriteByte(outfile, SOUNDPAGE_COMMAND_MAX_DIST);
190 cf_WriteByte(outfile, 4);
191 cf_WriteFloat(outfile, soundpage->sound_struct.max_distance);
192 cf_WriteByte(outfile, SOUNDPAGE_COMMAND_MIN_DIST);
193 cf_WriteByte(outfile, 4);
194 cf_WriteFloat(outfile, soundpage->sound_struct.min_distance);
195 cf_WriteByte(outfile, SOUNDPAGE_COMMAND_IMPORT_VOLUME);
196 cf_WriteByte(outfile, 4);
197 cf_WriteFloat(outfile, soundpage->sound_struct.import_volume);
198 cf_WriteByte(outfile, SOUNDPAGE_COMMAND_END); // we're all done
199 cf_WriteByte(outfile, 0);
200 }
201 // Given an open file pointer and a sound_page struct, writes that sound page out
202 void mng_WriteNewSoundPage(CFILE *outfile, mngs_sound_page *soundpage) {
203 ASSERT(outfile != NULL);
204 ASSERT(soundpage != NULL);
205
206 int offset = StartManagePage(outfile, PAGETYPE_SOUND);
207 cf_WriteShort(outfile, SOUNDPAGE_VERSION);
208 // Write out name,rawfile name
209 cf_WriteString(outfile, soundpage->sound_struct.name);
210 cf_WriteString(outfile, soundpage->raw_name);
211 cf_WriteInt(outfile, soundpage->sound_struct.flags);
212 cf_WriteInt(outfile, soundpage->sound_struct.loop_start);
213 cf_WriteInt(outfile, soundpage->sound_struct.loop_end);
214 cf_WriteFloat(outfile, soundpage->sound_struct.outer_cone_volume);
215 cf_WriteInt(outfile, soundpage->sound_struct.inner_cone_angle);
216 cf_WriteInt(outfile, soundpage->sound_struct.outer_cone_angle);
217 cf_WriteFloat(outfile, soundpage->sound_struct.max_distance);
218 cf_WriteFloat(outfile, soundpage->sound_struct.min_distance);
219 cf_WriteFloat(outfile, soundpage->sound_struct.import_volume);
220 EndManagePage(outfile, offset);
221 }
222 // Reads a sound page from an open file. Returns 0 on error.
223 int mng_ReadNewSoundPage(CFILE *infile, mngs_sound_page *soundpage) {
224 ASSERT(infile != NULL);
225 int version = cf_ReadShort(infile);
226 // read in name,rawfile name
227 cf_ReadString(soundpage->sound_struct.name, PAGENAME_LEN, infile);
228 cf_ReadString(soundpage->raw_name, PAGENAME_LEN, infile);
229 soundpage->sound_struct.flags = cf_ReadInt(infile);
230
231 soundpage->sound_struct.loop_start = cf_ReadInt(infile);
232 soundpage->sound_struct.loop_end = cf_ReadInt(infile);
233 soundpage->sound_struct.outer_cone_volume = cf_ReadFloat(infile);
234 soundpage->sound_struct.inner_cone_angle = cf_ReadInt(infile);
235 soundpage->sound_struct.outer_cone_angle = cf_ReadInt(infile);
236 soundpage->sound_struct.max_distance = cf_ReadFloat(infile);
237 soundpage->sound_struct.min_distance = cf_ReadFloat(infile);
238 soundpage->sound_struct.import_volume = cf_ReadFloat(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_struct.used = 1;
255 return 1; // successfully read
256 }
257 // Reads a sound page from an open file. Returns 0 on error.
258 int mng_ReadSoundPage(CFILE *infile, mngs_sound_page *soundpage) {
259 int done = 0;
260 char command;
261 uint8_t len;
262 int i;
263 if (!Old_table_method)
264 return mng_ReadNewSoundPage(infile, soundpage);
265 ASSERT(infile != NULL);
266 soundpage->sound_struct.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_ReadByte(infile);
271 len = cf_ReadByte(infile);
272 switch (command) {
273 case SOUNDPAGE_COMMAND_END:
274 done = 1;
275 break;
276 case SOUNDPAGE_COMMAND_RAW_NAME: // the name of the sound sample
277 for (i = 0; i < PAGENAME_LEN; i++)
278 soundpage->raw_name[i] = cf_ReadByte(infile);
279 break;
280 case SOUNDPAGE_COMMAND_NAME:
281 for (i = 0; i < PAGENAME_LEN; i++)
282 soundpage->sound_struct.name[i] = cf_ReadByte(infile);
283 break;
284 case SOUNDPAGE_COMMAND_FLAGS:
285 soundpage->sound_struct.flags = cf_ReadInt(infile);
286 break;
287 case SOUNDPAGE_COMMAND_LOOP_START:
288 soundpage->sound_struct.loop_start = cf_ReadInt(infile);
289 break;
290 case SOUNDPAGE_COMMAND_LOOP_END:
291 soundpage->sound_struct.loop_end = cf_ReadInt(infile);
292 break;
293 case SOUNDPAGE_COMMAND_OUTER_CONE_VOLUME:
294 soundpage->sound_struct.outer_cone_volume = cf_ReadFloat(infile);
295 break;
296 case SOUNDPAGE_COMMAND_INNER_CONE_ANGLE:
297 soundpage->sound_struct.inner_cone_angle = cf_ReadInt(infile);
298 break;
299 case SOUNDPAGE_COMMAND_OUTER_CONE_ANGLE:
300 soundpage->sound_struct.outer_cone_angle = cf_ReadInt(infile);
301 break;
302 case SOUNDPAGE_COMMAND_MAX_DIST:
303 soundpage->sound_struct.max_distance = cf_ReadFloat(infile);
304 break;
305 case SOUNDPAGE_COMMAND_MIN_DIST:
306 soundpage->sound_struct.min_distance = cf_ReadFloat(infile);
307 break;
308 case SOUNDPAGE_COMMAND_IMPORT_VOLUME:
309 soundpage->sound_struct.import_volume = cf_ReadFloat(infile);
310 break;
311 default:
312 // Ignore the ones we don't know
313 for (i = 0; i < len; i++)
314 cf_ReadByte(infile);
315 break;
316 }
317 }
318 // This is a valid new page
319 soundpage->sound_struct.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_FindSpecificSoundPage(char *name, mngs_sound_page *soundpage, int offset) {
325 CFILE *infile;
326 uint8_t pagetype;
327 int done = 0, found = 0;
328 std::filesystem::path tablename;
329 if (Loading_locals) {
330 infile = cfopen(LocalTableFilename, "rb");
331 } else if (Loading_addon_table != -1) {
332 infile = cfopen(AddOnDataTables[Loading_addon_table].AddOnTableFilename, "rb");
333 } else {
334 if (Network_up && Starting_editor) {
335 int farg = FindArg("-filter");
336 if (farg)
337 tablename = GameArgs[farg + 1];
338 else
339 tablename = LocalTableDir / NET_TABLE;
340 infile = cfopen(tablename, "rb");
341 } else {
342 infile = NULL;
343 if (TablefileNameOverride) {
344 infile = cfopen(TablefileNameOverride, "rb");
345 }
346
347 if (!infile)
348 infile = cfopen(TableFilename, "rb");
349 }
350 }
351 if (!infile) {
352 mprintf(0, "Couldn't open table file to find sound!\n");
353 Int3();
354 return 0;
355 }
356 if (offset)
357 cfseek(infile, offset, SEEK_SET);
358
359 // Read in the entire page file until we find the page we want
360 while (!done) {
361 if (cfeof(infile)) {
362 done = 1;
363 continue;
364 }
365 pagetype = cf_ReadByte(infile);
366 int len = cf_ReadInt(infile);
367 // If not a sound page, just read it in and ignore it
368 if (pagetype != PAGETYPE_SOUND) {
369 cfseek(infile, len - 4, SEEK_CUR);
370 continue;
371 }
372 mng_ReadNewSoundPage(infile, soundpage);
373
374 if (!stricmp(name, soundpage->sound_struct.name)) {
375 // This is the page we want
376 found = 1;
377 done = 1;
378 }
379 }
380 cfclose(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_SetAndLoadSound(mngs_sound_page *soundpage) {
387 int n;
388
389 n = AllocSound();
390 if (n < 0)
391 return -1;
392 if (!mng_AssignSoundPageToSound(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_AssignSoundPageToSound(mngs_sound_page *soundpage, int n) {
401 sound_info *soundpointer = &Sounds[n];
402 int raw_handle;
403 // copy our values
404 memcpy(soundpointer, &soundpage->sound_struct, sizeof(sound_info));
405 strcpy(soundpointer->name, soundpage->sound_struct.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_up) {
411 UpdatePrimitive(LocalSoundsDir / soundpage->raw_name, NetSoundsDir / soundpage->raw_name, soundpage->raw_name,
412 PAGETYPE_SOUND, soundpointer->name);
413 }
414 #endif
415 // Try and load our sound raw from the disk
416 raw_handle = LoadSoundFile(soundpage->raw_name, Sounds[n].import_volume, false);
417 if (raw_handle < 0) {
418 mprintf(0, "Couldn't load file '%s' in AssignSoundPage...\n", soundpage->raw_name);
419 soundpointer->sample_index = -1;
420 return 0;
421 } else
422 soundpointer->sample_index = raw_handle;
423 return 1;
424 }
425 // Copies values from a sound into a sound_page
426 void mng_AssignSoundToSoundPage(int n, mngs_sound_page *soundpage) {
427 sound_info *soundpointer = &Sounds[n];
428 // Assign the values
429 memcpy(&soundpage->sound_struct, soundpointer, sizeof(sound_info));
430
431 strcpy(soundpage->sound_struct.name, soundpointer->name);
432 if (soundpointer->sample_index != -1)
433 strcpy(soundpage->raw_name, SoundFiles[soundpointer->sample_index].name);
434 else
435 strcpy(soundpage->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_LoadNetSoundPage(CFILE *infile, bool overlay) {
441 mngs_sound_page soundpage;
442 memset(&soundpage, 0, sizeof(mngs_sound_page));
443
444 if (mng_ReadNewSoundPage(infile, &soundpage)) {
445 int n = FindSoundName(soundpage.sound_struct.name);
446 if (n != -1) {
447 if (overlay) {
448 mprintf(0, "OVERLAYING SOUND %s\n", soundpage.sound_struct.name);
449 mng_FreePagetypePrimitives(PAGETYPE_SOUND, soundpage.sound_struct.name, 0);
450 mng_AssignSoundPageToSound(&soundpage, n);
451 }
452 return; // already in memory
453 }
454 int ret = mng_SetAndLoadSound(&soundpage);
455 ASSERT(ret >= 0);
456 } else
457 mprintf(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_LoadLocalSoundPage(CFILE *infile) {
462 mngs_sound_page soundpage;
463 int ok = 0;
464 memset(&soundpage, 0, sizeof(mngs_sound_page));
465 if (mng_ReadNewSoundPage(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 = FindSoundName(soundpage.sound_struct.name);
469 if (i != -1) {
470 // Make sure we really have this page checked out
471 mngs_Pagelock pl;
472
473 strcpy(pl.name, soundpage.sound_struct.name);
474 pl.pagetype = PAGETYPE_SOUND;
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_table != -1) {
487 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 = &AddOnDataTables[Loading_addon_table];
494 for (tidx = 0; tidx < addon->Num_addon_tracklocks; tidx++) {
495 if (addon->Addon_tracklocks[tidx].pagetype == PAGETYPE_SOUND &&
496 !stricmp(addon->Addon_tracklocks[tidx].name, soundpage.sound_struct.name)) {
497 // found it!!
498 mprintf(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_FreePagetypePrimitives(PAGETYPE_SOUND, soundpage.sound_struct.name, 0);
507 mng_AssignSoundPageToSound(&soundpage, i);
508
509 // For addon data
510 if (Loading_addon_table != -1) {
511 int overlay = 1;
512 int addidx, tidx;
513 bool found = false;
514 AddOnTablefile *addon;
515
516 // this is an overlay of some sort..see which we are overlaying
517 for (addidx = Num_addon_tables - 1; addidx >= 0; addidx--) {
518 if (addidx == Loading_addon_table)
519 continue;
520 addon = &AddOnDataTables[addidx];
521
522 // look for the page in this table file
523 for (tidx = 0; tidx < addon->Num_addon_tracklocks; tidx++) {
524 if (addon->Addon_tracklocks[tidx].pagetype == PAGETYPE_SOUND &&
525 !stricmp(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_PushAddonPage(PAGETYPE_SOUND, soundpage.sound_struct.name, overlay);
538 }
539 }
540 } else {
541 // This is a local sound that has never been checked in
542 if ((i = mng_SetAndLoadSound(&soundpage)) < 0)
543 ok = 0;
544 else
545 ok = 1;
546 // For addon data
547 if (ok && Loading_addon_table != -1)
548 mng_PushAddonPage(PAGETYPE_SOUND, soundpage.sound_struct.name, 0);
549 }
550
551 ASSERT(ok == 1);
552 if (Loading_addon_table == -1)
553 mng_AllocTrackLock(soundpage.sound_struct.name, PAGETYPE_SOUND);
554 } else
555 mprintf(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_GetGuaranteedSoundPage(char *name, CFILE *infile) {
561 int i;
562 mngs_sound_page soundpage;
563 // See if its in memory
564 i = FindSoundName(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_FindSpecificSoundPage(name, &soundpage, infile ? infile->position : 0);
570 if (!ret)
571 return -1;
572 // We've found it in the table file, now load it.
573 ret = mng_SetAndLoadSound(&soundpage);
574 // ASSERT (ret>=0);
575 if (ret < 0)
576 DataError("Cannot load sound <%s>, wav file <%s>\n", soundpage.sound_struct.name, soundpage.raw_name);
577
578 if (Loading_addon_table != -1) {
579 // we're loading addon table pages, this will not overlay anything
580 mng_PushAddonPage(PAGETYPE_SOUND, soundpage.sound_struct.name, 0);
581 }
582 return ret;
583 }