- removed the non-functional and long abandoned level music alias feature.

With RMAPINFO such a hack is no longer needed for anything.
This commit is contained in:
Christoph Oelckers 2021-05-12 01:58:42 +02:00
parent 783b94f922
commit d097c8e635
16 changed files with 45 additions and 76 deletions

View file

@ -52,13 +52,11 @@ enum SICommands
SI_MusicVolume, SI_MusicVolume,
SI_MidiDevice, SI_MidiDevice,
SI_MusicAlias, SI_MusicAlias,
SI_LevelMusic,
}; };
// This specifies whether Timidity or Windows playback is preferred for a certain song (only useful for Windows.) // This specifies whether Timidity or Windows playback is preferred for a certain song (only useful for Windows.)
extern MusicAliasMap MusicAliases; extern MusicAliasMap MusicAliases;
extern MusicAliasMap LevelMusicAliases;
extern MidiDeviceMap MidiDevices; extern MidiDeviceMap MidiDevices;
extern MusicVolumeMap MusicVolumes; extern MusicVolumeMap MusicVolumes;
@ -80,7 +78,6 @@ static const char *SICommandStrings[] =
"$musicvolume", "$musicvolume",
"$mididevice", "$mididevice",
"$musicalias", "$musicalias",
"$levelmusic",
NULL NULL
}; };
@ -140,7 +137,7 @@ static void S_AddSNDINFO (int lump)
sc.MustGetString(); sc.MustGetString();
FName musname (sc.String); FName musname (sc.String);
sc.MustGetFloat(); sc.MustGetFloat();
MusicVolumes[musname] = sc.Float; MusicVolumes[musname] = (float)sc.Float;
} }
break; break;
@ -172,20 +169,6 @@ static void S_AddSNDINFO (int lump)
} }
break; break;
case SI_LevelMusic: {
sc.MustGetString();
FName alias = sc.String;
sc.MustGetString();
FName mapped = sc.String;
// only set the alias if the lump it maps to exists.
if (mapped == NAME_None || fileSystem.FindFile(sc.String) >= 0)
{
LevelMusicAliases[alias] = mapped;
}
}
break;
case SI_MidiDevice: { case SI_MidiDevice: {
sc.MustGetString(); sc.MustGetString();
FName nm = sc.String; FName nm = sc.String;

View file

@ -49,7 +49,6 @@ static FString lastStartedMusic;
TArray<FString> specialmusic; TArray<FString> specialmusic;
MusicAliasMap MusicAliases; MusicAliasMap MusicAliases;
MusicAliasMap LevelMusicAliases;
CVAR(Bool, printmusicinfo, false, 0) CVAR(Bool, printmusicinfo, false, 0)
CVAR(Bool, mus_extendedlookup, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, mus_extendedlookup, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
@ -191,31 +190,18 @@ static FString LookupMusicCB(const char* musicname, int& order)
} }
static FString lastMusicLevel, lastMusic; static FString lastMusic;
int Mus_Play(const char *mapname, const char *fn, bool loop) int Mus_Play(const char *fn, bool loop)
{ {
if (mus_blocked) return 1; // Caller should believe it succeeded. if (mus_blocked) return 1; // Caller should believe it succeeded.
if (*fn == '/') fn++; if (*fn == '/') fn++;
// Store the requested names for resuming. // Store the requested names for resuming.
lastMusicLevel = mapname;
lastMusic = fn; lastMusic = fn;
if (!MusicEnabled()) if (!MusicEnabled())
{ {
return 1; return 1;
} }
// Allow per level music substitution.
// For most cases using $musicalias would be sufficient, but that method only works if a level actually has some music defined at all.
// This way it can be done with an add-on definition lump even in cases like Redneck Rampage where no music definitions exist
// or where music gets reused for multiple levels but replacement is wanted individually.
if (mapname && *mapname)
{
if (*mapname == '/') mapname++;
FName *check = LevelMusicAliases.CheckKey(FName(mapname, true));
if (check) fn = check->GetChars();
}
return S_ChangeMusic(fn, 0, loop, true); return S_ChangeMusic(fn, 0, loop, true);
} }

View file

@ -11,7 +11,7 @@ extern TArray<FString> specialmusic;
// Totally minimalistic interface - should be all the game modules need. // Totally minimalistic interface - should be all the game modules need.
void Mus_InitMusic(); void Mus_InitMusic();
void Mus_UpdateMusic(); void Mus_UpdateMusic();
int Mus_Play(const char *mapname, const char *fn, bool loop); int Mus_Play(const char *fn, bool loop);
void Mus_Stop(); void Mus_Stop();
bool Mus_IsPlaying(); bool Mus_IsPlaying();
void Mus_SetPaused(bool on); void Mus_SetPaused(bool on);

View file

@ -244,7 +244,7 @@ void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int section
const auto &vp = di->Viewpoint; const auto &vp = di->Viewpoint;
float florz, ceilz; float florz, ceilz;
PlanesAtPoint(frontsector, vp.Pos.X * 16.f, vp.Pos.Y * -16.f, &ceilz, &florz); PlanesAtPoint(frontsector, float(vp.Pos.X) * 16.f, float(vp.Pos.Y) * -16.f, &ceilz, &florz);
fade = lookups.getFade(frontsector->floorpal); // fog is per sector. fade = lookups.getFade(frontsector->floorpal); // fog is per sector.
visibility = sectorVisibility(frontsector); visibility = sectorVisibility(frontsector);

View file

@ -139,8 +139,8 @@ public:
DVector2 dv = { double(ix2 - ix1), -double(iy2 - iy1) }; DVector2 dv = { double(ix2 - ix1), -double(iy2 - iy1) };
auto vang = dv.Angle() - 90.; auto vang = dv.Angle() - 90.;
cosalign = vang.Cos(); cosalign = float(vang.Cos());
sinalign = vang.Sin(); sinalign = float(vang.Sin());
int pow2width = 1 << sizeToBits((int)tx->GetDisplayWidth()); int pow2width = 1 << sizeToBits((int)tx->GetDisplayWidth());
if (pow2width < (int)tx->GetDisplayWidth()) pow2width *= 2; if (pow2width < (int)tx->GetDisplayWidth()) pow2width *= 2;
@ -247,9 +247,9 @@ bool SectorGeometry::MakeVertices(unsigned int secnum, int plane, const FVector2
{ {
auto sline = &sectionLines[sec->lines[start]]; auto sline = &sectionLines[sec->lines[start]];
auto wallp = &wall[sline->startpoint]; auto wallp = &wall[sline->startpoint];
float X = WallStartX(wallp); float X = float(WallStartX(wallp));
float Y = WallStartY(wallp); float Y = float(WallStartY(wallp));
if (fabs(X) > 32768. || fabs(Y) > 32768.) if (fabs(X) > 32768.f || fabs(Y) > 32768.f)
{ {
// If we get here there's some fuckery going around with the coordinates. Let's better abort and wait for things to realign. // If we get here there's some fuckery going around with the coordinates. Let's better abort and wait for things to realign.
// Do not try alternative methods if this happens. // Do not try alternative methods if this happens.
@ -277,7 +277,7 @@ bool SectorGeometry::MakeVertices(unsigned int secnum, int plane, const FVector2
{ {
minx = pt.first; minx = pt.first;
miny = pt.second; miny = pt.second;
outer = a; outer = int(a);
} }
} }
} }
@ -303,8 +303,8 @@ bool SectorGeometry::MakeVertices(unsigned int secnum, int plane, const FVector2
} }
auto& entry = data[secnum].planes[plane]; auto& entry = data[secnum].planes[plane];
entry.vertices.Resize(indices.size()); entry.vertices.Resize((unsigned)indices.size());
entry.texcoords.Resize(indices.size()); entry.texcoords.Resize((unsigned)indices.size());
entry.normal = CalcNormal(sectorp, plane); entry.normal = CalcNormal(sectorp, plane);
auto texture = tileGetTexture(plane ? sectorp->ceilingpicnum : sectorp->floorpicnum); auto texture = tileGetTexture(plane ? sectorp->ceilingpicnum : sectorp->floorpicnum);

View file

@ -487,7 +487,7 @@ void GameInterface::Render()
void sndPlaySpecialMusicOrNothing(int nMusic) void sndPlaySpecialMusicOrNothing(int nMusic)
{ {
if (!Mus_Play(nullptr, quoteMgr.GetQuote(nMusic), true)) if (!Mus_Play(quoteMgr.GetQuote(nMusic), true))
{ {
Mus_Stop(); Mus_Stop();
} }
@ -539,7 +539,7 @@ DEFINE_ACTION_FUNCTION(_Blood, OriginalLoadScreen)
DEFINE_ACTION_FUNCTION(_Blood, PlayIntroMusic) DEFINE_ACTION_FUNCTION(_Blood, PlayIntroMusic)
{ {
Mus_Play(nullptr, "PESTIS.MID", false); Mus_Play("PESTIS.MID", false);
return 0; return 0;
} }

View file

@ -246,12 +246,12 @@ void levelTryPlayMusic()
else else
{ {
buffer = currentLevel->music; buffer = currentLevel->music;
if (Mus_Play(currentLevel->labelName, buffer, true)) return; if (Mus_Play(buffer, true)) return;
if (buffer.IsNotEmpty()) DefaultExtension(buffer, ".mid"); if (buffer.IsNotEmpty()) DefaultExtension(buffer, ".mid");
} }
if (!Mus_Play(currentLevel->labelName, buffer, true)) if (!Mus_Play(buffer, true))
{ {
Mus_Play("", "", true); Mus_Play("", true);
} }
} }

View file

@ -674,7 +674,7 @@ void S_MenuSound(void)
static bool cd_disabled = false; // This is in case mus_redbook is enabled but no tracks found so that the regular music system can be switched on. static bool cd_disabled = false; // This is in case mus_redbook is enabled but no tracks found so that the regular music system can be switched on.
static void MusPlay(const char* label, const char* music, bool loop) static void MusPlay(const char* music, bool loop)
{ {
if (isWorldTour()) if (isWorldTour())
{ {
@ -688,26 +688,26 @@ static void MusPlay(const char* label, const char* music, bool loop)
int file = fileSystem.GetFileContainer(num); int file = fileSystem.GetFileContainer(num);
if (file == 1) if (file == 1)
{ {
Mus_Play(label, alternative, loop); Mus_Play(alternative, loop);
return; return;
} }
} }
} }
} }
int result = Mus_Play(label, music, loop); int result = Mus_Play(music, loop);
// do not remain silent if playing World Tour when the user has deleted the music. // do not remain silent if playing World Tour when the user has deleted the music.
if (!result && isWorldTour()) if (!result && isWorldTour())
{ {
FString alternative = music; FString alternative = music;
alternative.Substitute(".ogg", ".mid"); alternative.Substitute(".ogg", ".mid");
Mus_Play(label, alternative, loop); Mus_Play(alternative, loop);
} }
} }
void S_PlayLevelMusic(MapRecord *mi) void S_PlayLevelMusic(MapRecord *mi)
{ {
if (isRR() && mi->music.IsEmpty() && mus_redbook && !cd_disabled) return; if (isRR() && mi->music.IsEmpty() && mus_redbook && !cd_disabled) return;
MusPlay(mi->labelName, mi->music, true); MusPlay(mi->music, true);
} }
void S_PlaySpecialMusic(unsigned int m) void S_PlaySpecialMusic(unsigned int m)
@ -716,7 +716,7 @@ void S_PlaySpecialMusic(unsigned int m)
auto& musicfn = specialmusic[m]; auto& musicfn = specialmusic[m];
if (musicfn.IsNotEmpty()) if (musicfn.IsNotEmpty())
{ {
MusPlay(nullptr, musicfn, true); MusPlay(musicfn, true);
} }
} }
@ -741,10 +741,10 @@ void S_PlayRRMusic(int newTrack)
g_cdTrack = 2; g_cdTrack = 2;
FStringf filename("redneck%s%02d.ogg", isRRRA()? "rides" : "", g_cdTrack); FStringf filename("redneck%s%02d.ogg", isRRRA()? "rides" : "", g_cdTrack);
if (Mus_Play(nullptr, filename, false)) return; if (Mus_Play(filename, false)) return;
filename.Format("track%02d.ogg", g_cdTrack); filename.Format("track%02d.ogg", g_cdTrack);
if (Mus_Play(nullptr, filename, false)) return; if (Mus_Play(filename, false)) return;
} }
// If none of the tracks managed to start, disable the CD music for this session so that regular music can play if defined. // If none of the tracks managed to start, disable the CD music for this session so that regular music can play if defined.
cd_disabled = true; cd_disabled = true;

View file

@ -48,11 +48,11 @@ bool playCDtrack(int nTrack, bool bLoop)
// try ogg vorbis now from root directory. // try ogg vorbis now from root directory.
sprintf(filename, "exhumed%02d.ogg", nTrack); sprintf(filename, "exhumed%02d.ogg", nTrack);
if (!Mus_Play(nullptr, filename, true)) if (!Mus_Play(filename, true))
{ {
// try ogg vorbis now from GOG MUSIC subdirectory. // try ogg vorbis now from GOG MUSIC subdirectory.
sprintf(filename, "track%02d.ogg", nTrack); sprintf(filename, "track%02d.ogg", nTrack);
Mus_Play(nullptr, filename, true); Mus_Play(filename, true);
} }
return true; return true;
} }

View file

@ -197,7 +197,7 @@ void InitLevel(MapRecord* map)
RefreshStatus(); RefreshStatus();
if (!mus_redbook && map->music.IsNotEmpty()) Mus_Play(map->labelName, map->music, true); // Allow non-CD music if defined for the current level if (!mus_redbook && map->music.IsNotEmpty()) Mus_Play(map->music, true); // Allow non-CD music if defined for the current level
playCDtrack(map->cdSongId, true); playCDtrack(map->cdSongId, true);
setLevelStarted(currentLevel); setLevelStarted(currentLevel);
} }

View file

@ -404,7 +404,7 @@ void InitRunLevel(void)
if (currentLevel) if (currentLevel)
{ {
PlaySong(currentLevel->labelName, currentLevel->music, currentLevel->cdSongId); PlaySong(currentLevel->music, currentLevel->cdSongId);
} }
InitPrediction(&Player[myconnectindex]); InitPrediction(&Player[myconnectindex]);
@ -542,7 +542,7 @@ void GameInterface::LevelCompleted(MapRecord* map, int skill)
if (map == nullptr) if (map == nullptr)
{ {
FinishAnim = false; FinishAnim = false;
PlaySong(nullptr, ThemeSongs[0], ThemeTrack[0]); PlaySong(ThemeSongs[0], ThemeTrack[0]);
if (isShareware()) if (isShareware())
{ {
PlayOrderSound(); PlayOrderSound();

View file

@ -817,7 +817,7 @@ int DoDeathSpecial(short SpriteNum)
if (!SW_SHAREWARE) if (!SW_SHAREWARE)
{ {
// Resume the regular music - in a hack-free fashion. // Resume the regular music - in a hack-free fashion.
PlaySong(currentLevel->labelName, currentLevel->music, currentLevel->cdSongId); PlaySong(currentLevel->music, currentLevel->cdSongId);
} }
BossSpriteNum[0] = -2; BossSpriteNum[0] = -2;

View file

@ -935,16 +935,16 @@ int PlayerYellVocs[] =
// //
//========================================================================== //==========================================================================
bool PlaySong(const char* mapname, const char* song_file_name, int cdaudio_track, bool isThemeTrack) //(nullptr, nullptr, -1, false) starts the normal level music. bool PlaySong(const char* song_file_name, int cdaudio_track, bool isThemeTrack) //(nullptr, nullptr, -1, false) starts the normal level music.
{ {
// Play CD audio if enabled. // Play CD audio if enabled.
if (cdaudio_track >= 0 && (mus_redbook || !song_file_name || *song_file_name == 0)) if (cdaudio_track >= 0 && (mus_redbook || !song_file_name || *song_file_name == 0))
{ {
FStringf trackname("shadow%02d.ogg", cdaudio_track); FStringf trackname("shadow%02d.ogg", cdaudio_track);
if (!Mus_Play(mapname, trackname, true)) if (!Mus_Play(trackname, true))
{ {
trackname.Format("track%02d.ogg", cdaudio_track); trackname.Format("track%02d.ogg", cdaudio_track);
if (!Mus_Play(mapname, trackname, true)) if (!Mus_Play(trackname, true))
{ {
Printf("Can't find CD track %i!\n", cdaudio_track); Printf("Can't find CD track %i!\n", cdaudio_track);
} }
@ -955,14 +955,14 @@ bool PlaySong(const char* mapname, const char* song_file_name, int cdaudio_track
{ {
return true; return true;
} }
if (!Mus_Play(mapname, song_file_name, true)) if (!Mus_Play(song_file_name, true))
{ {
// try the CD track anyway if no MIDI could be found (the original game doesn't have any MIDI, it was CD Audio only, this avoids no music playing if mus_redbook is off.) // try the CD track anyway if no MIDI could be found (the original game doesn't have any MIDI, it was CD Audio only, this avoids no music playing if mus_redbook is off.)
FStringf trackname("shadow%02d.ogg", cdaudio_track); FStringf trackname("shadow%02d.ogg", cdaudio_track);
if (!Mus_Play(mapname, trackname, true)) if (!Mus_Play(trackname, true))
{ {
trackname.Format("track%02d.ogg", cdaudio_track); trackname.Format("track%02d.ogg", cdaudio_track);
if (!Mus_Play(nullptr, trackname, true)) return false; if (!Mus_Play(trackname, true)) return false;
} }
} }
return true; return true;
@ -1011,7 +1011,7 @@ DEFINE_ACTION_FUNCTION(_SW, PlaySong)
{ {
PARAM_PROLOGUE; PARAM_PROLOGUE;
PARAM_INT(song); PARAM_INT(song);
PlaySong(nullptr, ThemeSongs[song], ThemeTrack[song], true); PlaySong(ThemeSongs[song], ThemeTrack[song], true);
return 0; return 0;
} }

View file

@ -86,7 +86,7 @@ void StopFX(void);
void StopSound(void); void StopSound(void);
void StartAmbientSound(void); void StartAmbientSound(void);
void StopAmbientSound(void); void StopAmbientSound(void);
bool PlaySong(const char *mapname, const char *song_file_name, int cdaudio_track, bool isThemeTrack = false); //(nullptr, nullptr, -1, false) starts the normal level music. bool PlaySong(const char *song_file_name, int cdaudio_track, bool isThemeTrack = false); //(nullptr, nullptr, -1, false) starts the normal level music.
void PlaySoundRTS(int rts_num); void PlaySoundRTS(int rts_num);
// //

View file

@ -797,7 +797,7 @@ int DoSumoDeathMelt(short SpriteNum)
if (!SW_SHAREWARE) if (!SW_SHAREWARE)
{ {
// Resume the regular music - in a hack-free fashion. // Resume the regular music - in a hack-free fashion.
PlaySong(currentLevel->labelName, currentLevel->music, currentLevel->cdSongId); PlaySong(currentLevel->music, currentLevel->cdSongId);
} }
BossSpriteNum[1] = -2; // Sprite is gone, set it back to keep it valid! BossSpriteNum[1] = -2; // Sprite is gone, set it back to keep it valid!
@ -868,7 +868,7 @@ BossHealthMeter(void)
bosswasseen[0] = true; bosswasseen[0] = true;
if (!SW_SHAREWARE) if (!SW_SHAREWARE)
{ {
PlaySong(nullptr, ThemeSongs[2], ThemeTrack[2], true); PlaySong(ThemeSongs[2], ThemeTrack[2], true);
} }
} }
else if (i == 1 && !bosswasseen[1]) else if (i == 1 && !bosswasseen[1])
@ -876,7 +876,7 @@ BossHealthMeter(void)
bosswasseen[1] = true; bosswasseen[1] = true;
if (!SW_SHAREWARE) if (!SW_SHAREWARE)
{ {
PlaySong(nullptr, ThemeSongs[3], ThemeTrack[3], true); PlaySong(ThemeSongs[3], ThemeTrack[3], true);
} }
} }
else if (i == 2 && !bosswasseen[2]) else if (i == 2 && !bosswasseen[2])
@ -884,7 +884,7 @@ BossHealthMeter(void)
bosswasseen[2] = true; bosswasseen[2] = true;
if (!SW_SHAREWARE) if (!SW_SHAREWARE)
{ {
PlaySong(nullptr, ThemeSongs[4], ThemeTrack[4], true); PlaySong(ThemeSongs[4], ThemeTrack[4], true);
} }
} }
} }

View file

@ -775,7 +775,7 @@ int DoZillaDeathMelt(short SpriteNum)
if (!SW_SHAREWARE) if (!SW_SHAREWARE)
{ {
// Resume the regular music - in a hack-free fashion. // Resume the regular music - in a hack-free fashion.
PlaySong(currentLevel->labelName, currentLevel->music, currentLevel->cdSongId); PlaySong(currentLevel->music, currentLevel->cdSongId);
} }
//KeepActorOnFloor(SpriteNum); //KeepActorOnFloor(SpriteNum);