ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/request.C
(Generate patch)

Comparing deliantra/server/socket/request.C (file contents):
Revision 1.18 by root, Thu Sep 14 19:08:41 2006 UTC vs.
Revision 1.25 by root, Thu Sep 21 14:51:16 2006 UTC

1
2/*
3 * static char *rcsid_init_c =
4 * "$Id: request.C,v 1.18 2006/09/14 19:08:41 root Exp $";
5 */
6
7/* 1/*
8 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
9 3
10 Copyright (C) 2001 Mark Wedel 4 Copyright (C) 2001 Mark Wedel
11 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
22 16
23 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 20
27 The author can be reached via e-mail to crossfire-devel@real-time.com 21 The author can be reached via e-mail to <crossfire@schmorp.de>
28*/ 22*/
29 23
30/** 24/**
31 * \file 25 * \file
32 * Client handling. 26 * Client handling.
143 for (x = 0; x < mx; x++) 137 for (x = 0; x < mx; x++)
144 { 138 {
145 for (y = 0; y < my; y++) 139 for (y = 0; y < my; y++)
146 { 140 {
147 if (x >= ns->mapx || y >= ns->mapy) 141 if (x >= ns->mapx || y >= ns->mapy)
148 {
149 /* clear cells outside the viewable area */ 142 /* clear cells outside the viewable area */
150 memset (&newmap.cells[x][y], 0, sizeof (struct MapCell)); 143 memset (&newmap.cells[x][y], 0, sizeof (struct MapCell));
151 }
152 else if ((x + dx) < 0 || (x + dx) >= ns->mapx || (y + dy) < 0 || (y + dy) >= ns->mapy) 144 else if ((x + dx) < 0 || (x + dx) >= ns->mapx || (y + dy) < 0 || (y + dy) >= ns->mapy)
153 {
154 /* clear newly visible tiles within the viewable area */ 145 /* clear newly visible tiles within the viewable area */
155 memset (&(newmap.cells[x][y]), 0, sizeof (struct MapCell)); 146 memset (&(newmap.cells[x][y]), 0, sizeof (struct MapCell));
156 }
157 else 147 else
158 {
159 memcpy (&(newmap.cells[x][y]), &(ns->lastmap.cells[x + dx][y + dy]), sizeof (struct MapCell)); 148 memcpy (&(newmap.cells[x][y]), &(ns->lastmap.cells[x + dx][y + dy]), sizeof (struct MapCell));
160 }
161 } 149 }
162 } 150 }
163 151
164 memcpy (&(ns->lastmap), &newmap, sizeof (struct Map)); 152 memcpy (&(ns->lastmap), &newmap, sizeof (struct Map));
165 153
264 if (!strncmp (buf, "spatial ", 8)) 252 if (!strncmp (buf, "spatial ", 8))
265 { 253 {
266 buf += 8; 254 buf += 8;
267 255
268 // initial map and its origin 256 // initial map and its origin
269 mapstruct *map = pl->ob->map; 257 maptile *map = pl->ob->map;
270 sint16 dx, dy; 258 sint16 dx, dy;
271 int mapx = pl->socket.mapx / 2 - pl->ob->x; 259 int mapx = pl->socket.mapx / 2 - pl->ob->x;
272 int mapy = pl->socket.mapy / 2 - pl->ob->y; 260 int mapy = pl->socket.mapy / 2 - pl->ob->y;
273 int max_distance = 8; // limit maximum path length to something generous 261 int max_distance = 8; // limit maximum path length to something generous
274 262
1137 AddIfShort (pl->last_stats.Wis, pl->ob->stats.Wis, CS_STAT_WIS); 1125 AddIfShort (pl->last_stats.Wis, pl->ob->stats.Wis, CS_STAT_WIS);
1138 AddIfShort (pl->last_stats.Dex, pl->ob->stats.Dex, CS_STAT_DEX); 1126 AddIfShort (pl->last_stats.Dex, pl->ob->stats.Dex, CS_STAT_DEX);
1139 AddIfShort (pl->last_stats.Con, pl->ob->stats.Con, CS_STAT_CON); 1127 AddIfShort (pl->last_stats.Con, pl->ob->stats.Con, CS_STAT_CON);
1140 AddIfShort (pl->last_stats.Cha, pl->ob->stats.Cha, CS_STAT_CHA); 1128 AddIfShort (pl->last_stats.Cha, pl->ob->stats.Cha, CS_STAT_CHA);
1141 } 1129 }
1130
1142 if (pl->socket.exp64) 1131 if (pl->socket.exp64)
1143 { 1132 {
1144 uint8 s; 1133 uint8 s;
1145 1134
1146 for (s = 0; s < NUM_SKILLS; s++) 1135 for (s = 0; s < NUM_SKILLS; s++)
1156 SockList_AddInt64 (&sl, pl->last_skill_ob[s]->stats.exp); 1145 SockList_AddInt64 (&sl, pl->last_skill_ob[s]->stats.exp);
1157 pl->last_skill_exp[s] = pl->last_skill_ob[s]->stats.exp; 1146 pl->last_skill_exp[s] = pl->last_skill_ob[s]->stats.exp;
1158 } 1147 }
1159 } 1148 }
1160 } 1149 }
1150
1161 if (pl->socket.exp64) 1151 if (pl->socket.exp64)
1162 {
1163 AddIfInt64 (pl->last_stats.exp, pl->ob->stats.exp, CS_STAT_EXP64); 1152 { AddIfInt64 (pl->last_stats.exp, pl->ob->stats.exp, CS_STAT_EXP64) }
1164 }
1165 else 1153 else
1166 {
1167 AddIfInt (pl->last_stats.exp, (int) pl->ob->stats.exp, CS_STAT_EXP); 1154 { AddIfInt (pl->last_stats.exp, (int) pl->ob->stats.exp, CS_STAT_EXP) }
1168 } 1155
1169 AddIfShort (pl->last_level, (char) pl->ob->level, CS_STAT_LEVEL); 1156 AddIfShort (pl->last_level, (char) pl->ob->level, CS_STAT_LEVEL);
1170 AddIfShort (pl->last_stats.wc, pl->ob->stats.wc, CS_STAT_WC); 1157 AddIfShort (pl->last_stats.wc, pl->ob->stats.wc, CS_STAT_WC);
1171 AddIfShort (pl->last_stats.ac, pl->ob->stats.ac, CS_STAT_AC); 1158 AddIfShort (pl->last_stats.ac, pl->ob->stats.ac, CS_STAT_AC);
1172 AddIfShort (pl->last_stats.dam, pl->ob->stats.dam, CS_STAT_DAM); 1159 AddIfShort (pl->last_stats.dam, pl->ob->stats.dam, CS_STAT_DAM);
1173 AddIfFloat (pl->last_speed, pl->ob->speed, CS_STAT_SPEED); 1160 AddIfFloat (pl->last_speed, pl->ob->speed, CS_STAT_SPEED);
1174 AddIfShort (pl->last_stats.food, pl->ob->stats.food, CS_STAT_FOOD); 1161 AddIfShort (pl->last_stats.food, pl->ob->stats.food, CS_STAT_FOOD);
1175 AddIfFloat (pl->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP); 1162 AddIfFloat (pl->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP);
1176 AddIfInt (pl->last_weight_limit, (sint32) weight_limit[pl->ob->stats.Str], CS_STAT_WEIGHT_LIM); 1163 AddIfInt (pl->last_weight_limit, (sint32) weight_limit[pl->ob->stats.Str], CS_STAT_WEIGHT_LIM);
1177 flags = 0; 1164 flags = 0;
1165
1178 if (pl->fire_on) 1166 if (pl->fire_on)
1179 flags |= SF_FIREON; 1167 flags |= SF_FIREON;
1168
1180 if (pl->run_on) 1169 if (pl->run_on)
1181 flags |= SF_RUNON; 1170 flags |= SF_RUNON;
1182 1171
1183 AddIfShort (pl->last_flags, flags, CS_STAT_FLAGS); 1172 AddIfShort (pl->last_flags, flags, CS_STAT_FLAGS);
1173
1184 if (pl->socket.sc_version < 1025) 1174 if (pl->socket.sc_version < 1025)
1185 {
1186 AddIfShort (pl->last_resist[ATNR_PHYSICAL], pl->ob->resist[ATNR_PHYSICAL], CS_STAT_ARMOUR); 1175 { AddIfShort (pl->last_resist[ATNR_PHYSICAL], pl->ob->resist[ATNR_PHYSICAL], CS_STAT_ARMOUR) }
1187 }
1188 else 1176 else
1189 { 1177 {
1190 int i; 1178 int i;
1191 1179
1192 for (i = 0; i < NROFATTACKS; i++) 1180 for (i = 0; i < NROFATTACKS; i++)
1193 { 1181 {
1194 /* Skip ones we won't send */ 1182 /* Skip ones we won't send */
1195 if (atnr_cs_stat[i] == -1) 1183 if (atnr_cs_stat[i] == -1)
1196 continue; 1184 continue;
1185
1197 AddIfShort (pl->last_resist[i], pl->ob->resist[i], (char) atnr_cs_stat[i]); 1186 AddIfShort (pl->last_resist[i], pl->ob->resist[i], (char) atnr_cs_stat[i]);
1198 } 1187 }
1199 } 1188 }
1189
1200 if (pl->socket.monitor_spells) 1190 if (pl->socket.monitor_spells)
1201 { 1191 {
1202 AddIfInt (pl->last_path_attuned, pl->ob->path_attuned, CS_STAT_SPELL_ATTUNE); 1192 AddIfInt (pl->last_path_attuned, pl->ob->path_attuned, CS_STAT_SPELL_ATTUNE);
1203 AddIfInt (pl->last_path_repelled, pl->ob->path_repelled, CS_STAT_SPELL_REPEL); 1193 AddIfInt (pl->last_path_repelled, pl->ob->path_repelled, CS_STAT_SPELL_REPEL);
1204 AddIfInt (pl->last_path_denied, pl->ob->path_denied, CS_STAT_SPELL_DENY); 1194 AddIfInt (pl->last_path_denied, pl->ob->path_denied, CS_STAT_SPELL_DENY);
1205 } 1195 }
1196
1206 rangetostring (pl->ob, buf); /* we want use the new fire & run system in new client */ 1197 rangetostring (pl->ob, buf); /* we want use the new fire & run system in new client */
1207 AddIfString (pl->socket.stats.range, buf, CS_STAT_RANGE); 1198 AddIfString (pl->socket.stats.range, buf, CS_STAT_RANGE);
1208 set_title (pl->ob, buf); 1199 set_title (pl->ob, buf);
1209 AddIfString (pl->socket.stats.title, buf, CS_STAT_TITLE); 1200 AddIfString (pl->socket.stats.title, buf, CS_STAT_TITLE);
1210 1201
1214#ifdef ESRV_DEBUG 1205#ifdef ESRV_DEBUG
1215 LOG (llevDebug, "Sending stats command, %d bytes long.\n", sl.len); 1206 LOG (llevDebug, "Sending stats command, %d bytes long.\n", sl.len);
1216#endif 1207#endif
1217 Send_With_Handling (&pl->socket, &sl); 1208 Send_With_Handling (&pl->socket, &sl);
1218 } 1209 }
1210
1219 free (sl.buf); 1211 free (sl.buf);
1220} 1212}
1221
1222 1213
1223/** 1214/**
1224 * Tells the client that here is a player it should start using. 1215 * Tells the client that here is a player it should start using.
1225 */ 1216 */
1226void 1217void
1244 1235
1245 Send_With_Handling (&pl->socket, &sl); 1236 Send_With_Handling (&pl->socket, &sl);
1246 free (sl.buf); 1237 free (sl.buf);
1247 SET_FLAG (pl->ob, FLAG_CLIENT_SENT); 1238 SET_FLAG (pl->ob, FLAG_CLIENT_SENT);
1248} 1239}
1249
1250 1240
1251/** 1241/**
1252 * Need to send an animation sequence to the client. 1242 * Need to send an animation sequence to the client.
1253 * We will send appropriate face commands to the client if we haven't 1243 * We will send appropriate face commands to the client if we haven't
1254 * sent them the face yet (this can become quite costly in terms of 1244 * sent them the face yet (this can become quite costly in terms of
1464map_clearcell (struct MapCell *cell, int face0, int face1, int face2, int count) 1454map_clearcell (struct MapCell *cell, int face0, int face1, int face2, int count)
1465{ 1455{
1466 cell->faces[0] = face0; 1456 cell->faces[0] = face0;
1467 cell->faces[1] = face1; 1457 cell->faces[1] = face1;
1468 cell->faces[2] = face2; 1458 cell->faces[2] = face2;
1469 cell->count = count; 1459 cell->count = count;
1470 cell->stat_hp = 0; 1460 cell->stat_hp = 0;
1461 cell->flags = 0;
1471 cell->player = 0; 1462 cell->player = 0;
1472} 1463}
1473 1464
1474#define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y) 1465#define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y)
1475#define MAX_LAYERS 3 1466#define MAX_LAYERS 3
1476 1467
1547 * the case, it seems to make more sense to have these layer values 1538 * the case, it seems to make more sense to have these layer values
1548 * actually match. 1539 * actually match.
1549 */ 1540 */
1550 1541
1551static int 1542static int
1552update_space (SockList * sl, NewSocket * ns, mapstruct *mp, int mx, int my, int sx, int sy, int layer) 1543update_space (SockList * sl, NewSocket * ns, maptile *mp, int mx, int my, int sx, int sy, int layer)
1553{ 1544{
1554 object *ob, *head; 1545 object *ob, *head;
1555 uint16 face_num; 1546 uint16 face_num;
1556 int bx, by, i; 1547 int bx, by, i;
1557 1548
1771 * top layer (this matches what the GET_MAP_FACE and GET_MAP_FACE_OBJ 1762 * top layer (this matches what the GET_MAP_FACE and GET_MAP_FACE_OBJ
1772 * take. 1763 * take.
1773 */ 1764 */
1774 1765
1775static inline int 1766static inline int
1776update_smooth (SockList * sl, NewSocket * ns, mapstruct *mp, int mx, int my, int sx, int sy, int layer) 1767update_smooth (SockList * sl, NewSocket * ns, maptile *mp, int mx, int my, int sx, int sy, int layer)
1777{ 1768{
1778 object *ob; 1769 object *ob;
1779 int smoothlevel; /* old face_num; */ 1770 int smoothlevel; /* old face_num; */
1780 1771
1781 ob = GET_MAP_FACE_OBJ (mp, mx, my, layer); 1772 ob = GET_MAP_FACE_OBJ (mp, mx, my, layer);
1859 SockList esl; /*For extended Map info */ 1850 SockList esl; /*For extended Map info */
1860 uint16 mask, emask; 1851 uint16 mask, emask;
1861 uint8 eentrysize; 1852 uint8 eentrysize;
1862 uint16 ewhatstart, ewhatflag; 1853 uint16 ewhatstart, ewhatflag;
1863 uint8 extendedinfos; 1854 uint8 extendedinfos;
1864 mapstruct *m; 1855 maptile *m;
1865 1856
1866 NewSocket & socket = pl->contr->socket; 1857 NewSocket & socket = pl->contr->socket;
1867 1858
1868 check_map_change (pl->contr); 1859 check_map_change (pl->contr);
1869 1860
1872 strcpy ((char *) sl.buf, "map1 "); 1863 strcpy ((char *) sl.buf, "map1 ");
1873 else 1864 else
1874 strcpy ((char *) sl.buf, "map1a "); 1865 strcpy ((char *) sl.buf, "map1a ");
1875 sl.len = strlen ((char *) sl.buf); 1866 sl.len = strlen ((char *) sl.buf);
1876 startlen = sl.len; 1867 startlen = sl.len;
1868
1877 /*Extendedmapinfo structure initialisation */ 1869 /*Extendedmapinfo structure initialisation */
1878 if (socket.ext_mapinfos) 1870 if (socket.ext_mapinfos)
1879 { 1871 {
1880 esl.buf = (unsigned char *) malloc (MAXSOCKBUF); 1872 esl.buf = (unsigned char *) malloc (MAXSOCKBUF);
1881 strcpy ((char *) esl.buf, "mapextended "); 1873 strcpy ((char *) esl.buf, "mapextended ");
1882 esl.len = strlen ((char *) esl.buf); 1874 esl.len = strlen ((char *) esl.buf);
1883 extendedinfos = EMI_NOREDRAW; 1875 extendedinfos = EMI_NOREDRAW;
1876
1884 if (socket.EMI_smooth) 1877 if (socket.EMI_smooth)
1885 extendedinfos |= EMI_SMOOTH; 1878 extendedinfos |= EMI_SMOOTH;
1879
1886 ewhatstart = esl.len; 1880 ewhatstart = esl.len;
1887 ewhatflag = extendedinfos; /*The EMI_NOREDRAW bit 1881 ewhatflag = extendedinfos; /*The EMI_NOREDRAW bit
1888 could need to be taken away */ 1882 could need to be taken away */
1889 SockList_AddChar (&esl, extendedinfos); 1883 SockList_AddChar (&esl, extendedinfos);
1890 eentrysize = getExtendedMapInfoSize (&socket); 1884 eentrysize = getExtendedMapInfoSize (&socket);
1896 /* suppress compiler warnings */ 1890 /* suppress compiler warnings */
1897 ewhatstart = 0; 1891 ewhatstart = 0;
1898 ewhatflag = 0; 1892 ewhatflag = 0;
1899 estartlen = 0; 1893 estartlen = 0;
1900 } 1894 }
1895
1901 /* Init data to zero */ 1896 /* Init data to zero */
1902 memset (heads, 0, sizeof (object *) * MAX_HEAD_POS * MAX_HEAD_POS * MAX_LAYERS); 1897 memset (heads, 0, sizeof (object *) * MAX_HEAD_POS * MAX_HEAD_POS * MAX_LAYERS);
1903 1898
1904 /* x,y are the real map locations. ax, ay are viewport relative 1899 /* x,y are the real map locations. ax, ay are viewport relative
1905 * locations. 1900 * locations.
1909 /* We could do this logic as conditionals in the if statement, 1904 /* We could do this logic as conditionals in the if statement,
1910 * but that started to get a bit messy to look at. 1905 * but that started to get a bit messy to look at.
1911 */ 1906 */
1912 max_x = pl->x + (socket.mapx + 1) / 2; 1907 max_x = pl->x + (socket.mapx + 1) / 2;
1913 max_y = pl->y + (socket.mapy + 1) / 2; 1908 max_y = pl->y + (socket.mapy + 1) / 2;
1909
1914 if (socket.mapmode == Map1aCmd) 1910 if (socket.mapmode == Map1aCmd)
1915 { 1911 {
1916 max_x += MAX_HEAD_OFFSET; 1912 max_x += MAX_HEAD_OFFSET;
1917 max_y += MAX_HEAD_OFFSET; 1913 max_y += MAX_HEAD_OFFSET;
1918 } 1914 }
1951 * with no faces tells the client to blank out the 1947 * with no faces tells the client to blank out the
1952 * space. 1948 * space.
1953 */ 1949 */
1954 got_one = 0; 1950 got_one = 0;
1955 for (i = oldlen + 2; i < sl.len; i++) 1951 for (i = oldlen + 2; i < sl.len; i++)
1956 {
1957 if (sl.buf[i]) 1952 if (sl.buf[i])
1958 got_one = 1; 1953 got_one = 1;
1959 }
1960 1954
1961 if (got_one && (mask & 0xf)) 1955 if (got_one && (mask & 0xf))
1962 {
1963 sl.buf[oldlen + 1] = mask & 0xff; 1956 sl.buf[oldlen + 1] = mask & 0xff;
1964 }
1965 else 1957 else
1966 { /*either all faces blank, either no face at all */ 1958 { /*either all faces blank, either no face at all */
1967 if (mask & 0xf) /*at least 1 face, we know it's blank, only send coordinates */ 1959 if (mask & 0xf) /*at least 1 face, we know it's blank, only send coordinates */
1968 sl.len = oldlen + 2; 1960 sl.len = oldlen + 2;
1969 else 1961 else
1970 sl.len = oldlen; 1962 sl.len = oldlen;
1971 } 1963 }
1964
1972 /*What concerns extendinfos, nothing to be done for now 1965 /*What concerns extendinfos, nothing to be done for now
1973 * (perhaps effects layer later) 1966 * (perhaps effects layer later)
1974 */ 1967 */
1975 continue; /* don't do processing below */ 1968 continue; /* don't do processing below */
1976 } 1969 }
1977 1970
1978 MapCell & lastcell = socket.lastmap.cells[ax][ay]; 1971 MapCell &lastcell = socket.lastmap.cells[ax][ay];
1979 1972
1980 d = pl->contr->blocked_los[ax][ay]; 1973 d = pl->contr->blocked_los[ax][ay];
1981 1974
1982 /* If the coordinates are not valid, or it is too dark to see, 1975 /* If the coordinates are not valid, or it is too dark to see,
1983 * we tell the client as such 1976 * we tell the client as such
1984 */ 1977 */
1985 nx = x; 1978 nx = x;
1986 ny = y; 1979 ny = y;
1987 m = get_map_from_coord (pl->map, &nx, &ny); 1980 m = get_map_from_coord (pl->map, &nx, &ny);
1981
1988 if (!m) 1982 if (!m)
1989 { 1983 {
1990 /* space is out of map. Update space and clear values 1984 /* space is out of map. Update space and clear values
1991 * if this hasn't already been done. If the space is out 1985 * if this hasn't already been done. If the space is out
1992 * of the map, it shouldn't have a head 1986 * of the map, it shouldn't have a head
2006 */ 2000 */
2007 2001
2008 oldlen = sl.len; 2002 oldlen = sl.len;
2009 2003
2010 SockList_AddShort (&sl, mask); 2004 SockList_AddShort (&sl, mask);
2005
2011 if (lastcell.count != -1) 2006 if (lastcell.count != -1)
2012 need_send = 1; 2007 need_send = 1;
2008
2013 count = -1; 2009 count = -1;
2014 2010
2015 if (socket.mapmode == Map1aCmd && have_head (ax, ay)) 2011 if (socket.mapmode == Map1aCmd && have_head (ax, ay))
2016 { 2012 {
2017 /* Now check to see if any heads need to be sent */ 2013 /* Now check to see if any heads need to be sent */
2022 mask |= 0x2; 2018 mask |= 0x2;
2023 if (check_head (sl, socket, ax, ay, 0)) 2019 if (check_head (sl, socket, ax, ay, 0))
2024 mask |= 0x1; 2020 mask |= 0x1;
2025 2021
2026 lastcell.count = count; 2022 lastcell.count = count;
2027
2028 } 2023 }
2029 else 2024 else
2030 { 2025 {
2031 struct MapCell *cell = &lastcell;
2032
2033 /* properly clear a previously sent big face */ 2026 /* properly clear a previously sent big face */
2034 if (cell->faces[0] != 0 || cell->faces[1] != 0 || cell->faces[2] != 0) 2027 if (lastcell.faces[0] != 0 || lastcell.faces[1] != 0 || lastcell.faces[2] != 0
2028 || lastcell.stat_hp || lastcell.flags || lastcell.player)
2035 need_send = 1; 2029 need_send = 1;
2030
2036 map_clearcell (&lastcell, 0, 0, 0, count); 2031 map_clearcell (&lastcell, 0, 0, 0, count);
2037 } 2032 }
2038 2033
2039 if ((mask & 0xf) || need_send) 2034 if ((mask & 0xf) || need_send)
2040 {
2041 sl.buf[oldlen + 1] = mask & 0xff; 2035 sl.buf[oldlen + 1] = mask & 0xff;
2042 }
2043 else 2036 else
2044 {
2045 sl.len = oldlen; 2037 sl.len = oldlen;
2046 }
2047 } 2038 }
2048 else 2039 else
2049 { 2040 {
2050 /* In this block, the space is visible or there are head objects 2041 /* In this block, the space is visible or there are head objects
2051 * we need to send. 2042 * we need to send.
2092 2083
2093 if (socket.extmap) 2084 if (socket.extmap)
2094 { 2085 {
2095 uint8 stat_hp = 0; 2086 uint8 stat_hp = 0;
2096 uint8 stat_width = 0; 2087 uint8 stat_width = 0;
2088 uint8 flags = 0;
2097 tag_t player = 0; 2089 tag_t player = 0;
2098 2090
2099 // send hp information, if applicable 2091 // send hp information, if applicable
2100 if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0)) 2092 if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0))
2101 { 2093 {
2109 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; 2101 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp;
2110 stat_width = op->arch->tail_x; 2102 stat_width = op->arch->tail_x;
2111 } 2103 }
2112 } 2104 }
2113 2105
2106 if (op->msg && op->msg[0] == '@')
2107 flags |= 1;
2108
2114 if (op->type == PLAYER && op != pl) 2109 if (op->type == PLAYER && op != pl)
2115 player = op->count; 2110 player = op->count;
2116 } 2111 }
2117 2112
2118 if (lastcell.stat_hp != stat_hp) 2113 if (lastcell.stat_hp != stat_hp)
2132 SockList_AddChar (&sl, 6); 2127 SockList_AddChar (&sl, 6);
2133 SockList_AddChar (&sl, stat_width); 2128 SockList_AddChar (&sl, stat_width);
2134 } 2129 }
2135 } 2130 }
2136 2131
2137 if (lastcell.player !=player) 2132 if (lastcell.player != player)
2138 { 2133 {
2139 lastcell.player = player; 2134 lastcell.player = player;
2140 2135
2141 mask |= 0x8; 2136 mask |= 0x8;
2142 *last_ext |= 0x80; 2137 *last_ext |= 0x80;
2143 last_ext = sl.buf + sl.len; 2138 last_ext = sl.buf + sl.len;
2144 SockList_AddChar (&sl, 0x47); 2139 SockList_AddChar (&sl, 0x47);
2145 SockList_AddChar (&sl, 4); 2140 SockList_AddChar (&sl, 4);
2146 SockList_AddInt (&sl, player); 2141 SockList_AddInt (&sl, player);
2147 } 2142 }
2143
2144 if (lastcell.flags != flags)
2145 {
2146 lastcell.flags = flags;
2147
2148 mask |= 0x8;
2149 *last_ext |= 0x80;
2150 last_ext = sl.buf + sl.len;
2151 SockList_AddChar (&sl, 8);
2152 SockList_AddChar (&sl, flags);
2153 }
2148 } 2154 }
2149 2155
2150 /* Floor face */ 2156 /* Floor face */
2151 if (update_space (&sl, &socket, m, nx, ny, ax, ay, 2)) 2157 if (update_space (&sl, &socket, m, nx, ny, ax, ay, 2))
2152 mask |= 0x4; 2158 mask |= 0x4;
2167 { 2173 {
2168 if (lastcell.faces[0] != pl->face->number) 2174 if (lastcell.faces[0] != pl->face->number)
2169 { 2175 {
2170 lastcell.faces[0] = pl->face->number; 2176 lastcell.faces[0] = pl->face->number;
2171 mask |= 0x1; 2177 mask |= 0x1;
2178
2172 if (!(socket.faces_sent[pl->face->number] & NS_FACESENT_FACE)) 2179 if (!(socket.faces_sent[pl->face->number] & NS_FACESENT_FACE))
2173 esrv_send_face (&socket, pl->face->number, 0); 2180 esrv_send_face (&socket, pl->face->number, 0);
2181
2174 SockList_AddShort (&sl, pl->face->number); 2182 SockList_AddShort (&sl, pl->face->number);
2175 } 2183 }
2176 } 2184 }
2177 /* Top face */
2178 else 2185 else
2179 { 2186 {
2187 /* Top face */
2180 if (update_space (&sl, &socket, m, nx, ny, ax, ay, 0)) 2188 if (update_space (&sl, &socket, m, nx, ny, ax, ay, 0))
2181 mask |= 0x1; 2189 mask |= 0x1;
2190
2182 if (socket.EMI_smooth) 2191 if (socket.EMI_smooth)
2183 if (update_smooth (&esl, &socket, m, nx, ny, ax, ay, 0)) 2192 if (update_smooth (&esl, &socket, m, nx, ny, ax, ay, 0))
2184 {
2185 emask |= 0x1; 2193 emask |= 0x1;
2186 }
2187 } 2194 }
2195
2188 /* Check to see if we are in fact sending anything for this 2196 /* Check to see if we are in fact sending anything for this
2189 * space by checking the mask. If so, update the mask. 2197 * space by checking the mask. If so, update the mask.
2190 * if not, reset the len to that from before adding the mask 2198 * if not, reset the len to that from before adding the mask
2191 * value, so we don't send those bits. 2199 * value, so we don't send those bits.
2192 */ 2200 */
2193 if (mask & 0xf) 2201 if (mask & 0xf)
2194 {
2195 sl.buf[oldlen + 1] = mask & 0xff; 2202 sl.buf[oldlen + 1] = mask & 0xff;
2196 }
2197 else 2203 else
2198 {
2199 sl.len = oldlen; 2204 sl.len = oldlen;
2200 } 2205
2201 if (emask & 0xf) 2206 if (emask & 0xf)
2202 {
2203 esl.buf[eoldlen + 1] = emask & 0xff; 2207 esl.buf[eoldlen + 1] = emask & 0xff;
2204 }
2205 else 2208 else
2206 {
2207 esl.len = eoldlen; 2209 esl.len = eoldlen;
2208 }
2209 } /* else this is a viewable space */ 2210 } /* else this is a viewable space */
2210 } /* for x loop */ 2211 } /* for x loop */
2211 } /* for y loop */ 2212 } /* for y loop */
2212 2213
2213 /* Verify that we in fact do need to send this */ 2214 /* Verify that we in fact do need to send this */
2247 sint16 ax, ay, nx, ny; /* ax and ay goes from 0 to max-size of arrays */ 2248 sint16 ax, ay, nx, ny; /* ax and ay goes from 0 to max-size of arrays */
2248 New_Face *face, *floor; 2249 New_Face *face, *floor;
2249 New_Face *floor2; 2250 New_Face *floor2;
2250 int d, mflags; 2251 int d, mflags;
2251 struct Map newmap; 2252 struct Map newmap;
2252 mapstruct *m, *pm; 2253 maptile *m, *pm;
2253 2254
2254 if (pl->type != PLAYER) 2255 if (pl->type != PLAYER)
2255 { 2256 {
2256 LOG (llevError, "draw_client_map called with non player/non eric-server\n"); 2257 LOG (llevError, "draw_client_map called with non player/non eric-server\n");
2257 return; 2258 return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines