… | |
… | |
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) |
84 | { |
88 | { |
85 | if (!sound) |
89 | if (!sound) |
86 | return; |
90 | return; |
87 | |
91 | |
88 | if (this->sound) |
92 | if (dx < -10 || dx > 10) return; |
89 | { |
93 | if (dy < -10 || dy > 10) return; |
90 | // gcfclient compatibility |
|
|
91 | |
94 | |
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]) |
95 | if (fx_want [FT_SOUND]) |
102 | { |
96 | { |
103 | // cfplus |
97 | // cfplus |
104 | send_face (sound); |
98 | send_face (sound); |
105 | 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; |
106 | |
106 | |
107 | packet sl ("sc"); |
107 | packet sl ("sc"); |
108 | |
108 | |
109 | uint8 *len = sl.cur; |
109 | uint8 *len = sl.cur; |
110 | |
110 | |
111 | sl << uint8 (0) // group length |
111 | sl << uint8 (0) // group length |
112 | << uint8 (0) // type == one-time effect |
112 | << uint8 (0) // type == one-time effect |
113 | << ber32 (sound) |
113 | << ber32 (sound) |
114 | << sint8 (dx) |
114 | << sint8 (dx) |
115 | << sint8 (dy); |
115 | << sint8 (dy) |
|
|
116 | << uint8 (vol); // 0 == silent, 255 max |
116 | |
117 | |
117 | *len = sl.cur - len; // patch in group length |
118 | *len = sl.cur - len; // patch in group length |
118 | |
119 | |
119 | send_packet (sl); |
120 | send_packet (sl); |
120 | } |
121 | } |
|
|
122 | else if (this->sound) |
|
|
123 | { |
|
|
124 | //TODO: remove, or make bearable |
|
|
125 | // gcfclient compatibility |
|
|
126 | |
|
|
127 | int gcfclient_sound; |
|
|
128 | for (gcfclient_sound = SOUND_CAST_SPELL_0; gcfclient_sound--; ) |
|
|
129 | if (old_sound_index [gcfclient_sound] == sound) |
|
|
130 | { |
|
|
131 | packet sl ("sound"); |
|
|
132 | |
|
|
133 | sl << uint8 (dx) |
|
|
134 | << uint8 (dy) |
|
|
135 | << uint16 (gcfclient_sound) |
|
|
136 | << uint8 (SOUND_NORMAL); |
|
|
137 | |
|
|
138 | send_packet (sl); |
|
|
139 | |
|
|
140 | break; |
|
|
141 | } |
|
|
142 | } |
121 | } |
143 | } |
122 | |
144 | |