MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / LoadTheme

Method LoadTheme

music/omflex.cpp:124–381  ·  view source on GitHub ↗

takes a filename containing oms data.

Source from the content-addressed store, hash-verified

122
123// takes a filename containing oms data.
124bool OutrageMusicSeq::LoadTheme(const char *file) {
125 const int MAX_FILE_LABELS = 256;
126
127 InfFile inf;
128 char operand[INFFILE_LINELEN]; // operand
129 int theme_type;
130 music_ins temp_ins_buf[MAX_MUSIC_INSTRUCTIONS];
131 int temp_ins_idx = 0;
132 int16_t cur_region;
133 struct {
134 char *name;
135 int16_t index;
136 int16_t region;
137 } labels[MAX_FILE_LABELS];
138 int n_labels = 0, n_relabels = 0;
139 bool in_region = false;
140
141 // reset list management for new theme.
142 m_tracklist.reset();
143 m_ins_curptr = m_ins_buffer;
144 m_str_curptr = m_str_buffer;
145
146 // open file
147 if (!file)
148 return false;
149
150 if (!inf.Open(file, "[theme file]", OMFLex)) {
151 mprintf(0, "Unable to find requested theme %s or bad file.\n", file);
152 return false;
153 }
154
155 cur_region = 0;
156
157 // perform FIRST PASS for LABELS
158 while (inf.ReadLine()) {
159 int cmd;
160 bool ifi_block;
161 ifi_block = false;
162 while ((cmd = inf.ParseLine(operand, INFFILE_LINELEN)) > INFFILE_ERROR) {
163 switch (cmd) {
164 case OMFCMD_LABEL:
165 if (n_labels == MAX_FILE_LABELS) {
166 cmd = OMFFILEERR_LBLOVERFLOW;
167 goto force_pre_error;
168 }
169 labels[n_labels].index = temp_ins_idx;
170 labels[n_labels].region = cur_region;
171 labels[n_labels++].name = mem_strdup(operand);
172 break;
173 case OMFCMD_SECTION:
174 case OMFCMD_REGION:
175 temp_ins_idx = 0;
176 break;
177 case OMFCMD_ENDREGION:
178 cur_region++;
179 break;
180 case OMFCMD_STREAM:
181 break;

Callers

nothing calls this directly

Calls 7

ReadLineMethod · 0.80
ParseLineMethod · 0.80
resetMethod · 0.45
OpenMethod · 0.45
lineMethod · 0.45
CloseMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected