mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-01-06 23:13:20 +00:00
Merge branch 'alt-music' into 'master'
Alt Music See merge request KartKrew/Kart!915
This commit is contained in:
commit
3d625b533a
11 changed files with 68 additions and 18 deletions
|
|
@ -50,6 +50,7 @@
|
|||
// SRB2Kart
|
||||
#include "filesrch.h" // refreshdirmenu
|
||||
#include "k_follower.h"
|
||||
#include "doomstat.h" // MAXMUSNAMES
|
||||
|
||||
// Loops through every constant and operation in word and performs its calculations, returning the final value.
|
||||
fixed_t get_number(const char *word)
|
||||
|
|
@ -1165,11 +1166,25 @@ void readlevelheader(MYFILE *f, char * name)
|
|||
else if (fastcmp(word, "MUSIC"))
|
||||
{
|
||||
if (fastcmp(word2, "NONE"))
|
||||
mapheaderinfo[num]->musname[0] = 0; // becomes empty string
|
||||
{
|
||||
mapheaderinfo[num]->musname[0][0] = 0; // becomes empty string
|
||||
mapheaderinfo[num]->musname_size = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
deh_strlcpy(mapheaderinfo[num]->musname, word2,
|
||||
sizeof(mapheaderinfo[num]->musname), va("Level header %d: music", num));
|
||||
UINT8 j = 0; // i was declared elsewhere
|
||||
tmp = strtok(word2, ",");
|
||||
do {
|
||||
if (j >= MAXMUSNAMES)
|
||||
break;
|
||||
deh_strlcpy(mapheaderinfo[num]->musname[j], tmp,
|
||||
sizeof(mapheaderinfo[num]->musname[j]), va("Level header %d: music", num));
|
||||
j++;
|
||||
} while ((tmp = strtok(NULL,",")) != NULL);
|
||||
|
||||
if (tmp != NULL)
|
||||
deh_warning("Level header %d: additional music slots past %d discarded", num, MAXMUSNAMES);
|
||||
mapheaderinfo[num]->musname_size = j;
|
||||
}
|
||||
}
|
||||
else if (fastcmp(word, "MUSICSLOT"))
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ extern char mapmusname[7];
|
|||
extern UINT16 mapmusflags;
|
||||
extern UINT32 mapmusposition;
|
||||
extern UINT32 mapmusresume;
|
||||
extern UINT8 mapmusrng;
|
||||
#define MUSIC_TRACKMASK 0x0FFF // ----************
|
||||
#define MUSIC_RELOADRESET 0x8000 // *---------------
|
||||
#define MUSIC_FORCERESET 0x4000 // -*--------------
|
||||
|
|
@ -369,6 +370,8 @@ struct staffbrief_t
|
|||
tic_t lap;
|
||||
};
|
||||
|
||||
#define MAXMUSNAMES 3 // maximum definable music tracks per level
|
||||
|
||||
/** Map header information.
|
||||
*/
|
||||
struct mapheader_t
|
||||
|
|
@ -410,9 +413,10 @@ struct mapheader_t
|
|||
fixed_t gravity; ///< Map-wide gravity.
|
||||
|
||||
// Music information
|
||||
char musname[7]; ///< Music track to play. "" for no music.
|
||||
char musname[MAXMUSNAMES][7]; ///< Music tracks to play. First dimension is the track number, second is the music string. "" for no music.
|
||||
UINT16 mustrack; ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore.
|
||||
UINT32 muspos; ///< Music position to jump to.
|
||||
UINT8 musname_size; ///< Number of music tracks defined
|
||||
|
||||
// Sky information
|
||||
UINT8 weather; ///< See preciptype_t
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ char mapmusname[7]; // Music name
|
|||
UINT16 mapmusflags; // Track and reset bit
|
||||
UINT32 mapmusposition; // Position to jump to
|
||||
UINT32 mapmusresume;
|
||||
UINT8 mapmusrng; // Random selection result
|
||||
|
||||
INT16 gamemap = 1;
|
||||
UINT32 maptol;
|
||||
|
|
|
|||
|
|
@ -2508,12 +2508,22 @@ static int mapheaderinfo_get(lua_State *L)
|
|||
lua_pushinteger(L, header->typeoflevel);
|
||||
else if (fastcmp(field,"keywords"))
|
||||
lua_pushstring(L, header->keywords);
|
||||
else if (fastcmp(field,"musname"))
|
||||
lua_pushstring(L, header->musname);
|
||||
else if (fastcmp(field,"musname")) // we create a table here because it saves us from a userdata nightmare
|
||||
{
|
||||
UINT8 i;
|
||||
lua_createtable(L, header->musname_size, 0);
|
||||
for (i = 0; i < header->musname_size; i++)
|
||||
{
|
||||
lua_pushstring(L, header->musname[i]);
|
||||
lua_rawseti(L, -2, 1 + i);
|
||||
}
|
||||
}
|
||||
else if (fastcmp(field,"mustrack"))
|
||||
lua_pushinteger(L, header->mustrack);
|
||||
else if (fastcmp(field,"muspos"))
|
||||
lua_pushinteger(L, header->muspos);
|
||||
else if (fastcmp(field,"musname_size"))
|
||||
lua_pushinteger(L, header->musname_size);
|
||||
else if (fastcmp(field,"weather"))
|
||||
lua_pushinteger(L, header->weather);
|
||||
else if (fastcmp(field,"skytexture"))
|
||||
|
|
|
|||
|
|
@ -309,6 +309,9 @@ int LUA_PushGlobals(lua_State *L, const char *word)
|
|||
} else if (fastcmp(word,"mapmusposition")) {
|
||||
lua_pushinteger(L, mapmusposition);
|
||||
return 1;
|
||||
} else if (fastcmp(word,"mapmusrng")) {
|
||||
lua_pushinteger(L, mapmusrng);
|
||||
return 1;
|
||||
// local player variables, by popular request
|
||||
} else if (fastcmp(word,"consoleplayer")) { // player controlling console (aka local player 1)
|
||||
if (!addedtogame || consoleplayer < 0 || !playeringame[consoleplayer])
|
||||
|
|
@ -429,6 +432,8 @@ int LUA_WriteGlobals(lua_State *L, const char *word)
|
|||
}
|
||||
else if (fastcmp(word, "mapmusflags"))
|
||||
mapmusflags = (UINT16)luaL_checkinteger(L, 2);
|
||||
else if (fastcmp(word, "mapmusrng"))
|
||||
mapmusrng = (UINT8)luaL_checkinteger(L, 2);
|
||||
// SRB2Kart
|
||||
else if (fastcmp(word,"racecountdown"))
|
||||
racecountdown = (tic_t)luaL_checkinteger(L, 2);
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ UINT8 P_RandomByteD(const char *rfile, INT32 rline, pr_class_t pr_class)
|
|||
* NOTE: Maximum range is 65536.
|
||||
*
|
||||
* \param a Number of items in array.
|
||||
* \return A random integer from [0,a].
|
||||
* \return A random integer from [0,a).
|
||||
* \sa __internal_prng__
|
||||
*/
|
||||
#ifndef DEBUGRANDOM
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ typedef enum
|
|||
PR_RANDOMSKIN, // Random skin select from Heavy Magician(?)
|
||||
|
||||
PR_RULESCRAMBLE, // Rule scrambing events
|
||||
|
||||
PR_MUSICSELECT, // Randomized music selection
|
||||
|
||||
PR_ITEM_ROULETTE, // Item results
|
||||
PR_ITEM_RINGS, // Flung ring/bumper/player (on death)
|
||||
|
|
|
|||
|
|
@ -4881,6 +4881,8 @@ static void P_NetArchiveMisc(savebuffer_t *save, boolean resending)
|
|||
}
|
||||
|
||||
WRITEUINT8(save->p, encoremode);
|
||||
|
||||
WRITEUINT8(save->p, mapmusrng);
|
||||
|
||||
WRITEUINT32(save->p, leveltime);
|
||||
WRITEINT16(save->p, lastmap);
|
||||
|
|
@ -5045,6 +5047,8 @@ static inline boolean P_NetUnArchiveMisc(savebuffer_t *save, boolean reloading)
|
|||
}
|
||||
|
||||
encoremode = (boolean)READUINT8(save->p);
|
||||
|
||||
mapmusrng = READUINT8(save->p);
|
||||
|
||||
if (!P_LoadLevel(true, reloading))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
#include "k_director.h" // K_InitDirector
|
||||
#include "k_specialstage.h"
|
||||
#include "acs/interface.h"
|
||||
#include "doomstat.h" // MAXMUSNAMES
|
||||
|
||||
// Replay names have time
|
||||
#if !defined (UNDER_CE)
|
||||
|
|
@ -378,6 +379,8 @@ void P_DeleteFlickies(INT16 i)
|
|||
*/
|
||||
static void P_ClearSingleMapHeaderInfo(INT16 num)
|
||||
{
|
||||
UINT8 i = 0;
|
||||
|
||||
mapheaderinfo[num]->lvlttl[0] = '\0';
|
||||
mapheaderinfo[num]->subttl[0] = '\0';
|
||||
mapheaderinfo[num]->zonttl[0] = '\0';
|
||||
|
|
@ -385,10 +388,11 @@ static void P_ClearSingleMapHeaderInfo(INT16 num)
|
|||
mapheaderinfo[num]->typeoflevel = 0;
|
||||
mapheaderinfo[num]->gravity = DEFAULT_GRAVITY;
|
||||
mapheaderinfo[num]->keywords[0] = '\0';
|
||||
sprintf(mapheaderinfo[num]->musname, "%.5sM", G_BuildMapName(num+1));
|
||||
mapheaderinfo[num]->musname[6] = 0;
|
||||
for (i = 0; i < MAXMUSNAMES; i++)
|
||||
mapheaderinfo[num]->musname[i][0] = 0;
|
||||
mapheaderinfo[num]->mustrack = 0;
|
||||
mapheaderinfo[num]->muspos = 0;
|
||||
mapheaderinfo[num]->musname_size = 0;
|
||||
mapheaderinfo[num]->weather = PRECIP_NONE;
|
||||
snprintf(mapheaderinfo[num]->skytexture, 5, "SKY1");
|
||||
mapheaderinfo[num]->skytexture[4] = 0;
|
||||
|
|
@ -7636,10 +7640,9 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
|
|||
S_StartSound(NULL, sfx_s3k73);
|
||||
}
|
||||
|
||||
// As oddly named as this is, this handles music only.
|
||||
// We should be fine starting it here.
|
||||
// We should be fine starting music here.
|
||||
// Don't do this during titlemap, because the menu code handles music by itself.
|
||||
S_Start();
|
||||
S_InitLevelMusic(fromnetsave);
|
||||
}
|
||||
|
||||
if (gametyperules & GTR_SPECIALSTART)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "lua_hook.h" // MusicChange hook
|
||||
#include "byteptr.h"
|
||||
#include "k_menu.h" // M_PlayMenuJam
|
||||
#include "m_random.h" // P_RandomKey
|
||||
|
||||
#ifdef HW3SOUND
|
||||
// 3D Sound Interface
|
||||
|
|
@ -2425,13 +2426,19 @@ boolean S_FadeOutStopMusic(UINT32 ms)
|
|||
// Kills playing sounds at start of level,
|
||||
// determines music if any, changes music.
|
||||
//
|
||||
void S_StartEx(boolean reset)
|
||||
void S_InitLevelMusic(boolean fromnetsave)
|
||||
{
|
||||
(void)reset;
|
||||
|
||||
if (mapmusflags & MUSIC_RELOADRESET)
|
||||
{
|
||||
strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7);
|
||||
if (!fromnetsave)
|
||||
{
|
||||
if (mapheaderinfo[gamemap-1]->musname_size > 1)
|
||||
mapmusrng = P_RandomKey(PR_MUSICSELECT, mapheaderinfo[gamemap-1]->musname_size);
|
||||
else
|
||||
mapmusrng = 0;
|
||||
}
|
||||
strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname[mapmusrng], 7);
|
||||
mapmusname[6] = 0;
|
||||
mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK);
|
||||
mapmusposition = mapheaderinfo[gamemap-1]->muspos;
|
||||
|
|
@ -2514,7 +2521,7 @@ static void Command_Tunes_f(void)
|
|||
}
|
||||
else if (!strcasecmp(tunearg, "-default"))
|
||||
{
|
||||
tunearg = mapheaderinfo[gamemap-1]->musname;
|
||||
tunearg = mapheaderinfo[gamemap-1]->musname[0];
|
||||
track = mapheaderinfo[gamemap-1]->mustrack;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,8 +123,7 @@ void S_InitSfxChannels(INT32 sfxVolume);
|
|||
//
|
||||
void S_StopSounds(void);
|
||||
void S_ClearSfx(void);
|
||||
void S_StartEx(boolean reset);
|
||||
#define S_Start() S_StartEx(false)
|
||||
void S_InitLevelMusic(boolean reset);
|
||||
|
||||
//
|
||||
// Basically a W_GetNumForName that adds "ds" at the beginning of the string. Returns a lumpnum.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue