1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_init_c = |
|
|
4 | * "$Id: request.C,v 1.17 2006/09/12 19:20:09 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2001 Mark Wedel |
4 | Copyright (C) 2001 Mark Wedel |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
22 | |
16 | |
23 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
24 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | |
20 | |
27 | The author can be reached via e-mail to crossfire-devel@real-time.com |
21 | The author can be reached via e-mail to <crossfire@schmorp.de> |
28 | */ |
22 | */ |
29 | |
23 | |
30 | /** |
24 | /** |
31 | * \file |
25 | * \file |
32 | * Client handling. |
26 | * Client handling. |
… | |
… | |
50 | * operations |
44 | * operations |
51 | * |
45 | * |
52 | * esrv_map_doneredraw finishes the map update, and ships across the |
46 | * esrv_map_doneredraw finishes the map update, and ships across the |
53 | * map updates. |
47 | * map updates. |
54 | * |
48 | * |
55 | * esrv_map_scroll tells the client to scroll the map, and does similarily |
|
|
56 | * for the locally cached copy. |
|
|
57 | */ |
49 | */ |
58 | |
50 | |
59 | #include <global.h> |
51 | #include <global.h> |
60 | #include <sproto.h> |
52 | #include <sproto.h> |
61 | |
53 | |
… | |
… | |
266 | if (!strncmp (buf, "spatial ", 8)) |
258 | if (!strncmp (buf, "spatial ", 8)) |
267 | { |
259 | { |
268 | buf += 8; |
260 | buf += 8; |
269 | |
261 | |
270 | // initial map and its origin |
262 | // initial map and its origin |
271 | mapstruct *map = pl->ob->map; |
263 | maptile *map = pl->ob->map; |
272 | sint16 dx, dy; |
264 | sint16 dx, dy; |
273 | int mapx = pl->socket.mapx / 2 - pl->ob->x; |
265 | int mapx = pl->socket.mapx / 2 - pl->ob->x; |
274 | int mapy = pl->socket.mapy / 2 - pl->ob->y; |
266 | int mapy = pl->socket.mapy / 2 - pl->ob->y; |
275 | int max_distance = 8; // limit maximum path length to something generous |
267 | int max_distance = 8; // limit maximum path length to something generous |
276 | |
268 | |
… | |
… | |
1444 | |
1436 | |
1445 | if (sl.len > (int) strlen ("map ") || ns->sent_scroll) |
1437 | if (sl.len > (int) strlen ("map ") || ns->sent_scroll) |
1446 | { |
1438 | { |
1447 | /* All of this is just accounting stuff */ |
1439 | /* All of this is just accounting stuff */ |
1448 | if (tframes > 100) |
1440 | if (tframes > 100) |
1449 | { |
|
|
1450 | tframes = tbytes = 0; |
1441 | tframes = tbytes = 0; |
1451 | } |
1442 | |
1452 | tframes++; |
1443 | tframes++; |
1453 | frames++; |
1444 | frames++; |
1454 | tbytes += sl.len; |
1445 | tbytes += sl.len; |
1455 | bytes += sl.len; |
1446 | bytes += sl.len; |
1456 | memcpy (&ns->lastmap, newmap, sizeof (struct Map)); |
1447 | memcpy (&ns->lastmap, newmap, sizeof (struct Map)); |
1457 | Send_With_Handling (ns, &sl); |
1448 | Send_With_Handling (ns, &sl); |
1458 | ns->sent_scroll = 0; |
1449 | ns->sent_scroll = 0; |
1459 | } |
1450 | } |
|
|
1451 | |
1460 | free (sl.buf); |
1452 | free (sl.buf); |
1461 | } |
1453 | } |
1462 | |
1454 | |
1463 | |
1455 | |
1464 | /** Clears a map cell */ |
1456 | /** Clears a map cell */ |
… | |
… | |
1549 | * the case, it seems to make more sense to have these layer values |
1541 | * the case, it seems to make more sense to have these layer values |
1550 | * actually match. |
1542 | * actually match. |
1551 | */ |
1543 | */ |
1552 | |
1544 | |
1553 | static int |
1545 | static int |
1554 | update_space (SockList * sl, NewSocket * ns, mapstruct *mp, int mx, int my, int sx, int sy, int layer) |
1546 | update_space (SockList * sl, NewSocket * ns, maptile *mp, int mx, int my, int sx, int sy, int layer) |
1555 | { |
1547 | { |
1556 | object *ob, *head; |
1548 | object *ob, *head; |
1557 | uint16 face_num; |
1549 | uint16 face_num; |
1558 | int bx, by, i; |
1550 | int bx, by, i; |
1559 | |
1551 | |
… | |
… | |
1773 | * top layer (this matches what the GET_MAP_FACE and GET_MAP_FACE_OBJ |
1765 | * top layer (this matches what the GET_MAP_FACE and GET_MAP_FACE_OBJ |
1774 | * take. |
1766 | * take. |
1775 | */ |
1767 | */ |
1776 | |
1768 | |
1777 | static inline int |
1769 | static inline int |
1778 | update_smooth (SockList * sl, NewSocket * ns, mapstruct *mp, int mx, int my, int sx, int sy, int layer) |
1770 | update_smooth (SockList * sl, NewSocket * ns, maptile *mp, int mx, int my, int sx, int sy, int layer) |
1779 | { |
1771 | { |
1780 | object *ob; |
1772 | object *ob; |
1781 | int smoothlevel; /* old face_num; */ |
1773 | int smoothlevel; /* old face_num; */ |
1782 | |
1774 | |
1783 | ob = GET_MAP_FACE_OBJ (mp, mx, my, layer); |
1775 | ob = GET_MAP_FACE_OBJ (mp, mx, my, layer); |
… | |
… | |
1861 | SockList esl; /*For extended Map info */ |
1853 | SockList esl; /*For extended Map info */ |
1862 | uint16 mask, emask; |
1854 | uint16 mask, emask; |
1863 | uint8 eentrysize; |
1855 | uint8 eentrysize; |
1864 | uint16 ewhatstart, ewhatflag; |
1856 | uint16 ewhatstart, ewhatflag; |
1865 | uint8 extendedinfos; |
1857 | uint8 extendedinfos; |
1866 | mapstruct *m; |
1858 | maptile *m; |
1867 | |
1859 | |
1868 | NewSocket & socket = pl->contr->socket; |
1860 | NewSocket & socket = pl->contr->socket; |
1869 | |
1861 | |
1870 | check_map_change (pl->contr); |
1862 | check_map_change (pl->contr); |
1871 | |
1863 | |
… | |
… | |
2134 | SockList_AddChar (&sl, 6); |
2126 | SockList_AddChar (&sl, 6); |
2135 | SockList_AddChar (&sl, stat_width); |
2127 | SockList_AddChar (&sl, stat_width); |
2136 | } |
2128 | } |
2137 | } |
2129 | } |
2138 | |
2130 | |
2139 | if (lastcell.player !=player) |
2131 | if (lastcell.player != player) |
2140 | { |
2132 | { |
2141 | lastcell.player = player; |
2133 | lastcell.player = player; |
2142 | |
2134 | |
2143 | mask |= 0x8; |
2135 | mask |= 0x8; |
2144 | *last_ext |= 0x80; |
2136 | *last_ext |= 0x80; |
… | |
… | |
2221 | * it doesn't need draw! |
2213 | * it doesn't need draw! |
2222 | */ |
2214 | */ |
2223 | ewhatflag &= (~EMI_NOREDRAW); |
2215 | ewhatflag &= (~EMI_NOREDRAW); |
2224 | esl.buf[ewhatstart + 1] = ewhatflag & 0xff; |
2216 | esl.buf[ewhatstart + 1] = ewhatflag & 0xff; |
2225 | } |
2217 | } |
|
|
2218 | |
2226 | if (esl.len > estartlen) |
2219 | if (esl.len > estartlen) |
2227 | { |
|
|
2228 | Send_With_Handling (&socket, &esl); |
2220 | Send_With_Handling (&socket, &esl); |
2229 | } |
2221 | |
2230 | free (esl.buf); |
2222 | free (esl.buf); |
2231 | } |
2223 | } |
|
|
2224 | |
2232 | if (sl.len > startlen || socket.sent_scroll) |
2225 | if (sl.len > startlen || socket.sent_scroll) |
2233 | { |
2226 | { |
2234 | Send_With_Handling (&socket, &sl); |
2227 | Send_With_Handling (&socket, &sl); |
2235 | socket.sent_scroll = 0; |
2228 | socket.sent_scroll = 0; |
2236 | } |
2229 | } |
|
|
2230 | |
2237 | free (sl.buf); |
2231 | free (sl.buf); |
2238 | } |
2232 | } |
2239 | |
2233 | |
2240 | /** |
2234 | /** |
2241 | * Draws client map. |
2235 | * Draws client map. |
… | |
… | |
2247 | sint16 ax, ay, nx, ny; /* ax and ay goes from 0 to max-size of arrays */ |
2241 | sint16 ax, ay, nx, ny; /* ax and ay goes from 0 to max-size of arrays */ |
2248 | New_Face *face, *floor; |
2242 | New_Face *face, *floor; |
2249 | New_Face *floor2; |
2243 | New_Face *floor2; |
2250 | int d, mflags; |
2244 | int d, mflags; |
2251 | struct Map newmap; |
2245 | struct Map newmap; |
2252 | mapstruct *m, *pm; |
2246 | maptile *m, *pm; |
2253 | |
2247 | |
2254 | if (pl->type != PLAYER) |
2248 | if (pl->type != PLAYER) |
2255 | { |
2249 | { |
2256 | LOG (llevError, "draw_client_map called with non player/non eric-server\n"); |
2250 | LOG (llevError, "draw_client_map called with non player/non eric-server\n"); |
2257 | return; |
2251 | return; |