mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-30 15:52:09 +00:00
- added a $musicalias command to SNDINFO that allows remapping of music tracks. Mapping to 'none' means that starting the remapped song will have no effect at all. There's one limitation though: If you load a WAD with the same music name after the one with the SNDINFO lump the mapping will be ignored. This is so that music resources can use this command without interfering with WADs that replace the music with their own.
SVN r3002 (trunk)
This commit is contained in:
parent
aa2e14b27f
commit
2fcf1af21b
3 changed files with 41 additions and 1 deletions
|
@ -149,6 +149,7 @@ enum SICommands
|
||||||
SI_IfStrife,
|
SI_IfStrife,
|
||||||
SI_Rolloff,
|
SI_Rolloff,
|
||||||
SI_Volume,
|
SI_Volume,
|
||||||
|
SI_MusicAlias,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Blood was a cool game. If Monolith ever releases the source for it,
|
// Blood was a cool game. If Monolith ever releases the source for it,
|
||||||
|
@ -183,6 +184,7 @@ struct FSavedPlayerSoundInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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.)
|
||||||
|
MusicAliasMap MusicAliases;
|
||||||
MidiDeviceMap MidiDevices;
|
MidiDeviceMap MidiDevices;
|
||||||
|
|
||||||
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
||||||
|
@ -241,6 +243,7 @@ static const char *SICommandStrings[] =
|
||||||
"$ifstrife",
|
"$ifstrife",
|
||||||
"$rolloff",
|
"$rolloff",
|
||||||
"$volume",
|
"$volume",
|
||||||
|
"$musicalias",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -254,6 +257,7 @@ static bool PlayerClassesIsSorted;
|
||||||
static TArray<FPlayerClassLookup> PlayerClassLookups;
|
static TArray<FPlayerClassLookup> PlayerClassLookups;
|
||||||
static TArray<FPlayerSoundHashTable> PlayerSounds;
|
static TArray<FPlayerSoundHashTable> PlayerSounds;
|
||||||
|
|
||||||
|
|
||||||
static FString DefPlayerClassName;
|
static FString DefPlayerClassName;
|
||||||
static int DefPlayerClass;
|
static int DefPlayerClass;
|
||||||
|
|
||||||
|
@ -1285,6 +1289,32 @@ static void S_AddSNDINFO (int lump)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SI_MusicAlias: {
|
||||||
|
sc.MustGetString();
|
||||||
|
int lump = Wads.CheckNumForName(sc.String, ns_music);
|
||||||
|
if (lump >= 0)
|
||||||
|
{
|
||||||
|
// do not set the alias if a later WAD defines its own music of this name
|
||||||
|
int file = Wads.GetLumpFile(lump);
|
||||||
|
int sndifile = Wads.GetLumpFile(sc.LumpNum);
|
||||||
|
if (file > sndifile)
|
||||||
|
{
|
||||||
|
sc.MustGetString();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 || Wads.CheckNumForName(sc.String, ns_music) >= 0)
|
||||||
|
{
|
||||||
|
MusicAliases[alias] = mapped;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SI_MidiDevice: {
|
case SI_MidiDevice: {
|
||||||
sc.MustGetString();
|
sc.MustGetString();
|
||||||
FName nm = sc.String;
|
FName nm = sc.String;
|
||||||
|
|
|
@ -2386,8 +2386,16 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
||||||
int offset = 0, length = 0;
|
int offset = 0, length = 0;
|
||||||
int device = MDEV_DEFAULT;
|
int device = MDEV_DEFAULT;
|
||||||
MusInfo *handle = NULL;
|
MusInfo *handle = NULL;
|
||||||
|
FName musicasname = musicname;
|
||||||
|
|
||||||
int *devp = MidiDevices.CheckKey(FName(musicname));
|
FName *aliasp = MusicAliases.CheckKey(musicasname);
|
||||||
|
if (aliasp != NULL)
|
||||||
|
{
|
||||||
|
musicname = (musicasname = *aliasp).GetChars();
|
||||||
|
if (musicasname == NAME_None) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int *devp = MidiDevices.CheckKey(musicasname);
|
||||||
if (devp != NULL) device = *devp;
|
if (devp != NULL) device = *devp;
|
||||||
|
|
||||||
// Strip off any leading file:// component.
|
// Strip off any leading file:// component.
|
||||||
|
|
|
@ -382,8 +382,10 @@ enum EMidiDevice
|
||||||
MDEV_GUS = 5,
|
MDEV_GUS = 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef TMap<FName, FName> MusicAliasMap;
|
||||||
typedef TMap<FName, int> MidiDeviceMap;
|
typedef TMap<FName, int> MidiDeviceMap;
|
||||||
|
|
||||||
|
extern MusicAliasMap MusicAliases;
|
||||||
extern MidiDeviceMap MidiDevices;
|
extern MidiDeviceMap MidiDevices;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue