From 75771acbe1cbbe573f95ca30c1f1a60a9dea96df Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Mar 2002 18:13:08 +0000 Subject: [PATCH] get_skill muss has_skill sein. --- src/common/gamecode/creport.c | 5 ----- src/common/gamecode/economy.c | 16 +++++++------- src/common/gamecode/laws.c | 21 +----------------- src/common/gamecode/monster.c | 4 ++-- src/common/gamecode/randenc.c | 38 +++----------------------------- src/common/gamecode/study.c | 10 +++------ src/common/items/xerewards.c | 11 --------- src/common/kernel/battle.c | 24 -------------------- src/common/kernel/combatspells.c | 4 ---- src/common/kernel/eressea.c | 13 ----------- src/common/kernel/reports.c | 7 ------ src/common/kernel/spell.c | 9 -------- src/common/kernel/unit.h | 8 ------- src/mapper/map_partei.c | 6 ++--- 14 files changed, 19 insertions(+), 157 deletions(-) diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index a07d5ef03..9ac3b77ce 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -671,13 +671,8 @@ cr_output_unit(FILE * F, const region * r, pr = 1; fprintf(F, "TALENTE\n"); } -#if SKILLPOINTS - fprintf(F, "%d %d;%s\n", get_skill(u, sk), esk, - add_translation(skillname(sk, NULL), skillname(sk, f->locale))); -#else fprintf(F, "%d %d;%s\n", u->number*level_days(get_level(u, sk)), esk, add_translation(skillname(sk, NULL), skillname(sk, f->locale))); -#endif } } /* spells */ diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 845ebb94a..eae1ad527 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -430,13 +430,13 @@ recruit(region * r, unit * u, strlist * S, } n = geti(); - if (get_skill(u, SK_MAGIC)) { + if (has_skill(u, SK_MAGIC)) { /* error158;de;{unit} in {region}: '{command}' - Magier arbeiten * grundsätzlich nur alleine! */ cmistake(u, S->s, 158, MSG_EVENT); return; } - if (get_skill(u, SK_ALCHEMY) + if (has_skill(u, SK_ALCHEMY) && count_skill(u->faction, SK_ALCHEMY) + n > max_skill(u->faction, SK_ALCHEMY)) { @@ -584,7 +584,7 @@ givemen(int n, unit * u, unit * u2, const char * cmd) && u2->faction != u->faction && ucontact(u2, u) == 0) { error = 73; - } else if (u2 && (get_skill(u, SK_MAGIC) || get_skill(u2, SK_MAGIC))) { + } else if (u2 && (has_skill(u, SK_MAGIC) || has_skill(u2, SK_MAGIC))) { error = 158; } else { if (n > u->number) n = u->number; @@ -607,17 +607,17 @@ givemen(int n, unit * u, unit * u2, const char * cmd) } } } - if (u2 && (get_skill(u, SK_ALCHEMY) || get_skill(u2, SK_ALCHEMY))) { + if (u2 && (has_skill(u, SK_ALCHEMY) || has_skill(u2, SK_ALCHEMY))) { k = count_skill(u2->faction, SK_ALCHEMY); /* Falls die Zieleinheit keine Alchemisten sind, werden sie nun * welche. */ - if (!get_skill(u2, SK_ALCHEMY) && get_skill(u, SK_ALCHEMY) > 0) + if (!has_skill(u2, SK_ALCHEMY) && has_skill(u, SK_ALCHEMY)) k += u2->number; /* Wenn in eine Alchemisteneinheit Personen verschoben werden */ - if (get_skill(u2, SK_ALCHEMY) && !get_skill(u, SK_ALCHEMY)) + if (has_skill(u2, SK_ALCHEMY) && !has_skill(u, SK_ALCHEMY)) k += n; /* Wenn Parteigrenzen überschritten werden */ @@ -736,7 +736,7 @@ giveunit(region * r, unit * u, unit * u2, strlist * S) return; } } - if (get_skill(u, SK_MAGIC)) { + if (has_skill(u, SK_MAGIC)) { if (count_skill(u2->faction, SK_MAGIC) + u->number > max_skill(u2->faction, SK_MAGIC)) { @@ -748,7 +748,7 @@ giveunit(region * r, unit * u, unit * u2, strlist * S) return; } } - if (get_skill(u, SK_ALCHEMY) + if (has_skill(u, SK_ALCHEMY) && count_skill(u2->faction, SK_ALCHEMY) + u->number > max_skill(u2->faction, SK_ALCHEMY)) { diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 94256bbb1..b96d88dbc 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -370,24 +370,6 @@ live(region * r) if (!is_monstrous(u)) { int effect = get_effect(u, oldpotiontype[P_FOOL]); if (effect > 0) { /* Trank "Dumpfbackenbrot" */ -#if SKILLPOINTS - skill_t sk, ibest = NOSKILL; - int best = 0; - for (sk = 0; sk < MAXSKILLS; sk++) { - if (get_skill(u, sk) > best) { - best = get_skill(u, sk); - ibest = sk; - } - } /* bestes Talent raussuchen */ - if (best > 0) { - int k = get_skill(u, ibest); - int value = min(effect, u->number) * 30; - k = min(k, value); - change_skill(u, ibest, -k); - ADDMSG(&u->faction->msgs, msg_message("dumbeffect", - "unit days skill", u, (k+29)/30, ibest)); - } /* sonst Glück gehabt: wer nix weiß, kann nix vergessen... */ -#else skill * sv = u->skills, * sb = NULL; while (sv!=u->skills+u->skill_size) { if (sb==NULL || skill_compare(sv, sb)>0) { @@ -401,7 +383,6 @@ live(region * r) ADDMSG(&u->faction->msgs, msg_message("dumbeffect", "unit weeks skill", u, weeks, (skill_t)sb->id)); } /* sonst Glück gehabt: wer nix weiß, kann nix vergessen... */ -#endif } } age_unit(r, u); @@ -2168,7 +2149,7 @@ set_passw(void) for (r2 = firstregion(u->faction); r2 != last; r2 = r2->next) { for (u2 = r->units; u2; u2 = u2->next) { if(u2->faction == u->faction - && get_skill(u2, SK_MAGIC)) { + && has_skill(u2, SK_MAGIC)) { m = get_mage(u2); m->magietyp = mtyp; } diff --git a/src/common/gamecode/monster.c b/src/common/gamecode/monster.c index ff12a3b03..9fe243fe5 100644 --- a/src/common/gamecode/monster.c +++ b/src/common/gamecode/monster.c @@ -869,7 +869,7 @@ learn_monster(unit *u) * Lerntage hat. */ for(sk=0;skfaction->locale, keywords[K_STUDY]), diff --git a/src/common/gamecode/randenc.c b/src/common/gamecode/randenc.c index f595f8d73..c9ddd4399 100644 --- a/src/common/gamecode/randenc.c +++ b/src/common/gamecode/randenc.c @@ -177,15 +177,10 @@ improve_all(faction * f, skill_t sk, int weeks) for (r = firstregion(f); r != last; r = r->next) { for (u = r->units; u; u = u->next) { - if (u->faction == f && get_skill(u, sk)) { -#if SKILLPOINTS - change_skill(u, sk, u->number * weeks * 30); - n += u->number; -#else + if (u->faction == f && has_skill(u, sk)) { for (n=0;n!=weeks;++n) { learn_skill(u, sk, 1.0); } -#endif } } } @@ -1026,22 +1021,12 @@ godcurse(void) if(is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0)) { unit * u; for(u=r->units; u; u=u->next) { -#if SKILLPOINTS - skill_t sk; - for(sk=0; sk < MAXSKILLS; sk++) { - int s = get_skill(u, sk); - if (s > 0) { - change_skill(u, sk, -min(s, (30+rand()%90)*u->number)); - } - } -#else skill * sv = u->skills; while (sv!=u->skills+u->skill_size) { int weeks = 1+rand()%3; reduce_skill(u, sv, weeks); ++sv; } -#endif } } } @@ -1091,8 +1076,7 @@ randomevents(void) if (p && (p->flags & PFL_NOORCGROWTH)) continue; for (u = r->units; u; u = u->next) { if ( (u->race == new_race[RC_ORC] || is_cursed(u->attribs, C_ORC, 0)) - && !get_skill(u, SK_MAGIC) - && !get_skill(u, SK_ALCHEMY)) { + && !has_skill(u, SK_MAGIC) && !has_skill(u, SK_ALCHEMY)) { int increase = 0; int num, prob; @@ -1121,8 +1105,7 @@ randomevents(void) { SK_AUSDAUER, 0 }, { NOSKILL, 0 } }; for (i=0;skills[i].skill!=NOSKILL;++i) { - int s = get_skill(u, skills[i].skill) / (u->number * 2); - int k = skill_level(skills[i].level); + int k = get_level(u, skills[i].skill); change_skill(u, skills[i].skill, increase * max(k, s)); } } @@ -1193,20 +1176,6 @@ randomevents(void) dc = min(dc, peasantfood); dc = peasantfood - max(u->number - bauernblut, 0); dc = max(0, dc); -#if SKILLPOINTS - for (sk = 0; sk != MAXSKILLS; sk++) { - if (get_skill(u, sk) && rand() % 100 < 25) { - int change = rand() % 90 + 1; - if (rand() % 100 < 60) { - change_skill(u, sk, u->number * change); - } else { - int s = get_skill(u, sk); - s = min(s, u->number * change); - change_skill(u, sk, -s); - } - } - } -#else sv = u->skills; while (sv!=u->skills+u->skill_size) { if (rand() % 100 < 25) { @@ -1216,7 +1185,6 @@ randomevents(void) } ++sv; } -#endif } } rsetpeasants(r, peasantfood/10); diff --git a/src/common/gamecode/study.c b/src/common/gamecode/study.c index 9102ca6bd..fe771c0e0 100644 --- a/src/common/gamecode/study.c +++ b/src/common/gamecode/study.c @@ -514,10 +514,10 @@ learn(void) /* Vertraute zählen nicht zu den Magiern einer Partei, * können aber nur Graue Magie lernen */ mtyp = M_GRAU; - if (!get_skill(u, SK_MAGIC)){ + if (!has_skill(u, SK_MAGIC)) { create_mage(u, mtyp); } - } else if (!get_skill(u, SK_MAGIC)){ + } else if (!has_skill(u, SK_MAGIC)){ /* Die Einheit ist noch kein Magier */ if (count_skill(u->faction, SK_MAGIC) + u->number > max_skill(u->faction, SK_MAGIC)) @@ -570,7 +570,7 @@ learn(void) } if (i == SK_ALCHEMY) { maxalchemy = eff_skill(u, SK_ALCHEMY, r); - if (get_skill(u, SK_ALCHEMY)==0 + if (has_skill(u, SK_ALCHEMY)==0 && count_skill(u->faction, SK_ALCHEMY) + u->number > max_skill(u->faction, SK_ALCHEMY)) { sprintf(buf, "Es kann maximal %d Alchemisten pro Partei geben", @@ -648,9 +648,6 @@ learn(void) days = (int)((u->number * 30 + a->data.i) * multi); if (fval(u, FL_HUNGER)) days = days / 2; -#if SKILLPOINTS - change_skill(u, (skill_t)i, days); -#else while (days) { if (days>=u->number*30) { learn_skill(u, (skill_t)i, 1.0); @@ -661,7 +658,6 @@ learn(void) days = 0; } } -#endif if (a) { a_remove(&u->attribs, a); a = NULL; diff --git a/src/common/items/xerewards.c b/src/common/items/xerewards.c index dc9611e0f..d5977ea19 100644 --- a/src/common/items/xerewards.c +++ b/src/common/items/xerewards.c @@ -36,23 +36,12 @@ static int use_skillpotion(struct unit * u, const struct item_type * itype, const char *cm) { -#if SKILLPOINTS - skill_t sk; - for(sk = 0; sk != MAXSKILLS; sk++) { - int skillvalue = get_skill(u, sk)/u->number; - if(skillvalue > 0) { - int change = max(90, (skillvalue * 10)/100); - change_skill(u, sk, change); - } - } -#else skill * sv = u->skills; while (sv!=u->skills+u->skill_size) { int i; for (i=0;i!=3;++i) learn_skill(u, sv->id, 1.0); ++sv; } -#endif add_message(&u->faction->msgs, new_message(u->faction, "skillpotion_use%u:unit", u)); diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index d905690e1..c64877e36 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -945,29 +945,6 @@ remove_troop(troop dt) /* ------------------------------------------------------------- */ -#if SKILLPOINTS -void -drain_exp(const struct unit *u, int n) -{ - skill_t sk = (skill_t)(rand() % MAXSKILLS); - skill_t ssk; - - ssk = sk; - - while (get_skill(u, sk) <= 0) { - sk++; - if (sk == MAXSKILLS) - sk = 0; - if (sk == ssk) { - sk = NOSKILL; - break; - } - } - if (sk != NOSKILL) { - change_skill(u, sk, -n); - } -} -#else /** reduces the target's exp by an equivalent of n points learning * 30 points = 1 week */ @@ -1001,7 +978,6 @@ drain_exp(struct unit *u, int n) } } } -#endif const char * rel_dam(int dam, int hp) diff --git a/src/common/kernel/combatspells.c b/src/common/kernel/combatspells.c index bedec4256..8089f0b84 100644 --- a/src/common/kernel/combatspells.c +++ b/src/common/kernel/combatspells.c @@ -540,9 +540,6 @@ sp_mindblast(fighter * fi, int level, int power, spell * sp) if (sk != NOSKILL) { /* Skill abziehen */ int n = 30+rand()%61; -#if SKILLPOINTS - change_skill(du, sk, -n); -#else skill * sv = get_skill(du, sk); while (n>0) { if (n>=30*du->number) { @@ -553,7 +550,6 @@ sp_mindblast(fighter * fi, int level, int power, spell * sp) n = 0; } } -#endif --enemies; } else { troop t; diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 5f7638cb9..da4d7afdd 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -695,19 +695,6 @@ scale_number (unit * u, int n) if (n==0 || u->number == 0) { set_level(u, sk, 0); } -#if SKILLPOINTS - /* not necessary to scale in the new system */ - else { - int sval = get_skill(u, sk); - int snew = sval / u->number * n; - remain = sval - snew / n * u->number; - snew += remain * n / u->number; - remain = (remain * n) % u->number; - if ((rand() % u->number) < remain) - ++snew; /* Nachkommastellen */ - set_skill(u, sk, snew); - } -#endif } set_number(u, n); diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index 05cee4233..a5c6c580d 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -630,12 +630,6 @@ spskill(const struct locale * lang, const struct unit * u, skill_t sk, int *dh, effsk = effskill(u, sk); sbuf += sprintf(sbuf, "%d", effsk); -#if SKILLPOINTS == 1 - if (days) { - assert(u->number); - sbuf += sprintf(sbuf, " [%d]", get_skill(u, sk) / u->number); - } -#else if(u->faction->options & Pow(O_SHOWSKCHANGE)) { skill *skill = get_skill(u, sk); int oldeff = 0; @@ -652,7 +646,6 @@ spskill(const struct locale * lang, const struct unit * u, skill_t sk, int *dh, sbuf += sprintf(sbuf, " (%s%hd)", (diff>0)?"+":"", diff); } } -#endif } void diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index 09cf3048f..12d05ba96 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -141,21 +141,12 @@ do_shock(unit *u, char *reason) } /* Evt. Talenttageverlust */ -#if SKILLPOINTS - if(rand()%10 < 2) { - for (sk=0; sk < MAXSKILLS; sk++) { - int n = get_skill(u, sk); - if (n!=0) set_skill(u, sk, (n*9)/10, false); - } - } -#else for (i=0;i!=u->skill_size;++i) if (rand()%5==0) { skill * sv = u->skills+i; int weeks = (sv->level * sv->level - sv->level) / 2; int change = (weeks+9) / 10; reduce_skill(u, sv, change); } -#endif /* Dies ist ein Hack, um das skillmod und familiar-Attribut beim Mage * zu löschen wenn der Familiar getötet wird. Da sollten wir über eine diff --git a/src/common/kernel/unit.h b/src/common/kernel/unit.h index c9afd4566..b48e9d261 100644 --- a/src/common/kernel/unit.h +++ b/src/common/kernel/unit.h @@ -110,17 +110,9 @@ extern const struct unit u_unknown; extern struct unit * udestroy; -#if SKILLPOINTS -extern int change_skill(struct unit * u, skill_t id, int byvalue); -extern void set_skill(struct unit * u, skill_t id, int value); -extern int get_skill(const struct unit * u, skill_t id); -#define has_skill(u, id) (get_skill(u, id)>0) -#define change_level(u, sk, bylevel) set_level(u, sk, max(0,get_level(u,sk)+bylevel)); -#else extern struct skill * add_skill(struct unit * u, skill_t id); extern struct skill * get_skill(const struct unit * u, skill_t id); extern boolean has_skill(const unit* u, skill_t sk); -#endif extern void set_level(struct unit * u, skill_t id, int level); extern int get_level(const struct unit * u, skill_t id); diff --git a/src/mapper/map_partei.c b/src/mapper/map_partei.c index 3dabca0cf..d2e84d53f 100644 --- a/src/mapper/map_partei.c +++ b/src/mapper/map_partei.c @@ -293,7 +293,6 @@ days2level(int days) return l-1; } -#if SKILLPOINTS == 0 static void change_level(unit * u, skill_t sk, int bylevel) { @@ -302,7 +301,6 @@ change_level(unit * u, skill_t sk, int bylevel) if (sv==0) sv = add_skill(u, sk); sk_set(sv, sv->level+bylevel); } -#endif static void give_latestart_bonus(region *r, unit *u, int b) @@ -445,7 +443,7 @@ ModifyPartei(faction * f) waddnstr(win, " (", -1); for (r = firstregion(f); r != lastregion(f); r = r->next) for (u = r->units; u; u = u->next) - if (u->faction == f && get_skill(u, SK_MAGIC)) { + if (u->faction == f && has_skill(u, SK_MAGIC)) { if (fval(f, FL_DH)) waddnstr(win, ", ", -1); wprintw(win, (NCURSES_CONST char*)"%s(%d): %d", unitid(u), u->number, get_level(u, SK_MAGIC)); @@ -461,7 +459,7 @@ ModifyPartei(faction * f) freset(f, FL_DH); for (r = firstregion(f); r != lastregion(f); r = r->next) for (u = r->units; u; u = u->next) - if (u->faction == f && get_skill(u, SK_ALCHEMY)) { + if (u->faction == f && has_skill(u, SK_ALCHEMY)) { if (fval(f, FL_DH)) waddnstr(win, ", ", -1); wprintw(win, (NCURSES_CONST char*)"%s(%d): %d", unitid(u), u->number, get_level(u, SK_ALCHEMY));