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.70 by root, Sun Mar 11 21:26:05 2007 UTC vs.
Revision 1.72 by root, Mon Mar 12 02:07:43 2007 UTC

97 * complexities for the client, and probably doesn't make 97 * complexities for the client, and probably doesn't make
98 * that much difference in bandwidth. 98 * that much difference in bandwidth.
99 */ 99 */
100 mx = ns->mapx; 100 mx = ns->mapx;
101 my = ns->mapy; 101 my = ns->mapy;
102
103 if (ns->mapmode == Map1aCmd)
104 {
105 mx += MAX_HEAD_OFFSET;
106 my += MAX_HEAD_OFFSET;
107 }
108 102
109 /* the x and y here are coordinates for the new map, i.e. if we moved 103 /* the x and y here are coordinates for the new map, i.e. if we moved
110 * (dx,dy), newmap[x][y] = oldmap[x-dx][y-dy]. For this reason, 104 * (dx,dy), newmap[x][y] = oldmap[x-dx][y-dy]. For this reason,
111 * if the destination x or y coordinate is outside the viewable 105 * if the destination x or y coordinate is outside the viewable
112 * area, we clear the values - otherwise, the old values 106 * area, we clear the values - otherwise, the old values
437 } 431 }
438 else if (!strcmp (cmd, "newmapcmd")) 432 else if (!strcmp (cmd, "newmapcmd"))
439 { 433 {
440 ns->newmapcmd = atoi (param); 434 ns->newmapcmd = atoi (param);
441 safe_strcat (cmdback, param, &slen, HUGE_BUF); 435 safe_strcat (cmdback, param, &slen, HUGE_BUF);
442// } else if (!strcmp(cmd,"plugincmd")) {
443// ns->plugincmd = atoi(param);
444// safe_strcat(cmdback, param, &slen, HUGE_BUF);
445 } 436 }
446 else if (!strcmp (cmd, "mapinfocmd")) 437 else if (!strcmp (cmd, "mapinfocmd"))
447 { 438 {
448 ns->mapinfocmd = atoi (param); 439 ns->mapinfocmd = atoi (param);
449 safe_strcat (cmdback, "1", &slen, HUGE_BUF); 440 safe_strcat (cmdback, "1", &slen, HUGE_BUF);
505 if (*cp == 'x' || *cp == 'X') 496 if (*cp == 'x' || *cp == 'X')
506 { 497 {
507 y = atoi (cp + 1); 498 y = atoi (cp + 1);
508 break; 499 break;
509 } 500 }
501
510 if (x < 9 || y < 9 || x > MAP_CLIENT_X || y > MAP_CLIENT_Y) 502 if (x < 9 || y < 9 || x > MAP_CLIENT_X || y > MAP_CLIENT_Y)
511 { 503 {
512 sprintf (tmpbuf, " %dx%d", MAP_CLIENT_X, MAP_CLIENT_Y); 504 sprintf (tmpbuf, " %dx%d", MAP_CLIENT_X, MAP_CLIENT_Y);
513 safe_strcat (cmdback, tmpbuf, &slen, HUGE_BUF); 505 safe_strcat (cmdback, tmpbuf, &slen, HUGE_BUF);
514 } 506 }
880 ns->cs_version = atoi (buf); 872 ns->cs_version = atoi (buf);
881 ns->sc_version = ns->cs_version; 873 ns->sc_version = ns->cs_version;
882 874
883 LOG (llevDebug, "connection from client <%s>\n", buf); 875 LOG (llevDebug, "connection from client <%s>\n", buf);
884 876
885
886 //TODO: should log here just for statistics 877 //TODO: should log here just for statistics
887 878
888 //if (VERSION_CS != ns->cs_version) 879 //if (VERSION_CS != ns->cs_version)
889 // unchecked; 880 // unchecked;
890 881
1255 * holds the old values. 1246 * holds the old values.
1256 * layer is the layer to update, with 2 being the floor and 0 the 1247 * layer is the layer to update, with 2 being the floor and 0 the
1257 * top layer (this matches what the GET_MAP_FACE and GET_MAP_FACE_OBJ 1248 * top layer (this matches what the GET_MAP_FACE and GET_MAP_FACE_OBJ
1258 * take. 1249 * take.
1259 */ 1250 */
1260
1261static inline int 1251static inline int
1262update_smooth (packet &sl, client &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) 1252update_smooth (packet &sl, client &ns, maptile *mp, int mx, int my, int sx, int sy, int layer)
1263{ 1253{
1264 object *ob; 1254 object *ob;
1265 int smoothlevel; /* old face_num; */ 1255 int smoothlevel; /* old face_num; */
1361 * look like. 1351 * look like.
1362 */ 1352 */
1363void 1353void
1364draw_client_map1 (object *pl) 1354draw_client_map1 (object *pl)
1365{ 1355{
1366 int x, y, ax, ay, d, startlen, max_x, max_y, oldlen; 1356 int x, y, ax, ay, startlen, max_x, max_y, oldlen;
1367 sint16 nx, ny; 1357 sint16 nx, ny;
1368 int estartlen, eoldlen; 1358 int estartlen, eoldlen;
1369 uint16 mask, emask;
1370 uint8 eentrysize; 1359 uint8 eentrysize;
1371 uint16 ewhatstart, ewhatflag; 1360 uint16 ewhatstart, ewhatflag;
1372 uint8 extendedinfos; 1361 uint8 extendedinfos;
1373 maptile *m; 1362 maptile *m;
1374 1363
1420 * but that started to get a bit messy to look at. 1409 * but that started to get a bit messy to look at.
1421 */ 1410 */
1422 max_x = pl->x + (socket.mapx + 1) / 2; 1411 max_x = pl->x + (socket.mapx + 1) / 2;
1423 max_y = pl->y + (socket.mapy + 1) / 2; 1412 max_y = pl->y + (socket.mapy + 1) / 2;
1424 1413
1425 if (socket.mapmode == Map1aCmd)
1426 {
1427 max_x += MAX_HEAD_OFFSET;
1428 max_y += MAX_HEAD_OFFSET;
1429 }
1430
1431 for (y = pl->y - socket.mapy / 2; y < max_y; y++, ay++) 1414 for (y = pl->y - socket.mapy / 2; y < max_y; y++, ay++)
1432 { 1415 {
1433 ax = 0; 1416 ax = 0;
1434 for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++) 1417 for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++)
1435 { 1418 {
1419 int emask, mask;
1436 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; 1420 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4;
1437 1421
1438 /* If this space is out of the normal viewable area, we only check
1439 * the heads value ax or ay will only be greater than what
1440 * the client wants if using the map1a command - this is because
1441 * if the map1a command is not used, max_x and max_y will be
1442 * set to lower values.
1443 */
1444 if (ax >= socket.mapx || ay >= socket.mapy)
1445 {
1446 int i, got_one;
1447
1448 oldlen = sl.length ();
1449
1450 sl << uint16 (mask);
1451
1452 /* If all we are doing is sending 0 (blank) faces, we don't
1453 * actually need to send that - just the coordinates
1454 * with no faces tells the client to blank out the
1455 * space.
1456 */
1457 got_one = 0;
1458 for (i = oldlen + 2; i < sl.length (); i++)
1459 if (sl[i])
1460 got_one = 1;
1461
1462 if (got_one && (mask & 0xf))
1463 sl[oldlen + 1] = mask & 0xff;
1464 else
1465 { /*either all faces blank, either no face at all */
1466 if (mask & 0xf) /*at least 1 face, we know it's blank, only send coordinates */
1467 sl.reset (oldlen + 2);
1468 else
1469 sl.reset (oldlen);
1470 }
1471
1472 /*What concerns extendinfos, nothing to be done for now
1473 * (perhaps effects layer later)
1474 */
1475 continue; /* don't do processing below */
1476 }
1477
1478 MapCell &lastcell = socket.lastmap.cells[ax][ay]; 1422 MapCell &lastcell = socket.lastmap.cells[ax][ay];
1479
1480 d = pl->contr->blocked_los[ax][ay];
1481 1423
1482 /* If the coordinates are not valid, or it is too dark to see, 1424 /* If the coordinates are not valid, or it is too dark to see,
1483 * we tell the client as such 1425 * we tell the client as such
1484 */ 1426 */
1485 nx = x; 1427 nx = x;
1495 if (lastcell.count != -1) 1437 if (lastcell.count != -1)
1496 { 1438 {
1497 sl << uint16 (mask); 1439 sl << uint16 (mask);
1498 map_clearcell (&lastcell, -1); 1440 map_clearcell (&lastcell, -1);
1499 } 1441 }
1442
1443 continue;
1500 } 1444 }
1445
1446 m->touch ();
1447
1448 int d = pl->contr->blocked_los[ax][ay];
1449
1501 else if (d > 3) 1450 if (d > 3)
1502 { 1451 {
1503 m->touch ();
1504 1452
1505 int need_send = 0, count; 1453 int need_send = 0, count;
1506 1454
1507 /* This block deals with spaces that are not visible for whatever 1455 /* This block deals with spaces that are not visible for whatever
1508 * reason. Still may need to send the head for this space. 1456 * reason. Still may need to send the head for this space.
1509 */ 1457 */
1510 1458
1511 oldlen = sl.length (); 1459 oldlen = sl.length ();
1512 1460
1513 sl << uint16 (mask); 1461 sl << uint16 (mask);
1516 need_send = 1; 1464 need_send = 1;
1517 1465
1518 count = -1; 1466 count = -1;
1519 1467
1520 /* properly clear a previously sent big face */ 1468 /* properly clear a previously sent big face */
1521 if (lastcell.faces[0] != 0 || lastcell.faces[1] != 0 || lastcell.faces[2] != 0 1469 if (lastcell.faces[0] || lastcell.faces[1] || lastcell.faces[2]
1522 || lastcell.stat_hp || lastcell.flags || lastcell.player) 1470 || lastcell.stat_hp || lastcell.flags || lastcell.player)
1523 need_send = 1; 1471 need_send = 1;
1524 1472
1525 map_clearcell (&lastcell, count); 1473 map_clearcell (&lastcell, count);
1526 1474
1529 else 1477 else
1530 sl.reset (oldlen); 1478 sl.reset (oldlen);
1531 } 1479 }
1532 else 1480 else
1533 { 1481 {
1534 m->touch ();
1535
1536 /* In this block, the space is visible or there are head objects 1482 /* In this block, the space is visible.
1537 * we need to send.
1538 */ 1483 */
1539 1484
1540 /* Rather than try to figure out what everything that we might 1485 /* Rather than try to figure out what everything that we might
1541 * need to send is, then form the packet after that, 1486 * need to send is, then form the packet after that,
1542 * we presume that we will in fact form a packet, and update 1487 * we presume that we will in fact form a packet, and update
1545 * is done. 1490 * is done.
1546 * I think this is simpler than doing a bunch of checks to see 1491 * I think this is simpler than doing a bunch of checks to see
1547 * what if anything we need to send, setting the bits, then 1492 * what if anything we need to send, setting the bits, then
1548 * doing those checks again to add the real data. 1493 * doing those checks again to add the real data.
1549 */ 1494 */
1550 oldlen = sl.length (); 1495 oldlen = sl.length ();
1551 mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4;
1552 eoldlen = esl.length (); 1496 eoldlen = esl.length ();
1553 emask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; 1497
1554 sl << uint16 (mask); 1498 sl << uint16 (mask);
1555 1499
1556 if (socket.ext_mapinfos) 1500 if (socket.ext_mapinfos)
1557 esl << uint16 (emask); 1501 esl << uint16 (emask);
1558 1502
1711 if (!(sl.length () > startlen || socket.sent_scroll)) 1655 if (!(sl.length () > startlen || socket.sent_scroll))
1712 { 1656 {
1713 /* No map data will follow, so don't say the client 1657 /* No map data will follow, so don't say the client
1714 * it doesn't need draw! 1658 * it doesn't need draw!
1715 */ 1659 */
1716 ewhatflag &= (~EMI_NOREDRAW); 1660 ewhatflag &= ~EMI_NOREDRAW;
1717 esl[ewhatstart + 1] = ewhatflag & 0xff; 1661 esl[ewhatstart + 1] = ewhatflag & 0xff;
1718 } 1662 }
1719 1663
1720 if (esl.length () > estartlen) 1664 if (esl.length () > estartlen)
1721 socket.send_packet (esl); 1665 socket.send_packet (esl);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines