Debian Codegraph @

prboom2/src/dsda/sndinfo.c

raw
1 //
2 // Copyright(C) 2022 by Ryan Krafnick
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // DESCRIPTION:
15 // DSDA SndInfo
16 //
17
18 #include <stddef.h>
19
20 #include "m_misc.h"
21 #include "s_sound.h"
22 #include "sc_man.h"
23 #include "sounds.h"
24
25 #include "dsda/ambient.h"
26 #include "dsda/map_format.h"
27
28 #include "sndinfo.h"
29
30 static char song_lump[99][10];
31
32 static void ReadMapSongLumpName(int map, char* lump_name) {
33 if (map < 1 || map > 98)
34 return;
35
36 M_StringCopy(song_lump[map], lump_name, sizeof(song_lump[map]));
37 }
38
39 const char* dsda_SndInfoMapSongLumpName(int map) {
40 if (map < 1 || map > 98)
41 return song_lump[0];
42
43 return song_lump[map];
44 }
45
46 void dsda_LoadSndInfo(void) {
47 int i;
48
49 if (!hexen) {
50 dsda_LoadAmbientSndInfo();
51 return;
52 }
53
54 SC_OpenLump("sndinfo");
55
56 while (SC_GetString()) {
57 if (*sc_String == '$') {
58 if (!strcasecmp(sc_String, "$ARCHIVEPATH"))
59 SC_MustGetString();
60 else if (!strcasecmp(sc_String, "$MAP")) {
61 SC_MustGetNumber();
62 SC_MustGetString();
63
64 if (sc_Number)
65 ReadMapSongLumpName(sc_Number, sc_String);
66 }
67
68 continue;
69 }
70 else {
71 for (i = 0; i < num_sfx; i++) {
72 if (!strcmp(S_sfx[i].tagname, sc_String)) {
73 SC_MustGetString();
74
75 if (*sc_String != '?')
76 S_sfx[i].name = Z_Strdup(sc_String);
77 else
78 S_sfx[i].name = Z_Strdup("default");
79
80 break;
81 }
82 }
83 if (i == num_sfx)
84 SC_MustGetString();
85 }
86 }
87
88 SC_Close();
89
90 for (i = 0; i < num_sfx; i++)
91 if (!strcmp(S_sfx[i].name, ""))
92 S_sfx[i].name = Z_Strdup("default");
93 }