mirror of
				https://github.com/KartKrewDev/RingRacers.git
				synced 2025-10-30 08:01:28 +00:00 
			
		
		
		
	commit 8d382e49fb3411cad1a3ef5ee1e546030c3a9d93
Author: James R <justsomejames2@gmail.com>
Date:   Tue Nov 17 04:14:45 2020 -0800
    Big Large Lua Hooklib Refactor
    * Hooks are no longer a mess of lua boiler plate. Helper functions reduce hooks
      to, at the most basic level, only two calls.
    * Lua tables (the array part) are used to index hooks. Such tables contain only
      hooks of the same type.
    * Hook types are defined in one place so you no longer need to sync up the enum
      and name array.
commit 3f7c2ae0b0c450cb8993ffe7664ead05fd9f5000
Author: James R <justsomejames2@gmail.com>
Date:   Thu Dec 10 05:39:53 2020 -0800
    Avoid using multiple tables to fetch hook
    String hooks still use a table to fetch the id, but the id indexes a C array.
    Also I fixed a missing call in the MusicChange hook.
commit dbd8903a538e7b87061795ce27ec5c72c26743af
Author: James R <justsomejames2@gmail.com>
Date:   Thu Dec 10 08:50:23 2020 -0800
    Use ref for pushing error handler
commit 9ddeb5f5896de0407b2b6fce8c949295a9e6d5e4
Author: James R <justsomejames2@gmail.com>
Date:   Sat Dec 12 02:05:21 2020 -0800
    Resolve GameQuit hook conflicts
commit 93e4f43e4b3a24fc2d8032e8730cbf427e75b297
Author: James R <justsomejames2@gmail.com>
Date:   Sat Dec 12 03:06:57 2020 -0800
    Hooklib macros names -> uppercase + documentation
commit 80fe39bbd1433c91131d2cdb36ba709f37d3b5f3
Author: Steel Titanium <steeltitanium1@gmail.com>
Date:   Mon May 3 01:40:02 2021 -0400
    Fix MusicChange hook not returning some values correctly
commit 46ca9613c68422a26910cbb034a9f3e004a967c3
Author: James R <justsomejames2@gmail.com>
Date:   Thu Jun 10 18:09:39 2021 -0700
    Pop hook id fetched from table
commit a75d4a1c360874a3c301a494e38ea49cd89b6616
Author: James R <justsomejames2@gmail.com>
Date:   Tue Jul 6 18:42:08 2021 -0700
    Automatically count hook values
commit 331329306cad257d52f84e47a92d9214d9eaa8d3
Author: James R <justsomejames2@gmail.com>
Date:   Tue Jul 6 19:12:47 2021 -0700
    Refactor hook ref allocation
commit ae57b6ca8664e00ff4d9544339dbf29a41138040
Author: James R <justsomejames2@gmail.com>
Date:   Tue Jul 6 20:23:38 2021 -0700
    MORE MACROS
    I just can't stop myself!
commit b4fa98d2fbab180f487ce3efedb8ab715e5f3390
Author: James R <justsomejames2@gmail.com>
Date:   Wed Jul 7 00:23:51 2021 -0700
    Refactor hudlib hooks to hooklib
    HUD hooks now meet the standard of hooklib. HUD registry
    magic numbers are gone.
    HUD hooks may also be added using addHook.
        addHook('HUD', fn[, type])
    hud.add still exists, but the intention is to remove it
    eventually.
commit cb619fad5d762ba8d8dd20e9a979a04ced7c943f
Author: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com>
Date:   Wed Jul 7 19:57:28 2021 -0500
    Rebase on !1307
commit f271f88c7f3084523a03ca7f47060d6527724796
Author: LJ Sonic <lamr@free.fr>
Date:   Sun Dec 5 17:59:33 2021 +0100
    Fix MusicChange hook crashing when called
    BRUH MOMENT BRUH MOMENT
    PREPARE THE HALL OF SHAME
commit 0a0c17da7c793ec29e80c5bdaa66b02da0884078
Author: James R <justsomejames2@gmail.com>
Date:   Tue Feb 1 02:27:27 2022 -0800
    PARANOIA: I_Error if mobj hook is called with MT_NULL
commit 86336d6bed80bee6f8168078aa8856109091e50f
Author: katsy <katmint@live.com>
Date:   Mon Mar 7 18:33:15 2022 -0600
    remove MODID check from hooklib to fix compile issue
		
	
			
		
			
				
	
	
		
			330 lines
		
	
	
	
		
			8 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			330 lines
		
	
	
	
		
			8 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
// SONIC ROBO BLAST 2
 | 
						|
//-----------------------------------------------------------------------------
 | 
						|
// Copyright (C) 1993-1996 by id Software, Inc.
 | 
						|
// Copyright (C) 1998-2000 by DooM Legacy Team.
 | 
						|
// Copyright (C) 1999-2020 by Sonic Team Junior.
 | 
						|
//
 | 
						|
// This program is free software distributed under the
 | 
						|
// terms of the GNU General Public License, version 2.
 | 
						|
// See the 'LICENSE' file for more details.
 | 
						|
//-----------------------------------------------------------------------------
 | 
						|
/// \file  s_sound.h
 | 
						|
/// \brief The not so system specific sound interface
 | 
						|
 | 
						|
#ifndef __S_SOUND__
 | 
						|
#define __S_SOUND__
 | 
						|
 | 
						|
#include "i_sound.h" // musictype_t
 | 
						|
#include "sounds.h"
 | 
						|
#include "m_fixed.h"
 | 
						|
#include "command.h"
 | 
						|
#include "tables.h" // angle_t
 | 
						|
 | 
						|
#ifdef HAVE_OPENMPT
 | 
						|
#include "libopenmpt/libopenmpt.h"
 | 
						|
extern openmpt_module *openmpt_mhandle;
 | 
						|
#endif
 | 
						|
 | 
						|
// mask used to indicate sound origin is player item pickup
 | 
						|
#define PICKUP_SOUND 0x8000
 | 
						|
 | 
						|
//
 | 
						|
#define SOUND_VOLUME_RANGE 256
 | 
						|
#define MAX_SOUND_VOLUME 255
 | 
						|
 | 
						|
#define DEFAULT_MUSICDEF_VOLUME ( 100 / VOLUME_DIVIDER )
 | 
						|
 | 
						|
extern consvar_t stereoreverse;
 | 
						|
extern consvar_t cv_soundvolume, cv_closedcaptioning, cv_digmusicvolume; 
 | 
						|
 | 
						|
extern consvar_t surround;
 | 
						|
extern consvar_t cv_numChannels;
 | 
						|
 | 
						|
extern consvar_t cv_gamedigimusic;
 | 
						|
 | 
						|
extern consvar_t cv_gamesounds;
 | 
						|
extern consvar_t cv_playmusicifunfocused;
 | 
						|
extern consvar_t cv_playsoundifunfocused;
 | 
						|
 | 
						|
extern consvar_t cv_music_resync_threshold;
 | 
						|
extern consvar_t cv_music_resync_powerups_only;
 | 
						|
 | 
						|
#ifdef HAVE_OPENMPT
 | 
						|
extern consvar_t cv_modfilter;
 | 
						|
#endif
 | 
						|
 | 
						|
extern CV_PossibleValue_t soundvolume_cons_t[];
 | 
						|
 | 
						|
typedef enum
 | 
						|
{
 | 
						|
	SF_TOTALLYSINGLE =  1, // Only play one of these sounds at a time...GLOBALLY
 | 
						|
	SF_NOMULTIPLESOUND =  2, // Like SF_NOINTERRUPT, but doesnt care what the origin is
 | 
						|
	SF_OUTSIDESOUND  =  4, // Volume is adjusted depending on how far away you are from 'outside'
 | 
						|
	SF_X4AWAYSOUND   =  8, // Hear it from 4x the distance away
 | 
						|
	SF_X8AWAYSOUND   = 16, // Hear it from 8x the distance away
 | 
						|
	SF_NOINTERRUPT   = 32, // Only play this sound if it isn't already playing on the origin
 | 
						|
	SF_X2AWAYSOUND   = 64, // Hear it from 2x the distance away
 | 
						|
} soundflags_t;
 | 
						|
 | 
						|
typedef struct {
 | 
						|
	fixed_t x, y, z;
 | 
						|
	angle_t angle;
 | 
						|
} listener_t;
 | 
						|
 | 
						|
typedef struct
 | 
						|
{
 | 
						|
	// sound information (if null, channel avail.)
 | 
						|
	sfxinfo_t *sfxinfo;
 | 
						|
 | 
						|
	// origin of sound
 | 
						|
	const void *origin;
 | 
						|
 | 
						|
	// initial volume of sound, which is applied after distance and direction
 | 
						|
	INT32 volume;
 | 
						|
 | 
						|
	// handle of the sound being played
 | 
						|
	INT32 handle;
 | 
						|
 | 
						|
} channel_t;
 | 
						|
 | 
						|
typedef struct {
 | 
						|
	channel_t *c;
 | 
						|
	sfxinfo_t *s;
 | 
						|
	UINT16 t;
 | 
						|
	UINT8 b;
 | 
						|
} caption_t;
 | 
						|
 | 
						|
#define NUMCAPTIONS 8
 | 
						|
#define MAXCAPTIONTICS (2*TICRATE)
 | 
						|
#define CAPTIONFADETICS 20
 | 
						|
 | 
						|
extern caption_t closedcaptions[NUMCAPTIONS];
 | 
						|
void S_StartCaption(sfxenum_t sfx_id, INT32 cnum, UINT16 lifespan);
 | 
						|
void S_ResetCaptions(void);
 | 
						|
 | 
						|
// register sound vars and commands at game startup
 | 
						|
void S_RegisterSoundStuff(void);
 | 
						|
 | 
						|
//
 | 
						|
// Initializes sound stuff, including volume
 | 
						|
// Sets channels, SFX, allocates channel buffer, sets S_sfx lookup.
 | 
						|
//
 | 
						|
void S_InitSfxChannels(INT32 sfxVolume);
 | 
						|
 | 
						|
//
 | 
						|
// Per level startup code.
 | 
						|
// Kills playing sounds at start of level, determines music if any, changes music.
 | 
						|
//
 | 
						|
void S_StopSounds(void);
 | 
						|
void S_ClearSfx(void);
 | 
						|
void S_StartEx(boolean reset);
 | 
						|
#define S_Start() S_StartEx(false)
 | 
						|
 | 
						|
//
 | 
						|
// Basically a W_GetNumForName that adds "ds" at the beginning of the string. Returns a lumpnum.
 | 
						|
//
 | 
						|
lumpnum_t S_GetSfxLumpNum(sfxinfo_t *sfx);
 | 
						|
 | 
						|
//
 | 
						|
// Sound Status
 | 
						|
//
 | 
						|
 | 
						|
boolean S_SoundDisabled(void);
 | 
						|
 | 
						|
//
 | 
						|
// Start sound for thing at <origin> using <sound_id> from sounds.h
 | 
						|
//
 | 
						|
void S_StartSound(const void *origin, sfxenum_t sound_id);
 | 
						|
 | 
						|
// Will start a sound at a given volume.
 | 
						|
void S_StartSoundAtVolume(const void *origin, sfxenum_t sound_id, INT32 volume);
 | 
						|
 | 
						|
// Stop sound for thing at <origin>
 | 
						|
void S_StopSound(void *origin);
 | 
						|
 | 
						|
//
 | 
						|
// Music Status
 | 
						|
//
 | 
						|
 | 
						|
boolean S_DigMusicDisabled(void);
 | 
						|
boolean S_MusicDisabled(void);
 | 
						|
boolean S_MusicPlaying(void);
 | 
						|
boolean S_MusicPaused(void);
 | 
						|
boolean S_MusicNotInFocus(void);
 | 
						|
musictype_t S_MusicType(void);
 | 
						|
const char *S_MusicName(void);
 | 
						|
 | 
						|
boolean S_MusicExists(const char *mname);
 | 
						|
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping);
 | 
						|
 | 
						|
 | 
						|
//
 | 
						|
// Music Effects
 | 
						|
//
 | 
						|
 | 
						|
// Set Speed of Music
 | 
						|
boolean S_SpeedMusic(float speed);
 | 
						|
 | 
						|
// Music credits
 | 
						|
typedef struct musicdef_s
 | 
						|
{
 | 
						|
	char name[7];
 | 
						|
	//char usage[256];
 | 
						|
	char source[256];
 | 
						|
	int volume;
 | 
						|
	struct musicdef_s *next;
 | 
						|
} musicdef_t;
 | 
						|
 | 
						|
extern struct cursongcredit
 | 
						|
{
 | 
						|
	musicdef_t *def;
 | 
						|
	UINT16 anim;
 | 
						|
	UINT8 trans;
 | 
						|
	fixed_t x;
 | 
						|
	fixed_t old_x;
 | 
						|
} cursongcredit;
 | 
						|
 | 
						|
extern musicdef_t *musicdefstart;
 | 
						|
extern int musicdef_volume;
 | 
						|
 | 
						|
void S_LoadMusicDefs(UINT16 wadnum);
 | 
						|
void S_InitMusicDefs(void);
 | 
						|
void S_ShowMusicCredit(void);
 | 
						|
 | 
						|
//
 | 
						|
// Music Seeking
 | 
						|
//
 | 
						|
 | 
						|
// Get Length of Music
 | 
						|
UINT32 S_GetMusicLength(void);
 | 
						|
 | 
						|
// Set LoopPoint of Music
 | 
						|
boolean S_SetMusicLoopPoint(UINT32 looppoint);
 | 
						|
 | 
						|
// Get LoopPoint of Music
 | 
						|
UINT32 S_GetMusicLoopPoint(void);
 | 
						|
 | 
						|
// Set Position of Music
 | 
						|
boolean S_SetMusicPosition(UINT32 position);
 | 
						|
 | 
						|
// Get Position of Music
 | 
						|
UINT32 S_GetMusicPosition(void);
 | 
						|
 | 
						|
//
 | 
						|
// Music Stacking (Jingles)
 | 
						|
//
 | 
						|
 | 
						|
typedef struct musicstack_s
 | 
						|
{
 | 
						|
	char musname[7];
 | 
						|
	UINT16 musflags;
 | 
						|
	boolean looping;
 | 
						|
	UINT32 position;
 | 
						|
	tic_t tic;
 | 
						|
	UINT16 status;
 | 
						|
	lumpnum_t mlumpnum;
 | 
						|
	boolean noposition; // force music stack resuming from zero (like music_stack_noposition)
 | 
						|
 | 
						|
    struct musicstack_s *prev;
 | 
						|
    struct musicstack_s *next;
 | 
						|
} musicstack_t;
 | 
						|
 | 
						|
extern char music_stack_nextmusname[7];
 | 
						|
extern boolean music_stack_noposition;
 | 
						|
extern UINT32 music_stack_fadeout;
 | 
						|
extern UINT32 music_stack_fadein;
 | 
						|
 | 
						|
void S_SetStackAdjustmentStart(void);
 | 
						|
void S_AdjustMusicStackTics(void);
 | 
						|
void S_RetainMusic(const char *mname, UINT16 mflags, boolean looping, UINT32 position, UINT16 status);
 | 
						|
boolean S_RecallMusic(UINT16 status, boolean fromfirst);
 | 
						|
 | 
						|
//
 | 
						|
// Music Playback
 | 
						|
//
 | 
						|
 | 
						|
/* this is for the sake of the hook */
 | 
						|
struct MusicChange {
 | 
						|
	char    * newname;
 | 
						|
	UINT16  * mflags;
 | 
						|
	boolean * looping;
 | 
						|
	UINT32  * position;
 | 
						|
	UINT32  * prefadems;
 | 
						|
	UINT32  * fadeinms;
 | 
						|
};
 | 
						|
 | 
						|
enum
 | 
						|
{
 | 
						|
	MUS_SPECIAL = 1,/* powerups--invincibility, grow */
 | 
						|
};
 | 
						|
 | 
						|
// Start music track, arbitrary, given its name, and set whether looping
 | 
						|
// note: music flags 12 bits for tracknum (gme, other formats with more than one track)
 | 
						|
//       13-15 aren't used yet
 | 
						|
//       and the last bit we ignore (internal game flag for resetting music on reload)
 | 
						|
void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms);
 | 
						|
#define S_ChangeMusicInternal(a,b) S_ChangeMusicEx(a,0,b,0,0,0)
 | 
						|
#define S_ChangeMusic(a,b,c) S_ChangeMusicEx(a,b,c,0,0,0)
 | 
						|
 | 
						|
void S_ChangeMusicSpecial (const char *mmusic);
 | 
						|
 | 
						|
void S_SetRestoreMusicFadeInCvar (consvar_t *cvar);
 | 
						|
#define S_ClearRestoreMusicFadeInCvar() \
 | 
						|
	S_SetRestoreMusicFadeInCvar(0)
 | 
						|
int  S_GetRestoreMusicFadeIn (void);
 | 
						|
 | 
						|
void S_SetMusicUsage (int type);
 | 
						|
int  S_MusicUsage (void);
 | 
						|
 | 
						|
// Stops the music.
 | 
						|
void S_StopMusic(void);
 | 
						|
 | 
						|
// Stop and resume music, during game PAUSE.
 | 
						|
void S_PauseAudio(void);
 | 
						|
void S_ResumeAudio(void);
 | 
						|
 | 
						|
// Enable and disable sound effects
 | 
						|
void S_EnableSound(void);
 | 
						|
void S_DisableSound(void);
 | 
						|
 | 
						|
//
 | 
						|
// Music Fading
 | 
						|
//
 | 
						|
 | 
						|
void S_SetInternalMusicVolume(INT32 volume);
 | 
						|
void S_StopFadingMusic(void);
 | 
						|
boolean S_FadeMusicFromVolume(UINT8 target_volume, INT16 source_volume, UINT32 ms);
 | 
						|
#define S_FadeMusic(a, b) S_FadeMusicFromVolume(a, -1, b)
 | 
						|
#define S_FadeInChangeMusic(a,b,c,d) S_ChangeMusicEx(a,b,c,0,0,d)
 | 
						|
boolean S_FadeOutStopMusic(UINT32 ms);
 | 
						|
 | 
						|
//
 | 
						|
// Updates music & sounds
 | 
						|
//
 | 
						|
void S_UpdateSounds(void);
 | 
						|
void S_UpdateClosedCaptions(void);
 | 
						|
 | 
						|
FUNCMATH fixed_t S_CalculateSoundDistance(fixed_t px1, fixed_t py1, fixed_t pz1, fixed_t px2, fixed_t py2, fixed_t pz2);
 | 
						|
 | 
						|
INT32 S_GetSoundVolume(sfxinfo_t *sfx, INT32 volume);
 | 
						|
 | 
						|
void S_SetSfxVolume(INT32 volume);
 | 
						|
void S_SetMusicVolume(INT32 digvolume);
 | 
						|
#define S_SetDigMusicVolume S_SetMusicVolume
 | 
						|
#define S_InitMusicVolume() S_SetMusicVolume(-1)
 | 
						|
 | 
						|
INT32 S_OriginPlaying(void *origin);
 | 
						|
INT32 S_IdPlaying(sfxenum_t id);
 | 
						|
INT32 S_SoundPlaying(void *origin, sfxenum_t id);
 | 
						|
 | 
						|
void S_StartSoundName(void *mo, const  char *soundname);
 | 
						|
 | 
						|
void S_StopSoundByID(void *origin, sfxenum_t sfx_id);
 | 
						|
void S_StopSoundByNum(sfxenum_t sfxnum);
 | 
						|
 | 
						|
#ifndef HW3SOUND
 | 
						|
#define S_StartAttackSound S_StartSound
 | 
						|
#define S_StartScreamSound S_StartSound
 | 
						|
#endif
 | 
						|
 | 
						|
#endif
 |