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.28 by root, Thu Sep 14 22:34:03 2006 UTC vs.
Revision 1.31 by root, Sun Dec 3 20:26:35 2006 UTC

1942 { 1942 {
1943 LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); 1943 LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name);
1944 new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense."); 1944 new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense.");
1945 return; 1945 return;
1946 } 1946 }
1947
1947 if (spell->level > (skop->level + 10)) 1948 if (spell->level > (skop->level + 10))
1948 { 1949 {
1949 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); 1950 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols.");
1950 return; 1951 return;
1951 } 1952 }
2082 */ 2083 */
2083static void 2084static void
2084apply_treasure (object *op, object *tmp) 2085apply_treasure (object *op, object *tmp)
2085{ 2086{
2086 object *treas; 2087 object *treas;
2087 tag_t tmp_tag = tmp->count, op_tag = op->count;
2088 2088
2089 2089
2090 /* Nice side effect of new treasure creation method is that the treasure 2090 /* Nice side effect of new treasure creation method is that the treasure
2091 * for the chest is done when the chest is created, and put into the chest 2091 * for the chest is done when the chest is created, and put into the chest
2092 * inventory. So that when the chest burns up, the items still exist. Also 2092 * inventory. So that when the chest burns up, the items still exist. Also
2117 /* If either player or container was destroyed, no need to do 2117 /* If either player or container was destroyed, no need to do
2118 * further processing. I think this should be enclused with 2118 * further processing. I think this should be enclused with
2119 * spring trap above, as I don't think there is otherwise 2119 * spring trap above, as I don't think there is otherwise
2120 * any way for the treasure chest or player to get killed 2120 * any way for the treasure chest or player to get killed
2121 */ 2121 */
2122 if (was_destroyed (op, op_tag) || was_destroyed (tmp, tmp_tag)) 2122 if (op->destroyed () || tmp->destroyed ())
2123 break; 2123 break;
2124 } 2124 }
2125 2125
2126 if (!was_destroyed (tmp, tmp_tag) && tmp->inv == NULL) 2126 if (!tmp->destroyed () && tmp->inv == NULL)
2127 decrease_ob (tmp); 2127 decrease_ob (tmp);
2128 2128
2129} 2129}
2130 2130
2131/** 2131/**
2459is_legal_2ways_exit (object *op, object *exit) 2459is_legal_2ways_exit (object *op, object *exit)
2460{ 2460{
2461 object *tmp; 2461 object *tmp;
2462 object *exit_owner; 2462 object *exit_owner;
2463 player *pp; 2463 player *pp;
2464 mapstruct *exitmap; 2464 maptile *exitmap;
2465 2465
2466 if (exit->stats.exp != 1) 2466 if (exit->stats.exp != 1)
2467 return 1; /*This is not a 2 way, so it is legal */ 2467 return 1; /*This is not a 2 way, so it is legal */
2468 if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) 2468 if (!has_been_loaded (EXIT_PATH (exit)) && exit->race)
2469 return 0; /* This is a reset town portal */ 2469 return 0; /* This is a reset town portal */
2946 tmp2->map = op->map; 2946 tmp2->map = op->map;
2947 tmp2->below = op->below; 2947 tmp2->below = op->below;
2948 tmp2->above = op->above; 2948 tmp2->above = op->above;
2949 tmp2->stats.food = op->stats.food; 2949 tmp2->stats.food = op->stats.food;
2950 CLEAR_FLAG (tmp2, FLAG_APPLIED); 2950 CLEAR_FLAG (tmp2, FLAG_APPLIED);
2951
2951 if (QUERY_FLAG (op, FLAG_INV_LOCKED)) 2952 if (QUERY_FLAG (op, FLAG_INV_LOCKED))
2952 SET_FLAG (tmp2, FLAG_INV_LOCKED); 2953 SET_FLAG (tmp2, FLAG_INV_LOCKED);
2954
2953 if (who->type == PLAYER) 2955 if (who->type == PLAYER)
2954 esrv_del_item (who->contr, (tag_t) op->count); 2956 esrv_del_item (who->contr, op->count);
2957
2955 remove_ob (op); 2958 remove_ob (op);
2956 free_object (op); 2959 free_object (op);
2957 insert_ob_in_ob (tmp2, who); 2960 insert_ob_in_ob (tmp2, who);
2958 fix_player (who); 2961 fix_player (who);
2959 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) 2962 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))
3002 3005
3003 if (!(aflags & AP_NO_MERGE)) 3006 if (!(aflags & AP_NO_MERGE))
3004 { 3007 {
3005 object *tmp; 3008 object *tmp;
3006 3009
3007 tag_t del_tag = op->count;
3008
3009 tmp = merge_ob (op, NULL); 3010 tmp = merge_ob (op, NULL);
3010 if (who->type == PLAYER) 3011 if (who->type == PLAYER)
3011 { 3012 {
3012 if (tmp) 3013 if (tmp)
3013 { /* it was merged */ 3014 { /* it was merged */
3014 esrv_del_item (who->contr, del_tag); 3015 esrv_del_item (who->contr, op->count);
3015 op = tmp; 3016 op = tmp;
3016 } 3017 }
3018
3017 esrv_send_item (who, op); 3019 esrv_send_item (who, op);
3018 } 3020 }
3019 } 3021 }
3020 return 0; 3022 return 0;
3021} 3023}
3485 SET_FLAG (tmp2, FLAG_INV_LOCKED); 3487 SET_FLAG (tmp2, FLAG_INV_LOCKED);
3486 insert_ob_in_ob (tmp2, who); 3488 insert_ob_in_ob (tmp2, who);
3487 3489
3488 /* Remove the old lantern */ 3490 /* Remove the old lantern */
3489 if (who->type == PLAYER) 3491 if (who->type == PLAYER)
3490 esrv_del_item (who->contr, (tag_t) op->count); 3492 esrv_del_item (who->contr, op->count);
3493
3491 remove_ob (op); 3494 remove_ob (op);
3492 free_object (op); 3495 free_object (op);
3493 3496
3494 /* insert the portion that was split off */ 3497 /* insert the portion that was split off */
3495 if (tmp != NULL) 3498 if (tmp != NULL)
3712 * when an original map is loaded) and performs special actions for 3715 * when an original map is loaded) and performs special actions for
3713 * certain objects (most initialization of chests and creation of 3716 * certain objects (most initialization of chests and creation of
3714 * treasures and stuff). Calls auto_apply if appropriate. 3717 * treasures and stuff). Calls auto_apply if appropriate.
3715 */ 3718 */
3716void 3719void
3717fix_auto_apply (mapstruct *m) 3720fix_auto_apply (maptile *m)
3718{ 3721{
3719 object *tmp, *above = NULL; 3722 object *tmp, *above = NULL;
3720 int x, y; 3723 int x, y;
3721 3724
3722 if (m == NULL) 3725 if (m == NULL)
3910void 3913void
3911apply_lighter (object *who, object *lighter) 3914apply_lighter (object *who, object *lighter)
3912{ 3915{
3913 object *item; 3916 object *item;
3914 int is_player_env = 0; 3917 int is_player_env = 0;
3915 uint32 nrof;
3916 tag_t count;
3917 char item_name[MAX_BUF]; 3918 char item_name[MAX_BUF];
3918 3919
3919 item = find_marked_object (who); 3920 item = find_marked_object (who);
3920 if (item) 3921 if (item)
3921 { 3922 {
3934 esrv_send_item (who, lighter); 3935 esrv_send_item (who, lighter);
3935 oneLighter = insert_ob_in_ob (oneLighter, who); 3936 oneLighter = insert_ob_in_ob (oneLighter, who);
3936 esrv_send_item (who, oneLighter); 3937 esrv_send_item (who, oneLighter);
3937 } 3938 }
3938 else 3939 else
3939 {
3940 lighter->stats.food--; 3940 lighter->stats.food--;
3941 }
3942
3943 } 3941 }
3944 else if (lighter->last_eat) 3942 else if (lighter->last_eat)
3945 { /* no charges left in lighter */ 3943 { /* no charges left in lighter */
3946 new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with a used up %s.", &item->name, &lighter->name); 3944 new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with a used up %s.", &item->name, &lighter->name);
3947 return; 3945 return;
3948 } 3946 }
3949 /* Perhaps we should split what we are trying to light on fire? 3947 /* Perhaps we should split what we are trying to light on fire?
3950 * I can't see many times when you would want to light multiple 3948 * I can't see many times when you would want to light multiple
3951 * objects at once. 3949 * objects at once.
3952 */ 3950 */
3953 nrof = item->nrof;
3954 count = item->count;
3955 /* If the item is destroyed, we don't have a valid pointer to the 3951 /* If the item is destroyed, we don't have a valid pointer to the
3956 * name object, so make a copy so the message we print out makes 3952 * name object, so make a copy so the message we print out makes
3957 * some sense. 3953 * some sense.
3958 */ 3954 */
3959 strcpy (item_name, item->name); 3955 strcpy (item_name, item->name);
3962 3958
3963 save_throw_object (item, AT_FIRE, who); 3959 save_throw_object (item, AT_FIRE, who);
3964 /* Change to check count and not freed, since the object pointer 3960 /* Change to check count and not freed, since the object pointer
3965 * may have gotten recycled 3961 * may have gotten recycled
3966 */ 3962 */
3967 if ((nrof != item->nrof) || (count != item->count)) 3963 if (item->destroyed ())
3968 { 3964 {
3969 new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item_name, &lighter->name); 3965 new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item_name, &lighter->name);
3970 /* Need to update the player so that the players glow radius 3966 /* Need to update the player so that the players glow radius
3971 * gets changed. 3967 * gets changed.
3972 */ 3968 */
3973 if (is_player_env) 3969 if (is_player_env)
3974 fix_player (who); 3970 fix_player (who);
3975 } 3971 }
3976 else 3972 else
3977 {
3978 new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with the %s and fail.", &item->name, &lighter->name); 3973 new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with the %s and fail.", &item->name, &lighter->name);
3979 }
3980
3981 } 3974 }
3982 else /* nothing to light */ 3975 else /* nothing to light */
3983 new_draw_info (NDI_UNIQUE, 0, who, "You need to mark a lightable object."); 3976 new_draw_info (NDI_UNIQUE, 0, who, "You need to mark a lightable object.");
3984 3977
3985} 3978}
4205 if (!new_item) 4198 if (!new_item)
4206 { 4199 {
4207 new_draw_info_format (NDI_UNIQUE, 0, pl, "This %s is strange, better to not use it.", query_base_name (marked, 0)); 4200 new_draw_info_format (NDI_UNIQUE, 0, pl, "This %s is strange, better to not use it.", query_base_name (marked, 0));
4208 return; 4201 return;
4209 } 4202 }
4203
4210 new_item->nrof = yield; 4204 new_item->nrof = yield;
4211 new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); 4205 new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0));
4212 insert_ob_in_ob (new_item, pl); 4206 insert_ob_in_ob (new_item, pl);
4213 esrv_send_inventory (pl, pl); 4207 esrv_send_inventory (pl, pl);
4214 /* Eat up one item */ 4208 /* Eat up one item */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines