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.55 by root, Wed May 30 03:03:10 2007 UTC vs.
Revision 1.57 by root, Tue Jun 5 13:05:03 2007 UTC

61 * subtypes. 61 * subtypes.
62 */ 62 */
63void 63void
64init_skills (void) 64init_skills (void)
65{ 65{
66 for (archetype *at = first_archetype; at; at = at->next) 66 for_all_archetypes (at)
67 if (at->clone.type == SKILL) 67 if (at->type == SKILL)
68 { 68 {
69 if (skill_names[at->clone.subtype]) 69 if (skill_names[at->subtype])
70 LOG (llevError, "init_skills: multiple skill using same subtype %d, %s, %s\n", 70 LOG (llevError, "init_skills: multiple skill using same subtype %d, %s, %s\n",
71 at->clone.subtype, &skill_names[at->clone.subtype], &at->clone.skill); 71 at->subtype, &skill_names[at->subtype], &at->skill);
72 else 72 else
73 skill_names[at->clone.subtype] = at->clone.skill; 73 skill_names[at->subtype] = at->skill;
74 } 74 }
75 75
76 /* This isn't really an error if there is no skill subtype set, but 76 /* This isn't really an error if there is no skill subtype set, but
77 * checking for this may catch some user errors. 77 * checking for this may catch some user errors.
78 */ 78 */
548 /* if skill really is a skill, then we can look at the skill archetype for 548 /* if skill really is a skill, then we can look at the skill archetype for
549 * bse reward value (exp) and level multiplier factor. 549 * bse reward value (exp) and level multiplier factor.
550 */ 550 */
551 if (skill->type == SKILL) 551 if (skill->type == SKILL)
552 { 552 {
553 base += skill->arch->clone.stats.exp; 553 base += skill->arch->stats.exp;
554 if (settings.simple_exp) 554 if (settings.simple_exp)
555 { 555 {
556 if (skill->arch->clone.level) 556 if (skill->arch->level)
557 lvl_mult = (float) skill->arch->clone.level / 100.0; 557 lvl_mult = (float) skill->arch->level / 100.0;
558 else 558 else
559 lvl_mult = 1.0; /* no adjustment */ 559 lvl_mult = 1.0; /* no adjustment */
560 } 560 }
561 else 561 else
562 { 562 {
563 if (skill->level) 563 if (skill->level)
564 lvl_mult = ((float) skill->arch->clone.level * (float) op_lvl) / ((float) skill->level * 100.0); 564 lvl_mult = ((float) skill->arch->level * (float) op_lvl) / ((float) skill->level * 100.0);
565 else 565 else
566 lvl_mult = 1.0; 566 lvl_mult = 1.0;
567 } 567 }
568 } 568 }
569 else 569 else
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