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.33 by pippijn, Sat Jan 6 14:42:31 2007 UTC vs.
Revision 1.35 by root, Mon Jan 8 18:18:36 2007 UTC

59: fd (fd), host (strdup (peername)), 59: fd (fd), host (strdup (peername)),
60 socket_ev (this, &client::socket_cb), 60 socket_ev (this, &client::socket_cb),
61 cmd_ev (this, &client::cmd_cb), 61 cmd_ev (this, &client::cmd_cb),
62 cc_inv (this), cc_other (this) 62 cc_inv (this), cc_other (this)
63{ 63{
64 refcnt_inc (); // the socket is an external reference
65
64 { 66 {
65 struct linger linger_opt; 67 struct linger linger_opt;
66 68
67 linger_opt.l_onoff = 0; 69 linger_opt.l_onoff = 0;
68 linger_opt.l_linger = 0; 70 linger_opt.l_linger = 0;
150 152
151 // initialisation done, kick it! 153 // initialisation done, kick it!
152 send_packet_printf ("version %d %d %s\n", VERSION_CS, VERSION_SC, VERSION_INFO); 154 send_packet_printf ("version %d %d %s\n", VERSION_CS, VERSION_SC, VERSION_INFO);
153 flush (); 155 flush ();
154 156
155 // clients are externally referenced by the socket 157 reset_stats ();
156 refcnt_inc ();
157 clients.push_back (this);
158 158
159#if 0//TODO 159 clients.insert (this);
160 socket_info.nconns++;
161 if (socket_info.nconns > cst_tot.max_conn) cst_tot.max_conn = socket_info.nconns;
162 if (socket_info.nconns > cst_lst.max_conn) cst_lst.max_conn = socket_info.nconns;
163#endif
164} 160}
165 161
166client::~client () 162client::~client ()
167{ 163{
168 sockvec::iterator i = find (clients.begin (), clients.end (), this);
169 if (i != clients.end ())
170 clients.erase (i); 164 clients.erase (this);
171 165
172 sfree<uint8> (faces_sent, nrofpixmaps); 166 sfree<uint8> (faces_sent, nrofpixmaps);
173 free (stats.range); 167 free (stats.range);
174 free (stats.title); 168 free (stats.title);
175 free (host); 169 free (host);
182 176
183 if (pl) 177 if (pl)
184 pl->disconnect (); 178 pl->disconnect ();
185 179
186 if (fd >= 0) 180 if (fd >= 0)
181 {
182 send_packet ("goodbye");
183 flush ();
184
187 close (fd); 185 close (fd);
186 }
188 187
189 state = ST_DEAD; 188 state = ST_DEAD;
190 189
191 socket_ev.suspend (); 190 socket_ev.suspend ();
192 cmd_ev.suspend (); 191 cmd_ev.suspend ();
193 192
194 // socket now longer references us 193 refcnt_dec (); // socket no longer open
195 refcnt_dec (); 194}
195
196void
197client::reset_stats ()
198{
199 /* we need to clear these to -1 and not zero - otherwise,
200 * if a player quits and starts a new character, we wont
201 * send new values to the client, as things like exp start
202 * at zero.
203 */
204 for (int i = 0; i < NUM_SKILLS; i++)
205 last_skill_exp[i] = -1;
206
207 for (int i = 0; i < NROFATTACKS; i++)
208 last_resist[i] = -1;
209
210 last_weapon_sp = -1;
211 last_level = -1;
212 last_stats.exp = -1;
213 last_weight = (uint32) - 1;
214 last_flags = 0;
215 last_weight = 0;
216 last_weight_limit = 0;
217 last_path_attuned = 0;
218 last_path_repelled = 0;
219 last_path_denied = 0;
220 last_speed = 0;
221 flags = 0;
222
223 static living zero_living;
224 last_stats = zero_living;
196} 225}
197 226
198/** This sets up the socket and reads all the image information into memory. */ 227/** This sets up the socket and reads all the image information into memory. */
199void 228void
200init_ericserver (void) 229init_ericserver (void)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines