mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-02-05 05:10:55 +00:00
Attempt to fix music replacement definitions again
Store per-map music replacements in a TMap, and perform the replacements after parsing the MAPINFO
This commit is contained in:
parent
f675adebbd
commit
2297c9351a
4 changed files with 24 additions and 1 deletions
|
@ -815,7 +815,7 @@ void parseMusic(FScanner& sc, FScriptPosition& pos)
|
||||||
if (sc.Compare("id")) sc.GetString(id);
|
if (sc.Compare("id")) sc.GetString(id);
|
||||||
else if (sc.Compare("file")) sc.GetString(file);
|
else if (sc.Compare("file")) sc.GetString(file);
|
||||||
}
|
}
|
||||||
SetMusicForMap(id, file, true);
|
SetMusicReplacement(id, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
|
@ -1057,6 +1057,7 @@ int RunGame()
|
||||||
gi->app_init();
|
gi->app_init();
|
||||||
StartScreen->Progress();
|
StartScreen->Progress();
|
||||||
G_ParseMapInfo();
|
G_ParseMapInfo();
|
||||||
|
ReplaceMusics(true);
|
||||||
CreateStatusBar();
|
CreateStatusBar();
|
||||||
SetDefaultMenuColors();
|
SetDefaultMenuColors();
|
||||||
M_Init();
|
M_Init();
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
#include "gamecontrol.h"
|
#include "gamecontrol.h"
|
||||||
#include "raze_sound.h"
|
#include "raze_sound.h"
|
||||||
|
#include "zstring.h"
|
||||||
|
|
||||||
FString gSkillNames[MAXSKILLS];
|
FString gSkillNames[MAXSKILLS];
|
||||||
int gDefaultVolume = 0, gDefaultSkill = 1;
|
int gDefaultVolume = 0, gDefaultSkill = 1;
|
||||||
|
@ -48,6 +49,7 @@ GlobalCutscenes globalCutscenes;
|
||||||
TArray<ClusterDef> clusters;
|
TArray<ClusterDef> clusters;
|
||||||
TArray<VolumeRecord> volumes;
|
TArray<VolumeRecord> volumes;
|
||||||
TArray<TPointer<MapRecord>> mapList; // must be allocated as pointers because it can whack the currentlLevel pointer if this was a flat array.
|
TArray<TPointer<MapRecord>> mapList; // must be allocated as pointers because it can whack the currentlLevel pointer if this was a flat array.
|
||||||
|
static TMap<FString, FString> musicReplacements;
|
||||||
MapRecord *currentLevel; // level that is currently played.
|
MapRecord *currentLevel; // level that is currently played.
|
||||||
MapRecord* lastLevel; // Same here, for the last level.
|
MapRecord* lastLevel; // Same here, for the last level.
|
||||||
|
|
||||||
|
@ -157,6 +159,23 @@ MapRecord* FindNextSecretMap(MapRecord* thismap)
|
||||||
return next? next : FindNextMap(thismap);
|
return next? next : FindNextMap(thismap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetMusicReplacement(const char *mapname, const char *music)
|
||||||
|
{
|
||||||
|
musicReplacements[mapname] = music;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReplaceMusics(bool namehack)
|
||||||
|
{
|
||||||
|
TMap<FString, FString>::Iterator it(musicReplacements);
|
||||||
|
TMap<FString, FString>::Pair* pair;
|
||||||
|
while (it.NextPair(pair))
|
||||||
|
{
|
||||||
|
FString mapname = pair->Key;
|
||||||
|
FString music = pair->Value;
|
||||||
|
SetMusicForMap(mapname, music, namehack);
|
||||||
|
}
|
||||||
|
musicReplacements.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
bool SetMusicForMap(const char* mapname, const char* music, bool namehack)
|
bool SetMusicForMap(const char* mapname, const char* music, bool namehack)
|
||||||
{
|
{
|
||||||
|
@ -192,6 +211,7 @@ bool SetMusicForMap(const char* mapname, const char* music, bool namehack)
|
||||||
index->music = music;
|
index->music = music;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
DPrintf(DMSG_WARNING, "Could not replace %s music with %s\n", mapname, music);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,8 @@ struct SummaryInfo
|
||||||
extern GlobalCutscenes globalCutscenes;
|
extern GlobalCutscenes globalCutscenes;
|
||||||
extern MapRecord *currentLevel;
|
extern MapRecord *currentLevel;
|
||||||
|
|
||||||
|
void SetMusicReplacement(const char *mapname, const char *music);
|
||||||
|
void ReplaceMusics(bool namehack = false);
|
||||||
bool SetMusicForMap(const char* mapname, const char* music, bool namehack = false);
|
bool SetMusicForMap(const char* mapname, const char* music, bool namehack = false);
|
||||||
|
|
||||||
MapRecord *FindMapByName(const char *nm);
|
MapRecord *FindMapByName(const char *nm);
|
||||||
|
|
Loading…
Reference in a new issue