ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/apply.C
(Generate patch)

Comparing deliantra/server/server/apply.C (file contents):
Revision 1.266 by root, Tue May 25 02:49:11 2010 UTC vs.
Revision 1.267 by root, Fri Jul 2 18:41:42 2010 UTC

1395apply_special (object *who, object *op, int aflags) 1395apply_special (object *who, object *op, int aflags)
1396{ 1396{
1397 int basic_flag = aflags & AP_MODE; 1397 int basic_flag = aflags & AP_MODE;
1398 object *tmp, *tmp2, *skop = NULL; 1398 object *tmp, *tmp2, *skop = NULL;
1399 1399
1400 if (who == NULL)
1401 {
1402 LOG (llevError, "apply_special() from object without environment.\n");
1403 return 1;
1404 }
1405
1406 //TODO: remove these when apply_special is no longer exposed
1407 if (op->env != who)
1408 return 1; /* op is not in inventory */
1409
1410 /* trying to unequip op */ 1400 /* trying to unequip op */
1411 if (op->flag [FLAG_APPLIED]) 1401 if (op->flag [FLAG_APPLIED])
1412 { 1402 {
1413 /* always apply, so no reason to unapply */ 1403 /* always apply, so no reason to unapply */
1414 if (basic_flag == AP_APPLY) 1404 if (basic_flag == AP_APPLY)
1415 return 0; 1405 return 0;
1416
1417 if (!(aflags & AP_IGNORE_CURSE) && (op->flag [FLAG_CURSED] || op->flag [FLAG_DAMNED]))
1418 {
1419 who->failmsgf ("No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, query_name (op));
1420 return 1;
1421 }
1422 1406
1423 return unapply_special (who, op, aflags); 1407 return unapply_special (who, op, aflags);
1424 } 1408 }
1425 else if (basic_flag == AP_UNAPPLY) 1409 else if (basic_flag == AP_UNAPPLY)
1426 return 0; 1410 return 0;
3348 * them in this function - they are passed to apply_special 3332 * them in this function - they are passed to apply_special
3349 */ 3333 */
3350static bool 3334static bool
3351manual_apply (object *who, object *op, int aflag) 3335manual_apply (object *who, object *op, int aflag)
3352{ 3336{
3353 op = op->head_ ();
3354
3355 if (op->flag [FLAG_UNPAID] && !op->flag [FLAG_APPLIED])
3356 {
3357 if (who->contr)
3358 {
3359 examine (who, op);
3360 //who->failmsg ("You should pay for it first! H<You cannot use items marked as unpaid.>");//TODO remove
3361 return 1;
3362 }
3363 else
3364 return 0; /* monsters just skip unpaid items */
3365 }
3366
3367 if (INVOKE_OBJECT (APPLY, op, ARG_OBJECT (who))) 3337 if (INVOKE_OBJECT (APPLY, op, ARG_OBJECT (who)))
3368 return RESULT_INT (0); 3338 return RESULT_INT (0);
3369 else if (apply_types_inv_only [op->type]) 3339 else if (apply_types_inv_only [op->type])
3370 { 3340 {
3371 // special item, using slot system, needs to be in inv 3341 // special item, using slot system, needs to be in inv
3590object::apply (object *ob, int aflags) 3560object::apply (object *ob, int aflags)
3591{ 3561{
3592 if (!ob) // simplifies a lot of callers 3562 if (!ob) // simplifies a lot of callers
3593 return true; 3563 return true;
3594 3564
3565 ob = ob->head_ ();
3566
3567 if (ob->flag [FLAG_UNPAID] && !ob->flag [FLAG_APPLIED])
3568 {
3569 if (contr)
3570 {
3571 examine (this, ob);
3572 //who->failmsg ("You should pay for it first! H<You cannot use items marked as unpaid.>");//TODO remove
3573 return 1;
3574 }
3575 else
3576 return 0; /* monsters just skip unpaid items */
3577 }
3578
3595 if (contr) 3579 if (contr)
3596 { 3580 {
3597 if (!ob->env && (move_type & MOVE_FLYING)) 3581 if (!ob->env && (move_type & MOVE_FLYING))
3598 { 3582 {
3599 /* player is flying and applying object not in inventory */ 3583 /* player is flying and applying object not in inventory */
3611 3595
3612 bool want_apply = 3596 bool want_apply =
3613 aflags & AP_APPLY ? true 3597 aflags & AP_APPLY ? true
3614 : aflags & AP_UNAPPLY ? false 3598 : aflags & AP_UNAPPLY ? false
3615 : !ob->flag [FLAG_APPLIED]; // AP_TOGGLE 3599 : !ob->flag [FLAG_APPLIED]; // AP_TOGGLE
3600
3601 // cannot unapply cursed items
3602 if (!want_apply
3603 && (ob->flag [FLAG_CURSED] || ob->flag [FLAG_DAMNED])
3604 && ob->flag [FLAG_APPLIED]
3605 && !(aflags & AP_IGNORE_CURSE))
3606 {
3607 failmsgf ("No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, ob->query_name ());
3608 return 0;
3609 }
3616 3610
3617 object_ptr *slot = 0; 3611 object_ptr *slot = 0;
3618 3612
3619 // detect the slot, if this is a player 3613 // detect the slot, if this is a player
3620 if (contr && !(aflags & AP_NO_SLOT)) 3614 if (contr && !(aflags & AP_NO_SLOT))
3696 // only one slot can be active 3690 // only one slot can be active
3697 if (want_apply) 3691 if (want_apply)
3698 { 3692 {
3699 // clear slot unless we are in it already 3693 // clear slot unless we are in it already
3700 if (*slot != ob) 3694 if (*slot != ob)
3701 apply (*slot, AP_UNAPPLY); 3695 if (!apply (*slot, AP_UNAPPLY))
3696 return false;
3702 3697
3703 // unapply other slot, because we want to become active 3698 // unapply other slot, because we want to become active
3704 apply (oslot, AP_UNAPPLY); 3699 if (!apply (oslot, AP_UNAPPLY))
3700 return false;
3705 } 3701 }
3706 3702
3707 // clear item from slot if applied 3703 // clear item from slot if applied
3708 if (!want_apply && current_weapon == ob) 3704 if (!want_apply && current_weapon == ob)
3709 current_weapon = 0; 3705 current_weapon = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines