ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/init.C
(Generate patch)

Comparing deliantra/server/socket/init.C (file contents):
Revision 1.66 by root, Thu Apr 8 19:31:22 2010 UTC vs.
Revision 1.78 by root, Sat Dec 1 20:22:13 2018 UTC

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
128 129
129 if (fcntl (fd, F_SETFL, O_NONBLOCK) == -1) 130 if (fcntl (fd, F_SETFL, O_NONBLOCK) == -1)
130 LOG (llevError, "InitConnection: Error on fcntl.\n"); 131 LOG (llevError, "InitConnection: Error on fcntl.\n");
131 132
132 state = ST_SETUP; 133 state = ST_SETUP;
133 mapmode = Map1aCmd;
134 mapx = 11; 134 mapx = 11;
135 mapy = 11; 135 mapy = 11;
136 itemcmd = 1; /* Default is version item1 command */ 136 itemcmd = 1; /* Default is version item1 command */
137 max_rate = 200000 / (1000000 / MAX_TIME); // ~2mbit is assumed per default 137 max_rate = 100000 / (1000000 / MAX_TIME); // ~1mbit is assumed per default
138 138
139 /* 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
140 * 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
141 * face information. 141 * for following faces in fx.
142 */ 142 */
143 faces_sent[0] = true; 143 faces_sent[0] = true;
144 fx_want [FT_FACE] = true; // all clients must support image faces 144 fx_want [FT_IMAGE] = true; // all clients must support image faces
145 145
146 socket_ev.set (fd, EV_READ); 146 socket_ev.set (fd, EV_READ);
147 socket_ev.prio (2); // one higher than the ticker priority 147 socket_ev.prio (2); // one higher than the ticker priority
148 socket_ev.start (); 148 socket_ev.start ();
149 149
150 // initialisation done, kick it!
151 INVOKE_CLIENT (CONNECT, this);
152
153 flush ();
154
155 reset_stats (); 150 reset_stats ();
156 151
157 clients.insert (this); 152 clients.insert (this);
158} 153}
159 154
160client::~client () 155client::~client ()
161{ 156{
162 clients.erase (this); 157 clients.erase (this);
158
159 while (!ixface.empty ())
160 ix_pop ();
163 161
164 mapinfo_queue_clear (); 162 mapinfo_queue_clear ();
165 free (stats.range); 163 free (stats.range);
166 free (stats.title); 164 free (stats.title);
167 free (host); 165 free (host);
166 free (ws_inbuf);
167}
168
169void
170client::run ()
171{
172 // initialisation done, kick it!
173 INVOKE_CLIENT (CONNECT, this);
174
175 flush ();
168} 176}
169 177
170void 178void
171client::do_destroy () 179client::do_destroy ()
172{ 180{
197 /* we need to clear these to -1 and not zero - otherwise, 205 /* we need to clear these to -1 and not zero - otherwise,
198 * if a player quits and starts a new character, we wont 206 * if a player quits and starts a new character, we wont
199 * send new values to the client, as things like exp start 207 * send new values to the client, as things like exp start
200 * at zero. 208 * at zero.
201 */ 209 */
202 for (int i = 0; i < NUM_SKILLS; i++) 210 for (int i = 0; i < ecb_array_length (last_skill_exp); i++)
203 last_skill_exp[i] = -1; 211 last_skill_exp[i] = -1;
204 212
205 for (int i = 0; i < NROFATTACKS; i++) 213 for (int i = 0; i < ecb_array_length (last_resist); i++)
206 last_resist[i] = -1; 214 last_resist[i] = -1;
207 215
208 last_weapon_sp = -1; 216 last_weapon_sp = -1;
209 last_level = -1; 217 last_level = -1;
210 last_stats.exp = -1; 218 last_stats.exp = -1;
211 last_flags = 0; 219 last_flags = 0;
212 last_weight = -1; 220 last_weight = -1;
213 last_weight_limit = 0; 221 last_weight_limit = 0;
214 last_path_attuned = 0; 222 last_path_attuned = 0;
215 last_path_repelled = 0; 223 last_path_repelled = 0;
216 last_path_denied = 0; 224 last_path_denied = 0;
217 last_speed = 0; 225 last_speed = 0;
218 last_flags = 0; 226 last_flags = 0;
219 227
220 static living zero_living; 228 static living zero_living;
221 last_stats = zero_living; 229 last_stats = zero_living;
222} 230}
223 231

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines