--- deliantra/server/socket/request.C 2006/08/18 02:06:58 1.3 +++ deliantra/server/socket/request.C 2006/08/24 17:29:30 1.9 @@ -1,6 +1,6 @@ /* * static char *rcsid_init_c = - * "$Id: request.C,v 1.3 2006/08/18 02:06:58 root Exp $"; + * "$Id: request.C,v 1.9 2006/08/24 17:29:30 root Exp $"; */ /* @@ -165,6 +165,20 @@ ns->sent_scroll = 1; } +static void +clear_map (player *pl) +{ + NewSocket &socket = pl->socket; + + memset (&socket.lastmap, 0, sizeof (socket.lastmap)); + + if (socket.newmapcmd == 1) + Write_String_To_Socket (&socket, "newmap", 6); + + socket.update_look = 1; + socket.look_position = 0; +} + /** check for map change and send new map data */ static void check_map_change (player *pl) @@ -176,13 +190,8 @@ if (socket.current_map != ob->map) { socket.current_map = ob->map; - memset (&socket.lastmap, 0, sizeof(socket.lastmap)); - - if (socket.newmapcmd == 1) - Write_String_To_Socket (&socket, "newmap", 6); - socket.update_look = 1; - socket.look_position =0; + clear_map (pl); if (socket.mapinfocmd) { @@ -207,9 +216,17 @@ } else if (socket.current_x != ob->x || socket.current_y != ob->y) { - socket_map_scroll (&socket, ob->x - socket.current_x, ob->y - socket.current_y); - socket.update_look = 1; - socket.look_position = 0; + int dx = ob->x - socket.current_x; + int dy = ob->y - socket.current_y; + + if (socket.buggy_mapscroll && (abs (dx) > 8 || abs (dy) > 8)) + clear_map (pl); // current (<= 1.9.1) clients have unchecked buffer overflows + else + { + socket_map_scroll (&socket, ob->x - socket.current_x, ob->y - socket.current_y); + socket.update_look = 1; + socket.look_position = 0; + } } socket.current_x = ob->x; @@ -825,6 +842,8 @@ if (cp) { LOG(llevDebug,"CS: connection from client of type <%s>, ip %s\n", cp, ns->host); + snprintf (ns->client, sizeof (ns->client), "%s", cp + 1); + /* This is first implementation - i skip all beta DX clients with it * Add later stuff here for other clients */ @@ -1274,7 +1293,8 @@ cell->faces[1] = face1; cell->faces[2] = face2; cell->count = count; - cell->stat_hp = 255; + cell->stat_hp = 0; + cell->player = 0; } #define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y) @@ -1830,22 +1850,54 @@ if (socket.extmap) { - uint8 stat_hp = 0; + uint8 stat_hp = 0; + uint8 stat_width = 0; + tag_t player = 0; // send hp information, if applicable if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0)) - if (op->stats.maxhp > 0 - && (unsigned)op->stats.maxhp + 1 > (unsigned)op->stats.hp - && IS_LIVE (op)) - stat_hp = 255 - op->stats.hp * 255 / op->stats.maxhp; + { + if (op->head || op->invisible) + ; // do not show + else if (op->type == PLAYER + || QUERY_FLAG (op, FLAG_MONSTER) + || QUERY_FLAG (op, FLAG_ALIVE) + || QUERY_FLAG (op, FLAG_GENERATOR)) + { + if (op->stats.maxhp > 0 + && (unsigned)op->stats.maxhp > (unsigned)op->stats.hp) + { + stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; + stat_width = op->arch->tail_x; + } + } + + if (op->type == PLAYER && op != pl) + player = op->count; + } - if (lastcell.stat_hp != stat_hp) + if (lastcell.stat_hp != stat_hp && 0) { lastcell.stat_hp = stat_hp; mask |= 0x8; *last_ext |= 0x80; last_ext = sl.buf + sl.len; SockList_AddChar (&sl, 5); SockList_AddChar (&sl, stat_hp); + + if (stat_width > 1) + { + *last_ext |= 0x80; last_ext = sl.buf + sl.len; SockList_AddChar (&sl, 6); + SockList_AddChar (&sl, stat_width); + } + } + + if (lastcell.player != player && 0) + { + lastcell.player = player; + mask |= 0x8; + *last_ext |= 0x80; last_ext = sl.buf + sl.len; SockList_AddChar (&sl, 0x47); + SockList_AddChar (&sl, 4); + SockList_AddInt (&sl, player); } }