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.183 by root, Sat May 7 20:03:28 2011 UTC vs.
Revision 1.185 by root, Sun May 8 12:40:42 2011 UTC

163 if (ob->map && ob->map->path) 163 if (ob->map && ob->map->path)
164 { 164 {
165 int flags = 0; 165 int flags = 0;
166 166
167 // due to historical glitches, the bit ordering and map index ordering differs 167 // due to historical glitches, the bit ordering and map index ordering differs
168 if (ob->map->tile_path[TILE_NORTH]) flags |= 0x01; 168 if (ob->map->tile_path [TILE_NORTH]) flags |= 0x01;
169 if (ob->map->tile_path[TILE_EAST ]) flags |= 0x02; 169 if (ob->map->tile_path [TILE_EAST ]) flags |= 0x02;
170 if (ob->map->tile_path[TILE_SOUTH]) flags |= 0x04; 170 if (ob->map->tile_path [TILE_SOUTH]) flags |= 0x04;
171 if (ob->map->tile_path[TILE_WEST ]) flags |= 0x08; 171 if (ob->map->tile_path [TILE_WEST ]) flags |= 0x08;
172 // these two are debatable 172 // these two are debatable
173 if (ob->map->tile_path[TILE_UP ]) flags |= 0x10; 173 if (ob->map->tile_path [TILE_UP ]) flags |= 0x10;
174 if (ob->map->tile_path[TILE_DOWN ]) flags |= 0x20; 174 if (ob->map->tile_path [TILE_DOWN ]) flags |= 0x20;
175 175
176 socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s", 176 socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s",
177 flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, 177 flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y,
178 ob->map->width, ob->map->height, &ob->map->path); 178 ob->map->width, ob->map->height, &ob->map->path);
179 } 179 }
349 349
350 // due to historical glitches, the mapinfo index and tile index differs 350 // due to historical glitches, the mapinfo index and tile index differs
351 static unsigned char dirmap [] = { TILE_NORTH, TILE_EAST, TILE_SOUTH, TILE_WEST, TILE_UP, TILE_DOWN }; 351 static unsigned char dirmap [] = { TILE_NORTH, TILE_EAST, TILE_SOUTH, TILE_WEST, TILE_UP, TILE_DOWN };
352 352
353 // maybe we should only allow the four flat directions 353 // maybe we should only allow the four flat directions
354 if (dir >= 0 && dir < array_length (dirmap)) 354 if (IN_RANGE_EXC (dir, 0, array_length (dirmap)))
355 { 355 {
356 dir = dirmap [dir]; 356 dir = dirmap [dir];
357 357
358 if (!map->tile_path [dir]) 358 if (!map->tile_path [dir])
359 map = 0; 359 map = 0;
386 else 386 else
387 { 387 {
388 int flags = 0; 388 int flags = 0;
389 389
390 // due to historical glitches, the bit ordering and map index ordering differs 390 // due to historical glitches, the bit ordering and map index ordering differs
391 if (map->tile_path[TILE_NORTH]) flags |= 0x01; 391 if (map->tile_path [TILE_NORTH]) flags |= 0x01;
392 if (map->tile_path[TILE_EAST ]) flags |= 0x02; 392 if (map->tile_path [TILE_EAST ]) flags |= 0x02;
393 if (map->tile_path[TILE_SOUTH]) flags |= 0x04; 393 if (map->tile_path [TILE_SOUTH]) flags |= 0x04;
394 if (map->tile_path[TILE_WEST ]) flags |= 0x08; 394 if (map->tile_path [TILE_WEST ]) flags |= 0x08;
395 // these two are debatable 395 // these two are debatable
396 if (map->tile_path[TILE_UP ]) flags |= 0x10; 396 if (map->tile_path [TILE_UP ]) flags |= 0x10;
397 if (map->tile_path[TILE_DOWN ]) flags |= 0x20; 397 if (map->tile_path [TILE_DOWN ]) flags |= 0x20;
398 398
399 send_packet_printf ("mapinfo %s spatial %d %d %d %d %d %s", token, flags, mapx, mapy, map->width, map->height, &map->path); 399 send_packet_printf ("mapinfo %s spatial %d %d %d %d %d %s", token, flags, mapx, mapy, map->width, map->height, &map->path);
400 } 400 }
401 401
402 return 1; 402 return 1;
886 } 886 }
887 887
888 /* Nothing changed */ 888 /* Nothing changed */
889 return 0; 889 return 0;
890} 890}
891
892//-GPL
893
894// prefetch some flat area around the player
895static void
896prefetch_surrounding_area (object *op, maptile *map, int range)
897{
898 for (maprect *rect = map->split_to_tiles (mapwalk_buf,
899 op->x - range , op->y - range ,
900 op->x + range + 1, op->y + range + 1);
901 rect->m;
902 ++rect)
903 {
904 rect->m->touch ();
905 rect->m->activate ();
906 }
907}
908
909// prefetch a generous area around the player, also up and down
910void
911object::prefetch_surrounding_maps ()
912{
913 prefetch_surrounding_area (this, map, 40);
914
915 if (maptile *m = map->tile_available (TILE_DOWN))
916 prefetch_surrounding_area (this, m, 20);
917
918 if (maptile *m = map->tile_available (TILE_UP))
919 prefetch_surrounding_area (this, m, 20);
920}
921
922//+GPL
923 891
924/** 892/**
925 * Draws client map. 893 * Draws client map.
926 */ 894 */
927void 895void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines