1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
|
|
4 | * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * |
6 | * |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
7 | * Deliantra is free software: you can redistribute it and/or modify it under |
7 | * the terms of the Affero GNU General Public License as published by the |
8 | * the terms of the Affero GNU General Public License as published by the |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * option) any later version. |
10 | * option) any later version. |
10 | * |
11 | * |
11 | * This program is distributed in the hope that it will be useful, |
12 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * GNU General Public License for more details. |
15 | * |
16 | * |
16 | * You should have received a copy of the Affero GNU General Public License |
17 | * You should have received a copy of the Affero GNU General Public License |
17 | * and the GNU General Public License along with this program. If not, see |
18 | * and the GNU General Public License along with this program. If not, see |
18 | * <http://www.gnu.org/licenses/>. |
19 | * <http://www.gnu.org/licenses/>. |
19 | * |
20 | * |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | */ |
22 | */ |
22 | |
23 | |
23 | /* |
24 | /* |
24 | * Socket general functions |
25 | * Socket general functions |
… | |
… | |
134 | mapy = 11; |
135 | mapy = 11; |
135 | itemcmd = 1; /* Default is version item1 command */ |
136 | itemcmd = 1; /* Default is version item1 command */ |
136 | max_rate = 100000 / (1000000 / MAX_TIME); // ~1mbit is assumed per default |
137 | max_rate = 100000 / (1000000 / MAX_TIME); // ~1mbit is assumed per default |
137 | |
138 | |
138 | /* Do this so we don't send a face command for the client for |
139 | /* Do this so we don't send a face command for the client for |
139 | * this face. Face 0 is sent to the client to say clear |
140 | * this face. Face 0 is sent to the client to set meta data |
140 | * face information. |
141 | * for following faces in fx. |
141 | */ |
142 | */ |
142 | faces_sent[0] = true; |
143 | faces_sent[0] = true; |
143 | fx_want [FT_FACE] = true; // all clients must support image faces |
144 | fx_want [FT_IMAGE] = true; // all clients must support image faces |
144 | |
145 | |
145 | socket_ev.set (fd, EV_READ); |
146 | socket_ev.set (fd, EV_READ); |
146 | socket_ev.prio (2); // one higher than the ticker priority |
147 | socket_ev.prio (2); // one higher than the ticker priority |
147 | socket_ev.start (); |
148 | socket_ev.start (); |
148 | |
149 | |
149 | // initialisation done, kick it! |
|
|
150 | INVOKE_CLIENT (CONNECT, this); |
|
|
151 | |
|
|
152 | flush (); |
|
|
153 | |
|
|
154 | reset_stats (); |
150 | reset_stats (); |
155 | |
151 | |
156 | clients.insert (this); |
152 | clients.insert (this); |
157 | } |
153 | } |
158 | |
154 | |
159 | client::~client () |
155 | client::~client () |
160 | { |
156 | { |
161 | clients.erase (this); |
157 | clients.erase (this); |
|
|
158 | |
|
|
159 | while (!ixface.empty ()) |
|
|
160 | ix_pop (); |
162 | |
161 | |
163 | mapinfo_queue_clear (); |
162 | mapinfo_queue_clear (); |
164 | free (stats.range); |
163 | free (stats.range); |
165 | free (stats.title); |
164 | free (stats.title); |
166 | free (host); |
165 | free (host); |
|
|
166 | free (ws_inbuf); |
|
|
167 | } |
|
|
168 | |
|
|
169 | void |
|
|
170 | client::run () |
|
|
171 | { |
|
|
172 | // initialisation done, kick it! |
|
|
173 | INVOKE_CLIENT (CONNECT, this); |
|
|
174 | |
|
|
175 | flush (); |
167 | } |
176 | } |
168 | |
177 | |
169 | void |
178 | void |
170 | client::do_destroy () |
179 | client::do_destroy () |
171 | { |
180 | { |
… | |
… | |
196 | /* we need to clear these to -1 and not zero - otherwise, |
205 | /* we need to clear these to -1 and not zero - otherwise, |
197 | * if a player quits and starts a new character, we wont |
206 | * if a player quits and starts a new character, we wont |
198 | * send new values to the client, as things like exp start |
207 | * send new values to the client, as things like exp start |
199 | * at zero. |
208 | * at zero. |
200 | */ |
209 | */ |
201 | for (int i = 0; i < NUM_SKILLS; i++) |
210 | for (int i = 0; i < ecb_array_length (last_skill_exp); i++) |
202 | last_skill_exp[i] = -1; |
211 | last_skill_exp[i] = -1; |
203 | |
212 | |
204 | for (int i = 0; i < NROFATTACKS; i++) |
213 | for (int i = 0; i < ecb_array_length (last_resist); i++) |
205 | last_resist[i] = -1; |
214 | last_resist[i] = -1; |
206 | |
215 | |
207 | last_weapon_sp = -1; |
216 | last_weapon_sp = -1; |
208 | last_level = -1; |
217 | last_level = -1; |
209 | last_stats.exp = -1; |
218 | last_stats.exp = -1; |