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.71 by root, Mon Mar 12 01:13:10 2007 UTC vs.
Revision 1.74 by root, Wed Mar 14 01:19:10 2007 UTC

683 683
684 ns->send_packet (cmdback); 684 ns->send_packet (cmdback);
685} 685}
686 686
687/** 687/**
688 * A lot like the old AskSmooth (in fact, now called by AskSmooth).
689 * Basically, it makes no sense to wait for the client to request a
690 * a piece of data from us that we know the client wants. So
691 * if we know the client wants it, might as well push it to the
692 * client.
693 */
694static void
695SendSmooth (client *ns, uint16 face)
696{
697 uint16 smoothface;
698
699 /* If we can't find a face, return and set it so we won't try to send this
700 * again.
701 */
702 if (!FindSmooth (face, &smoothface))
703 {
704
705 LOG (llevError, "could not findsmooth for %d.\n", face);
706 ns->faces_sent[face] |= NS_FACESENT_SMOOTH;
707 return;
708 }
709
710 if (!(ns->faces_sent[smoothface] & NS_FACESENT_FACE))
711 esrv_send_face (ns, smoothface, 0);
712
713 ns->faces_sent[face] |= NS_FACESENT_SMOOTH;
714
715 packet sl ("smooth");
716
717 sl << uint16 (face)
718 << uint16 (smoothface);
719
720 ns->send_packet (sl);
721}
722
723/**
724 * Tells client the picture it has to use 688 * Tells client the picture it has to use
725 * to smooth a picture number given as argument. 689 * to smooth a picture number given as argument.
726 */ 690 */
727void 691void
728AskSmooth (char *buf, int len, client *ns) 692AskSmooth (char *buf, int len, client *ns)
729{ 693{
730 SendSmooth (ns, atoi (buf)); 694 ns->send_face (atoi (buf));
731} 695}
732 696
733/** 697/**
734 * This handles the general commands from the client (ie, north, fire, cast, 698 * This handles the general commands from the client (ie, north, fire, cast,
735 * etc.) 699 * etc.)
1106 1070
1107 pl->ns->last_weight = weight; 1071 pl->ns->last_weight = weight;
1108 pl->ns->send_packet (sl); 1072 pl->ns->send_packet (sl);
1109 SET_FLAG (pl->ob, FLAG_CLIENT_SENT); 1073 SET_FLAG (pl->ob, FLAG_CLIENT_SENT);
1110} 1074}
1111
1112/**
1113 * Need to send an animation sequence to the client.
1114 * We will send appropriate face commands to the client if we haven't
1115 * sent them the face yet (this can become quite costly in terms of
1116 * how much we are sending - on the other hand, this should only happen
1117 * when the player logs in and picks stuff up.
1118 */
1119void
1120esrv_send_animation (client * ns, short anim_num)
1121{
1122 /* Do some checking on the anim_num we got. Note that the animations
1123 * are added in contigous order, so if the number is in the valid
1124 * range, it must be a valid animation.
1125 */
1126 if (anim_num < 0 || anim_num > num_animations)
1127 {
1128 LOG (llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num);
1129 return;
1130 }
1131
1132 packet sl ("anim");
1133
1134 sl << uint16 (anim_num)
1135 << uint16 (0); /* flags - not used right now */
1136
1137 /* Build up the list of faces. Also, send any information (ie, the
1138 * the face itself) down to the client.
1139 */
1140 for (int i = 0; i < animations[anim_num].num_animations; i++)
1141 {
1142 if (!(ns->faces_sent[animations[anim_num].faces[i]] & NS_FACESENT_FACE))
1143 esrv_send_face (ns, animations[anim_num].faces[i], 0);
1144
1145 sl << uint16 (animations[anim_num].faces[i]); /* flags - not used right now */
1146 }
1147
1148 ns->send_packet (sl);
1149
1150 ns->anims_sent[anim_num] = 1;
1151}
1152
1153 1075
1154/****************************************************************************** 1076/******************************************************************************
1155 * 1077 *
1156 * Start of map related commands. 1078 * Start of map related commands.
1157 * 1079 *
1217 * if it has changed since we last sent it to the client. 1139 * if it has changed since we last sent it to the client.
1218 */ 1140 */
1219 if (ns.lastmap.cells[sx][sy].faces[layer] != face_num) 1141 if (ns.lastmap.cells[sx][sy].faces[layer] != face_num)
1220 { 1142 {
1221 ns.lastmap.cells[sx][sy].faces[layer] = face_num; 1143 ns.lastmap.cells[sx][sy].faces[layer] = face_num;
1144
1222 if (!(ns.faces_sent[face_num] & NS_FACESENT_FACE)) 1145 if (!ns.faces_sent[face_num])
1146 if (ob)
1147 ns.send_faces (ob);
1148 else
1223 esrv_send_face (&ns, face_num, 0); 1149 ns.send_face (face_num);
1224 1150
1225 sl << uint16 (face_num); 1151 sl << uint16 (face_num);
1226 return 1; 1152 return 1;
1227 } 1153 }
1228 1154
1249 * take. 1175 * take.
1250 */ 1176 */
1251static inline int 1177static inline int
1252update_smooth (packet &sl, client &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) 1178update_smooth (packet &sl, client &ns, maptile *mp, int mx, int my, int sx, int sy, int layer)
1253{ 1179{
1254 object *ob;
1255 int smoothlevel; /* old face_num; */
1256
1257 ob = GET_MAP_FACE_OBJ (mp, mx, my, layer); 1180 object *ob = GET_MAP_FACE_OBJ (mp, mx, my, layer);
1258 1181
1259 /* If there is no object for this space, or if the face for the object 1182 /* If there is no object for this space, or if the face for the object
1260 * is the blank face, set the smoothlevel to zero. 1183 * is the blank face, set the smoothlevel to zero.
1261 */ 1184 */
1262 if (!ob || ob->face == blank_face) 1185 int smoothlevel = ob && ob->face != blank_face ? ob->smoothlevel : 0;
1263 smoothlevel = 0;
1264 else
1265 {
1266 smoothlevel = ob->smoothlevel;
1267 if (smoothlevel && !(ns.faces_sent[ob->face] & NS_FACESENT_SMOOTH))
1268 SendSmooth (&ns, ob->face);
1269 } /* else not already head object or blank face */
1270 1186
1271 /* We've gotten what face we want to use for the object. Now see if 1187 /* We've gotten what face we want to use for the object. Now see if
1272 * if it has changed since we last sent it to the client. 1188 * if it has changed since we last sent it to the client.
1273 */ 1189 */
1274 if (smoothlevel > 255) 1190 if (smoothlevel > 255)
1351 * look like. 1267 * look like.
1352 */ 1268 */
1353void 1269void
1354draw_client_map1 (object *pl) 1270draw_client_map1 (object *pl)
1355{ 1271{
1356 int x, y, ax, ay, d, startlen, max_x, max_y, oldlen; 1272 int x, y, ax, ay, startlen, max_x, max_y, oldlen;
1357 sint16 nx, ny; 1273 sint16 nx, ny;
1358 int estartlen, eoldlen; 1274 int estartlen, eoldlen;
1359 uint16 mask, emask;
1360 uint8 eentrysize; 1275 uint8 eentrysize;
1361 uint16 ewhatstart, ewhatflag; 1276 uint16 ewhatstart, ewhatflag;
1362 uint8 extendedinfos; 1277 uint8 extendedinfos;
1363 maptile *m; 1278 maptile *m;
1364 1279
1415 for (y = pl->y - socket.mapy / 2; y < max_y; y++, ay++) 1330 for (y = pl->y - socket.mapy / 2; y < max_y; y++, ay++)
1416 { 1331 {
1417 ax = 0; 1332 ax = 0;
1418 for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++) 1333 for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++)
1419 { 1334 {
1335 int emask, mask;
1420 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; 1336 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4;
1421 1337
1422 MapCell &lastcell = socket.lastmap.cells[ax][ay]; 1338 MapCell &lastcell = socket.lastmap.cells[ax][ay];
1423
1424 d = pl->contr->blocked_los[ax][ay];
1425 1339
1426 /* If the coordinates are not valid, or it is too dark to see, 1340 /* If the coordinates are not valid, or it is too dark to see,
1427 * we tell the client as such 1341 * we tell the client as such
1428 */ 1342 */
1429 nx = x; 1343 nx = x;
1439 if (lastcell.count != -1) 1353 if (lastcell.count != -1)
1440 { 1354 {
1441 sl << uint16 (mask); 1355 sl << uint16 (mask);
1442 map_clearcell (&lastcell, -1); 1356 map_clearcell (&lastcell, -1);
1443 } 1357 }
1358
1359 continue;
1444 } 1360 }
1361
1362 m->touch ();
1363
1364 int d = pl->contr->blocked_los[ax][ay];
1365
1445 else if (d > 3) 1366 if (d > 3)
1446 { 1367 {
1447 m->touch ();
1448 1368
1449 int need_send = 0, count; 1369 int need_send = 0, count;
1450 1370
1451 /* This block deals with spaces that are not visible for whatever 1371 /* This block deals with spaces that are not visible for whatever
1452 * reason. Still may need to send the head for this space. 1372 * reason. Still may need to send the head for this space.
1460 need_send = 1; 1380 need_send = 1;
1461 1381
1462 count = -1; 1382 count = -1;
1463 1383
1464 /* properly clear a previously sent big face */ 1384 /* properly clear a previously sent big face */
1465 if (lastcell.faces[0] != 0 || lastcell.faces[1] != 0 || lastcell.faces[2] != 0 1385 if (lastcell.faces[0] || lastcell.faces[1] || lastcell.faces[2]
1466 || lastcell.stat_hp || lastcell.flags || lastcell.player) 1386 || lastcell.stat_hp || lastcell.flags || lastcell.player)
1467 need_send = 1; 1387 need_send = 1;
1468 1388
1469 map_clearcell (&lastcell, count); 1389 map_clearcell (&lastcell, count);
1470 1390
1473 else 1393 else
1474 sl.reset (oldlen); 1394 sl.reset (oldlen);
1475 } 1395 }
1476 else 1396 else
1477 { 1397 {
1478 m->touch ();
1479
1480 /* In this block, the space is visible. 1398 /* In this block, the space is visible.
1481 */ 1399 */
1482 1400
1483 /* Rather than try to figure out what everything that we might 1401 /* Rather than try to figure out what everything that we might
1484 * need to send is, then form the packet after that, 1402 * need to send is, then form the packet after that,
1488 * is done. 1406 * is done.
1489 * I think this is simpler than doing a bunch of checks to see 1407 * I think this is simpler than doing a bunch of checks to see
1490 * what if anything we need to send, setting the bits, then 1408 * what if anything we need to send, setting the bits, then
1491 * doing those checks again to add the real data. 1409 * doing those checks again to add the real data.
1492 */ 1410 */
1493 oldlen = sl.length (); 1411 oldlen = sl.length ();
1494 mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4;
1495 eoldlen = esl.length (); 1412 eoldlen = esl.length ();
1496 emask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; 1413
1497 sl << uint16 (mask); 1414 sl << uint16 (mask);
1498 1415
1499 if (socket.ext_mapinfos) 1416 if (socket.ext_mapinfos)
1500 esl << uint16 (emask); 1417 esl << uint16 (emask);
1501 1418
1611 if (lastcell.faces[0] != pl->face) 1528 if (lastcell.faces[0] != pl->face)
1612 { 1529 {
1613 lastcell.faces[0] = pl->face; 1530 lastcell.faces[0] = pl->face;
1614 mask |= 0x1; 1531 mask |= 0x1;
1615 1532
1616 if (!(socket.faces_sent[pl->face] & NS_FACESENT_FACE)) 1533 socket.send_faces (pl);
1617 esrv_send_face (&socket, pl->face, 0);
1618 1534
1619 sl << uint16 (pl->face); 1535 sl << uint16 (pl->face);
1620 } 1536 }
1621 } 1537 }
1622 else 1538 else
1654 if (!(sl.length () > startlen || socket.sent_scroll)) 1570 if (!(sl.length () > startlen || socket.sent_scroll))
1655 { 1571 {
1656 /* No map data will follow, so don't say the client 1572 /* No map data will follow, so don't say the client
1657 * it doesn't need draw! 1573 * it doesn't need draw!
1658 */ 1574 */
1659 ewhatflag &= (~EMI_NOREDRAW); 1575 ewhatflag &= ~EMI_NOREDRAW;
1660 esl[ewhatstart + 1] = ewhatflag & 0xff; 1576 esl[ewhatstart + 1] = ewhatflag & 0xff;
1661 } 1577 }
1662 1578
1663 if (esl.length () > estartlen) 1579 if (esl.length () > estartlen)
1664 socket.send_packet (esl); 1580 socket.send_packet (esl);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines