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.145 by root, Fri Dec 26 10:44:17 2008 UTC

404AddMeCmd (char *buf, int len, client *ns) 404AddMeCmd (char *buf, int len, client *ns)
405{ 405{
406 INVOKE_CLIENT (ADDME, ns, ARG_DATA (buf, len)); 406 INVOKE_CLIENT (ADDME, ns, ARG_DATA (buf, len));
407} 407}
408 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}
461
462/* 409/*
463#define MSG_TYPE_BOOK 1 410#define MSG_TYPE_BOOK 1
464#define MSG_TYPE_CARD 2 411#define MSG_TYPE_CARD 2
465#define MSG_TYPE_PAPER 3 412#define MSG_TYPE_PAPER 3
466#define MSG_TYPE_SIGN 4 413#define MSG_TYPE_SIGN 4
984 931
985 /* Nothing changed */ 932 /* Nothing changed */
986 return 0; 933 return 0;
987} 934}
988 935
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 936// prefetch (and touch) all maps within a specific distancd
1009static void 937static void
1010prefetch_surrounding_maps (maptile *map, int distance) 938prefetch_surrounding_maps (maptile *map, int distance)
1011{ 939{
1012 map->last_access = runtime; 940 map->last_access = runtime;
1043 */ 971 */
1044 if (!ob->map || ob->map->in_memory != MAP_ACTIVE) 972 if (!ob->map || ob->map->in_memory != MAP_ACTIVE)
1045 return; 973 return;
1046 974
1047 int startlen, oldlen; 975 int startlen, oldlen;
1048 int estartlen, eoldlen;
1049 uint8 eentrysize;
1050 uint16 ewhatstart, ewhatflag;
1051 uint8 extendedinfos;
1052 976
1053 check_map_change (pl); 977 check_map_change (pl);
1054 prefetch_surrounding_maps (pl->ob); 978 prefetch_surrounding_maps (pl->ob);
1055 979
1056 /* do LOS after calls to update_position */ 980 /* do LOS after calls to update_position */
1085 */ 1009 */
1086 1010
1087 client &socket = *pl->ns; 1011 client &socket = *pl->ns;
1088 1012
1089 packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a"); 1013 packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a");
1090 packet esl;
1091 1014
1092 startlen = sl.length (); 1015 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 1016
1113 int hx = socket.mapx / 2; 1017 int hx = socket.mapx / 2;
1114 int hy = socket.mapy / 2; 1018 int hy = socket.mapy / 2;
1115 1019
1116 ordered_mapwalk_begin (ob, -hx, -hy, hx, hy) 1020 ordered_mapwalk_begin (ob, -hx, -hy, hx, hy)
1117 int ax = dx + hx; 1021 int ax = dx + hx;
1118 int ay = dy + hy; 1022 int ay = dy + hy;
1119 1023
1120 int emask, mask;
1121 emask = mask = (ax << 10) | (ay << 4); 1024 int mask = (ax << 10) | (ay << 4);
1122
1123 MapCell &lastcell = socket.lastmap.cells[ax][ay]; 1025 MapCell &lastcell = socket.lastmap.cells[ax][ay];
1124 1026
1125 /* If the coordinates are not valid, or it is too dark to see, 1027 /* If the coordinates are not valid, or it is too dark to see,
1126 * we tell the client as such 1028 * we tell the client as such
1127 */ 1029 */
1173 * I think this is simpler than doing a bunch of checks to see 1075 * 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 1076 * what if anything we need to send, setting the bits, then
1175 * doing those checks again to add the real data. 1077 * doing those checks again to add the real data.
1176 */ 1078 */
1177 oldlen = sl.length (); 1079 oldlen = sl.length ();
1178 eoldlen = esl.length ();
1179 1080
1180 sl << uint16 (mask); 1081 sl << uint16 (mask);
1181 1082
1182 unsigned char dummy; 1083 unsigned char dummy;
1183 unsigned char *last_ext = &dummy; 1084 unsigned char *last_ext = &dummy;
1310 */ 1211 */
1311 if (mask & 0xf) 1212 if (mask & 0xf)
1312 sl[oldlen + 1] = mask & 0xff; 1213 sl[oldlen + 1] = mask & 0xff;
1313 else 1214 else
1314 sl.reset (oldlen); 1215 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 */ 1216 } /* else this is a viewable space */
1345 ordered_mapwalk_end 1217 ordered_mapwalk_end
1346 1218
1347 socket.flush_fx (); 1219 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 1220
1365 if (sl.length () > startlen || socket.sent_scroll) 1221 if (sl.length () > startlen || socket.sent_scroll)
1366 { 1222 {
1367 socket.send_packet (sl); 1223 socket.send_packet (sl);
1368 socket.sent_scroll = 0; 1224 socket.sent_scroll = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines