1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
3 | |
3 | |
|
|
4 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002-2003 Mark Wedel & The Crossfire Development Team |
5 | Copyright (C) 2002-2003 Mark Wedel & The Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | |
7 | This program is free software; you can redistribute it and/or modify |
8 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | it under the terms of the GNU General Public License as published by |
… | |
… | |
46 | #include <arpa/inet.h> |
47 | #include <arpa/inet.h> |
47 | |
48 | |
48 | #include <loader.h> |
49 | #include <loader.h> |
49 | |
50 | |
50 | #define MAX_QUEUE_DEPTH 500 //TODO |
51 | #define MAX_QUEUE_DEPTH 500 //TODO |
51 | #define MAX_QUEUE_BACKLOG 5. //TODO |
52 | #define MAX_QUEUE_BACKLOG 3. //TODO |
52 | |
53 | |
53 | void |
54 | void |
54 | client::reset_state () |
55 | client::reset_state () |
55 | { |
56 | { |
56 | if (!pl) |
57 | if (!pl) |
… | |
… | |
135 | if ((time (NULL) - cst_lst.time_start) >= CS_LOGTIME) |
136 | if ((time (NULL) - cst_lst.time_start) >= CS_LOGTIME) |
136 | write_cs_stats (); |
137 | write_cs_stats (); |
137 | #endif |
138 | #endif |
138 | |
139 | |
139 | //TODO: should not be done here, either |
140 | //TODO: should not be done here, either |
140 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
141 | for (int i = 0; i < clients.size (); ++i) |
141 | { |
142 | { |
142 | client *s = *i; |
143 | client *s = clients [i]; |
|
|
144 | player *pl = s->pl; |
143 | |
145 | |
144 | if (player *pl = s->pl) |
146 | if (pl && pl->ns && !pl->ns->destroyed ()) |
145 | { |
147 | { |
|
|
148 | client *ns = pl->ns; |
|
|
149 | |
146 | /* Update the players stats once per tick. More efficient than |
150 | /* Update the players stats once per tick. More efficient than |
147 | * sending them whenever they change, and probably just as useful |
151 | * sending them whenever they change, and probably just as useful |
148 | */ |
152 | */ |
149 | esrv_update_stats (pl); |
153 | esrv_update_stats (pl); |
150 | |
154 | |
151 | if (pl->last_weight != -1 && pl->last_weight != WEIGHT (pl->ob)) |
155 | if (ns->last_weight != -1 && ns->last_weight != WEIGHT (pl->ob)) |
152 | { |
156 | { |
153 | esrv_update_item (UPD_WEIGHT, pl->ob, pl->ob); |
157 | esrv_update_item (UPD_WEIGHT, pl->ob, pl->ob); |
154 | if (pl->last_weight != WEIGHT (pl->ob)) |
158 | if (ns->last_weight != WEIGHT (pl->ob)) |
155 | LOG (llevError, "esrv_update_item(UPD_WEIGHT) did not set player weight: is %lu, should be %lu\n", |
159 | LOG (llevError, "esrv_update_item(UPD_WEIGHT) did not set player weight: is %lu, should be %lu\n", |
156 | (unsigned long) pl->last_weight, WEIGHT (pl->ob)); |
160 | (unsigned long) ns->last_weight, WEIGHT (pl->ob)); |
157 | } |
161 | } |
158 | |
162 | |
159 | draw_client_map (pl->ob); |
163 | draw_client_map (pl->ob); |
160 | |
164 | |
161 | if (s->update_look) |
165 | if (s->update_look) |