ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/sounds.C
Revision: 1.14
Committed: Sun Jul 1 05:00:21 2007 UTC (16 years, 11 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.13: +11 -12 lines
Log Message:
- upgrade crossfire trt to the GPL version 3 (hopefully correctly).
- add a single file covered by the GNU Affero General Public License
  (which is not yet released, so I used the current draft, which is
  legally a bit wavy, but its likely better than nothing as it expresses
  direct intent by the authors, and we can upgrade as soon as it has been
  released).
  * this should ensure availability of source code for the server at least
    and hopefully also archetypes and maps even when modified versions
    are not being distributed, in accordance of section 13 of the agplv3.

File Contents

# User Rev Content
1 root 1.13 /*
2 root 1.14 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 root 1.13 *
4     * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5     * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6     * Copyright (©) 1992,2007 Frank Tore Johansen
7     *
8 root 1.14 * Crossfire TRT is free software: you can redistribute it and/or modify
9     * it under the terms of the GNU General Public License as published by
10     * the Free Software Foundation, either version 3 of the License, or
11     * (at your option) any later version.
12 root 1.13 *
13 root 1.14 * This program is distributed in the hope that it will be useful,
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     * GNU General Public License for more details.
17 root 1.13 *
18 root 1.14 * You should have received a copy of the GNU General Public License
19     * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 root 1.13 *
21     * The authors can be reached via e-mail to <crossfire@schmorp.de>
22     */
23    
24 elmex 1.1 /* Send bug reports to Raphael Quinet (quinet@montefiore.ulg.ac.be) */
25    
26     /**
27     * \file
28     * Sound-related functions.
29     *
30     * \date 2003-12-02
31     */
32    
33     #include <global.h>
34     #include <sproto.h>
35     #include <sounds.h>
36    
37     /**
38     * Maximum distance a player may hear a sound from.
39     * This is only used for new client/server sound. If the sound source
40     * on the map is farther away than this, we don't sent it to the client.
41     */
42     #define MAX_SOUND_DISTANCE 10
43    
44     /**
45     * Plays a sound for specified player only
46     */
47 root 1.3 void
48     play_sound_player_only (player *pl, short soundnum, sint8 x, sint8 y)
49 elmex 1.1 {
50 root 1.3 char soundtype;
51 elmex 1.1
52 root 1.10 if (!pl->ns->sound)
53 root 1.3 return;
54 root 1.6
55 root 1.3 /* Do some quick conversion to the sound type we want. */
56     if (soundnum >= SOUND_CAST_SPELL_0)
57     {
58     soundtype = SOUND_SPELL;
59     soundnum -= SOUND_CAST_SPELL_0;
60 elmex 1.1 }
61 root 1.3 else
62     soundtype = SOUND_NORMAL;
63 elmex 1.1
64 root 1.7 packet sl;
65 root 1.6
66     sl << "sound "
67     << uint8 (x)
68     << uint8 (y)
69     << uint16 (soundnum)
70     << uint8 (soundtype);
71    
72 root 1.10 pl->ns->send_packet (sl);
73 elmex 1.1 }
74    
75     /** Plays some sound on map at x,y. */
76 root 1.3 void
77 root 1.5 play_sound_map (maptile *map, int x, int y, short sound_num)
78 elmex 1.1 {
79 root 1.3 if (sound_num >= NROF_SOUNDS)
80     {
81     LOG (llevError, "Tried to play an invalid sound num: %d\n", sound_num);
82     return;
83 elmex 1.1 }
84    
85 root 1.11 for_all_players (pl)
86 root 1.3 {
87     if (pl->ob->map == map)
88     {
89 root 1.12 int distance = idistance (pl->ob->x - x, pl->ob->y - y);
90 root 1.3
91     if (distance <= MAX_SOUND_DISTANCE)
92 root 1.12 play_sound_player_only (pl, sound_num, x - pl->ob->x, y - pl->ob->y);
93 root 1.2 }
94 elmex 1.1 }
95     }