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.15 by root, Thu Jul 26 00:27:09 2007 UTC vs.
Revision 1.19 by root, Tue Jul 31 01:06:20 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
88 if (this->sound)
89 {
90 // gcfclient compatibility
91
92 packet sl ("sound");
93
94 sl << uint8 (dx)
95 << uint8 (dy)
96 << uint16 (sound)
97 << uint8 (SOUND_NORMAL);
98
99 send_packet (sl);
100 }
101 else if (fx_want [FT_SOUND]) 92 if (fx_want [FT_SOUND])
102 { 93 {
103 // cfplus 94 // cfplus
104 send_face (sound); 95 send_face (sound);
105 flush_fx (); 96 flush_fx ();
97
98 uint8 vol = clamp (255 - idistance (dx, dy) * 255 / 10, 0, 255);
99
100 // cut off volume here
101 if (vol < 16)
102 return;
106 103
107 packet sl ("sc"); 104 packet sl ("sc");
108 105
109 uint8 *len = sl.cur; 106 uint8 *len = sl.cur;
110 107
111 sl << uint8 (0) // group length 108 sl << uint8 (0) // group length
112 << uint8 (0) // type == one-time effect 109 << uint8 (0) // type == one-time effect
113 << ber32 (sound) 110 << ber32 (sound)
114 << sint8 (dx) 111 << sint8 (dx)
115 << sint8 (dy); 112 << sint8 (dy)
113 << uint8 (vol); // 0 == silent, 255 max
116 114
117 *len = sl.cur - len; // patch in group length 115 *len = sl.cur - len; // patch in group length
118 116
119 send_packet (sl); 117 send_packet (sl);
120 } 118 }
119 else if (this->sound)
120 {
121 //TODO: remove, or make bearable
122 // gcfclient compatibility
123
124 int gcfclient_sound;
125 for (gcfclient_sound = SOUND_CAST_SPELL_0; gcfclient_sound--; )
126 if (old_sound_index [gcfclient_sound] == sound)
127 {
128 packet sl ("sound");
129
130 sl << uint8 (dx)
131 << uint8 (dy)
132 << uint16 (gcfclient_sound)
133 << uint8 (SOUND_NORMAL);
134
135 send_packet (sl);
136
137 break;
138 }
139 }
121} 140}
122 141

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines