… | |
… | |
116 | |
116 | |
117 | void |
117 | void |
118 | flush_sockets (void) |
118 | flush_sockets (void) |
119 | { |
119 | { |
120 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
120 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
121 | if ((*i)->status != Ns_Dead) |
121 | if (!(*i)->destroyed) |
122 | (*i)->flush (); |
122 | (*i)->flush (); |
123 | } |
123 | } |
124 | |
124 | |
125 | /** |
125 | /** |
126 | * This checks the sockets for input, does the right thing. |
126 | * This checks the sockets for input, does the right thing. |
… | |
… | |
144 | for (player *pl = first_player; pl; ) |
144 | for (player *pl = first_player; pl; ) |
145 | { |
145 | { |
146 | player *npl = pl->next; |
146 | player *npl = pl->next; |
147 | |
147 | |
148 | //TODO: must be handled cleanly elsewhere |
148 | //TODO: must be handled cleanly elsewhere |
149 | if (!pl->socket || pl->socket->status == Ns_Dead) |
149 | if (!pl->socket || pl->socket->destroyed) |
150 | { |
150 | { |
151 | save_player (pl->ob, 0); |
151 | save_player (pl->ob, 0); |
152 | |
152 | |
153 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
153 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
154 | { |
154 | { |
… | |
… | |
165 | |
165 | |
166 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ) |
166 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ) |
167 | { |
167 | { |
168 | client *s = *i; |
168 | client *s = *i; |
169 | |
169 | |
170 | if (s->status == Ns_Dead) |
170 | if (s->destroyed) |
171 | { |
171 | { |
172 | clients.erase (i); |
172 | clients.erase (i); |
173 | delete s; |
173 | delete s; |
174 | } |
174 | } |
175 | else |
175 | else |
… | |
… | |
182 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
182 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
183 | { |
183 | { |
184 | client *s = *i; |
184 | client *s = *i; |
185 | player *pl = s->pl; |
185 | player *pl = s->pl; |
186 | |
186 | |
187 | s->handle_packet (); |
|
|
188 | |
|
|
189 | for (int i = 16; --i; ) //D |
|
|
190 | if (!//D |
|
|
191 | s->handle_command () |
|
|
192 | ) break;//D |
|
|
193 | |
|
|
194 | //TODO: should not be done here, either |
187 | //TODO: should not be done here, either |
195 | if (s->status != Ns_Dead && pl) |
188 | if (!s->destroyed && pl) |
196 | { |
189 | { |
197 | /* Update the players stats once per tick. More efficient than |
190 | /* Update the players stats once per tick. More efficient than |
198 | * sending them whenever they change, and probably just as useful |
191 | * sending them whenever they change, and probably just as useful |
199 | */ |
192 | */ |
200 | esrv_update_stats (pl); |
193 | esrv_update_stats (pl); |