Hacks for the splitscreen mod: play sounds from both players.

The sound distance is the minimum of the two.  Both point sources as well
as MUSICANDSFX ambient sound is handled.

git-svn-id: https://svn.eduke32.com/eduke32@2885 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-08-13 18:25:53 +00:00
parent af05fe18be
commit 8039db5ff2
2 changed files with 61 additions and 11 deletions

View file

@ -1217,7 +1217,6 @@ BOLT:
ACTOR_STATIC void G_MoveFX(void) ACTOR_STATIC void G_MoveFX(void)
{ {
int32_t i = headspritestat[STAT_FX], j, nexti; int32_t i = headspritestat[STAT_FX], j, nexti;
int32_t x, ht;
spritetype *s; spritetype *s;
while (i >= 0) while (i >= 0)
@ -1240,8 +1239,8 @@ ACTOR_STATIC void G_MoveFX(void)
break; break;
case MUSICANDSFX__STATIC: case MUSICANDSFX__STATIC:
{
ht = s->hitag; const int32_t ht = s->hitag;
if (T2 != ud.config.SoundToggle) if (T2 != ud.config.SoundToggle)
{ {
@ -1251,7 +1250,15 @@ ACTOR_STATIC void G_MoveFX(void)
if (s->lotag >= 1000 && s->lotag < 2000) if (s->lotag >= 1000 && s->lotag < 2000)
{ {
x = ldist(&sprite[g_player[screenpeek].ps->i],s); int32_t x = ldist(&sprite[g_player[screenpeek].ps->i],s);
if (g_fakeMultiMode && ud.multimode==2)
{
// HACK for splitscreen mod
int32_t otherdist = ldist(&sprite[g_player[1].ps->i],s);
x = min(x, otherdist);
}
if (x < ht && T1 == 0) if (x < ht && T1 == 0)
{ {
FX_SetReverb(s->lotag - 1000); FX_SetReverb(s->lotag - 1000);
@ -1268,7 +1275,15 @@ ACTOR_STATIC void G_MoveFX(void)
{ {
if ((g_sounds[s->lotag].m&2)) if ((g_sounds[s->lotag].m&2))
{ {
x = dist(&sprite[g_player[screenpeek].ps->i],s); int32_t x = dist(&sprite[g_player[screenpeek].ps->i],s);
if (g_fakeMultiMode && ud.multimode==2)
{
// HACK for splitscreen mod
int32_t otherdist = dist(&sprite[g_player[1].ps->i],s);
x = min(x, otherdist);
}
if (x < ht && T1 == 0 && FX_VoiceAvailable(g_sounds[s->lotag].pr-1)) if (x < ht && T1 == 0 && FX_VoiceAvailable(g_sounds[s->lotag].pr-1))
{ {
if (g_numEnvSoundsPlaying == ud.config.NumVoices) if (g_numEnvSoundsPlaying == ud.config.NumVoices)
@ -1312,6 +1327,7 @@ ACTOR_STATIC void G_MoveFX(void)
} }
break; break;
} }
}
BOLT: BOLT:
i = nexti; i = nexti;
} }

View file

@ -400,6 +400,13 @@ static inline int32_t find_free_slot(int32_t num)
return j; return j;
} }
static inline int32_t get_sound_ang(int32_t camang, const vec3_t *cam, const vec3_t *pos)
{
int32_t sndang = 2048 + camang - getangle(cam->x-pos->x, cam->y-pos->y);
sndang &= 2047;
return sndang;
}
static int32_t S_CalcDistAndAng(int32_t i, int32_t num, int32_t camsect, int32_t camang, static int32_t S_CalcDistAndAng(int32_t i, int32_t num, int32_t camsect, int32_t camang,
const vec3_t *cam, const vec3_t *pos, const vec3_t *cam, const vec3_t *pos,
int32_t *sndistptr, int32_t *sndangptr) int32_t *sndistptr, int32_t *sndangptr)
@ -410,17 +417,44 @@ static int32_t S_CalcDistAndAng(int32_t i, int32_t num, int32_t camsect, int32_t
if (PN == APLAYER && sprite[i].yvel == screenpeek) if (PN == APLAYER && sprite[i].yvel == screenpeek)
{ {
sndang = sndist = 0; sndang = sndist = 0;
goto sound_further_processing;
} }
else
sndang = get_sound_ang(camang, cam, pos);
sndist = FindDistance3D(cam->x-pos->x, cam->y-pos->y, (cam->z-pos->z)>>4);
if (g_fakeMultiMode && ud.multimode==2)
{ {
sndang = 2048 + camang - getangle(cam->x-pos->x, cam->y-pos->y); // HACK for splitscreen mod: take the min of sound distances
sndang &= 2047; // to 1st and 2nd player.
sndist = FindDistance3D(cam->x-pos->x, cam->y-pos->y, (cam->z-pos->z)>>4); if (PN == APLAYER && sprite[i].yvel==1)
if ((g_sounds[num].m&16) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9) {
sndist = divscale14(sndist, SHT+1); sndist = sndang = 0;
goto sound_further_processing;
}
{
const vec3_t *cam2 = &g_player[1].ps->pos;
int32_t sndist2 = FindDistance3D(cam2->x-pos->x, cam2->y-pos->y, (cam2->z-pos->z)>>4);
if (sndist2 < sndist)
{
cam = cam2;
camsect = g_player[1].ps->cursectnum;
camang = g_player[1].ps->ang;
sndist = sndist2;
sndang = get_sound_ang(camang, cam, pos);
}
}
} }
if ((g_sounds[num].m&16) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9)
sndist = divscale14(sndist, SHT+1);
sound_further_processing:
sndist += g_sounds[num].vo; sndist += g_sounds[num].vo;
if (sndist < 0) if (sndist < 0)
sndist = 0; sndist = 0;