--- deliantra/server/socket/request.C 2006/09/16 22:24:13 1.21 +++ 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)); } } @@ -1133,6 +1125,7 @@ AddIfShort (pl->last_stats.Con, pl->ob->stats.Con, CS_STAT_CON); AddIfShort (pl->last_stats.Cha, pl->ob->stats.Cha, CS_STAT_CHA); } + if (pl->socket.exp64) { uint8 s; @@ -1152,14 +1145,12 @@ } } } + if (pl->socket.exp64) - { - AddIfInt64 (pl->last_stats.exp, pl->ob->stats.exp, CS_STAT_EXP64); - } + { AddIfInt64 (pl->last_stats.exp, pl->ob->stats.exp, CS_STAT_EXP64) } else - { - AddIfInt (pl->last_stats.exp, (int) pl->ob->stats.exp, CS_STAT_EXP); - } + { AddIfInt (pl->last_stats.exp, (int) pl->ob->stats.exp, CS_STAT_EXP) } + AddIfShort (pl->last_level, (char) pl->ob->level, CS_STAT_LEVEL); AddIfShort (pl->last_stats.wc, pl->ob->stats.wc, CS_STAT_WC); AddIfShort (pl->last_stats.ac, pl->ob->stats.ac, CS_STAT_AC); @@ -1169,16 +1160,17 @@ AddIfFloat (pl->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP); AddIfInt (pl->last_weight_limit, (sint32) weight_limit[pl->ob->stats.Str], CS_STAT_WEIGHT_LIM); flags = 0; + if (pl->fire_on) flags |= SF_FIREON; + if (pl->run_on) flags |= SF_RUNON; AddIfShort (pl->last_flags, flags, CS_STAT_FLAGS); + if (pl->socket.sc_version < 1025) - { - AddIfShort (pl->last_resist[ATNR_PHYSICAL], pl->ob->resist[ATNR_PHYSICAL], CS_STAT_ARMOUR); - } + { AddIfShort (pl->last_resist[ATNR_PHYSICAL], pl->ob->resist[ATNR_PHYSICAL], CS_STAT_ARMOUR) } else { int i; @@ -1188,15 +1180,18 @@ /* Skip ones we won't send */ if (atnr_cs_stat[i] == -1) continue; + AddIfShort (pl->last_resist[i], pl->ob->resist[i], (char) atnr_cs_stat[i]); } } + if (pl->socket.monitor_spells) { AddIfInt (pl->last_path_attuned, pl->ob->path_attuned, CS_STAT_SPELL_ATTUNE); AddIfInt (pl->last_path_repelled, pl->ob->path_repelled, CS_STAT_SPELL_REPEL); AddIfInt (pl->last_path_denied, pl->ob->path_denied, CS_STAT_SPELL_DENY); } + rangetostring (pl->ob, buf); /* we want use the new fire & run system in new client */ AddIfString (pl->socket.stats.range, buf, CS_STAT_RANGE); set_title (pl->ob, buf); @@ -1210,10 +1205,10 @@ #endif Send_With_Handling (&pl->socket, &sl); } + free (sl.buf); } - /** * Tells the client that here is a player it should start using. */ @@ -1241,7 +1236,6 @@ SET_FLAG (pl->ob, FLAG_CLIENT_SENT); } - /** * Need to send an animation sequence to the client. * We will send appropriate face commands to the client if we haven't @@ -1460,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) @@ -1868,6 +1863,7 @@ strcpy ((char *) sl.buf, "map1a "); sl.len = strlen ((char *) sl.buf); startlen = sl.len; + /*Extendedmapinfo structure initialisation */ if (socket.ext_mapinfos) { @@ -1875,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 */ @@ -1892,6 +1890,7 @@ ewhatflag = 0; estartlen = 0; } + /* Init data to zero */ memset (heads, 0, sizeof (object *) * MAX_HEAD_POS * MAX_HEAD_POS * MAX_LAYERS); @@ -1905,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; @@ -1947,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 */ @@ -1963,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]; @@ -1979,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 @@ -2002,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)) @@ -2018,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 { @@ -2088,6 +2083,7 @@ { uint8 stat_hp = 0; uint8 stat_width = 0; + uint8 flags = 0; tag_t player = 0; // send hp information, if applicable @@ -2105,6 +2101,9 @@ } } + if (op->msg && op->msg[0] == '@') + flags |= 1; + if (op->type == PLAYER && op != pl) player = op->count; } @@ -2139,6 +2138,17 @@ SockList_AddChar (&sl, 4); SockList_AddInt (&sl, player); } + + if (lastcell.flags != flags) + { + lastcell.flags = flags; + + mask |= 0x8; + *last_ext |= 0x80; + last_ext = sl.buf + sl.len; + SockList_AddChar (&sl, 8); + SockList_AddChar (&sl, flags); + } } /* Floor face */ @@ -2163,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 */