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