| 188 | } |
| 189 | |
| 190 | bool 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 | |
| 228 | MapRecord *AllocateMap() |
| 229 | { |
no test coverage detected