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.182 by root, Thu May 5 18:59:43 2011 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001 Mark Wedel 5 * Copyright (©) 2001 Mark Wedel
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
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
346 if (dir >= 0 && dir <= 3) 349 // maybe we should only allow the four flat directions
350 if (dir >= 0 && dir < array_length (map->tile_path))
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)
896 {
892 rect->m->touch (); 897 rect->m->touch ();
898 rect->m->activate ();
899 }
900}
901
902// prefetch a generous area around the player, also up and down
903void
904object::prefetch_surrounding_maps ()
905{
906 prefetch_surrounding_area (this, map, 40);
907
908 if (maptile *m = map->tile_available (TILE_DOWN))
909 prefetch_surrounding_area (this, m, 20);
910
911 if (maptile *m = map->tile_available (TILE_UP))
912 prefetch_surrounding_area (this, m, 20);
893} 913}
894 914
895//+GPL 915//+GPL
896 916
897/** 917/**
906 926
907 /* If player is just joining the game, he isn't here yet, so the map 927 /* If player is just joining the game, he isn't here yet, so the map
908 * can get swapped out. If so, don't try to send them a map. All will 928 * can get swapped out. If so, don't try to send them a map. All will
909 * be OK once they really log in. 929 * be OK once they really log in.
910 */ 930 */
911 if (!ob->map || ob->map->in_memory != MAP_ACTIVE) 931 if (!ob->map || ob->map->state != MAP_ACTIVE)
912 return; 932 return;
913 933
914 int startlen, oldlen; 934 int startlen, oldlen;
915 935
916 check_map_change (pl); 936 check_map_change (pl);
917 prefetch_surrounding_maps (pl->ob); 937 pl->ob->prefetch_surrounding_maps ();
918 938
919 /* do LOS after calls to update_position */ 939 /* do LOS after calls to update_position */
920 /* unfortunately, we need to udpate los when observing, currently */ 940 /* unfortunately, we need to udpate los when observing, currently */
921 if (pl->do_los || pl->viewpoint != pl->ob) 941 if (pl->do_los || pl->viewpoint != pl->ob)
922 { 942 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines