Debian Codegraph @

music/tracklist.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 * $Source: $
21 * $Revision: 4 $
22 * $Author: Jeff $
23 * $Date: 3/15/99 4:32p $
24 *
25 *
26 *
27 * $Log: /DescentIII/Main/music/tracklist.cpp $
28 *
29 * 4 3/15/99 4:32p Jeff
30 * fixed code so mem library compiles correctly
31 *
32 * 3 12/11/98 4:03p Samir
33 * error checking.
34 *
35 * 2 11/13/98 2:27p Samir
36 * created.
37 *
38 */
39
40 #include "music.h"cxx . . $ `<file>/music/music.h`/
41 #include "mem.h"cxx . . $ `<file>/mem/mem.h`/
42 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
43
44 #include <string.h>
45
46 //////////////////////////////////////////////////////////////////////////////
47
48 oms_tracklistcxx . . $ oms_tracklist#::oms_tracklistcxx . . $ oms_tracklist#oms_tracklist(49f6e7a06ebc5aa8).() {
49 m_fnamelistcxx . . $ oms_tracklist#m_fnamelist. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
50 m_symlistcxx . . $ oms_tracklist#m_symlist. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
51 m_numtrackscxx . . $ oms_tracklist#m_numtracks. = 0;
52 m_maxtrackscxx . . $ oms_tracklist#m_maxtracks. = 0;
53 m_initcxx . . $ oms_tracklist#m_init. = false;
54 }
55
56 oms_tracklistcxx . . $ oms_tracklist#::~cxx . . $ oms_tracklist#`~oms_tracklist`(ced63f7c635d850d).oms_tracklistcxx . . $ oms_tracklist#() { oms_tracklistcxx . . $ oms_tracklist#::freecxx . . $ oms_tracklist#free(49f6e7a06ebc5aa8).(); }
57
58 // initializes track list system
59 void oms_tracklistcxx . . $ oms_tracklist#::initcxx . . $ oms_tracklist#init(68e3ae50fe6578a9).(int16_t maxtracks) {
60 if (!m_initcxx . . $ oms_tracklist#m_init.) {
61 m_maxtrackscxx . . $ oms_tracklist#m_maxtracks. = maxtracks;
62 m_numtrackscxx . . $ oms_tracklist#m_numtracks. = 0;
63
64 m_fnamelistcxx . . $ oms_tracklist#m_fnamelist. = new char *[m_maxtrackscxx . . $ oms_tracklist#m_maxtracks.];
65 m_symlistcxx . . $ oms_tracklist#m_symlist. = new char *[m_maxtrackscxx . . $ oms_tracklist#m_maxtracks.];
66 m_initcxx . . $ oms_tracklist#m_init. = true;
67 }
68 }
69
70 // frees track list system
71 void oms_tracklistcxx . . $ oms_tracklist#::freecxx . . $ oms_tracklist#free(49f6e7a06ebc5aa8).() {
72 if (m_initcxx . . $ oms_tracklist#m_init.) {
73 oms_tracklistcxx . . $ oms_tracklist#::resetcxx . . $ oms_tracklist#reset(49f6e7a06ebc5aa8).();
74 delete[] m_symlistcxx . . $ oms_tracklist#m_symlist.;
75 delete[] m_fnamelistcxx . . $ oms_tracklist#m_fnamelist.;
76
77 m_initcxx . . $ oms_tracklist#m_init. = false;
78 }
79 }
80
81 // resets track list to 0
82 void oms_tracklistcxx . . $ oms_tracklist#::resetcxx . . $ oms_tracklist#reset(49f6e7a06ebc5aa8).() {
83 int i;
84
85 if (!m_initcxx . . $ oms_tracklist#m_init.)
86 return;
87
88 for (i = 0; i < m_numtrackscxx . . $ oms_tracklist#m_numtracks.; i++) {
89 ::mem_freecxx . . $ `mem/mem.h:80:9`!(m_fnamelist[i]);
90 ::mem_freecxx . . $ `mem/mem.h:80:9`!(m_symlist[i]);
91 }
92
93 m_numtrackscxx . . $ oms_tracklist#m_numtracks. = 0;
94 }
95
96 // adds a track to list.
97 bool oms_tracklistcxx . . $ oms_tracklist#::addcxx . . $ oms_tracklist#add(b7a7aa4a824b7595).(const char *fname, const char *sym) {
98 if (!m_initcxx . . $ oms_tracklist#m_init.)
99 return false;
100
101 if (m_numtrackscxx . . $ oms_tracklist#m_numtracks. == m_maxtrackscxx . . $ oms_tracklist#m_maxtracks.) {
102 Int3cxx . . $ `misc/pserror.h:247:9`!();
103 return false;
104 }
105
106 // add symbol and track name
107 m_fnamelistcxx . . $ oms_tracklist#m_fnamelist.[m_numtrackscxx . . $ oms_tracklist#m_numtracks.] = mem_strdupcxx . . $ `mem/mem.h:81:9`!(fname);
108 m_symlistcxx . . $ oms_tracklist#m_symlist.[m_numtrackscxx . . $ oms_tracklist#m_numtracks.] = mem_strdupcxx . . $ `mem/mem.h:81:9`!(sym);
109 m_numtrackscxx . . $ oms_tracklist#m_numtracks.++;
110
111 return true;
112 }
113
114 // returns a track filename.
115 const char *oms_tracklistcxx . . $ oms_tracklist#::getcxx . . $ oms_tracklist#get(fb58d2e09a2a1ce6).(const char *sym) {
116 int i;
117
118 if (sym) {
119 for (i = 0; i < m_numtrackscxx . . $ oms_tracklist#m_numtracks.; i++) {
120 if (strcmp(m_symlistcxx . . $ oms_tracklist#m_symlist.[i], sym) == 0)
121 return m_fnamelistcxx . . $ oms_tracklist#m_fnamelist.[i];
122 }
123 }
124
125 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
126 }