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.51 by root, Fri Dec 22 16:34:00 2006 UTC vs.
Revision 1.63 by root, Mon Jan 29 15:36:25 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
3 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2001 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 *
21 The authors can be reached via e-mail to <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
22*/ 23 */
23 24
24#include <global.h> 25#include <global.h>
25#include <living.h> 26#include <living.h>
26#include <spells.h> 27#include <spells.h>
27#include <skills.h> 28#include <skills.h>
978 else 979 else
979 { 980 {
980 if (converter->other_arch == NULL) 981 if (converter->other_arch == NULL)
981 { 982 {
982 LOG (llevError, "move_creator: Converter doesn't have other arch set: %s (%s, %d, %d)\n", 983 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); 984 &converter->name, &converter->map->path, converter->x, converter->y);
984 return -1; 985 return -1;
985 } 986 }
986 987
987 item = object_create_arch (converter->other_arch); 988 item = object_create_arch (converter->other_arch);
988 fix_generated_item (item, converter, 0, 0, GT_MINIMAL); 989 fix_generated_item (item, converter, 0, 0, GT_MINIMAL);
995 if (is_in_shop (converter)) 996 if (is_in_shop (converter))
996 SET_FLAG (item, FLAG_UNPAID); 997 SET_FLAG (item, FLAG_UNPAID);
997 else if (price_in < item->nrof * item->value) 998 else if (price_in < item->nrof * item->value)
998 { 999 {
999 LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", 1000 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); 1001 &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name);
1001 1002
1002 /** 1003 /**
1003 * elmex: we are going to let the game continue, as the mapcreator 1004 * elmex: we are going to let the game continue, as the mapcreator
1004 * propably had something in mind when doing this 1005 * propably had something in mind when doing this
1005 */ 1006 */
1627 1628
1628 1629
1629 case CONVERTER: 1630 case CONVERTER:
1630 if (convert_item (victim, trap) < 0) 1631 if (convert_item (victim, trap) < 0)
1631 { 1632 {
1632 object *op;
1633
1634 new_draw_info_format (NDI_UNIQUE, 0, originator, "The %s seems to be broken!", query_name (trap)); 1633 new_draw_info_format (NDI_UNIQUE, 0, originator, "The %s seems to be broken!", query_name (trap));
1635 1634 get_archetype ("burnout")->insert_at (trap, trap);
1636 op = get_archetype ("burnout");
1637 if (op != NULL)
1638 {
1639 op->x = trap->x;
1640 op->y = trap->y;
1641 insert_ob_in_map (op, trap->map, trap, 0);
1642 } 1635 }
1643 } 1636
1644 goto leave; 1637 goto leave;
1645 1638
1646 case TRIGGER_BUTTON: 1639 case TRIGGER_BUTTON:
1647 case TRIGGER_PEDESTAL: 1640 case TRIGGER_PEDESTAL:
1648 case TRIGGER_ALTAR: 1641 case TRIGGER_ALTAR:
1677 if (victim->type == PLAYER && EXIT_PATH (trap)) 1670 if (victim->type == PLAYER && EXIT_PATH (trap))
1678 { 1671 {
1679 /* Basically, don't show exits leading to random maps the 1672 /* Basically, don't show exits leading to random maps the
1680 * players output. 1673 * players output.
1681 */ 1674 */
1682 if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2) && strncmp (EXIT_PATH (trap), "/random/", 8)) 1675 if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2))
1683 new_draw_info (NDI_NAVY, 0, victim, trap->msg); 1676 new_draw_info (NDI_NAVY, 0, victim, trap->msg);
1677
1684 enter_exit (victim, trap); 1678 victim->enter_exit (trap);
1685 } 1679 }
1686 goto leave; 1680 goto leave;
1687 1681
1688 case ENCOUNTER: 1682 case ENCOUNTER:
1689 /* may be some leftovers on this */ 1683 /* may be some leftovers on this */
2225 if (meal->type != FLESH || !is_dragon_pl (op)) 2219 if (meal->type != FLESH || !is_dragon_pl (op))
2226 return 0; 2220 return 0;
2227 2221
2228 /* now grab the 'dragon_skin'- and 'dragon_ability'-forces 2222 /* now grab the 'dragon_skin'- and 'dragon_ability'-forces
2229 from the player's inventory */ 2223 from the player's inventory */
2224 shstr_cmp dragon_ability_force ("dragon_ability_force");
2225 shstr_cmp dragon_skin_force ("dragon_skin_force");
2226
2230 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2227 for (tmp = op->inv; tmp; tmp = tmp->below)
2231 {
2232 if (tmp->type == FORCE) 2228 if (tmp->type == FORCE)
2233 {
2234 if (strcmp (tmp->arch->name, "dragon_skin_force") == 0) 2229 if (tmp->arch->name == dragon_skin_force)
2235 skin = tmp; 2230 skin = tmp;
2236 else if (strcmp (tmp->arch->name, "dragon_ability_force") == 0) 2231 else if (tmp->arch->name == dragon_ability_force)
2237 abil = tmp; 2232 abil = tmp;
2238 }
2239 }
2240 2233
2241 /* if either skin or ability are missing, this is an old player 2234 /* if either skin or ability are missing, this is an old player
2242 which is not to be considered a dragon -> bail out */ 2235 which is not to be considered a dragon -> bail out */
2243 if (skin == NULL || abil == NULL) 2236 if (skin == NULL || abil == NULL)
2244 return 0; 2237 return 0;
2285 /* doubled chance for resistance of ability-focus */ 2278 /* doubled chance for resistance of ability-focus */
2286 if (i == abil->stats.exp) 2279 if (i == abil->stats.exp)
2287 chance = MIN (100., chance * 2.); 2280 chance = MIN (100., chance * 2.);
2288 2281
2289 /* now make the throw and save all winners (Don't insert luck bonus here!) */ 2282 /* now make the throw and save all winners (Don't insert luck bonus here!) */
2290 if (RANDOM () % 10000 < (int) (chance * 100)) 2283 if (rndm (10000) < (int) (chance * 100))
2291 { 2284 {
2292 atnr_winner[winners] = i; 2285 atnr_winner[winners] = i;
2293 winners++; 2286 winners++;
2294 } 2287 }
2295 2288
2410 handle_apply_yield (tmp); 2403 handle_apply_yield (tmp);
2411 decrease_ob (tmp); 2404 decrease_ob (tmp);
2412} 2405}
2413 2406
2414/** 2407/**
2415 * This fonction return true if the exit is not a 2 ways one or it is 2 ways, valid exit. 2408 * 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: 2409 * A valid 2 way exit means:
2417 * -You can come back (there is another exit at the other side) 2410 * -You can come back (there is another exit at the other side)
2418 * -You are 2411 * -You are
2419 * ° the owner of the exit 2412 * ° the owner of the exit
2420 * ° or in the same party as the owner 2413 * ° or in the same party as the owner
2424 * survive in the swapping (in fact the whole exit doesn't survive). 2417 * survive in the swapping (in fact the whole exit doesn't survive).
2425 */ 2418 */
2426int 2419int
2427is_legal_2ways_exit (object *op, object *exit) 2420is_legal_2ways_exit (object *op, object *exit)
2428{ 2421{
2429 object *tmp;
2430 object *exit_owner;
2431 player *pp;
2432 maptile *exitmap;
2433
2434 if (exit->stats.exp != 1) 2422 if (exit->stats.exp != 1)
2435 return 1; /*This is not a 2 way, so it is legal */ 2423 return 1; /*This is not a 2 way, so it is legal */
2424
2425#if 0 //TODO
2436 if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) 2426 if (!has_been_loaded (EXIT_PATH (exit)) && exit->race)
2437 return 0; /* This is a reset town portal */ 2427 return 0; /* This is a reset town portal */
2438 /* To know if an exit has a correspondant, we look at 2428#endif
2439 * all the exits in destination and try to find one with same path as 2429
2440 * the current exit's position */ 2430 maptile *exitmap = maptile::find_sync (EXIT_PATH (exit), exit->map);
2441 if (!strncmp (EXIT_PATH (exit), settings.localdir, strlen (settings.localdir))) 2431
2442 exitmap = ready_map_name (EXIT_PATH (exit), MAP_PLAYER_UNIQUE);
2443 else
2444 exitmap = ready_map_name (EXIT_PATH (exit), 0);
2445 if (exitmap) 2432 if (exitmap)
2446 { 2433 {
2434 exitmap->load_sync ();
2435
2447 tmp = GET_MAP_OB (exitmap, EXIT_X (exit), EXIT_Y (exit)); 2436 object *tmp = exitmap->at (EXIT_X (exit), EXIT_Y (exit)).bot;
2437
2448 if (!tmp) 2438 if (!tmp)
2449 return 0; 2439 return 0;
2450 for ((tmp = GET_MAP_OB (exitmap, EXIT_X (exit), EXIT_Y (exit))); tmp; tmp = tmp->above) 2440
2441 for (; tmp; tmp = tmp->above)
2451 { 2442 {
2452 if (tmp->type != EXIT) 2443 if (tmp->type != EXIT)
2453 continue; /*Not an exit */ 2444 continue; /*Not an exit */
2445
2454 if (!EXIT_PATH (tmp)) 2446 if (!EXIT_PATH (tmp))
2455 continue; /*Not a valid exit */ 2447 continue; /*Not a valid exit */
2448
2456 if ((EXIT_X (tmp) != exit->x) || (EXIT_Y (tmp) != exit->y)) 2449 if ((EXIT_X (tmp) != exit->x) || (EXIT_Y (tmp) != exit->y))
2457 continue; /*Not in the same place */ 2450 continue; /*Not in the same place */
2451
2458 if (strcmp (exit->map->path, EXIT_PATH (tmp)) != 0) 2452 if (strcmp (exit->map->path, EXIT_PATH (tmp)) != 0)
2459 continue; /*Not in the same map */ 2453 continue; /*Not in the same map */
2460 2454
2461 /* From here we have found the exit is valid. However we do 2455 /* From here we have found the exit is valid. However we do
2462 * here the check of the exit owner. It is important for the 2456 * here the check of the exit owner. It is important for the
2463 * town portals to prevent strangers from visiting your appartments 2457 * town portals to prevent strangers from visiting your appartments
2464 */ 2458 */
2465 if (!exit->race) 2459 if (!exit->race)
2466 return 1; /*No owner, free for all! */ 2460 return 1; /*No owner, free for all! */
2461
2467 exit_owner = NULL; 2462 object *exit_owner = 0;
2468 for (pp = first_player; pp; pp = pp->next) 2463
2464 for_all_players (pp)
2469 { 2465 {
2470 if (!pp->ob) 2466 if (!pp->ob)
2471 continue; 2467 continue;
2468
2472 if (pp->ob->name != exit->race) 2469 if (pp->ob->name != exit->race)
2473 continue; 2470 continue;
2471
2474 exit_owner = pp->ob; /*We found a player which correspond to the player name */ 2472 exit_owner = pp->ob; /*We found a player which correspond to the player name */
2475 break; 2473 break;
2476 } 2474 }
2475
2477 if (!exit_owner) 2476 if (!exit_owner)
2478 return 0; /* No more owner */ 2477 return 0; /* No more owner */
2478
2479 if (exit_owner->contr == op->contr) 2479 if (exit_owner->contr == op->contr)
2480 return 1; /*It is your exit */ 2480 return 1; /*It is your exit */
2481
2481 if (exit_owner && /*There is a owner */ 2482 if (exit_owner && /*There is a owner */
2482 (op->contr) && /*A player tries to pass */ 2483 (op->contr) && /*A player tries to pass */
2483 ((exit_owner->contr->party == NULL) || /*No pass if controller has no party */ 2484 ((exit_owner->contr->party == NULL) || /*No pass if controller has no party */
2484 (exit_owner->contr->party != op->contr->party))) /* Or not the same as op */ 2485 (exit_owner->contr->party != op->contr->party))) /* Or not the same as op */
2485 return 0; 2486 return 0;
2487
2486 return 1; 2488 return 1;
2487 } 2489 }
2488 } 2490 }
2491
2489 return 0; 2492 return 0;
2490} 2493}
2491 2494
2492 2495
2493/** 2496/**
2543 { 2546 {
2544 new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); 2547 new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle.");
2545 play_sound_map (tmp->map, tmp->x, tmp->y, SOUND_TURN_HANDLE); 2548 play_sound_map (tmp->map, tmp->x, tmp->y, SOUND_TURN_HANDLE);
2546 } 2549 }
2547 else 2550 else
2548 {
2549 new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); 2551 new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move.");
2550 } 2552
2551 return 1; 2553 return 1;
2552 2554
2553 case EXIT: 2555 case EXIT:
2554 if (op->type != PLAYER) 2556 if (op->type != PLAYER)
2555 return 0; 2557 return 0;
2558
2556 if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp)) 2559 if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp))
2557 { 2560 {
2558 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s is closed.", query_name (tmp)); 2561 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s is closed.", query_name (tmp));
2559 } 2562 }
2560 else 2563 else
2561 { 2564 {
2562 /* Don't display messages for random maps. */ 2565 /* Don't display messages for random maps. */
2563 if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2) && strncmp (EXIT_PATH (tmp), "/random/", 8)) 2566 if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2))
2564 new_draw_info (NDI_NAVY, 0, op, tmp->msg); 2567 new_draw_info (NDI_NAVY, 0, op, tmp->msg);
2568
2565 enter_exit (op, tmp); 2569 op->enter_exit (tmp);
2566 } 2570 }
2567 return 1; 2571 return 1;
2568 2572
2569 case SIGN: 2573 case SIGN:
2570 apply_sign (op, tmp, 0); 2574 apply_sign (op, tmp, 0);
3327 } 3331 }
3328 else 3332 else
3329 { 3333 {
3330 if (who->contr->unapply == unapply_never || (i & CAN_APPLY_UNAPPLY_CHOICE && who->contr->unapply == unapply_nochoice)) 3334 if (who->contr->unapply == unapply_never || (i & CAN_APPLY_UNAPPLY_CHOICE && who->contr->unapply == unapply_nochoice))
3331 { 3335 {
3332 new_draw_info (NDI_UNIQUE, 0, who, "You need to unapply some item(s):"); 3336 new_draw_info (NDI_UNIQUE, 0, who, "You need to unapply some of the following item(s) or change your applymode:");
3333 unapply_for_ob (who, op, AP_PRINT); 3337 unapply_for_ob (who, op, AP_PRINT);
3334 return 1; 3338 return 1;
3335 } 3339 }
3336 else if (who->contr->unapply == unapply_always || !(i & CAN_APPLY_UNAPPLY_CHOICE)) 3340 else if (who->contr->unapply == unapply_always || !(i & CAN_APPLY_UNAPPLY_CHOICE))
3337 { 3341 {
3339 if (i) 3343 if (i)
3340 return 1; 3344 return 1;
3341 } 3345 }
3342 } 3346 }
3343 } 3347 }
3348
3344 if (op->skill && op->type != SKILL && op->type != SKILL_TOOL) 3349 if (op->skill && op->type != SKILL && op->type != SKILL_TOOL)
3345 { 3350 {
3346 skop = find_skill_by_name (who, op->skill); 3351 skop = find_skill_by_name (who, op->skill);
3347 if (!skop) 3352 if (!skop)
3348 { 3353 {
3670 * when an original map is loaded) and performs special actions for 3675 * when an original map is loaded) and performs special actions for
3671 * certain objects (most initialization of chests and creation of 3676 * certain objects (most initialization of chests and creation of
3672 * treasures and stuff). Calls auto_apply if appropriate. 3677 * treasures and stuff). Calls auto_apply if appropriate.
3673 */ 3678 */
3674void 3679void
3675fix_auto_apply (maptile *m) 3680maptile::fix_auto_apply ()
3676{ 3681{
3677 object *tmp, *above = NULL; 3682 if (!spaces)
3678 int x, y;
3679
3680 if (m == NULL)
3681 return; 3683 return;
3682 3684
3683 for (x = 0; x < MAP_WIDTH (m); x++) 3685 for (mapspace *ms = spaces + size (); ms-- > spaces; )
3684 for (y = 0; y < MAP_HEIGHT (m); y++) 3686 for (object *tmp = ms->bot; tmp; )
3685 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above)
3686 { 3687 {
3687 above = tmp->above; 3688 object *above = tmp->above;
3688 3689
3689 if (tmp->inv) 3690 if (tmp->inv)
3690 { 3691 {
3691 object *invtmp, *invnext; 3692 object *invtmp, *invnext;
3692 3693
3693 for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext) 3694 for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext)
3694 { 3695 {
3695 invnext = invtmp->below; 3696 invnext = invtmp->below;
3696 3697
3697 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) 3698 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY))
3698 auto_apply (invtmp); 3699 auto_apply (invtmp);
3699 else if (invtmp->type == TREASURE && invtmp->has_random_items ()) 3700 else if (invtmp->type == TREASURE && invtmp->has_random_items ())
3700 { 3701 {
3701 while ((invtmp->stats.hp--) > 0) 3702 while ((invtmp->stats.hp--) > 0)
3702 create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); 3703 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0);
3703 3704
3704 invtmp->randomitems = NULL; 3705 invtmp->randomitems = NULL;
3705 } 3706 }
3706 else if (invtmp && invtmp->arch 3707 else if (invtmp && invtmp->arch
3707 && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && invtmp->has_random_items ()) 3708 && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && invtmp->has_random_items ())
3708 { 3709 {
3709 create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); 3710 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0);
3710 /* Need to clear this so that we never try to create 3711 /* Need to clear this so that we never try to create
3711 * treasure again for this object 3712 * treasure again for this object
3712 */ 3713 */
3713 invtmp->randomitems = NULL; 3714 invtmp->randomitems = NULL;
3714 } 3715 }
3715 } 3716 }
3716 /* This is really temporary - the code at the bottom will 3717 /* This is really temporary - the code at the bottom will
3717 * also set randomitems to null. The problem is there are bunches 3718 * also set randomitems to null. The problem is there are bunches
3718 * of maps/players already out there with items that have spells 3719 * of maps/players already out there with items that have spells
3719 * which haven't had the randomitems set to null yet. 3720 * which haven't had the randomitems set to null yet.
3720 * MSW 2004-05-13 3721 * MSW 2004-05-13
3721 * 3722 *
3722 * And if it's a spellbook, it's better to set randomitems to NULL too, 3723 * And if it's a spellbook, it's better to set randomitems to NULL too,
3723 * else you get two spells in the book ^_- 3724 * else you get two spells in the book ^_-
3724 * Ryo 2004-08-16 3725 * Ryo 2004-08-16
3725 */ 3726 */
3726 if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL 3727 if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL
3727 || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) 3728 || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK)
3728 tmp->randomitems = NULL;
3729
3730 }
3731
3732 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY))
3733 auto_apply (tmp);
3734 else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ())
3735 {
3736 while ((tmp->stats.hp--) > 0)
3737 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0);
3738 tmp->randomitems = NULL; 3729 tmp->randomitems = NULL;
3730
3739 } 3731 }
3732
3733 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY))
3734 auto_apply (tmp);
3735 else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ())
3736 {
3737 while ((tmp->stats.hp--) > 0)
3738 create_treasure (tmp->randomitems, tmp, 0, difficulty, 0);
3739 tmp->randomitems = NULL;
3740 }
3740 else if (tmp->type == TIMED_GATE) 3741 else if (tmp->type == TIMED_GATE)
3741 { 3742 {
3742 object *head = tmp->head != NULL ? tmp->head : tmp; 3743 object *head = tmp->head != NULL ? tmp->head : tmp;
3743 3744
3744 if (QUERY_FLAG (head, FLAG_IS_LINKED)) 3745 if (QUERY_FLAG (head, FLAG_IS_LINKED))
3745 {
3746 tmp->speed = 0; 3746 tmp->set_speed (0);
3747 update_ob_speed (tmp);
3748 }
3749 } 3747 }
3750 /* This function can be called everytime a map is loaded, even when 3748 /* This function can be called everytime a map is loaded, even when
3751 * swapping back in. As such, we don't want to create the treasure 3749 * swapping back in. As such, we don't want to create the treasure
3752 * over and ove again, so after we generate the treasure, blank out 3750 * over and ove again, so after we generate the treasure, blank out
3753 * randomitems so if it is swapped in again, it won't make anything. 3751 * randomitems so if it is swapped in again, it won't make anything.
3754 * This is a problem for the above objects, because they have counters 3752 * This is a problem for the above objects, because they have counters
3755 * which say how many times to make the treasure. 3753 * which say how many times to make the treasure.
3756 */ 3754 */
3757 else if (tmp && tmp->arch && tmp->type != PLAYER 3755 else if (tmp && tmp->arch && tmp->type != PLAYER
3758 && tmp->type != TREASURE && tmp->type != SPELL 3756 && tmp->type != TREASURE && tmp->type != SPELL
3759 && tmp->type != PLAYER_CHANGER && tmp->type != CLASS && tmp->has_random_items ()) 3757 && tmp->type != PLAYER_CHANGER && tmp->type != CLASS && tmp->has_random_items ())
3760 { 3758 {
3761 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); 3759 create_treasure (tmp->randomitems, tmp, GT_APPLY, difficulty, 0);
3762 tmp->randomitems = NULL; 3760 tmp->randomitems = NULL;
3763 } 3761 }
3762
3763 tmp = above;
3764 } 3764 }
3765 3765
3766 for (x = 0; x < MAP_WIDTH (m); x++) 3766 for (mapspace *ms = spaces + size (); ms-- > spaces; )
3767 for (y = 0; y < MAP_HEIGHT (m); y++) 3767 for (object *tmp = ms->bot; tmp; tmp = tmp->above)
3768 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
3769 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) 3768 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
3770 check_trigger (tmp, tmp->above); 3769 check_trigger (tmp, tmp->above);
3771} 3770}
3772 3771
3773/** 3772/**
3774 * Handles player eating food that temporarily changes status (resistances, stats). 3773 * Handles player eating food that temporarily changes status (resistances, stats).
3775 * This used to call cast_change_attr(), but 3774 * This used to call cast_change_attr(), but
3806 } 3805 }
3807 } 3806 }
3808 3807
3809 if (did_one) 3808 if (did_one)
3810 { 3809 {
3811 force->speed = 0.1; 3810 force->set_speed (0.1);
3812 update_ob_speed (force);
3813 /* bigger morsel of food = longer effect time */ 3811 /* bigger morsel of food = longer effect time */
3814 force->duration = food->stats.food / 5; 3812 force->duration = food->stats.food / 5;
3815 SET_FLAG (force, FLAG_APPLIED); 3813 SET_FLAG (force, FLAG_APPLIED);
3816 change_abil (who, force); 3814 change_abil (who, force);
3817 insert_ob_in_ob (force, who); 3815 insert_ob_in_ob (force, who);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines