--- deliantra/server/socket/request.C 2008/04/22 07:01:47 1.126 +++ deliantra/server/socket/request.C 2008/05/20 13:25:55 1.131 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2001,2007 Mark Wedel * Copyright (©) 1992,2007 Frank Tore Johansen * @@ -143,6 +143,32 @@ pl->ns->floorbox_reset (); } +static void +send_map_info (player *pl) +{ + client &socket = *pl->ns; + object *ob = pl->observe; + + if (socket.mapinfocmd) + { + if (ob->map && ob->map->path[0]) + { + int flags = 0; + + if (ob->map->tile_path[0]) flags |= 1; + if (ob->map->tile_path[1]) flags |= 2; + if (ob->map->tile_path[2]) flags |= 4; + if (ob->map->tile_path[3]) flags |= 8; + + socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s", + flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, + ob->map->width, ob->map->height, &ob->map->path); + } + else + socket.send_packet ("mapinfo current"); + } +} + /** check for map/region change and send new map data */ static void check_map_change (player *pl) @@ -150,30 +176,39 @@ client &socket = *pl->ns; object *ob = pl->observe; - if (socket.current_map != ob->map || socket.force_newmap) + region *reg = ob->region (); + if (socket.current_region != reg) { - clear_map (pl); - socket.current_map = ob->map; + INVOKE_PLAYER (REGION_CHANGE, pl, ARG_REGION (reg), ARG_REGION (socket.current_region)); + socket.current_region = reg; + } + + // first try to aovid a full newmap on tiled map scrolls + if (socket.current_map != ob->map && !socket.force_newmap) + { + rv_vector rv; - if (socket.mapinfocmd) + get_rangevector_from_mapcoord (socket.current_map, socket.current_x, socket.current_y, ob, &rv, 0); + + // manhattan distance is very handy here + if (rv.distance < 8) // 8 works nicely for speed << 70 and buggy gcfclient { - if (ob->map && ob->map->path[0]) - { - int flags = 0; + socket.current_map = ob->map; + socket.current_x = ob->x; + socket.current_y = ob->y; - if (ob->map->tile_path[0]) flags |= 1; - if (ob->map->tile_path[1]) flags |= 2; - if (ob->map->tile_path[2]) flags |= 4; - if (ob->map->tile_path[3]) flags |= 8; - - socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s", - flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, - ob->map->width, ob->map->height, &ob->map->path); - } - else - socket.send_packet ("mapinfo current"); + socket_map_scroll (&socket, rv.distance_x, rv.distance_y); + socket.floorbox_reset (); + send_map_info (pl); } } + + if (socket.current_map != ob->map || socket.force_newmap) + { + clear_map (pl); + socket.current_map = ob->map; + send_map_info (pl); + } else if (socket.current_x != ob->x || socket.current_y != ob->y) { int dx = ob->x - socket.current_x; @@ -190,13 +225,6 @@ socket.current_x = ob->x; socket.current_y = ob->y; - - region *reg = ob->region (); - if (socket.current_region != reg) - { - INVOKE_PLAYER (REGION_CHANGE, pl, ARG_REGION (reg), ARG_REGION (socket.current_region)); - socket.current_region = reg; - } } /** @@ -688,30 +716,15 @@ void MoveCmd (char *buf, int len, player *pl) { - int vals[3], i; + int to, tag, nrof; - /* A little funky here. We only cycle for 2 records, because - * we obviously are not going to find a space after the third - * record. Perhaps we should just replace this with a - * sscanf? - */ - for (i = 0; i < 2; i++) + if (3 != sscanf (buf, "%d %d %d", &to, &tag, &nrof)) { - vals[i] = atoi (buf); - - if (!(buf = strchr (buf, ' '))) - { - LOG (llevError, "Incomplete move command: %s\n", buf); - return; - } - - buf++; + LOG (llevError, "Incomplete move command: %s\n", buf); + return; } - vals[2] = atoi (buf); - -/* LOG(llevDebug,"Move item %d (nrof=%d) to %d.\n", vals[1], vals[2], vals[0]);*/ - esrv_move_object (pl->ob, vals[0], vals[1], vals[2]); + esrv_move_object (pl->ob, to, tag, nrof); } /****************************************************************************** @@ -899,9 +912,7 @@ << uint32 (pl->ob->face) << data8 (pl->ob->name); -#if 0 pl->ns->last_weight = weight; -#endif pl->ns->send_packet (sl); SET_FLAG (pl->ob, FLAG_CLIENT_SENT); }