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.54 by root, Tue Dec 26 08:54:59 2006 UTC vs.
Revision 1.55 by root, Sat Dec 30 10:16:11 2006 UTC

978 else 978 else
979 { 979 {
980 if (converter->other_arch == NULL) 980 if (converter->other_arch == NULL)
981 { 981 {
982 LOG (llevError, "move_creator: Converter doesn't have other arch set: %s (%s, %d, %d)\n", 982 LOG (llevError, "move_creator: Converter doesn't have other arch set: %s (%s, %d, %d)\n",
983 &converter->name, converter->map->path, converter->x, converter->y); 983 &converter->name, &converter->map->path, converter->x, converter->y);
984 return -1; 984 return -1;
985 } 985 }
986 986
987 item = object_create_arch (converter->other_arch); 987 item = object_create_arch (converter->other_arch);
988 fix_generated_item (item, converter, 0, 0, GT_MINIMAL); 988 fix_generated_item (item, converter, 0, 0, GT_MINIMAL);
995 if (is_in_shop (converter)) 995 if (is_in_shop (converter))
996 SET_FLAG (item, FLAG_UNPAID); 996 SET_FLAG (item, FLAG_UNPAID);
997 else if (price_in < item->nrof * item->value) 997 else if (price_in < item->nrof * item->value)
998 { 998 {
999 LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", 999 LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n",
1000 &converter->name, converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); 1000 &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name);
1001 1001
1002 /** 1002 /**
1003 * elmex: we are going to let the game continue, as the mapcreator 1003 * elmex: we are going to let the game continue, as the mapcreator
1004 * propably had something in mind when doing this 1004 * propably had something in mind when doing this
1005 */ 1005 */
1679 /* Basically, don't show exits leading to random maps the 1679 /* Basically, don't show exits leading to random maps the
1680 * players output. 1680 * players output.
1681 */ 1681 */
1682 if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2) && strncmp (EXIT_PATH (trap), "/random/", 8)) 1682 if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2) && strncmp (EXIT_PATH (trap), "/random/", 8))
1683 new_draw_info (NDI_NAVY, 0, victim, trap->msg); 1683 new_draw_info (NDI_NAVY, 0, victim, trap->msg);
1684
1684 enter_exit (victim, trap); 1685 victim->enter_exit (trap);
1685 } 1686 }
1686 goto leave; 1687 goto leave;
1687 1688
1688 case ENCOUNTER: 1689 case ENCOUNTER:
1689 /* may be some leftovers on this */ 1690 /* may be some leftovers on this */
2410 handle_apply_yield (tmp); 2411 handle_apply_yield (tmp);
2411 decrease_ob (tmp); 2412 decrease_ob (tmp);
2412} 2413}
2413 2414
2414/** 2415/**
2415 * This fonction return true if the exit is not a 2 ways one or it is 2 ways, valid exit. 2416 * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit.
2416 * A valid 2 way exit means: 2417 * A valid 2 way exit means:
2417 * -You can come back (there is another exit at the other side) 2418 * -You can come back (there is another exit at the other side)
2418 * -You are 2419 * -You are
2419 * ° the owner of the exit 2420 * ° the owner of the exit
2420 * ° or in the same party as the owner 2421 * ° or in the same party as the owner
2424 * survive in the swapping (in fact the whole exit doesn't survive). 2425 * survive in the swapping (in fact the whole exit doesn't survive).
2425 */ 2426 */
2426int 2427int
2427is_legal_2ways_exit (object *op, object *exit) 2428is_legal_2ways_exit (object *op, object *exit)
2428{ 2429{
2430 if (exit->stats.exp != 1)
2431 return 1; /*This is not a 2 way, so it is legal */
2432
2433#if 0 //TODO
2434 if (!has_been_loaded (EXIT_PATH (exit)) && exit->race)
2435 return 0; /* This is a reset town portal */
2436#endif
2437
2438 maptile *exitmap = exit->map->find_map (EXIT_PATH (exit));
2439
2429 object *tmp; 2440 object *tmp;
2430 object *exit_owner; 2441 object *exit_owner;
2431 maptile *exitmap;
2432
2433 if (exit->stats.exp != 1)
2434 return 1; /*This is not a 2 way, so it is legal */
2435
2436 if (!has_been_loaded (EXIT_PATH (exit)) && exit->race)
2437 return 0; /* This is a reset town portal */
2438
2439 /* To know if an exit has a correspondant, we look at
2440 * all the exits in destination and try to find one with same path as
2441 * the current exit's position */
2442 if (!strncmp (EXIT_PATH (exit), settings.localdir, strlen (settings.localdir)))
2443 exitmap = ready_map_name (EXIT_PATH (exit), MAP_PLAYER_UNIQUE);
2444 else
2445 exitmap = ready_map_name (EXIT_PATH (exit), 0);
2446 2442
2447 if (exitmap) 2443 if (exitmap)
2448 { 2444 {
2449 tmp = GET_MAP_OB (exitmap, EXIT_X (exit), EXIT_Y (exit)); 2445 tmp = GET_MAP_OB (exitmap, EXIT_X (exit), EXIT_Y (exit));
2450 2446
2576 else 2572 else
2577 { 2573 {
2578 /* Don't display messages for random maps. */ 2574 /* Don't display messages for random maps. */
2579 if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2) && strncmp (EXIT_PATH (tmp), "/random/", 8)) 2575 if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2) && strncmp (EXIT_PATH (tmp), "/random/", 8))
2580 new_draw_info (NDI_NAVY, 0, op, tmp->msg); 2576 new_draw_info (NDI_NAVY, 0, op, tmp->msg);
2581 enter_exit (op, tmp); 2577 op->enter_exit (tmp);
2582 } 2578 }
2583 return 1; 2579 return 1;
2584 2580
2585 case SIGN: 2581 case SIGN:
2586 apply_sign (op, tmp, 0); 2582 apply_sign (op, tmp, 0);
3343 } 3339 }
3344 else 3340 else
3345 { 3341 {
3346 if (who->contr->unapply == unapply_never || (i & CAN_APPLY_UNAPPLY_CHOICE && who->contr->unapply == unapply_nochoice)) 3342 if (who->contr->unapply == unapply_never || (i & CAN_APPLY_UNAPPLY_CHOICE && who->contr->unapply == unapply_nochoice))
3347 { 3343 {
3348 new_draw_info (NDI_UNIQUE, 0, who, "You need to unapply some item(s):"); 3344 new_draw_info (NDI_UNIQUE, 0, who, "You need to unapply some of the following item(s) or change your applymode:");
3349 unapply_for_ob (who, op, AP_PRINT); 3345 unapply_for_ob (who, op, AP_PRINT);
3350 return 1; 3346 return 1;
3351 } 3347 }
3352 else if (who->contr->unapply == unapply_always || !(i & CAN_APPLY_UNAPPLY_CHOICE)) 3348 else if (who->contr->unapply == unapply_always || !(i & CAN_APPLY_UNAPPLY_CHOICE))
3353 { 3349 {
3355 if (i) 3351 if (i)
3356 return 1; 3352 return 1;
3357 } 3353 }
3358 } 3354 }
3359 } 3355 }
3356
3360 if (op->skill && op->type != SKILL && op->type != SKILL_TOOL) 3357 if (op->skill && op->type != SKILL && op->type != SKILL_TOOL)
3361 { 3358 {
3362 skop = find_skill_by_name (who, op->skill); 3359 skop = find_skill_by_name (who, op->skill);
3363 if (!skop) 3360 if (!skop)
3364 { 3361 {
3686 * when an original map is loaded) and performs special actions for 3683 * when an original map is loaded) and performs special actions for
3687 * certain objects (most initialization of chests and creation of 3684 * certain objects (most initialization of chests and creation of
3688 * treasures and stuff). Calls auto_apply if appropriate. 3685 * treasures and stuff). Calls auto_apply if appropriate.
3689 */ 3686 */
3690void 3687void
3691fix_auto_apply (maptile *m) 3688maptile::fix_auto_apply ()
3692{ 3689{
3693 object *tmp, *above = NULL; 3690 if (!spaces)
3694 int x, y;
3695
3696 if (m == NULL)
3697 return; 3691 return;
3698 3692
3699 for (x = 0; x < m->width; x++) 3693 for (mapspace *ms = spaces + size (); ms-- > spaces; )
3700 for (y = 0; y < m->height; y++) 3694 for (object *tmp = ms->bot; tmp; )
3701 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above)
3702 { 3695 {
3703 above = tmp->above; 3696 object *above = tmp->above;
3704 3697
3705 if (tmp->inv) 3698 if (tmp->inv)
3706 { 3699 {
3707 object *invtmp, *invnext; 3700 object *invtmp, *invnext;
3708 3701
3709 for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext) 3702 for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext)
3710 { 3703 {
3711 invnext = invtmp->below; 3704 invnext = invtmp->below;
3712 3705
3713 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) 3706 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY))
3714 auto_apply (invtmp); 3707 auto_apply (invtmp);
3715 else if (invtmp->type == TREASURE && invtmp->has_random_items ()) 3708 else if (invtmp->type == TREASURE && invtmp->has_random_items ())
3716 { 3709 {
3717 while ((invtmp->stats.hp--) > 0) 3710 while ((invtmp->stats.hp--) > 0)
3718 create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); 3711 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0);
3719 3712
3720 invtmp->randomitems = NULL; 3713 invtmp->randomitems = NULL;
3721 } 3714 }
3722 else if (invtmp && invtmp->arch 3715 else if (invtmp && invtmp->arch
3723 && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && invtmp->has_random_items ()) 3716 && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && invtmp->has_random_items ())
3724 { 3717 {
3725 create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); 3718 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0);
3726 /* Need to clear this so that we never try to create 3719 /* Need to clear this so that we never try to create
3727 * treasure again for this object 3720 * treasure again for this object
3728 */ 3721 */
3729 invtmp->randomitems = NULL; 3722 invtmp->randomitems = NULL;
3730 } 3723 }
3731 } 3724 }
3732 /* This is really temporary - the code at the bottom will 3725 /* This is really temporary - the code at the bottom will
3733 * also set randomitems to null. The problem is there are bunches 3726 * also set randomitems to null. The problem is there are bunches
3734 * of maps/players already out there with items that have spells 3727 * of maps/players already out there with items that have spells
3735 * which haven't had the randomitems set to null yet. 3728 * which haven't had the randomitems set to null yet.
3736 * MSW 2004-05-13 3729 * MSW 2004-05-13
3737 * 3730 *
3738 * And if it's a spellbook, it's better to set randomitems to NULL too, 3731 * And if it's a spellbook, it's better to set randomitems to NULL too,
3739 * else you get two spells in the book ^_- 3732 * else you get two spells in the book ^_-
3740 * Ryo 2004-08-16 3733 * Ryo 2004-08-16
3741 */ 3734 */
3742 if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL 3735 if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL
3743 || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) 3736 || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK)
3744 tmp->randomitems = NULL;
3745
3746 }
3747
3748 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY))
3749 auto_apply (tmp);
3750 else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ())
3751 {
3752 while ((tmp->stats.hp--) > 0)
3753 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0);
3754 tmp->randomitems = NULL; 3737 tmp->randomitems = NULL;
3738
3755 } 3739 }
3740
3741 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY))
3742 auto_apply (tmp);
3743 else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ())
3744 {
3745 while ((tmp->stats.hp--) > 0)
3746 create_treasure (tmp->randomitems, tmp, 0, difficulty, 0);
3747 tmp->randomitems = NULL;
3748 }
3756 else if (tmp->type == TIMED_GATE) 3749 else if (tmp->type == TIMED_GATE)
3757 { 3750 {
3758 object *head = tmp->head != NULL ? tmp->head : tmp; 3751 object *head = tmp->head != NULL ? tmp->head : tmp;
3759 3752
3760 if (QUERY_FLAG (head, FLAG_IS_LINKED)) 3753 if (QUERY_FLAG (head, FLAG_IS_LINKED))
3761 tmp->set_speed (0); 3754 tmp->set_speed (0);
3762 } 3755 }
3763 /* This function can be called everytime a map is loaded, even when 3756 /* This function can be called everytime a map is loaded, even when
3764 * swapping back in. As such, we don't want to create the treasure 3757 * swapping back in. As such, we don't want to create the treasure
3765 * over and ove again, so after we generate the treasure, blank out 3758 * over and ove again, so after we generate the treasure, blank out
3766 * randomitems so if it is swapped in again, it won't make anything. 3759 * randomitems so if it is swapped in again, it won't make anything.
3767 * This is a problem for the above objects, because they have counters 3760 * This is a problem for the above objects, because they have counters
3768 * which say how many times to make the treasure. 3761 * which say how many times to make the treasure.
3769 */ 3762 */
3770 else if (tmp && tmp->arch && tmp->type != PLAYER 3763 else if (tmp && tmp->arch && tmp->type != PLAYER
3771 && tmp->type != TREASURE && tmp->type != SPELL 3764 && tmp->type != TREASURE && tmp->type != SPELL
3772 && tmp->type != PLAYER_CHANGER && tmp->type != CLASS && tmp->has_random_items ()) 3765 && tmp->type != PLAYER_CHANGER && tmp->type != CLASS && tmp->has_random_items ())
3773 { 3766 {
3774 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); 3767 create_treasure (tmp->randomitems, tmp, GT_APPLY, difficulty, 0);
3775 tmp->randomitems = NULL; 3768 tmp->randomitems = NULL;
3776 } 3769 }
3770
3771 tmp = above;
3777 } 3772 }
3778 3773
3779 for (x = 0; x < m->width; x++) 3774 for (mapspace *ms = spaces + size (); ms-- > spaces; )
3780 for (y = 0; y < m->height; y++) 3775 for (object *tmp = ms->bot; tmp; tmp = tmp->above)
3781 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
3782 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) 3776 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
3783 check_trigger (tmp, tmp->above); 3777 check_trigger (tmp, tmp->above);
3784} 3778}
3785 3779
3786/** 3780/**
3787 * Handles player eating food that temporarily changes status (resistances, stats). 3781 * Handles player eating food that temporarily changes status (resistances, stats).
3788 * This used to call cast_change_attr(), but 3782 * This used to call cast_change_attr(), but

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines