MCPcopy Create free account
hub / github.com/ZDoom/Raze / SetMusicForMap

Function SetMusicForMap

source/core/mapinfo.cpp:190–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188}
189
190bool SetMusicForMap(const char* mapname, const char* music, bool namehack)
191{
192 static const char* specials[] = { "intro", "briefing", "loading" };
193 for (unsigned i = 0; i < 3; i++)
194 {
195 if (!stricmp(mapname, specials[i]))
196 {
197 if (specialmusic.Size() <= i) specialmusic.Resize(i + 1);
198 specialmusic[i] = music;
199 return true;
200 }
201 }
202
203 auto index = FindMapByName(mapname);
204
205 // This is for the DEFS parser's MUSIC command which never bothered to check for the real map name.
206 if (index == nullptr && namehack)
207 {
208 int lev, ep;
209 int8_t b1, b2;
210
211 int numMatches = sscanf(mapname, "%c%d%c%d", &b1, &ep, &b2, &lev);
212
213 if (numMatches != 4 || toupper(b1) != 'E' || toupper(b2) != 'L')
214 return false;
215
216 index = FindMapByIndexOnly(ep, lev);
217
218 }
219 if (index != nullptr)
220 {
221 index->music = music;
222 return true;
223 }
224 DPrintf(DMSG_WARNING, "Could not replace %s music with %s\n", mapname, music);
225 return false;
226}
227
228MapRecord *AllocateMap()
229{

Callers 1

ReplaceMusicsFunction · 0.85

Calls 6

stricmpFunction · 0.85
FindMapByNameFunction · 0.85
FindMapByIndexOnlyFunction · 0.85
DPrintfFunction · 0.85
SizeMethod · 0.45
ResizeMethod · 0.45

Tested by

no test coverage detected