From 8cfbc1ad26474ef691df4f22888b9dccd73f595f Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 27 Jul 2015 08:21:34 +0000 Subject: [PATCH] Fix some of my breakages. fix hexen2 blind monsters. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4949 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_cg.c | 2 +- engine/client/cl_main.c | 5 ++- engine/client/cl_parse.c | 16 ++++--- engine/client/cl_screen.c | 4 +- engine/client/cl_tent.c | 82 ++++++++++++++++----------------- engine/client/client.h | 2 +- engine/client/keys.c | 14 +++--- engine/client/m_mp3.c | 12 ++++- engine/client/m_options.c | 2 +- engine/client/menu.c | 2 +- engine/client/menu.h | 2 +- engine/client/p_script.c | 2 +- engine/client/pr_csqc.c | 32 ++++++------- engine/client/pr_menu.c | 16 +++++-- engine/client/snd_dma.c | 89 ++++++++++++++++++------------------ engine/client/snd_ov.c | 23 +++++----- engine/client/sound.h | 12 +++-- engine/common/protocol.h | 4 +- engine/common/world.h | 2 +- engine/gl/gl_shader.c | 8 +++- engine/gl/gl_vidcommon.c | 6 +-- engine/nacl/sys_ppapi.c | 3 ++ engine/server/pr_cmds.c | 26 +++++------ engine/server/pr_q1qvm.c | 95 ++++++++++++++++++++++++++------------- engine/server/savegame.c | 4 ++ engine/server/server.h | 4 +- engine/server/sv_ccmds.c | 4 ++ engine/server/sv_phys.c | 6 +-- engine/server/sv_send.c | 26 ++++------- engine/server/sv_user.c | 16 ++++++- 30 files changed, 307 insertions(+), 214 deletions(-) diff --git a/engine/client/cl_cg.c b/engine/client/cl_cg.c index 4e359943c..e2a448a4b 100644 --- a/engine/client/cl_cg.c +++ b/engine/client/cl_cg.c @@ -917,7 +917,7 @@ static qintptr_t CG_SystemCalls(void *offset, quintptr_t mask, qintptr_t fn, con break; case CG_S_STARTSOUND:// ( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx ) - S_StartSound(VM_LONG(arg[1])+1, VM_LONG(arg[2]), S_PrecacheSound(VM_FROMSTRCACHE(arg[3])), VM_POINTER(arg[0]), 1, 1, 0, 0); + S_StartSound(VM_LONG(arg[1])+1, VM_LONG(arg[2]), S_PrecacheSound(VM_FROMSTRCACHE(arg[3])), VM_POINTER(arg[0]), 1, 1, 0, 0, 0); break; case CG_S_ADDLOOPINGSOUND: diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index bacc554d1..bc043c26a 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1105,6 +1105,7 @@ void CL_Connect_f (void) CL_BeginServerConnect(server, 0, false); } +#if defined(CL_MASTER) static void CL_ConnectBestRoute_f (void) { char server[1024]; @@ -1139,6 +1140,7 @@ static void CL_ConnectBestRoute_f (void) CL_Disconnect_f (); CL_BeginServerConnect(server, 0, true); } +#endif static void CL_Join_f (void) { @@ -3874,8 +3876,9 @@ void CL_Init (void) Cmd_AddCommand ("cl_status", CL_Status_f); Cmd_AddCommandD ("quit", CL_Quit_f, "Use this command when you get angry. Does not save any cvars. Use cfg_save to save settings, or use the menu for a prompt."); +#if defined(CL_MASTER) Cmd_AddCommandD ("connectbr", CL_ConnectBestRoute_f, "connect address:port\nConnect to a qw server using the best route we can detect."); - +#endif Cmd_AddCommandD ("connect", CL_Connect_f, "connect scheme://address:port\nConnect to a server. " #if defined(FTE_TARGET_WEB) "Use a scheme of ws:// or wss:// to connect via using websockets." diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index b678b339e..2fd651361 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -4252,13 +4252,13 @@ void CLQW_ParseStartSoundPacket(void) Host_EndGame ("CL_ParseStartSoundPacket: ent = %i", ent); #ifdef PEXT_CSQC - if (!CSQC_StartSound(ent, channel, cl.sound_name[sound_num], pos, volume/255.0, attenuation, 100, 0)) + if (!CSQC_StartSound(ent, channel, cl.sound_name[sound_num], pos, volume/255.0, attenuation, 100, 0, 0)) #endif { if (!sound_num) S_StopSound(ent, channel); else - S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation, 0, 0); + S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation, 0, 0, 0); } @@ -4346,7 +4346,7 @@ void CLQ2_ParseStartSoundPacket(void) if (sfx->loadstate == SLS_FAILED) sfx = S_PrecacheSound(va("players/male/%s", cl.sound_precache[sound_num]->name+1)); } - S_StartSound (ent, channel, sfx, pos, volume, attenuation, ofs, 0); + S_StartSound (ent, channel, sfx, pos, volume, attenuation, ofs, 0, 0); } #endif @@ -4362,6 +4362,7 @@ void CLNQ_ParseStartSoundPacket(void) int i; int pitchadj; float timeofs; + unsigned int flags; field_mask = MSG_ReadByte(); @@ -4385,6 +4386,11 @@ void CLNQ_ParseStartSoundPacket(void) else timeofs = 0; +// if (field_mask & FTESND_FLAGS) +// flags = MSG_ReadByte(); +// else + flags = 0; + if (field_mask & DPSND_LARGEENTITY) { ent = MSGCL_ReadEntity(); @@ -4412,13 +4418,13 @@ void CLNQ_ParseStartSoundPacket(void) pos[i] = MSG_ReadCoord (); #ifdef PEXT_CSQC - if (!CSQC_StartSound(ent, channel, cl.sound_name[sound_num], pos, volume/255.0, attenuation, pitchadj, timeofs)) + if (!CSQC_StartSound(ent, channel, cl.sound_name[sound_num], pos, volume/255.0, attenuation, pitchadj, timeofs, flags)) #endif { if (!sound_num) S_StopSound(ent, channel); else - S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation, timeofs, pitchadj); + S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation, timeofs, pitchadj, flags); } if (ent == cl.playerview[0].playernum+1) diff --git a/engine/client/cl_screen.c b/engine/client/cl_screen.c index 89b124c46..a751b5e96 100644 --- a/engine/client/cl_screen.c +++ b/engine/client/cl_screen.c @@ -737,7 +737,7 @@ void SCR_DrawCursor(void) key_customcursor[cmod].dirty = false; oldcurs = key_customcursor[cmod].handle; - if (rf->VID_CreateCursor) + if (rf->VID_CreateCursor && strcmp(key_customcursor[cmod].name, "none")) { key_customcursor[cmod].handle = rf->VID_CreateCursor(key_customcursor[cmod].name, key_customcursor[cmod].hotspot[0], key_customcursor[cmod].hotspot[1], key_customcursor[cmod].scale); if (!key_customcursor[cmod].handle) @@ -763,7 +763,7 @@ void SCR_DrawCursor(void) return; //system doesn't support a hardware cursor, so try to draw a software one. - if (!*key_customcursor[cmod].name) + if (!strcmp(key_customcursor[cmod].name, "none")) return; p = R2D_SafeCachePic(key_customcursor[cmod].name); diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index e8527b24b..523574449 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -1122,7 +1122,7 @@ void CL_ParseTEnt (void) if (P_RunParticleEffectType(pos, NULL, 1, pt_wizspike)) P_RunParticleEffect (pos, vec3_origin, 20, 30); - S_StartSound (-2, 0, cl_sfx_wizhit, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_wizhit, pos, 1, 1, 0, 0, 0); break; case TE_KNIGHTSPIKE: // spike hitting wall @@ -1135,7 +1135,7 @@ void CL_ParseTEnt (void) if (P_RunParticleEffectType(pos, NULL, 1, pt_knightspike)) P_RunParticleEffect (pos, vec3_origin, 226, 20); - S_StartSound (-2, 0, cl_sfx_knighthit, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_knighthit, pos, 1, 1, 0, 0, 0); break; case TEDP_SPIKEQUAD: @@ -1151,16 +1151,16 @@ void CL_ParseTEnt (void) P_RunParticleEffect (pos, vec3_origin, 0, 10); if ( rand() % 5 ) - S_StartSound (-2, 0, cl_sfx_tink1, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_tink1, pos, 1, 1, 0, 0, 0); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric1, pos, 1, 1, 0, 0, 0); else if (rnd == 2) - S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric2, pos, 1, 1, 0, 0, 0); else - S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric3, pos, 1, 1, 0, 0, 0); } break; case TE_SPIKE: // spike hitting wall @@ -1175,16 +1175,16 @@ void CL_ParseTEnt (void) P_RunParticleEffect (pos, vec3_origin, 0, 10); if ( rand() % 5 ) - S_StartSound (-2, 0, cl_sfx_tink1, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_tink1, pos, 1, 1, 0, 0, 0); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric1, pos, 1, 1, 0, 0, 0); else if (rnd == 2) - S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric2, pos, 1, 1, 0, 0, 0); else - S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric3, pos, 1, 1, 0, 0, 0); } break; case TEDP_SUPERSPIKEQUAD: // super spike hitting wall @@ -1201,16 +1201,16 @@ void CL_ParseTEnt (void) P_RunParticleEffect (pos, vec3_origin, 0, 20); if ( rand() % 5 ) - S_StartSound (-2, 0, cl_sfx_tink1, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_tink1, pos, 1, 1, 0, 0, 0); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric1, pos, 1, 1, 0, 0, 0); else if (rnd == 2) - S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric2, pos, 1, 1, 0, 0, 0); else - S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric3, pos, 1, 1, 0, 0, 0); } break; case TE_SUPERSPIKE: // super spike hitting wall @@ -1226,16 +1226,16 @@ void CL_ParseTEnt (void) P_RunParticleEffect (pos, vec3_origin, 0, 20); if ( rand() % 5 ) - S_StartSound (-2, 0, cl_sfx_tink1, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_tink1, pos, 1, 1, 0, 0, 0); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric1, pos, 1, 1, 0, 0, 0); else if (rnd == 2) - S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric2, pos, 1, 1, 0, 0, 0); else - S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric3, pos, 1, 1, 0, 0, 0); } break; @@ -1254,16 +1254,16 @@ void CL_ParseTEnt (void) P_RunParticleEffect (pos, vec3_origin, 0, 10); if ( rand() % 5 ) - S_StartSound (-2, 0, cl_sfx_tink1, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_tink1, pos, 1, 1, 0, 0, 0); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric1, pos, 1, 1, 0, 0, 0); else if (rnd == 2) - S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric2, pos, 1, 1, 0, 0, 0); else - S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric3, pos, 1, 1, 0, 0, 0); } break; case TE_SUPERBULLET: @@ -1279,16 +1279,16 @@ void CL_ParseTEnt (void) P_RunParticleEffect (pos, vec3_origin, 0, 20); if ( rand() % 5 ) - S_StartSound (-2, 0, cl_sfx_tink1, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_tink1, pos, 1, 1, 0, 0, 0); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric1, pos, 1, 1, 0, 0, 0); else if (rnd == 2) - S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric2, pos, 1, 1, 0, 0, 0); else - S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_ric3, pos, 1, 1, 0, 0, 0); } break; #endif @@ -1323,7 +1323,7 @@ void CL_ParseTEnt (void) // sound - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0, 0); // sprite if (cl_expsprite.ival) // temp hopefully @@ -1364,7 +1364,7 @@ void CL_ParseTEnt (void) // sound - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0, 0); // sprite if (type == TE_EXPLOSION && cl_expsprite.ival) // temp hopefully @@ -1394,7 +1394,7 @@ void CL_ParseTEnt (void) dl->die = cl.time + 0.5; dl->decay = 300; } - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0, 0); } break; @@ -1425,7 +1425,7 @@ void CL_ParseTEnt (void) dl->channelfade[2] = 0; } - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0, 0); break; case TEDP_TEI_BIGEXPLOSION: @@ -1456,7 +1456,7 @@ void CL_ParseTEnt (void) dl->channelfade[2] = 0; } - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0, 0); break; case TE_TAREXPLOSION: // tarbaby explosion @@ -1465,7 +1465,7 @@ void CL_ParseTEnt (void) pos[2] = MSG_ReadCoord (); P_RunParticleEffectType(pos, NULL, 1, pt_tarexplosion); - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0, 0); break; case TE_LIGHTNING1: // lightning bolts @@ -2436,7 +2436,7 @@ static struct{ #define ATTN_STATIC 1 void Q2S_StartSound(vec3_t origin, int entnum, int entchannel, sfx_t *sfx, float fvol, float attenuation, float delay) { - S_StartSound(entnum, entchannel, sfx, origin, fvol, attenuation, -delay, 0); + S_StartSound(entnum, entchannel, sfx, origin, fvol, attenuation, -delay, 0, 0); } void CLQ2_ParseTEnt (void) { @@ -2629,7 +2629,7 @@ fixme: else P_RunParticleEffect (pos, dir, 0xb0, 40); //FIXME : replace or remove this sound - S_StartSound (-2, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1, 0, 0); + S_StartSound (0, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1, 0, 0, 0); break; case Q2TE_SHOTGUN: // bullet hitting wall @@ -2705,7 +2705,7 @@ fixme: ex->angles[1] = 0; ex->angles[0]*=-1; - S_StartSound (-2, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1, 0, 0); + S_StartSound (0, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1, 0, 0, 0); // light if (r_explosionlight.value) @@ -2763,9 +2763,9 @@ fixme: // sound if (type == Q2TE_GRENADE_EXPLOSION_WATER) - S_StartSound (-2, 0, S_PrecacheSound ("weapons/xpld_wat.wav"), pos, 1, 1, 0, 0); + S_StartSound (0, 0, S_PrecacheSound ("weapons/xpld_wat.wav"), pos, 1, 1, 0, 0, 0); else - S_StartSound (-2, 0, S_PrecacheSound ("weapons/grenlx1a.wav"), pos, 1, 1, 0, 0); + S_StartSound (0, 0, S_PrecacheSound ("weapons/grenlx1a.wav"), pos, 1, 1, 0, 0, 0); // sprite @@ -2858,9 +2858,9 @@ fixme: // sound if (type == Q2TE_ROCKET_EXPLOSION_WATER) - S_StartSound (-2, 0, S_PrecacheSound ("weapons/xpld_wat.wav"), pos, 1, 1, 0, 0); + S_StartSound (0, 0, S_PrecacheSound ("weapons/xpld_wat.wav"), pos, 1, 1, 0, 0, 0); else - S_StartSound (-2, 0, S_PrecacheSound ("weapons/rocklx1a.wav"), pos, 1, 1, 0, 0); + S_StartSound (0, 0, S_PrecacheSound ("weapons/rocklx1a.wav"), pos, 1, 1, 0, 0, 0); // sprite // if (!R_ParticleExplosionHeart(pos)) @@ -3032,7 +3032,7 @@ fixme: ex->angles[1] = 0; ex->angles[0]*=-1; - S_StartSound (-2, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1, 0, 0); + S_StartSound (0, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1, 0, 0, 0); // light if (r_explosionlight.value) @@ -3081,7 +3081,7 @@ fixme: ex->angles[1] = 0; ex->angles[0]*=-1; - S_StartSound (-2, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1, 0, 0); + S_StartSound (0, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1, 0, 0, 0); // light if (r_explosionlight.value) diff --git a/engine/client/client.h b/engine/client/client.h index ac07135be..a2e300894 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -1294,7 +1294,7 @@ qboolean CSQC_MouseMove(float xdelta, float ydelta, int devid); qboolean CSQC_MousePosition(float xabs, float yabs, int devid); qboolean CSQC_JoystickAxis(int axis, float value, int devid); qboolean CSQC_Accelerometer(float x, float y, float z); -int CSQC_StartSound(int entnum, int channel, char *soundname, vec3_t pos, float vol, float attenuation, float pitchmod, float timeofs); +int CSQC_StartSound(int entnum, int channel, char *soundname, vec3_t pos, float vol, float attenuation, float pitchmod, float timeofs, unsigned int flags); void CSQC_ParseEntities(void); void CSQC_ResetTrails(void); diff --git a/engine/client/keys.c b/engine/client/keys.c index b30c228ad..863cd889f 100644 --- a/engine/client/keys.c +++ b/engine/client/keys.c @@ -1862,14 +1862,16 @@ void Key_Bind_f (void) } if (bindmap) { - if (bindmap < 0 || bindmap > KEY_MODIFIER_ALTBINDMAP) + if (bindmap <= 0 || bindmap > KEY_MODIFIER_ALTBINDMAP) { - Con_Printf ("unsupported bindmap %i\n", bindmap); + if (cl_warncmd.ival) + Con_Printf ("unsupported bindmap %i\n", bindmap); return; } if (modifier != ~0) { - Con_Printf ("modifiers cannot be combined with bindmaps\n"); + if (cl_warncmd.ival) + Con_Printf ("modifiers cannot be combined with bindmaps\n"); return; } modifier = (bindmap-1) | KEY_MODIFIER_ALTBINDMAP; @@ -1997,10 +1999,10 @@ void Key_WriteBindings (vfsfile_t *f) { s = Key_KeynumToString(i, m); //quote it as required - if (i == ';' || i <= ' ' || i == '\"') + if (i == ';' || i <= ' ' || strchr(s, ' ') || strchr(s, '+') || strchr(s, '\"')) s = COM_QuotedString(s, keybuf, sizeof(keybuf), false); - if (bindcmdlevel[i][m] != bindcmdlevel[i][0]) + if (bindcmdlevel[i][m] != RESTRICT_LOCAL) s = va("bindlevel %s %i %s\n", s, bindcmdlevel[i][m], COM_QuotedString(binding, commandbuf, sizeof(commandbuf), false)); else s = va("bind %s %s\n", s, COM_QuotedString(binding, commandbuf, sizeof(commandbuf), false)); @@ -2043,7 +2045,7 @@ void Key_Init (void) key_linepos = 1; key_dest_mask = kdm_game; - key_dest_absolutemouse = kdm_console | kdm_editor | kdm_cwindows; + key_dest_absolutemouse = kdm_console | kdm_editor | kdm_cwindows | kdm_emenu; // // init ascii characters in console mode diff --git a/engine/client/m_mp3.c b/engine/client/m_mp3.c index 1b024019a..2bcf62288 100644 --- a/engine/client/m_mp3.c +++ b/engine/client/m_mp3.c @@ -748,7 +748,17 @@ void M_Media_Draw (menu_t *menu) { float time, duration; if (S_GetMusicInfo(0, &time, &duration)) - MP_Hightlight (12, y, va("<< %i:%02i / %i:%02i - %i%% >>", (int)time/60, (int)time%60, (int)duration/60, (int)duration%60, (int)(100*time/duration)), op == selectedoption); + { + int itime = time; + int iduration = duration; + if (iduration) + { + int pct = (int)((100*time)/duration); + MP_Hightlight (12, y, va("<< %i:%02i / %i:%02i - %i%% >>", itime/60, itime%60, iduration/60, iduration%60, pct), op == selectedoption); + } + else + MP_Hightlight (12, y, va("<< %i:%02i >>", itime/60, itime%60), op == selectedoption); + } else MP_Hightlight (12, y, "<< skip >>", op == selectedoption); } diff --git a/engine/client/m_options.c b/engine/client/m_options.c index a58da30c2..403ebd477 100644 --- a/engine/client/m_options.c +++ b/engine/client/m_options.c @@ -355,7 +355,7 @@ void M_Audio_StartSound (struct menu_s *menu) org[0] = mat[0][0] + 2*(mat[1][0]*(info->testsoundsource->common.posx-320/2) + mat[1][0]*(info->testsoundsource->common.posy-200/2)); org[1] = mat[0][1] + 2*(mat[1][1]*(info->testsoundsource->common.posx-320/2) + mat[1][1]*(info->testsoundsource->common.posy-200/2)); org[2] = mat[0][2] + 2*(mat[1][2]*(info->testsoundsource->common.posx-320/2) + mat[1][2]*(info->testsoundsource->common.posy-200/2)); - S_StartSound(-2, 0, S_PrecacheSound("player/pain3.wav"), org, 1, 4, 0, 0); + S_StartSound(-2, 0, S_PrecacheSound("player/pain3.wav"), org, 1, 4, 0, 0, 0); } } diff --git a/engine/client/menu.c b/engine/client/menu.c index 4182d8845..7a4b371ce 100644 --- a/engine/client/menu.c +++ b/engine/client/menu.c @@ -340,7 +340,7 @@ void M_ToggleMenu_f (void) } #endif #ifdef MENU_DAT - if (MP_Toggle()) + if (MP_Toggle(1)) { Key_Dest_Remove(kdm_console|kdm_cwindows); return; diff --git a/engine/client/menu.h b/engine/client/menu.h index 6f23340ad..3960c608e 100644 --- a/engine/client/menu.h +++ b/engine/client/menu.h @@ -463,7 +463,7 @@ int M_FindKeysForBind (int bindmap, const char *command, int *keylist, int *keym void MP_CvarChanged(cvar_t *var); qboolean MP_Init (void); void MP_Shutdown (void); -qboolean MP_Toggle(void); +qboolean MP_Toggle(int mode); void MP_Draw(void); void MP_RegisterCvarsAndCmds(void); void MP_Keydown(int key, int unicode); diff --git a/engine/client/p_script.c b/engine/client/p_script.c index 96151d8ce..dfde6708c 100644 --- a/engine/client/p_script.c +++ b/engine/client/p_script.c @@ -3684,7 +3684,7 @@ static void PScript_EffectSpawned(part_type_t *ptype, vec3_t org, vec3_t axis[3] if (w <= tw) { if (*ptype->sounds[i].name && ptype->sounds[i].vol > 0) - S_StartSound(0, 0, S_PrecacheSound(ptype->sounds[i].name), org, ptype->sounds[i].vol, ptype->sounds[i].atten, -ptype->sounds[i].delay, ptype->sounds[i].pitch); + S_StartSound(0, 0, S_PrecacheSound(ptype->sounds[i].name), org, ptype->sounds[i].vol, ptype->sounds[i].atten, -ptype->sounds[i].delay, ptype->sounds[i].pitch, 0); break; } } diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index 327659f0f..ee5ddb003 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -3259,12 +3259,12 @@ void QCBUILTIN PF_soundupdate (pubprogfuncs_t *prinst, struct globalvars_s *pr_g float volume = G_FLOAT(OFS_PARM3); float attenuation = G_FLOAT(OFS_PARM4); float pitchpct = (prinst->callargc >= 6)?G_FLOAT(OFS_PARM5):0; -// unsigned int flags = (prinst->callargc>=7)?G_FLOAT(OFS_PARM6):0; + unsigned int flags = (prinst->callargc>=7)?G_FLOAT(OFS_PARM6):0; float startoffset = (prinst->callargc>=8)?G_FLOAT(OFS_PARM7):0; sfx_t *sfx = S_PrecacheSound(sample); - G_FLOAT(OFS_RETURN) = S_UpdateSound(-entity->entnum, channel, sfx, entity->v->origin, volume, attenuation, startoffset, pitchpct); + G_FLOAT(OFS_RETURN) = S_UpdateSound(-entity->entnum, channel, sfx, entity->v->origin, volume, attenuation, startoffset, pitchpct, flags); } void QCBUILTIN PF_stopsound (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { @@ -3288,7 +3288,7 @@ static void QCBUILTIN PF_cs_sound(pubprogfuncs_t *prinst, struct globalvars_s *p float volume; float attenuation; float pitchpct; -// unsigned int flags; + unsigned int flags; float startoffset; sfx_t *sfx; @@ -3299,12 +3299,12 @@ static void QCBUILTIN PF_cs_sound(pubprogfuncs_t *prinst, struct globalvars_s *p volume = G_FLOAT(OFS_PARM3); attenuation = G_FLOAT(OFS_PARM4); pitchpct = (prinst->callargc>=6)?G_FLOAT(OFS_PARM5):0; -// flags = (prinst->callargc>=7)?G_FLOAT(OFS_PARM6):0; + flags = (prinst->callargc>=7)?G_FLOAT(OFS_PARM6):0; startoffset = (prinst->callargc>=8)?G_FLOAT(OFS_PARM7):0; sfx = S_PrecacheSound(sample); if (sfx) - S_StartSound(-entity->entnum, channel, sfx, entity->v->origin, volume, attenuation, startoffset, pitchpct); + S_StartSound(-entity->entnum, channel, sfx, entity->v->origin, volume, attenuation, startoffset, pitchpct, flags); }; static void QCBUILTIN PF_cs_pointsound(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) @@ -3328,7 +3328,7 @@ static void QCBUILTIN PF_cs_pointsound(pubprogfuncs_t *prinst, struct globalvars sfx = S_PrecacheSound(sample); if (sfx) - S_StartSound(0, 0, sfx, origin, volume, attenuation, 0, pitchpct); + S_StartSound(0, 0, sfx, origin, volume, attenuation, 0, pitchpct, 0); } static void QCBUILTIN PF_cs_particle(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) @@ -3610,14 +3610,14 @@ static void QCBUILTIN PF_cl_te_explosion (pubprogfuncs_t *prinst, struct globalv Surf_AddStain(pos, -1, -1, -1, 100); - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0, 0); } static void QCBUILTIN PF_cl_te_tarexplosion (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { float *pos = G_VECTOR(OFS_PARM0); P_RunParticleEffectType(pos, NULL, 1, pt_tarexplosion); - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0, 0); } static void QCBUILTIN PF_cl_te_wizspike (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { @@ -3625,7 +3625,7 @@ static void QCBUILTIN PF_cl_te_wizspike (pubprogfuncs_t *prinst, struct globalva if (P_RunParticleEffectType(pos, NULL, 1, pt_wizspike)) P_RunParticleEffect (pos, vec3_origin, 20, 30); - S_StartSound (-2, 0, cl_sfx_knighthit, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_knighthit, pos, 1, 1, 0, 0, 0); } static void QCBUILTIN PF_cl_te_knightspike (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { @@ -3633,7 +3633,7 @@ static void QCBUILTIN PF_cl_te_knightspike (pubprogfuncs_t *prinst, struct globa if (P_RunParticleEffectType(pos, NULL, 1, pt_knightspike)) P_RunParticleEffect (pos, vec3_origin, 226, 20); - S_StartSound (-2, 0, cl_sfx_knighthit, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_knighthit, pos, 1, 1, 0, 0, 0); } static void QCBUILTIN PF_cl_te_lavasplash (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { @@ -3696,7 +3696,7 @@ static void QCBUILTIN PF_cl_te_explosionquad (pubprogfuncs_t *prinst, struct glo dl->channelfade[2] = 0.12; } - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_r_exp3, pos, 1, 1, 0, 0, 0); } //void(vector org, float radius, float lifetime, vector color) te_customflash @@ -3807,7 +3807,7 @@ static void QCBUILTIN PF_cl_te_explosionrgb (pubprogfuncs_t *prinst, struct glob dl->channelfade[2] = 0; } - S_StartSound (-2, 0, cl_sfx_r_exp3, org, 1, 1, 0, 0); + S_StartSound (0, 0, cl_sfx_r_exp3, org, 1, 1, 0, 0, 0); } static void QCBUILTIN PF_cl_te_particlerain (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { @@ -5709,7 +5709,7 @@ void CSQC_Event_Sound (float *origin, wedict_t *wentity, int channel, const char origin = wentity->v->origin; } - S_StartSound(NUM_FOR_EDICT(csqcprogs, (edict_t*)wentity), channel, S_PrecacheSound(sample), origin, volume, attenuation, timeoffset, pitchadj); + S_StartSound(NUM_FOR_EDICT(csqcprogs, (edict_t*)wentity), channel, S_PrecacheSound(sample), origin, volume, attenuation, timeoffset, pitchadj, 0); } qboolean CSQC_Event_ContentsTransition(world_t *w, wedict_t *ent, int oldwatertype, int newwatertype) @@ -7048,7 +7048,7 @@ static void CSQC_EntityCheck(unsigned int entnum) } } -int CSQC_StartSound(int entnum, int channel, char *soundname, vec3_t pos, float vol, float attenuation, float pitchmod, float timeofs) +int CSQC_StartSound(int entnum, int channel, char *soundname, vec3_t pos, float vol, float attenuation, float pitchmod, float timeofs, unsigned int flags) { void *pr_globals; csqcedict_t *ent; @@ -7073,7 +7073,7 @@ int CSQC_StartSound(int entnum, int channel, char *soundname, vec3_t pos, float G_FLOAT(OFS_PARM4) = attenuation; VectorCopy(pos, G_VECTOR(OFS_PARM5)); G_FLOAT(OFS_PARM6) = pitchmod; - G_FLOAT(OFS_PARM7) = 0/*flags*/; + G_FLOAT(OFS_PARM7) = flags; // G_FLOAT(OFS_PARM8) = timeofs; PR_ExecuteProgram(csqcprogs, csqcg.event_sound); @@ -7095,7 +7095,7 @@ int CSQC_StartSound(int entnum, int channel, char *soundname, vec3_t pos, float VectorCopy(pos, G_VECTOR(OFS_PARM2)); G_FLOAT(OFS_PARM3) = vol; G_FLOAT(OFS_PARM4) = attenuation; - G_FLOAT(OFS_PARM5) = 0/*flags*/; + G_FLOAT(OFS_PARM5) = flags; G_FLOAT(OFS_PARM6) = timeofs; PR_ExecuteProgram(csqcprogs, csqcg.serversound); diff --git a/engine/client/pr_menu.c b/engine/client/pr_menu.c index 2493c6979..da35ced0b 100644 --- a/engine/client/pr_menu.c +++ b/engine/client/pr_menu.c @@ -2322,6 +2322,8 @@ pbool PDECL Menu_CheckHeaderCrc(pubprogfuncs_t *inst, progsnum_t idx, int crc) double menutime; qboolean MP_Init (void) { + struct key_cursor_s *m = &key_customcursor[kc_menu]; + if (qrenderer == QR_NONE) { return false; @@ -2375,8 +2377,13 @@ qboolean MP_Init (void) menuprogparms.user = &menu_world; menu_world.keydestmask = kdm_gmenu; - //default to free mouse, to match dp's default setting, and because its generally the right thing for a menu. + //default to free mouse+hidden cursor, to match dp's default setting, and because its generally the right thing for a menu. key_dest_absolutemouse |= kdm_gmenu; + Q_strncpyz(m->name, "none", sizeof(m->name)); + m->hotspot[0] = 0; + m->hotspot[1] = 0; + m->scale = 1; + m->dirty = true; menutime = Sys_DoubleTime(); if (!menu_world.progs) @@ -2624,7 +2631,7 @@ void MP_Keyup(int key, int unicode) inmenuprogs--; } -qboolean MP_Toggle(void) +qboolean MP_Toggle(int mode) { if (!menu_world.progs) return false; @@ -2633,6 +2640,9 @@ qboolean MP_Toggle(void) return false; #endif + if (!mode && !Key_Dest_Has(kdm_gmenu)) + return false; + if (setjmp(mp_abort)) return false; @@ -2644,7 +2654,7 @@ qboolean MP_Toggle(void) if (mp_toggle_function) { void *pr_globals = PR_globals(menu_world.progs, PR_CURRENT); - G_FLOAT(OFS_PARM0) = 1; + G_FLOAT(OFS_PARM0) = mode; PR_ExecuteProgram(menu_world.progs, mp_toggle_function); } inmenuprogs--; diff --git a/engine/client/snd_dma.c b/engine/client/snd_dma.c index c947415f9..bbb96c446 100644 --- a/engine/client/snd_dma.c +++ b/engine/client/snd_dma.c @@ -2256,24 +2256,22 @@ SND_Spatialize void SND_Spatialize(soundcardinfo_t *sc, channel_t *ch) { vec3_t listener_vec; - vec_t dist; - vec_t scale; - vec3_t world_vec; + vec_t dist; + vec_t scale; + vec3_t world_vec; int i, v; + float volscale; -// anything coming from the view entity will always be full volume + //sounds with absvolume ignore all volume etc cvars+settings if (ch->flags & CF_ABSVOLUME) + volscale = 1; + else + volscale = volume.value * voicevolumemod; + + // anything coming from the view entity will always be full volume + if (ch->entnum == listener[sc->seat].entnum) { - v = ch->master_vol; - for (i = 0; i < sc->sn.numchannels; i++) - { - ch->vol[i] = v; - } - return; - } - if (ch->entnum == -1 || ch->entnum == cl.playerview[0].playernum+1) - { - v = ch->master_vol * (ruleset_allow_localvolume.value ? snd_playersoundvolume.value : 1) * volume.value * voicevolumemod; + v = ch->master_vol * (ruleset_allow_localvolume.value ? snd_playersoundvolume.value : 1) * volscale; v = bound(0, v, 255); for (i = 0; i < sc->sn.numchannels; i++) { @@ -2287,6 +2285,16 @@ void SND_Spatialize(soundcardinfo_t *sc, channel_t *ch) dist = VectorNormalize(world_vec) * ch->dist_mult; + if (ch->flags & CF_NOSPACIALISE) + { + scale = 1; + scale = (1.0 - dist) * scale; + v = ch->master_vol * scale * volscale; + for (i = 0; i < sc->sn.numchannels; i++) + ch->vol[i] = bound(0, v, 255); + return; + } + //rotate the world_vec into listener space, so that the audio direction stored in the speakerdir array can be used directly. listener_vec[0] = DotProduct(listener[sc->seat].forward, world_vec); listener_vec[1] = DotProduct(listener[sc->seat].right, world_vec); @@ -2299,7 +2307,7 @@ void SND_Spatialize(soundcardinfo_t *sc, channel_t *ch) { scale = 1 + DotProduct(listener_vec, sc->speakerdir[i]); scale = (1.0 - dist) * scale * sc->dist[i]; - v = ch->master_vol * scale * volume.value * voicevolumemod; + v = ch->master_vol * scale * volscale; ch->vol[i] = bound(0, v, 255); } } @@ -2307,14 +2315,12 @@ void SND_Spatialize(soundcardinfo_t *sc, channel_t *ch) // ======================================================================= // Start a sound effect // ======================================================================= -static void S_UpdateSoundCard(soundcardinfo_t *sc, qboolean updateonly, channel_t *target_chan, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeoffset, float pitchadj) +static void S_UpdateSoundCard(soundcardinfo_t *sc, qboolean updateonly, channel_t *target_chan, int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeoffset, float pitchadj, unsigned int flags) { channel_t *check; int vol; int ch_idx; int skip; - int entnum = target_chan->entnum; - int entchannel = target_chan->entchannel; int absstartpos = updateonly?target_chan->pos:0; if (fvol < 0) @@ -2343,7 +2349,7 @@ static void S_UpdateSoundCard(soundcardinfo_t *sc, qboolean updateonly, channel_ { VectorCopy(origin, target_chan->origin); } - target_chan->flags = 0; + target_chan->flags = flags; target_chan->dist_mult = attenuation / sound_nominal_clip_dist; target_chan->master_vol = vol; target_chan->entnum = entnum; @@ -2394,7 +2400,7 @@ static void S_UpdateSoundCard(soundcardinfo_t *sc, qboolean updateonly, channel_ sc->ChannelUpdate(sc, target_chan, true); } -float S_UpdateSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeofs, float pitchadj) +float S_UpdateSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeofs, float pitchadj, unsigned int flags) { int i; int result = 0; @@ -2411,7 +2417,7 @@ float S_UpdateSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float { if (sc->channel[i].entnum == entnum && sc->channel[i].entchannel == entchannel && sc->channel[i].sfx) { - S_UpdateSoundCard(sc, true, &sc->channel[i], sfx, origin, fvol, attenuation, timeofs, pitchadj); + S_UpdateSoundCard(sc, true, &sc->channel[i], entnum, entchannel, sfx, origin, fvol, attenuation, timeofs, pitchadj, flags); result++; break; } @@ -2423,7 +2429,7 @@ float S_UpdateSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float return result / (float)cards; } -void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeofs, float pitchadj) +void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeofs, float pitchadj, unsigned int flags) { soundcardinfo_t *sc; channel_t *target_chan; @@ -2448,7 +2454,7 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f if (!target_chan) return; - S_UpdateSoundCard(sc, false, target_chan, sfx, origin, fvol, attenuation, timeofs, pitchadj); + S_UpdateSoundCard(sc, false, target_chan, entnum, entchannel, sfx, origin, fvol, attenuation, timeofs, pitchadj, flags); } S_UnlockMixer(); } @@ -2457,7 +2463,6 @@ qboolean S_GetMusicInfo(int musicchannel, float *time, float *duration) { qboolean result = false; soundcardinfo_t *sc; - sfxcache_t scachebuf, *c; sfx_t *sfx; *time = 0; *duration = 0; @@ -2470,24 +2475,18 @@ qboolean S_GetMusicInfo(int musicchannel, float *time, float *duration) sfx = sc->channel[musicchannel].sfx; if (sfx) { - if (sfx->loadstate != SLS_LOADED) - c = NULL; - else if (sfx->decoder.decodedata) + if (sfx->loadstate == SLS_LOADED && sfx->decoder.querydata) + *duration = sfx->decoder.querydata(sfx, NULL); + else if (sfx->decoder.buf) { - if (sfx->decoder.querydata) - c = sfx->decoder.querydata(sfx, &scachebuf); - else - c = NULL; //don't bother trying to actually decode anything here. + sfxcache_t *c = sfx->decoder.buf; + *duration = (float)c->length / c->speed; } else - c = sfx->decoder.buf; + *duration = 0; - if (c) - { - *duration = c->length / c->speed; - *time = (sc->channel[musicchannel].pos>>PITCHSHIFT) / (float)snd_speed; //the time into the sound, ignoring play rate. - result = true; - } + *time = (sc->channel[musicchannel].pos>>PITCHSHIFT) / (float)snd_speed; //the time into the sound, ignoring play rate. + result = true; } } S_UnlockMixer(); @@ -2667,7 +2666,7 @@ void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation) ss = &scard->channel[scard->total_chans]; scard->total_chans++; - ss->entnum = -2; + ss->entnum = 0; ss->sfx = sfx; ss->rate = 1<origin); @@ -2844,7 +2843,7 @@ void S_UpdateAmbientSounds (soundcardinfo_t *sc) chan = &sc->channel[AMBIENT_FIRST+ambient_channel]; chan->sfx = ambient_sfx[AMBIENT_FIRST+ambient_channel]; chan->entnum = -1; - chan->flags = CF_FORCELOOP; + chan->flags = CF_FORCELOOP | CF_NOSPACIALISE; chan->rate = 1<seat].origin, chan->origin); @@ -3185,7 +3184,7 @@ void S_Play(void) else Q_strncpyz(name, Cmd_Argv(i), sizeof(name)); sfx = S_PrecacheSound(name); - S_StartSound(cl.playerview[0].playernum+1, -1, sfx, vec3_origin, 1.0, 0.0, 0, 0); + S_StartSound(listener[0].entnum, -1, sfx, vec3_origin, 1.0, 0.0, 0, 0, CF_NOSPACIALISE); i++; } } @@ -3209,7 +3208,7 @@ void S_PlayVol(void) Q_strncpy(name, Cmd_Argv(i), sizeof(name)); sfx = S_PrecacheSound(name); vol = Q_atof(Cmd_Argv(i+1)); - S_StartSound(cl.playerview[0].playernum+1, -1, sfx, vec3_origin, vol, 0.0, 0, 0); + S_StartSound(listener[0].entnum, -1, sfx, vec3_origin, vol, 0.0, 0, 0, CF_NOSPACIALISE); i+=2; } } @@ -3234,7 +3233,7 @@ void S_SoundList_f(void) else if (sfx->decoder.decodedata) { if (sfx->decoder.querydata) - sc = sfx->decoder.querydata(sfx, &scachebuf); + sc = (sfx->decoder.querydata(sfx, &scachebuf) < 0)?NULL:&scachebuf; else sc = NULL; //don't bother trying to actually decode anything here. if (!sc) @@ -3280,7 +3279,7 @@ void S_LocalSound (const char *sound) Con_Printf ("S_LocalSound: can't cache %s\n", sound); return; } - S_StartSound (-1, -1, sfx, vec3_origin, 1, 1, 0, 0); + S_StartSound (0, -1, sfx, vec3_origin, 1, 1, 0, 0, CF_NOSPACIALISE); } @@ -3487,7 +3486,7 @@ void S_RawAudio(int sourceid, qbyte *data, int speed, int samples, int channels, channel_t *c = SND_PickChannel(si, -1, 0); if (c) { - c->flags = CF_ABSVOLUME; + c->flags = CF_ABSVOLUME|CF_NOSPACIALISE; c->entnum = -1; c->entchannel = 0; c->dist_mult = 0; diff --git a/engine/client/snd_ov.c b/engine/client/snd_ov.c index 60d6ce89c..403d931ed 100644 --- a/engine/client/snd_ov.c +++ b/engine/client/snd_ov.c @@ -20,6 +20,7 @@ #define p_ov_info ov_info #define p_ov_comment ov_comment #define p_ov_pcm_total ov_pcm_total + #define p_ov_time_total ov_time_total #define p_ov_read ov_read #define p_ov_pcm_seek ov_pcm_seek #else @@ -38,6 +39,7 @@ #define p_ov_info ov_info #define p_ov_comment ov_comment #define p_ov_pcm_total ov_pcm_total + #define p_ov_time_total ov_time_total #define p_ov_read ov_read #define p_ov_pcm_seek ov_pcm_seek #else @@ -46,8 +48,8 @@ vorbis_info *(VARGS *p_ov_info)(OggVorbis_File *vf,int link); vorbis_comment *(VARGS *p_ov_comment) (OggVorbis_File *vf,int link); ogg_int64_t (VARGS *p_ov_pcm_total)(OggVorbis_File *vf,int i); - long (VARGS *p_ov_read)(OggVorbis_File *vf,char *buffer,int length, - int bigendianp,int word,int sgned,int *bitstream); + double (VARGS *p_ov_time_total)(OggVorbis_File *vf,int i); + long (VARGS *p_ov_read)(OggVorbis_File *vf,char *buffer,int length,int bigendianp,int word,int sgned,int *bitstream); int (VARGS *p_ov_pcm_seek)(OggVorbis_File *vf,ogg_int64_t pos); #endif #endif @@ -75,7 +77,7 @@ typedef struct { sfx_t *s; } ovdecoderbuffer_t; -static sfxcache_t *OV_Query(struct sfx_s *sfx, struct sfxcache_s *buf); +float OV_Query(struct sfx_s *sfx, struct sfxcache_s *buf); static sfxcache_t *OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, ssamplepos_t start, int length); static void OV_CancelDecoder(sfx_t *s); static qboolean OV_StartDecode(unsigned char *start, unsigned long length, ovdecoderbuffer_t *buffer); @@ -119,11 +121,11 @@ qboolean S_LoadOVSound (sfx_t *s, qbyte *data, int datalen, int sndspeed) return true; } -static sfxcache_t *OV_Query(struct sfx_s *sfx, struct sfxcache_s *buf) +float OV_Query(struct sfx_s *sfx, struct sfxcache_s *buf) { ovdecoderbuffer_t *dec = sfx->decoder.buf; if (!dec) - buf = NULL; + return -1; if (buf) { buf->data = NULL; //you're not meant to actually be using the data here @@ -134,7 +136,7 @@ static sfxcache_t *OV_Query(struct sfx_s *sfx, struct sfxcache_s *buf) buf->speed = dec->srcspeed; buf->width = 2; } - return buf; + return p_ov_time_total(&dec->vf, -1); } static sfxcache_t *OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, ssamplepos_t start, int length) @@ -162,16 +164,16 @@ static sfxcache_t *OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, ssam //check pos //fixme: seeking might not be supported - p_ov_pcm_seek(&dec->vf, dec->decodedbytestart); + p_ov_pcm_seek(&dec->vf, (dec->decodedbytestart * dec->srcspeed) / outspeed); } /* if (start > dec->decodedbytestart + dec->decodedbytecount) { dec->decodedbytestart = start; - p_ov_pcm_seek(&dec->vf, dec->decodedbytestart); + p_ov_pcm_seek(&dec->vf, (dec->decodedbytestart * dec->srcspeed) / outspeed); } */ - if (dec->decodedbytecount > snd_speed*8) + if (dec->decodedbytecount > outspeed*8) { /*everything is okay, but our buffer is getting needlessly large. keep anything after the 'new' position, but discard all before that @@ -205,7 +207,7 @@ static sfxcache_t *OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, ssam if (dec->decodedbufferbytes < start+length - dec->decodedbytestart + 128) //expand if needed. { // Con_Printf("Expand buffer\n"); - dec->decodedbufferbytes = (start+length - dec->decodedbytestart) + snd_speed; + dec->decodedbufferbytes = (start+length - dec->decodedbytestart) + outspeed; dec->decodedbuffer = BZ_Realloc(dec->decodedbuffer, dec->decodedbufferbytes); } @@ -371,6 +373,7 @@ static qboolean OV_StartDecode(unsigned char *start, unsigned long length, ovdec {(void*)&p_ov_open_callbacks, "ov_open_callbacks"}, {(void*)&p_ov_comment, "ov_comment"}, {(void*)&p_ov_pcm_total, "ov_pcm_total"}, + {(void*)&p_ov_time_total, "ov_time_total"}, {(void*)&p_ov_clear, "ov_clear"}, {(void*)&p_ov_info, "ov_info"}, {(void*)&p_ov_read, "ov_read"}, diff --git a/engine/client/sound.h b/engine/client/sound.h index cefc66938..fa2bb3d04 100644 --- a/engine/client/sound.h +++ b/engine/client/sound.h @@ -37,7 +37,7 @@ typedef struct typedef struct { struct sfxcache_s *(*decodedata) (struct sfx_s *sfx, struct sfxcache_s *buf, ssamplepos_t start, int length); //return true when done. - struct sfxcache_s *(*querydata) (struct sfx_s *sfx, struct sfxcache_s *buf); //reports length + format info without actually decoding anything. + float (*querydata) (struct sfx_s *sfx, struct sfxcache_s *buf); //reports length + original format info without actually decoding anything. void (*ended) (struct sfx_s *sfx); //sound stopped playing and is now silent (allow rewinding or something). void (*purge) (struct sfx_s *sfx); //sound is being purged from memory. destroy everything. void *buf; @@ -89,8 +89,12 @@ typedef struct unsigned char *buffer; // pointer to mixed pcm buffer (not directly used by mixer) } dma_t; -#define CF_ABSVOLUME 1 // ignores volume cvar. +#define CF_RELIABLE 1 // serverside only. yeah, evil. screw you. #define CF_FORCELOOP 2 // forces looping. set on static sounds. +#define CF_NOSPACIALISE 4 // these sounds are played at a fixed volume +//#define CF_PAUSED 8 // rate = 0. or something. +#define CF_ABSVOLUME 16 // ignores volume cvar. + typedef struct { sfx_t *sfx; // sfx number @@ -122,8 +126,8 @@ void S_Init (void); void S_Startup (void); void S_Shutdown (qboolean final); float S_GetSoundTime(int entnum, int entchannel); -void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeofs, float pitchadj); -float S_UpdateSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeofs, float pitchadj); +void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeofs, float pitchadj, unsigned int flags); +float S_UpdateSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeofs, float pitchadj, unsigned int flags); void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation); void S_StopSound (int entnum, int entchannel); void S_StopAllSounds(qboolean clear); diff --git a/engine/common/protocol.h b/engine/common/protocol.h index 38797b3cf..b09395203 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -808,9 +808,11 @@ enum clcq2_ops_e #define NQSND_VOLUME (1<<0) // a qbyte #define NQSND_ATTENUATION (1<<1) // a qbyte -#define DPSND_LOOPING (1<<2) // a long, supposedly +//#define DPSND_LOOPING (1<<2) // a long, supposedly +#define FTESND_FLAGS (1<<2) // #define DPSND_LARGEENTITY (1<<3) #define DPSND_LARGESOUND (1<<4) +//#define DPSND_SPEEDUSHORT4000 (1<<5) // ushort speed*4000 (speed is usually 1.0, a value of 0.0 is the same as 1.0) #define FTESND_TIMEOFS (1<<6) //signed short, in milliseconds. #define FTESND_PITCHADJ (1<<7) //a byte (speed percent (0=100%)) diff --git a/engine/common/world.h b/engine/common/world.h index fc574f3a0..ad1101aa9 100644 --- a/engine/common/world.h +++ b/engine/common/world.h @@ -171,7 +171,7 @@ struct world_s { void (*Event_Touch)(struct world_s *w, wedict_t *s, wedict_t *o); void (*Event_Think)(struct world_s *w, wedict_t *s); - void (*Event_Sound) (float *origin, wedict_t *entity, int channel, const char *sample, int volume, float attenuation, int pitchadj, float timeoffset); + void (*Event_Sound) (float *origin, wedict_t *entity, int channel, const char *sample, int volume, float attenuation, int pitchadj, float timeoffset, unsigned int flags); qboolean (*Event_ContentsTransition) (struct world_s *w, wedict_t *ent, int oldwatertype, int newwatertype); model_t *(*Get_CModel)(struct world_s *w, int modelindex); void (*Get_FrameState)(struct world_s *w, wedict_t *s, framestate_t *fstate); diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index c87293cb7..1496d2e61 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -3942,7 +3942,7 @@ void Shader_Finish (shader_t *s) done:; //if we've no specular map, try and find whatever the q3 syntax said. hopefully it'll be compatible... - if (!TEXVALID(s->defaulttextures->specular)) + if (!TEXVALID(s->defaulttextures->specular)) { for (pass = s->passes, i = 0; i < s->numpasses; i++, pass++) { @@ -5398,6 +5398,12 @@ static void Shader_ReadShader(shader_t *s, char *shadersource, int parsemode) memset(&parsestate, 0, sizeof(parsestate)); parsestate.mode = parsemode; + if (!s->defaulttextures) + { + s->defaulttextures = Z_Malloc(sizeof(*s->defaulttextures)); + s->numdefaulttextures = 0; + } + // set defaults s->flags = SHADER_CULL_FRONT; s->uses = 1; diff --git a/engine/gl/gl_vidcommon.c b/engine/gl/gl_vidcommon.c index 9ad8ba4b0..d147db1ee 100644 --- a/engine/gl/gl_vidcommon.c +++ b/engine/gl/gl_vidcommon.c @@ -1579,13 +1579,13 @@ static const char *glsl_hdrs[] = "#endif\n" "}\n" - "float ShadowmapFilter(sampler2DShadow samp)\n" + "float ShadowmapFilter(sampler2DShadow smap)\n" "{\n" "vec3 shadowcoord = ShadowmapCoord();\n" "#if 0\n"//def GL_ARB_texture_gather "vec2 ipart, fpart;\n" - "#define dosamp(x,y) textureGatherOffset(s_t4, ipart.xy, vec2(x,y)))\n" + "#define dosamp(x,y) textureGatherOffset(smap, ipart.xy, vec2(x,y)))\n" "vec4 tl = step(shadowcoord.z, dosamp(-1.0, -1.0));\n" "vec4 bl = step(shadowcoord.z, dosamp(-1.0, 1.0));\n" "vec4 tr = step(shadowcoord.z, dosamp(1.0, -1.0));\n" @@ -1597,7 +1597,7 @@ static const char *glsl_hdrs[] = "mix(vec4(tl.rg, tr.rg), vec4(bl.ba, br.ba), fpart.y);\n" //top+bottom rows "return dot(mix(col.rgb, col.agb, fpart.x), vec3(1.0/9.0));\n" //blend r+a, gb are mixed because its pretty much free and gives a nicer dot instruction instead of lots of adds. "#else\n" - "#define dosamp(x,y) shadow2D(samp, shadowcoord.xyz + (vec3(x,y,0.0)*l_shadowmapscale.xyx)).r\n" + "#define dosamp(x,y) shadow2D(smap, shadowcoord.xyz + (vec3(x,y,0.0)*l_shadowmapscale.xyx)).r\n" "float s = 0.0;\n" "#if r_glsl_pcf >= 1 && r_glsl_pcf < 5\n" "s += dosamp(0.0, 0.0);\n" diff --git a/engine/nacl/sys_ppapi.c b/engine/nacl/sys_ppapi.c index 4ca628ac2..727fb2787 100644 --- a/engine/nacl/sys_ppapi.c +++ b/engine/nacl/sys_ppapi.c @@ -169,6 +169,9 @@ void INS_ReInit(void) void INS_Shutdown(void) { } +void INS_EnumerateDevices(void *ctx, void(*callback)(void *ctx, char *type, char *devicename, int *qdevid)) +{ +} /* //nacl supposedly has no way to implement this (other than us writing a listfile in each directory) diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index fa8f10634..6b7a603cd 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -3032,7 +3032,7 @@ static void QCBUILTIN PF_sound (pubprogfuncs_t *prinst, struct globalvars_s *pr_ int volume; float attenuation; int pitchadj; - int flags; + unsigned int flags; float timeofs; entity = G_EDICT(prinst, OFS_PARM0); @@ -3053,9 +3053,9 @@ static void QCBUILTIN PF_sound (pubprogfuncs_t *prinst, struct globalvars_s *pr_ else { //QW uses channel&8 to mean reliable. - flags = (channel & 8)?1:0; + flags = (channel & 8)?CF_RELIABLE:0; //demangle it so the upper bits are still useful. - channel = (channel & 7) | ((channel & 0x1f0) >> 1); + channel = (channel & 7) | ((channel & ~15) >> 1); } timeofs = (svprogfuncs->callargc>7)?G_FLOAT(OFS_PARM7):0; @@ -3065,11 +3065,7 @@ static void QCBUILTIN PF_sound (pubprogfuncs_t *prinst, struct globalvars_s *pr_ if (volume > 255) volume = 255; - //should probably be an argument instead, but whatever. - if (flags & 1) - channel |= 256; - - SVQ1_StartSound (NULL, (wedict_t*)entity, channel, sample, volume, attenuation, pitchadj, timeofs); + SVQ1_StartSound (NULL, (wedict_t*)entity, channel, sample, volume, attenuation, pitchadj, timeofs, flags); } static void QCBUILTIN PF_pointsound(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) @@ -3089,7 +3085,7 @@ static void QCBUILTIN PF_pointsound(pubprogfuncs_t *prinst, struct globalvars_s else pitchpct = 0; - SVQ1_StartSound (origin, sv.world.edicts, 0, sample, volume, attenuation, pitchpct, 0); + SVQ1_StartSound (origin, sv.world.edicts, 0, sample, volume, attenuation, pitchpct, 0, 0); } //an evil one from telejano. @@ -3105,7 +3101,7 @@ static void QCBUILTIN PF_LocalSound(pubprogfuncs_t *prinst, struct globalvars_s if (!isDedicated) { if ((sfx = S_PrecacheSound(s))) - S_StartSound(cl.playerview[0].playernum, chan, sfx, cl.playerview[0].simorg, vol, 0.0, 0, 0); + S_StartSound(cl.playerview[0].playernum, chan, sfx, cl.playerview[0].simorg, vol, 0.0, 0, 0, CF_NOSPACIALISE); } #endif }; @@ -7570,7 +7566,7 @@ static void QCBUILTIN PF_h2StopSound(pubprogfuncs_t *prinst, struct globalvars_s entity = G_EDICT(prinst, OFS_PARM0); channel = G_FLOAT(OFS_PARM1); - SVQ1_StartSound (NULL, (wedict_t*)entity, channel, "", 1, 0, 0, 0); + SVQ1_StartSound (NULL, (wedict_t*)entity, channel, "", 1, 0, 0, 0, 0); } static void QCBUILTIN PF_h2updatesoundpos(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) @@ -10734,7 +10730,7 @@ void PR_DumpPlatform_f(void) {"m_draw", "void()", MENU}, {"m_keydown", "void(float scan, float chr)", MENU}, {"m_keyup", "void(float scan, float chr)", MENU}, - {"m_toggle", "void(float mode)", MENU}, + {"m_toggle", "void(float wantmode)", MENU}, {"parm17, parm18, parm19, parm20, parm21, parm22, parm23, parm24, parm25, parm26, parm27, parm28, parm29, parm30, parm31, parm32", "float", QW|NQ}, {"parm33, parm34, parm35, parm36, parm37, parm38, parm39, parm40, parm41, parm42, parm43, parm44, parm45, parm46, parm47, parm48", "float", QW|NQ}, @@ -10839,8 +10835,10 @@ void PR_DumpPlatform_f(void) {"CHAN_BODY", "const float", QW|NQ|CS, NULL, CHAN_BODY}, {"CHANF_RELIABLE", "const float", QW, NULL, 8}, - {"SOUNDFLAG_RELIABLE", "const float", QW|NQ, NULL, 1}, -// {"SOUNDFLAG_ABSOLUTEVOL", "const float", CS, NULL, 256}, + {"SOUNDFLAG_RELIABLE", "const float", QW|NQ, NULL, CF_RELIABLE}, + {"SOUNDFLAG_ABSVOLUME", "const float", /*QW|NQ|*/CS,NULL, CF_ABSVOLUME}, + {"SOUNDFLAG_FORCELOOP", "const float", /*QW|NQ|*/CS,NULL, CF_FORCELOOP}, + {"SOUNDFLAG_NOSPACIALISE", "const float", /*QW|NQ|*/CS,NULL, CF_NOSPACIALISE}, {"ATTN_NONE", "const float", QW|NQ|CS, "Sounds with this attenuation can be heard throughout the map", ATTN_NONE}, {"ATTN_NORM", "const float", QW|NQ|CS, "Standard attenuation", ATTN_NORM}, diff --git a/engine/server/pr_q1qvm.c b/engine/server/pr_q1qvm.c index 7cde1607e..e24dc45c8 100755 --- a/engine/server/pr_q1qvm.c +++ b/engine/server/pr_q1qvm.c @@ -685,7 +685,14 @@ static qintptr_t QVM_AmbientSound (void *offset, quintptr_t mask, const qintptr_ static qintptr_t QVM_Sound (void *offset, quintptr_t mask, const qintptr_t *arg) { // ( int edn, int channel, char *samp, float vol, float att ) - SVQ1_StartSound (NULL, (wedict_t*)Q1QVMPF_EdictNum(svprogfuncs, VM_LONG(arg[0])), VM_LONG(arg[1]), VM_POINTER(arg[2]), VM_FLOAT(arg[3])*255, VM_FLOAT(arg[4]), 0, 0); + int channel = VM_LONG(arg[1]); + int flags = 0; + if (channel & 8) + { //based on quakeworld, remember + channel = (channel & 7) | ((channel&~15)>>1); + flags |= CF_RELIABLE; + } + SVQ1_StartSound (NULL, (wedict_t*)Q1QVMPF_EdictNum(svprogfuncs, VM_LONG(arg[0])), channel, VM_POINTER(arg[2]), VM_FLOAT(arg[3])*255, VM_FLOAT(arg[4]), 0, 0, flags); return 0; } static qintptr_t QVM_TraceLine (void *offset, quintptr_t mask, const qintptr_t *arg) @@ -952,45 +959,73 @@ static qintptr_t QVM_strncpy (void *offset, quintptr_t mask, const qintptr_t *ar } static qintptr_t QVM_sin (void *offset, quintptr_t mask, const qintptr_t *arg) { - qintptr_t fn; - VM_FLOAT(fn)=(float)sin(VM_FLOAT(arg[0])); - return fn; + union + { + qintptr_t r; + float f; + } u = {0}; + u.f = sin(VM_FLOAT(arg[0])); + return u.r; } static qintptr_t QVM_cos (void *offset, quintptr_t mask, const qintptr_t *arg) { - qintptr_t fn; - VM_FLOAT(fn)=(float)cos(VM_FLOAT(arg[0])); - return fn; + union + { + qintptr_t r; + float f; + } u = {0}; + u.f = cos(VM_FLOAT(arg[0])); + return u.r; } static qintptr_t QVM_atan2 (void *offset, quintptr_t mask, const qintptr_t *arg) { - int fn; - VM_FLOAT(fn)=(float)atan2(VM_FLOAT(arg[0]), VM_FLOAT(arg[1])); - return fn; + union + { + qintptr_t r; + float f; + } u = {0}; + u.f = atan2(VM_FLOAT(arg[0]), VM_FLOAT(arg[1])); + return u.r; } static qintptr_t QVM_sqrt (void *offset, quintptr_t mask, const qintptr_t *arg) { - int fn; - VM_FLOAT(fn)=(float)sqrt(VM_FLOAT(arg[0])); - return fn; + union + { + qintptr_t r; + float f; + } u = {0}; + u.f = sqrt(VM_FLOAT(arg[0])); + return u.r; } static qintptr_t QVM_floor (void *offset, quintptr_t mask, const qintptr_t *arg) { - int fn; - VM_FLOAT(fn)=(float)floor(VM_FLOAT(arg[0])); - return fn; + union + { + qintptr_t r; + float f; + } u = {0}; + u.f = floor(VM_FLOAT(arg[0])); + return u.r; } static qintptr_t QVM_ceil (void *offset, quintptr_t mask, const qintptr_t *arg) { - int fn; - VM_FLOAT(fn)=(float)ceil(VM_FLOAT(arg[0])); - return fn; + union + { + qintptr_t r; + float f; + } u = {0}; + u.f = ceil(VM_FLOAT(arg[0])); + return u.r; } static qintptr_t QVM_acos (void *offset, quintptr_t mask, const qintptr_t *arg) { - int fn; - VM_FLOAT(fn)=(float)acos(VM_FLOAT(arg[0])); - return fn; + union + { + qintptr_t r; + float f; + } u = {0}; + u.f = acos(VM_FLOAT(arg[0])); + return u.r; } static qintptr_t QVM_Cmd_ArgC (void *offset, quintptr_t mask, const qintptr_t *arg) { @@ -1614,7 +1649,14 @@ static qintptr_t QVM_Map_Extension (void *offset, quintptr_t mask, const qintptr //============== general Quake services ================== -#if FTE_WORDSIZE == 64 +#if FTE_WORDSIZE == 32 && !defined(NACL) +static int syscallqvm (void *offset, quintptr_t mask, int fn, const int *arg) +{ + if (fn >= countof(traps)) + return QVM_NotYetImplemented(offset, mask, arg); + return traps[fn](offset, mask, arg); +} +#else static int syscallqvm (void *offset, quintptr_t mask, int fn, const int *arg) { qintptr_t args[13]; @@ -1625,13 +1667,6 @@ static int syscallqvm (void *offset, quintptr_t mask, int fn, const int *arg) return QVM_NotYetImplemented(offset, mask, args); return traps[fn](offset, mask, args); } -#else -static int syscallqvm (void *offset, quintptr_t mask, int fn, const int *arg) -{ - if (fn >= countof(traps)) - return QVM_NotYetImplemented(offset, mask, arg); - return traps[fn](offset, mask, arg); -} #endif static qintptr_t EXPORT_FN syscallnative (qintptr_t arg, ...) diff --git a/engine/server/savegame.c b/engine/server/savegame.c index 935b247eb..eceb0a66e 100644 --- a/engine/server/savegame.c +++ b/engine/server/savegame.c @@ -1306,6 +1306,10 @@ void SV_Loadgame_f (void) return; } +#ifdef MENU_DAT + MP_Toggle(0); +#endif + VFS_GETS(f, str, sizeof(str)-1); version = atoi(str); if (version < FTESAVEGAME_VERSION || version >= FTESAVEGAME_VERSION+GT_MAX) diff --git a/engine/server/server.h b/engine/server/server.h index 2a3f5e452..8f4e908c6 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -1138,8 +1138,8 @@ void VARGS SV_Multicast (vec3_t origin, multicast_t to); #define FULLDIMENSIONMASK 0xffffffff void SV_MulticastProtExt(vec3_t origin, multicast_t to, int dimension_mask, int with, int without); -void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, const char *sample, int volume, float attenuation, int pitchadj, float timeofs); -void SVQ1_StartSound (float *origin, wedict_t *entity, int channel, const char *sample, int volume, float attenuation, int pitchadj, float timeofs); +void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, const char *sample, int volume, float attenuation, int pitchadj, float timeofs, unsigned int flags); +void SVQ1_StartSound (float *origin, wedict_t *entity, int channel, const char *sample, int volume, float attenuation, int pitchadj, float timeofs, unsigned int flags); void SV_PrintToClient(client_t *cl, int level, const char *string); void SV_TPrintToClient(client_t *cl, int level, const char *string); void SV_StuffcmdToClient(client_t *cl, const char *string); diff --git a/engine/server/sv_ccmds.c b/engine/server/sv_ccmds.c index 754289409..99c6b6d2c 100644 --- a/engine/server/sv_ccmds.c +++ b/engine/server/sv_ccmds.c @@ -610,6 +610,10 @@ void SV_Map_f (void) } #endif +#ifdef MENU_DAT + MP_Toggle(0); +#endif + for (i=0 ; ics_connected) //so that we don't send a datagram diff --git a/engine/server/sv_phys.c b/engine/server/sv_phys.c index 1261737a9..674bc01ce 100644 --- a/engine/server/sv_phys.c +++ b/engine/server/sv_phys.c @@ -1254,7 +1254,7 @@ static void WPhys_CheckWaterTransition (world_t *w, wedict_t *ent) { if (ent->v->watertype == Q1CONTENTS_EMPTY && *sv_sound_watersplash.string) { // just crossed into water - w->Event_Sound(NULL, ent, 0, sv_sound_watersplash.string, 255, 1, 0, 0); + w->Event_Sound(NULL, ent, 0, sv_sound_watersplash.string, 255, 1, 0, 0, 0); } ent->v->watertype = cont; ent->v->waterlevel = 1; @@ -1263,7 +1263,7 @@ static void WPhys_CheckWaterTransition (world_t *w, wedict_t *ent) { if (ent->v->watertype != Q1CONTENTS_EMPTY && *sv_sound_watersplash.string) { // just crossed into open - w->Event_Sound(NULL, ent, 0, sv_sound_watersplash.string, 255, 1, 0, 0); + w->Event_Sound(NULL, ent, 0, sv_sound_watersplash.string, 255, 1, 0, 0, 0); } ent->v->watertype = Q1CONTENTS_EMPTY; ent->v->waterlevel = cont; @@ -1449,7 +1449,7 @@ static void WPhys_Physics_Step (world_t *w, wedict_t *ent) { if (hitsound && *sv_sound_land.string) { - w->Event_Sound(NULL, ent, 0, sv_sound_land.string, 255, 1, 0, 0); + w->Event_Sound(NULL, ent, 0, sv_sound_land.string, 255, 1, 0, 0, 0); } } } diff --git a/engine/server/sv_send.c b/engine/server/sv_send.c index ce6e862d0..3507560ff 100644 --- a/engine/server/sv_send.c +++ b/engine/server/sv_send.c @@ -979,24 +979,16 @@ Larger attenuations will drop off. (max 4 attenuation) ================== */ -void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, const char *sample, int volume, float attenuation, int pitchadj, float timeofs) +void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, const char *sample, int volume, float attenuation, int pitchadj, float timeofs, unsigned int flags) { - int sound_num; - int extfield_mask; + int sound_num; + int extfield_mask; int qwflags; - int i; + int i; qboolean use_phs; - qboolean reliable; + qboolean reliable = flags & 1; int requiredextensions = 0; - if (channel & 256) - { - channel &= ~256; - reliable = true; - } - else - reliable = false; - if (volume < 0 || volume > 255) { Con_Printf ("SV_StartSound: volume = %i", volume); @@ -1078,7 +1070,7 @@ void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, const cha extfield_mask |= FTESND_TIMEOFS; #ifdef PEXT_SOUNDDBL - if (channel >= 8 || ent >= 2048 || sound_num > 0xff || (pitchadj && pitchadj != 100)) + if (channel >= 8 || ent >= 2048 || sound_num > 0xff || (pitchadj && pitchadj != 100) || timeofs) { //if any of the above conditions evaluates to true, then we can't use standard qw protocols MSG_WriteByte (&sv.multicast, svcfte_soundextended); @@ -1168,7 +1160,7 @@ void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, const cha SV_MulticastProtExt(origin, reliable ? MULTICAST_ALL_R : MULTICAST_ALL, seenmask, requiredextensions, 0); } -void SVQ1_StartSound (float *origin, wedict_t *wentity, int channel, const char *sample, int volume, float attenuation, int pitchadj, float timeofs) +void SVQ1_StartSound (float *origin, wedict_t *wentity, int channel, const char *sample, int volume, float attenuation, int pitchadj, float timeofs, unsigned int flags) { edict_t *entity = (edict_t*)wentity; int i; @@ -1186,7 +1178,7 @@ void SVQ1_StartSound (float *origin, wedict_t *wentity, int channel, const char //making them all reliable avoids packetloss and phs issues. //this applies only to pushers. you won't get extra latency on player actions because of this. //be warned that it does mean you might be able to hear people triggering stuff on the other side of the map however. - channel |= 256; + flags |= CF_RELIABLE; } else if (progstype == PROG_QW) { //quakeworld puts the sound ONLY at the entity's actual origin. this is annoying and stupid. I'm not really sure what to do here. it seems wrong. @@ -1199,7 +1191,7 @@ void SVQ1_StartSound (float *origin, wedict_t *wentity, int channel, const char } } - SV_StartSound(NUM_FOR_EDICT(svprogfuncs, entity), origin, entity->xv->dimension_seen, channel, sample, volume, attenuation, pitchadj, timeofs); + SV_StartSound(NUM_FOR_EDICT(svprogfuncs, entity), origin, entity->xv->dimension_seen, channel, sample, volume, attenuation, pitchadj, timeofs, flags); } /* diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index 663908d74..87d92d2c9 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -6157,6 +6157,8 @@ void SV_RunCmdCleanup(void) playertouchmax = 0; } +void Sh_CalcPointLight(vec3_t point, vec3_t light); + /* =========== SV_RunCmd @@ -6330,8 +6332,18 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) if (sv.world.worldmodel && sv.world.worldmodel->funcs.LightPointValues) { vec3_t diffuse, ambient, dir; - sv.world.worldmodel->funcs.LightPointValues(sv.world.worldmodel, sv_player->v->origin, diffuse, ambient, dir); - sv_player->xv->light_level = (ambient[0]+ambient[1]+ambient[2])/3.0+(diffuse[0]+diffuse[1]+diffuse[2])/6.0; + float lev = 0; +#ifdef RTLIGHTS + Sh_CalcPointLight(sv_player->v->origin, ambient); + lev += VectorLength(ambient); + + if (!r_shadow_realtime_world.ival || r_shadow_realtime_world_lightmaps.value) +#endif + { + cl.worldmodel->funcs.LightPointValues(cl.worldmodel, sv_player->v->origin, ambient, diffuse, dir); + lev += (VectorLength(ambient) + VectorLength(diffuse)/2.0)/256; + } + sv_player->xv->light_level = lev * 255; } else sv_player->xv->light_level = 128; //don't know, some dummy value.