--- deliantra/server/socket/sounds.C 2006/08/13 17:16:06 1.1 +++ deliantra/server/socket/sounds.C 2006/09/14 22:34:06 1.4 @@ -1,8 +1,3 @@ -/* - * static char *rcsid_sound_c = - * "$Id: sounds.C,v 1.1 2006/08/13 17:16:06 elmex Exp $"; - */ - /* Send bug reports to Raphael Quinet (quinet@montefiore.ulg.ac.be) */ /** @@ -26,49 +21,58 @@ /** * Plays a sound for specified player only */ -void play_sound_player_only(player *pl, short soundnum, sint8 x, sint8 y) +void +play_sound_player_only (player *pl, short soundnum, sint8 x, sint8 y) { - char soundtype; - SockList sl; + char soundtype; + SockList sl; - if (!pl->socket.sound) return; - /* Do some quick conversion to the sound type we want. */ - if (soundnum>=SOUND_CAST_SPELL_0) { - soundtype=SOUND_SPELL; - soundnum -=SOUND_CAST_SPELL_0; + if (!pl->socket.sound) + return; + /* Do some quick conversion to the sound type we want. */ + if (soundnum >= SOUND_CAST_SPELL_0) + { + soundtype = SOUND_SPELL; + soundnum -= SOUND_CAST_SPELL_0; } - else soundtype=SOUND_NORMAL; + else + soundtype = SOUND_NORMAL; - sl.buf=(unsigned char*)malloc(MAXSOCKBUF); - strcpy((char*)sl.buf, "sound "); - sl.len=strlen((char*)sl.buf); - SockList_AddChar(&sl, x); - SockList_AddChar(&sl, y); - SockList_AddShort(&sl, soundnum); - SockList_AddChar(&sl, soundtype); - Send_With_Handling(&pl->socket, &sl); - free(sl.buf); + sl.buf = (unsigned char *) malloc (MAXSOCKBUF); + strcpy ((char *) sl.buf, "sound "); + sl.len = strlen ((char *) sl.buf); + SockList_AddChar (&sl, x); + SockList_AddChar (&sl, y); + SockList_AddShort (&sl, soundnum); + SockList_AddChar (&sl, soundtype); + Send_With_Handling (&pl->socket, &sl); + free (sl.buf); } #define POW2(x) ((x) * (x)) /** Plays some sound on map at x,y. */ -void play_sound_map(mapstruct *map, int x, int y, short sound_num) +void +play_sound_map (mapstruct *map, int x, int y, short sound_num) { - player *pl; + player *pl; - if (sound_num >= NROF_SOUNDS) { - LOG(llevError,"Tried to play an invalid sound num: %d\n", sound_num); - return; + if (sound_num >= NROF_SOUNDS) + { + LOG (llevError, "Tried to play an invalid sound num: %d\n", sound_num); + return; } - for (pl = first_player; pl; pl = pl->next) { - if (pl->ob->map == map) { - int distance=isqrt(POW2(pl->ob->x - x) + POW2(pl->ob->y - y)); - - if (distance<=MAX_SOUND_DISTANCE) { - play_sound_player_only(pl, sound_num, ( sint8 )( x-pl->ob->x ), ( sint8 )( y-pl->ob->y )); - } - } + for (pl = first_player; pl; pl = pl->next) + { + if (pl->ob->map == map) + { + int distance = isqrt (POW2 (pl->ob->x - x) + POW2 (pl->ob->y - y)); + + if (distance <= MAX_SOUND_DISTANCE) + { + play_sound_player_only (pl, sound_num, (sint8) (x - pl->ob->x), (sint8) (y - pl->ob->y)); + } + } } }