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.72 by root, Mon Mar 12 02:07:43 2007 UTC vs.
Revision 1.73 by root, Wed Mar 14 00:04:59 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_smooth (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] & NS_FACESENT_FACE))
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)
1276 else if (smoothlevel < 0) 1192 else if (smoothlevel < 0)
1277 smoothlevel = 0; 1193 smoothlevel = 0;
1278 1194
1279 if (ns.lastmap.cells[sx][sy].smooth[layer] != smoothlevel) 1195 if (ns.lastmap.cells[sx][sy].smooth[layer] != smoothlevel)
1280 { 1196 {
1197 if (smoothlevel)
1198 ns.send_smooth (ob->face);
1199
1281 ns.lastmap.cells[sx][sy].smooth[layer] = smoothlevel; 1200 ns.lastmap.cells[sx][sy].smooth[layer] = smoothlevel;
1282 sl << uint8 (smoothlevel); 1201 sl << uint8 (smoothlevel);
1283 return 1; 1202 return 1;
1284 } 1203 }
1285 1204
1612 if (lastcell.faces[0] != pl->face) 1531 if (lastcell.faces[0] != pl->face)
1613 { 1532 {
1614 lastcell.faces[0] = pl->face; 1533 lastcell.faces[0] = pl->face;
1615 mask |= 0x1; 1534 mask |= 0x1;
1616 1535
1617 if (!(socket.faces_sent[pl->face] & NS_FACESENT_FACE)) 1536 socket.send_faces (pl);
1618 esrv_send_face (&socket, pl->face, 0);
1619 1537
1620 sl << uint16 (pl->face); 1538 sl << uint16 (pl->face);
1621 } 1539 }
1622 } 1540 }
1623 else 1541 else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines