aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-08-09 21:54:05 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-08-09 21:54:05 +0700
commit497deaf4774f6f2c478c52ff092a6eb85f2e0939 (patch)
treef793bb5aa4fd83e31b30adc98e2133ba176b84eb /src
parent1e83457eb3d786f553d77ece0b95f9aca641e524 (diff)
downloadblackshades-497deaf4774f6f2c478c52ff092a6eb85f2e0939.tar.gz
Disable NPC's footsteps and clean up sound loading1.3.4
https://todo.sr.ht/~cnx/blackshades/13
Diffstat (limited to 'src')
-rw-r--r--src/Fog.cpp12
-rw-r--r--src/Frustum.cpp12
-rw-r--r--src/GameInitDispose.cpp266
-rw-r--r--src/MacInput.h2
-rw-r--r--src/Person.cpp4
-rw-r--r--src/PhysicsMath.h3
-rw-r--r--src/Serialize.cpp3
-rw-r--r--src/Support.cpp142
-rw-r--r--src/Support.h7
9 files changed, 141 insertions, 310 deletions
diff --git a/src/Fog.cpp b/src/Fog.cpp
index 82f1d88..80e2830 100644
--- a/src/Fog.cpp
+++ b/src/Fog.cpp
@@ -16,8 +16,8 @@ void Fog::SetFog(float colorR, float colorG, float colorB, float fStart, float f
glFogfv(GL_FOG_COLOR,fogColor);
glFogf(GL_FOG_DENSITY,fogDensity);
glFogi(GL_FOG_HINT,GL_DONT_CARE);
- glFogi(GL_FOG_START,fogStart);
- glFogi(GL_FOG_END,fogEnd);
+ glFogf(GL_FOG_START,fogStart);
+ glFogf(GL_FOG_END,fogEnd);
glEnable(GL_FOG);
}
@@ -34,8 +34,8 @@ void Fog::TempFog(float colorR, float colorG, float colorB)
glFogfv(GL_FOG_COLOR,tempfogColor);
glFogf(GL_FOG_DENSITY,fogDensity);
glFogi(GL_FOG_HINT,GL_DONT_CARE);
- glFogi(GL_FOG_START,fogStart);
- glFogi(GL_FOG_END,fogEnd);
+ glFogf(GL_FOG_START,fogStart);
+ glFogf(GL_FOG_END,fogEnd);
glEnable(GL_FOG);
}
@@ -46,8 +46,8 @@ void Fog::ResetFog()
glFogfv(GL_FOG_COLOR,fogColor);
glFogf(GL_FOG_DENSITY,fogDensity);
glFogi(GL_FOG_HINT,GL_DONT_CARE);
- glFogi(GL_FOG_START,fogStart);
- glFogi(GL_FOG_END,fogEnd);
+ glFogf(GL_FOG_START,fogStart);
+ glFogf(GL_FOG_END,fogEnd);
glEnable(GL_FOG);
}
diff --git a/src/Frustum.cpp b/src/Frustum.cpp
index 712c4a3..3611a06 100644
--- a/src/Frustum.cpp
+++ b/src/Frustum.cpp
@@ -71,7 +71,7 @@ void FRUSTUM::
frustum[5][3] = clip[15] + clip[14];
/* normalize the right plane */
- t = sqrt(frustum[0][0]*frustum[0][0]
+ t = sqrtf(frustum[0][0]*frustum[0][0]
+ frustum[0][1]*frustum[0][1]
+ frustum[0][2]*frustum[0][2]);
frustum[0][0] /= t;
@@ -86,7 +86,7 @@ void FRUSTUM::
frustum[1][3] = clip[15] + clip[12];
/* normalize the left plane */
- t = sqrt(frustum[1][0]*frustum[1][0]
+ t = sqrtf(frustum[1][0]*frustum[1][0]
+ frustum[1][1]*frustum[1][1]
+ frustum[1][2]*frustum[1][2]);
frustum[1][0] /= t;
@@ -101,7 +101,7 @@ void FRUSTUM::
frustum[2][3] = clip[15] + clip[13];
/* normalize the bottom plane */
- t = sqrt(frustum[2][0]*frustum[2][0]
+ t = sqrtf(frustum[2][0]*frustum[2][0]
+ frustum[2][1]*frustum[2][1]
+ frustum[2][2]*frustum[2][2]);
frustum[2][0] /= t;
@@ -116,7 +116,7 @@ void FRUSTUM::
frustum[3][3] = clip[15] - clip[13];
/* normalize the top plane */
- t = sqrt(frustum[3][0]*frustum[3][0]
+ t = sqrtf(frustum[3][0]*frustum[3][0]
+ frustum[3][1]*frustum[3][1]
+ frustum[3][2]*frustum[3][2]);
frustum[3][0] /= t;
@@ -131,7 +131,7 @@ void FRUSTUM::
frustum[4][3] = clip[15] - clip[14];
/* normalize the far plane */
- t = sqrt(frustum[4][0]*frustum[4][0]
+ t = sqrtf(frustum[4][0]*frustum[4][0]
+ frustum[4][1]*frustum[4][1]
+ frustum[4][2]*frustum[4][2]);
frustum[4][0] /= t;
@@ -146,7 +146,7 @@ void FRUSTUM::
frustum[5][3] = clip[15] + clip[14];
/* normalize the near plane */
- t = sqrt(frustum[5][0]*frustum[5][0]
+ t = sqrtf(frustum[5][0]*frustum[5][0]
+ frustum[5][1]*frustum[5][1]
+ frustum[5][2]*frustum[5][2]);
frustum[5][0] /= t;
diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp
index 92a9f89..b9bdab7 100644
--- a/src/GameInitDispose.cpp
+++ b/src/GameInitDispose.cpp
@@ -40,190 +40,88 @@ extern int psychickey;
void LoadSounds(bool musictoggle)
{
- char *pBuffer1;
- long lBuffer1Len;
- ALenum formatBuffer1;
- ALsizei freqBuffer1;
- SInt16 iNumSources, iNumSampleSets;
-
- // initialize OpenAL
+ // generate ten OpenAL sample sets and two sources
alutInit(NULL, 0);
+ alGenBuffers(37, gSampleSet);
+ alGenSources(37, gSourceID);
// load up some audio data...
- // generate ten OpenAL sample sets and two sources
- iNumSources = 37;
- iNumSampleSets = 37;
- alGenSources(iNumSources, &gSourceID[0]);
- alGenBuffers(iNumSampleSets, &gSampleSet[0]);
- LoadOGG_CFH((char *)":Data:Sounds:underwater.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[visionsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[visionsound], AL_BUFFER, gSampleSet[visionsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:soulin.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[soulinsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[soulinsound], AL_BUFFER, gSampleSet[soulinsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:soulout.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[souloutsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[souloutsound], AL_BUFFER, gSampleSet[souloutsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:footstep1.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[footstepsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[footstepsound], AL_BUFFER, gSampleSet[footstepsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:footstep2.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[footstepsound+1], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[footstepsound+1], AL_BUFFER, gSampleSet[footstepsound+1]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:footstep3.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[footstepsound+2], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[footstepsound+2], AL_BUFFER, gSampleSet[footstepsound+2]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:footstep4.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[footstepsound+3], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[footstepsound+3], AL_BUFFER, gSampleSet[footstepsound+3]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:footstep5.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[footstepsound+4], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[footstepsound+4], AL_BUFFER, gSampleSet[footstepsound+4]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:bodyland.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[bodylandsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[bodylandsound], AL_BUFFER, gSampleSet[bodylandsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:headland.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[headlandsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[headlandsound], AL_BUFFER, gSampleSet[headlandsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:sniperrifle.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[riflesound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[riflesound], AL_BUFFER, gSampleSet[riflesound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:BodyHit.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[bodyhitsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[bodyhitsound], AL_BUFFER, gSampleSet[bodyhitsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:WallHit.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[wallhitsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[wallhitsound], AL_BUFFER, gSampleSet[wallhitsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:machinegun.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[machinegunsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[machinegunsound], AL_BUFFER, gSampleSet[machinegunsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:Nearbullet.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[nearbulletsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[nearbulletsound], AL_BUFFER, gSampleSet[nearbulletsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:riflewhack.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[headwhacksound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[headwhacksound], AL_BUFFER, gSampleSet[headwhacksound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:headshot.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[headshotsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[headshotsound], AL_BUFFER, gSampleSet[headshotsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:reload.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[reloadsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[reloadsound], AL_BUFFER, gSampleSet[reloadsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:click.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[clicksound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[clicksound], AL_BUFFER, gSampleSet[clicksound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:SW.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[pistol1sound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[pistol1sound], AL_BUFFER, gSampleSet[pistol1sound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:glock.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[pistol2sound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[pistol2sound], AL_BUFFER, gSampleSet[pistol2sound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:pinpull.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[pinpullsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[pinpullsound], AL_BUFFER, gSampleSet[pinpullsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:pinreplace.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[pinreplacesound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[pinreplacesound], AL_BUFFER, gSampleSet[pinreplacesound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:handlerelease.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[grenadethrowsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[grenadethrowsound], AL_BUFFER, gSampleSet[grenadethrowsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:bounce.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[bouncesound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[bouncesound], AL_BUFFER, gSampleSet[bouncesound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:bounce2.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[bounce2sound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[bounce2sound], AL_BUFFER, gSampleSet[bounce2sound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:explosion.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[explosionsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[explosionsound], AL_BUFFER, gSampleSet[explosionsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:headland.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[bodywhacksound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[bodywhacksound], AL_BUFFER, gSampleSet[bodywhacksound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:rain.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[rainsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[rainsound], AL_BUFFER, gSampleSet[rainsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:Lose.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[losesound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[losesound], AL_BUFFER, gSampleSet[losesound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:Disguisekill.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[disguisekillsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[disguisekillsound], AL_BUFFER, gSampleSet[disguisekillsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:knifeslash.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[knifeslashsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[knifeslashsound], AL_BUFFER, gSampleSet[knifeslashsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- LoadOGG_CFH((char *)":Data:Sounds:shotgun.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1);
- alBufferData(gSampleSet[shotgunsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[shotgunsound], AL_BUFFER, gSampleSet[shotgunsound]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
+ loadOgg((char*) ":Data:Sounds:underwater.ogg",
+ gSampleSet[visionsound], gSourceID[visionsound]);
+ loadOgg((char*) ":Data:Sounds:soulin.ogg",
+ gSampleSet[soulinsound], gSourceID[soulinsound]);
+ loadOgg((char*) ":Data:Sounds:soulout.ogg",
+ gSampleSet[souloutsound], gSourceID[souloutsound]);
+ loadOgg((char*) ":Data:Sounds:footstep1.ogg",
+ gSampleSet[footstepsound], gSourceID[footstepsound]);
+ loadOgg((char*) ":Data:Sounds:footstep2.ogg",
+ gSampleSet[footstepsound+1], gSourceID[footstepsound+1]);
+ loadOgg((char*) ":Data:Sounds:footstep3.ogg",
+ gSampleSet[footstepsound+2], gSourceID[footstepsound+2]);
+ loadOgg((char*) ":Data:Sounds:footstep4.ogg",
+ gSampleSet[footstepsound+3], gSourceID[footstepsound+3]);
+ loadOgg((char*) ":Data:Sounds:footstep5.ogg",
+ gSampleSet[footstepsound+4], gSourceID[footstepsound+4]);
+ loadOgg((char*) ":Data:Sounds:bodyland.ogg",
+ gSampleSet[bodylandsound], gSourceID[bodylandsound]);
+ loadOgg((char*) ":Data:Sounds:headland.ogg",
+ gSampleSet[headlandsound], gSourceID[headlandsound]);
+ loadOgg((char*) ":Data:Sounds:sniperrifle.ogg",
+ gSampleSet[riflesound], gSourceID[riflesound]);
+ loadOgg((char*) ":Data:Sounds:BodyHit.ogg",
+ gSampleSet[bodyhitsound], gSourceID[bodyhitsound]);
+ loadOgg((char*) ":Data:Sounds:WallHit.ogg",
+ gSampleSet[wallhitsound], gSourceID[wallhitsound]);
+ loadOgg((char*) ":Data:Sounds:machinegun.ogg",
+ gSampleSet[machinegunsound], gSourceID[machinegunsound]);
+ loadOgg((char*) ":Data:Sounds:Nearbullet.ogg",
+ gSampleSet[nearbulletsound], gSourceID[nearbulletsound]);
+ loadOgg((char*) ":Data:Sounds:riflewhack.ogg",
+ gSampleSet[headwhacksound], gSourceID[headwhacksound]);
+ loadOgg((char*) ":Data:Sounds:headshot.ogg",
+ gSampleSet[headshotsound], gSourceID[headshotsound]);
+ loadOgg((char*) ":Data:Sounds:reload.ogg",
+ gSampleSet[reloadsound], gSourceID[reloadsound]);
+ loadOgg((char*) ":Data:Sounds:click.ogg",
+ gSampleSet[clicksound], gSourceID[clicksound]);
+ loadOgg((char*) ":Data:Sounds:SW.ogg",
+ gSampleSet[pistol1sound], gSourceID[pistol1sound]);
+ loadOgg((char*) ":Data:Sounds:glock.ogg",
+ gSampleSet[pistol2sound], gSourceID[pistol2sound]);
+ loadOgg((char*) ":Data:Sounds:pinpull.ogg",
+ gSampleSet[pinpullsound], gSourceID[pinpullsound]);
+ loadOgg((char*) ":Data:Sounds:pinreplace.ogg",
+ gSampleSet[pinreplacesound], gSourceID[pinreplacesound]);
+ loadOgg((char*) ":Data:Sounds:handlerelease.ogg",
+ gSampleSet[grenadethrowsound], gSourceID[grenadethrowsound]);
+ loadOgg((char*) ":Data:Sounds:bounce.ogg",
+ gSampleSet[bouncesound], gSourceID[bouncesound]);
+ loadOgg((char*) ":Data:Sounds:bounce2.ogg",
+ gSampleSet[bounce2sound], gSourceID[bounce2sound]);
+ loadOgg((char*) ":Data:Sounds:explosion.ogg",
+ gSampleSet[explosionsound], gSourceID[explosionsound]);
+ loadOgg((char*) ":Data:Sounds:headland.ogg",
+ gSampleSet[bodywhacksound], gSourceID[bodywhacksound]);
+ loadOgg((char*) ":Data:Sounds:rain.ogg",
+ gSampleSet[rainsound], gSourceID[rainsound]);
+ loadOgg((char*) ":Data:Sounds:Lose.ogg",
+ gSampleSet[losesound], gSourceID[losesound]);
+ loadOgg((char*) ":Data:Sounds:Disguisekill.ogg",
+ gSampleSet[disguisekillsound], gSourceID[disguisekillsound]);
+ loadOgg((char*) ":Data:Sounds:knifeslash.ogg",
+ gSampleSet[knifeslashsound], gSourceID[knifeslashsound]);
+ loadOgg((char*) ":Data:Sounds:shotgun.ogg",
+ gSampleSet[shotgunsound], gSourceID[shotgunsound]);
if (musictoggle) {
- LoadOGG_CFH((char *) ":Data:Sounds:mainmenusong.ogg",
- &formatBuffer1, (void **) &pBuffer1,
- (unsigned int *) &lBuffer1Len, &freqBuffer1);
- alBufferData(gSampleSet[mainmenusong], formatBuffer1, pBuffer1,
- lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[mainmenusong], AL_BUFFER,
- gSampleSet[mainmenusong]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
-
- LoadOGG_CFH((char *) ":Data:Sounds:shootsong.ogg",
- &formatBuffer1, (void **) &pBuffer1,
- (unsigned int *) &lBuffer1Len, &freqBuffer1);
- alBufferData(gSampleSet[shootsong], formatBuffer1, pBuffer1,
- lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[shootsong], AL_BUFFER,
- gSampleSet[shootsong]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
-
- LoadOGG_CFH((char *) ":Data:Sounds:zombiesong.ogg",
- &formatBuffer1, (void **) &pBuffer1,
- (unsigned int *) &lBuffer1Len, &freqBuffer1);
- alBufferData(gSampleSet[zombiesong], formatBuffer1, pBuffer1,
- lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[zombiesong], AL_BUFFER,
- gSampleSet[zombiesong]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
-
- LoadOGG_CFH((char *) ":Data:Sounds:knifesong.ogg",
- &formatBuffer1, (void **) &pBuffer1,
- (unsigned int *) &lBuffer1Len, &freqBuffer1);
- alBufferData(gSampleSet[knifesong], formatBuffer1, pBuffer1,
- lBuffer1Len, freqBuffer1);
- alSourcei(gSourceID[knifesong], AL_BUFFER,
- gSampleSet[knifesong]);
- FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
+ loadOgg((char*) ":Data:Sounds:mainmenusong.ogg",
+ gSampleSet[mainmenusong], gSourceID[mainmenusong]);
+ loadOgg((char*) ":Data:Sounds:shootsong.ogg",
+ gSampleSet[shootsong], gSourceID[shootsong]);
+ loadOgg((char*) ":Data:Sounds:zombiesong.ogg",
+ gSampleSet[zombiesong], gSourceID[zombiesong]);
+ loadOgg((char*) ":Data:Sounds:knifesong.ogg",
+ gSampleSet[knifesong], gSourceID[knifesong]);
}
alListenerfv(AL_POSITION, {});
@@ -254,11 +152,11 @@ void LoadSounds(bool musictoggle)
alSourcef(gSourceID[riflesound], AL_MIN_GAIN, 0);
alSourcefv(gSourceID[bodyhitsound], AL_POSITION, {});
alSourcei(gSourceID[bodyhitsound], AL_LOOPING, 0);
- alSourcef(gSourceID[bodyhitsound], AL_MIN_GAIN, .1);
+ alSourcef(gSourceID[bodyhitsound], AL_MIN_GAIN, 0.1f);
alSourcefv(gSourceID[wallhitsound], AL_POSITION, {});
alSourcei(gSourceID[wallhitsound], AL_LOOPING, 0);
alSourcef(gSourceID[wallhitsound], AL_MIN_GAIN, 0);
- alSourcef(gSourceID[wallhitsound], AL_MAX_GAIN, .6);
+ alSourcef(gSourceID[wallhitsound], AL_MAX_GAIN, 0.6f);
alSourcefv(gSourceID[machinegunsound], AL_POSITION, {});
alSourcei(gSourceID[machinegunsound], AL_LOOPING, 0);
alSourcef(gSourceID[machinegunsound], AL_MIN_GAIN,0);
@@ -306,7 +204,7 @@ void LoadSounds(bool musictoggle)
alSourcef(gSourceID[bodywhacksound], AL_MIN_GAIN, 0);
alSourcefv(gSourceID[rainsound], AL_POSITION, {});
alSourcei(gSourceID[rainsound], AL_LOOPING, 1);
- alSourcef(gSourceID[rainsound], AL_MIN_GAIN, .3);
+ alSourcef(gSourceID[rainsound], AL_MIN_GAIN, 0.3f);
alSourcefv(gSourceID[losesound], AL_POSITION, {});
alSourcei(gSourceID[losesound], AL_LOOPING, 0);
alSourcef(gSourceID[losesound], AL_MIN_GAIN, 1);
@@ -404,7 +302,7 @@ void Game::LoadingScreen(float percent)
glEnable(GL_BLEND);
- glColor4f(1,0,0,.1);
+ glColor4f(1, 0, 0, 0.1f);
glBegin(GL_QUADS);
@@ -2095,7 +1993,6 @@ void Game::InitGame()
eqn[3]=0;
glClearColor(fogcolorr,fogcolorg,fogcolorb,1);
- if(!initialized)InitMouse();
//Draw city one frame to fix evil menu bug
if(!initialized)mainmenu=2;
if(!initialized){
@@ -2126,7 +2023,6 @@ int Game::InitGL(void)
//Config
if(!initialized){
//Default config in case config is not found
- STUB_FUNCTION;
screenwidth = 640;
screenheight = 480;
usermousesensitivity=.7;
diff --git a/src/MacInput.h b/src/MacInput.h
index ed9d267..fbe2c6d 100644
--- a/src/MacInput.h
+++ b/src/MacInput.h
@@ -93,9 +93,7 @@
/**> FUNCTION PROTOTYPES <**/
Boolean IsKeyDown( unsigned char *keyMap, unsigned short theKey );
-void InitMouse();
void MoveMouse(int xcoord, int ycoord, Point *mouseloc);
void RefreshMouse(Point *mouseloc);
-void DisposeMouse();
#endif
diff --git a/src/Person.cpp b/src/Person.cpp
index c8340d8..7e0d41c 100644
--- a/src/Person.cpp
+++ b/src/Person.cpp
@@ -217,7 +217,7 @@ void Person::DoAnimations(int who)
if (!slomo && !visions && (onground || abs(velocity.y) < 1)
&& (targetanimation == joganim
|| targetanimation == walkanim)
- && (targetframe == 0 || targetframe == 8)) {
+ && (targetframe == 0 || targetframe == 8) && who == 0) {
auto soundsrc = (playercoords - camera.position)
/ soundscalefactor;
ALfloat gLoc[] {soundsrc.x, soundsrc.y, soundsrc.z};
@@ -595,7 +595,7 @@ void Person::DoAnimationslite(int who)
return;
if (target > 1) {
// Footstep sounds
- if (!visions && (onground || abs(velocity.y) < 1)
+ if (who == 0 && !visions && (onground || abs(velocity.y) < 1)
&& (targetanimation == joganim
|| targetanimation == walkanim)
&& (targetframe == 0 || targetframe == 8)) {
diff --git a/src/PhysicsMath.h b/src/PhysicsMath.h
index 7eb13c5..c6c320c 100644
--- a/src/PhysicsMath.h
+++ b/src/PhysicsMath.h
@@ -452,7 +452,8 @@ inline Matrix3x3 Matrix3x3::Inverse(void)
e31*e22*e13;
- if (d == 0) d = 1;
+ if (abs(d) < 0.01f)
+ d = 1;
return Matrix3x3( (e22*e33-e23*e32)/d,
diff --git a/src/Serialize.cpp b/src/Serialize.cpp
index 443e935..c07a5db 100644
--- a/src/Serialize.cpp
+++ b/src/Serialize.cpp
@@ -12,7 +12,6 @@ int ReadBool(int fd, int count, bool *b)
unsigned char buf[1];
if (read(fd, buf, 1) != 1) {
- STUB_FUNCTION;
}
*b = (buf[0] != 0) ? true : false;
@@ -29,7 +28,6 @@ int ReadShort(int fd, int count, short *s)
unsigned char buf[2];
if (read(fd, buf, 2) != 2) {
- STUB_FUNCTION;
}
*s = (short)((buf[0] << 8) | buf[1]);
@@ -46,7 +44,6 @@ int ReadInt(int fd, int count, int *s)
unsigned char buf[4];
if (read(fd, buf, 4) != 4) {
- STUB_FUNCTION;
}
*s = (int)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]);
diff --git a/src/Support.cpp b/src/Support.cpp
index b88d3b1..a068360 100644
--- a/src/Support.cpp
+++ b/src/Support.cpp
@@ -55,11 +55,6 @@ int Button(void)
return (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1));
}
-void InitMouse()
-{
-// STUB_FUNCTION;
-}
-
void MoveMouse(int xcoord, int ycoord, Point *mouseloc)
{
/* TODO: mouse warp is annoying when we can just grab the mouse */
@@ -70,11 +65,6 @@ void MoveMouse(int xcoord, int ycoord, Point *mouseloc)
GetMouse(mouseloc);
}
-void DisposeMouse()
-{
-// STUB_FUNCTION;
-}
-
#ifndef O_BINARY
#define O_BINARY 0
#endif
@@ -244,116 +234,70 @@ void Files::EndLoad()
sFile = -1;
}
-/*
-Read the requested OGG file into memory, and extract the information required
-by OpenAL
-*/
-void LoadOGG_CFH(char *filename, ALenum *format, void **wave,
- unsigned int *size, ALsizei *freq)
+/* Read the requested Ogg file and load it into OpenAL */
+void loadOgg(char *filename, ALuint buffer, ALuint source)
{
+ /* Try to find the real file (and place it in filename1) */
char filename1[MAX_PATH];
- ALsizei format1, size1, freq1;
- void *wave1;
- OggVorbis_File vf;
- vorbis_info *vi;
- FILE *fp;
- int current_section;
- char *buf;
- int asize;
- int err;
- int eof;
-
-#if BYTE_ORDER == BIG_ENDIAN
- const int endian = 1;
-#else
- const int endian = 0;
-#endif
-
- /* try to find the real file (and place it in filename1) */
fix_filename(filename, filename1);
- /* open it for reading */
- fp = fopen(filename1, "rb");
+ FILE* fp = fopen(filename1, "rb");
if (fp == NULL) {
fprintf(stderr, "ERROR: unable to open %s\n", filename1);
exit(EXIT_FAILURE);
}
- /* open it up */
- err = ov_open(fp, &vf, NULL, 0);
- if (err < 0) {
- fprintf(stderr, "ERROR: vorbis error %d opening %s\n", -err, filename1);
+ OggVorbis_File vf;
+ int error = -ov_open(fp, &vf, NULL, 0);
+ if (error > 0) {
+ fprintf(stderr, "ERROR: vorbis error %d opening %s\n",
+ error, filename1);
exit(EXIT_FAILURE);
}
- /* get the ogg information */
- vi = ov_info(&vf, -1);
+ vorbis_info* vi = ov_info(&vf, -1);
if (vi == NULL) {
- fprintf(stderr, "ERROR: vorbis error opening %s (ov_info failed)\n", filename1);
+ fprintf(stderr,
+ "ERROR: vorbis error opening %s (ov_info failed)\n",
+ filename1);
exit(EXIT_FAILURE);
}
- /* calculate the byte size */
- size1 = vi->channels * 2 * ov_pcm_total(&vf, -1);
-
- /* hack around some possible ogg vorbis weirdness */
- asize = ((size1 + 2047) / 2048 + 1) * 2048;
-
- /* allocate our buffer */
- wave1 = malloc(asize);
-
- if (wave1 == NULL) {
- fprintf(stderr, "ERROR: could not allocate %d bytes while loading %s\n", size1, filename1);
+ /* Hack around some possible ogg vorbis weirdness */
+ ALsizei size = vi->channels * 2 * ov_pcm_total(&vf, -1);
+ ALvoid* data = malloc(((size + 2047) / 2048 + 1) * 2048);
+ if (data == NULL) {
+ fprintf(stderr,
+ "ERROR: could not allocate %d bytes while loading %s\n",
+ size, filename1);
exit(EXIT_FAILURE);
}
- /* read it in */
- eof = 0;
- buf = (char *)wave1;
-
- while(!eof) {
- long ret = ov_read(&vf, buf, 1024, endian, 2, 1,
- &current_section);
-
- if (ret == 0) {
- /* end of file */
- eof = 1;
- } else if (ret < 0) {
- /* some sort of error */
-
- /* TODO: is this ok to ignore? */
- } else {
- buf += ret;
- }
- }
-
- /* get the rest of the information */
- if (vi->channels == 1) {
- format1 = AL_FORMAT_MONO16;
- } else if (vi->channels == 2) {
- format1 = AL_FORMAT_STEREO16;
- } else {
- fprintf(stderr, "ERROR: ogg %s has %d channels\n", filename1, vi->channels);
+ char* i = (char*) data;
+ int section;
+ long ret;
+#if BYTE_ORDER == BIG_ENDIAN
+ while (ret = ov_read(&vf, i, 1024, 1, 2, 1, &section))
+#else
+ while (ret = ov_read(&vf, i, 1024, 0, 2, 1, &section))
+#endif
+ if (ret > 0) /* XXX: How about negative ret? */
+ i += ret;
+
+ switch (vi->channels) {
+ case 1:
+ alBufferData(buffer, AL_FORMAT_MONO16, data, size, vi->rate);
+ break;
+ case 2:
+ alBufferData(buffer, AL_FORMAT_STEREO16, data, size, vi->rate);
+ break;
+ default:
+ fprintf(stderr, "ERROR: ogg %s has %d channels\n",
+ filename1, vi->channels);
exit(EXIT_FAILURE);
}
- freq1 = vi->rate;
-
- /* we are done with the ogg, so free it */
+ free(data);
ov_clear(&vf);
-
- /* finall, give the values to the caller */
- *format = format1;
- *size = size1;
- *freq = freq1;
- *wave = wave1;
-}
-
-/*
-Free the OGG buffer
-*/
-void FreeOGG(ALenum format, void *wave, unsigned int size,
- ALsizei freq)
-{
- free(wave);
+ alSourcei(source, AL_BUFFER, buffer);
}
diff --git a/src/Support.h b/src/Support.h
index 633a51a..bf0658d 100644
--- a/src/Support.h
+++ b/src/Support.h
@@ -6,8 +6,6 @@
#include <AL/al.h>
-#define STUB_FUNCTION fprintf(stderr,"STUB: %s at " __FILE__ ", line %d, thread %d\n",__FUNCTION__,__LINE__,getpid())
-
#define fsFromStart SEEK_SET
typedef unsigned char * Str255;
@@ -39,10 +37,7 @@ void GetMouse(Point *p);
void GetMouseRel(Point *p);
void GetKeys(unsigned long *keys);
int Button(void);
-void LoadOGG_CFH(char *filename, ALenum *format, void **wave,
- unsigned int *size, ALsizei *freq);
-void FreeOGG(ALenum format, void *wave, unsigned int size,
- ALsizei freq);
+void loadOgg(char* filename, ALuint buffer, ALuint source);
FILE *cfh_fopen(const char *filename, const char *mode);