… | |
… | |
221 | SET_FLAG (ob1, FLAG_BEEN_APPLIED); |
221 | SET_FLAG (ob1, FLAG_BEEN_APPLIED); |
222 | |
222 | |
223 | if (QUERY_FLAG (ob2, FLAG_IDENTIFIED)) |
223 | if (QUERY_FLAG (ob2, FLAG_IDENTIFIED)) |
224 | SET_FLAG (ob2, FLAG_BEEN_APPLIED); |
224 | SET_FLAG (ob2, FLAG_BEEN_APPLIED); |
225 | |
225 | |
226 | if ((ob1->flags ^ ob2->flags).reset (FLAG_INV_LOCKED).reset (FLAG_CLIENT_SENT).any () |
226 | if ((ob1->flag ^ ob2->flag).reset (FLAG_INV_LOCKED).reset (FLAG_CLIENT_SENT).any () |
227 | || ob1->arch != ob2->arch |
227 | || ob1->arch != ob2->arch |
228 | || ob1->name != ob2->name |
228 | || ob1->name != ob2->name |
229 | || ob1->title != ob2->title |
229 | || ob1->title != ob2->title |
230 | || ob1->msg != ob2->msg |
230 | || ob1->msg != ob2->msg |
231 | || ob1->weight != ob2->weight |
231 | || ob1->weight != ob2->weight |
… | |
… | |
467 | } |
467 | } |
468 | |
468 | |
469 | op->key_values = 0; |
469 | op->key_values = 0; |
470 | } |
470 | } |
471 | |
471 | |
472 | void object::clear () |
|
|
473 | { |
|
|
474 | attachable_base::clear (); |
|
|
475 | |
|
|
476 | free_key_values (this); |
|
|
477 | |
|
|
478 | owner = 0; |
|
|
479 | name = 0; |
|
|
480 | name_pl = 0; |
|
|
481 | title = 0; |
|
|
482 | race = 0; |
|
|
483 | slaying = 0; |
|
|
484 | skill = 0; |
|
|
485 | msg = 0; |
|
|
486 | lore = 0; |
|
|
487 | custom_name = 0; |
|
|
488 | materialname = 0; |
|
|
489 | contr = 0; |
|
|
490 | below = 0; |
|
|
491 | above = 0; |
|
|
492 | inv = 0; |
|
|
493 | container = 0; |
|
|
494 | env = 0; |
|
|
495 | more = 0; |
|
|
496 | head = 0; |
|
|
497 | map = 0; |
|
|
498 | active_next = 0; |
|
|
499 | active_prev = 0; |
|
|
500 | |
|
|
501 | memset (static_cast<object_pod *>(this), 0, sizeof (object_pod)); |
|
|
502 | |
|
|
503 | SET_FLAG (this, FLAG_REMOVED); |
|
|
504 | |
|
|
505 | /* What is not cleared is next, prev, and count */ |
|
|
506 | |
|
|
507 | expmul = 1.0; |
|
|
508 | face = blank_face; |
|
|
509 | |
|
|
510 | if (settings.casting_time) |
|
|
511 | casting_time = -1; |
|
|
512 | } |
|
|
513 | |
|
|
514 | /* |
472 | /* |
515 | * copy_to first frees everything allocated by the dst object, |
473 | * copy_to first frees everything allocated by the dst object, |
516 | * and then copies the contents of itself into the second |
474 | * and then copies the contents of itself into the second |
517 | * object, allocating what needs to be allocated. Basically, any |
475 | * object, allocating what needs to be allocated. Basically, any |
518 | * data that is malloc'd needs to be re-malloc/copied. Otherwise, |
476 | * data that is malloc'd needs to be re-malloc/copied. Otherwise, |
… | |
… | |
524 | { |
482 | { |
525 | bool is_freed = QUERY_FLAG (dst, FLAG_FREED); |
483 | bool is_freed = QUERY_FLAG (dst, FLAG_FREED); |
526 | bool is_removed = QUERY_FLAG (dst, FLAG_REMOVED); |
484 | bool is_removed = QUERY_FLAG (dst, FLAG_REMOVED); |
527 | |
485 | |
528 | *(object_copy *)dst = *this; |
486 | *(object_copy *)dst = *this; |
529 | *(object_pod *)dst = *this; |
|
|
530 | |
487 | |
531 | if (self || cb) |
488 | if (self || cb) |
532 | INVOKE_OBJECT (CLONE, this, ARG_OBJECT (dst)); |
489 | INVOKE_OBJECT (CLONE, this, ARG_OBJECT (dst)); |
533 | |
490 | |
534 | if (is_freed) |
491 | if (is_freed) |
… | |
… | |
1012 | /* NO_FIX_PLAYER is set when a great many changes are being |
969 | /* NO_FIX_PLAYER is set when a great many changes are being |
1013 | * made to players inventory. If set, avoiding the call |
970 | * made to players inventory. If set, avoiding the call |
1014 | * to save cpu time. |
971 | * to save cpu time. |
1015 | */ |
972 | */ |
1016 | if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
973 | if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1017 | fix_player (otmp); |
974 | otmp->update_stats (); |
1018 | |
975 | |
1019 | if (above != NULL) |
976 | if (above != NULL) |
1020 | above->below = below; |
977 | above->below = below; |
1021 | else |
978 | else |
1022 | env->inv = below; |
979 | env->inv = below; |
… | |
… | |
1548 | |
1505 | |
1549 | object * |
1506 | object * |
1550 | decrease_ob_nr (object *op, uint32 i) |
1507 | decrease_ob_nr (object *op, uint32 i) |
1551 | { |
1508 | { |
1552 | object *tmp; |
1509 | object *tmp; |
1553 | player *pl; |
|
|
1554 | |
1510 | |
1555 | if (i == 0) /* objects with op->nrof require this check */ |
1511 | if (i == 0) /* objects with op->nrof require this check */ |
1556 | return op; |
1512 | return op; |
1557 | |
1513 | |
1558 | if (i > op->nrof) |
1514 | if (i > op->nrof) |
… | |
… | |
1571 | * IMO, searching through all the players will mostly |
1527 | * IMO, searching through all the players will mostly |
1572 | * likely be quicker than following op->env to the map, |
1528 | * likely be quicker than following op->env to the map, |
1573 | * and then searching the map for a player. |
1529 | * and then searching the map for a player. |
1574 | */ |
1530 | */ |
1575 | if (!tmp) |
1531 | if (!tmp) |
1576 | { |
1532 | for_all_players (pl) |
1577 | for (pl = first_player; pl; pl = pl->next) |
|
|
1578 | if (pl->ob->container == op->env) |
1533 | if (pl->ob->container == op->env) |
1579 | { |
1534 | { |
1580 | tmp = pl->ob; |
1535 | tmp = pl->ob; |
1581 | break; |
1536 | break; |
1582 | } |
1537 | } |
1583 | } |
|
|
1584 | |
1538 | |
1585 | if (i < op->nrof) |
1539 | if (i < op->nrof) |
1586 | { |
1540 | { |
1587 | sub_weight (op->env, op->weight * i); |
1541 | sub_weight (op->env, op->weight * i); |
1588 | op->nrof -= i; |
1542 | op->nrof -= i; |
… | |
… | |
1724 | add_weight (this, (op->weight + op->carrying)); |
1678 | add_weight (this, (op->weight + op->carrying)); |
1725 | |
1679 | |
1726 | otmp = this->in_player (); |
1680 | otmp = this->in_player (); |
1727 | if (otmp && otmp->contr) |
1681 | if (otmp && otmp->contr) |
1728 | if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1682 | if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1729 | fix_player (otmp); |
1683 | otmp->update_stats (); |
1730 | |
1684 | |
1731 | op->map = 0; |
1685 | op->map = 0; |
1732 | op->env = this; |
1686 | op->env = this; |
1733 | op->above = 0; |
1687 | op->above = 0; |
1734 | op->below = 0; |
1688 | op->below = 0; |