… | |
… | |
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 |
|
|
81 | faceidx 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 | */ |
82 | void |
86 | void |
83 | client::play_sound (faceidx sound, int dx, int dy) |
87 | client::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 | uint8 vol = clamp (255 - idistance (dx, dy) * 255 / 10, 0, 255); |
|
|
99 | |
|
|
100 | // cut off volume here |
|
|
101 | if (vol < 16) |
|
|
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 | << uint8 (vol); // 0 == silent, 255 max |
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 | |