summary refs log tree commit diff
path: root/src/GameInitDispose.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/GameInitDispose.cpp')
-rw-r--r--src/GameInitDispose.cpp166
1 files changed, 84 insertions, 82 deletions
diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp
index 94ad884..ed767fd 100644
--- a/src/GameInitDispose.cpp
+++ b/src/GameInitDispose.cpp
@@ -26,8 +26,8 @@
 #include "misc.h"
 #include "Game.h"
 
-extern unsigned int gSourceID[100];
-extern unsigned int gSampleSet[100];
+extern unsigned int gSourceID[37];
+extern unsigned int gSampleSet[37];
 extern Camera camera;
 extern Skeleton testskeleton;
 extern Sprites sprites;
@@ -109,87 +109,88 @@ Game* makeGame(Config config)
 
 void LoadSounds(bool musictoggle)
 {
-	// generate ten OpenAL sample sets and two sources
-	alGenBuffers(37, gSampleSet);
-	alGenSources(37, gSourceID);
-
-	// load up some audio data...
-	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]);
+	gSampleSet[visionsound] = loadSound("underwater.ogg");
+	gSampleSet[soulinsound] = loadSound("soul-in.ogg");
+	gSampleSet[souloutsound] = loadSound("soul-out.ogg");
+	gSampleSet[footstepsound + 0] = loadSound("footstep1.ogg");
+	gSampleSet[footstepsound + 1] = loadSound("footstep2.ogg");
+	gSampleSet[footstepsound + 2] = loadSound("footstep3.ogg");
+	gSampleSet[footstepsound + 3] = loadSound("footstep4.ogg");
+	gSampleSet[footstepsound + 4] = loadSound("footstep5.ogg");
+	gSampleSet[bodylandsound] = loadSound("bodyland.ogg");
+	gSampleSet[headlandsound] = loadSound("headland.ogg");
+	gSampleSet[riflesound] = loadSound("sniperrifle.ogg");
+	gSampleSet[machinegunsound] = loadSound("machinegun.ogg");
+	gSampleSet[bodyhitsound] = loadSound("BodyHit.ogg");
+	gSampleSet[wallhitsound] = loadSound("WallHit.ogg");
+	gSampleSet[machinegunsound] = loadSound("machinegun.ogg");
+	gSampleSet[nearbulletsound] = loadSound("Nearbullet.ogg");
+	gSampleSet[headwhacksound] = loadSound("riflewhack.ogg");
+	gSampleSet[headshotsound] = loadSound("headshot.ogg");
+	gSampleSet[reloadsound] = loadSound("reload.ogg");
+	gSampleSet[clicksound] = loadSound("click.ogg");
+	gSampleSet[pistol1sound] = loadSound("SW.ogg");
+	gSampleSet[pistol2sound] = loadSound("glock.ogg");
+	gSampleSet[pinpullsound] = loadSound("pinpull.ogg");
+	gSampleSet[pinreplacesound] = loadSound("pinreplace.ogg");
+	gSampleSet[grenadethrowsound] = loadSound("handlerelease.ogg");
+	gSampleSet[bouncesound] = loadSound("bounce.ogg");
+	gSampleSet[bounce2sound] = loadSound("bounce2.ogg");
+	gSampleSet[explosionsound] = loadSound("explosion.ogg");
+	gSampleSet[headlandsound] = loadSound("headland.ogg");
+	gSampleSet[rainsound] = loadSound("rain.ogg");
+	gSampleSet[losesound] = loadSound("Lose.ogg");
+	gSampleSet[disguisekillsound] = loadSound("disguise-kill.ogg");
+	gSampleSet[knifeslashsound] = loadSound("knifeslash.ogg");
+	gSampleSet[shotgunsound] = loadSound("shotgun.ogg");
+	if (musictoggle) {
+		gSampleSet[mainmenusong] = loadSound("mainmenusong.ogg");
+		gSampleSet[shootsong] = loadSound("shootsong.ogg");
+		gSampleSet[zombiesong] = loadSound("zombiesong.ogg");
+		gSampleSet[knifesong] = loadSound("knifesong.ogg");
+	}
+
+	alGenSources(33, gSourceID);
+	alSourcei(gSourceID[visionsound], AL_BUFFER, gSampleSet[visionsound]);
+	alSourcei(gSourceID[soulinsound], AL_BUFFER, gSampleSet[soulinsound]);
+	alSourcei(gSourceID[souloutsound], AL_BUFFER, gSampleSet[souloutsound]);
+	alSourcei(gSourceID[footstepsound + 0], AL_BUFFER, gSampleSet[footstepsound + 0]);
+	alSourcei(gSourceID[footstepsound + 1], AL_BUFFER, gSampleSet[footstepsound + 1]);
+	alSourcei(gSourceID[footstepsound + 2], AL_BUFFER, gSampleSet[footstepsound + 2]);
+	alSourcei(gSourceID[footstepsound + 3], AL_BUFFER, gSampleSet[footstepsound + 3]);
+	alSourcei(gSourceID[footstepsound + 4], AL_BUFFER, gSampleSet[footstepsound + 4]);
+	alSourcei(gSourceID[bodylandsound], AL_BUFFER, gSampleSet[bodylandsound]);
+	alSourcei(gSourceID[headlandsound], AL_BUFFER, gSampleSet[headlandsound]);
+	alSourcei(gSourceID[riflesound], AL_BUFFER, gSampleSet[riflesound]);
+	alSourcei(gSourceID[bodyhitsound], AL_BUFFER, gSampleSet[bodyhitsound]);
+	alSourcei(gSourceID[wallhitsound], AL_BUFFER, gSampleSet[wallhitsound]);
+	alSourcei(gSourceID[machinegunsound], AL_BUFFER, gSampleSet[machinegunsound]);
+	alSourcei(gSourceID[nearbulletsound], AL_BUFFER, gSampleSet[nearbulletsound]);
+	alSourcei(gSourceID[headwhacksound], AL_BUFFER, gSampleSet[headwhacksound]);
+	alSourcei(gSourceID[headshotsound], AL_BUFFER, gSampleSet[headshotsound]);
+	alSourcei(gSourceID[reloadsound], AL_BUFFER, gSampleSet[reloadsound]);
+	alSourcei(gSourceID[clicksound], AL_BUFFER, gSampleSet[clicksound]);
+	alSourcei(gSourceID[pistol1sound], AL_BUFFER, gSampleSet[pistol1sound]);
+	alSourcei(gSourceID[pistol2sound], AL_BUFFER, gSampleSet[pistol2sound]);
+	alSourcei(gSourceID[pinpullsound], AL_BUFFER, gSampleSet[pinpullsound]);
+	alSourcei(gSourceID[pinreplacesound], AL_BUFFER, gSampleSet[pinreplacesound]);
+	alSourcei(gSourceID[grenadethrowsound], AL_BUFFER, gSampleSet[grenadethrowsound]);
+	alSourcei(gSourceID[bouncesound], AL_BUFFER, gSampleSet[bouncesound]);
+	alSourcei(gSourceID[bounce2sound], AL_BUFFER, gSampleSet[bounce2sound]);
+	alSourcei(gSourceID[explosionsound], AL_BUFFER, gSampleSet[explosionsound]);
+	alSourcei(gSourceID[bodywhacksound], AL_BUFFER, gSampleSet[bodywhacksound]);
+	alSourcei(gSourceID[rainsound], AL_BUFFER, gSampleSet[rainsound]);
+	alSourcei(gSourceID[losesound], AL_BUFFER, gSampleSet[losesound]);
+	alSourcei(gSourceID[disguisekillsound], AL_BUFFER, gSampleSet[disguisekillsound]);
+	alSourcei(gSourceID[knifeslashsound], AL_BUFFER, gSampleSet[knifeslashsound]);
+	alSourcei(gSourceID[shotgunsound], AL_BUFFER, gSampleSet[shotgunsound]);
 
 	if (musictoggle) {
-		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]);
+		alGenSources(4, gSourceID + 33);
+		alSourcei(gSourceID[mainmenusong], AL_BUFFER, gSampleSet[mainmenusong]);
+		alSourcei(gSourceID[shootsong], AL_BUFFER, gSampleSet[shootsong]);
+		alSourcei(gSourceID[zombiesong], AL_BUFFER, gSampleSet[zombiesong]);
+		alSourcei(gSourceID[knifesong], AL_BUFFER, gSampleSet[knifesong]);
 	}
 
 	alListenerfv(AL_POSITION, {});
@@ -1677,5 +1678,6 @@ void closeGame(Game* game)
 		game->flaretextureptr,
 	};
 	glDeleteTextures(4, textures);
-	alDeleteSources(100, gSourceID); // delete sound sources
+	alDeleteSources(33 + game->musictoggle * 4, gSourceID);
+	alDeleteBuffers(33 + game->musictoggle * 4, gSampleSet);
 }