--- deliantra/server/socket/request.C 2006/09/19 22:05:55 1.24 +++ deliantra/server/socket/request.C 2006/12/11 19:46:47 1.26 @@ -59,13 +59,11 @@ /* This block is basically taken from socket.c - I assume if it works there, * it should work here. */ -#ifndef WIN32 /* ---win32 exclude unix headers */ -# include -# include -# include -# include -# include -#endif /* win32 */ +#include +#include +#include +#include +#include #ifdef HAVE_UNISTD_H # include @@ -139,19 +137,13 @@ for (y = 0; y < my; y++) { if (x >= ns->mapx || y >= ns->mapy) - { - /* clear cells outside the viewable area */ - memset (&newmap.cells[x][y], 0, sizeof (struct MapCell)); - } + /* clear cells outside the viewable area */ + memset (&newmap.cells[x][y], 0, sizeof (struct MapCell)); else if ((x + dx) < 0 || (x + dx) >= ns->mapx || (y + dy) < 0 || (y + dy) >= ns->mapy) - { - /* clear newly visible tiles within the viewable area */ - memset (&(newmap.cells[x][y]), 0, sizeof (struct MapCell)); - } + /* clear newly visible tiles within the viewable area */ + memset (&(newmap.cells[x][y]), 0, sizeof (struct MapCell)); else - { - memcpy (&(newmap.cells[x][y]), &(ns->lastmap.cells[x + dx][y + dy]), sizeof (struct MapCell)); - } + memcpy (&(newmap.cells[x][y]), &(ns->lastmap.cells[x + dx][y + dy]), sizeof (struct MapCell)); } } @@ -1462,9 +1454,10 @@ cell->faces[0] = face0; cell->faces[1] = face1; cell->faces[2] = face2; - cell->count = count; - cell->stat_hp = 0; - cell->player = 0; + cell->count = count; + cell->stat_hp = 0; + cell->flags = 0; + cell->player = 0; } #define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y) @@ -1870,6 +1863,7 @@ strcpy ((char *) sl.buf, "map1a "); sl.len = strlen ((char *) sl.buf); startlen = sl.len; + /*Extendedmapinfo structure initialisation */ if (socket.ext_mapinfos) { @@ -1877,8 +1871,10 @@ strcpy ((char *) esl.buf, "mapextended "); esl.len = strlen ((char *) esl.buf); extendedinfos = EMI_NOREDRAW; + if (socket.EMI_smooth) extendedinfos |= EMI_SMOOTH; + ewhatstart = esl.len; ewhatflag = extendedinfos; /*The EMI_NOREDRAW bit could need to be taken away */ @@ -1894,6 +1890,7 @@ ewhatflag = 0; estartlen = 0; } + /* Init data to zero */ memset (heads, 0, sizeof (object *) * MAX_HEAD_POS * MAX_HEAD_POS * MAX_LAYERS); @@ -1907,6 +1904,7 @@ */ max_x = pl->x + (socket.mapx + 1) / 2; max_y = pl->y + (socket.mapy + 1) / 2; + if (socket.mapmode == Map1aCmd) { max_x += MAX_HEAD_OFFSET; @@ -1949,15 +1947,11 @@ */ got_one = 0; for (i = oldlen + 2; i < sl.len; i++) - { - if (sl.buf[i]) - got_one = 1; - } + if (sl.buf[i]) + got_one = 1; if (got_one && (mask & 0xf)) - { - sl.buf[oldlen + 1] = mask & 0xff; - } + sl.buf[oldlen + 1] = mask & 0xff; else { /*either all faces blank, either no face at all */ if (mask & 0xf) /*at least 1 face, we know it's blank, only send coordinates */ @@ -1965,13 +1959,14 @@ else sl.len = oldlen; } + /*What concerns extendinfos, nothing to be done for now * (perhaps effects layer later) */ continue; /* don't do processing below */ } - MapCell & lastcell = socket.lastmap.cells[ax][ay]; + MapCell &lastcell = socket.lastmap.cells[ax][ay]; d = pl->contr->blocked_los[ax][ay]; @@ -1981,6 +1976,7 @@ nx = x; ny = y; m = get_map_from_coord (pl->map, &nx, &ny); + if (!m) { /* space is out of map. Update space and clear values @@ -2004,8 +2000,10 @@ oldlen = sl.len; SockList_AddShort (&sl, mask); + if (lastcell.count != -1) need_send = 1; + count = -1; if (socket.mapmode == Map1aCmd && have_head (ax, ay)) @@ -2020,26 +2018,21 @@ mask |= 0x1; lastcell.count = count; - } else { - struct MapCell *cell = &lastcell; - /* properly clear a previously sent big face */ - if (cell->faces[0] != 0 || cell->faces[1] != 0 || cell->faces[2] != 0) + if (lastcell.faces[0] != 0 || lastcell.faces[1] != 0 || lastcell.faces[2] != 0 + || lastcell.stat_hp || lastcell.flags || lastcell.player) need_send = 1; + map_clearcell (&lastcell, 0, 0, 0, count); } if ((mask & 0xf) || need_send) - { - sl.buf[oldlen + 1] = mask & 0xff; - } + sl.buf[oldlen + 1] = mask & 0xff; else - { - sl.len = oldlen; - } + sl.len = oldlen; } else { @@ -2180,43 +2173,38 @@ { lastcell.faces[0] = pl->face->number; mask |= 0x1; + if (!(socket.faces_sent[pl->face->number] & NS_FACESENT_FACE)) esrv_send_face (&socket, pl->face->number, 0); + SockList_AddShort (&sl, pl->face->number); } } - /* Top face */ else { + /* Top face */ if (update_space (&sl, &socket, m, nx, ny, ax, ay, 0)) mask |= 0x1; + if (socket.EMI_smooth) if (update_smooth (&esl, &socket, m, nx, ny, ax, ay, 0)) - { - emask |= 0x1; - } + emask |= 0x1; } + /* Check to see if we are in fact sending anything for this * space by checking the mask. If so, update the mask. * if not, reset the len to that from before adding the mask * value, so we don't send those bits. */ if (mask & 0xf) - { - sl.buf[oldlen + 1] = mask & 0xff; - } + sl.buf[oldlen + 1] = mask & 0xff; else - { - sl.len = oldlen; - } + sl.len = oldlen; + if (emask & 0xf) - { - esl.buf[eoldlen + 1] = emask & 0xff; - } + esl.buf[eoldlen + 1] = emask & 0xff; else - { - esl.len = eoldlen; - } + esl.len = eoldlen; } /* else this is a viewable space */ } /* for x loop */ } /* for y loop */