From: Guus Sliepen <guus@debian.org>
Date: Sun, 9 Aug 2015 14:19:32 +0000 (+0200)
Subject: Add position information to sounds effects.
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ba501dd7fa8b13b543dcbb8089ee0b1d7830ee11;p=quix0rs-blobwars.git

Add position information to sounds effects.
---

diff --git a/src/aquaBoss.cpp b/src/aquaBoss.cpp
index 45e9817..466de92 100644
--- a/src/aquaBoss.cpp
+++ b/src/aquaBoss.cpp
@@ -78,7 +78,7 @@ void aquaBossRecharge()
 				enemy->health = -1;
 				if (enemy->health % 10)
 				{
-					audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH);
+					audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
 				}
 				
 				Math::limitInt(&(++self->health), 0, self->maxHealth);
diff --git a/src/bosses.cpp b/src/bosses.cpp
index 0af6d84..7c4c26a 100644
--- a/src/bosses.cpp
+++ b/src/bosses.cpp
@@ -438,7 +438,7 @@ bool isCorrectShieldFrequency(Entity *bullet)
 		Math::removeBit(&bullet->flags, ENT_WEIGHTLESS);
 		Math::removeBit(&bullet->flags, ENT_BOUNCES);
 		
-		audio.playSound(SND_RICO1, CH_ANY);
+		audio.playSound(SND_RICO1, CH_ANY, bullet->x);
 		
 		return false;
 	}
@@ -485,7 +485,7 @@ void checkBossBulletCollisions(Entity *bullet)
 				if (!(self->flags & ENT_IMMUNE))
 				{
 					self->health -= bullet->damage;
-					audio.playSound(SND_CLANG, CH_ANY);
+					audio.playSound(SND_CLANG, CH_ANY, bullet->x);
 					addColorParticles(bullet->x, bullet->y, Math::rrand(25, 75), -1);
 					Math::removeBit(&bullet->flags, ENT_SPARKS);
 					Math::removeBit(&bullet->flags, ENT_PUFFS);
diff --git a/src/bullets.cpp b/src/bullets.cpp
index 522a262..88e288c 100644
--- a/src/bullets.cpp
+++ b/src/bullets.cpp
@@ -81,7 +81,7 @@ void addBullet(Entity *owner, float dx, float dy)
 
 	if (owner->currentWeapon->fireSound > -1)
 	{
-		audio.playSound(owner->currentWeapon->fireSound, CH_WEAPON);
+		audio.playSound(owner->currentWeapon->fireSound, CH_WEAPON, owner->x);
 	}
 
 	if (owner->flags & ENT_AIMS)
@@ -133,7 +133,7 @@ void destroyBullet(Entity *bullet)
 
 	if (bullet->flags & ENT_SPARKS)
 	{
-		audio.playSound(bullet->deathSound, CH_TOUCH);
+		audio.playSound(bullet->deathSound, CH_TOUCH, bullet->x);
 	}
 
 	if (bullet->flags & ENT_EXPLODES)
@@ -183,7 +183,7 @@ void bounceBullet(Entity *bullet, float dx, float dy)
 		if (bullet->id != WP_LASER)
 		{
 			bullet->dx *= 0.75;
-			audio.playSound(SND_GRBOUNCE, CH_TOUCH);
+			audio.playSound(SND_GRBOUNCE, CH_TOUCH, bullet->x);
 		}
 		bullet->face = !bullet->face;
 	}
@@ -201,7 +201,7 @@ void bounceBullet(Entity *bullet, float dx, float dy)
 		if (bullet->id != WP_LASER)
 		{
 			bullet->dy *= 0.75;
-			audio.playSound(SND_GRBOUNCE, CH_TOUCH);
+			audio.playSound(SND_GRBOUNCE, CH_TOUCH, bullet->x);
 		}
 
 		if ((bullet->dy > -2) && (bullet->dy <= 0)) bullet->dy = -2;
@@ -233,7 +233,7 @@ bool bulletHasCollided(Entity *bullet, float dx, float dy)
 				{
 					Math::removeBit(&bullet->flags, ENT_BOUNCES);
 					map.data[x][y] = MAP_AIR;
-					audio.playSound(SND_STONEBREAK, CH_EXPLODE);
+					audio.playSound(SND_STONEBREAK, CH_EXPLODE, bullet->x);
 					throwBrickParticles(x << BRICKSHIFT, y << BRICKSHIFT);
 				}
 				else
@@ -241,7 +241,7 @@ bool bulletHasCollided(Entity *bullet, float dx, float dy)
 					if ((Math::prand() % 2) == 0)
 					{
 						map.data[x][y] = MAP_AIR;
-						audio.playSound(SND_STONEBREAK, CH_EXPLODE);
+						audio.playSound(SND_STONEBREAK, CH_EXPLODE, bullet->x);
 						throwBrickParticles(x << BRICKSHIFT, y << BRICKSHIFT);
 					}
 				}
diff --git a/src/droidBoss.cpp b/src/droidBoss.cpp
index 2f04f77..923fdb5 100644
--- a/src/droidBoss.cpp
+++ b/src/droidBoss.cpp
@@ -130,7 +130,7 @@ void droidBossChangeFrequency()
 			break;
 	}
 	
-	audio.playSound(SND_BOSSCUSTOM1, CH_AMBIANCE);
+	audio.playSound(SND_BOSSCUSTOM1, CH_AMBIANCE, self->x);
 }
 
 void droidBossDie()
@@ -183,7 +183,7 @@ void droidBossReact()
 	if ((Math::prand() % 10) == 0)
 	{
 		Math::addBit(&self->flags, ENT_IMMUNE);
-		audio.playSound(SND_BOSSCUSTOM2, CH_SPAWN);
+		audio.playSound(SND_BOSSCUSTOM2, CH_SPAWN, self->x);
 		self->custom = 5;
 		self->think = &droidGoCrazy;
 		self->setActionFinished(2);
diff --git a/src/enemies.cpp b/src/enemies.cpp
index 8f16847..41d31e6 100644
--- a/src/enemies.cpp
+++ b/src/enemies.cpp
@@ -422,7 +422,7 @@ void enemyBulletCollisions(Entity *bullet)
 
 				if (!(enemy->flags & ENT_EXPLODES))
 				{
-					audio.playSound(SND_HIT, CH_ANY);
+					audio.playSound(SND_HIT, CH_ANY, enemy->x);
 					if (game.gore)
 					{
 						addBlood(enemy, bullet->dx / 4, Math::rrand(-6, -3), 1);
@@ -434,7 +434,7 @@ void enemyBulletCollisions(Entity *bullet)
 				}
 				else
 				{
-					audio.playSound(SND_CLANG, CH_ANY);
+					audio.playSound(SND_CLANG, CH_ANY, enemy->x);
 					addColorParticles(bullet->x, bullet->y, Math::rrand(25, 75), -1);
 				}
 
@@ -470,11 +470,11 @@ void enemyBulletCollisions(Entity *bullet)
 							
 							if (enemy->flags & ENT_EXPLODES)
 							{
-								audio.playSound(SND_ELECDEATH1 + Math::prand() % 3, CH_DEATH);
+								audio.playSound(SND_ELECDEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
 							}
 							else if (game.gore)
 							{
-								audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH);
+								audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
 							}
 						}
 					}
@@ -494,11 +494,11 @@ void enemyBulletCollisions(Entity *bullet)
 					
 					if (enemy->flags & ENT_EXPLODES)
 					{
-						audio.playSound(SND_ELECDEATH1 + Math::prand() % 3, CH_DEATH);
+						audio.playSound(SND_ELECDEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
 					}
 					else if (game.gore)
 					{
-						audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH);
+						audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
 					}
 
 					if (bullet->owner == &player)
@@ -591,7 +591,7 @@ void gibEnemy(Entity *enemy)
 		}
 	}
 	
-	(game.gore) ? audio.playSound(SND_SPLAT, CH_ANY) : audio.playSound(SND_POP, CH_ANY);
+	(game.gore) ? audio.playSound(SND_SPLAT, CH_ANY) : audio.playSound(SND_POP, CH_ANY, enemy->x);
 }
 
 void doEnemies()
@@ -739,7 +739,7 @@ void doEnemies()
 					{
 						if (game.gore)
 						{
-							audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH);
+							audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
 						}
 					}
 				}
diff --git a/src/entities.cpp b/src/entities.cpp
index 7ab691f..25ae954 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -30,7 +30,7 @@ void throwAndDamageEntity(Entity *ent, int damage, int minDX, int maxDX, int DY)
 
 	if (!(ent->flags & ENT_EXPLODES))
 	{
-		audio.playSound(SND_HIT, CH_ANY);
+		audio.playSound(SND_HIT, CH_ANY, ent->x);
 		for (int i = 0 ; i < 4 ; i++)
 		{
 			addBlood(ent, Math::rrand(-5, 5), Math::rrand(-6, -3), i);
@@ -38,7 +38,7 @@ void throwAndDamageEntity(Entity *ent, int damage, int minDX, int maxDX, int DY)
 	}
 	else
 	{
-		audio.playSound(SND_CLANG, CH_ANY);
+		audio.playSound(SND_CLANG, CH_ANY, ent->x);
 		addColorParticles(ent->x, ent->y, Math::rrand(25, 75), -1);
 	}
 
@@ -62,7 +62,7 @@ void throwAndDamageEntity(Entity *ent, int damage, int minDX, int maxDX, int DY)
 
 		if (player.health <= 0)
 		{
-			audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH);
+			audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH, player.x);
 			player.health = 0;
 		}
 
diff --git a/src/explosions.cpp b/src/explosions.cpp
index e380ca0..86e1198 100644
--- a/src/explosions.cpp
+++ b/src/explosions.cpp
@@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 void addExplosion(float x, float y, int radius, Entity *owner)
 {
-	audio.playSound(SND_GRENADE, CH_EXPLODE);
+	audio.playSound(SND_GRENADE, CH_EXPLODE, x);
 
 	float dx, dy;
 	int distX, distY;
@@ -78,13 +78,13 @@ void addExplosion(float x, float y, int radius, Entity *owner)
 				{
 					if (enemy->flags & ENT_EXPLODES)
 					{
-						audio.playSound(SND_ELECDEATH1 + Math::prand() % 3, CH_DEATH);
+						audio.playSound(SND_ELECDEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
 					}
 					else
 					{
 						if (game.gore)
 						{
-							audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH);
+							audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
 						}
 					}
 				}
diff --git a/src/finalBattle.cpp b/src/finalBattle.cpp
index 3e846fb..bec9512 100644
--- a/src/finalBattle.cpp
+++ b/src/finalBattle.cpp
@@ -214,7 +214,7 @@ void galdovFinalDropCrystal()
 		map.boss[0]->health = 30 * game.skill;
 		map.boss[0]->setSprites(graphics.getSprite("GaldovPain", true), graphics.getSprite("GaldovPain", true), graphics.getSprite("GaldovPain", true));
 		engine.setInfoMessage("Galdov has dropped the crystal! Quick! Get it!!", 99, INFO_HINT);
-		audio.playSound(SND_BOSSCUSTOM2, CH_AMBIANCE);
+		audio.playSound(SND_BOSSCUSTOM2, CH_AMBIANCE, x);
 	}
 }
 
@@ -224,7 +224,7 @@ void galdovFinalDie()
 	{
 		game.missionOverReason = MIS_GAMECOMPLETE;
 		audio.stopMusic();
-		audio.playSound(SND_BOSSCUSTOM3, CH_AMBIANCE);
+		audio.playSound(SND_BOSSCUSTOM3, CH_AMBIANCE, self->x);
 		player.health = 10;
 		self->dx = 5;
 		self->dy = -6;
@@ -466,7 +466,7 @@ void galdovRejoin()
 	self->think = &galdovFinalTeleport;
 	self->currentWeapon = getRandomGaldovWeapon();
 	
-	audio.playSound(SND_BOSSCUSTOM1, CH_AMBIANCE);
+	audio.playSound(SND_BOSSCUSTOM1, CH_AMBIANCE, self->x);
 	
 	map.setMainBossPart(map.boss[0]);
 	
@@ -528,13 +528,14 @@ void galdovFinalSplit()
 		addTeleportParticles(map.boss[i]->x + 10 + map.boss[i]->dx, map.boss[i]->y + 10 + map.boss[i]->dy, 75, -1);
 	}
 	
+	audio.playSound(SND_BOSSCUSTOM1, CH_AMBIANCE, map.boss[0]->x);
+
 	map.boss[0]->place(9999, 9999);
 	map.boss[0]->setThinkTime(2);
 	map.boss[0]->setActionFinished(Math::rrand(10, 15) * 60);
 	map.boss[0]->think = &galdovRejoin;
 	map.boss[0]->active = true;
 	
-	audio.playSound(SND_BOSSCUSTOM1, CH_AMBIANCE);
 	map.setMainBossPart(NULL);
 	
 	debug(("galdovFinalSplit: Done\n"));
@@ -655,13 +656,13 @@ void orbSeekGaldov()
 		self->setActionFinished(60);
 		self->setThinkTime(60);
 		addExplosion(self->x, self->y, 75, &player);
+		audio.playSound(SND_BOSSCUSTOM2, CH_AMBIANCE, self->x);
 		self->place(9999, 9999);
 		map.boss[0]->setSprites(graphics.getSprite("GaldovPain", true), graphics.getSprite("GaldovPain", true), graphics.getSprite("GaldovPain", true));
 		map.boss[0]->think = &galdovFinalPainThrow2;
 		map.boss[0]->health -= (3 * game.skill);
 		Math::removeBit(&map.boss[0]->flags, ENT_FLIES);
 		Math::removeBit(&map.boss[0]->flags, ENT_FIRETRAIL);
-		audio.playSound(SND_BOSSCUSTOM2, CH_AMBIANCE);
 	}
 }
 
diff --git a/src/galdov.cpp b/src/galdov.cpp
index 8f1240c..00bd898 100644
--- a/src/galdov.cpp
+++ b/src/galdov.cpp
@@ -131,7 +131,7 @@ void galdovReact()
 
 void galdovSplit(int i)
 {
-	audio.playSound(SND_BOSSCUSTOM1, CH_AMBIANCE);
+	audio.playSound(SND_BOSSCUSTOM1, CH_AMBIANCE, map.boss[0]->x);
 	
 	map.boss[i]->active = true;
 	map.boss[i]->health = 4 * game.skill;
@@ -389,7 +389,7 @@ void galdovDie()
 	if (map.mainBossPart != NULL)
 	{
 		map.mainBossPart = NULL;
-		audio.playSound(SND_BOSSCUSTOM2, CH_AMBIANCE);
+		audio.playSound(SND_BOSSCUSTOM2, CH_AMBIANCE, self->x);
 	}
 	
 	if ((self->health % 5) == 0)
diff --git a/src/game.cpp b/src/game.cpp
index b78972d..7cb8c0f 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -529,7 +529,7 @@ void beamInPlayer()
 	
 	unsigned int frameLimit = SDL_GetTicks() + 16;
 	
-	audio.playSound(SND_TELEPORT1, CH_ANY);
+	audio.playSound(SND_TELEPORT1, CH_ANY, player.x);
 	
 	engine.setPlayerPosition((int)player.x, (int)player.y, map.limitLeft, map.limitRight, map.limitUp, map.limitDown);
 	
diff --git a/src/items.cpp b/src/items.cpp
index 4c28235..814dead 100644
--- a/src/items.cpp
+++ b/src/items.cpp
@@ -235,7 +235,7 @@ void pickUpItem(Entity *item)
 		case ITEM_SPREAD:
 			player.currentWeapon = &weapon[item->id];
 			game.currentWeapon = item->id;
-			audio.playSound(SND_GETWEAPON, CH_ITEM);
+			audio.playSound(SND_GETWEAPON, CH_ITEM, item->x);
 			break;
 		case ITEM_POINTS:
 		case ITEM_POINTS2:
@@ -245,18 +245,18 @@ void pickUpItem(Entity *item)
 		case ITEM_POINTS6:
 		case ITEM_POINTS7:
 			addPlayerScore(item->value);
-			audio.playSound(SND_ITEM, CH_ITEM);
+			audio.playSound(SND_ITEM, CH_ITEM, item->x);
 			break;
 		case ITEM_CHERRY:
 		case ITEM_DOUBLECHERRY:
 		case ITEM_TRIPLECHERRY:
 			Math::limitInt(&(player.health += item->value), 0, MAX_HEALTH);
-			audio.playSound(SND_GULP + (Math::prand() % 2), CH_ITEM);
+			audio.playSound(SND_GULP + (Math::prand() % 2), CH_ITEM, item->x);
 			break;
 		case ITEM_MISC:
 			item->owner = &player;
 		case ITEM_MISC_NOSHOW:
-			audio.playSound(SND_ITEM, CH_ITEM);
+			audio.playSound(SND_ITEM, CH_ITEM, item->x);
 			break;
 	}
 
diff --git a/src/map.cpp b/src/map.cpp
index d0206cc..e7d548f 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -512,7 +512,7 @@ void evaluateMapAttribute(Entity *ent, int mapAttribute)
 					
 					if (ent->dy < 0)
 					{
-						audio.playSound(SND_WATEROUT, CH_TOUCH);
+						audio.playSound(SND_WATEROUT, CH_TOUCH, ent->x);
 					}
 
 					ent->checkEnvironment();
@@ -529,7 +529,7 @@ void evaluateMapAttribute(Entity *ent, int mapAttribute)
 
 			if (ent->environment == ENV_AIR)
 			{
-				audio.playSound(SND_WATERIN, CH_TOUCH);
+				audio.playSound(SND_WATERIN, CH_TOUCH, ent->x);
 				if ((mapAttribute == MAP_SLIME) || (mapAttribute == MAP_LAVA))
 					ent->thinktime = 1;
 			}
diff --git a/src/mias.cpp b/src/mias.cpp
index 25d093b..2d4e263 100644
--- a/src/mias.cpp
+++ b/src/mias.cpp
@@ -116,7 +116,7 @@ void doMIAs()
 				{
 					Math::addBit(&mia->flags, ENT_WEIGHTLESS);
 					Math::addBit(&mia->flags, ENT_DYING);
-					audio.playSound(SND_TELEPORT1, CH_ANY);
+					audio.playSound(SND_TELEPORT1, CH_ANY, mia->x);
 				}
 			}
 			
diff --git a/src/particles.cpp b/src/particles.cpp
index 4416444..942a79d 100644
--- a/src/particles.cpp
+++ b/src/particles.cpp
@@ -137,7 +137,7 @@ void addTeleportParticles(float x, float y, int amount, int soundToPlay)
 
 	if (soundToPlay != -1)
 	{
-		audio.playSound(soundToPlay, CH_SPAWN);
+		audio.playSound(soundToPlay, CH_SPAWN, x);
 	}
 }
 
diff --git a/src/switches.cpp b/src/switches.cpp
index 1ce0119..2545f8b 100644
--- a/src/switches.cpp
+++ b/src/switches.cpp
@@ -85,7 +85,7 @@ void checkSwitchContact(Entity *ent)
 				{
 					if ((swt->type == SWT_NORMAL) || (swt->type == SWT_WATERLEVEL))
 					{
-						audio.playSound(SND_SWITCH1, CH_TOUCH);
+						audio.playSound(SND_SWITCH1, CH_TOUCH, swt->x);
 						swt->activated = !swt->activated;
 						activateTrigger(swt->linkName, swt->activateMessage, swt->activated);
 						swt->health = 1;
@@ -93,20 +93,20 @@ void checkSwitchContact(Entity *ent)
 					}
 					else if (swt->type == SWT_TOGGLE)
 					{
-						audio.playSound(SND_SWITCH1, CH_TOUCH);
+						audio.playSound(SND_SWITCH1, CH_TOUCH, swt->x);
 						activateTrigger(swt->linkName, swt->activateMessage, !swt->activated);
 						swt->activated = !swt->activated;
 					}
 					else if (swt->type == SWT_PRESSURE)
 					{
-						audio.playSound(SND_SWITCH1, CH_TOUCH);
+						audio.playSound(SND_SWITCH1, CH_TOUCH, swt->x);
 						swt->activated = true;
 						activateTrigger(swt->linkName, swt->activateMessage, true);
 						swt->health = 2;
 					}
 					else if ((swt->type == SWT_TIMED) || (swt->type == SWT_RESET))
 					{
-						audio.playSound(SND_SWITCH1, CH_TOUCH);
+						audio.playSound(SND_SWITCH1, CH_TOUCH, swt->x);
 						activateTrigger(swt->linkName, swt->activateMessage, true);
 						swt->activated = !swt->activated;
 						swt->health = 240;
diff --git a/src/tankBoss.cpp b/src/tankBoss.cpp
index fac7b8f..59ed0f1 100644
--- a/src/tankBoss.cpp
+++ b/src/tankBoss.cpp
@@ -173,7 +173,7 @@ void tankBossMGCannonChargeFire()
 	if (self->custom == 0)
 	{
 		self->think = tankBossMGCannonFire;
-		audio.playSound(SND_BOSSCUSTOM2, CH_AMBIANCE);
+		audio.playSound(SND_BOSSCUSTOM2, CH_AMBIANCE, self->x);
 	}
 }
 
@@ -267,7 +267,7 @@ void tankBossMGAttack()
 		self->think = &tankBossMGCannonChargeFire;
 		self->setThinkTime(0);
 		self->setActionFinished(2);
-		audio.playSound(SND_BOSSCUSTOM1, CH_AMBIANCE);
+		audio.playSound(SND_BOSSCUSTOM1, CH_AMBIANCE, self->x);
 		Math::addBit(&self->flags, ENT_IMMUNE);
 	}
 	else
diff --git a/src/trains.cpp b/src/trains.cpp
index f1cbb4f..2c7585f 100644
--- a/src/trains.cpp
+++ b/src/trains.cpp
@@ -63,7 +63,7 @@ void openDoor(Train *train)
 
 	train->active = true;
 
-	audio.playSound(SND_OPENDOOR, CH_TOUCH);
+	audio.playSound(SND_OPENDOOR, CH_TOUCH, train->x);
 }
 
 /**
@@ -81,7 +81,7 @@ void trainBlockEntity(Entity *ent, const char *message, Train *train, int dir)
 		if ((train->isReady()) && (!train->active))
 		{
 			engine.setInfoMessage(message, 1, INFO_NORMAL);
-			audio.playSound(SND_LOCKEDDOOR, CH_TOUCH);
+			audio.playSound(SND_LOCKEDDOOR, CH_TOUCH, train->x);
 		}
 	}
 	
@@ -355,7 +355,7 @@ void doTrains()
 				}
 				else if (playSound)
 				{
-					audio.playSound(SND_DOOROPENED, CH_TOUCH);
+					audio.playSound(SND_DOOROPENED, CH_TOUCH, train->x);
 				}
 			}
 		}
diff --git a/src/traps.cpp b/src/traps.cpp
index 842554b..33e0dd8 100644
--- a/src/traps.cpp
+++ b/src/traps.cpp
@@ -219,24 +219,24 @@ void doTraps()
 				switch (trap->type)
 				{
 					case TRAP_TYPE_MINE:
-						audio.playSound(SND_ROCKET, CH_SPAWN);
+						audio.playSound(SND_ROCKET, CH_SPAWN, trap->x);
 						break;
 					case TRAP_TYPE_SPIKE:
-						audio.playSound(SND_ROCKET, CH_SPAWN);
+						audio.playSound(SND_ROCKET, CH_SPAWN, trap->x);
 						break;
 					case TRAP_TYPE_SWING:
-						audio.playSound(SND_THROW, CH_SPAWN);
+						audio.playSound(SND_THROW, CH_SPAWN, trap->x);
 						break;
 					case TRAP_TYPE_BARRIER:
 						if ((absX <= 640) && (absY <= 480))
 						{
-							audio.playSound(SND_ELECTRICITY1 + Math::prand() % 3, CH_SPAWN);
+							audio.playSound(SND_ELECTRICITY1 + Math::prand() % 3, CH_SPAWN, trap->x);
 						}
 						break;
 					case TRAP_TYPE_FLAME:
 						if ((absX <= 640) && (absY <= 480))
 						{
-							audio.playSound(SND_FIRECRACKLE, CH_SPAWN);
+							audio.playSound(SND_FIRECRACKLE, CH_SPAWN, trap->x);
 						}
 						break;
 				}
diff --git a/src/triggers.cpp b/src/triggers.cpp
index 76f7935..9d9584e 100644
--- a/src/triggers.cpp
+++ b/src/triggers.cpp
@@ -93,7 +93,7 @@ void activateTrigger(const char *linkName, const char *activateMessage, bool act
 				engine.setInfoMessage(activateMessage, 1, INFO_ACTIVATE);
 
 			if (train->type != TR_TRAIN)
-				audio.playSound(SND_OPENDOOR, CH_TOUCH);
+				audio.playSound(SND_OPENDOOR, CH_TOUCH, train->x);
 
 			linkOkay = true;
 		}