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

Comparing deliantra/server/socket/request.C (file contents):
Revision 1.61 by root, Mon Jan 8 18:18:36 2007 UTC vs.
Revision 1.66 by root, Thu Feb 15 04:04:23 2007 UTC

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) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 Copyright (C) 2001 Mark Wedel 5 * Copyright (C) 2001 Mark Wedel
6 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 7 *
8 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
9 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
10 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 * (at your option) any later version.
12 12 *
13 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 * GNU General Public License for more details.
17 17 *
18 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 21 *
22 The author can be reached via e-mail to <crossfire@schmorp.de> 22 * The author can be reached via e-mail to <crossfire@schmorp.de>
23*/ 23 */
24 24
25/** 25/**
26 * \file 26 * \file
27 * Client handling. 27 * Client handling.
28 * 28 *
147 pl->ns->send_packet ("newmap"); 147 pl->ns->send_packet ("newmap");
148 148
149 pl->ns->floorbox_reset (); 149 pl->ns->floorbox_reset ();
150} 150}
151 151
152/** check for map change and send new map data */ 152/** check for map/region change and send new map data */
153static void 153static void
154check_map_change (player *pl) 154check_map_change (player *pl)
155{ 155{
156 client &socket = *pl->ns; 156 client &socket = *pl->ns;
157 object *ob = pl->ob; 157 object *ob = pl->ob;
201 } 201 }
202 } 202 }
203 203
204 socket.current_x = ob->x; 204 socket.current_x = ob->x;
205 socket.current_y = ob->y; 205 socket.current_y = ob->y;
206
207 region *reg = ob->region ();
208 if (socket.current_region != reg)
209 {
210 socket.current_region = reg;
211 socket.send_packet_printf ("drawinfo 0 You are now %s.\n(use whereami for more details)", &reg->longname);
212 }
206} 213}
207 214
208/** 215/**
209 * RequestInfo is sort of a meta command. There is some specific 216 * RequestInfo is sort of a meta command. There is some specific
210 * request of information, but we call other functions to provide 217 * request of information, but we call other functions to provide
798 * commands. 805 * commands.
799 */ 806 */
800 pl->count = 0; 807 pl->count = 0;
801 808
802 //TODO: schmorp thinks whatever this calculates, it makes no sense at all 809 //TODO: schmorp thinks whatever this calculates, it makes no sense at all
803 int time = FABS (pl->ob->speed) < 0.001 810 int time = fabs (pl->ob->speed) < 0.001
804 ? time = MAX_TIME * 100 811 ? time = MAX_TIME * 100
805 : time = (int) (MAX_TIME / FABS (pl->ob->speed)); 812 : time = (int) (MAX_TIME / fabs (pl->ob->speed));
806 813
807 /* Send confirmation of command execution now */ 814 /* Send confirmation of command execution now */
808 packet sl ("comc"); 815 packet sl ("comc");
809 sl << uint16 (cmdid) << uint32 (time); 816 sl << uint16 (cmdid) << uint32 (time);
810 pl->ns->send_packet (sl); 817 pl->ns->send_packet (sl);
1552 } 1559 }
1553 1560
1554 return result; 1561 return result;
1555} 1562}
1556 1563
1564// prefetch (and touch) all maps within a specific distancd
1565static void
1566prefetch_surrounding_maps (maptile *map, int distance)
1567{
1568 map->last_access = runtime;
1569
1570 if (--distance)
1571 for (int dir = 4; --dir; )
1572 if (const shstr &path = map->tile_path [dir])
1573 if (maptile *&neigh = map->tile_map [dir])
1574 prefetch_surrounding_maps (neigh, distance);
1575 else
1576 neigh = maptile::find_async (path, map);
1577}
1578
1579// prefetch a generous area around the player
1580static void
1581prefetch_surrounding_maps (object *op)
1582{
1583 prefetch_surrounding_maps (op->map, 3);
1584}
1585
1557/** 1586/**
1558 * This function uses the new map1 protocol command to send the map 1587 * This function uses the new map1 protocol command to send the map
1559 * to the client. It is necessary because the old map command supports 1588 * to the client. It is necessary because the old map command supports
1560 * a maximum map size of 15x15. 1589 * a maximum map size of 15x15.
1561 * This function is much simpler than the old one. This is because 1590 * This function is much simpler than the old one. This is because
1592 1621
1593 if (!pl->active) 1622 if (!pl->active)
1594 return; 1623 return;
1595 1624
1596 check_map_change (pl->contr); 1625 check_map_change (pl->contr);
1626 prefetch_surrounding_maps (pl);
1597 1627
1598 packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a"); 1628 packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a");
1599 packet esl; 1629 packet esl;
1600 1630
1601 startlen = sl.length (); 1631 startlen = sl.length ();
1969void 1999void
1970draw_client_map (object *pl) 2000draw_client_map (object *pl)
1971{ 2001{
1972 int i, j; 2002 int i, j;
1973 sint16 ax, ay, nx, ny; /* ax and ay goes from 0 to max-size of arrays */ 2003 sint16 ax, ay, nx, ny; /* ax and ay goes from 0 to max-size of arrays */
1974 New_Face *face, *floor; 2004 facetile *face, *floor;
1975 New_Face *floor2; 2005 facetile *floor2;
1976 int d, mflags; 2006 int d, mflags;
1977 struct Map newmap; 2007 struct Map newmap;
1978 maptile *m, *pm; 2008 maptile *m, *pm;
1979 2009
1980 if (pl->type != PLAYER) 2010 if (pl->type != PLAYER)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines