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.18 by root, Sat Jul 28 00:45:05 2007 UTC vs.
Revision 1.20 by root, Tue Jul 31 01:18:16 2007 UTC

87client::play_sound (faceidx sound, int dx, int dy) 87client::play_sound (faceidx sound, int dx, int dy)
88{ 88{
89 if (!sound) 89 if (!sound)
90 return; 90 return;
91 91
92 if (dx < -10 || dx > 10) return;
93 if (dy < -10 || dy > 10) return;
94
92 if (fx_want [FT_SOUND]) 95 if (fx_want [FT_SOUND])
93 { 96 {
94 // cfplus 97 // cfplus
95 send_face (sound); 98 send_face (sound);
96 flush_fx (); 99 flush_fx ();
97 100
98 sint8 vol = idistance (dx, dy) * -80 / 10; 101 uint8 vol = clamp (255 - idistance (dx, dy) * 255 / 10, 0, 255);
99 102
100 // cut off volume here 103 // cut off volume here
101 if (vol < -80) 104 if (vol < 16)
102 return; 105 return;
103 106
104 packet sl ("sc"); 107 packet sl ("sc");
105 108
106 uint8 *len = sl.cur; 109 uint8 *len = sl.cur;
108 sl << uint8 (0) // group length 111 sl << uint8 (0) // group length
109 << uint8 (0) // type == one-time effect 112 << uint8 (0) // type == one-time effect
110 << ber32 (sound) 113 << ber32 (sound)
111 << sint8 (dx) 114 << sint8 (dx)
112 << sint8 (dy) 115 << sint8 (dy)
113 << sint8 (vol); // -128 == silent, 0 normal, 127 twice the amplitude 116 << uint8 (vol); // 0 == silent, 255 max
114 117
115 *len = sl.cur - len; // patch in group length 118 *len = sl.cur - len; // patch in group length
116 119
117 send_packet (sl); 120 send_packet (sl);
118 } 121 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines