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.43 by root, Tue Dec 19 05:12:52 2006 UTC vs.
Revision 1.53 by root, Mon Dec 25 14:43:23 2006 UTC

25#include <living.h> 25#include <living.h>
26#include <spells.h> 26#include <spells.h>
27#include <skills.h> 27#include <skills.h>
28#include <tod.h> 28#include <tod.h>
29 29
30#ifndef __CEXTRACT__
31# include <sproto.h> 30#include <sproto.h>
32#endif
33 31
34/* Want this regardless of rplay. */ 32/* Want this regardless of rplay. */
35#include <sounds.h> 33#include <sounds.h>
36 34
37/* need math lib for double-precision and pow() in dragon_eat_flesh() */ 35/* need math lib for double-precision and pow() in dragon_eat_flesh() */
195apply_potion (object *op, object *tmp) 193apply_potion (object *op, object *tmp)
196{ 194{
197 int got_one = 0, i; 195 int got_one = 0, i;
198 object *force = 0, *floor = 0; 196 object *force = 0, *floor = 0;
199 197
200 floor = get_map_ob (op->map, op->x, op->y); 198 floor = GET_MAP_OB (op->map, op->x, op->y);
201 199
202 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 200 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
203 { 201 {
204 if (op->type == PLAYER) 202 if (op->type == PLAYER)
205 new_draw_info (NDI_UNIQUE, 0, op, "Gods prevent you from using this here, it's sacred ground!"); 203 new_draw_info (NDI_UNIQUE, 0, op, "Gods prevent you from using this here, it's sacred ground!");
219 object *depl; 217 object *depl;
220 archetype *at; 218 archetype *at;
221 219
222 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 220 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
223 { 221 {
224 drain_stat (op); 222 op->drain_stat ();
225 fix_player (op); 223 op->update_stats ();
226 decrease_ob (tmp); 224 decrease_ob (tmp);
227 return 1; 225 return 1;
228 } 226 }
229 227
230 if ((at = archetype::find (ARCH_DEPLETION)) == NULL) 228 if (!(at = archetype::find (ARCH_DEPLETION)))
231 { 229 {
232 LOG (llevError, "Could not find archetype depletion\n"); 230 LOG (llevError, "Could not find archetype depletion\n");
233 return 0; 231 return 0;
234 } 232 }
235 depl = present_arch_in_ob (at, op); 233 depl = present_arch_in_ob (at, op);
236 234
237 if (depl != NULL) 235 if (depl)
238 { 236 {
239 for (i = 0; i < NUM_STATS; i++) 237 for (i = 0; i < NUM_STATS; i++)
240 if (get_attr_value (&depl->stats, i)) 238 if (get_attr_value (&depl->stats, i))
241 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); 239 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]);
242 240
243 depl->destroy (); 241 depl->destroy ();
244 fix_player (op); 242 op->update_stats ();
245 } 243 }
246 else 244 else
247 new_draw_info (NDI_UNIQUE, 0, op, "You potion had no effect."); 245 new_draw_info (NDI_UNIQUE, 0, op, "You potion had no effect.");
248 246
249 decrease_ob (tmp); 247 decrease_ob (tmp);
299 297
300 if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)) 298 if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED))
301 { 299 {
302 if (got_one) 300 if (got_one)
303 { 301 {
304 fix_player (op); 302 op->update_stats ();
305 new_draw_info (NDI_UNIQUE, 0, op, "The Gods smile upon you and remake you"); 303 new_draw_info (NDI_UNIQUE, 0, op, "The Gods smile upon you and remake you");
306 new_draw_info (NDI_UNIQUE, 0, op, "a little more in their image."); 304 new_draw_info (NDI_UNIQUE, 0, op, "a little more in their image.");
307 new_draw_info (NDI_UNIQUE, 0, op, "You feel a little more perfect."); 305 new_draw_info (NDI_UNIQUE, 0, op, "You feel a little more perfect.");
308 } 306 }
309 else 307 else
311 } 309 }
312 else 310 else
313 { /* cursed potion */ 311 { /* cursed potion */
314 if (got_one) 312 if (got_one)
315 { 313 {
316 fix_player (op); 314 op->update_stats ();
317 new_draw_info (NDI_UNIQUE, 0, op, "The Gods are angry and punish you."); 315 new_draw_info (NDI_UNIQUE, 0, op, "The Gods are angry and punish you.");
318 } 316 }
319 else 317 else
320 new_draw_info (NDI_UNIQUE, 0, op, "You are fortunate that you are so pathetic."); 318 new_draw_info (NDI_UNIQUE, 0, op, "You are fortunate that you are so pathetic.");
321 } 319 }
349 cast_spell (op, tmp, op->facing, tmp->inv, NULL); 347 cast_spell (op, tmp, op->facing, tmp->inv, NULL);
350 348
351 decrease_ob (tmp); 349 decrease_ob (tmp);
352 /* if youre dead, no point in doing this... */ 350 /* if youre dead, no point in doing this... */
353 if (!QUERY_FLAG (op, FLAG_REMOVED)) 351 if (!QUERY_FLAG (op, FLAG_REMOVED))
354 fix_player (op); 352 op->update_stats ();
355 return 1; 353 return 1;
356 } 354 }
357 355
358 /* Deal with protection potions */ 356 /* Deal with protection potions */
359 force = NULL; 357 force = NULL;
403 * that were grouped with the one consumed, his 401 * that were grouped with the one consumed, his
404 * stat will not be raised by them. fix_player just clears 402 * stat will not be raised by them. fix_player just clears
405 * up all the stats. 403 * up all the stats.
406 */ 404 */
407 CLEAR_FLAG (tmp, FLAG_APPLIED); 405 CLEAR_FLAG (tmp, FLAG_APPLIED);
408 fix_player (op); 406 op->update_stats ();
409 decrease_ob (tmp); 407 decrease_ob (tmp);
410 return 1; 408 return 1;
411} 409}
412 410
413/**************************************************************************** 411/****************************************************************************
570 weapon->last_eat++; 568 weapon->last_eat++;
571 new_draw_info_format (NDI_UNIQUE, 0, op, "Weapon's bonus to %s improved by %d", statname, sacrifice_count); 569 new_draw_info_format (NDI_UNIQUE, 0, op, "Weapon's bonus to %s improved by %d", statname, sacrifice_count);
572 decrease_ob (improver); 570 decrease_ob (improver);
573 571
574 /* So it updates the players stats and the window */ 572 /* So it updates the players stats and the window */
575 fix_player (op); 573 op->update_stats ();
576 return 1; 574 return 1;
577} 575}
578 576
579/* Types of improvements, hidden in the sp field. */ 577/* Types of improvements, hidden in the sp field. */
580#define IMPROVE_PREPARE 1 578#define IMPROVE_PREPARE 1
883 881
884 if (op->type == PLAYER) 882 if (op->type == PLAYER)
885 { 883 {
886 esrv_send_item (op, armour); 884 esrv_send_item (op, armour);
887 if (QUERY_FLAG (armour, FLAG_APPLIED)) 885 if (QUERY_FLAG (armour, FLAG_APPLIED))
888 fix_player (op); 886 op->update_stats ();
889 } 887 }
890 decrease_ob (improver); 888 decrease_ob (improver);
891 if (tmp) 889 if (tmp)
892 { 890 {
893 insert_ob_in_ob (tmp, op); 891 insert_ob_in_ob (tmp, op);
1046 if (op->container != sack) 1044 if (op->container != sack)
1047 { 1045 {
1048 /* it's closed OR some player has opened it */ 1046 /* it's closed OR some player has opened it */
1049 if (QUERY_FLAG (sack, FLAG_APPLIED)) 1047 if (QUERY_FLAG (sack, FLAG_APPLIED))
1050 { 1048 {
1051 for (tmp = get_map_ob (sack->map, sack->x, sack->y); tmp && tmp->container != sack; tmp = tmp->above); 1049 for (tmp = GET_MAP_OB (sack->map, sack->x, sack->y); tmp && tmp->container != sack; tmp = tmp->above);
1052 if (tmp) 1050 if (tmp)
1053 { 1051 {
1054 /* some other player have opened it */ 1052 /* some other player have opened it */
1055 new_draw_info_format (NDI_UNIQUE, 0, op, "%s is already occupied.", query_name (sack)); 1053 new_draw_info_format (NDI_UNIQUE, 0, op, "%s is already occupied.", query_name (sack));
1056 return 1; 1054 return 1;
1120 tmp = find_key (op, op, sack); 1118 tmp = find_key (op, op, sack);
1121 if (tmp) 1119 if (tmp)
1122 { 1120 {
1123 sprintf (buf, "You unlock %s with %s.", query_name (sack), query_name (tmp)); 1121 sprintf (buf, "You unlock %s with %s.", query_name (sack), query_name (tmp));
1124 SET_FLAG (sack, FLAG_APPLIED); 1122 SET_FLAG (sack, FLAG_APPLIED);
1123
1125 if (sack->env == NULL) 1124 if (sack->env == NULL)
1126 { /* if it's on ground,open it also */ 1125 { /* if it's on ground,open it also */
1127 new_draw_info (NDI_UNIQUE, 0, op, buf); 1126 new_draw_info (NDI_UNIQUE, 0, op, buf);
1128 apply_container (op, sack); 1127 apply_container (op, sack);
1129 return 1; 1128 return 1;
1130 } 1129 }
1131 } 1130 }
1132 else 1131 else
1133 {
1134 sprintf (buf, "You don't have the key to unlock %s.", query_name (sack)); 1132 sprintf (buf, "You don't have the key to unlock %s.", query_name (sack));
1135 }
1136 } 1133 }
1137 else 1134 else
1138 { 1135 {
1139 sprintf (buf, "You readied %s.", query_name (sack)); 1136 sprintf (buf, "You readied %s.", query_name (sack));
1140 SET_FLAG (sack, FLAG_APPLIED); 1137 SET_FLAG (sack, FLAG_APPLIED);
1138
1141 if (sack->env == NULL) 1139 if (sack->env == NULL)
1142 { /* if it's on ground,open it also */ 1140 { /* if it's on ground,open it also */
1143 new_draw_info (NDI_UNIQUE, 0, op, buf); 1141 new_draw_info (NDI_UNIQUE, 0, op, buf);
1144 apply_container (op, sack); 1142 apply_container (op, sack);
1145 return 1; 1143 return 1;
1148 } 1146 }
1149 1147
1150 new_draw_info (NDI_UNIQUE, 0, op, buf); 1148 new_draw_info (NDI_UNIQUE, 0, op, buf);
1151 1149
1152 if (op->contr) 1150 if (op->contr)
1153 op->contr->socket->floorbox_update (); 1151 op->contr->ns->floorbox_update ();
1154 1152
1155 return 1; 1153 return 1;
1156} 1154}
1157 1155
1158/** 1156/**
1795 1793
1796 /* If in a container, update how it looks */ 1794 /* If in a container, update how it looks */
1797 if (tmp->env) 1795 if (tmp->env)
1798 esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); 1796 esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp);
1799 else 1797 else
1800 op->contr->socket->floorbox_update (); 1798 op->contr->ns->floorbox_update ();
1801 } 1799 }
1802 1800
1803 change_exp (op, exp_gain, skill_ob->skill, 0); 1801 change_exp (op, exp_gain, skill_ob->skill, 0);
1804 SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ 1802 SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */
1805 } 1803 }
1958 identify (tmp); 1956 identify (tmp);
1959 1957
1960 if (tmp->env) 1958 if (tmp->env)
1961 esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); 1959 esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp);
1962 else 1960 else
1963 op->contr->socket->floorbox_update (); 1961 op->contr->ns->floorbox_update ();
1964 } 1962 }
1965 1963
1966 /* I removed the check for special_prayer_mark here - it didn't make 1964 /* I removed the check for special_prayer_mark here - it didn't make
1967 * a lot of sense - special prayers are not found in spellbooks, and 1965 * a lot of sense - special prayers are not found in spellbooks, and
1968 * if the player doesn't know the spell, doesn't make a lot of sense that 1966 * if the player doesn't know the spell, doesn't make a lot of sense that
2328 2326
2329 if (i >= 0 && i < NROFATTACKS && skin->resist[i] < 95) 2327 if (i >= 0 && i < NROFATTACKS && skin->resist[i] < 95)
2330 { 2328 {
2331 /* resistance increased! */ 2329 /* resistance increased! */
2332 skin->resist[i]++; 2330 skin->resist[i]++;
2333 fix_player (op); 2331 op->update_stats ();
2334 2332
2335 sprintf (buf, "Your skin is now more resistant to %s!", change_resist_msg[i]); 2333 sprintf (buf, "Your skin is now more resistant to %s!", change_resist_msg[i]);
2336 new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, buf); 2334 new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, buf);
2337 } 2335 }
2338 2336
2357 } 2355 }
2358 } 2356 }
2359 return 1; 2357 return 1;
2360} 2358}
2361 2359
2362static void
2363apply_savebed (object *pl)
2364{
2365#ifndef COZY_SERVER
2366 if (!pl->contr->name_changed || !pl->stats.exp)
2367 {
2368 new_draw_info (NDI_UNIQUE, 0, pl, "You don't deserve to save your character yet.");
2369 return;
2370 }
2371#endif
2372 INVOKE_PLAYER (LOGOUT, pl->contr);
2373 /* Need to call terminate_all_pets() before we remove the player ob */
2374 terminate_all_pets (pl);
2375 pl->remove ();
2376 pl->direction = 0;
2377 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, pl, "%s leaves the game.", &pl->name);
2378
2379 /* update respawn position */
2380 strcpy (pl->contr->savebed_map, pl->map->path);
2381 pl->contr->bed_x = pl->x;
2382 pl->contr->bed_y = pl->y;
2383
2384 strcpy (pl->contr->killer, "left");
2385 check_score (pl); /* Always check score */
2386 (void) save_player (pl, 0);
2387 pl->map->players--;
2388#if MAP_MAXTIMEOUT
2389 MAP_SWAP_TIME (pl->map) = MAP_TIMEOUT (pl->map);
2390#endif
2391 play_again (pl);
2392 pl->speed = 0;
2393 update_ob_speed (pl);
2394}
2395
2396/** 2360/**
2397 * Handles applying an improve armor scroll. 2361 * Handles applying an improve armor scroll.
2398 * Does some sanity checks, then calls improve_armour. 2362 * Does some sanity checks, then calls improve_armour.
2399 */ 2363 */
2400static void 2364static void
2405 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) 2369 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC))
2406 { 2370 {
2407 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll."); 2371 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll.");
2408 return; 2372 return;
2409 } 2373 }
2374
2410 armor = find_marked_object (op); 2375 armor = find_marked_object (op);
2376
2411 if (!armor) 2377 if (!armor)
2412 { 2378 {
2413 new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object."); 2379 new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object.");
2414 return; 2380 return;
2415 } 2381 }
2382
2416 if (armor->type != ARMOUR 2383 if (armor->type != ARMOUR
2417 && armor->type != CLOAK 2384 && armor->type != CLOAK
2418 && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) 2385 && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET)
2419 { 2386 {
2420 new_draw_info (NDI_UNIQUE, 0, op, "Your marked item is not armour!\n"); 2387 new_draw_info (NDI_UNIQUE, 0, op, "Your marked item is not armour!\n");
2422 } 2389 }
2423 2390
2424 new_draw_info (NDI_UNIQUE, 0, op, "Applying armour enchantment."); 2391 new_draw_info (NDI_UNIQUE, 0, op, "Applying armour enchantment.");
2425 improve_armour (op, tmp, armor); 2392 improve_armour (op, tmp, armor);
2426} 2393}
2427
2428 2394
2429extern void 2395extern void
2430apply_poison (object *op, object *tmp) 2396apply_poison (object *op, object *tmp)
2431{ 2397{
2432 if (op->type == PLAYER) 2398 if (op->type == PLAYER)
2448/** 2414/**
2449 * This fonction return true if the exit is not a 2 ways one or it is 2 ways, valid exit. 2415 * This fonction return true if the exit is not a 2 ways one or it is 2 ways, valid exit.
2450 * A valid 2 way exit means: 2416 * A valid 2 way exit means:
2451 * -You can come back (there is another exit at the other side) 2417 * -You can come back (there is another exit at the other side)
2452 * -You are 2418 * -You are
2453 * ° the owner of the exit 2419 * ° the owner of the exit
2454 * ° or in the same party as the owner 2420 * ° or in the same party as the owner
2455 * 2421 *
2456 * Note: a owner in a 2 way exit is saved as the owner's name 2422 * Note: a owner in a 2 way exit is saved as the owner's name
2457 * in the field exit->name cause the field exit->owner doesn't 2423 * in the field exit->name cause the field exit->owner doesn't
2458 * survive in the swapping (in fact the whole exit doesn't survive). 2424 * survive in the swapping (in fact the whole exit doesn't survive).
2459 */ 2425 */
2460int 2426int
2461is_legal_2ways_exit (object *op, object *exit) 2427is_legal_2ways_exit (object *op, object *exit)
2462{ 2428{
2463 object *tmp; 2429 object *tmp;
2464 object *exit_owner; 2430 object *exit_owner;
2465 player *pp;
2466 maptile *exitmap; 2431 maptile *exitmap;
2467 2432
2468 if (exit->stats.exp != 1) 2433 if (exit->stats.exp != 1)
2469 return 1; /*This is not a 2 way, so it is legal */ 2434 return 1; /*This is not a 2 way, so it is legal */
2435
2470 if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) 2436 if (!has_been_loaded (EXIT_PATH (exit)) && exit->race)
2471 return 0; /* This is a reset town portal */ 2437 return 0; /* This is a reset town portal */
2438
2472 /* To know if an exit has a correspondant, we look at 2439 /* To know if an exit has a correspondant, we look at
2473 * all the exits in destination and try to find one with same path as 2440 * all the exits in destination and try to find one with same path as
2474 * the current exit's position */ 2441 * the current exit's position */
2475 if (!strncmp (EXIT_PATH (exit), settings.localdir, strlen (settings.localdir))) 2442 if (!strncmp (EXIT_PATH (exit), settings.localdir, strlen (settings.localdir)))
2476 exitmap = ready_map_name (EXIT_PATH (exit), MAP_PLAYER_UNIQUE); 2443 exitmap = ready_map_name (EXIT_PATH (exit), MAP_PLAYER_UNIQUE);
2477 else 2444 else
2478 exitmap = ready_map_name (EXIT_PATH (exit), 0); 2445 exitmap = ready_map_name (EXIT_PATH (exit), 0);
2446
2479 if (exitmap) 2447 if (exitmap)
2480 { 2448 {
2481 tmp = get_map_ob (exitmap, EXIT_X (exit), EXIT_Y (exit)); 2449 tmp = GET_MAP_OB (exitmap, EXIT_X (exit), EXIT_Y (exit));
2450
2482 if (!tmp) 2451 if (!tmp)
2483 return 0; 2452 return 0;
2453
2484 for ((tmp = get_map_ob (exitmap, EXIT_X (exit), EXIT_Y (exit))); tmp; tmp = tmp->above) 2454 for ((tmp = GET_MAP_OB (exitmap, EXIT_X (exit), EXIT_Y (exit))); tmp; tmp = tmp->above)
2485 { 2455 {
2486 if (tmp->type != EXIT) 2456 if (tmp->type != EXIT)
2487 continue; /*Not an exit */ 2457 continue; /*Not an exit */
2458
2488 if (!EXIT_PATH (tmp)) 2459 if (!EXIT_PATH (tmp))
2489 continue; /*Not a valid exit */ 2460 continue; /*Not a valid exit */
2461
2490 if ((EXIT_X (tmp) != exit->x) || (EXIT_Y (tmp) != exit->y)) 2462 if ((EXIT_X (tmp) != exit->x) || (EXIT_Y (tmp) != exit->y))
2491 continue; /*Not in the same place */ 2463 continue; /*Not in the same place */
2464
2492 if (strcmp (exit->map->path, EXIT_PATH (tmp)) != 0) 2465 if (strcmp (exit->map->path, EXIT_PATH (tmp)) != 0)
2493 continue; /*Not in the same map */ 2466 continue; /*Not in the same map */
2494 2467
2495 /* From here we have found the exit is valid. However we do 2468 /* From here we have found the exit is valid. However we do
2496 * here the check of the exit owner. It is important for the 2469 * here the check of the exit owner. It is important for the
2497 * town portals to prevent strangers from visiting your appartments 2470 * town portals to prevent strangers from visiting your appartments
2498 */ 2471 */
2499 if (!exit->race) 2472 if (!exit->race)
2500 return 1; /*No owner, free for all! */ 2473 return 1; /*No owner, free for all! */
2474
2501 exit_owner = NULL; 2475 exit_owner = NULL;
2502 for (pp = first_player; pp; pp = pp->next) 2476
2477 for_all_players (pp)
2503 { 2478 {
2504 if (!pp->ob) 2479 if (!pp->ob)
2505 continue; 2480 continue;
2481
2506 if (pp->ob->name != exit->race) 2482 if (pp->ob->name != exit->race)
2507 continue; 2483 continue;
2484
2508 exit_owner = pp->ob; /*We found a player which correspond to the player name */ 2485 exit_owner = pp->ob; /*We found a player which correspond to the player name */
2509 break; 2486 break;
2510 } 2487 }
2488
2511 if (!exit_owner) 2489 if (!exit_owner)
2512 return 0; /* No more owner */ 2490 return 0; /* No more owner */
2491
2513 if (exit_owner->contr == op->contr) 2492 if (exit_owner->contr == op->contr)
2514 return 1; /*It is your exit */ 2493 return 1; /*It is your exit */
2494
2515 if (exit_owner && /*There is a owner */ 2495 if (exit_owner && /*There is a owner */
2516 (op->contr) && /*A player tries to pass */ 2496 (op->contr) && /*A player tries to pass */
2517 ((exit_owner->contr->party == NULL) || /*No pass if controller has no party */ 2497 ((exit_owner->contr->party == NULL) || /*No pass if controller has no party */
2518 (exit_owner->contr->party != op->contr->party))) /* Or not the same as op */ 2498 (exit_owner->contr->party != op->contr->party))) /* Or not the same as op */
2519 return 0; 2499 return 0;
2500
2520 return 1; 2501 return 1;
2521 } 2502 }
2522 } 2503 }
2504
2523 return 0; 2505 return 0;
2524} 2506}
2525 2507
2526 2508
2527/** 2509/**
2553 { 2535 {
2554 new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first."); 2536 new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first.");
2555 return 1; 2537 return 1;
2556 } 2538 }
2557 else 2539 else
2558 {
2559 return 0; /* monsters just skip unpaid items */ 2540 return 0; /* monsters just skip unpaid items */
2560 }
2561 } 2541 }
2562 2542
2563 if (INVOKE_OBJECT (APPLY, tmp, ARG_OBJECT (op))) 2543 if (INVOKE_OBJECT (APPLY, tmp, ARG_OBJECT (op)))
2564 return RESULT_INT (0); 2544 return RESULT_INT (0);
2565 2545
2566 switch (tmp->type) 2546 switch (tmp->type)
2567 { 2547 {
2568
2569 case CF_HANDLE: 2548 case CF_HANDLE:
2570 new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); 2549 new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle.");
2571 play_sound_map (op->map, op->x, op->y, SOUND_TURN_HANDLE); 2550 play_sound_map (op->map, op->x, op->y, SOUND_TURN_HANDLE);
2572 tmp->value = tmp->value ? 0 : 1; 2551 tmp->value = tmp->value ? 0 : 1;
2573 SET_ANIMATION (tmp, tmp->value); 2552 SET_ANIMATION (tmp, tmp->value);
2701 case POISON: 2680 case POISON:
2702 apply_poison (op, tmp); 2681 apply_poison (op, tmp);
2703 return 1; 2682 return 1;
2704 2683
2705 case SAVEBED: 2684 case SAVEBED:
2706 if (op->type == PLAYER)
2707 {
2708 apply_savebed (op);
2709 return 1; 2685 return 1;
2710 }
2711 else
2712 {
2713 return 0;
2714 }
2715 2686
2716 case ARMOUR_IMPROVER: 2687 case ARMOUR_IMPROVER:
2717 if (op->type == PLAYER) 2688 if (op->type == PLAYER)
2718 { 2689 {
2719 apply_armour_improver (op, tmp); 2690 apply_armour_improver (op, tmp);
2720 return 1; 2691 return 1;
2721 } 2692 }
2722 else 2693 else
2723 {
2724 return 0; 2694 return 0;
2725 }
2726 2695
2727 case WEAPON_IMPROVER: 2696 case WEAPON_IMPROVER:
2728 (void) check_improve_weapon (op, tmp); 2697 (void) check_improve_weapon (op, tmp);
2729 return 1; 2698 return 1;
2730 2699
2955 if (who->type == PLAYER) 2924 if (who->type == PLAYER)
2956 esrv_del_item (who->contr, op->count); 2925 esrv_del_item (who->contr, op->count);
2957 2926
2958 op->destroy (); 2927 op->destroy ();
2959 insert_ob_in_ob (tmp2, who); 2928 insert_ob_in_ob (tmp2, who);
2960 fix_player (who); 2929 who->update_stats ();
2961 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) 2930 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))
2962 { 2931 {
2963 if (who->type == PLAYER) 2932 if (who->type == PLAYER)
2964 { 2933 {
2965 new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); 2934 new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!");
2998 default: 2967 default:
2999 new_draw_info_format (NDI_UNIQUE, 0, who, "You unapply %s.", query_name (op)); 2968 new_draw_info_format (NDI_UNIQUE, 0, who, "You unapply %s.", query_name (op));
3000 break; 2969 break;
3001 } 2970 }
3002 2971
3003 fix_player (who); 2972 who->update_stats ();
3004 2973
3005 if (!(aflags & AP_NO_MERGE)) 2974 if (!(aflags & AP_NO_MERGE))
3006 { 2975 {
3007 object *tmp; 2976 object *tmp;
3008 2977
3497 { 3466 {
3498 (void) insert_ob_in_ob (tmp, who); 3467 (void) insert_ob_in_ob (tmp, who);
3499 if (who->type == PLAYER) 3468 if (who->type == PLAYER)
3500 esrv_send_item (who, tmp); 3469 esrv_send_item (who, tmp);
3501 } 3470 }
3502 fix_player (who); 3471 who->update_stats ();
3503 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) 3472 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))
3504 { 3473 {
3505 if (who->type == PLAYER) 3474 if (who->type == PLAYER)
3506 { 3475 {
3507 new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); 3476 new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!");
3604 SET_FLAG (op, FLAG_APPLIED); 3573 SET_FLAG (op, FLAG_APPLIED);
3605 3574
3606 if (tmp != NULL) 3575 if (tmp != NULL)
3607 tmp = insert_ob_in_ob (tmp, who); 3576 tmp = insert_ob_in_ob (tmp, who);
3608 3577
3609 fix_player (who); 3578 who->update_stats ();
3610 3579
3611 /* We exclude spell casting objects. The fire code will set the 3580 /* We exclude spell casting objects. The fire code will set the
3612 * been applied flag when they are used - until that point, 3581 * been applied flag when they are used - until that point,
3613 * you don't know anything about them. 3582 * you don't know anything about them.
3614 */ 3583 */
3725 int x, y; 3694 int x, y;
3726 3695
3727 if (m == NULL) 3696 if (m == NULL)
3728 return; 3697 return;
3729 3698
3730 for (x = 0; x < MAP_WIDTH (m); x++) 3699 for (x = 0; x < m->width; x++)
3731 for (y = 0; y < MAP_HEIGHT (m); y++) 3700 for (y = 0; y < m->height; y++)
3732 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = above) 3701 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above)
3733 { 3702 {
3734 above = tmp->above; 3703 above = tmp->above;
3735 3704
3736 if (tmp->inv) 3705 if (tmp->inv)
3737 { 3706 {
3808 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); 3777 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0);
3809 tmp->randomitems = NULL; 3778 tmp->randomitems = NULL;
3810 } 3779 }
3811 } 3780 }
3812 3781
3813 for (x = 0; x < MAP_WIDTH (m); x++) 3782 for (x = 0; x < m->width; x++)
3814 for (y = 0; y < MAP_HEIGHT (m); y++) 3783 for (y = 0; y < m->height; y++)
3815 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 3784 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
3816 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) 3785 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
3817 check_trigger (tmp, tmp->above); 3786 check_trigger (tmp, tmp->above);
3818} 3787}
3819 3788
3820/** 3789/**
3850 { 3819 {
3851 force->resist[i] = food->resist[i] / 2; 3820 force->resist[i] = food->resist[i] / 2;
3852 did_one = 1; 3821 did_one = 1;
3853 } 3822 }
3854 } 3823 }
3824
3855 if (did_one) 3825 if (did_one)
3856 { 3826 {
3857 force->speed = 0.1; 3827 force->speed = 0.1;
3858 update_ob_speed (force); 3828 update_ob_speed (force);
3859 /* bigger morsel of food = longer effect time */ 3829 /* bigger morsel of food = longer effect time */
3860 force->stats.food = food->stats.food / 5; 3830 force->duration = food->stats.food / 5;
3861 SET_FLAG (force, FLAG_IS_USED_UP);
3862 SET_FLAG (force, FLAG_APPLIED); 3831 SET_FLAG (force, FLAG_APPLIED);
3863 change_abil (who, force); 3832 change_abil (who, force);
3864 insert_ob_in_ob (force, who); 3833 insert_ob_in_ob (force, who);
3865 } 3834 }
3866 else 3835 else
3898 new_draw_info (NDI_UNIQUE, 0, who, "You feel a rush of magical energy!"); 3867 new_draw_info (NDI_UNIQUE, 0, who, "You feel a rush of magical energy!");
3899 who->stats.sp += food->stats.sp; 3868 who->stats.sp += food->stats.sp;
3900 /* place limit on max sp from food? */ 3869 /* place limit on max sp from food? */
3901 } 3870 }
3902 } 3871 }
3903 fix_player (who); 3872 who->update_stats ();
3904} 3873}
3905
3906 3874
3907/** 3875/**
3908 * Designed primarily to light torches/lanterns/etc. 3876 * Designed primarily to light torches/lanterns/etc.
3909 * Also burns up burnable material too. First object in the inventory is 3877 * Also burns up burnable material too. First object in the inventory is
3910 * the selected object to "burn". -b.t. 3878 * the selected object to "burn". -b.t.
3911 */ 3879 */
3912
3913void 3880void
3914apply_lighter (object *who, object *lighter) 3881apply_lighter (object *who, object *lighter)
3915{ 3882{
3916 object *item; 3883 object *item;
3917 int is_player_env = 0; 3884 int is_player_env = 0;
3918 char item_name[MAX_BUF];
3919 3885
3920 item = find_marked_object (who); 3886 item = find_marked_object (who);
3921 if (item) 3887 if (item)
3922 { 3888 {
3923 if (lighter->last_eat && lighter->stats.food) 3889 if (lighter->last_eat && lighter->stats.food)
3941 else if (lighter->last_eat) 3907 else if (lighter->last_eat)
3942 { /* no charges left in lighter */ 3908 { /* no charges left in lighter */
3943 new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with a used up %s.", &item->name, &lighter->name); 3909 new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with a used up %s.", &item->name, &lighter->name);
3944 return; 3910 return;
3945 } 3911 }
3912
3946 /* Perhaps we should split what we are trying to light on fire? 3913 /* Perhaps we should split what we are trying to light on fire?
3947 * I can't see many times when you would want to light multiple 3914 * I can't see many times when you would want to light multiple
3948 * objects at once. 3915 * objects at once.
3949 */ 3916 */
3950 /* If the item is destroyed, we don't have a valid pointer to the 3917
3951 * name object, so make a copy so the message we print out makes
3952 * some sense.
3953 */
3954 strcpy (item_name, item->name);
3955 if (who == is_player_inv (item)) 3918 if (who == item->in_player ())
3956 is_player_env = 1; 3919 is_player_env = 1;
3957 3920
3958 save_throw_object (item, AT_FIRE, who); 3921 save_throw_object (item, AT_FIRE, who);
3959 /* Change to check count and not freed, since the object pointer 3922
3960 * may have gotten recycled
3961 */
3962 if (item->destroyed ()) 3923 if (item->destroyed ())
3963 { 3924 {
3964 new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item_name, &lighter->name); 3925 new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item->name, &lighter->name);
3965 /* Need to update the player so that the players glow radius 3926 /* Need to update the player so that the players glow radius
3966 * gets changed. 3927 * gets changed.
3967 */ 3928 */
3968 if (is_player_env) 3929 if (is_player_env)
3969 fix_player (who); 3930 who->update_stats ();
3970 } 3931 }
3971 else 3932 else
3972 new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with the %s and fail.", &item->name, &lighter->name); 3933 new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with the %s and fail.", &item->name, &lighter->name);
3973 } 3934 }
3974 else /* nothing to light */ 3935 else /* nothing to light */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines