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.4 by root, Fri Aug 18 02:23:28 2006 UTC vs.
Revision 1.8 by root, Thu Aug 24 10:58:39 2006 UTC

1/* 1/*
2 * static char *rcsid_init_c = 2 * static char *rcsid_init_c =
3 * "$Id: request.C,v 1.4 2006/08/18 02:23:28 root Exp $"; 3 * "$Id: request.C,v 1.8 2006/08/24 10:58:39 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
168static void
169clear_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 */
169static void 183static void
170check_map_change (player *pl) 184check_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 */
1828 1847
1829 lastcell.count = d; 1848 lastcell.count = d;
1830 1849
1831 if (socket.extmap) 1850 if (socket.extmap)
1832 { 1851 {
1833 uint8 stat_hp = 0; 1852 uint8 stat_hp = 0;
1853 uint8 stat_width = 0;
1854 tag_t player = 0;
1834 1855
1835 // send hp information, if applicable 1856 // send hp information, if applicable
1836 if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0)) 1857 if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0))
1858 {
1859 if (op->head || op->invisible)
1860 continue;
1861
1862 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 }
1874
1875 if (op->type == PLAYER && op != pl)
1876 player = op->count;
1877 }
1841 1878
1842 if (lastcell.stat_hp != stat_hp) 1879 if (lastcell.stat_hp != stat_hp)
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)
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))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines