1 | /* |
1 | /* |
2 | * static char *rcsid_init_c = |
2 | * static char *rcsid_init_c = |
3 | * "$Id: request.C,v 1.2 2006/08/17 20:23:32 root Exp $"; |
3 | * "$Id: request.C,v 1.5 2006/08/19 02:57:05 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
368 | ns->mapinfocmd = atoi(param); |
368 | ns->mapinfocmd = atoi(param); |
369 | safe_strcat(cmdback, "1", &slen, HUGE_BUF); |
369 | safe_strcat(cmdback, "1", &slen, HUGE_BUF); |
370 | } else if (!strcmp(cmd,"extcmd")) { |
370 | } else if (!strcmp(cmd,"extcmd")) { |
371 | ns->extcmd = atoi(param); |
371 | ns->extcmd = atoi(param); |
372 | safe_strcat(cmdback, "1", &slen, HUGE_BUF); |
372 | safe_strcat(cmdback, "1", &slen, HUGE_BUF); |
|
|
373 | } else if (!strcmp(cmd,"extmap")) { |
|
|
374 | ns->extmap = atoi(param); |
|
|
375 | safe_strcat(cmdback, "1", &slen, HUGE_BUF); |
373 | } else if (!strcmp(cmd,"facecache")) { |
376 | } else if (!strcmp(cmd,"facecache")) { |
374 | ns->facecache = atoi(param); |
377 | ns->facecache = atoi(param); |
375 | safe_strcat(cmdback, param, &slen, HUGE_BUF); |
378 | safe_strcat(cmdback, param, &slen, HUGE_BUF); |
376 | } else if (!strcmp(cmd,"faceset")) { |
379 | } else if (!strcmp(cmd,"faceset")) { |
377 | char tmpbuf[20]; |
380 | char tmpbuf[20]; |
… | |
… | |
1265 | |
1268 | |
1266 | |
1269 | |
1267 | /** Clears a map cell */ |
1270 | /** Clears a map cell */ |
1268 | static void map_clearcell(struct MapCell *cell, int face0, int face1, int face2, int count) |
1271 | static void map_clearcell(struct MapCell *cell, int face0, int face1, int face2, int count) |
1269 | { |
1272 | { |
1270 | cell->count=count; |
|
|
1271 | cell->faces[0] = face0; |
1273 | cell->faces[0] = face0; |
1272 | cell->faces[1] = face1; |
1274 | cell->faces[1] = face1; |
1273 | cell->faces[2] = face2; |
1275 | cell->faces[2] = face2; |
|
|
1276 | cell->count = count; |
|
|
1277 | cell->stat_hp = 0; |
1274 | } |
1278 | } |
1275 | |
1279 | |
1276 | #define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y) |
1280 | #define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y) |
1277 | #define MAX_LAYERS 3 |
1281 | #define MAX_LAYERS 3 |
1278 | |
1282 | |
… | |
… | |
1303 | * basically, it only checks the that the head on space ax,ay at layer |
1307 | * basically, it only checks the that the head on space ax,ay at layer |
1304 | * needs to get sent - if so, it adds the data, sending the head |
1308 | * needs to get sent - if so, it adds the data, sending the head |
1305 | * if needed, and returning 1. If this no data needs to get |
1309 | * if needed, and returning 1. If this no data needs to get |
1306 | * sent, it returns zero. |
1310 | * sent, it returns zero. |
1307 | */ |
1311 | */ |
1308 | static inline int check_head(SockList *sl, NewSocket *ns, int ax, int ay, int layer) |
1312 | static int check_head (SockList &sl, NewSocket &ns, int ax, int ay, int layer) |
1309 | { |
1313 | { |
1310 | short face_num; |
1314 | short face_num; |
1311 | |
1315 | |
1312 | if (heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]) |
1316 | if (heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]) |
1313 | face_num = heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]->face->number; |
1317 | face_num = heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]->face->number; |
1314 | else |
1318 | else |
1315 | face_num = 0; |
1319 | face_num = 0; |
1316 | |
1320 | |
1317 | if (face_num != ns->lastmap.cells[ax][ay].faces[layer]) { |
1321 | if (face_num != ns.lastmap.cells[ax][ay].faces[layer]) { |
1318 | SockList_AddShort(sl, face_num); |
1322 | SockList_AddShort (&sl, face_num); |
1319 | if (face_num && !(ns->faces_sent[face_num] & NS_FACESENT_FACE)) |
1323 | if (face_num && !(ns.faces_sent[face_num] & NS_FACESENT_FACE)) |
1320 | esrv_send_face(ns, face_num, 0); |
1324 | esrv_send_face (&ns, face_num, 0); |
1321 | heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer] = NULL; |
1325 | heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer] = NULL; |
1322 | ns->lastmap.cells[ax][ay].faces[layer] = face_num; |
1326 | ns.lastmap.cells[ax][ay].faces[layer] = face_num; |
1323 | return 1; |
1327 | return 1; |
1324 | } |
1328 | } |
1325 | |
1329 | |
1326 | return 0; /* No change */ |
1330 | return 0; /* No change */ |
1327 | } |
1331 | } |
… | |
… | |
1344 | * the map command, where the faces stack up. Sinces that is no longer |
1348 | * the map command, where the faces stack up. Sinces that is no longer |
1345 | * the case, it seems to make more sense to have these layer values |
1349 | * the case, it seems to make more sense to have these layer values |
1346 | * actually match. |
1350 | * actually match. |
1347 | */ |
1351 | */ |
1348 | |
1352 | |
1349 | static inline int update_space(SockList *sl, NewSocket *ns, mapstruct *mp, int mx, int my, int sx, int sy, int layer) |
1353 | static int update_space(SockList *sl, NewSocket *ns, mapstruct *mp, int mx, int my, int sx, int sy, int layer) |
1350 | { |
1354 | { |
1351 | object *ob, *head; |
1355 | object *ob, *head; |
1352 | uint16 face_num; |
1356 | uint16 face_num; |
1353 | int bx, by,i; |
1357 | int bx, by,i; |
1354 | |
1358 | |
… | |
… | |
1623 | uint16 mask,emask; |
1627 | uint16 mask,emask; |
1624 | uint8 eentrysize; |
1628 | uint8 eentrysize; |
1625 | uint16 ewhatstart,ewhatflag; |
1629 | uint16 ewhatstart,ewhatflag; |
1626 | uint8 extendedinfos; |
1630 | uint8 extendedinfos; |
1627 | mapstruct *m; |
1631 | mapstruct *m; |
|
|
1632 | NewSocket &socket = pl->contr->socket; |
1628 | |
1633 | |
1629 | check_map_change (pl->contr); |
1634 | check_map_change (pl->contr); |
1630 | |
1635 | |
1631 | sl.buf=(unsigned char*)malloc(MAXSOCKBUF); |
1636 | sl.buf=(unsigned char*)malloc(MAXSOCKBUF); |
1632 | if (pl->contr->socket.mapmode == Map1Cmd) |
1637 | if (socket.mapmode == Map1Cmd) |
1633 | strcpy((char*)sl.buf,"map1 "); |
1638 | strcpy((char*)sl.buf,"map1 "); |
1634 | else |
1639 | else |
1635 | strcpy((char*)sl.buf,"map1a "); |
1640 | strcpy((char*)sl.buf,"map1a "); |
1636 | sl.len=strlen((char*)sl.buf); |
1641 | sl.len=strlen((char*)sl.buf); |
1637 | startlen = sl.len; |
1642 | startlen = sl.len; |
1638 | /*Extendedmapinfo structure initialisation*/ |
1643 | /*Extendedmapinfo structure initialisation*/ |
1639 | if (pl->contr->socket.ext_mapinfos){ |
1644 | if (socket.ext_mapinfos){ |
1640 | esl.buf=(unsigned char*)malloc(MAXSOCKBUF); |
1645 | esl.buf=(unsigned char*)malloc(MAXSOCKBUF); |
1641 | strcpy((char*)esl.buf,"mapextended "); |
1646 | strcpy((char*)esl.buf,"mapextended "); |
1642 | esl.len=strlen((char*)esl.buf); |
1647 | esl.len=strlen((char*)esl.buf); |
1643 | extendedinfos=EMI_NOREDRAW; |
1648 | extendedinfos=EMI_NOREDRAW; |
1644 | if (pl->contr->socket.EMI_smooth) |
1649 | if (socket.EMI_smooth) |
1645 | extendedinfos|=EMI_SMOOTH; |
1650 | extendedinfos|=EMI_SMOOTH; |
1646 | ewhatstart=esl.len; |
1651 | ewhatstart=esl.len; |
1647 | ewhatflag=extendedinfos; /*The EMI_NOREDRAW bit |
1652 | ewhatflag=extendedinfos; /*The EMI_NOREDRAW bit |
1648 | could need to be taken away*/ |
1653 | could need to be taken away*/ |
1649 | SockList_AddChar(&esl, extendedinfos); |
1654 | SockList_AddChar(&esl, extendedinfos); |
1650 | eentrysize=getExtendedMapInfoSize(&(pl->contr->socket)); |
1655 | eentrysize=getExtendedMapInfoSize(&socket); |
1651 | SockList_AddChar(&esl, eentrysize); |
1656 | SockList_AddChar(&esl, eentrysize); |
1652 | estartlen = esl.len; |
1657 | estartlen = esl.len; |
1653 | } else { |
1658 | } else { |
1654 | /* suppress compiler warnings */ |
1659 | /* suppress compiler warnings */ |
1655 | ewhatstart = 0; |
1660 | ewhatstart = 0; |
… | |
… | |
1665 | ay=0; |
1670 | ay=0; |
1666 | |
1671 | |
1667 | /* We could do this logic as conditionals in the if statement, |
1672 | /* We could do this logic as conditionals in the if statement, |
1668 | * but that started to get a bit messy to look at. |
1673 | * but that started to get a bit messy to look at. |
1669 | */ |
1674 | */ |
1670 | max_x = pl->x+(pl->contr->socket.mapx+1)/2; |
1675 | max_x = pl->x+(socket.mapx+1)/2; |
1671 | max_y = pl->y+(pl->contr->socket.mapy+1)/2; |
1676 | max_y = pl->y+(socket.mapy+1)/2; |
1672 | if (pl->contr->socket.mapmode == Map1aCmd) { |
1677 | if (socket.mapmode == Map1aCmd) { |
1673 | max_x += MAX_HEAD_OFFSET; |
1678 | max_x += MAX_HEAD_OFFSET; |
1674 | max_y += MAX_HEAD_OFFSET; |
1679 | max_y += MAX_HEAD_OFFSET; |
1675 | } |
1680 | } |
1676 | |
1681 | |
1677 | for(y=pl->y-pl->contr->socket.mapy/2; y<max_y; y++,ay++) { |
1682 | for(y=pl->y-socket.mapy/2; y<max_y; y++,ay++) { |
1678 | ax=0; |
1683 | ax=0; |
1679 | for(x=pl->x-pl->contr->socket.mapx/2;x<max_x;x++,ax++) { |
1684 | for(x=pl->x-socket.mapx/2;x<max_x;x++,ax++) { |
1680 | |
1685 | |
1681 | emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1686 | emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1682 | |
1687 | |
1683 | /* If this space is out of the normal viewable area, we only check |
1688 | /* If this space is out of the normal viewable area, we only check |
1684 | * the heads value ax or ay will only be greater than what |
1689 | * the heads value ax or ay will only be greater than what |
1685 | * the client wants if using the map1a command - this is because |
1690 | * the client wants if using the map1a command - this is because |
1686 | * if the map1a command is not used, max_x and max_y will be |
1691 | * if the map1a command is not used, max_x and max_y will be |
1687 | * set to lower values. |
1692 | * set to lower values. |
1688 | */ |
1693 | */ |
1689 | if (ax >= pl->contr->socket.mapx || ay >= pl->contr->socket.mapy) { |
1694 | if (ax >= socket.mapx || ay >= socket.mapy) { |
1690 | int i, got_one; |
1695 | int i, got_one; |
1691 | |
1696 | |
1692 | oldlen = sl.len; |
1697 | oldlen = sl.len; |
1693 | |
1698 | |
1694 | |
|
|
1695 | SockList_AddShort(&sl, mask); |
1699 | SockList_AddShort(&sl, mask); |
1696 | |
1700 | |
1697 | if (check_head(&sl, &pl->contr->socket, ax, ay, 2)) |
1701 | if (check_head (sl, socket, ax, ay, 2)) |
1698 | mask |= 0x4; |
1702 | mask |= 0x4; |
1699 | if (check_head(&sl, &pl->contr->socket, ax, ay, 1)) |
1703 | if (check_head (sl, socket, ax, ay, 1)) |
1700 | mask |= 0x2; |
1704 | mask |= 0x2; |
1701 | if (check_head(&sl, &pl->contr->socket, ax, ay, 0)) |
1705 | if (check_head (sl, socket, ax, ay, 0)) |
1702 | mask |= 0x1; |
1706 | mask |= 0x1; |
1703 | |
1707 | |
1704 | /* If all we are doing is sending 0 (blank) faces, we don't |
1708 | /* If all we are doing is sending 0 (blank) faces, we don't |
1705 | * actually need to send that - just the coordinates |
1709 | * actually need to send that - just the coordinates |
1706 | * with no faces tells the client to blank out the |
1710 | * with no faces tells the client to blank out the |
… | |
… | |
1712 | } |
1716 | } |
1713 | |
1717 | |
1714 | if (got_one && (mask & 0xf)) { |
1718 | if (got_one && (mask & 0xf)) { |
1715 | sl.buf[oldlen+1] = mask & 0xff; |
1719 | sl.buf[oldlen+1] = mask & 0xff; |
1716 | } else { /*either all faces blank, either no face at all*/ |
1720 | } else { /*either all faces blank, either no face at all*/ |
1717 | if (mask & 0xf) /*at least 1 face, we know it's blank, only send coordinates*/ |
1721 | if (mask & 0xf) /*at least 1 face, we know it's blank, only send coordinates*/ |
1718 | sl.len = oldlen + 2; |
1722 | sl.len = oldlen + 2; |
1719 | else |
1723 | else |
1720 | sl.len = oldlen; |
1724 | sl.len = oldlen; |
1721 | } |
1725 | } |
1722 | /*What concerns extendinfos, nothing to be done for now |
1726 | /*What concerns extendinfos, nothing to be done for now |
1723 | * (perhaps effects layer later) |
1727 | * (perhaps effects layer later) |
1724 | */ |
1728 | */ |
1725 | continue; /* don't do processing below */ |
1729 | continue; /* don't do processing below */ |
1726 | } |
1730 | } |
|
|
1731 | |
|
|
1732 | MapCell &lastcell = socket.lastmap.cells[ax][ay]; |
1727 | |
1733 | |
1728 | d = pl->contr->blocked_los[ax][ay]; |
1734 | d = pl->contr->blocked_los[ax][ay]; |
1729 | |
1735 | |
1730 | /* If the coordinates are not valid, or it is too dark to see, |
1736 | /* If the coordinates are not valid, or it is too dark to see, |
1731 | * we tell the client as such |
1737 | * we tell the client as such |
… | |
… | |
1736 | if (!m) { |
1742 | if (!m) { |
1737 | /* space is out of map. Update space and clear values |
1743 | /* space is out of map. Update space and clear values |
1738 | * if this hasn't already been done. If the space is out |
1744 | * if this hasn't already been done. If the space is out |
1739 | * of the map, it shouldn't have a head |
1745 | * of the map, it shouldn't have a head |
1740 | */ |
1746 | */ |
1741 | if (pl->contr->socket.lastmap.cells[ax][ay].count != -1) { |
1747 | if (lastcell.count != -1) { |
1742 | SockList_AddShort(&sl, mask); |
1748 | SockList_AddShort(&sl, mask); |
1743 | map_clearcell(&pl->contr->socket.lastmap.cells[ax][ay],0,0,0,-1); |
1749 | map_clearcell(&lastcell,0,0,0,-1); |
1744 | } |
1750 | } |
1745 | } else if (d>3) { |
1751 | } else if (d>3) { |
1746 | int need_send=0, count; |
1752 | int need_send=0, count; |
1747 | /* This block deals with spaces that are not visible for whatever |
1753 | /* This block deals with spaces that are not visible for whatever |
1748 | * reason. Still may need to send the head for this space. |
1754 | * reason. Still may need to send the head for this space. |
1749 | */ |
1755 | */ |
1750 | |
1756 | |
1751 | oldlen = sl.len; |
1757 | oldlen = sl.len; |
1752 | #if 0 |
1758 | |
1753 | /* First thing we do is blank out this space (clear it) |
|
|
1754 | * if not already done. If the client is using darkness, and |
|
|
1755 | * this space is at the edge, we also include the darkness. |
|
|
1756 | */ |
|
|
1757 | if (d==4) { |
|
|
1758 | if (pl->contr->socket.darkness && pl->contr->socket.lastmap.cells[ax][ay].count != d) { |
|
|
1759 | mask |= 8; |
|
|
1760 | SockList_AddShort(&sl, mask); |
|
|
1761 | SockList_AddChar(&sl, 0); |
|
|
1762 | } |
|
|
1763 | count = d; |
|
|
1764 | } else |
|
|
1765 | #endif |
|
|
1766 | { |
|
|
1767 | SockList_AddShort(&sl, mask); |
1759 | SockList_AddShort(&sl, mask); |
1768 | if (pl->contr->socket.lastmap.cells[ax][ay].count != -1) need_send=1; |
1760 | if (lastcell.count != -1) need_send=1; |
1769 | count = -1; |
1761 | count = -1; |
1770 | } |
|
|
1771 | |
1762 | |
1772 | if (pl->contr->socket.mapmode == Map1aCmd && have_head(ax, ay)) { |
1763 | if (socket.mapmode == Map1aCmd && have_head(ax, ay)) { |
1773 | /* Now check to see if any heads need to be sent */ |
1764 | /* Now check to see if any heads need to be sent */ |
1774 | |
1765 | |
1775 | if (check_head(&sl, &pl->contr->socket, ax, ay, 2)) |
1766 | if (check_head (sl, socket, ax, ay, 2)) |
1776 | mask |= 0x4; |
1767 | mask |= 0x4; |
1777 | if (check_head(&sl, &pl->contr->socket, ax, ay, 1)) |
1768 | if (check_head (sl, socket, ax, ay, 1)) |
1778 | mask |= 0x2; |
1769 | mask |= 0x2; |
1779 | if (check_head(&sl, &pl->contr->socket, ax, ay, 0)) |
1770 | if (check_head (sl, socket, ax, ay, 0)) |
1780 | mask |= 0x1; |
1771 | mask |= 0x1; |
1781 | pl->contr->socket.lastmap.cells[ax][ay].count = count; |
1772 | |
|
|
1773 | lastcell.count = count; |
1782 | |
1774 | |
1783 | } else { |
1775 | } else { |
1784 | struct MapCell *cell = &pl->contr->socket.lastmap.cells[ax][ay]; |
1776 | struct MapCell *cell = &lastcell; |
1785 | /* properly clear a previously sent big face */ |
1777 | /* properly clear a previously sent big face */ |
1786 | if(cell->faces[0] != 0 |
1778 | if(cell->faces[0] != 0 |
1787 | || cell->faces[1] != 0 |
1779 | || cell->faces[1] != 0 |
1788 | || cell->faces[2] != 0) |
1780 | || cell->faces[2] != 0) |
1789 | need_send = 1; |
1781 | need_send = 1; |
1790 | map_clearcell(&pl->contr->socket.lastmap.cells[ax][ay], 0, 0, 0, count); |
1782 | map_clearcell(&lastcell, 0, 0, 0, count); |
1791 | } |
1783 | } |
1792 | |
1784 | |
1793 | if ((mask & 0xf) || need_send) { |
1785 | if ((mask & 0xf) || need_send) { |
1794 | sl.buf[oldlen+1] = mask & 0xff; |
1786 | sl.buf[oldlen+1] = mask & 0xff; |
1795 | } else { |
1787 | } else { |
… | |
… | |
1814 | mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1806 | mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1815 | eoldlen = esl.len; |
1807 | eoldlen = esl.len; |
1816 | emask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1808 | emask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1817 | SockList_AddShort(&sl, mask); |
1809 | SockList_AddShort(&sl, mask); |
1818 | |
1810 | |
1819 | if (pl->contr->socket.ext_mapinfos) |
1811 | if (socket.ext_mapinfos) |
1820 | SockList_AddShort(&esl, emask); |
1812 | SockList_AddShort(&esl, emask); |
1821 | |
1813 | |
|
|
1814 | unsigned char dummy; |
|
|
1815 | unsigned char *last_ext = &dummy; |
|
|
1816 | |
1822 | /* Darkness changed */ |
1817 | /* Darkness changed */ |
1823 | if (pl->contr->socket.lastmap.cells[ax][ay].count != d && pl->contr->socket.darkness) { |
1818 | if (lastcell.count != d && socket.darkness) { |
1824 | pl->contr->socket.lastmap.cells[ax][ay].count = d; |
1819 | mask |= 0x8; |
1825 | mask |= 0x8; /* darkness bit */ |
|
|
1826 | |
1820 | |
1827 | /* Protocol defines 255 full bright, 0 full dark. |
1821 | if (socket.extmap) |
1828 | * We currently don't have that many darkness ranges, |
1822 | { |
1829 | * so we current what limited values we do have. |
1823 | *last_ext |= 0x80; last_ext = sl.buf + sl.len; SockList_AddChar (&sl, d); |
1830 | */ |
1824 | } |
1831 | if (d==0) SockList_AddChar(&sl, 255); |
1825 | else |
1832 | else if (d==1) SockList_AddChar(&sl, 191); |
1826 | SockList_AddChar (&sl, 255 - 64 * d); |
1833 | else if (d==2) SockList_AddChar(&sl, 127); |
|
|
1834 | else if (d==3) SockList_AddChar(&sl, 63); |
|
|
1835 | } |
1827 | } |
1836 | else { |
1828 | |
1837 | /* need to reset from -1 so that if it does become blocked again, |
1829 | lastcell.count = d; |
1838 | * the code that deals with that can detect that it needs to tell |
1830 | |
1839 | * the client that this space is now blocked. |
1831 | if (socket.extmap) |
1840 | */ |
1832 | { |
1841 | pl->contr->socket.lastmap.cells[ax][ay].count = d; |
1833 | uint8 stat_hp = 0; |
1842 | } |
1834 | |
|
|
1835 | // send hp information, if applicable |
|
|
1836 | if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0)) |
|
|
1837 | if (op->stats.maxhp > 0 |
|
|
1838 | && (unsigned)op->stats.maxhp > (unsigned)op->stats.hp |
|
|
1839 | && IS_LIVE (op)) |
|
|
1840 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
|
|
1841 | |
|
|
1842 | if (lastcell.stat_hp != stat_hp) |
|
|
1843 | { |
|
|
1844 | lastcell.stat_hp = stat_hp; |
|
|
1845 | |
|
|
1846 | mask |= 0x8; |
|
|
1847 | *last_ext |= 0x80; last_ext = sl.buf + sl.len; SockList_AddChar (&sl, 5); |
|
|
1848 | SockList_AddChar (&sl, stat_hp); |
|
|
1849 | } |
|
|
1850 | } |
1843 | |
1851 | |
1844 | /* Floor face */ |
1852 | /* Floor face */ |
1845 | if (update_space(&sl, &pl->contr->socket, m, nx, ny, ax, ay, 2)) |
1853 | if (update_space(&sl, &socket, m, nx, ny, ax, ay, 2)) |
1846 | mask |= 0x4; |
1854 | mask |= 0x4; |
1847 | |
1855 | |
1848 | if (pl->contr->socket.EMI_smooth) |
1856 | if (socket.EMI_smooth) |
1849 | if (update_smooth(&esl, &pl->contr->socket, m, nx, ny, ax, ay, 2)){ |
1857 | if (update_smooth(&esl, &socket, m, nx, ny, ax, ay, 2)) |
1850 | emask |= 0x4; |
1858 | emask |= 0x4; |
1851 | } |
|
|
1852 | |
1859 | |
1853 | /* Middle face */ |
1860 | /* Middle face */ |
1854 | if (update_space(&sl, &pl->contr->socket, m, nx, ny, ax, ay, 1)) |
1861 | if (update_space(&sl, &socket, m, nx, ny, ax, ay, 1)) |
1855 | mask |= 0x2; |
1862 | mask |= 0x2; |
1856 | |
1863 | |
1857 | if (pl->contr->socket.EMI_smooth) |
1864 | if (socket.EMI_smooth) |
1858 | if (update_smooth(&esl, &pl->contr->socket, m, nx, ny, ax, ay, 1)){ |
1865 | if (update_smooth(&esl, &socket, m, nx, ny, ax, ay, 1)) |
1859 | emask |= 0x2; |
1866 | emask |= 0x2; |
1860 | } |
|
|
1861 | |
|
|
1862 | |
1867 | |
1863 | if(nx == pl->x && ny == pl->y && pl->invisible & (pl->invisible < 50 ? 4 : 1)) { |
1868 | if(nx == pl->x && ny == pl->y && pl->invisible & (pl->invisible < 50 ? 4 : 1)) { |
1864 | if (pl->contr->socket.lastmap.cells[ax][ay].faces[0] != pl->face->number) { |
1869 | if (lastcell.faces[0] != pl->face->number) { |
1865 | pl->contr->socket.lastmap.cells[ax][ay].faces[0] = pl->face->number; |
1870 | lastcell.faces[0] = pl->face->number; |
1866 | mask |= 0x1; |
1871 | mask |= 0x1; |
1867 | if (!(pl->contr->socket.faces_sent[pl->face->number] &NS_FACESENT_FACE)) |
1872 | if (!(socket.faces_sent[pl->face->number] &NS_FACESENT_FACE)) |
1868 | esrv_send_face(&pl->contr->socket, pl->face->number, 0); |
1873 | esrv_send_face(&socket, pl->face->number, 0); |
1869 | SockList_AddShort(&sl, pl->face->number); |
1874 | SockList_AddShort(&sl, pl->face->number); |
1870 | } |
1875 | } |
1871 | } |
1876 | } |
1872 | /* Top face */ |
1877 | /* Top face */ |
1873 | else { |
1878 | else { |
1874 | if (update_space(&sl, &pl->contr->socket, m, nx, ny, ax, ay, 0)) |
1879 | if (update_space(&sl, &socket, m, nx, ny, ax, ay, 0)) |
1875 | mask |= 0x1; |
1880 | mask |= 0x1; |
1876 | if (pl->contr->socket.EMI_smooth) |
1881 | if (socket.EMI_smooth) |
1877 | if (update_smooth(&esl, &pl->contr->socket, m, nx, ny, ax, ay, 0)){ |
1882 | if (update_smooth(&esl, &socket, m, nx, ny, ax, ay, 0)){ |
1878 | emask |= 0x1; |
1883 | emask |= 0x1; |
1879 | } |
1884 | } |
1880 | } |
1885 | } |
1881 | /* Check to see if we are in fact sending anything for this |
1886 | /* Check to see if we are in fact sending anything for this |
1882 | * space by checking the mask. If so, update the mask. |
1887 | * space by checking the mask. If so, update the mask. |
… | |
… | |
1896 | } /* else this is a viewable space */ |
1901 | } /* else this is a viewable space */ |
1897 | } /* for x loop */ |
1902 | } /* for x loop */ |
1898 | } /* for y loop */ |
1903 | } /* for y loop */ |
1899 | |
1904 | |
1900 | /* Verify that we in fact do need to send this */ |
1905 | /* Verify that we in fact do need to send this */ |
1901 | if (pl->contr->socket.ext_mapinfos){ |
1906 | if (socket.ext_mapinfos){ |
1902 | if (!(sl.len>startlen || pl->contr->socket.sent_scroll)){ |
1907 | if (!(sl.len>startlen || socket.sent_scroll)){ |
1903 | /* No map data will follow, so don't say the client |
1908 | /* No map data will follow, so don't say the client |
1904 | * it doesn't need draw! |
1909 | * it doesn't need draw! |
1905 | */ |
1910 | */ |
1906 | ewhatflag&=(~EMI_NOREDRAW); |
1911 | ewhatflag&=(~EMI_NOREDRAW); |
1907 | esl.buf[ewhatstart+1] = ewhatflag & 0xff; |
1912 | esl.buf[ewhatstart+1] = ewhatflag & 0xff; |
1908 | } |
1913 | } |
1909 | if (esl.len>estartlen) { |
1914 | if (esl.len>estartlen) { |
1910 | Send_With_Handling(&pl->contr->socket, &esl); |
1915 | Send_With_Handling(&socket, &esl); |
1911 | } |
1916 | } |
1912 | free(esl.buf); |
1917 | free(esl.buf); |
1913 | } |
1918 | } |
1914 | if (sl.len>startlen || pl->contr->socket.sent_scroll) { |
1919 | if (sl.len>startlen || socket.sent_scroll) { |
1915 | Send_With_Handling(&pl->contr->socket, &sl); |
1920 | Send_With_Handling(&socket, &sl); |
1916 | pl->contr->socket.sent_scroll = 0; |
1921 | socket.sent_scroll = 0; |
1917 | } |
1922 | } |
1918 | free(sl.buf); |
1923 | free(sl.buf); |
1919 | } |
1924 | } |
1920 | |
1925 | |
1921 | /** |
1926 | /** |