forgor
- refactored musicdef handling - other things
This commit is contained in:
1 parent
1ae5bb9d27
commit
6afcb06e08
7 files changed
+164
-314
No files matched your search
@@ -17,7 +17,6 @@
|
||||
|
||||
#include "../qs22j.h"
|
||||
|
||||
|
||||
// The texture for the next polygon given to HWR_ProcessPolygon.
|
||||
// Set with HWR_SetCurrentTexture.
|
||||
GLMipmap_t *current_texture = NULL;
|
||||
|
||||
@@ -588,9 +588,9 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
|
||||
Surf.PolyColor.s.alpha = (strength*8);
|
||||
poly_flags |= PF_Translucent;
|
||||
}
|
||||
}
|
||||
else // Do TRANSMAP** fade.
|
||||
{
|
||||
}
|
||||
else // Do TRANSMAP** fade.
|
||||
{
|
||||
RGBA_t *palette = HWR_GetTexturePalette();
|
||||
Surf.PolyColor.rgba = palette[color&0xFF].rgba;
|
||||
|
||||
@@ -600,7 +600,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
|
||||
Surf.PolyColor.s.alpha = (UINT8)(strength*25.5f);
|
||||
|
||||
poly_flags |= PF_Translucent;
|
||||
}
|
||||
}
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, poly_flags);
|
||||
}
|
||||
|
||||
+1
-1
@@ -8834,7 +8834,7 @@ static void K_drawKartSpeedometer(void)
|
||||
{
|
||||
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE);
|
||||
V_DrawStretchyFixedPatch((SPDM_X-1)<<FRACBITS, (SPDM_Y + 5)<<FRACBITS, FRACUNIT*0.765, FRACUNIT*0.55, (V_HUDTRANS|splitflags), (skp_smallstickerclr3), colormap);
|
||||
}
|
||||
}
|
||||
else
|
||||
V_DrawStretchyFixedPatch((SPDM_X-1)<<FRACBITS, (SPDM_Y + 5)<<FRACBITS, FRACUNIT*0.765, FRACUNIT*0.55, (V_HUDTRANS|splitflags), (skp_smallsticker3), NULL);
|
||||
|
||||
|
||||
@@ -3024,11 +3024,6 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local)
|
||||
//
|
||||
S_LoadMusicDefs(wadnum);
|
||||
|
||||
//
|
||||
// edit music defs for stuff like musictest
|
||||
//
|
||||
S_LoadMTDefs(wadnum);
|
||||
|
||||
//
|
||||
// search for maps
|
||||
//
|
||||
|
||||
+1
-2
@@ -4147,8 +4147,7 @@ void P_PlayerThink(player_t *player)
|
||||
{
|
||||
seenplayer = NULL;
|
||||
|
||||
if (cv_seenames.value && cv_allowseenames.value &&
|
||||
!(G_TagGametype() && (player->pflags & PF_TAGIT)))
|
||||
if (cv_seenames.value && cv_allowseenames.value)
|
||||
{
|
||||
mobj_t *mo = P_SpawnNameFinder(player->mo, MT_NAMECHECK);
|
||||
|
||||
|
||||
+157
-301
@@ -1258,175 +1258,191 @@ static UINT32 queue_fadeinms;
|
||||
musicdef_t *musicdefstart = NULL; // First music definition
|
||||
struct cursongcredit cursongcredit; // Currently displayed song credit info
|
||||
|
||||
//
|
||||
// search for music definition in wad
|
||||
//
|
||||
static UINT16 W_CheckForMusicDefInPwad(UINT16 wadid)
|
||||
static boolean
|
||||
ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp)
|
||||
{
|
||||
UINT16 i;
|
||||
lumpinfo_t *lump_p;
|
||||
musicdef_t *def;
|
||||
|
||||
lump_p = wadfiles[wadid]->lumpinfo;
|
||||
for (i = 0; i < wadfiles[wadid]->numlumps; i++, lump_p++)
|
||||
if (memcmp(lump_p->name, "MUSICDEF", 8) == 0)
|
||||
return i;
|
||||
|
||||
return INT16_MAX; // not found
|
||||
}
|
||||
|
||||
void S_LoadMusicDefs(UINT16 wadnum)
|
||||
{
|
||||
UINT16 lump;
|
||||
char *buf;
|
||||
char *buf2;
|
||||
char *stoken;
|
||||
char *value;
|
||||
size_t size;
|
||||
musicdef_t *def, *prev;
|
||||
UINT16 line = 1; // for better error msgs
|
||||
char *textline;
|
||||
|
||||
lump = W_CheckForMusicDefInPwad(wadnum);
|
||||
if (lump == INT16_MAX)
|
||||
return;
|
||||
|
||||
buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE);
|
||||
size = W_LumpLengthPwad(wadnum, lump);
|
||||
|
||||
// for strtok
|
||||
buf2 = malloc(size+1);
|
||||
if (!buf2)
|
||||
I_Error("S_LoadMusicDefs: No more free memory\n");
|
||||
M_Memcpy(buf2,buf,size);
|
||||
buf2[size] = '\0';
|
||||
|
||||
def = prev = NULL;
|
||||
|
||||
stoken = strtok (buf2, "\r\n ");
|
||||
// Find music def
|
||||
while (stoken)
|
||||
if (!stricmp(stoken, "lump"))
|
||||
{
|
||||
if (!stricmp(stoken, "lump"))
|
||||
value = strtok(NULL, " ");
|
||||
if (!value)
|
||||
{
|
||||
value = strtok(NULL, "\r\n ");
|
||||
|
||||
if (!value)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "MUSICDEF: Lump '%s' is missing name. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
|
||||
stoken = strtok(NULL, "\r\n"); // skip end of line
|
||||
goto skip_lump;
|
||||
}
|
||||
|
||||
// No existing musicdefs
|
||||
if (!musicdefstart)
|
||||
{
|
||||
musicdefstart = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL);
|
||||
STRBUFCPY(musicdefstart->name, value);
|
||||
strlwr(musicdefstart->name);
|
||||
def = musicdefstart;
|
||||
//CONS_Printf("S_LoadMusicDefs: Initialized musicdef w/ song '%s'\n", def->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
def = musicdefstart;
|
||||
|
||||
// Search if this is a replacement
|
||||
//CONS_Printf("S_LoadMusicDefs: Searching for song replacement...\n");
|
||||
while (def)
|
||||
{
|
||||
if (!stricmp(def->name, value))
|
||||
{
|
||||
//CONS_Printf("S_LoadMusicDefs: Found song replacement '%s'\n", def->name);
|
||||
break;
|
||||
}
|
||||
|
||||
prev = def;
|
||||
def = def->next;
|
||||
}
|
||||
|
||||
// Nothing found, add to the end.
|
||||
if (!def)
|
||||
{
|
||||
def = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL);
|
||||
STRBUFCPY(def->name, value);
|
||||
strlwr(def->name);
|
||||
if (prev != NULL)
|
||||
prev->next = def;
|
||||
//CONS_Printf("S_LoadMusicDefs: Added song '%s'\n", def->name);
|
||||
}
|
||||
}
|
||||
|
||||
strncpy(def->filename, wadfiles[wadnum]->filename, 256);
|
||||
def->filename[256] = '\0';
|
||||
|
||||
skip_lump:
|
||||
stoken = strtok(NULL, "\r\n ");
|
||||
line++;
|
||||
CONS_Alert(CONS_WARNING,
|
||||
"MUSICDEF: Field '%s' is missing name. (file %s, line %d)\n",
|
||||
stoken, wadfiles[wadnum]->filename, line);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = strtok(NULL, "\r\n= ");
|
||||
def = S_FindMusicCredit(value);
|
||||
|
||||
if (!value)
|
||||
// Nothing found, add to the end.
|
||||
if (!def)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
|
||||
stoken = strtok(NULL, "\r\n"); // skip end of line
|
||||
goto skip_field;
|
||||
def = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL);
|
||||
|
||||
STRBUFCPY(def->name, value);
|
||||
strlwr(def->name);
|
||||
def->hash = quickncasehash (def->name, 6);
|
||||
|
||||
def->next = musicdefstart;
|
||||
musicdefstart = def;
|
||||
}
|
||||
|
||||
(*defp) = def;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = strtok(NULL, "");
|
||||
|
||||
if (value)
|
||||
{
|
||||
// Find the equals sign.
|
||||
value = strchr(value, '=');
|
||||
}
|
||||
|
||||
if (!value)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING,
|
||||
"MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n",
|
||||
stoken, wadfiles[wadnum]->filename, line);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
def = (*defp);
|
||||
|
||||
if (!def)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "MUSICDEF: No music definition before field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
|
||||
free(buf2);
|
||||
return;
|
||||
CONS_Alert(CONS_ERROR,
|
||||
"MUSICDEF: No music definition before field '%s'. (file %s, line %d)\n",
|
||||
stoken, wadfiles[wadnum]->filename, line);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Skip the equals sign.
|
||||
value++;
|
||||
|
||||
// Now skip funny whitespace.
|
||||
value += strspn(value, "\t ");
|
||||
|
||||
textline = value;
|
||||
|
||||
// turn _ into spaces.
|
||||
#define ADDDEF(field)\
|
||||
STRBUFCPY(def->field, textline);\
|
||||
for (textline = def->field; *textline; textline++)\
|
||||
if (*textline == '_') *textline = ' ';
|
||||
|
||||
if (!stricmp(stoken, "usage"))
|
||||
{
|
||||
STRBUFCPY(def->usage, value);
|
||||
for (value = def->usage; *value; value++)
|
||||
if (*value == '_') *value = ' '; // turn _ into spaces.
|
||||
//CONS_Printf("S_LoadMusicDefs: Set usage to '%s'\n", def->usage);
|
||||
ADDDEF(usage);
|
||||
}
|
||||
else if (!stricmp(stoken, "source"))
|
||||
{
|
||||
STRBUFCPY(def->source, value);
|
||||
for (value = def->source; *value; value++)
|
||||
if (*value == '_') *value = ' '; // turn _ into spaces.
|
||||
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
|
||||
ADDDEF(source);
|
||||
}
|
||||
else if (!stricmp(stoken, "title"))
|
||||
{
|
||||
def->use_info = true;
|
||||
STRBUFCPY(def->title, value);
|
||||
for (value = def->title; *value; value++)
|
||||
if (*value == '_') *value = ' '; // turn _ into spaces.
|
||||
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
|
||||
ADDDEF(title);
|
||||
}
|
||||
else if (!stricmp(stoken, "alttitle"))
|
||||
{
|
||||
STRBUFCPY(def->alttitle, value);
|
||||
for (value = def->alttitle; *value; value++)
|
||||
if (*value == '_') *value = ' '; // turn _ into spaces.
|
||||
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
|
||||
ADDDEF(alttitle);
|
||||
}
|
||||
else if (!stricmp(stoken, "authors"))
|
||||
{
|
||||
STRBUFCPY(def->authors, value);
|
||||
for (value = def->authors; *value; value++)
|
||||
if (*value == '_') *value = ' '; // turn _ into spaces.
|
||||
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
|
||||
ADDDEF(authors);
|
||||
}
|
||||
else
|
||||
CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
|
||||
|
||||
skip_field:
|
||||
stoken = strtok(NULL, "\r\n= ");
|
||||
line++;
|
||||
#undef ADDDEF
|
||||
}
|
||||
}
|
||||
|
||||
free(buf2);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
void S_LoadMusicDefs(UINT16 wadnum)
|
||||
{
|
||||
UINT16 lumpnum;
|
||||
char *lump;
|
||||
char *musdeftext;
|
||||
size_t size;
|
||||
|
||||
char *lf;
|
||||
char *stoken;
|
||||
|
||||
size_t nlf;
|
||||
size_t ncr;
|
||||
|
||||
musicdef_t *def = NULL;
|
||||
int line = 1; // for better error msgs
|
||||
|
||||
for (int k = 0; k < 2; k++)
|
||||
{
|
||||
lumpnum = W_CheckNumForNamePwad((k == 1 ? "MUSCINFO" : "MUSICDEF") , wadnum, 0); //check for MUSCINFO lump on 2nd iteration
|
||||
|
||||
if (lumpnum == INT16_MAX)
|
||||
continue;
|
||||
|
||||
lump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
|
||||
size = W_LumpLengthPwad(wadnum, lumpnum);
|
||||
|
||||
// Null-terminated MUSICDEF lump.
|
||||
musdeftext = malloc(size+1);
|
||||
if (!musdeftext)
|
||||
I_Error("S_LoadMusicDefs: No more free memory for the parser\n");
|
||||
M_Memcpy(musdeftext, lump, size);
|
||||
musdeftext[size] = '\0';
|
||||
|
||||
// Find music def
|
||||
stoken = musdeftext;
|
||||
for (;;)
|
||||
{
|
||||
lf = strpbrk(stoken, "\r\n");
|
||||
if (lf)
|
||||
{
|
||||
if (*lf == '\n')
|
||||
nlf = 1;
|
||||
else
|
||||
nlf = 0;
|
||||
*lf++ = '\0';/* now we can delimit to here */
|
||||
}
|
||||
|
||||
stoken = strtok(stoken, " ");
|
||||
if (stoken)
|
||||
{
|
||||
if (! ReadMusicDefFields(wadnum, line, stoken, &def))
|
||||
break;
|
||||
}
|
||||
|
||||
if (lf)
|
||||
{
|
||||
do
|
||||
{
|
||||
line += nlf;
|
||||
ncr = strspn(lf, "\r");/* skip CR */
|
||||
lf += ncr;
|
||||
nlf = strspn(lf, "\n");
|
||||
lf += nlf;
|
||||
}
|
||||
while (nlf || ncr) ;
|
||||
|
||||
stoken = lf;/* now the next nonempty line */
|
||||
}
|
||||
else
|
||||
break;/* EOF */
|
||||
}
|
||||
|
||||
free(musdeftext);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1441,164 +1457,6 @@ void S_InitMusicDefs(void)
|
||||
S_LoadMusicDefs(i);
|
||||
}
|
||||
|
||||
//
|
||||
// search for music definition in wad
|
||||
//
|
||||
static UINT16 W_CheckForMusicInfoInPwad(UINT16 wadid)
|
||||
{
|
||||
UINT16 i;
|
||||
lumpinfo_t *lump_p;
|
||||
|
||||
lump_p = wadfiles[wadid]->lumpinfo;
|
||||
for (i = 0; i < wadfiles[wadid]->numlumps; i++, lump_p++)
|
||||
if (memcmp(lump_p->name, "MUSCINFO", 8) == 0)
|
||||
return i;
|
||||
|
||||
return INT16_MAX; // not found
|
||||
}
|
||||
|
||||
void S_LoadMTDefs(UINT16 wadnum)
|
||||
{
|
||||
UINT16 lump;
|
||||
char *buf;
|
||||
char *buf2;
|
||||
char *stoken;
|
||||
char *value;
|
||||
size_t size;
|
||||
musicdef_t *def, *prev;
|
||||
UINT16 line = 1; // for better error msgs
|
||||
|
||||
lump = W_CheckForMusicInfoInPwad(wadnum);
|
||||
if (lump == INT16_MAX)
|
||||
return;
|
||||
|
||||
buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE);
|
||||
size = W_LumpLengthPwad(wadnum, lump);
|
||||
|
||||
// for strtok
|
||||
buf2 = malloc(size+1);
|
||||
if (!buf2)
|
||||
I_Error("S_LoadMTDefs: No more free memory\n");
|
||||
M_Memcpy(buf2,buf,size);
|
||||
buf2[size] = '\0';
|
||||
|
||||
def = prev = NULL;
|
||||
|
||||
stoken = strtok (buf2, "\r\n ");
|
||||
// Find music def
|
||||
while (stoken)
|
||||
{
|
||||
if (!stricmp(stoken, "lump"))
|
||||
{
|
||||
value = strtok(NULL, "\r\n ");
|
||||
|
||||
if (!value)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "MUSICDEF: Lump '%s' is missing name. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
|
||||
stoken = strtok(NULL, "\r\n"); // skip end of line
|
||||
goto skip_lump;
|
||||
}
|
||||
|
||||
// No existing musicdefs
|
||||
if (!musicdefstart)
|
||||
{
|
||||
musicdefstart = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL);
|
||||
STRBUFCPY(musicdefstart->name, value);
|
||||
strlwr(musicdefstart->name);
|
||||
def = musicdefstart;
|
||||
//CONS_Printf("S_LoadMusicDefs: Initialized musicdef w/ song '%s'\n", def->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
def = musicdefstart;
|
||||
|
||||
// Search if this is a replacement
|
||||
//CONS_Printf("S_LoadMusicDefs: Searching for song replacement...\n");
|
||||
while (def)
|
||||
{
|
||||
if (!stricmp(def->name, value))
|
||||
{
|
||||
//CONS_Printf("S_LoadMusicDefs: Found song replacement '%s'\n", def->name);
|
||||
break;
|
||||
}
|
||||
|
||||
prev = def;
|
||||
def = def->next;
|
||||
}
|
||||
|
||||
// Nothing found, abort.
|
||||
if (!def)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "MUSCINFO: Music def for '%s' does not exist. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
|
||||
free(buf2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
skip_lump:
|
||||
stoken = strtok(NULL, "\r\n ");
|
||||
line++;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = strtok(NULL, "\r\n= ");
|
||||
|
||||
if (!value)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "MUSCINFO: Field '%s' is missing value. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
|
||||
stoken = strtok(NULL, "\r\n"); // skip end of line
|
||||
goto skip_field;
|
||||
}
|
||||
|
||||
if (!def)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "MUSCINFO: No music definition before field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
|
||||
free(buf2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!stricmp(stoken, "title"))
|
||||
{
|
||||
def->use_info = true;
|
||||
STRBUFCPY(def->title, value);
|
||||
for (value = def->title; *value; value++)
|
||||
if (*value == '_') *value = ' '; // turn _ into spaces.
|
||||
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
|
||||
}
|
||||
else if (!stricmp(stoken, "alttitle"))
|
||||
{
|
||||
STRBUFCPY(def->alttitle, value);
|
||||
for (value = def->alttitle; *value; value++)
|
||||
if (*value == '_') *value = ' '; // turn _ into spaces.
|
||||
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
|
||||
}
|
||||
else if (!stricmp(stoken, "authors"))
|
||||
{
|
||||
STRBUFCPY(def->authors, value);
|
||||
for (value = def->authors; *value; value++)
|
||||
if (*value == '_') *value = ' '; // turn _ into spaces.
|
||||
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
|
||||
}
|
||||
else
|
||||
CONS_Alert(CONS_WARNING, "MUSCINFO: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
|
||||
|
||||
skip_field:
|
||||
stoken = strtok(NULL, "\r\n= ");
|
||||
line++;
|
||||
}
|
||||
}
|
||||
|
||||
free(buf2);
|
||||
return;
|
||||
}
|
||||
|
||||
void S_InitMTDefs(void)
|
||||
{
|
||||
UINT16 i;
|
||||
for (i = 0; i < numwadfiles; i++)
|
||||
S_LoadMTDefs(i);
|
||||
}
|
||||
|
||||
//
|
||||
// S_FindMusicCredit
|
||||
//
|
||||
@@ -1606,19 +1464,17 @@ void S_InitMTDefs(void)
|
||||
//
|
||||
musicdef_t *S_FindMusicCredit(const char *musname)
|
||||
{
|
||||
musicdef_t *def = musicdefstart;
|
||||
UINT32 hash = quickncasehash (musname, 6);
|
||||
musicdef_t *def;
|
||||
|
||||
if (!def) // No definitions
|
||||
return NULL;
|
||||
|
||||
while (def)
|
||||
for (def = musicdefstart; def; def = def->next)
|
||||
{
|
||||
if (!stricmp(def->name, musname))
|
||||
{
|
||||
return def;
|
||||
}
|
||||
else
|
||||
def = def->next;
|
||||
if (hash != def->hash)
|
||||
continue;
|
||||
if (stricmp(def->name, musname))
|
||||
continue;
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -168,6 +168,7 @@ boolean S_SpeedMusic(float speed);
|
||||
typedef struct musicdef_s
|
||||
{
|
||||
char name[7];
|
||||
UINT32 hash;
|
||||
char usage[256];
|
||||
char source[256];
|
||||
char filename[256+1];
|
||||
|
||||
Reference in new issue
Block a user