ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/sounds.C
(Generate patch)

Comparing deliantra/server/socket/sounds.C (file contents):
Revision 1.16 by root, Thu Jul 26 00:38:34 2007 UTC vs.
Revision 1.20 by root, Tue Jul 31 01:18:16 2007 UTC

74 i->second = face; 74 i->second = face;
75 else 75 else
76 ht.insert (std::make_pair (strdup (str), face)); 76 ht.insert (std::make_pair (strdup (str), face));
77} 77}
78 78
79//TODO: remove
80// for gcfclient-compatibility, to vanish at some point
81faceidx old_sound_index [SOUND_CAST_SPELL_0];
82
79/* 83/*
80 * Plays a sound for specified player only 84 * Plays a sound for specified player only
81 */ 85 */
82void 86void
83client::play_sound (faceidx sound, int dx, int dy) 87client::play_sound (faceidx sound, int dx, int dy)
84{ 88{
85 if (!sound) 89 if (!sound)
86 return; 90 return;
87 91
92 if (dx < -10 || dx > 10) return;
93 if (dy < -10 || dy > 10) return;
94
88 if (fx_want [FT_SOUND]) 95 if (fx_want [FT_SOUND])
89 { 96 {
90 // cfplus 97 // cfplus
91 send_face (sound); 98 send_face (sound);
92 flush_fx (); 99 flush_fx ();
100
101 uint8 vol = clamp (255 - idistance (dx, dy) * 255 / 10, 0, 255);
102
103 // cut off volume here
104 if (vol < 16)
105 return;
93 106
94 packet sl ("sc"); 107 packet sl ("sc");
95 108
96 uint8 *len = sl.cur; 109 uint8 *len = sl.cur;
97 110
98 sl << uint8 (0) // group length 111 sl << uint8 (0) // group length
99 << uint8 (0) // type == one-time effect 112 << uint8 (0) // type == one-time effect
100 << ber32 (sound) 113 << ber32 (sound)
101 << sint8 (dx) 114 << sint8 (dx)
102 << sint8 (dy); 115 << sint8 (dy)
116 << uint8 (vol); // 0 == silent, 255 max
103 117
104 *len = sl.cur - len; // patch in group length 118 *len = sl.cur - len; // patch in group length
105 119
106 send_packet (sl); 120 send_packet (sl);
107 } 121 }
108 else if (this->sound) 122 else if (this->sound)
109 { 123 {
124 //TODO: remove, or make bearable
110 // gcfclient compatibility 125 // gcfclient compatibility
111 // fetch compatibility sound index first
112 126
127 int gcfclient_sound;
128 for (gcfclient_sound = SOUND_CAST_SPELL_0; gcfclient_sound--; )
129 if (old_sound_index [gcfclient_sound] == sound)
130 {
113 packet sl ("sound"); 131 packet sl ("sound");
114 132
115 sl << uint8 (dx) 133 sl << uint8 (dx)
116 << uint8 (dy) 134 << uint8 (dy)
117 << uint16 (sound) 135 << uint16 (gcfclient_sound)
118 << uint8 (SOUND_NORMAL); 136 << uint8 (SOUND_NORMAL);
119 137
120 send_packet (sl); 138 send_packet (sl);
139
140 break;
141 }
121 } 142 }
122} 143}
123 144

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines