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

Comparing deliantra/server/server/skill_util.C (file contents):
Revision 1.63 by root, Wed May 7 23:25:58 2008 UTC vs.
Revision 1.64 by root, Mon Sep 22 01:33:10 2008 UTC

656 */ 656 */
657//TODO: egad, do it in perl, do not suffer from the big buffer on stack, make it one single drawinfo. 657//TODO: egad, do it in perl, do not suffer from the big buffer on stack, make it one single drawinfo.
658void 658void
659show_skills (object *op, const char *search) 659show_skills (object *op, const char *search)
660{ 660{
661 object *tmp = NULL;
662 char buf[MAX_BUF];
663 const char *cp; 661 const char *cp;
664 int i, num_skills_found = 0; 662 int i, num_skills_found = 0;
665 static const char *const periods = "........................................"; 663 const char *const periods = ".............................."; // 30
666 664
667 /* Need to have a pointer and use strdup for qsort to work properly */ 665 /* Need to have a pointer and use strdup for qsort to work properly */
668 char skills[NUM_SKILLS][MAX_BUF]; 666 char skills[NUM_SKILLS][128]; // d'oh
669 667
670 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 668 for (object *tmp = op->inv; tmp; tmp = tmp->below)
671 { 669 {
672 if (tmp->type == SKILL) 670 if (tmp->type == SKILL)
673 { 671 {
674 if (search && strstr (tmp->name, search) == NULL) 672 if (search && !strstr (tmp->name, search))
675 continue; 673 continue;
674
675 char buf[30];
676
676 /* Basically want to fill this out to 40 spaces with periods */ 677 /* Basically want to fill this out to 30 spaces with periods */
677 sprintf (buf, "%s%s", &tmp->name, periods); 678 snprintf (buf, sizeof (buf), "%s%s", &tmp->name, periods);
678 buf[40] = 0;
679 679
680 if (settings.permanent_exp_ratio) 680 if (settings.permanent_exp_ratio)
681 sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%" PRId64 "/%" PRId64 "/%d%%)", 681 snprintf (skills[num_skills_found++], sizeof (skills [0]), "%slvl:%3d (xp:%" PRId64 "/%" PRId64 "/%d%%)",
682 buf, tmp->level, tmp->stats.exp, 682 buf, tmp->level, tmp->stats.exp,
683 level_exp (tmp->level + 1, op->expmul), clipped_percent (tmp->perm_exp, tmp->stats.exp)); 683 level_exp (tmp->level + 1, op->expmul), clipped_percent (tmp->perm_exp, tmp->stats.exp));
684 else 684 else
685 sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%" PRId64 "/%" PRId64 ")", 685 snprintf (skills[num_skills_found++], sizeof (skills [0]), "%slvl:%3d (xp:%" PRId64 "/%" PRId64 ")",
686 buf, tmp->level, tmp->stats.exp, level_exp (tmp->level + 1, op->expmul)); 686 buf, tmp->level, tmp->stats.exp, level_exp (tmp->level + 1, op->expmul));
687 687
688 /* I don't know why some characters get a bunch of skills, but 688 /* I don't know why some characters get a bunch of skills, but
689 * it sometimes happens (maybe a leftover from bugier earlier code 689 * it sometimes happens (maybe a leftover from bugier earlier code
690 * and those character are still about). In any case, lets handle 690 * and those character are still about). In any case, lets handle
691 * it so it doesn't crash the server - otherwise, one character may 691 * it so it doesn't crash the server - otherwise, one character may
698 break; 698 break;
699 } 699 }
700 } 700 }
701 } 701 }
702 702
703 new_draw_info (NDI_UNIQUE, 0, op, "Player skills:"); 703 dynbuf_text msg (4096, 1024);
704
705 msg << "T<Player skills:>\n\n";
704 if (num_skills_found > 1) 706 if (num_skills_found > 1)
705 qsort (skills, num_skills_found, MAX_BUF, (int (*)(const void *, const void *)) std::strcmp); 707 qsort (skills, num_skills_found, sizeof (skills [0]), (int (*)(const void *, const void *)) std::strcmp);
706 708
707 for (i = 0; i < num_skills_found; i++) 709 for (i = 0; i < num_skills_found; i++)
708 new_draw_info (NDI_UNIQUE, 0, op, skills[i]); 710 msg << " C<" << skills [i] << ">\n";
709 711
710 new_draw_info_format (NDI_UNIQUE, 0, op, "You can handle %d weapon improvements.", op->level / 5 + 5); 712 msg << "\nYou can handle " << op->level / 5 + 5 << " weapon improvements.\r";
711 713
712 cp = determine_god (op); 714 cp = determine_god (op);
713 new_draw_info_format (NDI_UNIQUE, 0, op, "You worship %s.", cp ? cp : "no god at current time"); 715 msg << "You worship " << (cp ? cp : "no god at current time") << ".\r";
714 716
715 new_draw_info_format (NDI_UNIQUE, 0, op, "Your equipped item power is %d out of %d\n", 717 msg << "Your equipped item power is " << (int)op->contr->item_power
716 op->contr->item_power, (int) (op->level * settings.item_power_factor)); 718 << " out of " << int (op->level * settings.item_power_factor)
719 << "\n";
720
721 op->contr->infobox (MSG_CHANNEL ("skills"), msg);
717} 722}
718 723
719/* use_skill() - similar to invoke command, it executes the skill in the 724/* use_skill() - similar to invoke command, it executes the skill in the
720 * direction that the user is facing. Returns false if we are unable to 725 * direction that the user is facing. Returns false if we are unable to
721 * change to the requested skill, or were unable to use the skill properly. 726 * change to the requested skill, or were unable to use the skill properly.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines