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.31 by root, Mon Dec 25 11:25:50 2006 UTC vs.
Revision 1.34 by root, Sun Jan 7 02:39:15 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
3 3
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2001 Mark Wedel 5 Copyright (C) 2001 Mark Wedel
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
6 7
7 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
58: fd (fd), host (strdup (peername)), 59: fd (fd), host (strdup (peername)),
59 socket_ev (this, &client::socket_cb), 60 socket_ev (this, &client::socket_cb),
60 cmd_ev (this, &client::cmd_cb), 61 cmd_ev (this, &client::cmd_cb),
61 cc_inv (this), cc_other (this) 62 cc_inv (this), cc_other (this)
62{ 63{
64 refcnt_inc (); // the socket is an external reference
65
63 { 66 {
64 struct linger linger_opt; 67 struct linger linger_opt;
65 68
66 linger_opt.l_onoff = 0; 69 linger_opt.l_onoff = 0;
67 linger_opt.l_linger = 0; 70 linger_opt.l_linger = 0;
149 152
150 // initialisation done, kick it! 153 // initialisation done, kick it!
151 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);
152 flush (); 155 flush ();
153 156
154 // clients are externally referenced by the socket 157 clients.insert (this);
155 refcnt_inc ();
156 clients.push_back (this);
157
158#if 0//TODO
159 socket_info.nconns++;
160 if (socket_info.nconns > cst_tot.max_conn) cst_tot.max_conn = socket_info.nconns;
161 if (socket_info.nconns > cst_lst.max_conn) cst_lst.max_conn = socket_info.nconns;
162#endif
163} 158}
164 159
165client::~client () 160client::~client ()
166{ 161{
162 clients.erase (this);
163
167 sfree<uint8> (faces_sent, nrofpixmaps); 164 sfree<uint8> (faces_sent, nrofpixmaps);
168 free (stats.range); 165 free (stats.range);
169 free (stats.title); 166 free (stats.title);
170 free (host); 167 free (host);
171} 168}
173void 170void
174client::do_destroy () 171client::do_destroy ()
175{ 172{
176 attachable::do_destroy (); 173 attachable::do_destroy ();
177 174
178 sockvec::iterator i = find (clients.begin (), clients.end (), this);
179 if (i != clients.end ())
180 clients.erase (i);
181
182 if (pl) 175 if (pl)
183 pl->disconnect (); 176 pl->disconnect ();
184 177
185 if (fd >= 0) 178 if (fd >= 0)
179 {
180 send_packet ("goodbye");
181 flush ();
182
186 close (fd); 183 close (fd);
184 }
187 185
188 state = ST_DEAD; 186 state = ST_DEAD;
189 187
190 socket_ev.suspend (); 188 socket_ev.suspend ();
191 cmd_ev.suspend (); 189 cmd_ev.suspend ();
192 190
193 // socket now longer references us 191 refcnt_dec (); // socket no longer open
194 refcnt_dec ();
195} 192}
196 193
197/** This sets up the socket and reads all the image information into memory. */ 194/** This sets up the socket and reads all the image information into memory. */
198void 195void
199init_ericserver (void) 196init_ericserver (void)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines