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.18 by root, Sat Jul 28 00:45:05 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)
89 { 93 {
90 // cfplus 94 // cfplus
91 send_face (sound); 95 send_face (sound);
92 flush_fx (); 96 flush_fx ();
93 97
98 sint8 vol = idistance (dx, dy) * -80 / 10;
99
100 // cut off volume here
101 if (vol < -80)
102 return;
103
94 packet sl ("sc"); 104 packet sl ("sc");
95 105
96 uint8 *len = sl.cur; 106 uint8 *len = sl.cur;
97 107
98 sl << uint8 (0) // group length 108 sl << uint8 (0) // group length
99 << uint8 (0) // type == one-time effect 109 << uint8 (0) // type == one-time effect
100 << ber32 (sound) 110 << ber32 (sound)
101 << sint8 (dx) 111 << sint8 (dx)
102 << sint8 (dy); 112 << sint8 (dy)
113 << sint8 (vol); // -128 == silent, 0 normal, 127 twice the amplitude
103 114
104 *len = sl.cur - len; // patch in group length 115 *len = sl.cur - len; // patch in group length
105 116
106 send_packet (sl); 117 send_packet (sl);
107 } 118 }
108 else if (this->sound) 119 else if (this->sound)
109 { 120 {
121 //TODO: remove, or make bearable
110 // gcfclient compatibility 122 // gcfclient compatibility
111 // fetch compatibility sound index first
112 123
124 int gcfclient_sound;
125 for (gcfclient_sound = SOUND_CAST_SPELL_0; gcfclient_sound--; )
126 if (old_sound_index [gcfclient_sound] == sound)
127 {
113 packet sl ("sound"); 128 packet sl ("sound");
114 129
115 sl << uint8 (dx) 130 sl << uint8 (dx)
116 << uint8 (dy) 131 << uint8 (dy)
117 << uint16 (sound) 132 << uint16 (gcfclient_sound)
118 << uint8 (SOUND_NORMAL); 133 << uint8 (SOUND_NORMAL);
119 134
120 send_packet (sl); 135 send_packet (sl);
136
137 break;
138 }
121 } 139 }
122} 140}
123 141

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines