Skip to content

Commit c0bf553

Browse files
committed
refactor(sound): Use symbolic constants for sound IDs
1 parent 84aff56 commit c0bf553

29 files changed

Lines changed: 124 additions & 112 deletions

src/bflib_guibtns.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "bflib_string.h"
2929
#include "bflib_sound.h"
3030
#include "bflib_keybrd.h"
31+
#include "config_sounds.h"
3132
#include "post_inc.h"
3233

3334
#ifdef __cplusplus
@@ -68,9 +69,9 @@ void do_sound_menu_click(void)
6869
void do_sound_button_click(struct GuiButton *gbtn)
6970
{
7071
if (gbtn->gbtype == LbBtnT_RadioBtn)
71-
play_non_3d_sample(60);
72+
play_non_3d_sample(snd_button_click);
7273
else
73-
play_non_3d_sample(61);
74+
play_non_3d_sample(snd_button_click2);
7475
}
7576

7677
void setup_input_field(struct GuiButton *gbtn, const char * empty_text)

src/console_cmd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "bflib_datetm.h"
2525
#include "bflib_sound.h"
2626
#include "bflib_sndlib.h"
27-
#include "config.h"
27+
#include "config_sounds.h"
2828
#include "config_keeperfx.h"
2929
#include "config_campaigns.h"
3030
#include "config_effects.h"
@@ -1837,7 +1837,7 @@ TbBool cmd_freeze_creature(PlayerNumber plyr_idx, char * args)
18371837
targeted_message_add(MsgType_Player, plyr_idx, plyr_idx, GUI_MESSAGES_DELAY, "no thing selected or not creature");
18381838
return false;
18391839
}
1840-
thing_play_sample(thing, 50, NORMAL_PITCH, 0, 3, 0, 4, FULL_LOUDNESS);
1840+
thing_play_sample(thing, snd_spell_frozen, NORMAL_PITCH, 0, 3, 0, 4, FULL_LOUDNESS);
18411841
// Not sure how to handle this yet, for now simply hardcode the intended spell kind with a number.
18421842
apply_spell_effect_to_thing(thing, 3, 8, plyr_idx); // 3 was 'SplK_Freeze' in the enum.
18431843
return true;
@@ -1855,7 +1855,7 @@ TbBool cmd_slow_creature(PlayerNumber plyr_idx, char * args)
18551855
targeted_message_add(MsgType_Player, plyr_idx, plyr_idx, GUI_MESSAGES_DELAY, "no thing selected or not creature");
18561856
return false;
18571857
}
1858-
thing_play_sample(thing, 50, NORMAL_PITCH, 0, 3, 0, 4, FULL_LOUDNESS);
1858+
thing_play_sample(thing, snd_spell_frozen, NORMAL_PITCH, 0, 3, 0, 4, FULL_LOUDNESS);
18591859
// Not sure how to handle this yet, for now simply hardcode the intended spell kind with a number.
18601860
apply_spell_effect_to_thing(thing, 12, 8, plyr_idx); // 12 was 'SplK_Slow' in the enum.
18611861
return true;

src/creature_control.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ TbBool playing_creature_sound(struct Thing *thing, long snd_idx)
264264
struct CreatureSound* crsound = get_creature_sound(thing, snd_idx);
265265
for (long i = 0; i < crsound->count; i++)
266266
{
267-
if (S3DEmitterIsPlayingSample(thing->snd_emitter_id, crsound->index+i, 0))
267+
if (S3DEmitterIsPlayingSample(thing->snd_emitter_id, crsound->index+i))
268268
return true;
269269
}
270270
return false;
@@ -280,9 +280,9 @@ void stop_creature_sound(struct Thing *thing, long snd_idx)
280280

281281
for (int i = 0; i < crsound->count; i++)
282282
{
283-
if (S3DEmitterIsPlayingSample(thing->snd_emitter_id, crsound->index+i, 0))
283+
if (S3DEmitterIsPlayingSample(thing->snd_emitter_id, crsound->index+i))
284284
{
285-
S3DDeleteSampleFromEmitter(thing->snd_emitter_id, crsound->index+i, 0);
285+
S3DDeleteSampleFromEmitter(thing->snd_emitter_id, crsound->index+i);
286286
}
287287
}
288288
}

src/creature_instances.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "globals.h"
2323
#include "bflib_basics.h"
2424
#include "bflib_sound.h"
25+
#include "config_sounds.h"
2526

2627
#include "bflib_math.h"
2728
#include "thing_list.h"
@@ -676,7 +677,7 @@ long instf_dig(struct Thing *creatng, int32_t *param)
676677
}
677678
}
678679
check_map_explored(creatng, stl_x, stl_y);
679-
thing_play_sample(creatng, 72 + SOUND_RANDOM(3), NORMAL_PITCH, 0, 3, 0, 4, FULL_LOUDNESS);
680+
thing_play_sample(creatng, snd_dig_impact + SOUND_RANDOM(snd_dig_impact_count), NORMAL_PITCH, 0, 3, 0, 4, FULL_LOUDNESS);
680681
return 1;
681682
}
682683

@@ -702,7 +703,7 @@ long instf_destroy(struct Thing *creatng, int32_t *param)
702703
{
703704
volume = FULL_LOUDNESS;
704705
}
705-
thing_play_sample(creatng, 5 + SOUND_RANDOM(2), 200, 0, 3, 0, 2, volume);
706+
thing_play_sample(creatng, snd_foot_spur + SOUND_RANDOM(2), 200, 0, 3, 0, 2, volume);
706707
return 0;
707708
}
708709
clear_dig_on_room_slabs(room, creatng->owner);
@@ -717,7 +718,7 @@ long instf_destroy(struct Thing *creatng, int32_t *param)
717718
event_create_event_or_update_nearby_existing_event(ccor_x, ccor_y, EvKind_RoomLost, room->owner, room->kind);
718719
claim_enemy_room(room, creatng);
719720
}
720-
thing_play_sample(creatng, 76, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
721+
thing_play_sample(creatng, snd_spell_stars, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
721722
create_effects_on_room_slabs(room, imp_spangle_effects[get_player_color_idx(creatng->owner)], 0, creatng->owner);
722723
return 0;
723724
}
@@ -728,7 +729,7 @@ long instf_destroy(struct Thing *creatng, int32_t *param)
728729
{
729730
volume = FULL_LOUDNESS;
730731
}
731-
thing_play_sample(creatng, 128 + SOUND_RANDOM(3), 200, 0, 3, 0, 2, volume);
732+
thing_play_sample(creatng, snd_strike_wall + SOUND_RANDOM(snd_strike_wall_count), 200, 0, 3, 0, 2, volume);
732733
return 0;
733734
}
734735
if (prev_owner != game.neutral_player_num) {
@@ -768,7 +769,7 @@ long instf_attack_room_slab(struct Thing *creatng, int32_t *param)
768769
{
769770
//TODO CONFIG damage made to room slabs is constant - doesn't look good
770771
slb->health -= 2;
771-
thing_play_sample(creatng, 128 + SOUND_RANDOM(3), NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
772+
thing_play_sample(creatng, snd_strike_wall + SOUND_RANDOM(snd_strike_wall_count), NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
772773
return 1;
773774
}
774775
if (room->owner != game.neutral_player_num)
@@ -787,7 +788,7 @@ long instf_attack_room_slab(struct Thing *creatng, int32_t *param)
787788
return 0;
788789
}
789790
create_effect(&creatng->mappos, TngEff_Explosion3, creatng->owner);
790-
thing_play_sample(creatng, 47, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
791+
thing_play_sample(creatng, snd_explode, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
791792
if (z > 0)
792793
{
793794
for (long k = 0; k < AROUND_TILES_COUNT; k++)
@@ -822,9 +823,9 @@ long instf_damage_wall(struct Thing *creatng, int32_t *param)
822823
place_slab_type_on_map(SlbT_EARTH, stl_x, stl_y, creatng->owner, 0);
823824
do_slab_efficiency_alteration(slb_x, slb_y);
824825
create_dirt_rubble_for_dug_slab(slb_x, slb_y);
825-
thing_play_sample(creatng, 73, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
826+
thing_play_sample(creatng, snd_dig_dirt, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
826827
}
827-
thing_play_sample(creatng, 63+SOUND_RANDOM(6), NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
828+
thing_play_sample(creatng, snd_dig_spell + SOUND_RANDOM(snd_dig_spell_count), NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
828829
return 1;
829830
}
830831

@@ -1015,7 +1016,7 @@ long instf_pretty_path(struct Thing *creatng, int32_t *param)
10151016
MapSlabCoord slb_x = subtile_slab(creatng->mappos.x.stl.num);
10161017
MapSlabCoord slb_y = subtile_slab(creatng->mappos.y.stl.num);
10171018
create_effect(&creatng->mappos, imp_spangle_effects[get_player_color_idx(creatng->owner)], creatng->owner);
1018-
thing_play_sample(creatng, 76, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
1019+
thing_play_sample(creatng, snd_spell_stars, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
10191020
place_slab_type_on_map(SlbT_CLAIMED, slab_subtile_center(slb_x), slab_subtile_center(slb_y), creatng->owner, 1);
10201021
do_unprettying(creatng->owner, slb_x, slb_y);
10211022
do_slab_efficiency_alteration(slb_x, slb_y);
@@ -1039,7 +1040,7 @@ long instf_reinforce(struct Thing *creatng, int32_t *param)
10391040
if (cctrl->digger.consecutive_reinforcements <= 25)
10401041
{
10411042
cctrl->digger.consecutive_reinforcements++;
1042-
if (!S3DEmitterIsPlayingSample(creatng->snd_emitter_id, 63, 0))
1043+
if (!S3DEmitterIsPlayingSample(creatng->snd_emitter_id, 63))
10431044
{
10441045
struct PlayerInfo* player;
10451046
player = get_my_player();
@@ -1048,7 +1049,7 @@ long instf_reinforce(struct Thing *creatng, int32_t *param)
10481049
{
10491050
volume = FULL_LOUDNESS;
10501051
}
1051-
thing_play_sample(creatng, 1005 + SOUND_RANDOM(7), NORMAL_PITCH, 0, 3, 0, 2, volume);
1052+
thing_play_sample(creatng, snd_reinforce_hit + SOUND_RANDOM(snd_reinforce_hit_count), NORMAL_PITCH, 0, 3, 0, 2, volume);
10521053
}
10531054
return 0;
10541055
}
@@ -1066,7 +1067,7 @@ long instf_reinforce(struct Thing *creatng, int32_t *param)
10661067
create_effect(&pos, imp_spangle_effects[get_player_color_idx(creatng->owner)], creatng->owner);
10671068
}
10681069
}
1069-
thing_play_sample(creatng, 41, NORMAL_PITCH, 0, 3, 0, 3, FULL_LOUDNESS);
1070+
thing_play_sample(creatng, snd_spell_wall, NORMAL_PITCH, 0, 3, 0, 3, FULL_LOUDNESS);
10701071
return 0;
10711072
}
10721073

@@ -1087,7 +1088,7 @@ long instf_tunnel(struct Thing *creatng, int32_t *param)
10871088
if (slabmap_block_invalid(slb)) {
10881089
return 0;
10891090
}
1090-
thing_play_sample(creatng, 69+SOUND_RANDOM(3), NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
1091+
thing_play_sample(creatng, snd_tunnel_dig + SOUND_RANDOM(snd_tunnel_dig_count), NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
10911092
if (slb->health > 1) {
10921093
slb->health--;
10931094
} else {

src/creature_states.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "thing_traps.h"
6363
#include "magic_powers.h"
6464
#include "sounds.h"
65+
#include "config_sounds.h"
6566
#include "game_legacy.h"
6667
#include "sprites.h"
6768
#include "lua_cfg_funcs.h"
@@ -2812,7 +2813,7 @@ short creature_present_to_dungeon_heart(struct Thing *creatng)
28122813
{
28132814
TRACE_THING(creatng);
28142815
create_effect(&creatng->mappos, imp_spangle_effects[get_player_color_idx(creatng->owner)], creatng->owner);
2815-
thing_play_sample(creatng, 76, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
2816+
thing_play_sample(creatng, snd_spell_stars, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
28162817
if ( !external_set_thing_state(creatng, CrSt_CreatureDoingNothing) )
28172818
set_start_state(creatng);
28182819
return 1;
@@ -3164,7 +3165,7 @@ short creature_take_salary(struct Thing *creatng)
31643165
{
31653166
anger_apply_anger_to_creature_all_types(creatng, crconf->annoy_got_wage);
31663167
}
3167-
thing_play_sample(efftng, 32, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
3168+
thing_play_sample(efftng, snd_gold_pickup, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
31683169
dungeon->lvstats.salary_cost += salary;
31693170
return 1;
31703171
}

src/creature_states_gardn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "bflib_math.h"
2424
#include "bflib_planar.h"
25-
#include "creature_states.h"
25+
#include "config_sounds.h"
2626
#include "creature_instances.h"
2727
#include "thing_list.h"
2828
#include "creature_control.h"
@@ -75,7 +75,7 @@ TbBool hunger_is_creature_hungry(const struct Thing *creatng)
7575

7676
void person_eat_food(struct Thing *creatng, struct Thing *foodtng, struct Room *room)
7777
{
78-
thing_play_sample(creatng, 112+SOUND_RANDOM(3), NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
78+
thing_play_sample(creatng, snd_chicken_cluck + SOUND_RANDOM(snd_chicken_cluck_count), NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
7979
internal_set_thing_state(creatng, CrSt_CreatureEat);
8080
set_creature_instance(creatng, CrInst_EAT, 0, 0);
8181
creatng->continue_state = CrSt_CreatureToGarden;

src/creature_states_mood.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ short creature_piss(struct Thing *thing)
126126
struct CreatureControl* cctrl = creature_control_get_from_thing(thing);
127127
struct CreatureSound* crsound = get_creature_sound(thing, CrSnd_Piss);
128128
unsigned short sound_idx = crsound->index + THING_RANDOM(thing, crsound->count);
129-
if (!S3DEmitterIsPlayingSample(thing->snd_emitter_id, sound_idx, 0)) {
129+
if (!S3DEmitterIsPlayingSample(thing->snd_emitter_id, sound_idx)) {
130130
thing_play_sample(thing, sound_idx, NORMAL_PITCH, 0, 3, 1, 6, FULL_LOUDNESS);
131131
}
132132
long i = cctrl->countdown;

src/creature_states_scavn.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
#include "bflib_math.h"
2424
#include "bflib_sound.h"
25-
26-
#include "creature_states.h"
25+
#include "config_sounds.h"
2726
#include "thing_list.h"
2827
#include "creature_control.h"
2928
#include "creature_states_prisn.h"
@@ -162,8 +161,8 @@ short creature_being_scavenged(struct Thing *creatng)
162161
return 0;
163162
}
164163
creatng->continue_state = CrSt_CreatureBeingScavenged;
165-
if (!S3DEmitterIsPlayingSample(creatng->snd_emitter_id, 156, 0))
166-
thing_play_sample(creatng, 156, NORMAL_PITCH, 0, 3, 1, 2, FULL_LOUDNESS);
164+
if (!S3DEmitterIsPlayingSample(creatng->snd_emitter_id, snd_scavenge))
165+
thing_play_sample(creatng, snd_scavenge, NORMAL_PITCH, 0, 3, 1, 2, FULL_LOUDNESS);
167166
SYNCDBG(19,"Finished");
168167
return 1;
169168
}

src/creature_states_spdig.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "globals.h"
2222

2323
#include "bflib_sound.h"
24+
#include "config_sounds.h"
2425
#include "bflib_math.h"
2526
#include "bflib_planar.h"
2627
#include "creature_states.h"
@@ -1247,7 +1248,7 @@ short imp_drops_gold(struct Thing *spdigtng)
12471248
}
12481249
if ( (gold_added > 0) || (gold_created) )
12491250
{
1250-
thing_play_sample(spdigtng, SOUND_RANDOM(3) + 32, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
1251+
thing_play_sample(spdigtng, snd_gold_pickup + SOUND_RANDOM(snd_gold_pickup_count), NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
12511252
if (game.conf.rules[spdigtng->owner].workers.digger_work_experience != 0)
12521253
{
12531254
struct CreatureControl* cctrl = creature_control_get_from_thing(spdigtng);
@@ -1259,7 +1260,7 @@ short imp_drops_gold(struct Thing *spdigtng)
12591260
{
12601261
if (is_thing_directly_controlled_by_player(spdigtng, my_player_number))
12611262
{
1262-
play_non_3d_sample(119);
1263+
play_non_3d_sample(snd_refusal);
12631264
internal_set_thing_state(spdigtng, state);
12641265
return 1;
12651266
}
@@ -1390,7 +1391,7 @@ short imp_picks_up_gold_pile(struct Thing *spdigtng)
13901391
spdigtng->creature.gold_carried += gold_taken;
13911392
if (gold_taken > 0)
13921393
{
1393-
thing_play_sample(spdigtng, 32, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
1394+
thing_play_sample(spdigtng, snd_gold_pickup, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
13941395
}
13951396
}
13961397
internal_set_thing_state(spdigtng, state);

src/dungeon_stats.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "config_powerhands.h"
3636
#include "config_spritecolors.h"
3737
#include "config_players.h"
38+
#include "config_sounds.h"
3839
#include "room_library.h"
3940
#include "game_legacy.h"
4041
#include "post_inc.h"

0 commit comments

Comments
 (0)