… | |
… | |
47 | << uint8 (soundtype); |
47 | << uint8 (soundtype); |
48 | |
48 | |
49 | pl->ns->send_packet (sl); |
49 | pl->ns->send_packet (sl); |
50 | } |
50 | } |
51 | |
51 | |
52 | #define POW2(x) ((x) * (x)) |
|
|
53 | |
|
|
54 | /** Plays some sound on map at x,y. */ |
52 | /** Plays some sound on map at x,y. */ |
55 | void |
53 | void |
56 | play_sound_map (maptile *map, int x, int y, short sound_num) |
54 | play_sound_map (maptile *map, int x, int y, short sound_num) |
57 | { |
55 | { |
58 | if (sound_num >= NROF_SOUNDS) |
56 | if (sound_num >= NROF_SOUNDS) |
… | |
… | |
63 | |
61 | |
64 | for_all_players (pl) |
62 | for_all_players (pl) |
65 | { |
63 | { |
66 | if (pl->ob->map == map) |
64 | if (pl->ob->map == map) |
67 | { |
65 | { |
68 | int distance = isqrt (POW2 (pl->ob->x - x) + POW2 (pl->ob->y - y)); |
66 | int distance = idistance (pl->ob->x - x, pl->ob->y - y); |
69 | |
67 | |
70 | if (distance <= MAX_SOUND_DISTANCE) |
68 | if (distance <= MAX_SOUND_DISTANCE) |
71 | { |
|
|
72 | play_sound_player_only (pl, sound_num, (sint8) (x - pl->ob->x), (sint8) (y - pl->ob->y)); |
69 | play_sound_player_only (pl, sound_num, x - pl->ob->x, y - pl->ob->y); |
73 | } |
|
|
74 | } |
70 | } |
75 | } |
71 | } |
76 | } |
72 | } |