8 #define MAX_SOUNDS 1024
11 void play_sound(
int soundnum,
int soundtype,
int x,
int y);
14 char *c=(
char *)malloc(
sizeof(
char)*strlen(str)+1);
40 static int readtype=0, lastnum=0;
42 char *cp,*volume,*symbolic,*cp1,filename[512];
44 if (line[0]==
'#' || line[0]==
'\n')
return;
46 if (!strcmp(line,
"Standard Sounds:\n")) {
51 if (!strcmp(line,
"Spell Sounds:\n")) {
58 fprintf(stderr,
"Got input without finding section header yet:\n%d:%s\n",
64 if (line[strlen(line)-1]==
'\n') line[strlen(line)-1]=
'\0';
66 len=strcspn(line,
" \t");
72 while (*cp!=
'\0' && (*cp==
' ' || *cp==
'\t'))
79 if (!(cp=strchr(cp1,
' ')) && !(cp=strchr(cp1,
'\t'))) {
84 while (*cp!=
'\0' && (*cp==
' ' || *cp==
'\t'))
93 for (cp=symbolic; *cp!=
'\0' && *cp!=
'"'; cp++) ;
99 if (!(cp=strchr(cp1,
' ')) && !(cp=strchr(cp1,
'\t')))
103 while (*cp!=
'\0' && (*cp==
' ' || *cp==
'\t'))
107 else newnum=lastnum+1;
111 fprintf(stderr,
"Invalid sound number %d, line %d, buf %s\n",
112 newnum, lineno, line);
120 strcpy(filename, line);
121 cp = filename + strlen(filename)-3;
122 if (!strcmp(cp,
".au"))
125 if (symbolic && !strcmp(symbolic,
"DEFAULT")) {
128 default_normal.
volume=atoi(volume);
129 }
else if (readtype==2) {
131 default_spell.
volume=atoi(volume);
138 normal_sounds[newnum].
volume = atoi(volume);
140 else normal_sounds[newnum].
symbolic=NULL;
141 }
else if (readtype==2) {
143 spell_sounds[newnum].
volume = atoi(volume);
145 else spell_sounds[newnum].
symbolic=NULL;
160 char path[256], buf[512];
163 fprintf( stderr,
"Settings: bits: %i, ",
settings.
bit8?8:16);
164 fprintf( stderr,
"%s, ",
settings.
sign?
"signed":
"unsigned");
181 fprintf( stderr,
"%s, ",
sign?
"signed":
"unsigned");
182 fprintf( stderr,
"%s, ",
stereo?
"stereo":
"mono");
185 fprintf( stderr,
"0level: %i\n",
zerolevel);
191 normal_sounds[i].
size=-1;
192 spell_sounds[i].
size=-1;
197 sprintf(path,
"%s/.crossfire/sounds", getenv(
"HOME"));
199 if (!(fp=fopen(path,
"r"))) {
200 fprintf(stderr,
"Unable to open %s - will use built in defaults\n", path);
201 for (; i<
sizeof(
def_sounds)/
sizeof(
char*); i++) {
205 }
else while (fgets(buf, 511, fp)!=NULL) {
211 if (!normal_sounds[i].filename) {
215 if (!spell_sounds[i].filename) {
219 normal_sounds[i].
data=NULL;
220 spell_sounds[i].
data=NULL;
230 i=sscanf((
char *)data,
"%x %x %x %x",&num,&type,&x,&y);
232 fprintf(stderr,
"Wrong input!\n");
236 fprintf(stderr,
"Playing sound %d (type %d), offset %d, %d\n",
248 if ( (home=getenv(
"HOME")) == NULL )
return -1;
249 path=(
char *)malloc(strlen(home)+strlen(
CONFIG_FILE)+1);
250 if (!path)
return -1;
255 fprintf(f,
"# Crossfire sound server settings\n");
256 fprintf(f,
"# Please note, that not everything will work\n\n");
274 if ( (home=getenv(
"HOME")) == NULL )
return 0;
276 path=(
char *)malloc(strlen(home)+strlen(
CONFIG_FILE)+1);
285 while(fgets(linebuf,1023,f)!=NULL) {
288 linebuf[strlen(linebuf)-1]=0;
290 if (strncmp(linebuf,
"stereo:",strlen(
"stereo:"))==0)
292 else if (strncmp(linebuf,
"bits:",strlen(
"bits:"))==0)
294 else if (strncmp(linebuf,
"signed:",strlen(
"signed:"))==0)
296 else if (strncmp(linebuf,
"buffers:",strlen(
"buffers:"))==0)
298 else if (strncmp(linebuf,
"buflen:",strlen(
"buflen:"))==0)
300 else if (strncmp(linebuf,
"frequency:",strlen(
"frequency:"))==0)
302 else if (strncmp(linebuf,
"simultaneously:",strlen(
"simultaneously:"))==0)
305 else if (strncmp(linebuf,
"device: ",strlen(
"device: "))==0)
Sound_Info normal_sounds[MAX_SOUNDS]
void play_sound(int soundnum, int soundtype, int x, int y)
char * strdup_local(char *str)
Sound_Info spell_sounds[MAX_SOUNDS]
const char *const def_sounds[]
struct Sound_Info Sound_Info
struct sound_settings settings
Sound_Info default_normal
static void parse_sound_line(char *line, int lineno)
int SoundCmd(unsigned char *data, int len)