… | |
… | |
86 | client::handle_command () |
86 | client::handle_command () |
87 | { |
87 | { |
88 | bool skipping = false; |
88 | bool skipping = false; |
89 | |
89 | |
90 | while (!cmd_queue.empty () |
90 | while (!cmd_queue.empty () |
91 | && !(pl && pl->state == ST_PLAYING && pl->ob && pl->ob->speed_left < 0)) |
91 | && !(state == ST_PLAYING && pl->ob && pl->ob->speed_left < 0)) |
92 | { |
92 | { |
93 | command &cmd = cmd_queue.front (); |
93 | command &cmd = cmd_queue.front (); |
94 | |
94 | |
95 | if (cmd.stamp + MAX_QUEUE_BACKLOG < now ()) |
95 | if (cmd.stamp + MAX_QUEUE_BACKLOG < now ()) |
96 | { |
96 | { |
… | |
… | |
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) |
|
|
122 | (*i)->flush (); |
121 | (*i)->flush (); |
123 | } |
122 | } |
124 | |
123 | |
125 | /** |
124 | /** |
126 | * This checks the sockets for input, does the right thing. |
125 | * This checks the sockets for input, does the right thing. |
127 | * |
126 | * |
… | |
… | |
144 | for (player *pl = first_player; pl; ) |
143 | for (player *pl = first_player; pl; ) |
145 | { |
144 | { |
146 | player *npl = pl->next; |
145 | player *npl = pl->next; |
147 | |
146 | |
148 | //TODO: must be handled cleanly elsewhere |
147 | //TODO: must be handled cleanly elsewhere |
149 | if (!pl->socket || pl->socket->status == Ns_Dead) |
148 | if (!pl->ns || pl->ns->destroyed ()) |
150 | { |
149 | { |
151 | save_player (pl->ob, 0); |
150 | save_player (pl->ob, 0); |
152 | |
151 | |
153 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
152 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
154 | { |
153 | { |
… | |
… | |
165 | |
164 | |
166 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ) |
165 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ) |
167 | { |
166 | { |
168 | client *s = *i; |
167 | client *s = *i; |
169 | |
168 | |
170 | if (s->status == Ns_Dead) |
169 | if (s->destroyed ()) |
171 | { |
170 | { |
172 | clients.erase (i); |
171 | clients.erase (i); |
173 | delete s; |
172 | delete s; |
174 | } |
173 | } |
175 | else |
174 | else |
… | |
… | |
183 | { |
182 | { |
184 | client *s = *i; |
183 | client *s = *i; |
185 | player *pl = s->pl; |
184 | player *pl = s->pl; |
186 | |
185 | |
187 | //TODO: should not be done here, either |
186 | //TODO: should not be done here, either |
188 | if (s->status != Ns_Dead && pl) |
187 | if (!s->destroyed () && pl) |
189 | { |
188 | { |
190 | /* Update the players stats once per tick. More efficient than |
189 | /* Update the players stats once per tick. More efficient than |
191 | * sending them whenever they change, and probably just as useful |
190 | * sending them whenever they change, and probably just as useful |
192 | */ |
191 | */ |
193 | esrv_update_stats (pl); |
192 | esrv_update_stats (pl); |