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.316 by root, Sun Mar 28 02:53:46 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 if (chosen_skill)
621 chosen_skill->flag [FLAG_APPLIED] = false;
622
623 current_weapon = chosen_skill = 0;
624 update_stats ();
625
626 new_draw_info_format (NDI_UNIQUE, 0, this,
627 "You try to balance all your items at once, "
628 "but the %s is just too much for your body. "
629 "[You need to unapply some items first - use the 'body' command to see "
630 "how many items you can wear on a specific body part.]", &ob->name);
631 return false;
632 }
633
634 //new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name);
635 } 603 {
636 else 604 manual_apply (this, current_weapon, AP_UNAPPLY);
637 ;//new_draw_info_format (NDI_UNIQUE, 0, this, "You unwield your weapons.");
638 605
639 if (ob && !ob->flag [FLAG_APPLIED] && ob->type != SPELL) 606 if (current_weapon && !current_weapon->flag [FLAG_APPLIED])//D
640 { 607 LOG (llevError, "FATAL: did not clear current_weapon (%s)\n", current_weapon->debug_desc ());
641 LOG (llevError | logBacktrace, "%s changed to unapplied weapon %s", 608
642 &name, ob->debug_desc ()); 609 if (current_weapon && current_weapon->flag [FLAG_APPLIED])
643 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;
644 } 623 }
645 624
646 return true; 625 return true;
647} 626}
648 627
1152 below = 0; 1131 below = 0;
1153 env = 0; 1132 env = 0;
1154 1133
1155 if (pl && pl->is_player ()) 1134 if (pl && pl->is_player ())
1156 { 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
1157 pl->contr->queue_stats_update (); 1150 pl->contr->queue_stats_update ();
1158 1151
1159 if (glow_radius && pl->is_on_map ()) 1152 if (expect_false (glow_radius) && pl->is_on_map ())
1160 update_all_los (pl->map, pl->x, pl->y); 1153 update_all_los (pl->map, pl->x, pl->y);
1161 } 1154 }
1162 } 1155 }
1163 else if (map) 1156 else if (map)
1164 { 1157 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines