--- deliantra/server/socket/request.C 2008/05/06 19:37:01 1.129 +++ deliantra/server/socket/request.C 2008/07/13 11:57:25 1.133 @@ -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; + } - if (socket.mapinfocmd) + // first try to aovid a full newmap on tiled map scrolls + if (socket.current_map != ob->map && !socket.force_newmap) + { + rv_vector rv; + + 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; - } } /** @@ -1151,7 +1179,6 @@ if (d > 3) { - int need_send = 0, count; /* This block deals with spaces that are not visible for whatever @@ -1167,11 +1194,11 @@ count = -1; - /* properly clear a previously sent big face */ if (lastcell.faces[0] || lastcell.faces[1] || lastcell.faces[2] || lastcell.stat_hp || lastcell.flags || lastcell.player) need_send = 1; + /* properly clear a previously sent big face */ map_clearcell (&lastcell, count); if ((mask & 0xf) || need_send) @@ -1246,7 +1273,7 @@ if (op->msg && op->msg[0] == '@') flags |= 1; - if (op->type == PLAYER && op != ob) + if (op->type == PLAYER) player = op->count; } @@ -1461,21 +1488,21 @@ int flags = 0; /* check if we need to update it */ - if (spell->last_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) + if (spell->cached_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) { - spell->last_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); + spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); flags |= UPD_SP_MANA; } - if (spell->last_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) + if (spell->cached_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) { - spell->last_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); + spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); flags |= UPD_SP_GRACE; } - if (spell->last_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) + if (spell->cached_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) { - spell->last_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); + spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); flags |= UPD_SP_DAMAGE; } @@ -1487,9 +1514,9 @@ << uint8 (flags) << uint32 (spell->count); - if (flags & UPD_SP_MANA ) sl << uint16 (spell->last_sp); - if (flags & UPD_SP_GRACE ) sl << uint16 (spell->last_grace); - if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->last_eat); + if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp); + if (flags & UPD_SP_GRACE ) sl << uint16 (spell->cached_grace); + if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->cached_eat); pl->ns->send_packet (sl); } @@ -1529,9 +1556,9 @@ } /* store costs and damage in the object struct, to compare to later */ - spell->last_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); - spell->last_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); - spell->last_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); + spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); + spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); + spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); /* figure out which skill it uses, if it uses one */ if (spell->skill) @@ -1557,9 +1584,9 @@ sl << uint32 (spell->count) << uint16 (spell->level) << uint16 (spell->casting_time) - << uint16 (spell->last_sp) - << uint16 (spell->last_grace) - << uint16 (spell->last_eat) + << uint16 (spell->cached_sp) + << uint16 (spell->cached_grace) + << uint16 (spell->cached_eat) << uint8 (skill) << uint32 (spell->path_attuned) << uint32 (spell->face)