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.71 by root, Mon Mar 12 01:13:10 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; */
1420 * but that started to get a bit messy to look at. 1410 * but that started to get a bit messy to look at.
1421 */ 1411 */
1422 max_x = pl->x + (socket.mapx + 1) / 2; 1412 max_x = pl->x + (socket.mapx + 1) / 2;
1423 max_y = pl->y + (socket.mapy + 1) / 2; 1413 max_y = pl->y + (socket.mapy + 1) / 2;
1424 1414
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++) 1415 for (y = pl->y - socket.mapy / 2; y < max_y; y++, ay++)
1432 { 1416 {
1433 ax = 0; 1417 ax = 0;
1434 for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++) 1418 for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++)
1435 { 1419 {
1436 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; 1420 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4;
1437
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 1421
1478 MapCell &lastcell = socket.lastmap.cells[ax][ay]; 1422 MapCell &lastcell = socket.lastmap.cells[ax][ay];
1479 1423
1480 d = pl->contr->blocked_los[ax][ay]; 1424 d = pl->contr->blocked_los[ax][ay];
1481 1425
1503 m->touch (); 1447 m->touch ();
1504 1448
1505 int need_send = 0, count; 1449 int need_send = 0, count;
1506 1450
1507 /* This block deals with spaces that are not visible for whatever 1451 /* This block deals with spaces that are not visible for whatever
1508 * reason. Still may need to send the head for this space. 1452 * reason. Still may need to send the head for this space.
1509 */ 1453 */
1510 1454
1511 oldlen = sl.length (); 1455 oldlen = sl.length ();
1512 1456
1513 sl << uint16 (mask); 1457 sl << uint16 (mask);
1531 } 1475 }
1532 else 1476 else
1533 { 1477 {
1534 m->touch (); 1478 m->touch ();
1535 1479
1536 /* In this block, the space is visible or there are head objects 1480 /* In this block, the space is visible.
1537 * we need to send.
1538 */ 1481 */
1539 1482
1540 /* Rather than try to figure out what everything that we might 1483 /* Rather than try to figure out what everything that we might
1541 * need to send is, then form the packet after that, 1484 * need to send is, then form the packet after that,
1542 * we presume that we will in fact form a packet, and update 1485 * we presume that we will in fact form a packet, and update

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines