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.7 by root, Mon Aug 21 07:13:32 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.7 2006/08/21 07:13:32 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 */
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;
1834 1854
1835 // send hp information, if applicable 1855 // send hp information, if applicable
1836 if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0)) 1856 if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0))
1857 if (!op->head
1837 if (op->stats.maxhp > 0 1858 && op->stats.maxhp > 0
1838 && (unsigned)op->stats.maxhp + 1 > (unsigned)op->stats.hp 1859 && (unsigned)op->stats.maxhp > (unsigned)op->stats.hp
1839 && IS_LIVE (op)) 1860 && IS_LIVE (op))
1861 {
1840 stat_hp = 255 - op->stats.hp * 255 / op->stats.maxhp; 1862 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp;
1863 stat_width = op->arch->tail_x;
1864 }
1841 1865
1842 if (lastcell.stat_hp != stat_hp) 1866 if (lastcell.stat_hp != stat_hp)
1843 { 1867 {
1844 lastcell.stat_hp = stat_hp; 1868 lastcell.stat_hp = stat_hp;
1845 1869
1846 mask |= 0x8; 1870 mask |= 0x8;
1847 *last_ext |= 0x80; last_ext = sl.buf + sl.len; SockList_AddChar (&sl, 5); 1871 *last_ext |= 0x80; last_ext = sl.buf + sl.len; SockList_AddChar (&sl, 5);
1848 SockList_AddChar (&sl, stat_hp); 1872 SockList_AddChar (&sl, stat_hp);
1873
1874 if (stat_width > 1)
1875 {
1876 *last_ext |= 0x80; last_ext = sl.buf + sl.len; SockList_AddChar (&sl, 6);
1877 SockList_AddChar (&sl, stat_width);
1878 }
1849 } 1879 }
1850 } 1880 }
1851 1881
1852 /* Floor face */ 1882 /* Floor face */
1853 if (update_space(&sl, &socket, m, nx, ny, ax, ay, 2)) 1883 if (update_space(&sl, &socket, m, nx, ny, ax, ay, 2))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines