1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_sound_c = |
|
|
4 | * "$Id: sounds.C,v 1.3 2006/09/10 13:43:34 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* Send bug reports to Raphael Quinet (quinet@montefiore.ulg.ac.be) */ |
1 | /* Send bug reports to Raphael Quinet (quinet@montefiore.ulg.ac.be) */ |
8 | |
2 | |
9 | /** |
3 | /** |
10 | * \file |
4 | * \file |
11 | * Sound-related functions. |
5 | * Sound-related functions. |
… | |
… | |
29 | */ |
23 | */ |
30 | void |
24 | void |
31 | play_sound_player_only (player *pl, short soundnum, sint8 x, sint8 y) |
25 | play_sound_player_only (player *pl, short soundnum, sint8 x, sint8 y) |
32 | { |
26 | { |
33 | char soundtype; |
27 | char soundtype; |
34 | SockList sl; |
|
|
35 | |
28 | |
36 | if (!pl->socket.sound) |
29 | if (!pl->socket.sound) |
37 | return; |
30 | return; |
|
|
31 | |
38 | /* Do some quick conversion to the sound type we want. */ |
32 | /* Do some quick conversion to the sound type we want. */ |
39 | if (soundnum >= SOUND_CAST_SPELL_0) |
33 | if (soundnum >= SOUND_CAST_SPELL_0) |
40 | { |
34 | { |
41 | soundtype = SOUND_SPELL; |
35 | soundtype = SOUND_SPELL; |
42 | soundnum -= SOUND_CAST_SPELL_0; |
36 | soundnum -= SOUND_CAST_SPELL_0; |
43 | } |
37 | } |
44 | else |
38 | else |
45 | soundtype = SOUND_NORMAL; |
39 | soundtype = SOUND_NORMAL; |
46 | |
40 | |
47 | sl.buf = (unsigned char *) malloc (MAXSOCKBUF); |
41 | SockList sl (MAXSOCKBUF); |
48 | strcpy ((char *) sl.buf, "sound "); |
42 | |
49 | sl.len = strlen ((char *) sl.buf); |
43 | sl << "sound " |
50 | SockList_AddChar (&sl, x); |
44 | << uint8 (x) |
51 | SockList_AddChar (&sl, y); |
45 | << uint8 (y) |
52 | SockList_AddShort (&sl, soundnum); |
46 | << uint16 (soundnum) |
53 | SockList_AddChar (&sl, soundtype); |
47 | << uint8 (soundtype); |
|
|
48 | |
54 | Send_With_Handling (&pl->socket, &sl); |
49 | Send_With_Handling (&pl->socket, &sl); |
55 | free (sl.buf); |
50 | sl.free (); |
56 | } |
51 | } |
57 | |
52 | |
58 | #define POW2(x) ((x) * (x)) |
53 | #define POW2(x) ((x) * (x)) |
59 | |
54 | |
60 | /** Plays some sound on map at x,y. */ |
55 | /** Plays some sound on map at x,y. */ |
61 | void |
56 | void |
62 | play_sound_map (mapstruct *map, int x, int y, short sound_num) |
57 | play_sound_map (maptile *map, int x, int y, short sound_num) |
63 | { |
58 | { |
64 | player *pl; |
59 | player *pl; |
65 | |
60 | |
66 | if (sound_num >= NROF_SOUNDS) |
61 | if (sound_num >= NROF_SOUNDS) |
67 | { |
62 | { |