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.24 by root, Tue Sep 19 22:05:55 2006 UTC vs.
Revision 1.25 by root, Thu Sep 21 14:51:16 2006 UTC

137 for (x = 0; x < mx; x++) 137 for (x = 0; x < mx; x++)
138 { 138 {
139 for (y = 0; y < my; y++) 139 for (y = 0; y < my; y++)
140 { 140 {
141 if (x >= ns->mapx || y >= ns->mapy) 141 if (x >= ns->mapx || y >= ns->mapy)
142 {
143 /* clear cells outside the viewable area */ 142 /* clear cells outside the viewable area */
144 memset (&newmap.cells[x][y], 0, sizeof (struct MapCell)); 143 memset (&newmap.cells[x][y], 0, sizeof (struct MapCell));
145 }
146 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)
147 {
148 /* clear newly visible tiles within the viewable area */ 145 /* clear newly visible tiles within the viewable area */
149 memset (&(newmap.cells[x][y]), 0, sizeof (struct MapCell)); 146 memset (&(newmap.cells[x][y]), 0, sizeof (struct MapCell));
150 }
151 else 147 else
152 {
153 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));
154 }
155 } 149 }
156 } 150 }
157 151
158 memcpy (&(ns->lastmap), &newmap, sizeof (struct Map)); 152 memcpy (&(ns->lastmap), &newmap, sizeof (struct Map));
159 153
1460map_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)
1461{ 1455{
1462 cell->faces[0] = face0; 1456 cell->faces[0] = face0;
1463 cell->faces[1] = face1; 1457 cell->faces[1] = face1;
1464 cell->faces[2] = face2; 1458 cell->faces[2] = face2;
1465 cell->count = count; 1459 cell->count = count;
1466 cell->stat_hp = 0; 1460 cell->stat_hp = 0;
1461 cell->flags = 0;
1467 cell->player = 0; 1462 cell->player = 0;
1468} 1463}
1469 1464
1470#define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y) 1465#define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y)
1471#define MAX_LAYERS 3 1466#define MAX_LAYERS 3
1472 1467
1868 strcpy ((char *) sl.buf, "map1 "); 1863 strcpy ((char *) sl.buf, "map1 ");
1869 else 1864 else
1870 strcpy ((char *) sl.buf, "map1a "); 1865 strcpy ((char *) sl.buf, "map1a ");
1871 sl.len = strlen ((char *) sl.buf); 1866 sl.len = strlen ((char *) sl.buf);
1872 startlen = sl.len; 1867 startlen = sl.len;
1868
1873 /*Extendedmapinfo structure initialisation */ 1869 /*Extendedmapinfo structure initialisation */
1874 if (socket.ext_mapinfos) 1870 if (socket.ext_mapinfos)
1875 { 1871 {
1876 esl.buf = (unsigned char *) malloc (MAXSOCKBUF); 1872 esl.buf = (unsigned char *) malloc (MAXSOCKBUF);
1877 strcpy ((char *) esl.buf, "mapextended "); 1873 strcpy ((char *) esl.buf, "mapextended ");
1878 esl.len = strlen ((char *) esl.buf); 1874 esl.len = strlen ((char *) esl.buf);
1879 extendedinfos = EMI_NOREDRAW; 1875 extendedinfos = EMI_NOREDRAW;
1876
1880 if (socket.EMI_smooth) 1877 if (socket.EMI_smooth)
1881 extendedinfos |= EMI_SMOOTH; 1878 extendedinfos |= EMI_SMOOTH;
1879
1882 ewhatstart = esl.len; 1880 ewhatstart = esl.len;
1883 ewhatflag = extendedinfos; /*The EMI_NOREDRAW bit 1881 ewhatflag = extendedinfos; /*The EMI_NOREDRAW bit
1884 could need to be taken away */ 1882 could need to be taken away */
1885 SockList_AddChar (&esl, extendedinfos); 1883 SockList_AddChar (&esl, extendedinfos);
1886 eentrysize = getExtendedMapInfoSize (&socket); 1884 eentrysize = getExtendedMapInfoSize (&socket);
1892 /* suppress compiler warnings */ 1890 /* suppress compiler warnings */
1893 ewhatstart = 0; 1891 ewhatstart = 0;
1894 ewhatflag = 0; 1892 ewhatflag = 0;
1895 estartlen = 0; 1893 estartlen = 0;
1896 } 1894 }
1895
1897 /* Init data to zero */ 1896 /* Init data to zero */
1898 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);
1899 1898
1900 /* 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
1901 * locations. 1900 * locations.
1905 /* We could do this logic as conditionals in the if statement, 1904 /* We could do this logic as conditionals in the if statement,
1906 * but that started to get a bit messy to look at. 1905 * but that started to get a bit messy to look at.
1907 */ 1906 */
1908 max_x = pl->x + (socket.mapx + 1) / 2; 1907 max_x = pl->x + (socket.mapx + 1) / 2;
1909 max_y = pl->y + (socket.mapy + 1) / 2; 1908 max_y = pl->y + (socket.mapy + 1) / 2;
1909
1910 if (socket.mapmode == Map1aCmd) 1910 if (socket.mapmode == Map1aCmd)
1911 { 1911 {
1912 max_x += MAX_HEAD_OFFSET; 1912 max_x += MAX_HEAD_OFFSET;
1913 max_y += MAX_HEAD_OFFSET; 1913 max_y += MAX_HEAD_OFFSET;
1914 } 1914 }
1947 * with no faces tells the client to blank out the 1947 * with no faces tells the client to blank out the
1948 * space. 1948 * space.
1949 */ 1949 */
1950 got_one = 0; 1950 got_one = 0;
1951 for (i = oldlen + 2; i < sl.len; i++) 1951 for (i = oldlen + 2; i < sl.len; i++)
1952 {
1953 if (sl.buf[i]) 1952 if (sl.buf[i])
1954 got_one = 1; 1953 got_one = 1;
1955 }
1956 1954
1957 if (got_one && (mask & 0xf)) 1955 if (got_one && (mask & 0xf))
1958 {
1959 sl.buf[oldlen + 1] = mask & 0xff; 1956 sl.buf[oldlen + 1] = mask & 0xff;
1960 }
1961 else 1957 else
1962 { /*either all faces blank, either no face at all */ 1958 { /*either all faces blank, either no face at all */
1963 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 */
1964 sl.len = oldlen + 2; 1960 sl.len = oldlen + 2;
1965 else 1961 else
1966 sl.len = oldlen; 1962 sl.len = oldlen;
1967 } 1963 }
1964
1968 /*What concerns extendinfos, nothing to be done for now 1965 /*What concerns extendinfos, nothing to be done for now
1969 * (perhaps effects layer later) 1966 * (perhaps effects layer later)
1970 */ 1967 */
1971 continue; /* don't do processing below */ 1968 continue; /* don't do processing below */
1972 } 1969 }
1973 1970
1974 MapCell & lastcell = socket.lastmap.cells[ax][ay]; 1971 MapCell &lastcell = socket.lastmap.cells[ax][ay];
1975 1972
1976 d = pl->contr->blocked_los[ax][ay]; 1973 d = pl->contr->blocked_los[ax][ay];
1977 1974
1978 /* 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,
1979 * we tell the client as such 1976 * we tell the client as such
1980 */ 1977 */
1981 nx = x; 1978 nx = x;
1982 ny = y; 1979 ny = y;
1983 m = get_map_from_coord (pl->map, &nx, &ny); 1980 m = get_map_from_coord (pl->map, &nx, &ny);
1981
1984 if (!m) 1982 if (!m)
1985 { 1983 {
1986 /* space is out of map. Update space and clear values 1984 /* space is out of map. Update space and clear values
1987 * 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
1988 * of the map, it shouldn't have a head 1986 * of the map, it shouldn't have a head
2002 */ 2000 */
2003 2001
2004 oldlen = sl.len; 2002 oldlen = sl.len;
2005 2003
2006 SockList_AddShort (&sl, mask); 2004 SockList_AddShort (&sl, mask);
2005
2007 if (lastcell.count != -1) 2006 if (lastcell.count != -1)
2008 need_send = 1; 2007 need_send = 1;
2008
2009 count = -1; 2009 count = -1;
2010 2010
2011 if (socket.mapmode == Map1aCmd && have_head (ax, ay)) 2011 if (socket.mapmode == Map1aCmd && have_head (ax, ay))
2012 { 2012 {
2013 /* Now check to see if any heads need to be sent */ 2013 /* Now check to see if any heads need to be sent */
2018 mask |= 0x2; 2018 mask |= 0x2;
2019 if (check_head (sl, socket, ax, ay, 0)) 2019 if (check_head (sl, socket, ax, ay, 0))
2020 mask |= 0x1; 2020 mask |= 0x1;
2021 2021
2022 lastcell.count = count; 2022 lastcell.count = count;
2023
2024 } 2023 }
2025 else 2024 else
2026 { 2025 {
2027 struct MapCell *cell = &lastcell;
2028
2029 /* properly clear a previously sent big face */ 2026 /* properly clear a previously sent big face */
2030 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)
2031 need_send = 1; 2029 need_send = 1;
2030
2032 map_clearcell (&lastcell, 0, 0, 0, count); 2031 map_clearcell (&lastcell, 0, 0, 0, count);
2033 } 2032 }
2034 2033
2035 if ((mask & 0xf) || need_send) 2034 if ((mask & 0xf) || need_send)
2036 {
2037 sl.buf[oldlen + 1] = mask & 0xff; 2035 sl.buf[oldlen + 1] = mask & 0xff;
2038 }
2039 else 2036 else
2040 {
2041 sl.len = oldlen; 2037 sl.len = oldlen;
2042 }
2043 } 2038 }
2044 else 2039 else
2045 { 2040 {
2046 /* 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
2047 * we need to send. 2042 * we need to send.
2178 { 2173 {
2179 if (lastcell.faces[0] != pl->face->number) 2174 if (lastcell.faces[0] != pl->face->number)
2180 { 2175 {
2181 lastcell.faces[0] = pl->face->number; 2176 lastcell.faces[0] = pl->face->number;
2182 mask |= 0x1; 2177 mask |= 0x1;
2178
2183 if (!(socket.faces_sent[pl->face->number] & NS_FACESENT_FACE)) 2179 if (!(socket.faces_sent[pl->face->number] & NS_FACESENT_FACE))
2184 esrv_send_face (&socket, pl->face->number, 0); 2180 esrv_send_face (&socket, pl->face->number, 0);
2181
2185 SockList_AddShort (&sl, pl->face->number); 2182 SockList_AddShort (&sl, pl->face->number);
2186 } 2183 }
2187 } 2184 }
2188 /* Top face */
2189 else 2185 else
2190 { 2186 {
2187 /* Top face */
2191 if (update_space (&sl, &socket, m, nx, ny, ax, ay, 0)) 2188 if (update_space (&sl, &socket, m, nx, ny, ax, ay, 0))
2192 mask |= 0x1; 2189 mask |= 0x1;
2190
2193 if (socket.EMI_smooth) 2191 if (socket.EMI_smooth)
2194 if (update_smooth (&esl, &socket, m, nx, ny, ax, ay, 0)) 2192 if (update_smooth (&esl, &socket, m, nx, ny, ax, ay, 0))
2195 {
2196 emask |= 0x1; 2193 emask |= 0x1;
2197 }
2198 } 2194 }
2195
2199 /* 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
2200 * space by checking the mask. If so, update the mask. 2197 * space by checking the mask. If so, update the mask.
2201 * 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
2202 * value, so we don't send those bits. 2199 * value, so we don't send those bits.
2203 */ 2200 */
2204 if (mask & 0xf) 2201 if (mask & 0xf)
2205 {
2206 sl.buf[oldlen + 1] = mask & 0xff; 2202 sl.buf[oldlen + 1] = mask & 0xff;
2207 }
2208 else 2203 else
2209 {
2210 sl.len = oldlen; 2204 sl.len = oldlen;
2211 } 2205
2212 if (emask & 0xf) 2206 if (emask & 0xf)
2213 {
2214 esl.buf[eoldlen + 1] = emask & 0xff; 2207 esl.buf[eoldlen + 1] = emask & 0xff;
2215 }
2216 else 2208 else
2217 {
2218 esl.len = eoldlen; 2209 esl.len = eoldlen;
2219 }
2220 } /* else this is a viewable space */ 2210 } /* else this is a viewable space */
2221 } /* for x loop */ 2211 } /* for x loop */
2222 } /* for y loop */ 2212 } /* for y loop */
2223 2213
2224 /* Verify that we in fact do need to send this */ 2214 /* Verify that we in fact do need to send this */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines