… | |
… | |
2805 | * loc is the index into the array we are looking for a match. |
2805 | * loc is the index into the array we are looking for a match. |
2806 | * don't return invisible objects unless they are skill objects |
2806 | * don't return invisible objects unless they are skill objects |
2807 | * invisible other objects that use |
2807 | * invisible other objects that use |
2808 | * up body locations can be used as restrictions. |
2808 | * up body locations can be used as restrictions. |
2809 | */ |
2809 | */ |
2810 | object * |
2810 | static object * |
2811 | get_item_from_body_location (object *start, int loc) |
2811 | get_item_from_body_location (int loc, object *start) |
2812 | { |
2812 | { |
2813 | object *tmp; |
|
|
2814 | |
|
|
2815 | if (!start) |
2813 | if (start) |
2816 | return NULL; |
|
|
2817 | |
|
|
2818 | for (tmp = start; tmp; tmp = tmp->below) |
2814 | for (object *tmp = start; tmp; tmp = tmp->below) |
2819 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->slot[loc].info && (!tmp->invisible || tmp->type == SKILL)) |
2815 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->slot[loc].info && (!tmp->invisible || tmp->type == SKILL)) |
2820 | return tmp; |
2816 | return tmp; |
2821 | |
2817 | |
2822 | return NULL; |
2818 | return 0; |
2823 | } |
2819 | } |
2824 | |
2820 | |
2825 | /** |
2821 | /** |
2826 | * 'op' wants to apply an object, but can't because of other equipment. |
2822 | * 'op' wants to apply an object, but can't because of other equipment. |
2827 | * This should only be called when it is known |
2823 | * This should only be called when it is known |
… | |
… | |
2866 | /* We do a while loop - may need to remove several items in order |
2862 | /* We do a while loop - may need to remove several items in order |
2867 | * to free up enough slots. |
2863 | * to free up enough slots. |
2868 | */ |
2864 | */ |
2869 | while ((who->slot[i].used + op->slot[i].info) < 0) |
2865 | while ((who->slot[i].used + op->slot[i].info) < 0) |
2870 | { |
2866 | { |
2871 | object *tmp = get_item_from_body_location (last, i); |
2867 | object *tmp = get_item_from_body_location (i, last); |
2872 | |
2868 | |
2873 | if (!tmp) |
2869 | if (!tmp) |
2874 | { |
2870 | { |
2875 | #if 0 |
2871 | #if 0 |
2876 | /* Not a bug - we'll get this if the player has cursed items |
2872 | /* Not a bug - we'll get this if the player has cursed items |
… | |
… | |
2947 | /* in this case, equipping this would use more free spots than |
2943 | /* in this case, equipping this would use more free spots than |
2948 | * we have. |
2944 | * we have. |
2949 | */ |
2945 | */ |
2950 | |
2946 | |
2951 | /* if we have an applied weapon/shield, and unapply it would free |
2947 | /* if we have an applied weapon/shield, and unapply it would free |
2952 | * enough slots to equip the new item, then just set this can |
2948 | * enough slots to equip the new item, then just set "can |
2953 | * continue. We don't care about the logic below - if you have |
2949 | * apply unapply". We don't care about the logic below - if you have a |
2954 | * shield equipped and try to equip another shield, there is only |
2950 | * shield equipped and try to equip another shield, there is only |
2955 | * one choice. However, the check for the number of body locations |
2951 | * one choice. However, the check for the number of body locations |
2956 | * does take into the account cases where what is being applied |
2952 | * does take into the account cases where what is being applied |
2957 | * may be two handed for example. |
2953 | * may be two handed for example. |
2958 | */ |
2954 | */ |
… | |
… | |
2963 | retval |= CAN_APPLY_UNAPPLY; |
2959 | retval |= CAN_APPLY_UNAPPLY; |
2964 | continue; |
2960 | continue; |
2965 | } |
2961 | } |
2966 | } |
2962 | } |
2967 | |
2963 | |
2968 | object *tmp1 = get_item_from_body_location (who->inv, i); |
2964 | object *tmp1 = get_item_from_body_location (i, who->inv); |
2969 | if (!tmp1) |
2965 | if (!tmp1) |
2970 | { |
2966 | { |
2971 | #if 0 |
2967 | #if 0 |
2972 | /* This is sort of an error, but happens a lot when old players |
2968 | /* This is sort of an error, but happens a lot when old players |
2973 | * join in with more stuff equipped than they are now allowed. |
2969 | * join in with more stuff equipped than they are now allowed. |