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.29 by root, Thu Sep 14 23:13:49 2006 UTC

2082 */ 2082 */
2083static void 2083static void
2084apply_treasure (object *op, object *tmp) 2084apply_treasure (object *op, object *tmp)
2085{ 2085{
2086 object *treas; 2086 object *treas;
2087 tag_t tmp_tag = tmp->count, op_tag = op->count;
2088 2087
2089 2088
2090 /* Nice side effect of new treasure creation method is that the treasure 2089 /* 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 2090 * 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 2091 * 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 2116 /* If either player or container was destroyed, no need to do
2118 * further processing. I think this should be enclused with 2117 * further processing. I think this should be enclused with
2119 * spring trap above, as I don't think there is otherwise 2118 * spring trap above, as I don't think there is otherwise
2120 * any way for the treasure chest or player to get killed 2119 * any way for the treasure chest or player to get killed
2121 */ 2120 */
2122 if (was_destroyed (op, op_tag) || was_destroyed (tmp, tmp_tag)) 2121 if (op->destroyed () || tmp->destroyed ())
2123 break; 2122 break;
2124 } 2123 }
2125 2124
2126 if (!was_destroyed (tmp, tmp_tag) && tmp->inv == NULL) 2125 if (!tmp->destroyed () && tmp->inv == NULL)
2127 decrease_ob (tmp); 2126 decrease_ob (tmp);
2128 2127
2129} 2128}
2130 2129
2131/** 2130/**
2946 tmp2->map = op->map; 2945 tmp2->map = op->map;
2947 tmp2->below = op->below; 2946 tmp2->below = op->below;
2948 tmp2->above = op->above; 2947 tmp2->above = op->above;
2949 tmp2->stats.food = op->stats.food; 2948 tmp2->stats.food = op->stats.food;
2950 CLEAR_FLAG (tmp2, FLAG_APPLIED); 2949 CLEAR_FLAG (tmp2, FLAG_APPLIED);
2950
2951 if (QUERY_FLAG (op, FLAG_INV_LOCKED)) 2951 if (QUERY_FLAG (op, FLAG_INV_LOCKED))
2952 SET_FLAG (tmp2, FLAG_INV_LOCKED); 2952 SET_FLAG (tmp2, FLAG_INV_LOCKED);
2953
2953 if (who->type == PLAYER) 2954 if (who->type == PLAYER)
2954 esrv_del_item (who->contr, (tag_t) op->count); 2955 esrv_del_item (who->contr, op->count);
2956
2955 remove_ob (op); 2957 remove_ob (op);
2956 free_object (op); 2958 free_object (op);
2957 insert_ob_in_ob (tmp2, who); 2959 insert_ob_in_ob (tmp2, who);
2958 fix_player (who); 2960 fix_player (who);
2959 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) 2961 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))
3002 3004
3003 if (!(aflags & AP_NO_MERGE)) 3005 if (!(aflags & AP_NO_MERGE))
3004 { 3006 {
3005 object *tmp; 3007 object *tmp;
3006 3008
3007 tag_t del_tag = op->count;
3008
3009 tmp = merge_ob (op, NULL); 3009 tmp = merge_ob (op, NULL);
3010 if (who->type == PLAYER) 3010 if (who->type == PLAYER)
3011 { 3011 {
3012 if (tmp) 3012 if (tmp)
3013 { /* it was merged */ 3013 { /* it was merged */
3014 esrv_del_item (who->contr, del_tag); 3014 esrv_del_item (who->contr, op->count);
3015 op = tmp; 3015 op = tmp;
3016 } 3016 }
3017
3017 esrv_send_item (who, op); 3018 esrv_send_item (who, op);
3018 } 3019 }
3019 } 3020 }
3020 return 0; 3021 return 0;
3021} 3022}
3485 SET_FLAG (tmp2, FLAG_INV_LOCKED); 3486 SET_FLAG (tmp2, FLAG_INV_LOCKED);
3486 insert_ob_in_ob (tmp2, who); 3487 insert_ob_in_ob (tmp2, who);
3487 3488
3488 /* Remove the old lantern */ 3489 /* Remove the old lantern */
3489 if (who->type == PLAYER) 3490 if (who->type == PLAYER)
3490 esrv_del_item (who->contr, (tag_t) op->count); 3491 esrv_del_item (who->contr, op->count);
3492
3491 remove_ob (op); 3493 remove_ob (op);
3492 free_object (op); 3494 free_object (op);
3493 3495
3494 /* insert the portion that was split off */ 3496 /* insert the portion that was split off */
3495 if (tmp != NULL) 3497 if (tmp != NULL)
3910void 3912void
3911apply_lighter (object *who, object *lighter) 3913apply_lighter (object *who, object *lighter)
3912{ 3914{
3913 object *item; 3915 object *item;
3914 int is_player_env = 0; 3916 int is_player_env = 0;
3915 uint32 nrof;
3916 tag_t count;
3917 char item_name[MAX_BUF]; 3917 char item_name[MAX_BUF];
3918 3918
3919 item = find_marked_object (who); 3919 item = find_marked_object (who);
3920 if (item) 3920 if (item)
3921 { 3921 {
3934 esrv_send_item (who, lighter); 3934 esrv_send_item (who, lighter);
3935 oneLighter = insert_ob_in_ob (oneLighter, who); 3935 oneLighter = insert_ob_in_ob (oneLighter, who);
3936 esrv_send_item (who, oneLighter); 3936 esrv_send_item (who, oneLighter);
3937 } 3937 }
3938 else 3938 else
3939 {
3940 lighter->stats.food--; 3939 lighter->stats.food--;
3941 }
3942
3943 } 3940 }
3944 else if (lighter->last_eat) 3941 else if (lighter->last_eat)
3945 { /* no charges left in lighter */ 3942 { /* 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); 3943 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; 3944 return;
3948 } 3945 }
3949 /* Perhaps we should split what we are trying to light on fire? 3946 /* 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 3947 * I can't see many times when you would want to light multiple
3951 * objects at once. 3948 * objects at once.
3952 */ 3949 */
3953 nrof = item->nrof;
3954 count = item->count;
3955 /* If the item is destroyed, we don't have a valid pointer to the 3950 /* 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 3951 * name object, so make a copy so the message we print out makes
3957 * some sense. 3952 * some sense.
3958 */ 3953 */
3959 strcpy (item_name, item->name); 3954 strcpy (item_name, item->name);
3962 3957
3963 save_throw_object (item, AT_FIRE, who); 3958 save_throw_object (item, AT_FIRE, who);
3964 /* Change to check count and not freed, since the object pointer 3959 /* Change to check count and not freed, since the object pointer
3965 * may have gotten recycled 3960 * may have gotten recycled
3966 */ 3961 */
3967 if ((nrof != item->nrof) || (count != item->count)) 3962 if (item->destroyed ())
3968 { 3963 {
3969 new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item_name, &lighter->name); 3964 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 3965 /* Need to update the player so that the players glow radius
3971 * gets changed. 3966 * gets changed.
3972 */ 3967 */
3973 if (is_player_env) 3968 if (is_player_env)
3974 fix_player (who); 3969 fix_player (who);
3975 } 3970 }
3976 else 3971 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); 3972 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 } 3973 }
3982 else /* nothing to light */ 3974 else /* nothing to light */
3983 new_draw_info (NDI_UNIQUE, 0, who, "You need to mark a lightable object."); 3975 new_draw_info (NDI_UNIQUE, 0, who, "You need to mark a lightable object.");
3984 3976
3985} 3977}
4205 if (!new_item) 4197 if (!new_item)
4206 { 4198 {
4207 new_draw_info_format (NDI_UNIQUE, 0, pl, "This %s is strange, better to not use it.", query_base_name (marked, 0)); 4199 new_draw_info_format (NDI_UNIQUE, 0, pl, "This %s is strange, better to not use it.", query_base_name (marked, 0));
4208 return; 4200 return;
4209 } 4201 }
4202
4210 new_item->nrof = yield; 4203 new_item->nrof = yield;
4211 new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); 4204 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); 4205 insert_ob_in_ob (new_item, pl);
4213 esrv_send_inventory (pl, pl); 4206 esrv_send_inventory (pl, pl);
4214 /* Eat up one item */ 4207 /* Eat up one item */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines