1 | /* |
1 | /* |
2 | * static char *rcsid_init_c = |
2 | * static char *rcsid_init_c = |
3 | * "$Id: request.C,v 1.3 2006/08/18 02:06:58 root Exp $"; |
3 | * "$Id: request.C,v 1.9 2006/08/24 17:29:30 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 | |
… | |
… | |
163 | * empty). |
163 | * empty). |
164 | */ |
164 | */ |
165 | ns->sent_scroll = 1; |
165 | ns->sent_scroll = 1; |
166 | } |
166 | } |
167 | |
167 | |
|
|
168 | static void |
|
|
169 | clear_map (player *pl) |
|
|
170 | { |
|
|
171 | NewSocket &socket = pl->socket; |
|
|
172 | |
|
|
173 | memset (&socket.lastmap, 0, sizeof (socket.lastmap)); |
|
|
174 | |
|
|
175 | if (socket.newmapcmd == 1) |
|
|
176 | Write_String_To_Socket (&socket, "newmap", 6); |
|
|
177 | |
|
|
178 | socket.update_look = 1; |
|
|
179 | socket.look_position = 0; |
|
|
180 | } |
|
|
181 | |
168 | /** check for map change and send new map data */ |
182 | /** check for map change and send new map data */ |
169 | static void |
183 | static void |
170 | check_map_change (player *pl) |
184 | check_map_change (player *pl) |
171 | { |
185 | { |
172 | NewSocket &socket = pl->socket; |
186 | NewSocket &socket = pl->socket; |
… | |
… | |
174 | char buf[MAX_BUF]; /* eauugggh */ |
188 | char buf[MAX_BUF]; /* eauugggh */ |
175 | |
189 | |
176 | if (socket.current_map != ob->map) |
190 | if (socket.current_map != ob->map) |
177 | { |
191 | { |
178 | socket.current_map = ob->map; |
192 | socket.current_map = ob->map; |
179 | memset (&socket.lastmap, 0, sizeof(socket.lastmap)); |
|
|
180 | |
193 | |
181 | if (socket.newmapcmd == 1) |
194 | clear_map (pl); |
182 | Write_String_To_Socket (&socket, "newmap", 6); |
|
|
183 | |
|
|
184 | socket.update_look = 1; |
|
|
185 | socket.look_position =0; |
|
|
186 | |
195 | |
187 | if (socket.mapinfocmd) |
196 | if (socket.mapinfocmd) |
188 | { |
197 | { |
189 | if (ob->map && ob->map->path [0]) |
198 | if (ob->map && ob->map->path [0]) |
190 | { |
199 | { |
… | |
… | |
205 | Write_String_To_Socket (&socket, buf, strlen (buf)); |
214 | Write_String_To_Socket (&socket, buf, strlen (buf)); |
206 | } |
215 | } |
207 | } |
216 | } |
208 | else if (socket.current_x != ob->x || socket.current_y != ob->y) |
217 | else if (socket.current_x != ob->x || socket.current_y != ob->y) |
209 | { |
218 | { |
|
|
219 | int dx = ob->x - socket.current_x; |
|
|
220 | int dy = ob->y - socket.current_y; |
|
|
221 | |
|
|
222 | if (socket.buggy_mapscroll && (abs (dx) > 8 || abs (dy) > 8)) |
|
|
223 | clear_map (pl); // current (<= 1.9.1) clients have unchecked buffer overflows |
|
|
224 | else |
|
|
225 | { |
210 | socket_map_scroll (&socket, ob->x - socket.current_x, ob->y - socket.current_y); |
226 | socket_map_scroll (&socket, ob->x - socket.current_x, ob->y - socket.current_y); |
211 | socket.update_look = 1; |
227 | socket.update_look = 1; |
212 | socket.look_position = 0; |
228 | socket.look_position = 0; |
|
|
229 | } |
213 | } |
230 | } |
214 | |
231 | |
215 | socket.current_x = ob->x; |
232 | socket.current_x = ob->x; |
216 | socket.current_y = ob->y; |
233 | socket.current_y = ob->y; |
217 | } |
234 | } |
… | |
… | |
823 | } |
840 | } |
824 | cp = strchr(cp+1, ' '); |
841 | cp = strchr(cp+1, ' '); |
825 | if (cp) { |
842 | if (cp) { |
826 | LOG(llevDebug,"CS: connection from client of type <%s>, ip %s\n", cp, ns->host); |
843 | LOG(llevDebug,"CS: connection from client of type <%s>, ip %s\n", cp, ns->host); |
827 | |
844 | |
|
|
845 | snprintf (ns->client, sizeof (ns->client), "%s", cp + 1); |
|
|
846 | |
828 | /* This is first implementation - i skip all beta DX clients with it |
847 | /* This is first implementation - i skip all beta DX clients with it |
829 | * Add later stuff here for other clients |
848 | * Add later stuff here for other clients |
830 | */ |
849 | */ |
831 | |
850 | |
832 | /* these are old dxclients */ |
851 | /* these are old dxclients */ |
… | |
… | |
1272 | { |
1291 | { |
1273 | cell->faces[0] = face0; |
1292 | cell->faces[0] = face0; |
1274 | cell->faces[1] = face1; |
1293 | cell->faces[1] = face1; |
1275 | cell->faces[2] = face2; |
1294 | cell->faces[2] = face2; |
1276 | cell->count = count; |
1295 | cell->count = count; |
1277 | cell->stat_hp = 255; |
1296 | cell->stat_hp = 0; |
|
|
1297 | cell->player = 0; |
1278 | } |
1298 | } |
1279 | |
1299 | |
1280 | #define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y) |
1300 | #define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y) |
1281 | #define MAX_LAYERS 3 |
1301 | #define MAX_LAYERS 3 |
1282 | |
1302 | |
… | |
… | |
1828 | |
1848 | |
1829 | lastcell.count = d; |
1849 | lastcell.count = d; |
1830 | |
1850 | |
1831 | if (socket.extmap) |
1851 | if (socket.extmap) |
1832 | { |
1852 | { |
1833 | uint8 stat_hp = 0; |
1853 | uint8 stat_hp = 0; |
|
|
1854 | uint8 stat_width = 0; |
|
|
1855 | tag_t player = 0; |
1834 | |
1856 | |
1835 | // send hp information, if applicable |
1857 | // send hp information, if applicable |
1836 | if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0)) |
1858 | if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0)) |
|
|
1859 | { |
|
|
1860 | if (op->head || op->invisible) |
|
|
1861 | ; // do not show |
|
|
1862 | else if (op->type == PLAYER |
|
|
1863 | || QUERY_FLAG (op, FLAG_MONSTER) |
|
|
1864 | || QUERY_FLAG (op, FLAG_ALIVE) |
|
|
1865 | || QUERY_FLAG (op, FLAG_GENERATOR)) |
|
|
1866 | { |
1837 | if (op->stats.maxhp > 0 |
1867 | if (op->stats.maxhp > 0 |
1838 | && (unsigned)op->stats.maxhp + 1 > (unsigned)op->stats.hp |
1868 | && (unsigned)op->stats.maxhp > (unsigned)op->stats.hp) |
1839 | && IS_LIVE (op)) |
1869 | { |
1840 | stat_hp = 255 - op->stats.hp * 255 / op->stats.maxhp; |
1870 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
|
|
1871 | stat_width = op->arch->tail_x; |
|
|
1872 | } |
|
|
1873 | } |
1841 | |
1874 | |
|
|
1875 | if (op->type == PLAYER && op != pl) |
|
|
1876 | player = op->count; |
|
|
1877 | } |
|
|
1878 | |
1842 | if (lastcell.stat_hp != stat_hp) |
1879 | if (lastcell.stat_hp != stat_hp && 0) |
1843 | { |
1880 | { |
1844 | lastcell.stat_hp = stat_hp; |
1881 | lastcell.stat_hp = stat_hp; |
1845 | |
1882 | |
1846 | mask |= 0x8; |
1883 | mask |= 0x8; |
1847 | *last_ext |= 0x80; last_ext = sl.buf + sl.len; SockList_AddChar (&sl, 5); |
1884 | *last_ext |= 0x80; last_ext = sl.buf + sl.len; SockList_AddChar (&sl, 5); |
1848 | SockList_AddChar (&sl, stat_hp); |
1885 | SockList_AddChar (&sl, stat_hp); |
|
|
1886 | |
|
|
1887 | if (stat_width > 1) |
|
|
1888 | { |
|
|
1889 | *last_ext |= 0x80; last_ext = sl.buf + sl.len; SockList_AddChar (&sl, 6); |
|
|
1890 | SockList_AddChar (&sl, stat_width); |
|
|
1891 | } |
|
|
1892 | } |
|
|
1893 | |
|
|
1894 | if (lastcell.player != player && 0) |
|
|
1895 | { |
|
|
1896 | lastcell.player = player; |
|
|
1897 | mask |= 0x8; |
|
|
1898 | *last_ext |= 0x80; last_ext = sl.buf + sl.len; SockList_AddChar (&sl, 0x47); |
|
|
1899 | SockList_AddChar (&sl, 4); |
|
|
1900 | SockList_AddInt (&sl, player); |
1849 | } |
1901 | } |
1850 | } |
1902 | } |
1851 | |
1903 | |
1852 | /* Floor face */ |
1904 | /* Floor face */ |
1853 | if (update_space(&sl, &socket, m, nx, ny, ax, ay, 2)) |
1905 | if (update_space(&sl, &socket, m, nx, ny, ax, ay, 2)) |