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.163 by elmex, Mon Jul 14 10:26:43 2008 UTC vs.
Revision 1.164 by root, Mon Jul 14 16:42:49 2008 UTC

3500auto_apply (object *op) 3500auto_apply (object *op)
3501{ 3501{
3502 object *tmp = NULL, *tmp2; 3502 object *tmp = NULL, *tmp2;
3503 int i; 3503 int i;
3504 3504
3505 if (INVOKE_OBJECT (AUTO_APPLY, op)) 3505 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
3506 return RESULT_INT (0);
3507 3506
3508 switch (op->type) 3507 switch (op->type)
3509 { 3508 {
3510 case SHOP_FLOOR: 3509 case SHOP_FLOOR:
3511 if (!op->has_random_items ()) 3510 if (!op->has_random_items ())
3513 3512
3514 do 3513 do
3515 { 3514 {
3516 i = 10; /* let's give it 10 tries */ 3515 i = 10; /* let's give it 10 tries */
3517 while ((tmp = generate_treasure (op->randomitems, 3516 while ((tmp = generate_treasure (op->randomitems,
3518 op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); 3517 op->stats.exp
3518 ? (int) op->stats.exp
3519 : max (op->map->difficulty, 5)))
3520 == NULL && --i);
3521
3519 if (tmp == NULL) 3522 if (tmp == NULL)
3520 return 0; 3523 return 0;
3524
3521 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 3525 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
3522 { 3526 {
3523 tmp->destroy (); 3527 tmp->destroy ();
3524 tmp = NULL; 3528 tmp = NULL;
3525 } 3529 }
3528 3532
3529 tmp->x = op->x; 3533 tmp->x = op->x;
3530 tmp->y = op->y; 3534 tmp->y = op->y;
3531 SET_FLAG (tmp, FLAG_UNPAID); 3535 SET_FLAG (tmp, FLAG_UNPAID);
3532 insert_ob_in_map (tmp, op->map, NULL, 0); 3536 insert_ob_in_map (tmp, op->map, NULL, 0);
3533 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
3534 identify (tmp); 3537 identify (tmp);
3535 break; 3538 break;
3536 3539
3537 case TREASURE: 3540 case TREASURE:
3538 if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) 3541 if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE))
3559 } 3562 }
3560 3563
3561 op->destroy (); 3564 op->destroy ();
3562 break; 3565 break;
3563 } 3566 }
3564 return tmp ? 1 : 0; 3567
3568 return !!tmp;
3565} 3569}
3566 3570
3567/** 3571/**
3568 * fix_auto_apply goes through the entire map every time a map 3572 * fix_auto_apply goes through the entire map every time a map
3569 * is loaded or swapped in and performs special actions for 3573 * is loaded or swapped in and performs special actions for
3583 3587
3584 if (tmp->inv) 3588 if (tmp->inv)
3585 { 3589 {
3586 object *invtmp, *invnext; 3590 object *invtmp, *invnext;
3587 3591
3588 for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext) 3592 for (invtmp = tmp->inv; invtmp; invtmp = invnext)
3589 { 3593 {
3590 invnext = invtmp->below; 3594 invnext = invtmp->below;
3591 3595
3592 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) 3596 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY))
3593 auto_apply (invtmp); 3597 auto_apply (invtmp);
3594 else if (invtmp->type == TREASURE && invtmp->has_random_items ()) 3598 else if (invtmp->type == TREASURE && invtmp->has_random_items ())
3595 { 3599 {
3596 while ((invtmp->stats.hp--) > 0) 3600 while (invtmp->stats.hp-- > 0)
3597 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); 3601 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0);
3598 3602
3599 invtmp->randomitems = NULL; 3603 invtmp->randomitems = NULL;
3600 } 3604 }
3601 else if (invtmp && invtmp->arch 3605 else if (invtmp && invtmp->arch

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines