Crossfire Server, Trunk  1.75.0
sounds.cpp File Reference
#include "global.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "sounds.h"
#include "sproto.h"
+ Include dependency graph for sounds.cpp:

Go to the source code of this file.

Macros

#define MAX_SOUND_DISTANCE   10
 Maximum distance a player may hear a sound from. More...
 
#define POW2(x)   ((x)*(x))
 

Functions

static char const * pick_bg_music (mapstruct *map)
 
void play_sound_map (int8_t sound_type, object *emitter, int dir, const char *action)
 Plays a sound on a map. More...
 
void play_sound_player_only (player *pl, int8_t sound_type, object *emitter, int dir, const char *action)
 Plays a sound for specified player only. More...
 
void player_update_bg_music (object *player)
 
void send_background_music (player *pl, const char *music)
 Sends background music to client. More...
 

Detailed Description

Sound-related functions.

Date
2003-12-02

Definition in file sounds.cpp.

Macro Definition Documentation

◆ MAX_SOUND_DISTANCE

#define MAX_SOUND_DISTANCE   10

Maximum distance a player may hear a sound from.

This is only used for new client/server sound. If the sound source on the map is farther away than this, we don't sent it to the client.

Definition at line 35 of file sounds.cpp.

◆ POW2

#define POW2 (   x)    ((x)*(x))

Definition at line 100 of file sounds.cpp.

Function Documentation

◆ pick_bg_music()

static char const* pick_bg_music ( mapstruct map)
static

Definition at line 163 of file sounds.cpp.

References mapstruct::background_music, and get_name_of_region_for_map().

Referenced by player_update_bg_music().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ play_sound_map()

void play_sound_map ( int8_t  sound_type,
object emitter,
int  dir,
const char *  action 
)

Plays a sound on a map.

Parameters
sound_typesound type, see the sound types.
emitterobject emitting the sound. Must be on a map.
dirdirection the sound is moving.
actionsound name to play.

Definition at line 113 of file sounds.cpp.

References object::env, first_player, ihypot(), object::map, MAX_SOUND_DISTANCE, player::next, player::ob, play_sound_player_only(), RANDOM, object::sound_chance, object::x, and object::y.

Referenced by apply_by_living(), attack_message(), attack_ob_simple(), button_type_move_on(), cast_spell(), cf_handle_type_apply(), fire_bow(), food_type_apply(), gate_type_process(), hole_type_move_on(), kill_object(), move_ob(), move_player_attack(), player_attack_door(), polymorph_melt(), potion_type_apply(), recharge(), save_life(), trapdoor_type_move_on(), and trigger_type_apply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ play_sound_player_only()

void play_sound_player_only ( player pl,
int8_t  sound_type,
object emitter,
int  dir,
const char *  action 
)

Plays a sound for specified player only.

Parameters
plplayer to play sound to.
sound_typesound type, see the sound types.
emitterobject emitting a sound.
dirdirection the sound is moving into.
actionsound name to play.

Definition at line 51 of file sounds.cpp.

References object::arch, archetype::clone, object::env, EXIT, FABS, object::map, MAX_SOUNDS_TICK, MIN, name, object::name, player::ob, PLAYER, object::race, Send_With_Handling(), SND_EFFECTS, SND_MUTE, player::socket, SockList_AddChar(), SockList_AddLen8Data(), SockList_AddString(), SockList_Init(), SockList_Term(), socket_struct::sound, socket_struct::sounds_this_tick, sstring, object::type, object::x, and object::y.

Referenced by apply_manual(), cast_spell(), clock_type_apply(), do_learn_spell(), fire_misc_object(), kill_player(), play_sound_map(), poison_type_apply(), and spellbook_type_apply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ player_update_bg_music()

void player_update_bg_music ( object player)

Definition at line 170 of file sounds.cpp.

References pick_bg_music(), PLAYER, and send_background_music().

Referenced by dimension_door(), do_follow(), object_teleport(), player_map_change_common(), teleport(), and transfer_ob().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_background_music()

void send_background_music ( player pl,
const char *  music 
)

Sends background music to client.

Parameters
plplayer
musicbackground music name. Can be NULL.

Definition at line 150 of file sounds.cpp.

References Send_With_Handling(), SND_MUSIC, SND_MUTE, player::socket, SockList_AddString(), SockList_Init(), SockList_Term(), and socket_struct::sound.

Referenced by player_update_bg_music().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: