… | |
… | |
515 | { |
515 | { |
516 | LOG (llevDebug, "%d allocated objects\n", nrofallocobjects); |
516 | LOG (llevDebug, "%d allocated objects\n", nrofallocobjects); |
517 | } |
517 | } |
518 | |
518 | |
519 | /* |
519 | /* |
520 | * Returns the object which this object marks as being the owner. |
|
|
521 | * A id-scheme is used to avoid pointing to objects which have been |
|
|
522 | * freed and are now reused. If this is detected, the owner is |
|
|
523 | * set to NULL, and NULL is returned. |
|
|
524 | * Changed 2004-02-12 - if the player is setting at the play again |
|
|
525 | * prompt, he is removed, and we don't want to treat him as an owner of |
|
|
526 | * anything, so check removed flag. I don't expect that this should break |
|
|
527 | * anything - once an object is removed, it is basically dead anyways. |
|
|
528 | */ |
|
|
529 | object * |
|
|
530 | object::get_owner () |
|
|
531 | { |
|
|
532 | if (!owner |
|
|
533 | || QUERY_FLAG (owner, FLAG_FREED) |
|
|
534 | || QUERY_FLAG (owner, FLAG_REMOVED)) |
|
|
535 | owner = 0; |
|
|
536 | |
|
|
537 | return owner; |
|
|
538 | } |
|
|
539 | |
|
|
540 | /* |
|
|
541 | * Sets the owner and sets the skill and exp pointers to owner's current |
520 | * Sets the owner and sets the skill and exp pointers to owner's current |
542 | * skill and experience objects. |
521 | * skill and experience objects. |
543 | */ |
522 | */ |
544 | void |
523 | void |
545 | object::set_owner (object *owner) |
524 | object::set_owner (object *owner) |
… | |
… | |
612 | |
591 | |
613 | /* What is not cleared is next, prev, and count */ |
592 | /* What is not cleared is next, prev, and count */ |
614 | |
593 | |
615 | expmul = 1.0; |
594 | expmul = 1.0; |
616 | face = blank_face; |
595 | face = blank_face; |
617 | attacked_by_count = -1; |
|
|
618 | |
596 | |
619 | if (settings.casting_time) |
597 | if (settings.casting_time) |
620 | casting_time = -1; |
598 | casting_time = -1; |
621 | } |
599 | } |
622 | |
600 | |
… | |
… | |
945 | { |
923 | { |
946 | SET_FLAG (this, FLAG_REMOVED); |
924 | SET_FLAG (this, FLAG_REMOVED); |
947 | |
925 | |
948 | expmul = 1.0; |
926 | expmul = 1.0; |
949 | face = blank_face; |
927 | face = blank_face; |
950 | attacked_by_count = -1; |
|
|
951 | } |
928 | } |
952 | |
929 | |
953 | object::~object () |
930 | object::~object () |
954 | { |
931 | { |
955 | free_key_values (this); |
932 | free_key_values (this); |
… | |
… | |
1061 | op = tmp; |
1038 | op = tmp; |
1062 | } |
1039 | } |
1063 | } |
1040 | } |
1064 | } |
1041 | } |
1065 | |
1042 | |
|
|
1043 | // clear those pointers that likely might have circular references to us |
1066 | owner = 0; |
1044 | owner = 0; |
|
|
1045 | enemy = 0; |
|
|
1046 | attacked_by = 0; |
1067 | |
1047 | |
1068 | /* Remove object from the active list */ |
1048 | /* Remove object from the active list */ |
1069 | speed = 0; |
1049 | speed = 0; |
1070 | update_ob_speed (this); |
1050 | update_ob_speed (this); |
1071 | |
1051 | |