… | |
… | |
85 | char data[SOCKETBUFSIZE]; |
85 | char data[SOCKETBUFSIZE]; |
86 | int start; |
86 | int start; |
87 | int len; |
87 | int len; |
88 | }; |
88 | }; |
89 | |
89 | |
|
|
90 | // states the socket can be in |
|
|
91 | enum { |
|
|
92 | ST_DEAD, // socket is dead |
|
|
93 | ST_SETUP, // initial handshake / setup / login |
|
|
94 | ST_PLAYING, // logged in an playing |
|
|
95 | ST_CUSTOM, // waiting for custom reply |
|
|
96 | |
|
|
97 | ST_CONFIRM_QUIT, |
|
|
98 | ST_CHANGE_CLASS, |
|
|
99 | ST_CONFIGURE, |
|
|
100 | ST_GET_PARTY_PASSWORD, |
|
|
101 | }; |
|
|
102 | |
90 | // a handler for a specific type of packet |
103 | // a handler for a specific type of packet |
91 | enum { |
104 | enum { |
92 | PF_PLAYER = 0x01, // must have valid player / will by synchronised |
105 | PF_PLAYER = 0x01, // must have valid player / will by synchronised |
93 | PF_PLAYING = 0x02, // must be in playing state |
106 | PF_PLAYING = 0x02, // must be in playing state |
94 | }; |
107 | }; |
… | |
… | |
160 | unsigned int inbuf_len; // number of bytes valid in inbuf |
173 | unsigned int inbuf_len; // number of bytes valid in inbuf |
161 | uint8 *faces_sent; // This is a bitmap on sent face status |
174 | uint8 *faces_sent; // This is a bitmap on sent face status |
162 | statsinfo stats; |
175 | statsinfo stats; |
163 | |
176 | |
164 | client_container cc_inv, cc_other; |
177 | client_container cc_inv, cc_other; |
|
|
178 | Buffer outputbuffer; |
165 | |
179 | |
166 | char *ACC (RW, host); /* Which host it is connected from (ip address) */ |
180 | char *ACC (RW, host); /* Which host it is connected from (ip address) */ |
|
|
181 | uint8 ACC (RW, state); /* Input state of the player (name, password, etc */ |
167 | uint8 ACC (RW, password_fails); /* how many times the player has failed to give the right password */ |
182 | uint8 ACC (RW, password_fails); /* how many times the player has failed to give the right password */ |
168 | bool destroyed; // set when this socket is to be destroyed |
|
|
169 | Buffer outputbuffer; |
|
|
170 | |
183 | |
171 | bool ACC (RW, facecache); /* If true, client is caching images */ |
184 | bool ACC (RW, facecache); /* If true, client is caching images */ |
172 | bool ACC (RW, sent_scroll); |
185 | bool ACC (RW, sent_scroll); |
173 | bool ACC (RW, sound); /* does the client want sound */ |
186 | bool ACC (RW, sound); /* does the client want sound */ |
174 | bool ACC (RW, exp64); /* Client wants 64 bit exp data, as well as skill data */ |
187 | bool ACC (RW, exp64); /* Client wants 64 bit exp data, as well as skill data */ |
… | |
… | |
206 | int ACC (RW, rtt), ACC (RW, rttvar); /* round-trip time and -variance, if known */ |
219 | int ACC (RW, rtt), ACC (RW, rttvar); /* round-trip time and -variance, if known */ |
207 | |
220 | |
208 | client (int fd, const char *from_ip); |
221 | client (int fd, const char *from_ip); |
209 | ~client (); |
222 | ~client (); |
210 | void destroy (); |
223 | void destroy (); |
|
|
224 | bool destroyed () const { return state == ST_DEAD; } |
211 | |
225 | |
212 | iw cmd_ev; void cmd_cb (iw &w); |
226 | iw cmd_ev; void cmd_cb (iw &w); |
213 | iow socket_ev; void socket_cb (iow &w, int got); |
227 | iow socket_ev; void socket_cb (iow &w, int got); |
214 | |
228 | |
215 | std::deque< command, slice_allocator<command> > cmd_queue; |
229 | std::deque< command, slice_allocator<command> > cmd_queue; |