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.144 by root, Fri Dec 26 10:36:42 2008 UTC vs.
Revision 1.146 by root, Sat Dec 27 01:25:00 2008 UTC

208 else if (socket.current_x != ob->x || socket.current_y != ob->y) 208 else if (socket.current_x != ob->x || socket.current_y != ob->y)
209 { 209 {
210 int dx = ob->x - socket.current_x; 210 int dx = ob->x - socket.current_x;
211 int dy = ob->y - socket.current_y; 211 int dy = ob->y - socket.current_y;
212 212
213 if (socket.buggy_mapscroll && (abs (dx) > 8 || abs (dy) > 8))
214 clear_map (pl); // current (<= 1.9.1) clients have unchecked buffer overflows
215 else
216 {
217 socket_map_scroll (&socket, ob->x - socket.current_x, ob->y - socket.current_y); 213 socket_map_scroll (&socket, ob->x - socket.current_x, ob->y - socket.current_y);
218 socket.floorbox_reset (); 214 socket.floorbox_reset ();
219 }
220 } 215 }
221 216
222 socket.current_x = ob->x; 217 socket.current_x = ob->x;
223 socket.current_y = ob->y; 218 socket.current_y = ob->y;
224} 219}
402 */ 397 */
403void 398void
404AddMeCmd (char *buf, int len, client *ns) 399AddMeCmd (char *buf, int len, client *ns)
405{ 400{
406 INVOKE_CLIENT (ADDME, ns, ARG_DATA (buf, len)); 401 INVOKE_CLIENT (ADDME, ns, ARG_DATA (buf, len));
407}
408
409/** Reply to ExtendedInfos command */
410void
411ToggleExtendedInfos (char *buf, int len, client * ns)
412{
413 char cmdback[MAX_BUF];
414 char command[50];
415 int info, nextinfo;
416
417 cmdback[0] = '\0';
418 nextinfo = 0;
419
420 while (1)
421 {
422 /* 1. Extract an info */
423 info = nextinfo;
424
425 while ((info < len) && (buf[info] == ' '))
426 info++;
427
428 if (info >= len)
429 break;
430
431 nextinfo = info + 1;
432
433 while ((nextinfo < len) && (buf[nextinfo] != ' '))
434 nextinfo++;
435
436 if (nextinfo - info >= 49) /*Erroneous info asked */
437 continue;
438
439 strncpy (command, &(buf[info]), nextinfo - info);
440
441 /* 2. Interpret info */
442 if (!strcmp ("smooth", command))
443 /* Toggle smoothing */
444 ns->EMI_smooth = !ns->EMI_smooth;
445 else
446 /*bad value */;
447
448 /*3. Next info */
449 }
450
451 strcpy (cmdback, "ExtendedInfoSet");
452
453 if (ns->EMI_smooth)
454 {
455 strcat (cmdback, " ");
456 strcat (cmdback, "smoothing");
457 }
458
459 ns->send_packet (cmdback);
460} 402}
461 403
462/* 404/*
463#define MSG_TYPE_BOOK 1 405#define MSG_TYPE_BOOK 1
464#define MSG_TYPE_CARD 2 406#define MSG_TYPE_CARD 2
984 926
985 /* Nothing changed */ 927 /* Nothing changed */
986 return 0; 928 return 0;
987} 929}
988 930
989/**
990 * Returns the size of a data for a map square as returned by
991 * mapextended. There are CLIENTMAPX*CLIENTMAPY*LAYERS entries
992 * available.
993 */
994int
995getExtendedMapInfoSize (client * ns)
996{
997 int result = 0;
998
999 if (ns->ext_mapinfos)
1000 {
1001 if (ns->EMI_smooth)
1002 result += 1; /*One byte for smoothlevel */
1003 }
1004
1005 return result;
1006}
1007
1008// prefetch (and touch) all maps within a specific distancd 931// prefetch (and touch) all maps within a specific distancd
1009static void 932static void
1010prefetch_surrounding_maps (maptile *map, int distance) 933prefetch_surrounding_maps (maptile *map, int distance)
1011{ 934{
1012 map->last_access = runtime; 935 map->last_access = runtime;
1043 */ 966 */
1044 if (!ob->map || ob->map->in_memory != MAP_ACTIVE) 967 if (!ob->map || ob->map->in_memory != MAP_ACTIVE)
1045 return; 968 return;
1046 969
1047 int startlen, oldlen; 970 int startlen, oldlen;
1048 int estartlen, eoldlen;
1049 uint8 eentrysize;
1050 uint16 ewhatstart, ewhatflag;
1051 uint8 extendedinfos;
1052 971
1053 check_map_change (pl); 972 check_map_change (pl);
1054 prefetch_surrounding_maps (pl->ob); 973 prefetch_surrounding_maps (pl->ob);
1055 974
1056 /* do LOS after calls to update_position */ 975 /* do LOS after calls to update_position */
1085 */ 1004 */
1086 1005
1087 client &socket = *pl->ns; 1006 client &socket = *pl->ns;
1088 1007
1089 packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a"); 1008 packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a");
1090 packet esl;
1091 1009
1092 startlen = sl.length (); 1010 startlen = sl.length ();
1093
1094 /*Extendedmapinfo structure initialisation */
1095 if (socket.ext_mapinfos)
1096 {
1097 extendedinfos = EMI_NOREDRAW;
1098
1099 if (socket.EMI_smooth)
1100 extendedinfos |= EMI_SMOOTH;
1101
1102 ewhatstart = esl.length ();
1103 ewhatflag = extendedinfos; /*The EMI_NOREDRAW bit
1104 could need to be taken away */
1105 eentrysize = getExtendedMapInfoSize (&socket);
1106 esl << "mapextended "
1107 << uint8 (extendedinfos)
1108 << uint8 (eentrysize);
1109
1110 estartlen = esl.length ();
1111 }
1112 1011
1113 int hx = socket.mapx / 2; 1012 int hx = socket.mapx / 2;
1114 int hy = socket.mapy / 2; 1013 int hy = socket.mapy / 2;
1115 1014
1116 ordered_mapwalk_begin (ob, -hx, -hy, hx, hy) 1015 ordered_mapwalk_begin (ob, -hx, -hy, hx, hy)
1117 int ax = dx + hx; 1016 int ax = dx + hx;
1118 int ay = dy + hy; 1017 int ay = dy + hy;
1119 1018
1120 int emask, mask;
1121 emask = mask = (ax << 10) | (ay << 4); 1019 int mask = (ax << 10) | (ay << 4);
1122
1123 MapCell &lastcell = socket.lastmap.cells[ax][ay]; 1020 MapCell &lastcell = socket.lastmap.cells[ax][ay];
1124 1021
1125 /* If the coordinates are not valid, or it is too dark to see, 1022 /* If the coordinates are not valid, or it is too dark to see,
1126 * we tell the client as such 1023 * we tell the client as such
1127 */ 1024 */
1173 * I think this is simpler than doing a bunch of checks to see 1070 * I think this is simpler than doing a bunch of checks to see
1174 * what if anything we need to send, setting the bits, then 1071 * what if anything we need to send, setting the bits, then
1175 * doing those checks again to add the real data. 1072 * doing those checks again to add the real data.
1176 */ 1073 */
1177 oldlen = sl.length (); 1074 oldlen = sl.length ();
1178 eoldlen = esl.length ();
1179 1075
1180 sl << uint16 (mask); 1076 sl << uint16 (mask);
1181 1077
1182 unsigned char dummy; 1078 unsigned char dummy;
1183 unsigned char *last_ext = &dummy; 1079 unsigned char *last_ext = &dummy;
1184 1080
1185 /* Darkness changed */ 1081 /* Darkness changed */
1186 if (lastcell.count != d && socket.darkness) 1082 if (lastcell.count != d)
1187 { 1083 {
1188 mask |= 0x8; 1084 mask |= 0x8;
1189 1085
1190 if (socket.extmap) 1086 if (socket.extmap)
1191 { 1087 {
1310 */ 1206 */
1311 if (mask & 0xf) 1207 if (mask & 0xf)
1312 sl[oldlen + 1] = mask & 0xff; 1208 sl[oldlen + 1] = mask & 0xff;
1313 else 1209 else
1314 sl.reset (oldlen); 1210 sl.reset (oldlen);
1315
1316 if (socket.ext_mapinfos)
1317 esl << uint16 (emask);
1318
1319 if (socket.EMI_smooth)
1320 {
1321 for (int layer = 2+1; layer--; )
1322 {
1323 object *ob = ms.faces_obj [layer];
1324
1325 // If there is no object for this space, or if the face for the object
1326 // is the blank face, set the smoothlevel to zero.
1327 int smoothlevel = ob && ob->face != blank_face ? ob->smoothlevel : 0;
1328
1329 // We've gotten what face we want to use for the object. Now see if
1330 // if it has changed since we last sent it to the client.
1331 if (lastcell.smooth[layer] != smoothlevel)
1332 {
1333 lastcell.smooth[layer] = smoothlevel;
1334 esl << uint8 (smoothlevel);
1335 emask |= 1 << layer;
1336 }
1337 }
1338
1339 if (emask & 0xf)
1340 esl[eoldlen + 1] = emask & 0xff;
1341 else
1342 esl.reset (eoldlen);
1343 }
1344 } /* else this is a viewable space */ 1211 } /* else this is a viewable space */
1345 ordered_mapwalk_end 1212 ordered_mapwalk_end
1346 1213
1347 socket.flush_fx (); 1214 socket.flush_fx ();
1348
1349 /* Verify that we in fact do need to send this */
1350 if (socket.ext_mapinfos)
1351 {
1352 if (!(sl.length () > startlen || socket.sent_scroll))
1353 {
1354 /* No map data will follow, so don't say the client
1355 * it doesn't need draw!
1356 */
1357 ewhatflag &= ~EMI_NOREDRAW;
1358 esl[ewhatstart + 1] = ewhatflag & 0xff;
1359 }
1360
1361 if (esl.length () > estartlen)
1362 socket.send_packet (esl);
1363 }
1364 1215
1365 if (sl.length () > startlen || socket.sent_scroll) 1216 if (sl.length () > startlen || socket.sent_scroll)
1366 { 1217 {
1367 socket.send_packet (sl); 1218 socket.send_packet (sl);
1368 socket.sent_scroll = 0; 1219 socket.sent_scroll = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines