From 913e26b1ae565158cf08e337b8910e1a9e01663d Mon Sep 17 00:00:00 2001 From: TimeServ Date: Sun, 7 May 2006 20:57:30 +0000 Subject: [PATCH] musicvolume uses callback, cosmetic fix to qclib, disabled sw r_drawflat until there's a solution to make it like gl's r_drawflat git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2250 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cd_linux.c | 37 ++++++++++++++++++----------------- engine/client/cd_sdl.c | 35 ++++++++++++++++----------------- engine/client/cd_win.c | 41 +++++++++++++++++++-------------------- engine/client/cl_main.c | 12 ++++++++++++ engine/qclib/qcc_pr_lex.c | 4 ++-- engine/sw/d_edge.c | 20 ------------------- engine/sw/d_iface.h | 1 - engine/sw/r_local.h | 1 - 8 files changed, 70 insertions(+), 81 deletions(-) diff --git a/engine/client/cd_linux.c b/engine/client/cd_linux.c index c08e24cde..d0bd38c89 100644 --- a/engine/client/cd_linux.c +++ b/engine/client/cd_linux.c @@ -46,7 +46,6 @@ static qboolean wasPlaying = false; static qboolean initialized = false; static qboolean enabled = true; static qboolean playLooping = false; -static float cdvolume; static qbyte remap[100]; static qbyte playTrack; static qbyte maxTrack; @@ -160,7 +159,7 @@ void CDAudio_Play(int track, qboolean looping) playTrack = track; playing = true; - if (cdvolume == 0.0) + if (!bgmvolume.value) CDAudio_Pause (); } @@ -330,6 +329,21 @@ static void CD_f (void) } } +void BGMVolume_Callback(struct cvar_s *var, char *oldvalue) +{ + int cdvolume; + + if (!enabled) + return; + + cdvolume = atof(oldvalue); + + if (cdvolume && !var->value) + CDAudio_Pause (); + else if (!cdvolume && var->value) + CDAudio_Resume (); +} + void CDAudio_Update(void) { struct cdrom_subchnl subchnl; @@ -338,22 +352,6 @@ void CDAudio_Update(void) if (!enabled) return; - if (bgmvolume.value != cdvolume) - { - if (cdvolume) - { - Cvar_SetValue (&bgmvolume, 0.0); - cdvolume = bgmvolume.value; - CDAudio_Pause (); - } - else - { - Cvar_SetValue (&bgmvolume, 1.0); - cdvolume = bgmvolume.value; - CDAudio_Resume (); - } - } - if (playing && lastchk < time(NULL)) { lastchk = time(NULL) + 2; //two seconds between chks subchnl.cdsc_format = CDROM_MSF; @@ -407,6 +405,8 @@ int CDAudio_Init(void) Cmd_AddCommand ("cd", CD_f); + Cvar_Hook(&bgmvolume, BGMVolume_Callback); + Con_Printf("CD Audio Initialized\n"); return 0; @@ -420,5 +420,6 @@ void CDAudio_Shutdown(void) CDAudio_Stop(); close(cdfile); cdfile = -1; + Cvar_Unhook(&bgmvolume); } #endif diff --git a/engine/client/cd_sdl.c b/engine/client/cd_sdl.c index 420a2fd31..d5ab48bf5 100644 --- a/engine/client/cd_sdl.c +++ b/engine/client/cd_sdl.c @@ -10,7 +10,6 @@ static qboolean wasPlaying = false; static qboolean initialized = false; static qboolean enabled = false; static qboolean playLooping = false; -static float cdvolume; static qbyte remap[100]; static qbyte playTrack; static qbyte maxTrack; @@ -90,7 +89,7 @@ void CDAudio_Play(int track, qboolean looping) playTrack = track; playing = true; - if (cdvolume == 0.0) + if (!bgmvolume.value) CDAudio_Pause (); return; @@ -306,26 +305,23 @@ LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } */ -void CDAudio_Update(void) +void BGMVolume_Callback(struct cvar_s *var, char *oldvalue) { + int cdvolume; + if (!enabled) return; - if (bgmvolume.value != cdvolume) - { - if (cdvolume) - { - Cvar_SetValue (&bgmvolume, 0.0); - cdvolume = bgmvolume.value; - CDAudio_Pause (); - } - else - { - Cvar_SetValue (&bgmvolume, 1.0); - cdvolume = bgmvolume.value; - CDAudio_Resume (); - } - } + cdvolume = atof(oldvalue); + + if (cdvolume && !var->value) + CDAudio_Pause (); + else if (!cdvolume && var->value) + CDAudio_Resume (); +} + +void CDAudio_Update(void) +{ } @@ -369,6 +365,7 @@ int CDAudio_Init(void) Cmd_AddCommand ("cd", CD_f); + Cvar_Hook(&bgmvolume, BGMVolume_Callback); // Con_Printf("CD Audio Initialized\n"); return 0; @@ -384,4 +381,6 @@ void CDAudio_Shutdown(void) SDL_CDClose(cddevice); cddevice = NULL; initialized = false; + + Cvar_Unhook(&bgmvolume); } diff --git a/engine/client/cd_win.c b/engine/client/cd_win.c index 96ab0a8d6..2cca4d18f 100644 --- a/engine/client/cd_win.c +++ b/engine/client/cd_win.c @@ -36,7 +36,6 @@ static qboolean wasPlaying = false; static qboolean initialized = false; static qboolean enabled = false; static qboolean playLooping = false; -static float cdvolume; static qbyte remap[100]; static qbyte playTrack; static qbyte maxTrack; @@ -189,7 +188,7 @@ void CDAudio_Play(int track, qboolean looping) playTrack = track; playing = true; - if (cdvolume == 0.0) + if (!bgmvolume.value) CDAudio_Pause (); return; @@ -250,7 +249,7 @@ void CDAudio_Resume(void) if (!wasPlaying) return; - if (!cdvolume) + if (!bgmvolume.value) return; mciPlayParms.dwFrom = MCI_MAKE_TMSF(playTrack, 0, 0, 0); @@ -379,7 +378,7 @@ static void CD_f (void) Con_Printf("Currently %s track %u\n", playLooping ? "looping" : "playing", playTrack); else if (wasPlaying) Con_Printf("Paused %s track %u\n", playLooping ? "looping" : "playing", playTrack); - Con_Printf("Volume is %f\n", cdvolume); + Con_Printf("Volume is %f\n", bgmvolume.value); return; } } @@ -418,27 +417,24 @@ LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return 0; } - -void CDAudio_Update(void) +void BGMVolume_Callback(struct cvar_s *var, char *oldvalue) { + int cdvolume; + if (!enabled) return; - if (bgmvolume.value != cdvolume) - { - if (cdvolume) - { - Cvar_SetValue (&bgmvolume, 0.0); - cdvolume = bgmvolume.value; - CDAudio_Pause (); - } - else - { - Cvar_SetValue (&bgmvolume, 1.0); - cdvolume = bgmvolume.value; - CDAudio_Resume (); - } - } + cdvolume = atof(oldvalue); + + if (cdvolume && !var->value) + CDAudio_Pause (); + else if (!cdvolume && var->value) + CDAudio_Resume (); +} + +void CDAudio_Update(void) +{ + } @@ -489,6 +485,7 @@ int CDAudio_Init(void) Cmd_AddCommand ("cd", CD_f); + Cvar_Hook(&bgmvolume, BGMVolume_Callback); // Con_Printf("CD Audio Initialized\n"); return 0; @@ -502,4 +499,6 @@ void CDAudio_Shutdown(void) CDAudio_Stop(); if (mciSendCommand(wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD_PTR)NULL)) Con_DPrintf("CDAudio_Shutdown: MCI_CLOSE failed\n"); + + Cvar_Unhook(&bgmvolume); } diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 3766feb53..bfded7b33 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -90,6 +90,8 @@ cvar_t r_drawflame = SCVAR("r_drawflame", "1"); static qboolean allowremotecmd = true; +extern int total_loading_size, current_loading_size, loading_stage; + // // info mirrors // @@ -2080,6 +2082,11 @@ client_connect: //fixme: make function cls.state = ca_connected; Con_TPrintf (TLC_CONNECTED); allowremotecmd = false; // localid required now for remote cmds + + total_loading_size = 100; + current_loading_size = 0; + loading_stage = 2; + return; } // remote command from gui front end @@ -2225,6 +2232,11 @@ void CLNQ_ConnectionlessPacket(void) cls.protocol = CP_NETQUAKE; cls.state = ca_connected; Con_TPrintf (TLC_CONNECTED); + + total_loading_size = 100; + current_loading_size = 0; + loading_stage = 2; + allowremotecmd = false; // localid required now for remote cmds //send a dummy packet. diff --git a/engine/qclib/qcc_pr_lex.c b/engine/qclib/qcc_pr_lex.c index 8c0739ef9..d2fc8b713 100644 --- a/engine/qclib/qcc_pr_lex.c +++ b/engine/qclib/qcc_pr_lex.c @@ -2399,13 +2399,13 @@ void QCC_PR_PrintScope (void) if (pr_scope) { if (errorscope != pr_scope) - printf ("in function %s (line %i)\n", pr_scope->name, pr_scope->s_line); + printf ("in function %s (line %i),\n", pr_scope->name, pr_scope->s_line); errorscope = pr_scope; } else { if (errorscope) - printf ("at global scope\n"); + printf ("at global scope,\n"); errorscope = NULL; } } diff --git a/engine/sw/d_edge.c b/engine/sw/d_edge.c index 460a4689a..6f8347ca6 100644 --- a/engine/sw/d_edge.c +++ b/engine/sw/d_edge.c @@ -231,26 +231,6 @@ void D_DrawSurfaces (void) D_DrawZSpans (s->spans); } } -// TODO: could preset a lot of this at mode set time - else if (r_drawflat.value) - { - for (s = &surfaces[1] ; sspans) - continue; - - d_zistepu = s->d_zistepu; - d_zistepv = s->d_zistepv; - d_ziorigin = s->d_ziorigin; - -#ifdef __alpha__ - D_DrawSolidSurface (s, (int)((long)s->data & 0xFF)); -#else - D_DrawSolidSurface (s, (int)s->data & 0xFF); -#endif - D_DrawZSpans (s->spans); - } - } else { for (s = &surfaces[1] ; s