… | |
… | |
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_PLAY_AGAIN, |
|
|
98 | ST_ROLL_STAT, |
|
|
99 | ST_CHANGE_CLASS, |
|
|
100 | ST_CONFIRM_QUIT, |
|
|
101 | ST_CONFIGURE, |
|
|
102 | ST_GET_NAME, |
|
|
103 | ST_GET_PASSWORD, |
|
|
104 | ST_CONFIRM_PASSWORD, |
|
|
105 | ST_GET_PARTY_PASSWORD, |
|
|
106 | }; |
|
|
107 | |
90 | // a handler for a specific type of packet |
108 | // a handler for a specific type of packet |
91 | enum { |
109 | enum { |
92 | PF_PLAYER = 0x01, // must have valid player / will by synchronised |
110 | PF_PLAYER = 0x01, // must have valid player / will by synchronised |
93 | PF_PLAYING = 0x02, // must be in playing state |
111 | PF_PLAYING = 0x02, // must be in playing state |
94 | }; |
112 | }; |
… | |
… | |
160 | unsigned int inbuf_len; // number of bytes valid in inbuf |
178 | unsigned int inbuf_len; // number of bytes valid in inbuf |
161 | uint8 *faces_sent; // This is a bitmap on sent face status |
179 | uint8 *faces_sent; // This is a bitmap on sent face status |
162 | statsinfo stats; |
180 | statsinfo stats; |
163 | |
181 | |
164 | client_container cc_inv, cc_other; |
182 | client_container cc_inv, cc_other; |
|
|
183 | Buffer outputbuffer; |
165 | |
184 | |
166 | char *ACC (RW, host); /* Which host it is connected from (ip address) */ |
185 | char *ACC (RW, host); /* Which host it is connected from (ip address) */ |
|
|
186 | 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 */ |
187 | 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 | |
188 | |
171 | bool ACC (RW, facecache); /* If true, client is caching images */ |
189 | bool ACC (RW, facecache); /* If true, client is caching images */ |
172 | bool ACC (RW, sent_scroll); |
190 | bool ACC (RW, sent_scroll); |
173 | bool ACC (RW, sound); /* does the client want sound */ |
191 | 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 */ |
192 | 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 */ |
224 | int ACC (RW, rtt), ACC (RW, rttvar); /* round-trip time and -variance, if known */ |
207 | |
225 | |
208 | client (int fd, const char *from_ip); |
226 | client (int fd, const char *from_ip); |
209 | ~client (); |
227 | ~client (); |
210 | void destroy (); |
228 | void destroy (); |
|
|
229 | bool destroyed () const { return state == ST_DEAD; } |
211 | |
230 | |
212 | iw cmd_ev; void cmd_cb (iw &w); |
231 | iw cmd_ev; void cmd_cb (iw &w); |
213 | iow socket_ev; void socket_cb (iow &w, int got); |
232 | iow socket_ev; void socket_cb (iow &w, int got); |
214 | |
233 | |
215 | std::deque< command, slice_allocator<command> > cmd_queue; |
234 | std::deque< command, slice_allocator<command> > cmd_queue; |