… | |
… | |
29 | * |
29 | * |
30 | * Mainly deals with initialization and higher level socket |
30 | * Mainly deals with initialization and higher level socket |
31 | * maintenance (checking for lost connections and if data has arrived.) |
31 | * maintenance (checking for lost connections and if data has arrived.) |
32 | * The reading of data is handled in ericserver.c |
32 | * The reading of data is handled in ericserver.c |
33 | */ |
33 | */ |
34 | |
|
|
35 | |
34 | |
36 | #include <global.h> |
35 | #include <global.h> |
37 | #include <sproto.h> |
36 | #include <sproto.h> |
38 | #include <sys/types.h> |
37 | #include <sys/types.h> |
39 | #include <sys/time.h> |
38 | #include <sys/time.h> |
… | |
… | |
121 | getsockopt (fd, SOL_SOCKET, SO_SNDBUF, (char *) &oldbufsize, (socklen_t *) & buflen); |
120 | getsockopt (fd, SOL_SOCKET, SO_SNDBUF, (char *) &oldbufsize, (socklen_t *) & buflen); |
122 | } |
121 | } |
123 | |
122 | |
124 | mapmode = Map0Cmd; |
123 | mapmode = Map0Cmd; |
125 | darkness = 1; |
124 | darkness = 1; |
126 | status = Ns_Add; |
|
|
127 | mapx = 11; |
125 | mapx = 11; |
128 | mapy = 11; |
126 | mapy = 11; |
129 | itemcmd = 1; /* Default is version item1 command */ |
127 | itemcmd = 1; /* Default is version item1 command */ |
130 | |
128 | |
131 | faces_sent = salloc<uint8> (nrofpixmaps, 0); |
129 | faces_sent = salloc0<uint8> (nrofpixmaps); |
132 | |
130 | |
133 | /* Do this so we don't send a face command for the client for |
131 | /* Do this so we don't send a face command for the client for |
134 | * this face. Face 0 is sent to the client to say clear |
132 | * this face. Face 0 is sent to the client to say clear |
135 | * face information. |
133 | * face information. |
136 | */ |
134 | */ |
… | |
… | |
172 | } |
170 | } |
173 | |
171 | |
174 | void |
172 | void |
175 | client::destroy () |
173 | client::destroy () |
176 | { |
174 | { |
177 | status = Ns_Dead; |
175 | destroyed = true; |
|
|
176 | |
178 | socket_ev.suspend (); |
177 | socket_ev.suspend (); |
179 | cmd_ev.suspend (); |
178 | cmd_ev.suspend (); |
180 | } |
179 | } |
181 | |
180 | |
182 | /** This sets up the socket and reads all the image information into memory. */ |
181 | /** This sets up the socket and reads all the image information into memory. */ |
… | |
… | |
211 | final_free_player (player *pl) |
210 | final_free_player (player *pl) |
212 | { |
211 | { |
213 | free_player (pl); |
212 | free_player (pl); |
214 | } |
213 | } |
215 | |
214 | |
216 | bool |
215 | client * |
217 | add_client (int fd, const char *peername) |
216 | client::create (int fd, const char *peername) |
218 | { |
217 | { |
219 | if (checkbanned (NULL, peername)) |
218 | if (checkbanned (NULL, peername)) |
220 | { |
219 | { |
221 | LOG (llevInfo, "Banned host tried to connect: [%s]\n", peername); |
220 | LOG (llevInfo, "Banned host tried to connect: [%s]\n", peername); |
222 | return false; |
221 | return 0; |
223 | } |
222 | } |
224 | else |
223 | else |
225 | { |
224 | { |
226 | client *ns = new client (dup (fd), peername); |
225 | client *ns = new client (dup (fd), peername); |
227 | clients.push_back (ns); |
226 | clients.push_back (ns); |
|
|
227 | |
|
|
228 | ns->instantiate (); // effectively a nop right now |
|
|
229 | |
|
|
230 | INVOKE_CLIENT (CONNECT, ns); |
|
|
231 | |
228 | return true; |
232 | return ns; |
229 | } |
233 | } |
230 | } |
234 | } |
231 | |
235 | |