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.56 by root, Mon Jun 4 13:04:00 2007 UTC vs.
Revision 1.57 by root, Tue Jun 5 13:05:03 2007 UTC

657 * Note this function is a bit more complicated becauase we 657 * Note this function is a bit more complicated becauase we
658 * we want ot sort the skills before printing them. If we 658 * we want ot sort the skills before printing them. If we
659 * just dumped this as we found it, this would be a bit 659 * just dumped this as we found it, this would be a bit
660 * simpler. 660 * simpler.
661 */ 661 */
662 662//TODO: egad, do it in perl, do not suffer from the big buffer on stack, make it one single drawinfo.
663void 663void
664show_skills (object *op, const char *search) 664show_skills (object *op, const char *search)
665{ 665{
666 object *tmp = NULL; 666 object *tmp = NULL;
667 char buf[MAX_BUF]; 667 char buf[MAX_BUF];
669 int i, num_skills_found = 0; 669 int i, num_skills_found = 0;
670 static const char *const periods = "........................................"; 670 static const char *const periods = "........................................";
671 671
672 /* Need to have a pointer and use strdup for qsort to work properly */ 672 /* Need to have a pointer and use strdup for qsort to work properly */
673 char skills[NUM_SKILLS][MAX_BUF]; 673 char skills[NUM_SKILLS][MAX_BUF];
674
675 674
676 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 675 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
677 { 676 {
678 if (tmp->type == SKILL) 677 if (tmp->type == SKILL)
679 { 678 {
682 /* Basically want to fill this out to 40 spaces with periods */ 681 /* Basically want to fill this out to 40 spaces with periods */
683 sprintf (buf, "%s%s", &tmp->name, periods); 682 sprintf (buf, "%s%s", &tmp->name, periods);
684 buf[40] = 0; 683 buf[40] = 0;
685 684
686 if (settings.permanent_exp_ratio) 685 if (settings.permanent_exp_ratio)
687 {
688 sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%" PRId64 "/%" PRId64 "/%d%%)", 686 sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%" PRId64 "/%" PRId64 "/%d%%)",
689 buf, tmp->level, tmp->stats.exp, 687 buf, tmp->level, tmp->stats.exp,
690 level_exp (tmp->level + 1, op->expmul), clipped_percent (tmp->perm_exp, tmp->stats.exp)); 688 level_exp (tmp->level + 1, op->expmul), clipped_percent (tmp->perm_exp, tmp->stats.exp));
691 }
692 else 689 else
693 {
694 sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%" PRId64 "/%" PRId64 ")", 690 sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%" PRId64 "/%" PRId64 ")",
695 buf, tmp->level, tmp->stats.exp, level_exp (tmp->level + 1, op->expmul)); 691 buf, tmp->level, tmp->stats.exp, level_exp (tmp->level + 1, op->expmul));
696 } 692
697 /* I don't know why some characters get a bunch of skills, but 693 /* I don't know why some characters get a bunch of skills, but
698 * it sometimes happens (maybe a leftover from bugier earlier code 694 * it sometimes happens (maybe a leftover from bugier earlier code
699 * and those character are still about). In any case, lets handle 695 * and those character are still about). In any case, lets handle
700 * it so it doesn't crash the server - otherwise, one character may 696 * it so it doesn't crash the server - otherwise, one character may
701 * crash the server numerous times. 697 * crash the server numerous times.
707 break; 703 break;
708 } 704 }
709 } 705 }
710 } 706 }
711 707
712 clear_win_info (op);
713 new_draw_info (NDI_UNIQUE, 0, op, "Player skills:"); 708 new_draw_info (NDI_UNIQUE, 0, op, "Player skills:");
714 if (num_skills_found > 1) 709 if (num_skills_found > 1)
715 qsort (skills, num_skills_found, MAX_BUF, (int (*)(const void *, const void *)) std::strcmp); 710 qsort (skills, num_skills_found, MAX_BUF, (int (*)(const void *, const void *)) std::strcmp);
716 711
717 for (i = 0; i < num_skills_found; i++) 712 for (i = 0; i < num_skills_found; i++)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines