ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/object.C
(Generate patch)

Comparing deliantra/server/common/object.C (file contents):
Revision 1.315 by root, Fri Mar 26 21:43:43 2010 UTC vs.
Revision 1.317 by root, Fri Apr 2 03:41:24 2010 UTC

597object::change_weapon (object *ob) 597object::change_weapon (object *ob)
598{ 598{
599 if (current_weapon == ob) 599 if (current_weapon == ob)
600 return true; 600 return true;
601 601
602 if (chosen_skill) 602 if (current_weapon && current_weapon->flag [FLAG_APPLIED])
603 chosen_skill->flag [FLAG_APPLIED] = false;
604
605 current_weapon = ob;
606 chosen_skill = !ob || ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill);
607
608 if (chosen_skill)
609 chosen_skill->flag [FLAG_APPLIED] = true;
610
611 update_stats ();
612
613 if (ob)
614 {
615 // now check wether any body locations became invalid, in which case
616 // we cannot apply the weapon at the moment.
617 for (int i = 0; i < NUM_BODY_LOCATIONS; ++i)
618 if (slot[i].used < 0)
619 {
620 current_weapon = chosen_skill = 0;
621 update_stats ();
622
623 new_draw_info_format (NDI_UNIQUE, 0, this,
624 "You try to balance all your items at once, "
625 "but the %s is just too much for your body. "
626 "[You need to unapply some items first - use the 'body' command to see "
627 "how many items you can wear on a specific body part.]", &ob->name);
628 return false;
629 }
630
631 //new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name);
632 } 603 {
633 else 604 manual_apply (this, current_weapon, AP_UNAPPLY);
634 ;//new_draw_info_format (NDI_UNIQUE, 0, this, "You unwield your weapons.");
635 605
636 if (ob && !ob->flag [FLAG_APPLIED] && ob->type != SPELL) 606 if (current_weapon && !current_weapon->flag [FLAG_APPLIED])//D
637 { 607 LOG (llevError, "FATAL: did not clear current_weapon (%s)\n", current_weapon->debug_desc ());
638 LOG (llevError | logBacktrace, "%s changed to unapplied weapon %s", 608
639 &name, ob->debug_desc ()); 609 if (current_weapon && current_weapon->flag [FLAG_APPLIED])
640 return false; 610 return false;
611 }
612
613 current_weapon = 0;
614
615 if (ob && !ob->flag [FLAG_APPLIED])
616 {
617 manual_apply (this, ob, AP_APPLY);
618
619 if (ob->flag [FLAG_APPLIED])
620 current_weapon = ob;
621 else
622 return false;
641 } 623 }
642 624
643 return true; 625 return true;
644} 626}
645 627
1149 below = 0; 1131 below = 0;
1150 env = 0; 1132 env = 0;
1151 1133
1152 if (pl && pl->is_player ()) 1134 if (pl && pl->is_player ())
1153 { 1135 {
1136 if (expect_false (pl->contr->combat_ob == this))
1137 {
1138 pl->apply (pl->contr->combat_ob, AP_UNAPPLY);
1139 pl->contr->combat_ob = 0;
1140 if (pl->contr->ranged_ob) pl->apply (pl->contr->ranged_ob);
1141 }
1142
1143 if (expect_false (pl->contr->ranged_ob == this))
1144 {
1145 pl->apply (pl->contr->ranged_ob, AP_UNAPPLY);
1146 pl->contr->ranged_ob = 0;
1147 if (pl->contr->combat_ob) pl->apply (pl->contr->combat_ob);
1148 }
1149
1154 pl->contr->queue_stats_update (); 1150 pl->contr->queue_stats_update ();
1155 1151
1156 if (glow_radius && pl->is_on_map ()) 1152 if (expect_false (glow_radius) && pl->is_on_map ())
1157 update_all_los (pl->map, pl->x, pl->y); 1153 update_all_los (pl->map, pl->x, pl->y);
1158 } 1154 }
1159 } 1155 }
1160 else if (map) 1156 else if (map)
1161 { 1157 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines