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.177 by root, Sat Oct 16 22:51:52 2010 UTC vs.
Revision 1.178 by root, Fri Apr 22 06:10:34 2011 UTC

162 { 162 {
163 if (ob->map && ob->map->path[0]) 163 if (ob->map && ob->map->path[0])
164 { 164 {
165 int flags = 0; 165 int flags = 0;
166 166
167 if (ob->map->tile_path[0]) flags |= 1; 167 if (ob->map->tile_path[0]) flags |= 0x01;
168 if (ob->map->tile_path[1]) flags |= 2; 168 if (ob->map->tile_path[1]) flags |= 0x02;
169 if (ob->map->tile_path[2]) flags |= 4; 169 if (ob->map->tile_path[2]) flags |= 0x04;
170 if (ob->map->tile_path[3]) flags |= 8; 170 if (ob->map->tile_path[3]) flags |= 0x08;
171 // these two are debatable
172 if (ob->map->tile_path[4]) flags |= 0x10;
173 if (ob->map->tile_path[5]) flags |= 0x20;
171 174
172 socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s", 175 socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s",
173 flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, 176 flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y,
174 ob->map->width, ob->map->height, &ob->map->path); 177 ob->map->width, ob->map->height, &ob->map->path);
175 } 178 }
341 344
342 while (*buf && map && max_distance) 345 while (*buf && map && max_distance)
343 { 346 {
344 int dir = *buf++ - '1'; 347 int dir = *buf++ - '1';
345 348
349 // maybe we should only allow the four flat directions
346 if (dir >= 0 && dir <= 3) 350 if (dir >= 0 && dir < TILE_NUM)
347 { 351 {
348 if (!map->tile_path [dir]) 352 if (!map->tile_path [dir])
349 map = 0; 353 map = 0;
350 else if (map->tile_available (dir, false)) 354 else if (map->tile_available (dir, false))
351 { 355 {
375 send_packet_printf ("mapinfo %s nomap", token); 379 send_packet_printf ("mapinfo %s nomap", token);
376 else 380 else
377 { 381 {
378 int flags = 0; 382 int flags = 0;
379 383
380 if (map->tile_path[0]) flags |= 1; 384 if (map->tile_path[0]) flags |= 0x01;
381 if (map->tile_path[1]) flags |= 2; 385 if (map->tile_path[1]) flags |= 0x02;
382 if (map->tile_path[2]) flags |= 4; 386 if (map->tile_path[2]) flags |= 0x04;
383 if (map->tile_path[3]) flags |= 8; 387 if (map->tile_path[3]) flags |= 0x08;
388 // these two are debatable
389 if (map->tile_path[4]) flags |= 0x10;
390 if (map->tile_path[5]) flags |= 0x20;
384 391
385 send_packet_printf ("mapinfo %s spatial %d %d %d %d %d %s", token, flags, mapx, mapy, map->width, map->height, &map->path); 392 send_packet_printf ("mapinfo %s spatial %d %d %d %d %d %s", token, flags, mapx, mapy, map->width, map->height, &map->path);
386 } 393 }
387 394
388 return 1; 395 return 1;
875 return 0; 882 return 0;
876} 883}
877 884
878//-GPL 885//-GPL
879 886
880// prefetch maps in an area of PREFETCH x PREFETCH around the player
881#define PREFETCH 40
882
883// prefetch a generous area around the player 887// prefetch some flat area around the player
884static void 888static void
885prefetch_surrounding_maps (object *op) 889prefetch_surrounding_area (object *op, maptile *map, int range)
886{ 890{
887 for (maprect *rect = op->map->split_to_tiles (mapwalk_buf, 891 for (maprect *rect = map->split_to_tiles (mapwalk_buf,
888 op->x - PREFETCH , op->y - PREFETCH , 892 op->x - range , op->y - range ,
889 op->x + PREFETCH + 1, op->y + PREFETCH + 1); 893 op->x + range + 1, op->y + range + 1);
890 rect->m; 894 rect->m;
891 ++rect) 895 ++rect)
892 rect->m->touch (); 896 rect->m->touch ();
897}
898
899// prefetch a generous area around the player, also up and down
900static void
901prefetch_surrounding_maps (object *op)
902{
903 prefetch_surrounding_area (op, op->map, 40);
904
905 if (maptile *m = op->map->tile_available (TILE_DOWN))
906 prefetch_surrounding_area (op, m, 20);
907
908 if (maptile *m = op->map->tile_available (TILE_UP))
909 prefetch_surrounding_area (op, m, 20);
893} 910}
894 911
895//+GPL 912//+GPL
896 913
897/** 914/**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines