diff --git a/engine/client/cl_cg.c b/engine/client/cl_cg.c index 68004c7c7..dfc29cf5a 100644 --- a/engine/client/cl_cg.c +++ b/engine/client/cl_cg.c @@ -835,7 +835,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]), VM_LONG(arg[2]), S_PrecacheSound(VM_FROMSTRCACHE(arg[3])), VM_POINTER(arg[0]), 1, 1); + S_StartSound(VM_LONG(arg[1]), VM_LONG(arg[2]), S_PrecacheSound(VM_FROMSTRCACHE(arg[3])), VM_POINTER(arg[0]), 1, 1, 0); break; case CG_S_ADDLOOPINGSOUND: @@ -855,7 +855,7 @@ static qintptr_t CG_SystemCalls(void *offset, quintptr_t mask, qintptr_t fn, con float *org = VM_POINTER(arg[1]); vec3_t *axis = VM_POINTER(arg[2]); - S_UpdateListener(org, axis[0], axis[1], axis[2], false); + S_UpdateListener(org, axis[0], axis[1], axis[2]); } break; diff --git a/engine/client/cl_input.c b/engine/client/cl_input.c index 8fbee255b..f84021274 100644 --- a/engine/client/cl_input.c +++ b/engine/client/cl_input.c @@ -626,6 +626,8 @@ void CL_ClampPitch (int pnum) else #endif { + if (cl.fixangle[pnum]) + return; if (cl.viewangles[pnum][PITCH] > cl.maxpitch) cl.viewangles[pnum][PITCH] = cl.maxpitch; if (cl.viewangles[pnum][PITCH] < cl.minpitch) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 29b1d0ccc..f6aea004c 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -3490,13 +3490,13 @@ void Host_Frame (double time) if (cls.state == ca_active) { if (cls.protocol != CP_QUAKE3) - S_UpdateListener (r_origin, vpn, vright, vup, false); + S_UpdateListener (r_origin, vpn, vright, vup); } else - S_UpdateListener (vec3_origin, vec3_origin, vec3_origin, vec3_origin, false); - } + S_UpdateListener (vec3_origin, vec3_origin, vec3_origin, vec3_origin); - S_ExtraUpdate (); + S_Update (); + } CDAudio_Update(); diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index b625e6bea..879cb68dc 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -3353,7 +3353,7 @@ void CL_ParseStartSoundPacket(void) if (!sound_num) S_StopSound(ent, channel); else - S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation); + S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation, 0); } @@ -3431,11 +3431,11 @@ void CLQ2_ParseStartSoundPacket(void) *skin = '\0'; if (*model) { - S_StartSound (ent, channel, S_PrecacheSound(va("players/%s/%s", model, cl.sound_precache[sound_num]->name+1)), pos, volume, attenuation); + S_StartSound (ent, channel, S_PrecacheSound(va("players/%s/%s", model, cl.sound_precache[sound_num]->name+1)), pos, volume, attenuation, 0); return; } } - S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume, attenuation); + S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume, attenuation, 0); } #endif @@ -3449,6 +3449,7 @@ void CLNQ_ParseStartSoundPacket(void) int field_mask; float attenuation; int i; + int pitchadj; field_mask = MSG_ReadByte(); @@ -3462,6 +3463,11 @@ void CLNQ_ParseStartSoundPacket(void) else attenuation = DEFAULT_SOUND_PACKET_ATTENUATION; + if (field_mask & FTESND_PITCHADJ) + pitchadj = MSG_ReadChar(); + else + pitchadj = 0; + if (field_mask & DPSND_LARGEENTITY) { ent = (unsigned short)MSG_ReadShort(); @@ -3492,7 +3498,7 @@ void CLNQ_ParseStartSoundPacket(void) if (!sound_num) S_StopSound(ent, channel); else - S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation); + S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation, pitchadj); } if (ent == cl.playernum[0]+1) @@ -4753,7 +4759,8 @@ void CL_ParseServerMessage (void) received_framecount = host_framecount; cl.last_servermessage = realtime; CL_ClearProjectiles (); - cl.fixangle = false; + for (i = 0; i < MAX_SPLITS; i++) + cl.fixangle[i] = false; // // if recording demos, copy the message out @@ -4897,21 +4904,25 @@ void CL_ParseServerMessage (void) case svc_setangle: if (cls.demoplayback == DPB_MVD || cls.demoplayback == DPB_EZTV) { + vec3_t ang; i = MSG_ReadByte(); - if (i != spec_track[0] || !autocam[0]) - { //this wasn't for us. - for (i=0 ; i<3 ; i++) - MSG_ReadAngle (); - break; - } - cl.fixangle=true; for (i=0 ; i<3 ; i++) - cl.simangles[destsplit][i] = cl.viewangles[destsplit][i] = MSG_ReadAngle (); + ang[i] = MSG_ReadAngle(); + for (j = 0; j < cl.splitclients; j++) + { + if (Cam_TrackNum(j) == i) + { + cl.fixangle[j]=true; + VectorCopy(ang, cl.simangles[j]); + VectorCopy(ang, cl.viewangles[j]); + VectorCopy(ang, cl.fixangles[j]); + } + } break; } - cl.fixangle=true; + cl.fixangle[destsplit]=true; for (i=0 ; i<3 ; i++) - cl.viewangles[destsplit][i] = MSG_ReadAngle (); + cl.viewangles[destsplit][i] = cl.fixangles[destsplit][i] = MSG_ReadAngle (); // cl.viewangles[PITCH] = cl.viewangles[ROLL] = 0; break; @@ -5581,7 +5592,7 @@ void CLNQ_ParseServerMessage (void) // received_framecount = host_framecount; // cl.last_servermessage = realtime; CL_ClearProjectiles (); - cl.fixangle = false; + cl.fixangle[0] = false; cl.allowsendpacket = true; @@ -5866,8 +5877,9 @@ void CLNQ_ParseServerMessage (void) CL_SetStatFloat (0, i, j); break; case svc_setangle: + cl.fixangle[0]=true; for (i=0 ; i<3 ; i++) - cl.viewangles[0][i] = MSG_ReadAngle (); + cl.viewangles[0][i] = cl.fixangles[0][i] = MSG_ReadAngle (); // cl.viewangles[PITCH] = cl.viewangles[ROLL] = 0; break; diff --git a/engine/client/cl_pred.c b/engine/client/cl_pred.c index 40beac7e2..0c03b0384 100644 --- a/engine/client/cl_pred.c +++ b/engine/client/cl_pred.c @@ -777,7 +777,7 @@ void CL_PredictMovePNum (int pnum) { return; } - + CL_ClampPitch(pnum); if (cls.netchan.outgoing_sequence - cl.ackedinputsequence >= UPDATE_BACKUP-1) { //lagging like poo. if (!cl.intermission) //keep the angles working though. diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index abe91bb8c..0af778101 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -729,7 +729,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); + S_StartSound (-2, 0, cl_sfx_wizhit, pos, 1, 1, 0); break; case TE_KNIGHTSPIKE: // spike hitting wall @@ -742,7 +742,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); + S_StartSound (-2, 0, cl_sfx_knighthit, pos, 1, 1, 0); break; case TEDP_SPIKEQUAD: @@ -759,16 +759,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); + S_StartSound (-2, 0, cl_sfx_tink1, pos, 1, 1, 0); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1, 0); else if (rnd == 2) - S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1, 0); else - S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1, 0); } break; case TE_SPIKE: // spike hitting wall @@ -784,16 +784,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); + S_StartSound (-2, 0, cl_sfx_tink1, pos, 1, 1, 0); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1, 0); else if (rnd == 2) - S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1, 0); else - S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1, 0); } break; case TEDP_SUPERSPIKEQUAD: // super spike hitting wall @@ -811,16 +811,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); + S_StartSound (-2, 0, cl_sfx_tink1, pos, 1, 1, 0); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1, 0); else if (rnd == 2) - S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1, 0); else - S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1, 0); } break; case TE_SUPERSPIKE: // super spike hitting wall @@ -837,16 +837,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); + S_StartSound (-2, 0, cl_sfx_tink1, pos, 1, 1, 0); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1, 0); else if (rnd == 2) - S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1, 0); else - S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1, 0); } break; @@ -866,16 +866,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); + S_StartSound (-2, 0, cl_sfx_tink1, pos, 1, 1, 0); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1, 0); else if (rnd == 2) - S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1, 0); else - S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1, 0); } break; case TE_SUPERBULLET: @@ -892,16 +892,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); + S_StartSound (-2, 0, cl_sfx_tink1, pos, 1, 1, 0); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric1, pos, 1, 1, 0); else if (rnd == 2) - S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric2, pos, 1, 1, 0); else - S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_ric3, pos, 1, 1, 0); } break; #endif @@ -936,7 +936,7 @@ void CL_ParseTEnt (void) // sound - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0); // sprite if (cl_expsprite.ival) // temp hopefully @@ -976,7 +976,7 @@ void CL_ParseTEnt (void) // sound - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0); // sprite if (cl_expsprite.ival && !nqprot) // temp hopefully @@ -1015,7 +1015,7 @@ void CL_ParseTEnt (void) dl->channelfade[2] = 0; } - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0); break; case TEDP_TEI_BIGEXPLOSION: @@ -1046,7 +1046,7 @@ void CL_ParseTEnt (void) dl->channelfade[2] = 0; } - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0); break; case TE_TAREXPLOSION: // tarbaby explosion @@ -1055,7 +1055,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); + S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0); break; case TE_LIGHTNING1: // lightning bolts @@ -1860,7 +1860,7 @@ void CLQ2_ParseTEnt (void) 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); + S_StartSound (-2, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1, 0); break; case Q2TE_SHOTGUN: // bullet hitting wall @@ -1946,7 +1946,7 @@ void CLQ2_ParseTEnt (void) ex->angles[1] = 0; ex->angles[0]*=-1; - S_StartSound (-2, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1); + S_StartSound (-2, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1, 0); // light if (r_explosionlight.value) @@ -2004,9 +2004,9 @@ void CLQ2_ParseTEnt (void) // sound if (type == Q2TE_GRENADE_EXPLOSION_WATER) - S_StartSound (-2, 0, S_PrecacheSound ("weapons/xpld_wat.wav"), pos, 1, 1); + S_StartSound (-2, 0, S_PrecacheSound ("weapons/xpld_wat.wav"), pos, 1, 1, 0); else - S_StartSound (-2, 0, S_PrecacheSound ("weapons/grenlx1a.wav"), pos, 1, 1); + S_StartSound (-2, 0, S_PrecacheSound ("weapons/grenlx1a.wav"), pos, 1, 1, 0); // sprite /* @@ -2099,9 +2099,9 @@ void CLQ2_ParseTEnt (void) // sound if (type == Q2TE_ROCKET_EXPLOSION_WATER) - S_StartSound (-2, 0, S_PrecacheSound ("weapons/xpld_wat.wav"), pos, 1, 1); + S_StartSound (-2, 0, S_PrecacheSound ("weapons/xpld_wat.wav"), pos, 1, 1, 0); else - S_StartSound (-2, 0, S_PrecacheSound ("weapons/rocklx1a.wav"), pos, 1, 1); + S_StartSound (-2, 0, S_PrecacheSound ("weapons/rocklx1a.wav"), pos, 1, 1, 0); // sprite /* if (!R_ParticleExplosionHeart(pos)) @@ -2273,7 +2273,7 @@ void CLQ2_ParseTEnt (void) ex->angles[1] = 0; ex->angles[0]*=-1; - S_StartSound (-2, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1); + S_StartSound (-2, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1, 0); // light if (r_explosionlight.value) @@ -2323,7 +2323,7 @@ void CLQ2_ParseTEnt (void) ex->angles[1] = 0; ex->angles[0]*=-1; - S_StartSound (-2, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1); + S_StartSound (-2, 0, S_PrecacheSound ("weapons/lashit.wav"), pos, 1, 1, 0); // light if (r_explosionlight.value) diff --git a/engine/client/client.h b/engine/client/client.h index 6cc317f80..6a4b596ad 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -632,7 +632,8 @@ typedef struct float entgravity[MAX_SPLITS]; float maxspeed[MAX_SPLITS]; float bunnyspeedcap; - qboolean fixangle; //received a fixangle - so disable prediction till the next packet. + qboolean fixangle[MAX_SPLITS]; //received a fixangle - so disable prediction till the next packet. + vec3_t fixangles[MAX_SPLITS]; //received a fixangle - so disable prediction till the next packet. int teamplay; int deathmatch; diff --git a/engine/client/m_options.c b/engine/client/m_options.c index 1c8250761..43402932b 100644 --- a/engine/client/m_options.c +++ b/engine/client/m_options.c @@ -180,7 +180,7 @@ qboolean M_Audio_Key (int key, struct menu_s *menu) i = key - '0'; x = info->testsoundsource->common.posx - 320/2; y = info->testsoundsource->common.posy - 200/2; - sc->yaw[i] = (-atan2 (y,x)*180/M_PI) - 90; +// sc->yaw[i] = (-atan2 (y,x)*180/M_PI) - 90; sc->dist[i] = 50/sqrt(x*x+y*y); } @@ -213,8 +213,8 @@ void M_Audio_StartSound (struct menu_s *menu) for (i = 0; i < sc->sn.numchannels; i++) { - info->speaker[i]->common.posx = 320/2 - sin(sc->yaw[i]*M_PI/180) * 50/sc->dist[i]; - info->speaker[i]->common.posy = 200/2 - cos(sc->yaw[i]*M_PI/180) * 50/sc->dist[i]; +// info->speaker[i]->common.posx = 320/2 - sin(sc->yaw[i]*M_PI/180) * 50/sc->dist[i]; +// info->speaker[i]->common.posy = 200/2 - cos(sc->yaw[i]*M_PI/180) * 50/sc->dist[i]; } for (; i < 6; i++) info->speaker[i]->common.posy = -100; @@ -227,7 +227,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); + S_StartSound(-2, 0, S_PrecacheSound("player/pain3.wav"), org, 1, 4, 0); } } diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index 30862b3cb..5276f08c8 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -2436,7 +2436,7 @@ static void PF_cs_sound(progfuncs_t *prinst, struct globalvars_s *pr_globals) sfx = S_PrecacheSound(sample); if (sfx) - S_StartSound(-entity->entnum, channel, sfx, entity->v->origin, volume, attenuation); + S_StartSound(-entity->entnum, channel, sfx, entity->v->origin, volume, attenuation, 0); }; void PF_cs_pointsound(progfuncs_t *prinst, struct globalvars_s *pr_globals) @@ -2455,7 +2455,7 @@ void PF_cs_pointsound(progfuncs_t *prinst, struct globalvars_s *pr_globals) sfx = S_PrecacheSound(sample); if (sfx) - S_StartSound(0, 0, sfx, origin, volume, attenuation); + S_StartSound(0, 0, sfx, origin, volume, attenuation, 0); } static void PF_cs_particle(progfuncs_t *prinst, struct globalvars_s *pr_globals) @@ -2841,14 +2841,14 @@ static void PF_cl_te_explosion (progfuncs_t *prinst, struct globalvars_s *pr_glo R_AddStain(pos, -1, -1, -1, 100); - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0); } static void PF_cl_te_tarexplosion (progfuncs_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); + S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0); } static void PF_cl_te_wizspike (progfuncs_t *prinst, struct globalvars_s *pr_globals) { @@ -2856,7 +2856,7 @@ static void PF_cl_te_wizspike (progfuncs_t *prinst, struct globalvars_s *pr_glob 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); + S_StartSound (-2, 0, cl_sfx_knighthit, pos, 1, 1, 0); } static void PF_cl_te_knightspike (progfuncs_t *prinst, struct globalvars_s *pr_globals) { @@ -2864,7 +2864,7 @@ static void PF_cl_te_knightspike (progfuncs_t *prinst, struct globalvars_s *pr_g 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); + S_StartSound (-2, 0, cl_sfx_knighthit, pos, 1, 1, 0); } static void PF_cl_te_lavasplash (progfuncs_t *prinst, struct globalvars_s *pr_globals) { @@ -2927,7 +2927,7 @@ static void PF_cl_te_explosionquad (progfuncs_t *prinst, struct globalvars_s *pr dl->channelfade[2] = 0.12; } - S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1); + S_StartSound (-2, 0, cl_sfx_r_exp3, pos, 1, 1, 0); } //void(vector org, float radius, float lifetime, vector color) te_customflash @@ -3038,7 +3038,7 @@ static void PF_cl_te_explosionrgb (progfuncs_t *prinst, struct globalvars_s *pr_ dl->channelfade[2] = 0; } - S_StartSound (-2, 0, cl_sfx_r_exp3, org, 1, 1); + S_StartSound (-2, 0, cl_sfx_r_exp3, org, 1, 1, 0); } static void PF_cl_te_particlerain (progfuncs_t *prinst, struct globalvars_s *pr_globals) { @@ -4158,7 +4158,8 @@ static void PF_cs_setlistener (progfuncs_t *prinst, struct globalvars_s *pr_glob float *right = G_VECTOR(OFS_PARM2); float *up = G_VECTOR(OFS_PARM3); csqc_usinglistener = true; - S_UpdateListener(origin, forward, right, up, false); + S_UpdateListener(origin, forward, right, up); + S_Update(); } #define RSES_NOLERP 1 diff --git a/engine/client/r_surf.c b/engine/client/r_surf.c index 07d60af85..f0559ddee 100644 --- a/engine/client/r_surf.c +++ b/engine/client/r_surf.c @@ -1912,7 +1912,7 @@ void Surf_SetupFrame(void) } -static mesh_t *surfbatchmeshes[128]; +static mesh_t *surfbatchmeshes[256]; static void Surf_BuildBrushBatch(batch_t *batch) { model_t *model = batch->ent->model; diff --git a/engine/client/renderer.c b/engine/client/renderer.c index e5a63ac70..7e0bc1d23 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -1812,6 +1812,11 @@ TRACE(("dbg: R_RestartRenderer_f\n")); newr.fullscreen = vid_fullscreen.value; newr.rate = vid_refreshrate.value; + if (!*_vid_wait_override.string || _vid_wait_override.value < 0) + newr.wait = -1; + else + newr.wait = _vid_wait_override.value; + Q_strncpyz(newr.glrenderer, gl_driver.string, sizeof(newr.glrenderer)); newr.renderer = NULL; diff --git a/engine/client/snd_dma.c b/engine/client/snd_dma.c index 81ae1691d..807adc53f 100644 --- a/engine/client/snd_dma.c +++ b/engine/client/snd_dma.c @@ -273,50 +273,33 @@ static int SNDDMA_Init(soundcardinfo_t *sc, int *cardnum, int *drivernum) void S_DefaultSpeakerConfiguration(soundcardinfo_t *sc) { + sc->dist[0] = 1; + sc->dist[1] = 1; + sc->dist[2] = 1; + sc->dist[3] = 1; + sc->dist[4] = 1; + sc->dist[5] = 1; + if (sc->sn.numchannels < 3) { - sc->pitch[0] = 0; - sc->pitch[1] = 0; - sc->dist[0] = 1; - sc->dist[1] = 1; - sc->yaw[0] = 270; - sc->yaw[1] = 90; + VectorSet(sc->speakerdir[0], 0, 1, 0); + VectorSet(sc->speakerdir[1], 0, -1, 0); } else if (sc->sn.numchannels < 5) { - sc->pitch[0] = 0; - sc->pitch[1] = 0; - sc->pitch[2] = 0; - sc->pitch[3] = 0; - sc->dist[0] = 1; - sc->dist[1] = 1; - sc->dist[2] = 1; - sc->dist[3] = 1; - sc->yaw[0] = 315; - sc->yaw[1] = 45; - sc->yaw[2] = 225; - sc->yaw[3] = 135; + VectorSet(sc->speakerdir[0], 0.7, -0.7, 0); + VectorSet(sc->speakerdir[1], 0.7, 0.7, 0); + VectorSet(sc->speakerdir[2], -0.7, -0.7, 0); + VectorSet(sc->speakerdir[3], -0.7, 0.7, 0); } else { - sc->pitch[0] = 0; - sc->pitch[1] = 0; - sc->pitch[2] = 0; - sc->pitch[3] = 0; - sc->pitch[4] = 0; - sc->pitch[5] = 0; - sc->dist[0] = 1; - sc->dist[1] = 1; - sc->dist[2] = 1; - sc->dist[3] = 1; - sc->dist[4] = 1; - sc->dist[5] = 1; - sc->yaw[0] = 315; - sc->yaw[1] = 45; - sc->yaw[2] = 0; - sc->yaw[3] = 0; - sc->yaw[4] = 225; - sc->yaw[5] = 135; + VectorSet(sc->speakerdir[0], 0.7, -0.7, 0); + VectorSet(sc->speakerdir[1], 0.7, 0.7, 0); + VectorSet(sc->speakerdir[2], 0, 0, 0); + VectorSet(sc->speakerdir[3], 0, 0, 0); + VectorSet(sc->speakerdir[4], -0.7, -0.7, 0); + VectorSet(sc->speakerdir[5], -0.7, 0.7, 0); } } @@ -431,8 +414,6 @@ void S_Control_f (void) { int i; char *command; - if (Cmd_Argc() < 2) - return; command = Cmd_Argv (1); @@ -501,8 +482,7 @@ void S_Control_f (void) { for (i = 0; i < MAXSOUNDCHANNELS; i++) { - sc->yaw[i] = 0; - sc->pitch[i] = 0; //point forwards + VectorSet(sc->speakerdir[i], 0, 0, 0); sc->dist[i] = 1; } } @@ -510,11 +490,7 @@ void S_Control_f (void) { for (i = 0; i < MAXSOUNDCHANNELS; i++) { - if (i & 1) - sc->yaw[i] = 90; //right - else - sc->yaw[i] = 270; //left - sc->pitch[i] = 0; + VectorSet(sc->speakerdir[i], 0, (i&1)?-1:1, 0); sc->dist[i] = 1; } } @@ -522,23 +498,14 @@ void S_Control_f (void) { for (i = 0; i < MAXSOUNDCHANNELS; i++) { - if (i & 1) - sc->yaw[i] = 270; //left - else - sc->yaw[i] = 90; //right - sc->pitch[i] = 0; - sc->dist[i] = 1; + sc->speakerdir[i][1] *= -1; } } else if (!Q_strcasecmp(command, "front")) { for (i = 0; i < MAXSOUNDCHANNELS; i++) { - if (i & 1) - sc->yaw[i] = 45; //front right - else - sc->yaw[i] = 315; //front left - sc->pitch[i] = 0; + VectorSet(sc->speakerdir[i], 0.7, (i&1)?-0.7:0.7, 0); sc->dist[i] = 1; } } @@ -546,16 +513,14 @@ void S_Control_f (void) { for (i = 0; i < MAXSOUNDCHANNELS; i++) { - if (i & 1) - sc->yaw[i] = 180-45; //behind right - else - sc->yaw[i] = 180+45; //behind left - sc->pitch[i] = 0; + VectorSet(sc->speakerdir[i], -0.7, (i&1)?-0.7:0.7, 0); sc->dist[i] = 1; } } return; } + else + Con_Printf("valid commands are: off, single, multi, cardX mono, cardX stereo, cardX front, cardX back\n"); } /* @@ -807,7 +772,7 @@ channel_t *SND_PickChannel(soundcardinfo_t *sc, int entnum, int entchannel) // Check for replacement sound, or find the best one to replace first_to_die = -1; life_left = 0x7fffffff; - for (ch_idx=NUM_AMBIENTS + NUM_MUSICS; ch_idx < NUM_AMBIENTS + NUM_MUSICS + MAX_DYNAMIC_CHANNELS ; ch_idx++) + for (ch_idx=DYNAMIC_FIRST; ch_idx < DYNAMIC_STOP ; ch_idx++) { if (entchannel != 0 // channel 0 never overrides && sc->channel[ch_idx].entnum == entnum @@ -846,10 +811,10 @@ SND_Spatialize */ void SND_Spatialize(soundcardinfo_t *sc, channel_t *ch) { - vec_t dotright, dotforward, dotup; + vec3_t listener_vec; vec_t dist; vec_t scale; - vec3_t source_vec; + vec3_t world_vec; sfx_t *snd; int i; @@ -859,33 +824,32 @@ void SND_Spatialize(soundcardinfo_t *sc, channel_t *ch) for (i = 0; i < sc->sn.numchannels; i++) { ch->vol[i] = ch->master_vol * (ruleset_allow_localvolume.value ? snd_playersoundvolume.value : 1); - ch->delay[i] = 0; } return; } // calculate stereo seperation and distance attenuation snd = ch->sfx; - VectorSubtract(ch->origin, listener_origin, source_vec); + VectorSubtract(ch->origin, listener_origin, world_vec); - dist = VectorNormalize(source_vec) * ch->dist_mult; + dist = VectorNormalize(world_vec) * ch->dist_mult; - dotright = DotProduct(listener_right, source_vec); - dotforward = DotProduct(listener_forward, source_vec); - dotup = DotProduct(listener_up, source_vec); + listener_vec[1] = DotProduct(listener_right, world_vec); + listener_vec[0] = DotProduct(listener_forward, world_vec); + listener_vec[2] = DotProduct(listener_up, world_vec); if (snd_leftisright.ival) - dotright = -dotright; + listener_vec[1] = -listener_vec[1]; for (i = 0; i < sc->sn.numchannels; i++) { - scale = 1 + (dotright*sin(sc->yaw[i]*M_PI/180) + dotforward*cos(sc->yaw[i]*M_PI/180));// - dotup*cos(sc->pitch[0])*2; + scale = (1 + DotProduct(listener_vec, sc->speakerdir[i])) / 2; + if (scale > 1) + scale = 1; scale = (1.0 - dist) * scale * sc->dist[i]; ch->vol[i] = (int) (ch->master_vol * scale); if (ch->vol[i] < 0) ch->vol[i] = 0; - - ch->delay[i] = 0;//(scale[0]-1)*1024; } } @@ -893,7 +857,7 @@ void SND_Spatialize(soundcardinfo_t *sc, channel_t *ch) // Start a sound effect // ======================================================================= -void S_StartSoundCard(soundcardinfo_t *sc, int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, int startpos) +void S_StartSoundCard(soundcardinfo_t *sc, int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, int startpos, int pitchadj) { channel_t *target_chan, *check; sfxcache_t *scache; @@ -955,14 +919,15 @@ void S_StartSoundCard(soundcardinfo_t *sc, int entnum, int entchannel, sfx_t *sf startpos = scache->length - snd_speed*10; } target_chan->sfx = sfx; - target_chan->pos = startpos; - target_chan->end = sc->paintedtime + scache->length - startpos; + target_chan->rate = (1<pos = startpos*target_chan->rate; + target_chan->end = sc->paintedtime + ((scache->length - startpos)<rate; target_chan->looping = false; // if an identical sound has also been started this frame, offset the pos // a bit to keep it from just making the first one louder - check = &sc->channel[NUM_AMBIENTS]; - for (ch_idx=NUM_AMBIENTS + NUM_MUSICS; ch_idx < NUM_AMBIENTS + NUM_MUSICS + MAX_DYNAMIC_CHANNELS; ch_idx++, check++) + check = &sc->channel[DYNAMIC_FIRST]; + for (ch_idx=DYNAMIC_FIRST; ch_idx < DYNAMIC_STOP; ch_idx++, check++) { if (check == target_chan) continue; @@ -971,7 +936,7 @@ void S_StartSoundCard(soundcardinfo_t *sc, int entnum, int entchannel, sfx_t *sf skip = rand () % (int)(0.1*sc->sn.speed); if (skip >= target_chan->end) skip = target_chan->end - 1; - target_chan->pos += skip; + target_chan->pos += skip*target_chan->rate; target_chan->end -= skip; break; } @@ -986,10 +951,10 @@ void S_StartSoundDelayed(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, return; for (sc = sndcardinfo; sc; sc = sc->next) - S_StartSoundCard(sc, entnum, entchannel, sfx, origin, fvol, attenuation, -(int)(timeofs * sc->sn.speed)); + S_StartSoundCard(sc, entnum, entchannel, sfx, origin, fvol, attenuation, -(int)(timeofs * sc->sn.speed), 0); } -void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation) +void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, int pitchadj) { soundcardinfo_t *sc; @@ -997,7 +962,7 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f return; for (sc = sndcardinfo; sc; sc = sc->next) - S_StartSoundCard(sc, entnum, entchannel, sfx, origin, fvol, attenuation, 0); + S_StartSoundCard(sc, entnum, entchannel, sfx, origin, fvol, attenuation, 0, pitchadj); } qboolean S_IsPlayingSomewhere(sfx_t *s) @@ -1134,10 +1099,11 @@ void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation) } ss->sfx = sfx; + ss->rate = 1<origin); ss->master_vol = vol; ss->dist_mult = (attenuation/64) / sound_nominal_clip_dist; - ss->end = scard->paintedtime + scache->length; + ss->end = scard->paintedtime + (scache->length<rate; ss->looping = true; SND_Spatialize (scard, ss); @@ -1154,7 +1120,7 @@ void S_Music_Clear(sfx_t *onlyifsample) sfx_t *s; soundcardinfo_t *sc; int i; - for (i = NUM_AMBIENTS; i < NUM_AMBIENTS + NUM_MUSICS; i++) + for (i = MUSIC_FIRST; i < MUSIC_STOP; i++) { for (sc = sndcardinfo; sc; sc=sc->next) { @@ -1182,11 +1148,11 @@ void S_Music_Seek(float time) { soundcardinfo_t *sc; int i; - for (i = NUM_AMBIENTS; i < NUM_AMBIENTS + NUM_MUSICS; i++) + for (i = MUSIC_FIRST; i < MUSIC_STOP; i++) { for (sc = sndcardinfo; sc; sc=sc->next) { - sc->channel[i].pos += sc->sn.speed*time; + sc->channel[i].pos += sc->sn.speed*time * sc->channel[i].rate; sc->channel[i].end += sc->sn.speed*time; if (sc->channel[i].pos < 0) @@ -1217,12 +1183,12 @@ void S_UpdateAmbientSounds (soundcardinfo_t *sc) if (!snd_ambient) return; - for (i = NUM_AMBIENTS; i < NUM_AMBIENTS + NUM_MUSICS; i++) + for (i = MUSIC_FIRST; i < MUSIC_STOP; i++) { chan = &sc->channel[i]; if (!chan->sfx) { - char *nexttrack = Media_NextTrack(i-NUM_AMBIENTS); + char *nexttrack = Media_NextTrack(i-MUSIC_FIRST); sfxcache_t *scache; sfx_t *newmusic; @@ -1235,8 +1201,9 @@ void S_UpdateAmbientSounds (soundcardinfo_t *sc) if (scache) { chan->sfx = newmusic; + chan->rate = 1<pos = 0; - chan->end = sc->paintedtime + scache->length+1000; + chan->end = sc->paintedtime + ((scache->length+1000)<rate; chan->vol[0] = chan->vol[1] = chan->vol[2] = chan->vol[3] = chan->vol[4] = chan->vol[5] = chan->master_vol = 100; } } @@ -1254,14 +1221,15 @@ void S_UpdateAmbientSounds (soundcardinfo_t *sc) if (!l || !ambient_level.value) { for (ambient_channel = 0 ; ambient_channel< NUM_AMBIENTS ; ambient_channel++) - sc->channel[ambient_channel].sfx = NULL; + sc->channel[AMBIENT_FIRST+ambient_channel].sfx = NULL; return; } for (ambient_channel = 0 ; ambient_channel< NUM_AMBIENTS ; ambient_channel++) { - chan = &sc->channel[ambient_channel]; - chan->sfx = ambient_sfx[ambient_channel]; + chan = &sc->channel[AMBIENT_FIRST+ambient_channel]; + chan->sfx = ambient_sfx[AMBIENT_FIRST+ambient_channel]; + chan->rate = 1<origin); @@ -1294,23 +1262,12 @@ S_Update Called once each time through the main loop ============ */ -void S_UpdateListener(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up, qboolean dontmix) +void S_UpdateListener(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) { - soundcardinfo_t *sc; - VectorCopy(origin, listener_origin); VectorCopy(forward, listener_forward); VectorCopy(right, listener_right); VectorCopy(up, listener_up); - - if (!dontmix) - { - S_RunCapture(); - - for (sc = sndcardinfo; sc; sc = sc->next) - S_UpdateCard(sc); - } - } void S_GetListenerInfo(float *origin, float *forward, float *right, float *up) @@ -1350,8 +1307,8 @@ void S_UpdateCard(soundcardinfo_t *sc) combine = NULL; // update spatialization for static and dynamic sounds - ch = sc->channel+NUM_AMBIENTS+NUM_MUSICS; - for (i=NUM_AMBIENTS+ NUM_MUSICS ; itotal_chans; i++, ch++) + ch = sc->channel+DYNAMIC_FIRST; + for (i=DYNAMIC_FIRST ; itotal_chans; i++, ch++) { if (!ch->sfx) continue; @@ -1363,7 +1320,7 @@ void S_UpdateCard(soundcardinfo_t *sc) // try to combine static sounds with a previous channel of the same // sound effect so we don't mix five torches every frame - if (i > MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS + NUM_MUSICS) + if (i >= DYNAMIC_STOP) { // see if it can just use the last one if (combine && combine->sfx == ch->sfx) @@ -1378,8 +1335,8 @@ void S_UpdateCard(soundcardinfo_t *sc) continue; } // search for one - combine = sc->channel+MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS + NUM_MUSICS; - for (j=MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS+ NUM_MUSICS ; jchannel+DYNAMIC_FIRST; + for (j=DYNAMIC_FIRST ; jsfx == ch->sfx) break; @@ -1402,8 +1359,6 @@ void S_UpdateCard(soundcardinfo_t *sc) continue; } } - - } // @@ -1454,6 +1409,16 @@ void GetSoundtime(soundcardinfo_t *sc) soundtime = sc->buffers*fullsamples + samplepos/sc->sn.numchannels; } +void S_Update (void) +{ + soundcardinfo_t *sc; + + S_RunCapture(); + + for (sc = sndcardinfo; sc; sc = sc->next) + S_UpdateCard(sc); +} + void S_ExtraUpdate (void) { soundcardinfo_t *sc; @@ -1481,7 +1446,6 @@ void S_Update_(soundcardinfo_t *sc) unsigned endtime; int samps; - if (sc->selfpainting) return; @@ -1542,7 +1506,7 @@ void S_Play(void) else Q_strncpyz(name, Cmd_Argv(i), sizeof(name)); sfx = S_PrecacheSound(name); - S_StartSound(cl.playernum[0]+1, -1, sfx, vec3_origin, 1.0, 0.0); + S_StartSound(cl.playernum[0]+1, -1, sfx, vec3_origin, 1.0, 0.0, 0); // hash++; i++; } @@ -1568,7 +1532,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.playernum[0]+1, -1, sfx, vec3_origin, vol, 0.0); + S_StartSound(cl.playernum[0]+1, -1, sfx, vec3_origin, vol, 0.0, 0); // hash; i+=2; } @@ -1614,7 +1578,7 @@ void S_LocalSound (char *sound) Con_Printf ("S_LocalSound: can't cache %s\n", sound); return; } - S_StartSound (-1, -1, sfx, vec3_origin, 1, 1); + S_StartSound (-1, -1, sfx, vec3_origin, 1, 1, 0); } @@ -1815,7 +1779,7 @@ void S_RawAudio(int sourceid, qbyte *data, int speed, int samples, int channels, for (i = 0; i < si->total_chans; i++) if (si->channel[i].sfx == &s->sfx) { - si->channel[i].pos -= prepadl; + si->channel[i].pos -= prepadl*si->channel[i].rate; // si->channel[i].end -= prepadl; si->channel[i].end += outsamples; @@ -1828,7 +1792,7 @@ void S_RawAudio(int sourceid, qbyte *data, int speed, int samples, int channels, } if (i == si->total_chans) //this one wasn't playing. { - S_StartSoundCard(si, -1, 0, &s->sfx, r_origin, 1, 32767, 500); + S_StartSoundCard(si, -1, 0, &s->sfx, r_origin, 1, 32767, 500, 0); // Con_Printf("Restarted\n"); } } diff --git a/engine/client/snd_mix.c b/engine/client/snd_mix.c index 94819172c..d5f687514 100644 --- a/engine/client/snd_mix.c +++ b/engine/client/snd_mix.c @@ -124,7 +124,6 @@ CHANNEL MIXING */ void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime); -//void SND_PaintChannelFrom8Duel (channel_t *ch, sfxcache_t *sc, int endtime); void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime); void SND_PaintChannelFrom8_4Speaker (channel_t *ch, sfxcache_t *sc, int count); void SND_PaintChannelFrom16_4Speaker (channel_t *ch, sfxcache_t *sc, int count); @@ -167,10 +166,10 @@ void S_PaintChannels(soundcardinfo_t *sc, int endtime) if (!scache) continue; - if (ch->pos > scache->length) //cache was flushed and gamedir changed. + if ((ch->pos>>PITCHSHIFT) > scache->length) //cache was flushed and gamedir changed. { - ch->pos = scache->length; - ch->end = scache->length; + ch->pos = scache->length*ch->rate; + ch->end = scache->length*ch->rate; } @@ -185,6 +184,7 @@ void S_PaintChannels(soundcardinfo_t *sc, int endtime) // start = ch->end - scache->length; // samples = end - start; +#pragma message("pitch fix needed") ch->sfx->decoder->decodemore(ch->sfx, end - (ch->end - scache->length) + 1); // ch->pos + end-ltime+1); @@ -198,7 +198,7 @@ void S_PaintChannels(soundcardinfo_t *sc, int endtime) { for (j = 0; j < sndc->total_chans; j++) if (sndc->channel[j].sfx == ch->sfx) //extend all of these. - ch->end += len_diff; + ch->end += len_diff*ch->rate; } } @@ -209,6 +209,7 @@ void S_PaintChannels(soundcardinfo_t *sc, int endtime) else count = end - ltime; + if (count > 0) { if (ch->pos < 0) //delay the sound a little @@ -216,7 +217,7 @@ void S_PaintChannels(soundcardinfo_t *sc, int endtime) if (count > -ch->pos) count = -ch->pos; ltime += count; - ch->pos += count; + ch->pos += count*ch->rate; continue; } @@ -252,8 +253,8 @@ void S_PaintChannels(soundcardinfo_t *sc, int endtime) { if (scache->length == scache->loopstart) break; - ch->pos = scache->loopstart; - ch->end = ltime + scache->length - ch->pos; + ch->pos = scache->loopstart*ch->rate; + ch->end = ltime + ((scache->length - scache->loopstart)<rate; if (!scache->length) { scache->loopstart=-1; @@ -263,7 +264,7 @@ void S_PaintChannels(soundcardinfo_t *sc, int endtime) else if (ch->looping && scache->length) { ch->pos = 0; - ch->end = ltime + scache->length - ch->pos; + ch->end = ltime + ((scache->length)<rate; } else { // channel just stopped @@ -286,8 +287,6 @@ void S_PaintChannels(soundcardinfo_t *sc, int endtime) } } -//if defined(NOSOUNDASM) || !id386 - void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count) { int data; @@ -298,47 +297,30 @@ void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count) ch->vol[0] = 255; if (ch->vol[1] > 255) ch->vol[1] = 255; - - sfx = (signed char *)sc->data + ch->pos; - for (i=0 ; irate != (1<vol[0] * data; - paintbuffer[i].s[1] += ch->vol[1] * data; + sfx = (signed char *)sc->data; + for (i=0 ; ipos>>PITCHSHIFT]; + ch->pos += ch->rate; + paintbuffer[i].s[0] += ch->vol[0] * data; + paintbuffer[i].s[1] += ch->vol[1] * data; + } } - - ch->pos += count; -} - -#if 0 -void SND_PaintChannelFrom8Duel (channel_t *ch, sfxcache_t *sc, int count) -{ - signed char *sfx1, *sfx2; - int i; - - if (ch->vol[0] > 255) - ch->vol[0] = 255; - if (ch->vol[1] > 255) - ch->vol[1] = 255; - - i = ch->pos - ch->delay[0]; - if (i < 0) i = 0; - sfx1 = (signed char *)sc->data + i; - i = ch->pos - ch->delay[1]; - if (i < 0) i = 0; - sfx2 = (signed char *)sc->data + i; - - for (i=0 ; ivol[0] * sfx1[i]; - paintbuffer[i].s[1] += ch->vol[1] * sfx2[i]; + sfx = (signed char *)sc->data + (ch->pos>>PITCHSHIFT); + for (i=0 ; ivol[0] * data; + paintbuffer[i].s[1] += ch->vol[1] * data; + } + ch->pos += count<pos += count; } -#endif -//endif // !id386 void SND_PaintChannelFrom8Stereo (channel_t *ch, sfxcache_t *sc, int count) { @@ -351,15 +333,26 @@ void SND_PaintChannelFrom8Stereo (channel_t *ch, sfxcache_t *sc, int count) if (ch->vol[1] > 255) ch->vol[1] = 255; - sfx = (signed char *)sc->data + ch->pos; - - for (i=0 ; ivol[0] * sfx[(i<<1)]; - paintbuffer[i].s[1] += ch->vol[1] * sfx[(i<<1)+1]; + if (ch->rate != (1<data; + for (i=0 ; ivol[0] * sfx[(ch->pos>>(PITCHSHIFT-1))&~1]; + paintbuffer[i].s[1] += ch->vol[1] * sfx[(ch->pos>>(PITCHSHIFT-1))|1]; + ch->pos += ch->rate; + } + } + else + { + sfx = (signed char *)sc->data + (ch->pos>>PITCHSHIFT)*2; + for (i=0 ; ivol[0] * sfx[(i<<1)]; + paintbuffer[i].s[1] += ch->vol[1] * sfx[(i<<1)+1]; + } + ch->pos += count<pos += count; } void SND_PaintChannelFrom8_4Speaker (channel_t *ch, sfxcache_t *sc, int count) @@ -376,17 +369,32 @@ void SND_PaintChannelFrom8_4Speaker (channel_t *ch, sfxcache_t *sc, int count) if (ch->vol[3] > 255) ch->vol[3] = 255; - sfx = (signed char *)sc->data + ch->pos; - - for (i=0 ; irate != (1<vol[0] * sfx[i]; - paintbuffer[i].s[1] += ch->vol[1] * sfx[i]; - paintbuffer[i].s[2] += ch->vol[2] * sfx[i]; - paintbuffer[i].s[3] += ch->vol[3] * sfx[i]; + signed char data; + sfx = (signed char *)sc->data; + for (i=0 ; ipos>>PITCHSHIFT]; + ch->pos += ch->rate; + paintbuffer[i].s[0] += ch->vol[0] * data; + paintbuffer[i].s[1] += ch->vol[1] * data; + paintbuffer[i].s[2] += ch->vol[2] * data; + paintbuffer[i].s[3] += ch->vol[3] * data; + } + } + else + { + sfx = (signed char *)sc->data + (ch->pos>>PITCHSHIFT); + for (i=0 ; ivol[0] * sfx[i]; + paintbuffer[i].s[1] += ch->vol[1] * sfx[i]; + paintbuffer[i].s[2] += ch->vol[2] * sfx[i]; + paintbuffer[i].s[3] += ch->vol[3] * sfx[i]; + } + ch->pos += count<pos += count; } void SND_PaintChannelFrom8_6Speaker (channel_t *ch, sfxcache_t *sc, int count) @@ -407,19 +415,36 @@ void SND_PaintChannelFrom8_6Speaker (channel_t *ch, sfxcache_t *sc, int count) if (ch->vol[5] > 255) ch->vol[5] = 255; - sfx = (signed char *)sc->data + ch->pos; - - for (i=0 ; ivol[0] * sfx[i]; - paintbuffer[i].s[1] += ch->vol[1] * sfx[i]; - paintbuffer[i].s[2] += ch->vol[2] * sfx[i]; - paintbuffer[i].s[3] += ch->vol[3] * sfx[i]; - paintbuffer[i].s[4] += ch->vol[4] * sfx[i]; - paintbuffer[i].s[5] += ch->vol[5] * sfx[i]; + if (ch->rate != (1<data; + for (i=0 ; ipos>>PITCHSHIFT]; + ch->pos += ch->rate; + paintbuffer[i].s[0] += ch->vol[0] * data; + paintbuffer[i].s[1] += ch->vol[1] * data; + paintbuffer[i].s[2] += ch->vol[2] * data; + paintbuffer[i].s[3] += ch->vol[3] * data; + paintbuffer[i].s[4] += ch->vol[4] * data; + paintbuffer[i].s[5] += ch->vol[5] * data; + } + } + else + { + sfx = (signed char *)sc->data + (ch->pos>>PITCHSHIFT); + for (i=0 ; ivol[0] * sfx[i]; + paintbuffer[i].s[1] += ch->vol[1] * sfx[i]; + paintbuffer[i].s[2] += ch->vol[2] * sfx[i]; + paintbuffer[i].s[3] += ch->vol[3] * sfx[i]; + paintbuffer[i].s[4] += ch->vol[4] * sfx[i]; + paintbuffer[i].s[5] += ch->vol[5] * sfx[i]; + } + ch->pos += count<pos += count; } @@ -434,18 +459,32 @@ void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count) leftvol = ch->vol[0]; rightvol = ch->vol[1]; - sfx = (signed short *)sc->data + ch->pos; - for (i=0 ; irate != (1<> 8; - right = (data * rightvol) >> 8; - paintbuffer[i].s[0] += left; - paintbuffer[i].s[1] += right; + signed short data; + sfx = (signed short *)sc->data; + for (i=0 ; ipos>>PITCHSHIFT]; + ch->pos += ch->rate; + paintbuffer[i].s[0] += (leftvol * data)>>8; + paintbuffer[i].s[1] += (rightvol * data)>>8; + } + } + else + { + sfx = (signed short *)sc->data + (ch->pos>>PITCHSHIFT); + for (i=0 ; i> 8; + right = (data * rightvol) >> 8; + paintbuffer[i].s[0] += left; + paintbuffer[i].s[1] += right; + } + ch->pos += count<pos += count; } void SND_PaintChannelFrom16Stereo (channel_t *ch, sfxcache_t *sc, int count) @@ -456,15 +495,30 @@ void SND_PaintChannelFrom16Stereo (channel_t *ch, sfxcache_t *sc, int count) leftvol = ch->vol[0]; rightvol = ch->vol[1]; - sfx = (signed short *)sc->data + ch->pos*2; - for (i=0 ; irate != (1<> 8; - paintbuffer[i].s[1] += (*sfx++ * rightvol) >> 8; + signed short l, r; + sfx = (signed short *)sc->data; + for (i=0 ; ipos>>(PITCHSHIFT-1))&~1]; + r = sfx[(ch->pos>>(PITCHSHIFT-1))|1]; + ch->pos += ch->rate; + paintbuffer[i].s[0] += (ch->vol[0] * l)>>8; + paintbuffer[i].s[1] += (ch->vol[1] * r)>>8; + } + } + else + { + sfx = (signed short *)sc->data + (ch->pos>>PITCHSHIFT)*2; + for (i=0 ; i> 8; + paintbuffer[i].s[1] += (*sfx++ * rightvol) >> 8; + } + ch->pos += count<pos += count; } void SND_PaintChannelFrom16_6Speaker (channel_t *ch, sfxcache_t *sc, int count) @@ -479,19 +533,37 @@ void SND_PaintChannelFrom16_6Speaker (channel_t *ch, sfxcache_t *sc, int count) vol[3] = ch->vol[3]; vol[4] = ch->vol[4]; vol[5] = ch->vol[5]; - sfx = (signed short *)sc->data + ch->pos; - for (i=0 ; irate != (1<> 8; - paintbuffer[i].s[1] += (sfx[i] * vol[1]) >> 8; - paintbuffer[i].s[2] += (sfx[i] * vol[2]) >> 8; - paintbuffer[i].s[3] += (sfx[i] * vol[3]) >> 8; - paintbuffer[i].s[4] += (sfx[i] * vol[4]) >> 8; - paintbuffer[i].s[5] += (sfx[i] * vol[5]) >> 8; + signed short data; + sfx = (signed short *)sc->data; + for (i=0 ; ipos>>PITCHSHIFT]; + ch->pos += ch->rate; + paintbuffer[i].s[0] += (vol[0] * data)>>8; + paintbuffer[i].s[1] += (vol[1] * data)>>8; + paintbuffer[i].s[2] += (vol[2] * data)>>8; + paintbuffer[i].s[3] += (vol[3] * data)>>8; + paintbuffer[i].s[4] += (vol[4] * data)>>8; + paintbuffer[i].s[5] += (vol[5] * data)>>8; + } + } + else + { + sfx = (signed short *)sc->data + (ch->pos>>PITCHSHIFT); + for (i=0 ; i> 8; + paintbuffer[i].s[1] += (sfx[i] * vol[1]) >> 8; + paintbuffer[i].s[2] += (sfx[i] * vol[2]) >> 8; + paintbuffer[i].s[3] += (sfx[i] * vol[3]) >> 8; + paintbuffer[i].s[4] += (sfx[i] * vol[4]) >> 8; + paintbuffer[i].s[5] += (sfx[i] * vol[5]) >> 8; + } + ch->pos += count<pos += count; } void SND_PaintChannelFrom16_4Speaker (channel_t *ch, sfxcache_t *sc, int count) @@ -504,15 +576,31 @@ void SND_PaintChannelFrom16_4Speaker (channel_t *ch, sfxcache_t *sc, int count) vol[1] = ch->vol[1]; vol[2] = ch->vol[2]; vol[3] = ch->vol[3]; - sfx = (signed short *)sc->data + ch->pos; - for (i=0 ; irate != (1<> 8; - paintbuffer[i].s[1] += (sfx[i] * vol[1]) >> 8; - paintbuffer[i].s[2] += (sfx[i] * vol[2]) >> 8; - paintbuffer[i].s[3] += (sfx[i] * vol[3]) >> 8; + signed short data; + sfx = (signed short *)sc->data; + for (i=0 ; ipos>>PITCHSHIFT]; + ch->pos += ch->rate; + paintbuffer[i].s[0] += (vol[0] * data)>>8; + paintbuffer[i].s[1] += (vol[1] * data)>>8; + paintbuffer[i].s[2] += (vol[2] * data)>>8; + paintbuffer[i].s[3] += (vol[3] * data)>>8; + } + } + else + { + sfx = (signed short *)sc->data + ch->pos; + for (i=0 ; i> 8; + paintbuffer[i].s[1] += (sfx[i] * vol[1]) >> 8; + paintbuffer[i].s[2] += (sfx[i] * vol[2]) >> 8; + paintbuffer[i].s[3] += (sfx[i] * vol[3]) >> 8; + } + ch->pos += count<pos += count; } diff --git a/engine/client/sound.h b/engine/client/sound.h index 54922eae8..a119f299b 100644 --- a/engine/client/sound.h +++ b/engine/client/sound.h @@ -81,13 +81,16 @@ typedef struct unsigned char *buffer; } dma_t; +#define PITCHSHIFT 8 + typedef struct { sfx_t *sfx; // sfx number int vol[MAXSOUNDCHANNELS]; // 0-255 volume - int delay[MAXSOUNDCHANNELS]; +// int delay[MAXSOUNDCHANNELS]; int end; // end time in global paintsamples - int pos; // sample position in sfx, <0 means delay sound start + int pos; // sample position in sfx, <0 means delay sound start (shifted up by 8) + int rate; // 24.8 fixed point rate scaling int looping; // where to loop, -1 = no looping int entnum; // to allow overriding a specific sound int entchannel; //int audio_fd @@ -112,13 +115,14 @@ typedef struct soundcardinfo_s soundcardinfo_t; void S_Init (void); void S_Startup (void); void S_Shutdown (void); -void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation); +void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, int pitchadj); void S_StartSoundDelayed(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeofs); 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); -void S_UpdateListener(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up, qboolean dontmix); +void S_UpdateListener(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up); void S_GetListenerInfo(float *origin, float *forward, float *right, float *up); +void S_Update (void); void S_ExtraUpdate (void); qboolean S_HaveOutput(void); @@ -180,10 +184,19 @@ void OpenAL_CvarInit(void); // User-setable variables // ==================================================================== -#define MAX_CHANNELS 256 -#define MAX_DYNAMIC_CHANNELS 8 +#define MAX_CHANNELS 256 /*tracked sounds (including statics)*/ +#define MAX_DYNAMIC_CHANNELS 8 /*playing sounds (identical ones merge)*/ +#define NUM_MUSICS 1 + +#define AMBIENT_FIRST 0 +#define AMBIENT_STOP NUM_AMBIENTS +#define MUSIC_FIRST AMBIENT_STOP +#define MUSIC_STOP (MUSIC_FIRST + NUM_MUSICS) +#define DYNAMIC_FIRST MUSIC_STOP +#define DYNAMIC_STOP (DYNAMIC_FIRST + MAX_DYNAMIC_CHANNELS) + // // Fake dma is a synchronous faking of the DMA progress used for // isolating performance in the renderer. The fakedma_updates is @@ -235,9 +248,9 @@ struct soundcardinfo_s { //windows has one defined AFTER directsound struct soundcardinfo_s *next; //speaker orientations for spacialisation. - float dist[MAX_CHANNELS]; - float pitch[MAX_CHANNELS]; - float yaw[MAX_CHANNELS]; + float dist[MAXSOUNDCHANNELS]; + + vec3_t speakerdir[MAXSOUNDCHANNELS]; //info on which sound effects are playing channel_t channel[MAX_CHANNELS]; diff --git a/engine/client/vid.h b/engine/client/vid.h index 9fcdab73c..1f38a7635 100644 --- a/engine/client/vid.h +++ b/engine/client/vid.h @@ -34,6 +34,7 @@ typedef struct { qboolean fullscreen; int bpp; int rate; + int wait; //-1 = default, 0 = off, 1 = on, 2 = every other int multisample; //for opengl antialiasing (which requires context stuff) char glrenderer[MAX_QPATH]; struct rendererinfo_s *renderer; diff --git a/engine/client/view.c b/engine/client/view.c index 5de0d77b4..5fe4c37e2 100644 --- a/engine/client/view.c +++ b/engine/client/view.c @@ -372,13 +372,6 @@ void GLV_Gamma_Callback(struct cvar_s *var, char *oldvalue) } #endif -qboolean V_CheckGamma (void) -{ - return false; -} - - - /* =============== V_ParseDamage @@ -986,7 +979,15 @@ void V_CalcRefdef (int pnum) r_refdef.vieworg[1] += 1.0/16; r_refdef.vieworg[2] += 1.0/16; - VectorCopy (cl.simangles[pnum], r_refdef.viewangles); + if (cl.fixangle[pnum]) + { + VectorCopy (cl.fixangles[pnum], r_refdef.viewangles); + } + else + { + VectorCopy (cl.simangles[pnum], r_refdef.viewangles); + } + VectorCopy (r_refdef.viewangles, view->angles); //copy before it gets manipulatd V_CalcViewRoll (pnum); V_AddIdle (pnum); @@ -1014,13 +1015,9 @@ void V_CalcRefdef (int pnum) // v_viewheight only affects the view if the player is alive r_refdef.vieworg[2] += bob; } - -// offsets - AngleVectors (cl.simangles[pnum], forward, right, up); // set up gun position - VectorCopy (cl.simangles[pnum], view->angles); - + AngleVectors (view->angles, forward, right, up); CalcGunAngle (pnum); VectorCopy (r_refdef.vieworg, view->origin); diff --git a/engine/client/view.h b/engine/client/view.h index f6c66f7ea..d9adb6ec5 100644 --- a/engine/client/view.h +++ b/engine/client/view.h @@ -32,7 +32,6 @@ float V_CalcRoll (vec3_t angles, vec3_t velocity); void GLV_UpdatePalette (qboolean force, double ftime); void SWV_UpdatePalette (qboolean force, double ftime); void V_ClearCShifts (void); -qboolean V_CheckGamma (void); void V_AddEntity(entity_t *in); void VQ2_AddLerpEntity(entity_t *in); void V_AddAxisEntity(entity_t *in); diff --git a/engine/client/winquake.h b/engine/client/winquake.h index 0ec8516a2..ae5ac623e 100644 --- a/engine/client/winquake.h +++ b/engine/client/winquake.h @@ -45,12 +45,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define WM_MOUSEWHEEL 0x020A #endif -#ifndef SERVERONLY -#ifdef AVAIL_DDRAW -#include -#endif -#endif - #undef byte extern HINSTANCE global_hInstance; diff --git a/engine/common/bspfile.h b/engine/common/bspfile.h index d3925776c..f52f7d42c 100644 --- a/engine/common/bspfile.h +++ b/engine/common/bspfile.h @@ -216,7 +216,6 @@ typedef struct #define AMBIENT_LAVA 3 #define NUM_AMBIENTS 4 // automatic ambient sounds -#define NUM_MUSICS 1 // leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas // all other leafs need visibility info diff --git a/engine/common/com_mesh.c b/engine/common/com_mesh.c index 6819e1b1f..b02ea86f9 100644 --- a/engine/common/com_mesh.c +++ b/engine/common/com_mesh.c @@ -902,6 +902,7 @@ void R_LightArraysByte(vecV_t *coords, byte_vec4_t *colours, int vertcount, vec3 { extern cvar_t r_vertexdlights; int i; + int c; float l; byte_vec4_t ambientlightb; @@ -921,16 +922,22 @@ void R_LightArraysByte(vecV_t *coords, byte_vec4_t *colours, int vertcount, vec3 } else { - vec3_t meanambient; + byte_vec4_t meanambient; /*dotproduct will return a value between 1 and -1, so increase the ambient to be correct for normals facing away from the light*/ VectorMA(ambientlightb, 1, shadelightb, meanambient); for (i = vertcount-1; i >= 0; i--) { l = DotProduct(normals[i], shadevector); - colours[i][0] = l*shadelightb[0]+meanambient[0]; - colours[i][1] = l*shadelightb[1]+meanambient[1]; - colours[i][2] = l*shadelightb[2]+meanambient[2]; + c = l*shadelightb[0]; + c += meanambient[0]; + colours[i][0] = bound(0, c, 255); + c = l*shadelightb[1]; + c += meanambient[1]; + colours[i][1] = bound(0, c, 255); + c = l*shadelightb[2]; + c += meanambient[2]; + colours[i][2] = bound(0, c, 255); } } } diff --git a/engine/common/protocol.h b/engine/common/protocol.h index e82a1699f..9ba28c00f 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -603,6 +603,7 @@ enum clcq2_ops_e #define DPSND_LOOPING (1<<2) // a long, supposedly #define DPSND_LARGEENTITY (1<<3) #define DPSND_LARGESOUND (1<<4) +#define FTESND_PITCHADJ (1<<7) //a char (final rate is (1<<8)+pitch as 24.8 fixed point) #define DEFAULT_SOUND_PACKET_VOLUME 255 #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0 diff --git a/engine/d3d/d3d_backend.c b/engine/d3d/d3d_backend.c index 6e6bde488..b26bf3b7a 100644 --- a/engine/d3d/d3d_backend.c +++ b/engine/d3d/d3d_backend.c @@ -9,7 +9,7 @@ extern LPDIRECT3DDEVICE9 pD3DDev9; //#define d3dcheck(foo) foo -#define d3dcheck(foo) do{HRESULT err = foo; if (FAILED(err)) Sys_Error("D3D reported error on line %i - error %x\n", __LINE__, err);} while(0) +#define d3dcheck(foo) do{HRESULT err = foo; if (FAILED(err)) Sys_Error("D3D reported error on backend line %i - error 0x%x\n", __LINE__, err);} while(0) #define MAX_TMUS 4 @@ -114,6 +114,10 @@ typedef struct IDirect3DIndexBuffer9 *dynidx_buff; unsigned int dynidx_offs; unsigned int dynidx_size; + + unsigned int wbatch; + unsigned int maxwbatches; + batch_t *wbatches; } d3dbackend_t; #define DYNVBUFFSIZE 65536 @@ -135,12 +139,126 @@ enum }; IDirect3DVertexDeclaration9 *vertexdecls[D3D_VDEC_MAX]; + +void BE_D3D_Reset(qboolean before) +{ + int i, tmu; + if (before) + { + IDirect3DDevice9_SetVertexDeclaration(pD3DDev9, NULL); + shaderstate.curvertdecl = 0; + for (i = 0; i < 5+MAX_TMUS; i++) + IDirect3DDevice9_SetStreamSource(pD3DDev9, i, NULL, 0, 0); + IDirect3DDevice9_SetIndices(pD3DDev9, NULL); + + if (shaderstate.dynxyz_buff) + IDirect3DVertexBuffer9_Release(shaderstate.dynxyz_buff); + shaderstate.dynxyz_buff = NULL; + for (tmu = 0; tmu < MAX_TMUS; tmu++) + { + if (shaderstate.dynst_buff[tmu]) + IDirect3DVertexBuffer9_Release(shaderstate.dynst_buff[tmu]); + shaderstate.dynst_buff[tmu] = NULL; + } + if (shaderstate.dyncol_buff) + IDirect3DVertexBuffer9_Release(shaderstate.dyncol_buff); + shaderstate.dyncol_buff = NULL; + if (shaderstate.dynidx_buff) + IDirect3DIndexBuffer9_Release(shaderstate.dynidx_buff); + shaderstate.dynidx_buff = NULL; + + for (i = 0; i < D3D_VDEC_MAX; i++) + { + if (vertexdecls[i]) + IDirect3DVertexDeclaration9_Release(vertexdecls[i]); + vertexdecls[i] = NULL; + } + } + else + { + D3DVERTEXELEMENT9 decl[8], declend=D3DDECL_END(); + int elements; + + for (i = 0; i < D3D_VDEC_MAX; i++) + { + elements = 0; + decl[elements].Stream = 0; + decl[elements].Offset = 0; + decl[elements].Type = D3DDECLTYPE_FLOAT3; + decl[elements].Method = D3DDECLMETHOD_DEFAULT; + decl[elements].Usage = D3DDECLUSAGE_POSITION; + decl[elements].UsageIndex = 0; + elements++; + + if (i & D3D_VDEC_COL4B) + { + decl[elements].Stream = 1; + decl[elements].Offset = 0; + decl[elements].Type = D3DDECLTYPE_D3DCOLOR; + decl[elements].Method = D3DDECLMETHOD_DEFAULT; + decl[elements].Usage = D3DDECLUSAGE_COLOR; + decl[elements].UsageIndex = 0; + elements++; + } + + if (i & D3D_VDEC_NORMS) + { + decl[elements].Stream = 2; + decl[elements].Offset = 0; + decl[elements].Type = D3DDECLTYPE_FLOAT2; + decl[elements].Method = D3DDECLMETHOD_DEFAULT; + decl[elements].Usage = D3DDECLUSAGE_TEXCOORD; + decl[elements].UsageIndex = 1; + elements++; + + decl[elements].Stream = 3; + decl[elements].Offset = 0; + decl[elements].Type = D3DDECLTYPE_FLOAT2; + decl[elements].Method = D3DDECLMETHOD_DEFAULT; + decl[elements].Usage = D3DDECLUSAGE_TEXCOORD; + decl[elements].UsageIndex = 1; + elements++; + + decl[elements].Stream = 4; + decl[elements].Offset = 0; + decl[elements].Type = D3DDECLTYPE_FLOAT2; + decl[elements].Method = D3DDECLMETHOD_DEFAULT; + decl[elements].Usage = D3DDECLUSAGE_TEXCOORD; + decl[elements].UsageIndex = 1; + elements++; + } + + for (tmu = 0; tmu < MAX_TMUS; tmu++) + { + if (i & (D3D_VDEC_ST0<flags & SHADER_PASS_NOCOLORARRAY) - usearray = false; - else - usearray = true; m = shaderstate.meshlist[0]; - if (usearray && m->colors4b_array) - { - shaderstate.passsinglecolour = false; - shaderstate.passcolour = D3DCOLOR_RGBA(255,255,255,255); - - ret |= D3D_VDEC_COL4B; - allocvertexbuffer(shaderstate.dyncol_buff, shaderstate.dyncol_size, &shaderstate.dyncol_offs, (void**)&map, vertcount*sizeof(D3DCOLOR)); - for (vertcount = 0, mno = 0; mno < shaderstate.nummeshes; mno++) - { - m = shaderstate.meshlist[mno]; - /*FIXME: rgba->bgra...*/ - memcpy((char*)map+vertcount*sizeof(D3DCOLOR), m->colors4b_array, m->numvertexes*sizeof(D3DCOLOR)); - vertcount += m->numvertexes; - } - d3dcheck(IDirect3DVertexBuffer9_Unlock(shaderstate.dyncol_buff)); - d3dcheck(IDirect3DDevice9_SetStreamSource(pD3DDev9, 1, shaderstate.dyncol_buff, shaderstate.dyncol_offs - vertcount*sizeof(D3DCOLOR), sizeof(D3DCOLOR))); - } - else if (usearray && m->colors4f_array) - { - unsigned int v; - float *src; - shaderstate.passsinglecolour = false; - shaderstate.passcolour = D3DCOLOR_RGBA(255,255,255,255); - - ret |= D3D_VDEC_COL4B; - allocvertexbuffer(shaderstate.dyncol_buff, shaderstate.dyncol_size, &shaderstate.dyncol_offs, (void**)&map, vertcount*sizeof(D3DCOLOR)); - for (vertcount = 0, mno = 0; mno < shaderstate.nummeshes; mno++) - { - m = shaderstate.meshlist[mno]; - src = m->colors4f_array[0]; - for (v = 0; v < m->numvertexes; v++) - { - map[0] = src[2]*255; - map[1] = src[1]*255; - map[2] = src[0]*255; - map[3] = src[3]*255; - /*FIXME: no clamping here*/ - map += 4; - src += 4; - } - vertcount += m->numvertexes; - } - map -= vertcount*4; - /*FIXME: m is wrong. its the last ent only*/ - colourgenbyte(pass, vertcount, (byte_vec4_t*)map, (byte_vec4_t*)map, m); - alphagenbyte(pass, vertcount, (byte_vec4_t*)map, (byte_vec4_t*)map, m); - d3dcheck(IDirect3DVertexBuffer9_Unlock(shaderstate.dyncol_buff)); - d3dcheck(IDirect3DDevice9_SetStreamSource(pD3DDev9, 1, shaderstate.dyncol_buff, shaderstate.dyncol_offs - vertcount*sizeof(D3DCOLOR), sizeof(D3DCOLOR))); - } - else + if (pass->flags & SHADER_PASS_NOCOLORARRAY) { shaderstate.passsinglecolour = true; shaderstate.passcolour = D3DCOLOR_RGBA(255,255,255,255); @@ -748,6 +753,71 @@ static unsigned int BE_GenerateColourMods(unsigned int vertcount, const shaderpa /*FIXME: just because there's no rgba set, there's no reason to assume it should be a single colour (unshaded ents)*/ d3dcheck(IDirect3DDevice9_SetStreamSource(pD3DDev9, 1, NULL, 0, 0)); } + else + { + unsigned int v; + int c; + float *src; + + shaderstate.passsinglecolour = false; + + ret |= D3D_VDEC_COL4B; + allocvertexbuffer(shaderstate.dyncol_buff, shaderstate.dyncol_size, &shaderstate.dyncol_offs, (void**)&map, vertcount*sizeof(D3DCOLOR)); + if (m->colors4b_array) + { + for (vertcount = 0, mno = 0; mno < shaderstate.nummeshes; mno++) + { + m = shaderstate.meshlist[mno]; + colourgenbyte(pass, m->numvertexes, (byte_vec4_t*)m->colors4b_array, (byte_vec4_t*)map, m); + alphagenbyte(pass, m->numvertexes, (byte_vec4_t*)m->colors4b_array, (byte_vec4_t*)map, m); + map += m->numvertexes*4; + vertcount += m->numvertexes; + } + } + else if (m->colors4f_array && + (pass->rgbgen == RGB_GEN_VERTEX) || + (pass->rgbgen == RGB_GEN_EXACT_VERTEX) || + (pass->rgbgen == RGB_GEN_ONE_MINUS_VERTEX) || + (pass->alphagen == ALPHA_GEN_VERTEX)) + { + for (vertcount = 0, mno = 0; mno < shaderstate.nummeshes; mno++) + { + m = shaderstate.meshlist[mno]; + src = m->colors4f_array[0]; + for (v = 0; v < m->numvertexes; v++) + { + c = src[0]*255; + map[0] = bound(0, c, 255); + c = src[1]*255; + map[1] = bound(0, c, 255); + c = src[2]*255; + map[2] = bound(0, c, 255); + c = src[3]*255; + map[3] = bound(0, c, 255); + map += 4; + src += 4; + } + vertcount += m->numvertexes; + } + map -= vertcount*4; + /*FIXME: m is wrong. its the last ent only*/ + colourgenbyte(pass, vertcount, (byte_vec4_t*)map, (byte_vec4_t*)map, m); + alphagenbyte(pass, vertcount, (byte_vec4_t*)map, (byte_vec4_t*)map, m); + } + else + { + for (vertcount = 0, mno = 0; mno < shaderstate.nummeshes; mno++) + { + m = shaderstate.meshlist[mno]; + colourgenbyte(pass, m->numvertexes, NULL, (byte_vec4_t*)map, m); + alphagenbyte(pass, m->numvertexes, NULL, (byte_vec4_t*)map, m); + map += m->numvertexes*4; + vertcount += m->numvertexes; + } + } + d3dcheck(IDirect3DVertexBuffer9_Unlock(shaderstate.dyncol_buff)); + d3dcheck(IDirect3DDevice9_SetStreamSource(pD3DDev9, 1, shaderstate.dyncol_buff, shaderstate.dyncol_offs - vertcount*sizeof(D3DCOLOR), sizeof(D3DCOLOR))); + } return ret; } /*********************************************************************************************************/ @@ -935,12 +1005,12 @@ static void GenerateTCMods(const shaderpass_t *pass, float *dest) /*******************************************************************************************************************/ /*does not do the draw call, does not consider indicies (except for billboard generation) */ -static void BE_DrawMeshChain_SetupPass(shaderpass_t *pass, unsigned int vertcount) +static qboolean BE_DrawMeshChain_SetupPass(shaderpass_t *pass, unsigned int vertcount) { int vdec; void *map; int i; - unsigned int passno = 0; + unsigned int passno = 0, tmu; int lastpass = pass->numMergedPasses; @@ -955,9 +1025,7 @@ static void BE_DrawMeshChain_SetupPass(shaderpass_t *pass, unsigned int vertcoun break; } if (i == lastpass) - return; - - passno = 0; + return lastpass; /*all meshes in a chain must have the same features*/ @@ -966,22 +1034,35 @@ static void BE_DrawMeshChain_SetupPass(shaderpass_t *pass, unsigned int vertcoun /*we only use one colour, generated from the first pass*/ vdec |= BE_GenerateColourMods(vertcount, pass); - for (; passno < lastpass; passno++) + tmu = 0; + /*activate tmus*/ + for (passno = 0; passno < lastpass; passno++) { - SelectPassTexture(passno, pass+passno); + if (pass[passno].texgen == T_GEN_UPPEROVERLAY && !TEXVALID(shaderstate.curtexnums->upperoverlay)) + continue; + if (pass[passno].texgen == T_GEN_LOWEROVERLAY && !TEXVALID(shaderstate.curtexnums->loweroverlay)) + continue; + if (pass[passno].texgen == T_GEN_FULLBRIGHT && !TEXVALID(shaderstate.curtexnums->fullbright)) + continue; - vdec |= D3D_VDEC_ST0<normals_array && // meshchain->2 && @@ -995,6 +1076,7 @@ static void BE_DrawMeshChain_SetupPass(shaderpass_t *pass, unsigned int vertcoun } D3DBE_ApplyShaderBits(pass->shaderbits); + return true; } static void BE_DrawMeshChain_Internal(void) @@ -1042,7 +1124,8 @@ static void BE_DrawMeshChain_Internal(void) /*now go through and flush each pass*/ for (passno = 0; passno < shaderstate.curshader->numpasses; passno += pass->numMergedPasses) { - BE_DrawMeshChain_SetupPass(pass+passno, vertcount); + if (!BE_DrawMeshChain_SetupPass(pass+passno, vertcount)) + continue; d3dcheck(IDirect3DDevice9_DrawIndexedPrimitive(pD3DDev9, D3DPT_TRIANGLELIST, 0, 0, vertcount, idxfirst, idxcount/3)); } } @@ -1279,8 +1362,12 @@ qboolean BE_LightCullModel(vec3_t org, model_t *model) batch_t *BE_GetTempBatch(void) { - /*FIXME: utterly evil*/ - return malloc(sizeof(batch_t)); + if (shaderstate.wbatch >= shaderstate.maxwbatches) + { + shaderstate.wbatch++; + return NULL; + } + return &shaderstate.wbatches[shaderstate.wbatch++]; } static void BE_RotateForEntity (const entity_t *e, const model_t *mod) @@ -1528,6 +1615,18 @@ void BE_DrawWorld (qbyte *vis) batch_t *batches[SHADER_SORT_COUNT]; RSpeedLocals(); + if (!r_refdef.recurse) + { + if (shaderstate.wbatch > shaderstate.maxwbatches) + { + int newm = shaderstate.wbatch; + shaderstate.wbatches = BZ_Realloc(shaderstate.wbatches, newm * sizeof(*shaderstate.wbatches)); + memset(shaderstate.wbatches + shaderstate.maxwbatches, 0, (newm - shaderstate.maxwbatches) * sizeof(*shaderstate.wbatches)); + shaderstate.maxwbatches = newm; + } + shaderstate.wbatch = 0; + } + BE_GenModelBatches(batches); shaderstate.curtime = realtime; diff --git a/engine/d3d/d3d_image.c b/engine/d3d/d3d_image.c index 07330b0c8..752bbbed1 100644 --- a/engine/d3d/d3d_image.c +++ b/engine/d3d/d3d_image.c @@ -30,6 +30,7 @@ static d3dtexture_t *d3d_lookup_texture(char *ident) tex = malloc(sizeof(*tex)); tex->name[0] = '\0'; } + tex->loaded = false; tex->tex.ptr = NULL; tex->next = d3dtextures; d3dtextures = tex; @@ -109,7 +110,7 @@ static void Upload_Texture_32(LPDIRECT3DTEXTURE9 tex, unsigned int *data, int wi D3DSURFACE_DESC desc; IDirect3DTexture9_GetLevelDesc(tex, 0, &desc); - IDirect3DTexture9_LockRect(tex, 0, &lock, NULL, DDLOCK_NOSYSLOCK|D3DLOCK_READONLY); + IDirect3DTexture9_LockRect(tex, 0, &lock, NULL, D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY); if (width == desc.Width && height == desc.Height) { @@ -192,6 +193,8 @@ static LPDIRECT3DBASETEXTURE9 D3D9_LoadTexture_32(d3dtexture_t *tex, unsigned in Upload_Texture_32(newsurf, data, width, height, flags); + tex->loaded = true; + return (LPDIRECT3DBASETEXTURE9)newsurf; } @@ -318,6 +321,23 @@ texid_t D3D9_LoadTexture (char *identifier, int width, int height, enum uploadfm { texid_t tid; d3dtexture_t *tex; + switch (fmt) + { + case TF_TRANS8_FULLBRIGHT: + { + qbyte *d = data; + unsigned int c = width * height; + while (c) + { + if (d[--c] > 255 - vid.fullbright) + break; + } + /*reject it if there's no fullbrights*/ + if (!c) + return r_nulltex; + } + break; + } tex = d3d_lookup_texture(identifier); switch (fmt) diff --git a/engine/d3d/vid_d3d.c b/engine/d3d/vid_d3d.c index 8ddb8334d..979400026 100644 --- a/engine/d3d/vid_d3d.c +++ b/engine/d3d/vid_d3d.c @@ -48,10 +48,10 @@ int gl_bumpmappingpossible; static void D3D9_GetBufferSize(int *width, int *height); +static void resetD3D9(void); static LPDIRECT3D9 pD3D; LPDIRECT3DDEVICE9 pD3DDev9; -//static LPDIRECTDRAWGAMMACONTROL pGammaControl; - +static D3DPRESENT_PARAMETERS d3dpp; static qboolean vid_initializing; @@ -145,6 +145,40 @@ static void D3D9_VID_GenPaletteTables (unsigned char *palette) typedef enum {MS_WINDOWED, MS_FULLSCREEN, MS_FULLDIB, MS_UNINIT} modestate_t; static modestate_t modestate; + +static void D3DVID_UpdateWindowStatus (HWND hWnd) +{ + POINT p; + RECT nr; + int window_width, window_height; + GetClientRect(hWnd, &nr); + + //if its bad then we're probably minimised + if (nr.right <= nr.left) + return; + if (nr.bottom <= nr.top) + return; + + p.x = 0; + p.y = 0; + ClientToScreen(hWnd, &p); + window_x = p.x; + window_y = p.y; + window_width = nr.right - nr.left; + window_height = nr.bottom - nr.top; +// vid.pixelwidth = window_width; +// vid.pixelheight = window_height; + + window_rect.left = window_x; + window_rect.top = window_y; + window_rect.right = window_x + window_width; + window_rect.bottom = window_y + window_height; + window_center_x = (window_rect.left + window_rect.right) / 2; + window_center_y = (window_rect.top + window_rect.bottom) / 2; + + IN_UpdateClipCursor (); +} + static qboolean D3D9AppActivate(BOOL fActive, BOOL minimize) /**************************************************************************** * @@ -215,10 +249,7 @@ static LRESULT WINAPI D3D9_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA break; case WM_MOVE: - GetWindowRect(mainwindow, &window_rect); - //window_x = (int) LOWORD(lParam); - //window_y = (int) HIWORD(lParam); -// VID_UpdateWindowStatus (); + D3DVID_UpdateWindowStatus (hWnd); break; case WM_KEYDOWN: @@ -313,12 +344,18 @@ static LRESULT WINAPI D3D9_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA case WM_SIZE: if (!vid_initializing) { - GetClientRect(mainwindow, &window_rect); // force width/height to be updated //vid.pixelwidth = window_rect.right - window_rect.left; //vid.pixelheight = window_rect.bottom - window_rect.top; // Cvar_ForceCallback(&vid_conautoscale); // Cvar_ForceCallback(&vid_conwidth); + D3DVID_UpdateWindowStatus(hWnd); + + BE_D3D_Reset(true); + vid.pixelwidth = d3dpp.BackBufferWidth = window_rect.right - window_rect.left; + vid.pixelheight = d3dpp.BackBufferHeight = window_rect.bottom - window_rect.top; + resetD3D9(); + BE_D3D_Reset(false); } break; @@ -366,10 +403,12 @@ static LRESULT WINAPI D3D9_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA return lRet; } -static D3DPRESENT_PARAMETERS d3dpp; static void resetD3D9(void) { - IDirect3DDevice9_Reset(pD3DDev9, &d3dpp); + HRESULT res; + res = IDirect3DDevice9_Reset(pD3DDev9, &d3dpp); + if (FAILED(res)) + return; /*clear the screen to black as soon as we start up, so there's no lingering framebuffer state*/ @@ -407,7 +446,8 @@ static void initD3D9(HWND hWnd, rendererstate_t *info) int err; RECT rect; D3DADAPTER_IDENTIFIER9 inf; - extern cvar_t _vid_wait_override; + D3DCAPS9 caps; + unsigned int cflags; static HMODULE d3d9dll; LPDIRECT3D9 (WINAPI *pDirect3DCreate9) (int version); @@ -433,6 +473,10 @@ static void initD3D9(HWND hWnd, rendererstate_t *info) numadaptors = IDirect3D9_GetAdapterCount(pD3D); for (i = 0; i < numadaptors; i++) { //try each adaptor in turn until we get one that actually works + + if (FAILED(IDirect3D9_GetDeviceCaps(pD3D, i, D3DDEVTYPE_HAL, &caps))) + continue; + memset(&d3dpp, 0, sizeof(d3dpp)); // clear out the struct for use d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames d3dpp.hDeviceWindow = hWnd; // set the window to be used by Direct3D @@ -445,24 +489,44 @@ static void initD3D9(HWND hWnd, rendererstate_t *info) d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; - d3dpp.BackBufferFormat = info->fullscreen?D3DFMT_X8R8G8B8:D3DFMT_UNKNOWN; - - if (!*_vid_wait_override.string) - d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; - else + d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; + if (info->fullscreen) { - if (_vid_wait_override.value == 1) - d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; - else if (_vid_wait_override.value == 2) - d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_TWO; - else if (_vid_wait_override.value == 3) - d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_THREE; - else if (_vid_wait_override.value == 4) - d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_FOUR; + if (info->bpp == 16) + d3dpp.BackBufferFormat = D3DFMT_R5G6B5; else - d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; } + switch(info->wait) + { + default: + d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; + break; + case 0: + d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + break; + case 1: + d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; + break; + case 2: + d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_TWO; + break; + case 3: + d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_THREE; + break; + case 4: + d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_FOUR; + break; + } + + cflags = D3DCREATE_FPU_PRESERVE; + if ((caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) && (caps.DevCaps & D3DDEVCAPS_PUREDEVICE)) + cflags |= D3DCREATE_HARDWARE_VERTEXPROCESSING; + else + cflags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; + //cflags |= D3DCREATE_DISABLE_DRIVER_MANAGEMENT; + memset(&inf, 0, sizeof(inf)); err = IDirect3D9_GetAdapterIdentifier(pD3D, i, 0, &inf); @@ -472,7 +536,7 @@ static void initD3D9(HWND hWnd, rendererstate_t *info) i, D3DDEVTYPE_HAL, hWnd, - D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, + cflags, &d3dpp, &pD3DDev9); @@ -560,6 +624,8 @@ static qboolean D3D9_VID_Init(rendererstate_t *info, unsigned char *palette) CLASSNAME }; + wc.hCursor = LoadCursor (NULL,IDC_ARROW); + vid_initializing = true; RegisterClass(&wc); @@ -608,39 +674,13 @@ static qboolean D3D9_VID_Init(rendererstate_t *info, unsigned char *palette) vid.width = width; vid.height = height; -// pDD->lpVtbl->QueryInterface ((void*)pDD, &IID_IDirectDrawGammaControl, (void**)&pGammaControl); -/* if (pGammaControl) - { - for (i = 0; i < 256; i++) - gammaramp.red[i] = i*2; - pGammaControl->lpVtbl->SetGammaRamp(pGammaControl, 0, &gammaramp); - } - else*/ - Con_Printf("Couldn't get gamma controls\n"); - vid_initializing = false; - -resetD3D9(); - - - - IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_ALPHAFUNC, D3DCMP_GREATER ); - IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_ALPHAREF, 0.666*256 ); - - IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_ALPHATESTENABLE, TRUE ); - - //IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRENDERSTATE_DITHERENABLE, FALSE); //IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRENDERSTATE_SPECULARENABLE, FALSE); //IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRENDERSTATE_TEXTUREPERSPECTIVE, TRUE); IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_LIGHTING, FALSE); - IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_ZWRITEENABLE, TRUE); - - IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_ZFUNC, D3DCMP_LESSEQUAL); - - GetWindowRect(mainwindow, &window_rect); @@ -796,14 +836,18 @@ static void (D3D9_SCR_UpdateScreen) (void) switch (IDirect3DDevice9_TestCooperativeLevel(pD3DDev9)) { case D3DERR_DEVICELOST: - //the user has task switched away from us or something + //the user has task switched away from us or something, don't do anything. return; case D3DERR_DEVICENOTRESET: + BE_D3D_Reset(true); resetD3D9(); if (FAILED(IDirect3DDevice9_TestCooperativeLevel(pD3DDev9))) - Sys_Error("D3D9 Device lost. Additionally restoration failed.\n"); - // D3DSucks(); - // scr_disabled_for_loading = false; + { + Con_Printf("Device lost, restarting video\n"); + Cmd_ExecuteString("vid_restart", RESTRICT_LOCAL); + return; + } + BE_D3D_Reset(false); VID_ShiftPalette (NULL); break; @@ -811,17 +855,6 @@ static void (D3D9_SCR_UpdateScreen) (void) break; } - - if (keydown['k']) - { - d3d9error(IDirect3DDevice9_BeginScene(pD3DDev9)); - d3d9error(IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(rand()&255, rand()&255, rand()&255), 1.0f, 0)); - d3d9error(IDirect3DDevice9_EndScene(pD3DDev9)); - d3d9error(IDirect3DDevice9_Present(pD3DDev9, NULL, NULL, NULL, NULL)); - - VID_ShiftPalette (NULL); - } - if (scr_disabled_for_loading) { extern float scr_disabled_time; @@ -960,6 +993,9 @@ static void (D3D9_SCR_UpdateScreen) (void) scr_con_forcedraw = false; if (noworld) { + if ((key_dest == key_console || key_dest == key_game) && SCR_GetLoadingStage() == LS_NONE) + scr_con_current = vid.height; + if (scr_con_current != vid.height) Draw_ConsoleBackground(0, vid.height, true); else diff --git a/engine/dotnet2005/ftequake.vcproj b/engine/dotnet2005/ftequake.vcproj index f81453507..f374a2138 100644 --- a/engine/dotnet2005/ftequake.vcproj +++ b/engine/dotnet2005/ftequake.vcproj @@ -5832,176 +5832,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -12894,1174 +12724,6 @@ /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -15252,2936 +13914,1348 @@ /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + engineflags & MDLF_FLAME) { - shadelight[0] = shadelight[1] = shadelight[2] = 4096; - ambientlight[0] = ambientlight[1] = ambientlight[2] = 4096; + shadelight[0] = shadelight[1] = shadelight[2] = 1; + ambientlight[0] = ambientlight[1] = ambientlight[2] = 1; return true; } if ((e->drawflags & MLS_MASKIN) == MLS_FULLBRIGHT || (e->flags & Q2RF_FULLBRIGHT)) { - shadelight[0] = shadelight[1] = shadelight[2] = 255; - ambientlight[0] = ambientlight[1] = ambientlight[2] = 0; + shadelight[0] = shadelight[1] = shadelight[2] = 1; + ambientlight[0] = ambientlight[1] = ambientlight[2] = 1; return true; } diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index 93c7174c1..00ac9d9b3 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -1049,8 +1049,7 @@ TRACE(("dbg: RMod_LoadTextures: inittexturedescs\n")); if (!Q_strncmp(mt->name,"sky",3)) { - tx->offsets[0] = (char *)mt + mt->offsets[0] - (char *)tx; - tn = R_InitSky (tx); + tn = R_InitSky (tx, (char *)mt + mt->offsets[0]); } else #ifdef PEXT_BULLETENS diff --git a/engine/gl/gl_model.h b/engine/gl/gl_model.h index 0708fc06d..b8155eed2 100644 --- a/engine/gl/gl_model.h +++ b/engine/gl/gl_model.h @@ -470,7 +470,6 @@ qboolean Q1BSP_EdictInFatPVS(struct model_s *mod, struct pvscache_s *ent, qbyte void Q1BSP_FindTouchedLeafs(struct model_s *mod, struct pvscache_s *ent, float *mins, float *maxs); qbyte *Q1BSP_LeafPVS (struct model_s *model, mleaf_t *leaf, qbyte *buffer, unsigned int buffersize); -texnums_t R_InitSky (struct texture_s *mt); /* ============================================================================== diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index adb30a234..a77e6a6c6 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -1293,7 +1293,7 @@ static void Shaderpass_BlendFunc (shader_t *shader, shaderpass_t *pass, char **p } else if (!Q_stricmp (token, "add")) { - pass->shaderbits |= SBITS_SRCBLEND_ONE | SBITS_DSTBLEND_ONE; + pass->shaderbits |= SBITS_SRCBLEND_SRC_ALPHA | SBITS_DSTBLEND_ONE; } else if (!Q_stricmp (token, "replace")) { diff --git a/engine/gl/gl_warp.c b/engine/gl/gl_warp.c index 73020d3cb..6da83e2d2 100644 --- a/engine/gl/gl_warp.c +++ b/engine/gl/gl_warp.c @@ -737,10 +737,9 @@ R_InitSky A sky texture is 256*128, with the right side being a masked overlay ============== */ -texnums_t R_InitSky (texture_t *mt) +texnums_t R_InitSky (texture_t *mt, qbyte *src) { int i, j, p; - qbyte *src; unsigned trans[128*128]; unsigned transpix, alphamask; int r, g, b; @@ -750,8 +749,6 @@ texnums_t R_InitSky (texture_t *mt) memset(&tn, 0, sizeof(tn)); - src = (qbyte *)mt + mt->offsets[0]; - // make an average value for the back to avoid // a fringe on the top level diff --git a/engine/gl/glquake.h b/engine/gl/glquake.h index 60dd24cd1..6fb395597 100644 --- a/engine/gl/glquake.h +++ b/engine/gl/glquake.h @@ -297,7 +297,7 @@ void FTE_DEPRECATED R_IBrokeTheArrays(void); // gl_warp.c // void R_DrawSkyChain (batch_t *batch); /*called from the backend, and calls back into it*/ -texnums_t R_InitSky (texture_t *mt); /*generate q1 sky texnums*/ +texnums_t R_InitSky (texture_t *mt, qbyte *src); /*generate q1 sky texnums*/ // // gl_draw.c diff --git a/engine/gl/shader.h b/engine/gl/shader.h index fd8b980fc..f058039bb 100644 --- a/engine/gl/shader.h +++ b/engine/gl/shader.h @@ -408,6 +408,8 @@ void BE_DrawNonWorld (void); //called at init, force the display to the right defaults etc void BE_Init(void); +void BE_D3D_Reset(qboolean before); + //Generates an optimised VBO, one for each texture on the map void BE_GenBrushModelVBO(model_t *mod); //Destroys the given vbo diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 0672297c0..de71a7386 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -2755,6 +2755,7 @@ already running on that entity/channel pair. An attenuation of 0 will play full volume everywhere in the level. Larger attenuations will drop off. +pitchadj is a number between -128 and 127. values greater than 0 will result in a higher pitch, less than 0 gives lower pitch. ================= */ @@ -2765,12 +2766,17 @@ void PF_sound (progfuncs_t *prinst, struct globalvars_s *pr_globals) edict_t *entity; int volume; float attenuation; + int pitchadj; entity = G_EDICT(prinst, OFS_PARM0); channel = G_FLOAT(OFS_PARM1); sample = PR_GetStringOfs(prinst, OFS_PARM2); volume = G_FLOAT(OFS_PARM3) * 255; attenuation = G_FLOAT(OFS_PARM4); + if (*svprogfuncs->callargc > 5) + pitchadj = G_FLOAT(OFS_PARM5); + else + pitchadj = 0; if (volume < 0) //erm... return; @@ -2778,7 +2784,7 @@ void PF_sound (progfuncs_t *prinst, struct globalvars_s *pr_globals) if (volume > 255) volume = 255; - SVQ1_StartSound (entity, channel, sample, volume, attenuation); + SVQ1_StartSound (entity, channel, sample, volume, attenuation, pitchadj); } //an evil one from telejano. @@ -2794,7 +2800,7 @@ void PF_LocalSound(progfuncs_t *prinst, struct globalvars_s *pr_globals) if (!isDedicated) { if ((sfx = S_PrecacheSound(s))) - S_StartSound(cl.playernum[0], chan, sfx, cl.simorg[0], vol, 0.0); + S_StartSound(cl.playernum[0], chan, sfx, cl.simorg[0], vol, 0.0, 0); } #endif }; @@ -7789,7 +7795,7 @@ void PF_h2StopSound(progfuncs_t *prinst, struct globalvars_s *pr_globals) entity = G_EDICT(prinst, OFS_PARM0); channel = G_FLOAT(OFS_PARM1); - SVQ1_StartSound (entity, channel, "", 1, 0); + SVQ1_StartSound (entity, channel, "", 1, 0, 0); } void PF_h2updatesoundpos(progfuncs_t *prinst, struct globalvars_s *pr_globals) diff --git a/engine/server/pr_q1qvm.c b/engine/server/pr_q1qvm.c index 60a055fbd..73f815a1d 100755 --- a/engine/server/pr_q1qvm.c +++ b/engine/server/pr_q1qvm.c @@ -640,7 +640,7 @@ static qintptr_t syscallhandle (void *offset, quintptr_t mask, qintptr_t fn, con case G_SOUND: // ( int edn, int channel, char *samp, float vol, float att ) - SVQ1_StartSound (Q1QVMPF_EdictNum(svprogfuncs, VM_LONG(arg[0])), VM_LONG(arg[1]), VM_POINTER(arg[2]), VM_FLOAT(arg[3])*255, VM_FLOAT(arg[4])); + SVQ1_StartSound (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); break; case G_TRACELINE: diff --git a/engine/server/server.h b/engine/server/server.h index 49b882ca5..680f07061 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -1017,8 +1017,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 entnum, vec3_t origin, int seenmask, int channel, char *sample, int volume, float attenuation); -void SVQ1_StartSound (edict_t *entity, int channel, char *sample, int volume, float attenuation); +void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, char *sample, int volume, float attenuation, int pitchadj); +void SVQ1_StartSound (edict_t *entity, int channel, char *sample, int volume, float attenuation, int pitchadj); void SV_PrintToClient(client_t *cl, int level, char *string); void VARGS SV_ClientPrintf (client_t *cl, int level, char *fmt, ...) LIKEPRINTF(3); void VARGS SV_ClientTPrintf (client_t *cl, int level, translation_t text, ...); diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 65ca62d3f..63e665232 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -2007,7 +2007,10 @@ client_t *SVC_DirectConnect(void) spectators = 0; newcl = NULL; if (!sv.allocated_client_slots) + { Con_Printf("Apparently, there are no client slots allocated. This shouldn't be happening\n"); + return NULL; + } for (i=0,cl=svs.clients ; istate == cs_free) @@ -2033,6 +2036,7 @@ client_t *SVC_DirectConnect(void) if (!newcl) //client has no slot. It's possible to bipass this if server is loading a game. (or a duplicated qsocket) { + /*single player logic*/ if (sv.allocated_client_slots == 1 && net_from.type == NA_LOOPBACK) if (svs.clients[0].state) SV_DropClient(svs.clients); @@ -2042,18 +2046,8 @@ client_t *SVC_DirectConnect(void) Cvar_SetValue (&maxclients, MAX_CLIENTS); if (maxspectators.ival > MAX_CLIENTS) Cvar_SetValue (&maxspectators, MAX_CLIENTS); -// if (maxspectators.ival + maxclients.value > MAX_CLIENTS) //maybe a server wishes to allow this sort of thing? -// Cvar_SetValue ("maxspectators", MAX_CLIENTS - maxspectators.ival + maxclients.ival); - if (svprogfuncs && ((spectator && spectators >= maxspectators.ival) - || (!spectator && clients >= maxclients.ival) - || (clients + spectators >= sv.allocated_client_slots) )) - { - Con_Printf ("%s:full connect\n", NET_AdrToString (adrbuf, sizeof(adrbuf), adr)); - SV_RejectMessage (protocol, "\nserver is full\n\n"); - return NULL; - } - // find a client slot + // find a free client slot for (i=0,cl=svs.clients ; istate == cs_free) @@ -2062,14 +2056,34 @@ client_t *SVC_DirectConnect(void) break; } } + + /*only q1/h2 has maxclients/maxspectators limits. q2 or q3 the gamecode does this*/ + if (svprogfuncs) + { + if (spectator && spectators >= maxspectators.ival) + newcl = NULL; + if (!spectator && clients >= maxclients.ival) + newcl = NULL; + } + if (!newcl) { - if (svprogfuncs) - Con_Printf ("WARNING: miscounted available clients\n"); + if (!svprogfuncs) + { + SV_RejectMessage (protocol, "\nserver is full\n\n"); + Con_Printf ("%s:full connect\n", NET_AdrToString (adrbuf, sizeof(adrbuf), adr)); + } else { - Con_Printf ("%s:full connect\n", NET_AdrToString (adrbuf, sizeof(adrbuf), adr)); - SV_RejectMessage (protocol, "server is full\n\n"); + if (spectator && spectators >= maxspectators.ival) + { + SV_RejectMessage (protocol, "\nserver is full (%i of %i spectators)\n\n", spectators, maxspectators.ival); + Con_Printf ("%s:full connect\n", NET_AdrToString (adrbuf, sizeof(adrbuf), adr)); + } + else if (!spectator && clients >= maxclients.ival) + SV_RejectMessage (protocol, "\nserver is full (%i of %i players)\n\n", clients, maxclients.ival); + else + SV_RejectMessage (protocol, "\nserver is full (%i of %i connections)\n\n", clients+spectators, sv.allocated_client_slots); } return NULL; } diff --git a/engine/server/sv_phys.c b/engine/server/sv_phys.c index d3d0c9d1f..7592d2e3a 100644 --- a/engine/server/sv_phys.c +++ b/engine/server/sv_phys.c @@ -1043,7 +1043,7 @@ static void SV_CheckWaterTransition (edict_t *ent) { if (ent->v->watertype == Q1CONTENTS_EMPTY) { // just crossed into water - SVQ1_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1); + SVQ1_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1, 0); } ent->v->watertype = cont; ent->v->waterlevel = 1; @@ -1052,7 +1052,7 @@ static void SV_CheckWaterTransition (edict_t *ent) { if (ent->v->watertype != Q1CONTENTS_EMPTY) { // just crossed into open - SVQ1_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1); + SVQ1_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1, 0); } ent->v->watertype = Q1CONTENTS_EMPTY; ent->v->waterlevel = cont; @@ -1210,9 +1210,9 @@ static void SV_Physics_Step (edict_t *ent) if (hitsound) { if (progstype == PROG_H2) - SVQ1_StartSound (ent, 0, "fx/thngland.wav", 255, 1); + SVQ1_StartSound (ent, 0, "fx/thngland.wav", 255, 1, 0); else - SVQ1_StartSound (ent, 0, "demon/dland2.wav", 255, 1); + SVQ1_StartSound (ent, 0, "demon/dland2.wav", 255, 1, 0); } } } diff --git a/engine/server/sv_send.c b/engine/server/sv_send.c index c14400522..4afb6843f 100644 --- a/engine/server/sv_send.c +++ b/engine/server/sv_send.c @@ -790,7 +790,7 @@ Larger attenuations will drop off. (max 4 attenuation) ================== */ -void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, char *sample, int volume, float attenuation) +void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, char *sample, int volume, float attenuation, int pitchadj) { int sound_num; int extfield_mask; @@ -857,9 +857,11 @@ void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, char *sam extfield_mask |= DPSND_LARGEENTITY; if (sound_num > 0xff) extfield_mask |= DPSND_LARGESOUND; + if (pitchadj) + extfield_mask |= FTESND_PITCHADJ; #ifdef PEXT_SOUNDDBL - if (channel >= 8 || ent >= 2048 || sound_num > 0xff) + if (channel >= 8 || ent >= 2048 || sound_num > 0xff || pitchadj) { //if any of the above conditions evaluates to true, then we can't use standard qw protocols MSG_WriteByte (&sv.multicast, svcfte_soundextended); @@ -868,6 +870,8 @@ void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, char *sam MSG_WriteByte (&sv.multicast, volume); if (extfield_mask & NQSND_ATTENUATION) MSG_WriteByte (&sv.multicast, attenuation*64); + if (extfield_mask & FTESND_PITCHADJ) + MSG_WriteChar (&sv.multicast, pitchadj); if (extfield_mask & DPSND_LARGEENTITY) { MSG_WriteShort (&sv.multicast, ent); @@ -921,6 +925,8 @@ void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, char *sam MSG_WriteByte (&sv.nqmulticast, volume); if (extfield_mask & NQSND_ATTENUATION) MSG_WriteByte (&sv.nqmulticast, attenuation*64); + if (extfield_mask & FTESND_PITCHADJ) + MSG_WriteChar (&sv.nqmulticast, pitchadj); if (extfield_mask & DPSND_LARGEENTITY) { MSG_WriteShort (&sv.nqmulticast, ent); @@ -941,7 +947,7 @@ void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, char *sam SV_MulticastProtExt(origin, reliable ? MULTICAST_ALL_R : MULTICAST_ALL, seenmask, requiredextensions, 0); } -void SVQ1_StartSound (edict_t *entity, int channel, char *sample, int volume, float attenuation) +void SVQ1_StartSound (edict_t *entity, int channel, char *sample, int volume, float attenuation, int pitchadj) { int i; vec3_t origin; @@ -955,7 +961,7 @@ void SVQ1_StartSound (edict_t *entity, int channel, char *sample, int volume, fl VectorCopy (entity->v->origin, origin); } - SV_StartSound(NUM_FOR_EDICT(svprogfuncs, entity), origin, entity->xv->dimension_seen, channel, sample, volume, attenuation); + SV_StartSound(NUM_FOR_EDICT(svprogfuncs, entity), origin, entity->xv->dimension_seen, channel, sample, volume, attenuation, pitchadj); } /* diff --git a/engine/server/svhl_game.c b/engine/server/svhl_game.c index 0be3ed93f..884c362e4 100644 --- a/engine/server/svhl_game.c +++ b/engine/server/svhl_game.c @@ -410,7 +410,7 @@ void QDECL GHL_SetOrigin(hledict_t *ed, float *neworg) } void QDECL GHL_EmitSound(hledict_t *ed, int chan, char *soundname, float vol, float atten, int flags, int pitch) { - SV_StartSound(ed-SVHL_Edict, ed->v.origin, ~0, chan, soundname, vol*255, atten); + SV_StartSound(ed-SVHL_Edict, ed->v.origin, ~0, chan, soundname, vol*255, atten, pitch); } void QDECL GHL_EmitAmbientSound(hledict_t *ed, float *org, char *soundname, float vol, float atten, unsigned int flags, int pitch) {