1 | /* |
1 | /* |
2 | * static char *rcsid_init_c = |
2 | * static char *rcsid_init_c = |
3 | * "$Id: request.c,v 1.1 2006/02/03 07:14:46 root Exp $"; |
3 | * "$Id: request.c,v 1.1.1.2 2006/02/22 18:03:29 elmex 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 | |
… | |
… | |
362 | * Basically, it makes no sense to wait for the client to request a |
362 | * Basically, it makes no sense to wait for the client to request a |
363 | * a piece of data from us that we know the client wants. So |
363 | * a piece of data from us that we know the client wants. So |
364 | * if we know the client wants it, might as well push it to the |
364 | * if we know the client wants it, might as well push it to the |
365 | * client. |
365 | * client. |
366 | */ |
366 | */ |
367 | void SendSmooth(NewSocket *ns, uint16 face) { |
367 | static void SendSmooth(NewSocket *ns, uint16 face) { |
368 | uint16 smoothface; |
368 | uint16 smoothface; |
369 | uint8 reply[MAX_BUF]; |
369 | uint8 reply[MAX_BUF]; |
370 | SockList sl; |
370 | SockList sl; |
371 | |
371 | |
372 | /* If we can't find a face, return and set it so we won't try to send this |
372 | /* If we can't find a face, return and set it so we won't try to send this |
… | |
… | |
1736 | sint16 ax, ay, nx, ny;/* ax and ay goes from 0 to max-size of arrays */ |
1736 | sint16 ax, ay, nx, ny;/* ax and ay goes from 0 to max-size of arrays */ |
1737 | New_Face *face,*floor; |
1737 | New_Face *face,*floor; |
1738 | New_Face *floor2; |
1738 | New_Face *floor2; |
1739 | int d, mflags; |
1739 | int d, mflags; |
1740 | struct Map newmap; |
1740 | struct Map newmap; |
1741 | mapstruct *m; |
1741 | mapstruct *m, *pm; |
1742 | |
1742 | |
1743 | if (pl->type != PLAYER) { |
1743 | if (pl->type != PLAYER) { |
1744 | LOG(llevError,"draw_client_map called with non player/non eric-server\n"); |
1744 | LOG(llevError,"draw_client_map called with non player/non eric-server\n"); |
1745 | return; |
1745 | return; |
1746 | } |
1746 | } |
1747 | |
1747 | |
|
|
1748 | if (pl->contr->transport) { |
|
|
1749 | pm = pl->contr->transport->map; |
|
|
1750 | } |
|
|
1751 | else |
|
|
1752 | pm = pl->map; |
|
|
1753 | |
1748 | /* IF player is just joining the game, he isn't here yet, so the map |
1754 | /* If player is just joining the game, he isn't here yet, so the map |
1749 | * can get swapped out. If so, don't try to send them a map. All will |
1755 | * can get swapped out. If so, don't try to send them a map. All will |
1750 | * be OK once they really log in. |
1756 | * be OK once they really log in. |
1751 | */ |
1757 | */ |
1752 | if (pl->map==NULL || pl->map->in_memory!=MAP_IN_MEMORY) return; |
1758 | if (pm==NULL || pm->in_memory!=MAP_IN_MEMORY) return; |
1753 | |
1759 | |
1754 | memset(&newmap, 0, sizeof(struct Map)); |
1760 | memset(&newmap, 0, sizeof(struct Map)); |
1755 | |
1761 | |
1756 | for(j = (pl->y - pl->contr->socket.mapy/2) ; j < (pl->y + (pl->contr->socket.mapy+1)/2); j++) { |
1762 | for(j = (pl->y - pl->contr->socket.mapy/2) ; j < (pl->y + (pl->contr->socket.mapy+1)/2); j++) { |
1757 | for(i = (pl->x - pl->contr->socket.mapx/2) ; i < (pl->x + (pl->contr->socket.mapx+1)/2); i++) { |
1763 | for(i = (pl->x - pl->contr->socket.mapx/2) ; i < (pl->x + (pl->contr->socket.mapx+1)/2); i++) { |
1758 | ax=i; |
1764 | ax=i; |
1759 | ay=j; |
1765 | ay=j; |
1760 | m = pl->map; |
1766 | m = pm; |
1761 | mflags = get_map_flags(m, &m, ax, ay, &ax, &ay); |
1767 | mflags = get_map_flags(m, &m, ax, ay, &ax, &ay); |
1762 | if (mflags & P_OUT_OF_MAP) |
1768 | if (mflags & P_OUT_OF_MAP) |
1763 | continue; |
1769 | continue; |
1764 | if (mflags & P_NEED_UPDATE) |
1770 | if (mflags & P_NEED_UPDATE) |
1765 | update_position(m, ax, ay); |
1771 | update_position(m, ax, ay); |
… | |
… | |
1807 | /* note the out_of_map and d>3 checks are both within the same |
1813 | /* note the out_of_map and d>3 checks are both within the same |
1808 | * negation check. |
1814 | * negation check. |
1809 | */ |
1815 | */ |
1810 | nx = i; |
1816 | nx = i; |
1811 | ny = j; |
1817 | ny = j; |
1812 | m = get_map_from_coord(pl->map, &nx, &ny); |
1818 | m = get_map_from_coord(pm, &nx, &ny); |
1813 | if (m && d<4) { |
1819 | if (m && d<4) { |
1814 | face = GET_MAP_FACE(m, nx, ny,0); |
1820 | face = GET_MAP_FACE(m, nx, ny,0); |
1815 | floor2 = GET_MAP_FACE(m, nx, ny,1); |
1821 | floor2 = GET_MAP_FACE(m, nx, ny,1); |
1816 | floor = GET_MAP_FACE(m, nx, ny,2); |
1822 | floor = GET_MAP_FACE(m, nx, ny,2); |
1817 | |
1823 | |
… | |
… | |
2011 | free(sl.buf); |
2017 | free(sl.buf); |
2012 | } |
2018 | } |
2013 | |
2019 | |
2014 | /* appends the spell *spell to the Socklist we will send the data to. */ |
2020 | /* appends the spell *spell to the Socklist we will send the data to. */ |
2015 | static void append_spell (player *pl, SockList *sl, object *spell) { |
2021 | static void append_spell (player *pl, SockList *sl, object *spell) { |
2016 | int len, i, skill=0; |
2022 | int len, i, skill=0; |
2017 | |
2023 | |
2018 | if (!(spell->name)) { |
2024 | if (!(spell->name)) { |
2019 | LOG(llevError, "item number %d is a spell with no name.\n", spell->count); |
2025 | LOG(llevError, "item number %d is a spell with no name.\n", spell->count); |
2020 | return; |
2026 | return; |
2021 | } |
2027 | } |
… | |
… | |
2029 | /* send the current values */ |
2035 | /* send the current values */ |
2030 | SockList_AddShort(sl, spell->last_sp); |
2036 | SockList_AddShort(sl, spell->last_sp); |
2031 | SockList_AddShort(sl, spell->last_grace); |
2037 | SockList_AddShort(sl, spell->last_grace); |
2032 | SockList_AddShort(sl, spell->last_eat); |
2038 | SockList_AddShort(sl, spell->last_eat); |
2033 | |
2039 | |
2034 | /* figure out which skill it uses */ |
2040 | /* figure out which skill it uses, if it uses one */ |
|
|
2041 | if (spell->skill) { |
2035 | for (i=1; i< NUM_SKILLS; i++) |
2042 | for (i=1; i< NUM_SKILLS; i++) |
2036 | if (!strcmp(spell->skill, skill_names[i])) { |
2043 | if (!strcmp(spell->skill, skill_names[i])) { |
2037 | skill = i+CS_STAT_SKILLINFO; |
2044 | skill = i+CS_STAT_SKILLINFO; |
2038 | break; |
2045 | break; |
2039 | } |
2046 | } |
2040 | skill = i+CS_STAT_SKILLINFO; |
2047 | } |
2041 | SockList_AddChar(sl, skill); |
2048 | SockList_AddChar(sl, skill); |
2042 | |
2049 | |
2043 | SockList_AddInt(sl, spell->path_attuned); |
2050 | SockList_AddInt(sl, spell->path_attuned); |
2044 | SockList_AddInt(sl, (spell->face)?spell->face->number:0); |
2051 | SockList_AddInt(sl, (spell->face)?spell->face->number:0); |
2045 | |
2052 | |