… | |
… | |
827 | } |
827 | } |
828 | |
828 | |
829 | static void |
829 | static void |
830 | change_object (object *op) |
830 | change_object (object *op) |
831 | { /* Doesn`t handle linked objs yet */ |
831 | { /* Doesn`t handle linked objs yet */ |
832 | int i, j; |
|
|
833 | |
|
|
834 | if (!op->other_arch) |
832 | if (!op->other_arch) |
835 | { |
833 | { |
836 | LOG (llevError, "Change object (%s) without other_arch error.\n", op->debug_desc ()); |
834 | LOG (llevError, "Change object (%s) without other_arch error.\n", op->debug_desc ()); |
837 | return; |
835 | return; |
838 | } |
836 | } |
… | |
… | |
847 | } |
845 | } |
848 | |
846 | |
849 | object *env = op->env; |
847 | object *env = op->env; |
850 | |
848 | |
851 | op->remove (); |
849 | op->remove (); |
852 | for (i = 0; i < op->stats.food; i++) |
850 | for (int i = 0; i < op->stats.food; i++) |
853 | { |
851 | { |
854 | object *tmp = arch_to_object (op->other_arch); |
852 | object *tmp = op->other_arch->instance (); |
855 | |
853 | |
856 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
854 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
857 | |
855 | |
858 | if (env) |
856 | if (env) |
859 | env->insert (tmp); |
857 | env->insert (tmp); |
860 | else |
858 | else |
861 | { |
859 | { |
862 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
860 | int j = find_first_free_spot (tmp, op->map, op->x, op->y); |
|
|
861 | |
863 | if (j < 0) /* No free spot */ |
862 | if (j < 0) /* No free spot */ |
864 | tmp->destroy (); |
863 | tmp->destroy (); |
865 | else |
864 | else |
866 | { |
865 | { |
867 | mapxy pos (op); pos.move (j); |
866 | mapxy pos (op); pos.move (j); |