Merge branch 'multi-musicdef' into 'master'
Multi Musicdef See merge request KartKrew/Kart!1084
This commit is contained in:
parent
4f6ebff439
commit
f6edce1f88
3 changed files with 134 additions and 21 deletions
|
|
@ -1360,22 +1360,26 @@ int musicdef_volume;
|
|||
//
|
||||
// Find music def by 6 char name
|
||||
//
|
||||
static musicdef_t *S_FindMusicDef(const char *name)
|
||||
musicdef_t *S_FindMusicDef(const char *name, UINT8 *i)
|
||||
{
|
||||
UINT32 hash = quickncasehash (name, 6);
|
||||
musicdef_t *def;
|
||||
|
||||
for (def = musicdefstart; def; def = def->next)
|
||||
{
|
||||
if (hash != def->hash)
|
||||
continue;
|
||||
for (*i = 0; *i < def->numtracks; (*i)++)
|
||||
{
|
||||
if (hash != def->hash[*i])
|
||||
continue;
|
||||
|
||||
if (stricmp(def->name, name))
|
||||
continue;
|
||||
if (stricmp(def->name[*i], name))
|
||||
continue;
|
||||
|
||||
return def;
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
*i = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1417,7 +1421,7 @@ ReadMusicDefFields
|
|||
|
||||
if (!stricmp(stoken, "lump"))
|
||||
{
|
||||
value = strtok(NULL, " ");
|
||||
value = strtok(NULL, " ,");
|
||||
if (!value)
|
||||
{
|
||||
return MusicDefError(CONS_WARNING,
|
||||
|
|
@ -1426,16 +1430,32 @@ ReadMusicDefFields
|
|||
}
|
||||
else
|
||||
{
|
||||
def = S_FindMusicDef(value);
|
||||
UINT8 i = 0;
|
||||
|
||||
def = S_FindMusicDef(value, &i);
|
||||
|
||||
// Nothing found, add to the end.
|
||||
if (!def)
|
||||
{
|
||||
def = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL);
|
||||
|
||||
STRBUFCPY(def->name, value);
|
||||
strlwr(def->name);
|
||||
def->hash = quickncasehash (def->name, 6);
|
||||
do {
|
||||
if (i >= MAXDEFTRACKS)
|
||||
break;
|
||||
STRBUFCPY(def->name[i], value);
|
||||
strlwr(def->name[i]);
|
||||
def->hash[i] = quickncasehash (def->name[i], 6);
|
||||
i++;
|
||||
} while ((value = strtok(NULL," ,")) != NULL);
|
||||
|
||||
if (value != NULL)
|
||||
{
|
||||
return MusicDefError(CONS_ERROR,
|
||||
"Extra tracks for field '%s' beyond 3 discarded.", // MAXDEFTRACKS
|
||||
stoken, lumpnum, line);
|
||||
}
|
||||
|
||||
def->numtracks = i;
|
||||
def->volume = DEFAULT_MUSICDEF_VOLUME;
|
||||
|
||||
def->next = musicdefstart;
|
||||
|
|
@ -1616,7 +1636,8 @@ void S_InitMusicDefs(void)
|
|||
//
|
||||
void S_ShowMusicCredit(void)
|
||||
{
|
||||
musicdef_t *def = S_FindMusicDef(music_name);
|
||||
UINT8 i = 0;
|
||||
musicdef_t *def = S_FindMusicDef(music_name, &i);
|
||||
|
||||
char credittext[128] = "";
|
||||
char *work = NULL;
|
||||
|
|
@ -1640,6 +1661,17 @@ void S_ShowMusicCredit(void)
|
|||
strncat(credittext, work, len);
|
||||
len -= worklen;
|
||||
|
||||
if (def->numtracks > 1)
|
||||
{
|
||||
work = va(" (%c)", i+'A');
|
||||
worklen = strlen(work);
|
||||
if (worklen <= len)
|
||||
{
|
||||
strncat(credittext, work, len);
|
||||
len -= worklen;
|
||||
}
|
||||
}
|
||||
|
||||
#define MUSICCREDITAPPEND(field)\
|
||||
if (field)\
|
||||
{\
|
||||
|
|
@ -2238,7 +2270,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
|
|||
musicdef_volume = DEFAULT_MUSICDEF_VOLUME;
|
||||
|
||||
{
|
||||
musicdef_t *def = S_FindMusicDef(music_name);
|
||||
UINT8 i = 0;
|
||||
musicdef_t *def = S_FindMusicDef(music_name, &i);
|
||||
|
||||
if (def)
|
||||
{
|
||||
|
|
@ -2456,11 +2489,16 @@ static inline void PrintMusicDefField(const char *label, const char *field)
|
|||
}
|
||||
}
|
||||
|
||||
static void PrintSongAuthors(const musicdef_t *def)
|
||||
static void PrintSongAuthors(const musicdef_t *def, UINT8 i)
|
||||
{
|
||||
CONS_Printf("Volume: %d/100\n\n", def->volume);
|
||||
|
||||
PrintMusicDefField("Title: ", def->title);
|
||||
if (def->numtracks > 1)
|
||||
{
|
||||
PrintMusicDefField("Title: ", va("%s (%c)", def->title, i+'A'));
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMusicDefField("Title: ", def->title);
|
||||
}
|
||||
PrintMusicDefField("Author: ", def->author);
|
||||
|
||||
CONS_Printf("\n");
|
||||
|
|
@ -2493,14 +2531,29 @@ static void Command_Tunes_f(void)
|
|||
|
||||
if (!strcasecmp(tunearg, "-show"))
|
||||
{
|
||||
const musicdef_t *def = S_FindMusicDef(mapmusname);
|
||||
UINT8 i = 0;
|
||||
const musicdef_t *def = S_FindMusicDef(music_name, &i);
|
||||
|
||||
CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"),
|
||||
music_name, (music_flags & MUSIC_TRACKMASK));
|
||||
|
||||
if (def != NULL)
|
||||
{
|
||||
PrintSongAuthors(def, i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!strcasecmp(tunearg, "-showdefault"))
|
||||
{
|
||||
UINT8 i = 0;
|
||||
const musicdef_t *def = S_FindMusicDef(mapmusname, &i);
|
||||
|
||||
CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"),
|
||||
mapmusname, (mapmusflags & MUSIC_TRACKMASK));
|
||||
|
||||
if (def != NULL)
|
||||
{
|
||||
PrintSongAuthors(def);
|
||||
PrintSongAuthors(def, i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,11 +164,14 @@ boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping);
|
|||
// Set Speed of Music
|
||||
boolean S_SpeedMusic(float speed);
|
||||
|
||||
#define MAXDEFTRACKS 3
|
||||
|
||||
// Music credits
|
||||
typedef struct musicdef_s
|
||||
{
|
||||
char name[7];
|
||||
UINT32 hash;
|
||||
char name[MAXDEFTRACKS][7];
|
||||
UINT32 hash[MAXDEFTRACKS];
|
||||
UINT8 numtracks;
|
||||
char *title;
|
||||
char *author;
|
||||
char *source;
|
||||
|
|
@ -192,6 +195,7 @@ extern int musicdef_volume;
|
|||
|
||||
void S_LoadMusicDefs(UINT16 wadnum);
|
||||
void S_InitMusicDefs(void);
|
||||
musicdef_t *S_FindMusicDef(const char *name, UINT8 *i);
|
||||
void S_ShowMusicCredit(void);
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "doomdef.h"
|
||||
#include "g_game.h"
|
||||
#include "i_sound.h"
|
||||
#include "r_local.h"
|
||||
#include "p_local.h"
|
||||
#include "f_finale.h"
|
||||
|
|
@ -364,6 +365,61 @@ static INT32 SCR(INT32 r)
|
|||
// =========================================================================
|
||||
|
||||
// Devmode information
|
||||
|
||||
static void ST_pushDebugString(INT32 *height, const char *string)
|
||||
{
|
||||
V_DrawRightAlignedString(320, *height, V_MONOSPACE, string);
|
||||
*height -= 8;
|
||||
}
|
||||
|
||||
static void ST_pushDebugTimeMS(INT32 *height, const char *label, UINT32 ms)
|
||||
{
|
||||
ST_pushDebugString(height, va("%s%02d:%05.2f", label,
|
||||
ms / 60000, ms % 60000 / 1000.f));
|
||||
}
|
||||
|
||||
static void ST_drawMusicDebug(INT32 *height)
|
||||
{
|
||||
char mname[7];
|
||||
UINT16 mflags; // unused
|
||||
boolean looping;
|
||||
UINT8 i = 0;
|
||||
|
||||
const musicdef_t *def;
|
||||
musictype_t format;
|
||||
|
||||
if (!S_MusicInfo(mname, &mflags, &looping))
|
||||
{
|
||||
ST_pushDebugString(height, "Song: <NOTHING>");
|
||||
return;
|
||||
}
|
||||
|
||||
def = S_FindMusicDef(mname, &i);
|
||||
format = S_MusicType();
|
||||
|
||||
ST_pushDebugTimeMS(height, " Elapsed: ", S_GetMusicPosition());
|
||||
ST_pushDebugTimeMS(height, looping
|
||||
? " Loop B: "
|
||||
: "Duration: ", S_GetMusicLength());
|
||||
|
||||
if (looping)
|
||||
{
|
||||
ST_pushDebugTimeMS(height, " Loop A: ", S_GetMusicLoopPoint());
|
||||
}
|
||||
|
||||
if (def)
|
||||
{
|
||||
ST_pushDebugString(height, va(" Volume: %4d/100", def->volume));
|
||||
}
|
||||
|
||||
if (format)
|
||||
{
|
||||
ST_pushDebugString(height, va(" Format: %d", S_MusicType()));
|
||||
}
|
||||
|
||||
ST_pushDebugString(height, va(" Song: %8s", mname));
|
||||
}
|
||||
|
||||
static void ST_drawDebugInfo(void)
|
||||
{
|
||||
INT32 height = 192;
|
||||
|
|
|
|||
Loading…
Reference in a new issue