ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/loop.C
(Generate patch)

Comparing deliantra/server/socket/loop.C (file contents):
Revision 1.28 by root, Sun Dec 17 19:14:00 2006 UTC vs.
Revision 1.32 by root, Fri Dec 22 16:34:00 2006 UTC

86client::handle_command () 86client::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
117void 117void
118flush_sockets (void) 118flush_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 *
135#ifdef CS_LOGSTATS 134#ifdef CS_LOGSTATS
136 if ((time (NULL) - cst_lst.time_start) >= CS_LOGTIME) 135 if ((time (NULL) - cst_lst.time_start) >= CS_LOGTIME)
137 write_cs_stats (); 136 write_cs_stats ();
138#endif 137#endif
139 138
140 /* Go through the players. Let the loop set the next pl value,
141 * since we may remove some
142 */
143 //TODO: must be handled cleanly elsewhere
144 for (player *pl = first_player; pl; )
145 {
146 player *npl = pl->next;
147
148 //TODO: must be handled cleanly elsewhere
149 if (!pl->socket || pl->socket->status == Ns_Dead)
150 {
151 save_player (pl->ob, 0);
152
153 if (!QUERY_FLAG (pl->ob, FLAG_REMOVED))
154 {
155 terminate_all_pets (pl->ob);
156 pl->ob->remove ();
157 }
158
159 leave (pl, 1);
160 final_free_player (pl);
161 }
162
163 pl = npl;
164 }
165
166 for (sockvec::iterator i = clients.begin (); i != clients.end (); ) 139 for (sockvec::iterator i = clients.begin (); i != clients.end (); )
167 { 140 {
168 client *s = *i; 141 client *s = *i;
169 142
170 if (s->status == Ns_Dead) 143 if (s->destroyed ())
171 { 144 {
172 clients.erase (i); 145 clients.erase (i);
173 delete s; 146 delete s;
174 } 147 }
175 else 148 else
182 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) 155 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
183 { 156 {
184 client *s = *i; 157 client *s = *i;
185 player *pl = s->pl; 158 player *pl = s->pl;
186 159
187 //TODO: this could probably be nuked completely
188 s->handle_packet ();
189 s->handle_command ();
190
191 //TODO: should not be done here, either 160 //TODO: should not be done here, either
192 if (s->status != Ns_Dead && pl) 161 if (!s->destroyed () && pl)
193 { 162 {
194 /* Update the players stats once per tick. More efficient than 163 /* Update the players stats once per tick. More efficient than
195 * sending them whenever they change, and probably just as useful 164 * sending them whenever they change, and probably just as useful
196 */ 165 */
197 esrv_update_stats (pl); 166 esrv_update_stats (pl);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines