From 501db4420b61f9d3e47b50c5ee34c9e3af225e6c Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 25 Feb 2018 17:29:44 +0000 Subject: [PATCH] Use entity id to play sounds. --- src/combat/explosions.c | 2 +- src/defs.h | 16 ++------- src/entities/blobs/bob.c | 12 +++---- src/entities/blobs/mia.c | 2 +- src/entities/blobs/teeka.c | 4 +-- src/entities/boss/blobBoss.c | 47 +++++++++++++------------ src/entities/boss/eyeDroidCommander.c | 43 +++++++++++----------- src/entities/boss/tankCommander.c | 31 ++++++++-------- src/entities/boss/tankTrack.c | 2 +- src/entities/bullets/bullet.c | 8 ++--- src/entities/bullets/grenade.c | 2 +- src/entities/bullets/laser.c | 4 +-- src/entities/evilBlobs/evilBlob.c | 8 ++--- src/entities/eyeDroids/eyeDroid.c | 4 +-- src/entities/items/battery.c | 2 +- src/entities/items/cell.c | 2 +- src/entities/items/cherry.c | 2 +- src/entities/items/heart.c | 2 +- src/entities/items/item.c | 8 ++--- src/entities/items/weaponPickup.c | 2 +- src/entities/structures/cardReader.c | 4 +-- src/entities/structures/door.c | 12 +++---- src/entities/structures/pressurePlate.c | 2 +- src/entities/structures/pushBlock.c | 2 +- src/entities/structures/teleporter.c | 2 +- src/entities/traps/laserTrap.c | 2 +- src/entities/unit.c | 4 +-- src/system/init.c | 2 +- src/world/world.c | 4 +-- 29 files changed, 117 insertions(+), 120 deletions(-) diff --git a/src/combat/explosions.c b/src/combat/explosions.c index 0f3a3f5..b7efb3d 100644 --- a/src/combat/explosions.c +++ b/src/combat/explosions.c @@ -30,7 +30,7 @@ void addExplosion(float x, float y, int radius, Entity *owner) float power; int i; - playSound(SND_EXPLOSION, CH_EXPLODE); + playSound(SND_EXPLOSION, -1); /* assuming x and y were from the top left of the entity */ x += radius / 2; diff --git a/src/defs.h b/src/defs.h index fa36d5a..5950271 100644 --- a/src/defs.h +++ b/src/defs.h @@ -89,6 +89,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MAX_ENTS_TO_OBSERVE 12 +#define MAX_SND_CHANNELS 64 + enum { ET_NONE, @@ -314,20 +316,6 @@ enum SND_MAX }; -enum -{ - CH_ANY = -1, - CH_BOB, - CH_EXPLODE, - CH_WEAPON, - CH_DEATH, - CH_ITEM, - CH_TOUCH, - CH_MECHANICAL, - CH_EFFECTS, - CH_MAX -}; - enum { WT_BUTTON, diff --git a/src/entities/blobs/bob.c b/src/entities/blobs/bob.c index bf565a8..9f731f0 100644 --- a/src/entities/blobs/bob.c +++ b/src/entities/blobs/bob.c @@ -352,7 +352,7 @@ static void doBobInWater(void) if (world.bob->oxygen == 0 && (world.frameCounter % 30) == 0) { world.bob->health--; - playSound(SND_DROWN, CH_BOB); + playSound(SND_DROWN, world.bob->uniqueId % MAX_SND_CHANNELS); } } } @@ -369,7 +369,7 @@ static void doDying(void) world.state = WS_GAME_OVER; - playSound(SND_SPLAT, CH_BOB); + playSound(SND_SPLAT, world.bob->uniqueId % MAX_SND_CHANNELS); game.stats[STAT_DEATHS]++; } @@ -610,7 +610,7 @@ void resetAtCheckpoint(void) addTeleportStars((Entity*)world.bob); if (world.state == WS_IN_PROGRESS) { - playSound(SND_APPEAR, CH_ANY); + playSound(SND_APPEAR, -1); } } @@ -630,15 +630,15 @@ static void die(void) switch (rand() % 3) { case 0: - playSound(SND_DEATH_1, CH_DEATH); + playSound(SND_DEATH_1, world.bob->uniqueId % MAX_SND_CHANNELS); break; case 1: - playSound(SND_DEATH_2, CH_DEATH); + playSound(SND_DEATH_2, world.bob->uniqueId % MAX_SND_CHANNELS); break; case 2: - playSound(SND_DEATH_3, CH_DEATH); + playSound(SND_DEATH_3, world.bob->uniqueId % MAX_SND_CHANNELS); break; } } diff --git a/src/entities/blobs/mia.c b/src/entities/blobs/mia.c index d160655..2d2a42e 100644 --- a/src/entities/blobs/mia.c +++ b/src/entities/blobs/mia.c @@ -115,7 +115,7 @@ static void touch(Entity *other) setGameplayMessage(MSG_OBJECTIVE, _("Rescued %s"), m->name); m->isMissionTarget = 0; m->flags |= EF_ALWAYS_PROCESS; - playSound(SND_MIA, CH_ANY); + playSound(SND_MIA, m->uniqueId % MAX_SND_CHANNELS); } } diff --git a/src/entities/blobs/teeka.c b/src/entities/blobs/teeka.c index 76f53f9..026f738 100644 --- a/src/entities/blobs/teeka.c +++ b/src/entities/blobs/teeka.c @@ -119,7 +119,7 @@ static void lookForEnemies(void) { addTeleportStars(self); u->alive = ALIVE_DEAD; - playSound(SND_APPEAR, CH_ANY); + playSound(SND_APPEAR, u->uniqueId % MAX_SND_CHANNELS); } else { @@ -175,7 +175,7 @@ static void attack(void) ((Unit*)self)->reload = 8; - playSound(SND_PISTOL, CH_WEAPON); + playSound(SND_PISTOL, self->uniqueId % MAX_SND_CHANNELS); } void teekaExitMission(void) diff --git a/src/entities/boss/blobBoss.c b/src/entities/boss/blobBoss.c index 7230f1b..565a11c 100644 --- a/src/entities/boss/blobBoss.c +++ b/src/entities/boss/blobBoss.c @@ -165,15 +165,15 @@ static void die1(void) switch (rand() % 3) { case 0: - playSound(SND_DEATH_1, CH_DEATH); + playSound(SND_DEATH_1, b->uniqueId % MAX_SND_CHANNELS); break; case 1: - playSound(SND_DEATH_2, CH_DEATH); + playSound(SND_DEATH_2, b->uniqueId % MAX_SND_CHANNELS); break; case 2: - playSound(SND_DEATH_3, CH_DEATH); + playSound(SND_DEATH_3, b->uniqueId % MAX_SND_CHANNELS); break; } @@ -306,26 +306,29 @@ static void attack(void) float dx, dy; int bx, by; - bx = (int) (world.bob->x + rrnd(-8, 24)); - by = (int) (world.bob->y + rrnd(-8, 24)); + if (self->facing != FACING_DIE) + { + bx = (int) (world.bob->x + rrnd(-8, 24)); + by = (int) (world.bob->y + rrnd(-8, 24)); - getSlope(bx, by, self->x, self->y, &dx, &dy); + getSlope(bx, by, self->x, self->y, &dx, &dy); - bullet = createBaseBullet((Unit*)self); - bullet->x = self->x; - bullet->y = (self->y + self->h / 2) - 3; - bullet->facing = self->facing; - bullet->damage = 1; - bullet->owner = self; - bullet->health = FPS * 3; - bullet->weaponType = WPN_AIMED_PISTOL; - bullet->dx = dx * 12; - bullet->dy = dy * 12; - bullet->sprite[0] = bullet->sprite[1] = aimedSprite; + bullet = createBaseBullet((Unit*)self); + bullet->x = self->x; + bullet->y = (self->y + self->h / 2) - 3; + bullet->facing = self->facing; + bullet->damage = 1; + bullet->owner = self; + bullet->health = FPS * 3; + bullet->weaponType = WPN_AIMED_PISTOL; + bullet->dx = dx * 12; + bullet->dy = dy * 12; + bullet->sprite[0] = bullet->sprite[1] = aimedSprite; - ((Boss*)self)->reload = 4; + ((Boss*)self)->reload = 4; - playSound(SND_MACHINE_GUN, CH_WEAPON); + playSound(SND_MACHINE_GUN, self->uniqueId % MAX_SND_CHANNELS); + } } static void walk(void) @@ -356,7 +359,7 @@ void reappear(void) addTeleportStars(self); - playSound(SND_APPEAR, CH_ANY); + playSound(SND_APPEAR, -1); } static void applyDamage(int amount) @@ -381,7 +384,7 @@ static void teleport(void) self->flags |= EF_GONE; self->thinkTime = FPS * rrnd(3, 6); addTeleportStars(self); - playSound(SND_APPEAR, CH_ANY); + playSound(SND_APPEAR, -1); } } @@ -397,7 +400,7 @@ static void die2(void) { addTeleportStars(self); - playSound(SND_APPEAR, CH_ANY); + playSound(SND_APPEAR, -1); /* don't die! */ b->flags |= EF_GONE; diff --git a/src/entities/boss/eyeDroidCommander.c b/src/entities/boss/eyeDroidCommander.c index 321b806..d4ea44a 100644 --- a/src/entities/boss/eyeDroidCommander.c +++ b/src/entities/boss/eyeDroidCommander.c @@ -243,21 +243,24 @@ static void attack(void) { Boss *b; - b = (Boss*)self; - - switch (b->weaponType) + if (self->facing != FACING_DIE) { - case WPN_AIMED_PISTOL: - attackPistol(); - break; - case WPN_MISSILE: - attackMissile(); - break; - case WPN_PLASMA: - attackPlasma(); - break; - default: - break; + b = (Boss*)self; + + switch (b->weaponType) + { + case WPN_AIMED_PISTOL: + attackPistol(); + break; + case WPN_MISSILE: + attackMissile(); + break; + case WPN_PLASMA: + attackPlasma(); + break; + default: + break; + } } } @@ -289,7 +292,7 @@ static void attackPistol(void) b->reload = 4; - playSound(SND_MACHINE_GUN, CH_WEAPON); + playSound(SND_MACHINE_GUN, b->uniqueId % MAX_SND_CHANNELS); } static void attackPlasma(void) @@ -314,7 +317,7 @@ static void attackPlasma(void) b->reload = 4; - playSound(SND_PLASMA, CH_WEAPON); + playSound(SND_PLASMA, b->uniqueId % MAX_SND_CHANNELS); } static void attackMissile(void) @@ -338,7 +341,7 @@ static void attackMissile(void) b->reload = 15; - playSound(SND_MISSILE, CH_WEAPON); + playSound(SND_MISSILE, b->uniqueId % MAX_SND_CHANNELS); } static void applyDamage(int amount) @@ -371,11 +374,11 @@ static void die(void) if (rand() % 2) { - playSound(SND_DROID_DIE_1, CH_DEATH); + playSound(SND_DROID_DIE_1, b->uniqueId % MAX_SND_CHANNELS); } else { - playSound(SND_DROID_DIE_2, CH_DEATH); + playSound(SND_DROID_DIE_2, b->uniqueId % MAX_SND_CHANNELS); } } @@ -389,7 +392,7 @@ static void die2() { addTeleportStars(self); - playSound(SND_APPEAR, CH_ANY); + playSound(SND_APPEAR, -1); /* don't die! */ b->flags |= EF_GONE; diff --git a/src/entities/boss/tankCommander.c b/src/entities/boss/tankCommander.c index 5e36d71..6b09495 100644 --- a/src/entities/boss/tankCommander.c +++ b/src/entities/boss/tankCommander.c @@ -216,18 +216,21 @@ static void attack(void) { Boss *b; - b = (Boss*)self; - - switch (b->weaponType) + if (self->facing != FACING_DIE) { - case WPN_AIMED_PISTOL: - attackPistol(); - break; - case WPN_MISSILE: - attackMissile(); - break; - default: - break; + b = (Boss*)self; + + switch (b->weaponType) + { + case WPN_AIMED_PISTOL: + attackPistol(); + break; + case WPN_MISSILE: + attackMissile(); + break; + default: + break; + } } } @@ -259,7 +262,7 @@ static void attackPistol(void) b->reload = 4; - playSound(SND_MACHINE_GUN, CH_WEAPON); + playSound(SND_MACHINE_GUN, b->uniqueId % MAX_SND_CHANNELS); } static void attackMissile(void) @@ -285,7 +288,7 @@ static void attackMissile(void) initMissile(missile); - playSound(SND_MISSILE, CH_WEAPON); + playSound(SND_MISSILE, b->uniqueId % MAX_SND_CHANNELS); } static void die1(void) @@ -327,7 +330,7 @@ static void die2(void) addTeleportStars(self); addTeleportStars(tankTrack); - playSound(SND_APPEAR, CH_ANY); + playSound(SND_APPEAR, -1); /* don't die! */ b->flags |= EF_GONE; diff --git a/src/entities/boss/tankTrack.c b/src/entities/boss/tankTrack.c index d951f75..dc9364c 100644 --- a/src/entities/boss/tankTrack.c +++ b/src/entities/boss/tankTrack.c @@ -78,7 +78,7 @@ static void touch(Entity *other) { if (other == (Entity*)world.bob && !world.bob->stunTimer && (world.bob->flags & EF_IMMUNE) == 0) { - playSound(SND_FLESH_HIT, CH_ANY); + playSound(SND_FLESH_HIT, world.bob->uniqueId % MAX_SND_CHANNELS); world.bob->dx = rrnd(-5, 5); world.bob->dy = JUMP_POWER; world.bob->applyDamage(3); diff --git a/src/entities/bullets/bullet.c b/src/entities/bullets/bullet.c index 13ce7da..9ae32df 100644 --- a/src/entities/bullets/bullet.c +++ b/src/entities/bullets/bullet.c @@ -88,11 +88,11 @@ static void touch(Entity *other) if (rand() % 2) { - playSound(SND_RICO_1, CH_ANY); + playSound(SND_RICO_1, b->uniqueId % MAX_SND_CHANNELS); } else { - playSound(SND_RICO_2, CH_ANY); + playSound(SND_RICO_2, b->uniqueId % MAX_SND_CHANNELS); } } else if (other != b->owner && (!(other->flags & EF_IGNORE_BULLETS)) && b->owner->type != other->type) @@ -103,13 +103,13 @@ static void touch(Entity *other) if (other->flags & EF_EXPLODES) { - playSound(SND_METAL_HIT, CH_ANY); + playSound(SND_METAL_HIT, b->uniqueId % MAX_SND_CHANNELS); addSparkParticles(b->x, b->y); } else { - playSound(SND_FLESH_HIT, CH_ANY); + playSound(SND_FLESH_HIT, b->uniqueId % MAX_SND_CHANNELS); addSmallFleshChunk(b->x, b->y); } diff --git a/src/entities/bullets/grenade.c b/src/entities/bullets/grenade.c index 90e3736..530813d 100644 --- a/src/entities/bullets/grenade.c +++ b/src/entities/bullets/grenade.c @@ -106,7 +106,7 @@ static float bounce(float x) if (b->environment == ENV_AIR) { - playSound(SND_GRENADE_BOUNCE, CH_EFFECTS); + playSound(SND_GRENADE_BOUNCE, b->uniqueId % MAX_SND_CHANNELS); } return superBounce(x); diff --git a/src/entities/bullets/laser.c b/src/entities/bullets/laser.c index e6331da..7242633 100644 --- a/src/entities/bullets/laser.c +++ b/src/entities/bullets/laser.c @@ -60,12 +60,12 @@ static void touch(Entity *other) if (other->flags & EF_EXPLODES) { addSparkParticles(b->x, b->y); - playSound(SND_METAL_HIT, CH_ANY); + playSound(SND_METAL_HIT, b->uniqueId % MAX_SND_CHANNELS); } else { addSmallFleshChunk(b->x, b->y); - playSound(SND_FLESH_HIT, CH_ANY); + playSound(SND_FLESH_HIT, b->uniqueId % MAX_SND_CHANNELS); } swapSelf(other); diff --git a/src/entities/evilBlobs/evilBlob.c b/src/entities/evilBlobs/evilBlob.c index 08687ae..a7d9b3a 100644 --- a/src/entities/evilBlobs/evilBlob.c +++ b/src/entities/evilBlobs/evilBlob.c @@ -94,7 +94,7 @@ static void die2(void) my = (int) (u->y / MAP_TILE_SIZE) + 1; addBloodDecal(mx, my); - playSound(SND_SPLAT, CH_ANY); + playSound(SND_SPLAT, u->uniqueId % MAX_SND_CHANNELS); } } @@ -297,15 +297,15 @@ static void die(void) switch (rand() % 3) { case 0: - playSound(SND_DEATH_1, CH_DEATH); + playSound(SND_DEATH_1, u->uniqueId % MAX_SND_CHANNELS); break; case 1: - playSound(SND_DEATH_2, CH_DEATH); + playSound(SND_DEATH_2, u->uniqueId % MAX_SND_CHANNELS); break; case 2: - playSound(SND_DEATH_3, CH_DEATH); + playSound(SND_DEATH_3, u->uniqueId % MAX_SND_CHANNELS); break; } } diff --git a/src/entities/eyeDroids/eyeDroid.c b/src/entities/eyeDroids/eyeDroid.c index 4b0927e..6849d13 100644 --- a/src/entities/eyeDroids/eyeDroid.c +++ b/src/entities/eyeDroids/eyeDroid.c @@ -134,11 +134,11 @@ static void die(void) if (rand() % 2) { - playSound(SND_DROID_DIE_1, CH_DEATH); + playSound(SND_DROID_DIE_1, u->uniqueId % MAX_SND_CHANNELS); } else { - playSound(SND_DROID_DIE_2, CH_DEATH); + playSound(SND_DROID_DIE_2, u->uniqueId % MAX_SND_CHANNELS); } } diff --git a/src/entities/items/battery.c b/src/entities/items/battery.c index 607b6bc..76b72da 100644 --- a/src/entities/items/battery.c +++ b/src/entities/items/battery.c @@ -50,7 +50,7 @@ static void touch(Entity *other) pickupItem(); - playSound(SND_ITEM, CH_ITEM); + playSound(SND_ITEM, i->uniqueId % MAX_SND_CHANNELS); game.stats[STAT_BATTERIES_PICKED_UP]++; } diff --git a/src/entities/items/cell.c b/src/entities/items/cell.c index 1ac99f3..015ed11 100644 --- a/src/entities/items/cell.c +++ b/src/entities/items/cell.c @@ -56,7 +56,7 @@ static void touch(Entity *other) setGameplayMessage(MSG_OBJECTIVE, _("Found a battery cell - Max power increased!")); - playSound(SND_HEART_CELL, CH_ITEM); + playSound(SND_HEART_CELL, self->uniqueId % MAX_SND_CHANNELS); self->alive = ALIVE_DEAD; diff --git a/src/entities/items/cherry.c b/src/entities/items/cherry.c index 0d6ec40..9d5f1ce 100644 --- a/src/entities/items/cherry.c +++ b/src/entities/items/cherry.c @@ -47,7 +47,7 @@ static void touch(Entity *other) pickupItem(); - playSound(SND_CHERRY, CH_BOB); + playSound(SND_CHERRY, i->uniqueId % MAX_SND_CHANNELS); game.stats[STAT_CHERRIES_PICKED_UP]++; } diff --git a/src/entities/items/heart.c b/src/entities/items/heart.c index 3e8ba3b..6be4ed5 100644 --- a/src/entities/items/heart.c +++ b/src/entities/items/heart.c @@ -68,7 +68,7 @@ static void touch(Entity *other) setGameplayMessage(MSG_OBJECTIVE, _("Found a heart - Max health increased!")); - playSound(SND_HEART_CELL, CH_ITEM); + playSound(SND_HEART_CELL, self->uniqueId % MAX_SND_CHANNELS); self->alive = ALIVE_DEAD; diff --git a/src/entities/items/item.c b/src/entities/items/item.c index f14ac23..263e08b 100644 --- a/src/entities/items/item.c +++ b/src/entities/items/item.c @@ -141,7 +141,7 @@ static void bobPickupItem(void) setGameplayMessage(MSG_STANDARD, _("Picked up a %s"), i->name); - playSound(SND_KEY, CH_ITEM); + playSound(SND_KEY, i->uniqueId % MAX_SND_CHANNELS); } else { @@ -161,7 +161,7 @@ static void bobPickupItem(void) setGameplayMessage(MSG_STANDARD, _("Picked up a %s"), i->name); - playSound(SND_ITEM, CH_ITEM); + playSound(SND_ITEM, i->uniqueId % MAX_SND_CHANNELS); } else { @@ -178,7 +178,7 @@ static void bobPickupItem(void) setGameplayMessage(MSG_STANDARD, _("Picked up a %s"), i->name); } - playSound(SND_ITEM, CH_ITEM); + playSound(SND_ITEM, i->uniqueId % MAX_SND_CHANNELS); } } @@ -222,7 +222,7 @@ static void changeEnvironment(void) i->x = i->startX; i->y = i->startY; addTeleportStars(self); - playSound(SND_APPEAR, CH_ANY); + playSound(SND_APPEAR, -1); } } diff --git a/src/entities/items/weaponPickup.c b/src/entities/items/weaponPickup.c index e4345f0..b105481 100644 --- a/src/entities/items/weaponPickup.c +++ b/src/entities/items/weaponPickup.c @@ -99,7 +99,7 @@ static void touch(Entity *other) pickupItem(); - playSound(SND_WEAPON, CH_ITEM); + playSound(SND_WEAPON, i->uniqueId % MAX_SND_CHANNELS); game.stats[STAT_WEAPONS_PICKED_UP]++; } diff --git a/src/entities/structures/cardReader.c b/src/entities/structures/cardReader.c index 6068a0c..0b59fc0 100644 --- a/src/entities/structures/cardReader.c +++ b/src/entities/structures/cardReader.c @@ -98,12 +98,12 @@ static void touch(Entity *other) s->spriteTime = 0; s->spriteFrame = 0; - playSound(SND_CONFIRMED, CH_TOUCH); + playSound(SND_CONFIRMED, s->uniqueId % MAX_SND_CHANNELS); } else if (s->bobTouching == 0) { setGameplayMessage(MSG_GAMEPLAY, _("%s required"), s->requiredItem); - playSound(SND_DENIED, CH_TOUCH); + playSound(SND_DENIED, s->uniqueId % MAX_SND_CHANNELS); } s->bobTouching = 2; diff --git a/src/entities/structures/door.c b/src/entities/structures/door.c index 7a40151..1e936b9 100644 --- a/src/entities/structures/door.c +++ b/src/entities/structures/door.c @@ -166,7 +166,7 @@ static void tick(void) { s->isStatic = 1; - playSound(SND_DOOR_FINISH, CH_MECHANICAL); + playSound(SND_DOOR_FINISH, s->uniqueId % MAX_SND_CHANNELS); } } @@ -193,7 +193,7 @@ static void touch(Entity *other) { setGameplayMessage(MSG_GAMEPLAY, _("Door is locked")); - playSound(SND_DENIED, CH_MECHANICAL); + playSound(SND_DENIED, s->uniqueId % MAX_SND_CHANNELS); } s->thinkTime = 2; @@ -208,7 +208,7 @@ static void touch(Entity *other) if (s->state != DOOR_OPEN) { - playSound(SND_DOOR_START, CH_MECHANICAL); + playSound(SND_DOOR_START, s->uniqueId % MAX_SND_CHANNELS); } s->state = DOOR_OPEN; @@ -231,7 +231,7 @@ static void openWithKey(void) if (s->state != DOOR_OPEN) { - playSound(SND_DOOR_START, CH_MECHANICAL); + playSound(SND_DOOR_START, s->uniqueId % MAX_SND_CHANNELS); } s->state = DOOR_OPEN; @@ -243,7 +243,7 @@ static void openWithKey(void) { setGameplayMessage(MSG_GAMEPLAY, _("%s required"), s->requiredItem); - playSound(SND_DENIED, CH_MECHANICAL); + playSound(SND_DENIED, s->uniqueId % MAX_SND_CHANNELS); } s->thinkTime = 2; @@ -276,7 +276,7 @@ static void activate(int active) s->state = (s->state == DOOR_CLOSED) ? DOOR_OPEN : DOOR_CLOSED; - playSound(SND_DOOR_START, CH_MECHANICAL); + playSound(SND_DOOR_START, s->uniqueId % MAX_SND_CHANNELS); if (active) { diff --git a/src/entities/structures/pressurePlate.c b/src/entities/structures/pressurePlate.c index 0529646..6718236 100644 --- a/src/entities/structures/pressurePlate.c +++ b/src/entities/structures/pressurePlate.c @@ -101,7 +101,7 @@ static void touch(Entity *other) { activateEntities(s->targetNames, 1); - playSound(SND_PRESSURE_PLATE, CH_MECHANICAL); + playSound(SND_PRESSURE_PLATE, s->uniqueId % MAX_SND_CHANNELS); } s->active = 1; diff --git a/src/entities/structures/pushBlock.c b/src/entities/structures/pushBlock.c index 3f64043..b4959a0 100644 --- a/src/entities/structures/pushBlock.c +++ b/src/entities/structures/pushBlock.c @@ -79,7 +79,7 @@ static void activate(int active) s->y = s->startY; s->dx = s->dy = 0; addTeleportStars(self); - playSound(SND_APPEAR, CH_ANY); + playSound(SND_APPEAR, s->uniqueId % MAX_SND_CHANNELS); } } diff --git a/src/entities/structures/teleporter.c b/src/entities/structures/teleporter.c index 13904e0..b99273c 100644 --- a/src/entities/structures/teleporter.c +++ b/src/entities/structures/teleporter.c @@ -97,7 +97,7 @@ static void touch(Entity *other) teleportEntity(other, tx, ty); - playSound(SND_TELEPORT, CH_EFFECTS); + playSound(SND_TELEPORT, self->uniqueId % MAX_SND_CHANNELS); } } diff --git a/src/entities/traps/laserTrap.c b/src/entities/traps/laserTrap.c index f8a01b9..d16f32b 100644 --- a/src/entities/traps/laserTrap.c +++ b/src/entities/traps/laserTrap.c @@ -138,7 +138,7 @@ static void touch(Entity *other) swapSelf(other); } - playSound(SND_FLESH_HIT, CH_ANY); + playSound(SND_FLESH_HIT, other->uniqueId % MAX_SND_CHANNELS); } if (other == (Entity*)world.bob && world.bob->stunTimer == 0) diff --git a/src/entities/unit.c b/src/entities/unit.c index 8b866aa..da9a5f5 100644 --- a/src/entities/unit.c +++ b/src/entities/unit.c @@ -158,7 +158,7 @@ static void reappear(void) addTeleportStars(self); - playSound(SND_APPEAR, CH_ANY); + playSound(SND_APPEAR, self->uniqueId % MAX_SND_CHANNELS); } else { @@ -192,7 +192,7 @@ static void applyDamage(int damage) u->flags |= EF_GONE; u->thinkTime = rrnd(FPS, FPS * 2); addTeleportStars(self); - playSound(SND_APPEAR, CH_ANY); + playSound(SND_APPEAR, self->uniqueId % MAX_SND_CHANNELS); } } } diff --git a/src/system/init.c b/src/system/init.c index 962ec53..48ff75b 100644 --- a/src/system/init.c +++ b/src/system/init.c @@ -83,7 +83,7 @@ void initSDL(void) exit(1); } - Mix_AllocateChannels(64); + Mix_AllocateChannels(MAX_SND_CHANNELS); Mix_Volume(-1, app.config.soundVolume); Mix_VolumeMusic(app.config.musicVolume); diff --git a/src/world/world.c b/src/world/world.c index f7d2cd5..33db6fc 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -490,7 +490,7 @@ static void doWorldComplete(void) dropCarriedItems(); world.bob->flags |= EF_GONE; addTeleportStars((Entity*)world.bob); - playSound(SND_TELEPORT, CH_BOB); + playSound(SND_TELEPORT, world.bob->uniqueId % MAX_SND_CHANNELS); } else { @@ -640,7 +640,7 @@ static void spawnEnemies(void) u->spawnedIn = 1; u->canCarryItem = 0; addTeleportStars((Entity*)u); - playSound(SND_APPEAR, CH_ANY); + playSound(SND_APPEAR, u->uniqueId % MAX_SND_CHANNELS); } }