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.1.1.2 by elmex, Wed Feb 22 18:03:18 2006 UTC vs.
Revision 1.2 by root, Thu Feb 9 02:11:26 2006 UTC

1/* 1/*
2 * static char *rcsid_apply_c = 2 * static char *rcsid_apply_c =
3 * "$Id: apply.c,v 1.1.1.2 2006/02/22 18:03:18 elmex Exp $"; 3 * "$Id: apply.c,v 1.2 2006/02/09 02:11:26 root Exp $";
4 */ 4 */
5/* 5/*
6 CrossFire, A Multiplayer game for X-windows 6 CrossFire, A Multiplayer game for X-windows
7 7
8 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 8 Copyright (C) 2001 Mark Wedel & Crossfire Development Team
38/* Want this regardless of rplay. */ 38/* Want this regardless of rplay. */
39#include <sounds.h> 39#include <sounds.h>
40 40
41/* need math lib for double-precision and pow() in dragon_eat_flesh() */ 41/* need math lib for double-precision and pow() in dragon_eat_flesh() */
42#include <math.h> 42#include <math.h>
43
44/* Can transport hold object op?
45 * This is a pretty trivial function,
46 * but in the future, possible transport may have more restrictions
47 * or weight reduction like containers
48 */
49int transport_can_hold(const object *transport, const object *op, int nrof)
50{
51 if ((op->weight *nrof + transport->carrying) > transport->weight_limit)
52 return 0;
53 else
54 return 1;
55}
56
57
58/*
59 * Player is trying to use a transport. This returns same values as
60 * manual_apply() does. This function basically checks to see if
61 * the player can use the transport, and if so, sets up the appropriate
62 * pointers.
63 */
64int apply_transport(object *pl, object *transport, int aflag) {
65
66 /* Only players can use transports right now */
67 if (pl->type != PLAYER) return 0;
68
69 /* If player is currently on a transport but not this transport, they need
70 * to exit first. Perhaps transport to transport transfers should be
71 * allowed.
72 */
73 if (pl->contr->transport && pl->contr->transport != transport) {
74 new_draw_info_format(NDI_UNIQUE, 0, pl,
75 "You must exit %s before you can board %s.",
76 query_name(pl->contr->transport),
77 query_name(transport));
78 return 1;
79 }
80
81 /* player is currently on a transport. This must mean he
82 * wants to exit.
83 */
84 if (pl->contr->transport) {
85 object *old_transport = pl->contr->transport, *inv;
86
87 /* Should we print a message if the player only wants to
88 * apply?
89 */
90 if (aflag & AP_APPLY) return 1;
91 new_draw_info_format(NDI_UNIQUE, 0, pl,
92 "You disembark from %s.",
93 query_name(old_transport));
94 remove_ob(pl);
95 pl->map = old_transport->map;
96 pl->x = old_transport->x;
97 pl->y = old_transport->y;
98 if (pl->contr == old_transport->contr)
99 old_transport->contr = NULL;
100
101 pl->contr->transport = NULL;
102 insert_ob_in_map(pl, pl->map, pl, 0);
103 sum_weight(old_transport);
104
105 /* Possible for more than one player to be using a transport.
106 * if that is the case, we don't want to reset the face, as the
107 * transport is still occupied.
108 */
109 for (inv=old_transport->inv; inv; inv=inv->below)
110 if (inv->type == PLAYER) break;
111 if (!inv) {
112 old_transport->face = old_transport->arch->clone.face;
113 old_transport->animation_id = old_transport->arch->clone.animation_id;
114 }
115 return 1;
116 }
117 else {
118 /* player is trying to board a transport */
119 int pc=0, p_limit;
120 object *inv;
121 const char *kv;
122
123 if (aflag & AP_UNAPPLY) return 1;
124
125 /* Can this transport hold the weight of this player? */
126 if (!transport_can_hold(transport, pl, 1)) {
127 new_draw_info_format(NDI_UNIQUE, 0, pl,
128 "The %s is unable to hold your weight!",
129 query_name(transport));
130 return 1;
131 }
132
133 /* Does this transport have space for more players? */
134 for (inv=transport->inv; inv; inv=inv->below) {
135 if (inv->type == PLAYER) pc++;
136 }
137 kv = get_ob_key_value(transport, "passenger_limit");
138 if (!kv) p_limit=1;
139 else p_limit = atoi(kv);
140 if (pc >= p_limit) {
141 new_draw_info_format(NDI_UNIQUE, 0, pl,
142 "The %s does not have space for any more people",
143 query_name(transport));
144 return 1;
145 }
146
147 /* Everything checks out OK - player can get on the transport */
148 pl->contr->transport = transport;
149 if (!transport->contr) transport->contr = pl->contr;
150 remove_ob(pl);
151 insert_ob_in_ob(pl, transport);
152 sum_weight(transport);
153 pl->map = transport->map;
154 pl->x = transport->x;
155 pl->y = transport->y;
156
157 /* Might need to update face, animation info */
158 if (!pc) {
159 const char *str;
160
161 str = get_ob_key_value(transport, "face_full");
162 if (str)
163 transport->face = &new_faces[FindFace(str,
164 transport->face->number)];
165 str = get_ob_key_value(transport, "anim_full");
166 if (str)
167 transport->animation_id = find_animation(str);
168 }
169
170 /* Does speed of this object change based on weight? */
171 kv = get_ob_key_value(transport, "weight_speed_ratio");
172 if (kv) {
173 int wsr = atoi(kv);
174 float base_speed;
175
176 kv = get_ob_key_value(transport, "base_speed");
177 if (kv) base_speed = atof(kv);
178 else base_speed = transport->arch->clone.speed;
179
180 transport->speed = base_speed - (base_speed * transport->carrying *
181 wsr) / (transport->weight_limit * 100);
182
183 /* Put some limits on min/max speeds */
184 if (transport->speed < 0.10) transport->speed = 0.10;
185 if (transport->speed > 1.0) transport->speed = 1.0;
186 }
187 } /* else if player is boarding the transport */
188
189 return 1;
190}
191
192
193 43
194/** 44/**
195 * Check if op should abort moving victim because of it's race or slaying. 45 * Check if op should abort moving victim because of it's race or slaying.
196 * Returns 1 if it should abort, returns 0 if it should continue. 46 * Returns 1 if it should abort, returns 0 if it should continue.
197 */ 47 */
515 ****************************************************************************/ 365 ****************************************************************************/
516 366
517/** 367/**
518 * This returns the sum of nrof of item (arch name). 368 * This returns the sum of nrof of item (arch name).
519 */ 369 */
520static int check_item(object *op, const char *item) 370int check_item(object *op,const char *item)
521{ 371{
522 int count=0; 372 int count=0;
523 373
524 374
525 if (item==NULL) return 0; 375 if (item==NULL) return 0;
574 * with improvs improvements (typically last_eat). We take an int here 424 * with improvs improvements (typically last_eat). We take an int here
575 * instead of the object so that the improvement code can pass along the 425 * instead of the object so that the improvement code can pass along the
576 * increased value to see if the object is usuable. 426 * increased value to see if the object is usuable.
577 * we return 1 (true) if the player can use the weapon. 427 * we return 1 (true) if the player can use the weapon.
578 */ 428 */
579static int check_weapon_power(const object *who, int improvs) 429int check_weapon_power(object *who, int improvs)
580{ 430{
581/* Old code is below (commented out). Basically, since weapons are the only 431/* Old code is below (commented out). Basically, since weapons are the only
582 * object players really have any control to improve, it's a bit harsh to 432 * object players really have any control to improve, it's a bit harsh to
583 * require high level in some combat skill, so we just use overall level. 433 * require high level in some combat skill, so we just use overall level.
584 */ 434 */
617 467
618/** 468/**
619 * Returns how many items of type improver->slaying there are under op. 469 * Returns how many items of type improver->slaying there are under op.
620 * Will display a message if none found, and 1 if improver->slaying is NULL. 470 * Will display a message if none found, and 1 if improver->slaying is NULL.
621 */ 471 */
622static int check_sacrifice(object *op, const object *improver) 472static int check_sacrifice(object *op,object *improver)
623{ 473{
624 int count=0; 474 int count=0;
625 475
626 if (improver->slaying!=NULL) { 476 if (improver->slaying!=NULL) {
627 count = check_item(op,improver->slaying); 477 count = check_item(op,improver->slaying);
811 661
812 switch (improver->stats.sp) { 662 switch (improver->stats.sp) {
813 case IMPROVE_STR: 663 case IMPROVE_STR:
814 return improve_weapon_stat(op,improver,weapon, 664 return improve_weapon_stat(op,improver,weapon,
815 (signed char *) &(weapon->stats.Str), 665 (signed char *) &(weapon->stats.Str),
816 1, "strength"); 666 1,(char *) "strength");
817 case IMPROVE_DEX: 667 case IMPROVE_DEX:
818 return improve_weapon_stat(op,improver,weapon, 668 return improve_weapon_stat(op,improver,weapon,
819 (signed char *) &(weapon->stats.Dex), 669 (signed char *) &(weapon->stats.Dex),
820 1, "dexterity"); 670 1,(char *) "dexterity");
821 case IMPROVE_CON: 671 case IMPROVE_CON:
822 return improve_weapon_stat(op,improver,weapon, 672 return improve_weapon_stat(op,improver,weapon,
823 (signed char *) &(weapon->stats.Con), 673 (signed char *) &(weapon->stats.Con),
824 1, "constitution"); 674 1,(char *) "constitution");
825 case IMPROVE_WIS: 675 case IMPROVE_WIS:
826 return improve_weapon_stat(op,improver,weapon, 676 return improve_weapon_stat(op,improver,weapon,
827 (signed char *) &(weapon->stats.Wis), 677 (signed char *) &(weapon->stats.Wis),
828 1, "wisdom"); 678 1,(char *) "wisdom");
829 case IMPROVE_CHA: 679 case IMPROVE_CHA:
830 return improve_weapon_stat(op,improver,weapon, 680 return improve_weapon_stat(op,improver,weapon,
831 (signed char *) &(weapon->stats.Cha), 681 (signed char *) &(weapon->stats.Cha),
832 1, "charisma"); 682 1,(char *) "charisma");
833 case IMPROVE_INT: 683 case IMPROVE_INT:
834 return improve_weapon_stat(op,improver,weapon, 684 return improve_weapon_stat(op,improver,weapon,
835 (signed char *) &(weapon->stats.Int), 685 (signed char *) &(weapon->stats.Int),
836 1, "intelligence"); 686 1,(char *) "intelligence");
837 case IMPROVE_POW: 687 case IMPROVE_POW:
838 return improve_weapon_stat(op,improver,weapon, 688 return improve_weapon_stat(op,improver,weapon,
839 (signed char *) &(weapon->stats.Pow), 689 (signed char *) &(weapon->stats.Pow),
840 1, "power"); 690 1,(char *) "power");
841 default: 691 default:
842 new_draw_info(NDI_UNIQUE, 0,op,"Unknown improvement type."); 692 new_draw_info(NDI_UNIQUE, 0,op,"Unknown improvement type.");
843 } 693 }
844 LOG(llevError,"improve_weapon: Got to end of function\n"); 694 LOG(llevError,"improve_weapon: Got to end of function\n");
845 return 0; 695 return 0;
2045 if(QUERY_FLAG(op, FLAG_BLIND)&&!QUERY_FLAG(op,FLAG_WIZ)) { 1895 if(QUERY_FLAG(op, FLAG_BLIND)&&!QUERY_FLAG(op,FLAG_WIZ)) {
2046 new_draw_info(NDI_UNIQUE, 0,op, "You are unable to read while blind."); 1896 new_draw_info(NDI_UNIQUE, 0,op, "You are unable to read while blind.");
2047 return; 1897 return;
2048 } 1898 }
2049 1899
1900 if (!QUERY_FLAG(tmp, FLAG_IDENTIFIED))
1901 identify(tmp);
1902
2050 if (!tmp->inv || tmp->inv->type != SPELL) { 1903 if (!tmp->inv || tmp->inv->type != SPELL) {
2051 new_draw_info (NDI_UNIQUE, 0, op, 1904 new_draw_info (NDI_UNIQUE, 0, op,
2052 "The scroll just doesn't make sense!"); 1905 "The scroll just doesn't make sense!");
2053 return; 1906 return;
2054 } 1907 }
2069 } 1922 }
2070 1923
2071 if((exp_gain = calc_skill_exp(op,tmp, skop))) 1924 if((exp_gain = calc_skill_exp(op,tmp, skop)))
2072 change_exp(op,exp_gain, skop->skill, 0); 1925 change_exp(op,exp_gain, skop->skill, 0);
2073 } 1926 }
2074
2075 if (!QUERY_FLAG(tmp, FLAG_IDENTIFIED))
2076 identify(tmp);
2077 1927
2078 new_draw_info_format(NDI_BLACK, 0, op, 1928 new_draw_info_format(NDI_BLACK, 0, op,
2079 "The scroll of %s turns to dust.", tmp->inv->name); 1929 "The scroll of %s turns to dust.", tmp->inv->name);
2080 1930
2081 1931
2348 return 1; 2198 return 1;
2349} 2199}
2350 2200
2351static void apply_savebed (object *pl) 2201static void apply_savebed (object *pl)
2352{ 2202{
2203#ifndef COZY_SERVER
2353 if(!pl->contr->name_changed||!pl->stats.exp) { 2204 if(!pl->contr->name_changed||!pl->stats.exp) {
2354 new_draw_info(NDI_UNIQUE, 0,pl,"You don't deserve to save your character yet."); 2205 new_draw_info(NDI_UNIQUE, 0,pl,"You don't deserve to save your character yet.");
2355 return; 2206 return;
2356 } 2207 }
2208#endif
2357 if(QUERY_FLAG(pl,FLAG_WAS_WIZ)) { 2209 if(QUERY_FLAG(pl,FLAG_WAS_WIZ)) {
2358 new_draw_info(NDI_UNIQUE, 0,pl,"Since you have cheated you can't save."); 2210 new_draw_info(NDI_UNIQUE, 0,pl,"Since you have cheated you can't save.");
2359 return; 2211 return;
2360 } 2212 }
2361 2213
2504 * 2356 *
2505 * Checks for unpaid items before applying. 2357 * Checks for unpaid items before applying.
2506 * 2358 *
2507 * Return value: 2359 * Return value:
2508 * 0: player or monster can't apply objects of that type 2360 * 0: player or monster can't apply objects of that type
2361 * 2: objects of that type can't be applied if not in inventory
2509 * 1: has been applied, or there was an error applying the object 2362 * 1: has been applied, or there was an error applying the object
2510 * 2: objects of that type can't be applied if not in inventory
2511 * 2363 *
2512 * op is the object that is causing object to be applied, tmp is the object 2364 * op is the object that is causing object to be applied, tmp is the object
2513 * being applied. 2365 * being applied.
2514 * 2366 *
2515 * aflag is special (always apply/unapply) flags. Nothing is done with 2367 * aflag is special (always apply/unapply) flags. Nothing is done with
2516 * them in this function - they are passed to apply_special 2368 * them in this function - they are passed to apply_special
2517 */ 2369 */
2518 2370
2519int manual_apply (object *op, object *tmp, int aflag) 2371int manual_apply (object *op, object *tmp, int aflag)
2520{ 2372{
2521 if (tmp->head) tmp=tmp->head; 2373 if (tmp->head) tmp=tmp->head;
2522 2374
2523 if (QUERY_FLAG (tmp, FLAG_UNPAID) && ! QUERY_FLAG (tmp, FLAG_APPLIED)) { 2375 if (QUERY_FLAG (tmp, FLAG_UNPAID) && ! QUERY_FLAG (tmp, FLAG_APPLIED)) {
2524 if (op->type == PLAYER) { 2376 if (op->type == PLAYER) {
2525 new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first."); 2377 new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first.");
2526 return 1; 2378 return 1;
2527 } else { 2379 } else {
2528 return 0; /* monsters just skip unpaid items */ 2380 return 0; /* monsters just skip unpaid items */
2529 } 2381 }
2530 } 2382 }
2531 2383
2384 /* monsters mustn't apply random chests, nor magic_mouths with a counter */
2385 if (op->type != PLAYER && tmp->type == TREASURE)
2386 return 0;
2532 2387
2533 /* Lauwenmark: Handle for plugin apply event */ 2388 /* Lauwenmark: Handle for plugin apply event */
2534 if (execute_event(tmp, EVENT_APPLY,op,NULL,NULL,SCRIPT_FIX_ALL)!=0) 2389 if (execute_event(tmp, EVENT_APPLY,op,NULL,NULL,SCRIPT_FIX_ALL)!=0)
2535 return 1; 2390 return 1;
2536
2537 switch (tmp->type) { 2391 switch (tmp->type)
2538 2392 {
2539 case TRANSPORT:
2540 return apply_transport(op, tmp, aflag);
2541
2542 case CF_HANDLE: 2393 case CF_HANDLE:
2543 new_draw_info(NDI_UNIQUE, 0,op,"You turn the handle."); 2394 new_draw_info(NDI_UNIQUE, 0,op,"You turn the handle.");
2544 play_sound_map(op->map, op->x, op->y, SOUND_TURN_HANDLE); 2395 play_sound_map(op->map, op->x, op->y, SOUND_TURN_HANDLE);
2545 tmp->value=tmp->value?0:1; 2396 tmp->value=tmp->value?0:1;
2546 SET_ANIMATION(tmp, tmp->value); 2397 SET_ANIMATION(tmp, tmp->value);
2547 update_object(tmp,UP_OBJ_FACE); 2398 update_object(tmp,UP_OBJ_FACE);
2548 push_button(tmp); 2399 push_button(tmp);
2549 return 1; 2400 return 1;
2550 2401
2551 case TRIGGER: 2402 case TRIGGER:
2552 if (check_trigger (tmp, op)) { 2403 if (check_trigger (tmp, op)) {
2553 new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); 2404 new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle.");
2554 play_sound_map (tmp->map, tmp->x, tmp->y, SOUND_TURN_HANDLE); 2405 play_sound_map (tmp->map, tmp->x, tmp->y, SOUND_TURN_HANDLE);
2555 } else { 2406 } else {
2556 new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); 2407 new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move.");
2557 } 2408 }
2558 return 1; 2409 return 1;
2559 2410
2560 case EXIT: 2411 case EXIT:
2561 if (op->type != PLAYER) 2412 if (op->type != PLAYER)
2562 return 0; 2413 return 0;
2563 if( ! EXIT_PATH (tmp) || !is_legal_2ways_exit(op,tmp)) { 2414 if( ! EXIT_PATH (tmp) || !is_legal_2ways_exit(op,tmp)) {
2564 new_draw_info_format(NDI_UNIQUE, 0, op, "The %s is closed.", 2415 new_draw_info_format(NDI_UNIQUE, 0, op, "The %s is closed.",
2565 query_name(tmp)); 2416 query_name(tmp));
2566 } else { 2417 } else {
2567 /* Don't display messages for random maps. */ 2418 /* Don't display messages for random maps. */
2568 if (tmp->msg && strncmp(EXIT_PATH(tmp),"/!",2) && 2419 if (tmp->msg && strncmp(EXIT_PATH(tmp),"/!",2) &&
2569 strncmp(EXIT_PATH(tmp), "/random/", 8)) 2420 strncmp(EXIT_PATH(tmp), "/random/", 8))
2570 new_draw_info (NDI_NAVY, 0, op, tmp->msg); 2421 new_draw_info (NDI_NAVY, 0, op, tmp->msg);
2571 enter_exit(op,tmp); 2422 enter_exit(op,tmp);
2572 } 2423 }
2573 return 1; 2424 return 1;
2574 2425
2575 case SIGN: 2426 case SIGN:
2576 apply_sign (op, tmp, 0); 2427 apply_sign (op, tmp, 0);
2577 return 1; 2428 return 1;
2578 2429
2579 case BOOK: 2430 case BOOK:
2580 if (op->type == PLAYER) { 2431 if (op->type == PLAYER) {
2581 apply_book (op, tmp); 2432 apply_book (op, tmp);
2582 return 1; 2433 return 1;
2583 } else { 2434 } else {
2584 return 0; 2435 return 0;
2585 } 2436 }
2586 2437
2587 case SKILLSCROLL: 2438 case SKILLSCROLL:
2588 if (op->type == PLAYER) { 2439 if (op->type == PLAYER) {
2589 apply_skillscroll (op, tmp); 2440 apply_skillscroll (op, tmp);
2590 return 1; 2441 return 1;
2591 } 2442 }
2592 return 0; 2443 return 0;
2593 2444
2594 case SPELLBOOK: 2445 case SPELLBOOK:
2595 if (op->type == PLAYER) { 2446 if (op->type == PLAYER) {
2596 apply_spellbook (op, tmp); 2447 apply_spellbook (op, tmp);
2597 return 1; 2448 return 1;
2598 } 2449 }
2599 return 0; 2450 return 0;
2600 2451
2601 case SCROLL: 2452 case SCROLL:
2602 apply_scroll (op, tmp, 0); 2453 apply_scroll (op, tmp, 0);
2603 return 1; 2454 return 1;
2604 2455
2605 case POTION: 2456 case POTION:
2606 (void) apply_potion(op, tmp); 2457 (void) apply_potion(op, tmp);
2607 return 1; 2458 return 1;
2608 2459
2609 /* Eneq(@csd.uu.se): Handle apply on containers. */ 2460 /* Eneq(@csd.uu.se): Handle apply on containers. */
2610 case CLOSE_CON: 2461 case CLOSE_CON:
2611 if (op->type==PLAYER) 2462 if (op->type==PLAYER)
2612 (void) esrv_apply_container (op, tmp->env); 2463 (void) esrv_apply_container (op, tmp->env);
2613 else 2464 else
2614 (void) apply_container (op, tmp->env); 2465 (void) apply_container (op, tmp->env);
2615 return 1; 2466 return 1;
2616 2467
2617 case CONTAINER: 2468 case CONTAINER:
2618 if (op->type==PLAYER) 2469 if (op->type==PLAYER)
2619 (void) esrv_apply_container (op, tmp); 2470 (void) esrv_apply_container (op, tmp);
2620 else 2471 else
2621 (void) apply_container (op, tmp); 2472 (void) apply_container (op, tmp);
2622 return 1; 2473 return 1;
2623 2474
2624 case TREASURE: 2475 case TREASURE:
2625 if (op->type == PLAYER) {
2626 apply_treasure (op, tmp); 2476 apply_treasure (op, tmp);
2627 return 1; 2477 return 1;
2628 } else {
2629 return 0;
2630 }
2631 2478
2632 case WEAPON: 2479 case WEAPON:
2633 case ARMOUR: 2480 case ARMOUR:
2634 case BOOTS: 2481 case BOOTS:
2635 case GLOVES: 2482 case GLOVES:
2636 case AMULET: 2483 case AMULET:
2637 case GIRDLE: 2484 case GIRDLE:
2638 case BRACERS: 2485 case BRACERS:
2639 case SHIELD: 2486 case SHIELD:
2640 case HELMET: 2487 case HELMET:
2641 case RING: 2488 case RING:
2642 case CLOAK: 2489 case CLOAK:
2643 case WAND: 2490 case WAND:
2644 case ROD: 2491 case ROD:
2645 case HORN: 2492 case HORN:
2646 case SKILL: 2493 case SKILL:
2647 case BOW: 2494 case BOW:
2648 case LAMP: 2495 case LAMP:
2649 case BUILDER: 2496 case BUILDER:
2650 case SKILL_TOOL: 2497 case SKILL_TOOL:
2651 if (tmp->env != op) 2498 if (tmp->env != op)
2652 return 2; /* not in inventory */ 2499 return 2; /* not in inventory */
2653 (void) apply_special (op, tmp, aflag); 2500 (void) apply_special (op, tmp, aflag);
2654 return 1; 2501 return 1;
2655 2502
2656 case DRINK: 2503 case DRINK:
2657 case FOOD: 2504 case FOOD:
2658 case FLESH: 2505 case FLESH:
2659 apply_food (op, tmp); 2506 apply_food (op, tmp);
2660 return 1; 2507 return 1;
2661 2508
2662 case POISON: 2509 case POISON:
2663 apply_poison (op, tmp); 2510 apply_poison (op, tmp);
2664 return 1; 2511 return 1;
2665 2512
2666 case SAVEBED: 2513 case SAVEBED:
2667 if (op->type == PLAYER) { 2514 if (op->type == PLAYER) {
2668 apply_savebed (op); 2515 apply_savebed (op);
2669 return 1; 2516 return 1;
2670 } else { 2517 } else {
2671 return 0; 2518 return 0;
2672 } 2519 }
2673 2520
2674 case ARMOUR_IMPROVER: 2521 case ARMOUR_IMPROVER:
2675 if (op->type == PLAYER) { 2522 if (op->type == PLAYER) {
2676 apply_armour_improver (op, tmp); 2523 apply_armour_improver (op, tmp);
2677 return 1; 2524 return 1;
2678 } else { 2525 } else {
2679 return 0; 2526 return 0;
2680 } 2527 }
2681 2528
2682 case WEAPON_IMPROVER: 2529 case WEAPON_IMPROVER:
2683 (void) check_improve_weapon(op, tmp); 2530 (void) check_improve_weapon(op, tmp);
2684 return 1; 2531 return 1;
2685 2532
2686 case CLOCK: 2533 case CLOCK:
2687 if (op->type == PLAYER) { 2534 if (op->type == PLAYER) {
2688 char buf[MAX_BUF]; 2535 char buf[MAX_BUF];
2689 timeofday_t tod; 2536 timeofday_t tod;
2690 2537
2691 get_tod(&tod); 2538 get_tod(&tod);
2692 sprintf(buf, "It is %d minute%s past %d o'clock %s", 2539 sprintf(buf, "It is %d minute%s past %d o'clock %s",
2693 tod.minute+1, ((tod.minute+1 < 2) ? "" : "s"), 2540 tod.minute+1, ((tod.minute+1 < 2) ? "" : "s"),
2694 ((tod.hour % 14 == 0) ? 14 : ((tod.hour)%14)), 2541 ((tod.hour % 14 == 0) ? 14 : ((tod.hour)%14)),
2695 ((tod.hour >= 14) ? "pm" : "am")); 2542 ((tod.hour >= 14) ? "pm" : "am"));
2696 play_sound_player_only(op->contr, SOUND_CLOCK,0,0); 2543 play_sound_player_only(op->contr, SOUND_CLOCK,0,0);
2697 new_draw_info(NDI_UNIQUE, 0,op, buf); 2544 new_draw_info(NDI_UNIQUE, 0,op, buf);
2698 return 1; 2545 return 1;
2699 } else { 2546 } else {
2700 return 0; 2547 return 0;
2701 } 2548 }
2702 2549
2703 case MENU: 2550 case MENU:
2704 if (op->type == PLAYER) { 2551 if (op->type == PLAYER) {
2705 shop_listing (op); 2552 shop_listing (op);
2706 return 1; 2553 return 1;
2707 } else { 2554 } else {
2708 return 0; 2555 return 0;
2709 } 2556 }
2710 2557
2711 case POWER_CRYSTAL: 2558 case POWER_CRYSTAL:
2712 apply_power_crystal(op,tmp); /* see egoitem.c */ 2559 apply_power_crystal(op,tmp); /* see egoitem.c */
2713 return 1; 2560 return 1;
2714 2561
2715 case LIGHTER: /* for lighting torches/lanterns/etc */ 2562 case LIGHTER: /* for lighting torches/lanterns/etc */
2716 if (op->type == PLAYER) { 2563 if (op->type == PLAYER) {
2717 apply_lighter(op,tmp); 2564 apply_lighter(op,tmp);
2718 return 1; 2565 return 1;
2719 } else { 2566 } else {
2720 return 0; 2567 return 0;
2721 } 2568 }
2722 2569
2723 case ITEM_TRANSFORMER: 2570 case ITEM_TRANSFORMER:
2724 apply_item_transformer( op, tmp ); 2571 apply_item_transformer( op, tmp );
2725 return 1; 2572 return 1;
2726
2727 default: 2573 default:
2728 return 0; 2574 return 0;
2729 } 2575 }
2730} 2576}
2731 2577
2732 2578
2733/* quiet suppresses the "don't know how to apply" and "you must get it first" 2579/* quiet suppresses the "don't know how to apply" and "you must get it first"
2734 * messages as needed by player_apply_below(). But there can still be 2580 * messages as needed by player_apply_below(). But there can still be
2787 2633
2788void player_apply_below (object *pl) 2634void player_apply_below (object *pl)
2789{ 2635{
2790 object *tmp, *next; 2636 object *tmp, *next;
2791 int floors; 2637 int floors;
2792
2793 if (pl->contr->transport && pl->contr->transport->type == TRANSPORT) {
2794 apply_transport(pl, pl->contr->transport, 0);
2795 return;
2796 }
2797 2638
2798 /* If using a container, set the starting item to be the top 2639 /* If using a container, set the starting item to be the top
2799 * item in the container. Otherwise, use the map. 2640 * item in the container. Otherwise, use the map.
2800 */ 2641 */
2801 tmp = (pl->container != NULL) ? pl->container->inv : pl->below; 2642 tmp = (pl->container != NULL) ? pl->container->inv : pl->below;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines