… | |
… | |
46 | #include <arpa/inet.h> |
46 | #include <arpa/inet.h> |
47 | |
47 | |
48 | #include <loader.h> |
48 | #include <loader.h> |
49 | |
49 | |
50 | #define MAX_QUEUE_DEPTH 500 //TODO |
50 | #define MAX_QUEUE_DEPTH 500 //TODO |
51 | #define MAX_QUEUE_BACKLOG 5. //TODO |
51 | #define MAX_QUEUE_BACKLOG 3. //TODO |
52 | |
52 | |
53 | void |
53 | void |
54 | client::reset_state () |
54 | client::reset_state () |
55 | { |
55 | { |
56 | if (!pl) |
56 | if (!pl) |
… | |
… | |
134 | #ifdef CS_LOGSTATS |
134 | #ifdef CS_LOGSTATS |
135 | if ((time (NULL) - cst_lst.time_start) >= CS_LOGTIME) |
135 | if ((time (NULL) - cst_lst.time_start) >= CS_LOGTIME) |
136 | write_cs_stats (); |
136 | write_cs_stats (); |
137 | #endif |
137 | #endif |
138 | |
138 | |
139 | /* Go through the players. Let the loop set the next pl value, |
139 | //TODO: should not be done here, either |
140 | * since we may remove some |
|
|
141 | */ |
|
|
142 | //TODO: must be handled cleanly elsewhere |
|
|
143 | for (player *pl = first_player; pl; ) |
|
|
144 | { |
|
|
145 | player *npl = pl->next; |
|
|
146 | |
|
|
147 | //TODO: must be handled cleanly elsewhere |
|
|
148 | if (!pl->ns || pl->ns->destroyed ()) |
|
|
149 | { |
|
|
150 | save_player (pl->ob, 0); |
|
|
151 | |
|
|
152 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
|
|
153 | { |
|
|
154 | terminate_all_pets (pl->ob); |
|
|
155 | pl->ob->remove (); |
|
|
156 | } |
|
|
157 | |
|
|
158 | leave (pl, 1); |
|
|
159 | final_free_player (pl); |
|
|
160 | } |
|
|
161 | |
|
|
162 | pl = npl; |
|
|
163 | } |
|
|
164 | |
|
|
165 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ) |
140 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
166 | { |
141 | { |
167 | client *s = *i; |
142 | client *s = *i; |
168 | |
143 | |
169 | if (s->destroyed ()) |
|
|
170 | { |
|
|
171 | clients.erase (i); |
|
|
172 | delete s; |
|
|
173 | } |
|
|
174 | else |
|
|
175 | ++i; |
|
|
176 | } |
|
|
177 | |
|
|
178 | /* We need to do some of the processing below regardless */ |
|
|
179 | |
|
|
180 | /* Check for any input on the sockets */ |
|
|
181 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
|
|
182 | { |
|
|
183 | client *s = *i; |
|
|
184 | player *pl = s->pl; |
144 | if (player *pl = s->pl) |
185 | |
|
|
186 | //TODO: should not be done here, either |
|
|
187 | if (!s->destroyed () && pl) |
|
|
188 | { |
145 | { |
189 | /* Update the players stats once per tick. More efficient than |
146 | /* Update the players stats once per tick. More efficient than |
190 | * sending them whenever they change, and probably just as useful |
147 | * sending them whenever they change, and probably just as useful |
191 | */ |
148 | */ |
192 | esrv_update_stats (pl); |
149 | esrv_update_stats (pl); |
… | |
… | |
202 | draw_client_map (pl->ob); |
159 | draw_client_map (pl->ob); |
203 | |
160 | |
204 | if (s->update_look) |
161 | if (s->update_look) |
205 | esrv_draw_look (pl->ob); |
162 | esrv_draw_look (pl->ob); |
206 | } |
163 | } |
|
|
164 | |
|
|
165 | s->refcnt_chk (); |
207 | } |
166 | } |
208 | } |
167 | } |
209 | |
168 | |