ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/item.C
(Generate patch)

Comparing deliantra/server/socket/item.C (file contents):
Revision 1.60 by root, Tue Apr 22 07:01:47 2008 UTC vs.
Revision 1.63 by root, Thu Apr 24 00:30:52 2008 UTC

193query_flags (object *op) 193query_flags (object *op)
194{ 194{
195 unsigned int flags = 0; 195 unsigned int flags = 0;
196 196
197 if (QUERY_FLAG (op, FLAG_APPLIED)) 197 if (QUERY_FLAG (op, FLAG_APPLIED))
198 {
199 switch (op->type) 198 switch (op->type)
200 { 199 {
201 case BOW: 200 case BOW:
202 case WAND: 201 case WAND:
203 case ROD: 202 case ROD:
204 case HORN: 203 case HORN:
205 flags = a_readied; 204 flags = a_readied;
206 break; 205 break;
207 case WEAPON: 206 case WEAPON:
208 flags = a_wielded; 207 flags = a_wielded;
209 break; 208 break;
210 case SKILL: 209 case SKILL:
211 case ARMOUR: 210 case ARMOUR:
212 case HELMET: 211 case HELMET:
213 case SHIELD: 212 case SHIELD:
214 case RING: 213 case RING:
215 case BOOTS: 214 case BOOTS:
216 case GLOVES: 215 case GLOVES:
217 case AMULET: 216 case AMULET:
218 case GIRDLE: 217 case GIRDLE:
219 case BRACERS: 218 case BRACERS:
220 case CLOAK: 219 case CLOAK:
221 flags = a_worn; 220 flags = a_worn;
222 break; 221 break;
223 case CONTAINER: 222 case CONTAINER:
224 flags = a_active; 223 flags = a_active;
225 break; 224 break;
226 default: 225 default:
227 flags = a_applied; 226 flags = a_applied;
228 break; 227 break;
229 } 228 }
230 }
231 229
232 if (op->type == CONTAINER && ((op->env && op->env->container == op) || (!op->env && QUERY_FLAG (op, FLAG_APPLIED)))) 230 if (op->type == CONTAINER && ((op->env && op->env->container == op) || (!op->env && QUERY_FLAG (op, FLAG_APPLIED))))
233 flags |= F_OPEN; 231 flags |= F_OPEN;
234 232
235 if (QUERY_FLAG (op, FLAG_KNOWN_CURSED)) 233 if (QUERY_FLAG (op, FLAG_KNOWN_CURSED))
341 if (!pl->ns->update_look) 339 if (!pl->ns->update_look)
342 { 340 {
343 LOG (llevDebug, "esrv_draw_look called when update_look was not set (player %s)\n", &ob->name); 341 LOG (llevDebug, "esrv_draw_look called when update_look was not set (player %s)\n", &ob->name);
344 return; 342 return;
345 } 343 }
346 else 344
347 pl->ns->update_look = 0; 345 pl->ns->update_look = 0;
348 346
349 if (QUERY_FLAG (ob, FLAG_REMOVED) 347 if (QUERY_FLAG (ob, FLAG_REMOVED)
350 || !ob->map 348 || !ob->map
351 || ob->map->in_memory != MAP_ACTIVE 349 || ob->map->in_memory != MAP_ACTIVE
352 || out_of_map (ob->map, ob->x, ob->y)) 350 || out_of_map (ob->map, ob->x, ob->y))
381 } 379 }
382 380
383 object *tmp = ob->ms ().top; 381 object *tmp = ob->ms ().top;
384 for (object *last = 0; tmp != last; tmp = tmp->below) 382 for (object *last = 0; tmp != last; tmp = tmp->below)
385 { 383 {
386 object *head;
387
388 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !last) 384 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !last)
389 { 385 {
390 last = tmp->below; /* assumes double floor mode */ 386 last = tmp->below; /* assumes double floor mode */
391 if (last && QUERY_FLAG (last, FLAG_IS_FLOOR)) 387 if (last && QUERY_FLAG (last, FLAG_IS_FLOOR))
392 last = last->below; 388 last = last->below;
417 sl << uint16 (0); 413 sl << uint16 (0);
418 414
419 break; 415 break;
420 } 416 }
421 417
422 if (tmp->head)
423 head = tmp->head;
424 else
425 head = tmp;
426
427 add_object_to_socklist (*pl->ns, sl, head); 418 add_object_to_socklist (*pl->ns, sl, tmp->head_ ());
428 got_one++; 419 got_one++;
429 420
430 if (sl.length () > MAXSOCKBUF - MAXITEMLEN) 421 if (sl.length () > MAXSOCKBUF - MAXITEMLEN)
431 { 422 {
432 pl->ns->send_packet (sl); 423 pl->ns->send_packet (sl);
506 */ 497 */
507void 498void
508esrv_update_item (int flags, object *pl, object *op) 499esrv_update_item (int flags, object *pl, object *op)
509{ 500{
510 /* If we have a request to send the player item, skip a few checks. */ 501 /* If we have a request to send the player item, skip a few checks. */
511 if (op != pl)
512 {
513 if (!op->client_visible ()) 502 if (op != pl && !op->client_visible ())
514 return; 503 return;
515 /* we remove the check for op->env, because in theory, the object
516 * is hopefully in the same place, so the client should preserve
517 * order.
518 */
519 }
520 504
521 client *ns = pl->contr->ns; 505 client *ns = pl->contr->ns;
522 if (!ns) 506 if (!ns)
523 return; 507 return;
524 508
533 517
534 packet sl ("upditem"); 518 packet sl ("upditem");
535 519
536 sl << uint8 (flags); 520 sl << uint8 (flags);
537 521
538 if (op->head)
539 op = op->head; 522 op = op->head_ ();
540 523
541 sl << uint32 (op->count); 524 sl << uint32 (op->count);
542 525
543 if (flags & UPD_LOCATION) 526 if (flags & UPD_LOCATION)
544 sl << uint32 (op->env ? op->env->count : 0); 527 sl << uint32 (op->env ? op->env->count : 0);
546 if (flags & UPD_FLAGS) 529 if (flags & UPD_FLAGS)
547 sl << uint32 (query_flags (op)); 530 sl << uint32 (query_flags (op));
548 531
549 if (flags & UPD_WEIGHT) 532 if (flags & UPD_WEIGHT)
550 { 533 {
551 sint32 weight = op->client_weight (); 534 sint32 weight = op->flag [FLAG_NO_PICK] ? -1 : op->client_weight ();
552 535
553 sl << uint32 (QUERY_FLAG (op, FLAG_NO_PICK) ? -1 : weight);
554
555#if 0
556 if (pl == op) 536 if (op)
557 ns->last_weight = weight; 537 ns->last_weight = weight;
558#endif 538
539 sl << uint32 (weight);
559 } 540 }
560 541
561 if (flags & UPD_FACE) 542 if (flags & UPD_FACE)
562 { 543 {
563 ns->send_face (op->face, -50); 544 ns->send_face (op->face, -50);
634esrv_send_item (object *pl, object *op) 615esrv_send_item (object *pl, object *op)
635{ 616{
636 if (!pl->contr->ns) 617 if (!pl->contr->ns)
637 return; 618 return;
638 619
639 /* If this is not the player object, do some more checks */
640 if (op != pl)
641 {
642 /* We only send 'visible' objects to the client */ 620 /* We only send 'visible' objects to the client, and sometimes the player */
643 if (!op->client_visible ()) 621 if (!op->client_visible () && op->type != PLAYER)
644 return; 622 return;
645
646 /* if the item is on the ground, mark that the look needs to
647 * be updated.
648 */
649 if (!op->env)
650 {
651 pl->contr->ns->floorbox_update ();
652 return;
653 }
654 }
655 623
656 packet sl; 624 packet sl;
657 625
658 sl.printf ("item%d ", pl->contr->ns->itemcmd); 626 sl.printf ("item%d ", pl->contr->ns->itemcmd);
659 627
660 if (op->head)
661 op = op->head; 628 op = op->head_ ();
662 629
663 sl << uint32 (op->env ? op->env->count : 0); 630 sl << uint32 (op->env ? op->env->count : 0);
664 631
665 add_object_to_socklist (*pl->contr->ns, sl, op); 632 add_object_to_socklist (*pl->contr->ns, sl, op);
666 633
943 op->failmsg ("Only dropped some items, can't drop that many items at once."); 910 op->failmsg ("Only dropped some items, can't drop that many items at once.");
944 } 911 }
945 else 912 else
946 drop_object (pl, op, nrof); 913 drop_object (pl, op, nrof);
947 914
948 update_after_inventory_change (pl);
949
950 return; 915 return;
951 } 916 }
952 else if (to == pl->count) 917 else if (to == pl->count)
953 { /* pick it up to the inventory */ 918 { /* pick it up to the inventory */
954 /* return if player has already picked it up */ 919 /* return if player has already picked it up */
970 /* put_object_in_sack presumes that necessary sanity checking 935 /* put_object_in_sack presumes that necessary sanity checking
971 * has already been done (eg, it can be picked up and fits in 936 * has already been done (eg, it can be picked up and fits in
972 * in a sack, so check for those things. We should also check 937 * in a sack, so check for those things. We should also check
973 * an make sure env is in fact a container for that matter. 938 * an make sure env is in fact a container for that matter.
974 */ 939 */
975 if (env->type == CONTAINER && can_pick (pl, op) && sack_can_hold (pl, env, op, nrof)) 940 if (env->type == CONTAINER
976 { 941 && can_pick (pl, op)
942 && sack_can_hold (pl, env, op, nrof))
977 put_object_in_sack (pl, env, op, nrof); 943 put_object_in_sack (pl, env, op, nrof);
978 update_after_inventory_change (pl);
979 }
980} 944}
981 945

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines