… | |
… | |
2626 | * being applied. |
2626 | * being applied. |
2627 | * |
2627 | * |
2628 | * aflag is special (always apply/unapply) flags. Nothing is done with |
2628 | * aflag is special (always apply/unapply) flags. Nothing is done with |
2629 | * them in this function - they are passed to apply_special |
2629 | * them in this function - they are passed to apply_special |
2630 | */ |
2630 | */ |
2631 | int |
2631 | static int |
2632 | manual_apply (object *who, object *op, int aflag) |
2632 | manual_apply (object *who, object *op, int aflag) |
2633 | { |
2633 | { |
2634 | op = op->head_ (); |
2634 | op = op->head_ (); |
2635 | |
2635 | |
2636 | if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) |
2636 | if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) |
… | |
… | |
3269 | object_ptr *slot = 0; |
3269 | object_ptr *slot = 0; |
3270 | |
3270 | |
3271 | // detect the slot, if this is a player |
3271 | // detect the slot, if this is a player |
3272 | if (contr && !(aflags & AP_NO_SLOT)) |
3272 | if (contr && !(aflags & AP_NO_SLOT)) |
3273 | { |
3273 | { |
|
|
3274 | object *oslot; |
|
|
3275 | |
3274 | switch (ob->type) |
3276 | switch (ob->type) |
3275 | { |
3277 | { |
3276 | case WEAPON: |
3278 | case WEAPON: |
3277 | slot = &contr->combat_ob; |
3279 | slot = &contr->combat_ob; |
|
|
3280 | oslot = contr->ranged_ob; |
3278 | break; |
3281 | break; |
3279 | |
3282 | |
3280 | case BOW: |
3283 | case BOW: |
3281 | case RANGED: |
3284 | case RANGED: |
3282 | case SPELL: |
3285 | case SPELL: |
3283 | case WAND: |
3286 | case WAND: |
3284 | case ROD: |
3287 | case ROD: |
3285 | case HORN: |
3288 | case HORN: |
3286 | case BUILDER: |
3289 | case BUILDER: |
3287 | slot = &contr->ranged_ob; |
3290 | slot = &contr->ranged_ob; |
|
|
3291 | oslot = contr->combat_ob; |
3288 | break; |
3292 | break; |
3289 | |
3293 | |
3290 | // oh, the humanity |
3294 | // oh, the humanity |
3291 | case SKILL: |
3295 | case SKILL: |
3292 | if (aflags & AP_NO_SLOT) |
3296 | if (aflags & AP_NO_SLOT) |
… | |
… | |
3294 | |
3298 | |
3295 | if (skill_flags [ob->subtype] & SF_NEED_ITEM) |
3299 | if (skill_flags [ob->subtype] & SF_NEED_ITEM) |
3296 | break; |
3300 | break; |
3297 | |
3301 | |
3298 | if (skill_flags [ob->subtype] & SF_COMBAT) |
3302 | if (skill_flags [ob->subtype] & SF_COMBAT) |
|
|
3303 | { |
3299 | slot = &contr->combat_ob; |
3304 | slot = &contr->combat_ob; |
|
|
3305 | oslot = contr->ranged_ob; |
|
|
3306 | } |
3300 | else if (skill_flags [ob->subtype] & SF_RANGED) |
3307 | else if (skill_flags [ob->subtype] & SF_RANGED) |
|
|
3308 | { |
3301 | slot = &contr->ranged_ob; |
3309 | slot = &contr->ranged_ob; |
|
|
3310 | oslot = contr->combat_ob; |
|
|
3311 | } |
3302 | |
3312 | |
3303 | break; |
3313 | break; |
3304 | } |
3314 | } |
3305 | |
3315 | |
|
|
3316 | // now handle slot exclusions |
|
|
3317 | if (slot) |
|
|
3318 | { |
|
|
3319 | // only one slot can be active |
|
|
3320 | if (want_apply) |
|
|
3321 | apply (oslot, AP_UNAPPLY); |
|
|
3322 | |
3306 | // clear item from slot if applied |
3323 | // clear item from slot if applied |
3307 | if (slot && *slot == ob && !want_apply) |
3324 | if (!want_apply && *slot == ob) |
3308 | { |
3325 | { |
3309 | *slot = 0; |
3326 | *slot = 0; |
3310 | |
3327 | |
3311 | if (current_weapon == ob) |
3328 | if (current_weapon == ob) |
3312 | current_weapon = 0; |
3329 | current_weapon = 0; |
|
|
3330 | } |
3313 | } |
3331 | } |
3314 | } |
3332 | } |
3315 | |
3333 | |
3316 | if (ob->flag [FLAG_APPLIED] != want_apply) |
3334 | if (ob->flag [FLAG_APPLIED] != want_apply) |
3317 | manual_apply (this, ob, aflags); |
3335 | manual_apply (this, ob, aflags); |