1 | /* |
1 | /* |
2 | * static char *rcsid_sound_c = |
2 | * static char *rcsid_sound_c = |
3 | * "$Id: sounds.C,v 1.1 2006/08/13 17:16:06 elmex Exp $"; |
3 | * "$Id: sounds.C,v 1.2 2006/08/29 08:01:38 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* Send bug reports to Raphael Quinet (quinet@montefiore.ulg.ac.be) */ |
6 | /* Send bug reports to Raphael Quinet (quinet@montefiore.ulg.ac.be) */ |
7 | |
7 | |
8 | /** |
8 | /** |
… | |
… | |
32 | SockList sl; |
32 | SockList sl; |
33 | |
33 | |
34 | if (!pl->socket.sound) return; |
34 | if (!pl->socket.sound) return; |
35 | /* Do some quick conversion to the sound type we want. */ |
35 | /* Do some quick conversion to the sound type we want. */ |
36 | if (soundnum>=SOUND_CAST_SPELL_0) { |
36 | if (soundnum>=SOUND_CAST_SPELL_0) { |
37 | soundtype=SOUND_SPELL; |
37 | soundtype=SOUND_SPELL; |
38 | soundnum -=SOUND_CAST_SPELL_0; |
38 | soundnum -=SOUND_CAST_SPELL_0; |
39 | } |
39 | } |
40 | else soundtype=SOUND_NORMAL; |
40 | else soundtype=SOUND_NORMAL; |
41 | |
41 | |
42 | sl.buf=(unsigned char*)malloc(MAXSOCKBUF); |
42 | sl.buf=(unsigned char*)malloc(MAXSOCKBUF); |
43 | strcpy((char*)sl.buf, "sound "); |
43 | strcpy((char*)sl.buf, "sound "); |
… | |
… | |
56 | void play_sound_map(mapstruct *map, int x, int y, short sound_num) |
56 | void play_sound_map(mapstruct *map, int x, int y, short sound_num) |
57 | { |
57 | { |
58 | player *pl; |
58 | player *pl; |
59 | |
59 | |
60 | if (sound_num >= NROF_SOUNDS) { |
60 | if (sound_num >= NROF_SOUNDS) { |
61 | LOG(llevError,"Tried to play an invalid sound num: %d\n", sound_num); |
61 | LOG(llevError,"Tried to play an invalid sound num: %d\n", sound_num); |
62 | return; |
62 | return; |
63 | } |
63 | } |
64 | |
64 | |
65 | for (pl = first_player; pl; pl = pl->next) { |
65 | for (pl = first_player; pl; pl = pl->next) { |
66 | if (pl->ob->map == map) { |
66 | if (pl->ob->map == map) { |
67 | int distance=isqrt(POW2(pl->ob->x - x) + POW2(pl->ob->y - y)); |
67 | int distance=isqrt(POW2(pl->ob->x - x) + POW2(pl->ob->y - y)); |
68 | |
68 | |
69 | if (distance<=MAX_SOUND_DISTANCE) { |
69 | if (distance<=MAX_SOUND_DISTANCE) { |
70 | play_sound_player_only(pl, sound_num, ( sint8 )( x-pl->ob->x ), ( sint8 )( y-pl->ob->y )); |
70 | play_sound_player_only(pl, sound_num, ( sint8 )( x-pl->ob->x ), ( sint8 )( y-pl->ob->y )); |
71 | } |
71 | } |
72 | } |
72 | } |
73 | } |
73 | } |
74 | } |
74 | } |