Crossfire Client, Trunk  R18666
Functions | Variables
/home/leaf/crossfire/client/trunk/sound-src/common.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "client-types.h"
#include "newclient.h"
#include "client.h"
#include "def_sounds.h"
#include "common.h"
Include dependency graph for common.c:

Go to the source code of this file.

Functions

int init_sounds (void)
int sound_to_soundnum (const char *name, uint8 type)
int type_to_soundtype (uint8 type)
int StdinCmd (char *data, int len)
int write_settings (void)
int read_settings (void)

Variables

const char * rcsid_sound_src_common_c = "$Id: common.c 13995 2010-10-14 04:01:47Z kbulgrien $"
Sound_Info normal_sounds [MAX_SOUNDS]
Sound_Info spell_sounds [MAX_SOUNDS]
Sound_Info default_normal
Sound_Info default_spell
char * client_sounds_path = NULL
char * user_sounds_path = NULL
char * user_sounds_file = NULL
char * user_config_file = NULL
char * buffers = NULL
int stereo = 0
int bit8 = 0
int sample_size = 0
int frequency = 0
int sign = 0
int zerolevel = 0

Detailed Description

Definition in file common.c.


Function Documentation

int init_sounds ( void  )

Opens the audio device, allocates buffers, and reads any configuration files that need to be.

http://en.wikipedia.org/wiki/Comparison_of_file_systems seems to show that 255 characters is the maximum file name length for most file systems. The same page notes that many file systems have no defined limit to directory depth. Some operating environments have a maximum that is quite large - for example, Windows NT can handle paths up to 32,767 bytes. This data, along with the fact that the server Music command from the server has no inherent limitation (other than MAXSOCKBUF), is why MAXSOCKBUF is chosen for the maximum size of the path buffer. MAXSOCKBUF is rather large, but the buffer size is practically only temporarily allocated (via the stack).

Returns:
Zero on success and on failure, the calling function will likely disable sound support/requests from the server.

Definition at line 329 of file common.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int read_settings ( void  )

Read the player .crossfire/sndconfig file.

Returns:

Definition at line 694 of file common.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int sound_to_soundnum ( const char *  name,
uint8  type 
)

Convert a sound name to a sound number to help with the transition of the sound server from sound support to sound2 capability. This is not an end solution, but one that gets the sound server working a little bit until a better one can be implemented.

Parameters:
name
type
Todo:
Implement conversion to legacy soundnum.
Todo:
Replace conversion to legacy soundnum.

Definition at line 461 of file common.c.

Here is the caller graph for this function:

int StdinCmd ( char *  data,
int  len 
)

Preliminary handler for Crossfire server sound2 and music commands that are received from the client via stdin.

The sound player differentiates sound2 and music commands by looking at the first parameter that comes in. Music commands consist of a single, quoted string that identifies the music to play, while a sound effect command has various numeric parameters followed by strings that identify what to play.

Sound2 data consists of whitespace delimited values: x, y, dir, vol, type, sound, and source. Type, sound, and source define what to play, while the other parameters may be used to figure out how to play it. x and y are offsets from the player to identify where the sound originated. dir can be set to indicate a direction that the source is travelling in. vol is an attenuation factor (0-100) that may be applied to the sound volume to make it possible, for example, to give map-designers the ability to suggest relative loudness of sounds in the environment.

FIXME: This is a work-in-progress. The sound2 was put into the server without a plan to fix the clients. cfsndserv is basically made obsolete by sound2. The basic fix resurrects some sound support but does not fully implement the features sound2 is supposed to provide.

Parameters:
dataA text buffer that (hopefully) has a sound or music command.
lenThe length of the text data in the command buffer.
Returns:
0 if the buffer contains a well-formed command, otherwise -1.

Definition at line 519 of file common.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int type_to_soundtype ( uint8  type)

Convert a sound type to legacy type to help with the transition of the sound server from sound support to sound2 capability. This is not an end solution, but one that gets the sound server working a little bit until a better one can be implemented. Basically, all types except 2 get changed to 1.

Parameters:
type
Todo:
Replace conversion to legacy soundtype.

Definition at line 480 of file common.c.

Here is the caller graph for this function:

int write_settings ( void  )

Update the player .crossfire/sndconfig file.

Returns:

Definition at line 668 of file common.c.

Here is the caller graph for this function:


Variable Documentation

int bit8 = 0

Definition at line 63 of file common.c.

char* buffers = NULL

Definition at line 57 of file common.c.

char* client_sounds_path = NULL

Definition at line 52 of file common.c.

Definition at line 49 of file common.c.

Definition at line 50 of file common.c.

int frequency = 0

Definition at line 65 of file common.c.

Definition at line 47 of file common.c.

const char* rcsid_sound_src_common_c = "$Id: common.c 13995 2010-10-14 04:01:47Z kbulgrien $"

Definition at line 1 of file common.c.

int sample_size = 0

Definition at line 64 of file common.c.

int sign = 0

Definition at line 66 of file common.c.

Definition at line 48 of file common.c.

int stereo = 0

Definition at line 62 of file common.c.

char* user_config_file = NULL

Definition at line 55 of file common.c.

char* user_sounds_file = NULL

Definition at line 54 of file common.c.

char* user_sounds_path = NULL

Definition at line 53 of file common.c.

int zerolevel = 0

Definition at line 67 of file common.c.