… | |
… | |
118 | |
118 | |
119 | buflen = sizeof (oldbufsize); |
119 | buflen = sizeof (oldbufsize); |
120 | getsockopt (fd, SOL_SOCKET, SO_SNDBUF, (char *) &oldbufsize, (socklen_t *) & buflen); |
120 | getsockopt (fd, SOL_SOCKET, SO_SNDBUF, (char *) &oldbufsize, (socklen_t *) & buflen); |
121 | } |
121 | } |
122 | |
122 | |
|
|
123 | state = ST_SETUP; |
123 | mapmode = Map0Cmd; |
124 | mapmode = Map0Cmd; |
124 | darkness = 1; |
125 | darkness = 1; |
125 | mapx = 11; |
126 | mapx = 11; |
126 | mapy = 11; |
127 | mapy = 11; |
127 | itemcmd = 1; /* Default is version item1 command */ |
128 | itemcmd = 1; /* Default is version item1 command */ |
… | |
… | |
156 | } |
157 | } |
157 | |
158 | |
158 | client::~client () |
159 | client::~client () |
159 | { |
160 | { |
160 | if (pl) |
161 | if (pl) |
|
|
162 | { |
|
|
163 | pl->save (); |
|
|
164 | leave (pl, 1); |
161 | pl->socket = 0; |
165 | pl->ns = 0; |
|
|
166 | |
|
|
167 | delete pl; |
|
|
168 | } |
162 | |
169 | |
163 | if (fd >= 0) |
170 | if (fd >= 0) |
164 | close (fd); |
171 | close (fd); |
165 | |
172 | |
166 | sfree<uint8> (faces_sent, nrofpixmaps); |
173 | sfree<uint8> (faces_sent, nrofpixmaps); |
… | |
… | |
170 | } |
177 | } |
171 | |
178 | |
172 | void |
179 | void |
173 | client::destroy () |
180 | client::destroy () |
174 | { |
181 | { |
175 | destroyed = true; |
182 | INVOKE_CLIENT (DESTROY, this); |
|
|
183 | |
|
|
184 | state = ST_DEAD; |
176 | |
185 | |
177 | socket_ev.suspend (); |
186 | socket_ev.suspend (); |
178 | cmd_ev.suspend (); |
187 | cmd_ev.suspend (); |
179 | } |
188 | } |
180 | |
189 | |
… | |
… | |
201 | void |
210 | void |
202 | free_all_newserver (void) |
211 | free_all_newserver (void) |
203 | { |
212 | { |
204 | LOG (llevDebug, "Freeing all new client/server information.\n"); |
213 | LOG (llevDebug, "Freeing all new client/server information.\n"); |
205 | free_socket_images (); |
214 | free_socket_images (); |
206 | } |
|
|
207 | |
|
|
208 | /** Sends the 'goodbye' command to the player, and closes connection. */ |
|
|
209 | void |
|
|
210 | final_free_player (player *pl) |
|
|
211 | { |
|
|
212 | free_player (pl); |
|
|
213 | } |
215 | } |
214 | |
216 | |
215 | client * |
217 | client * |
216 | client::create (int fd, const char *peername) |
218 | client::create (int fd, const char *peername) |
217 | { |
219 | { |