diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index cbf6ad63d..dd688fef5 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -2304,37 +2304,33 @@ display_item(faction *f, unit *u, const item_type * itype) const char *name; if (u && *i_find(&u->items, itype) == NULL) return false; - /* - info = mkname("info", itype->rtype->_name[0]); - name = LOC(u->faction->locale, info); - if (strcmp(name, info)==0) { - */ - name = resourcename(itype->rtype, 0); + + name = resourcename(itype->rtype, 0); + sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(f->locale), name); + fp = fopen(filename, "r"); + if (!fp) { + name = locale_string(f->locale, resourcename(itype->rtype, 0)); sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(f->locale), name); fp = fopen(filename, "r"); - if (!fp) { - name = locale_string(f->locale, resourcename(itype->rtype, 0)); - sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(f->locale), name); - fp = fopen(filename, "r"); - } - if (!fp) { - name = resourcename(itype->rtype, 0); - sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(default_locale), name); - fp = fopen(filename, "r"); - } - if (!fp) return false; + } + if (!fp) { + name = resourcename(itype->rtype, 0); + sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(default_locale), name); + fp = fopen(filename, "r"); + } + if (!fp) return false; - buf[0]='\0'; - while (fgets(t, NAMESIZE, fp) != NULL) { - if (t[strlen(t) - 1] == '\n') { - t[strlen(t) - 1] = 0; - } - strcat(buf, t); + buf[0]='\0'; + while (fgets(t, NAMESIZE, fp) != NULL) { + if (t[strlen(t) - 1] == '\n') { + t[strlen(t) - 1] = 0; } - fclose(fp); - name = buf; -/* } */ - ADDMSG(&f->msgs, msg_message("displayitem", "item description", itype->rtype, strdup(name))); + strcat(buf, t); + } + fclose(fp); + name = buf; + ADDMSG(&f->msgs, msg_message("displayitem", "weight item description", + itype->weight/1000, itype->rtype, strdup(name))); return true; } diff --git a/src/common/gamecode/study.c b/src/common/gamecode/study.c index b5d3f8492..70c18626e 100644 --- a/src/common/gamecode/study.c +++ b/src/common/gamecode/study.c @@ -499,266 +499,266 @@ learn(void) if (u->race == new_race[RC_INSECT] && r_insectstalled(r) && !is_cursed(u->attribs, C_KAELTESCHUTZ,0)) { - continue; - } - if (attacked(u)) { - cmistake(u, u->thisorder, 52, MSG_PRODUCE); - continue; - } - if ((u->race->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) { - sprintf(buf, "%s können nichts lernen", LOC(default_locale, rc_name(u->race, 1))); - mistake(u, u->thisorder, buf, MSG_EVENT); - continue; - } + continue; + } + if (attacked(u)) { + cmistake(u, u->thisorder, 52, MSG_PRODUCE); + continue; + } + if ((u->race->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) { + sprintf(buf, "%s können nichts lernen", LOC(default_locale, rc_name(u->race, 1))); + mistake(u, u->thisorder, buf, MSG_EVENT); + continue; + } - init_tokens(u->thisorder); - skip_token(); - sk = getskill(u->faction->locale); + init_tokens(u->thisorder); + skip_token(); + sk = getskill(u->faction->locale); - if (sk < 0) { + if (sk < 0) { + cmistake(u, u->thisorder, 77, MSG_EVENT); + continue; + } + if (SkillCap(sk) && SkillCap(sk) <= effskill(u, sk)) { cmistake(u, u->thisorder, 77, MSG_EVENT); + continue; + } + /* Hack: Talente mit Malus -99 können nicht gelernt werden */ + if (u->race->bonus[sk] == -99) { + cmistake(u, u->thisorder, 77, MSG_EVENT); + continue; + } + /* snotlings können Talente nur bis T8 lernen */ + if (u->race == new_race[RC_SNOTLING]){ + if (get_level(u, sk) >= 8){ + cmistake(u, u->thisorder, 308, MSG_EVENT); continue; } - if (SkillCap(sk) && SkillCap(sk) <= effskill(u, sk)) { - cmistake(u, u->thisorder, 77, MSG_EVENT); + } + + p = studycost = study_cost(u, sk); + a = a_find(u->attribs, &at_learning); + if (a!=NULL) { + teach = (teaching_info*)a->data.v; + } + + /* keine kostenpflichtigen Talente für Migranten. Vertraute sind + * keine Migranten, wird in is_migrant abgefangen. Vorsicht, + * studycost darf hier noch nicht durch Akademie erhöht sein */ + if (studycost > 0 && !ExpensiveMigrants() && is_migrant(u)) { + sprintf(buf, "Migranten können keine kostenpflichtigen Talente lernen"); + mistake(u, u->thisorder, buf, MSG_EVENT); + continue; + } + /* Akademie: */ + { + struct building * b = inside_building(u); + const struct building_type * btype = b?b->type:NULL; + + if (btype == bt_find("academy")) { + studycost = max(50, studycost * 2); + } + } + + if (sk == SK_MAGIC) { + if (u->number > 1){ + cmistake(u, u->thisorder, 106, MSG_MAGIC); continue; } - /* Hack: Talente mit Malus -99 können nicht gelernt werden */ - if (u->race->bonus[sk] == -99) { - cmistake(u, u->thisorder, 77, MSG_EVENT); - continue; - } - /* snotlings können Talente nur bis T8 lernen */ - if (u->race == new_race[RC_SNOTLING]){ - if (get_level(u, sk) >= 8){ - cmistake(u, u->thisorder, 308, MSG_EVENT); - continue; - } - } - - p = studycost = study_cost(u, sk); - a = a_find(u->attribs, &at_learning); - if (a!=NULL) { - teach = (teaching_info*)a->data.v; - } - - /* keine kostenpflichtigen Talente für Migranten. Vertraute sind - * keine Migranten, wird in is_migrant abgefangen. Vorsicht, - * studycost darf hier noch nicht durch Akademie erhöht sein */ - if (studycost > 0 && !ExpensiveMigrants() && is_migrant(u)) { - sprintf(buf, "Migranten können keine kostenpflichtigen Talente lernen"); - mistake(u, u->thisorder, buf, MSG_EVENT); - continue; - } - /* Akademie: */ - { - struct building * b = inside_building(u); - const struct building_type * btype = b?b->type:NULL; - - if (btype == bt_find("academy")) { - studycost = max(50, studycost * 2); - } - } - - if (sk == SK_MAGIC) { - if (u->number > 1){ - cmistake(u, u->thisorder, 106, MSG_MAGIC); - continue; - } - if (is_familiar(u)){ - /* Vertraute zählen nicht zu den Magiern einer Partei, - * können aber nur Graue Magie lernen */ - mtyp = M_GRAU; - if (!has_skill(u, SK_MAGIC)) { - create_mage(u, mtyp); - } - } 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)) - { - sprintf(buf, "Es kann maximal %d Magier pro Partei geben", - max_skill(u->faction, SK_MAGIC)); - mistake(u, u->thisorder, buf, MSG_EVENT); - continue; - } - mtyp = getmagicskill(); - if (mtyp == M_NONE || mtyp == M_GRAU) { - /* wurde kein Magiegebiet angegeben, wird davon - * ausgegangen, daß das normal gelernt werden soll */ - if(u->faction->magiegebiet != 0) { - mtyp = u->faction->magiegebiet; - } else { - /* Es wurde kein Magiegebiet angegeben und die Partei - * hat noch keins gewählt. */ - cmistake(u, u->thisorder, 178, MSG_MAGIC); - continue; - } - } - if (mtyp != u->faction->magiegebiet){ - /* Es wurde versucht, ein anderes Magiegebiet zu lernen - * als das der Partei */ - if (u->faction->magiegebiet != 0){ - cmistake(u, u->thisorder, 179, MSG_MAGIC); - continue; - } else { - /* Lernt zum ersten mal Magie und legt damit das - * Magiegebiet der Partei fest */ - u->faction->magiegebiet = mtyp; - } - } + if (is_familiar(u)){ + /* Vertraute zählen nicht zu den Magiern einer Partei, + * können aber nur Graue Magie lernen */ + mtyp = M_GRAU; + if (!has_skill(u, SK_MAGIC)) { create_mage(u, mtyp); - } else { - /* ist schon ein Magier und kein Vertrauter */ - if(u->faction->magiegebiet == 0){ - /* die Partei hat noch kein Magiegebiet gewählt. */ - mtyp = getmagicskill(); - if (mtyp == M_NONE){ - cmistake(u, u->thisorder, 178, MSG_MAGIC); - continue; - } else { - /* Legt damit das Magiegebiet der Partei fest */ - u->faction->magiegebiet = mtyp; - } - } } - } - if (sk == SK_ALCHEMY) { - maxalchemy = eff_skill(u, SK_ALCHEMY, r); - 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", - max_skill(u->faction, SK_ALCHEMY)); - mistake(u, u->thisorder, buf, MSG_EVENT); + } 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)) + { + sprintf(buf, "Es kann maximal %d Magier pro Partei geben", + max_skill(u->faction, SK_MAGIC)); + mistake(u, u->thisorder, buf, MSG_EVENT); + continue; + } + mtyp = getmagicskill(); + if (mtyp == M_NONE || mtyp == M_GRAU) { + /* wurde kein Magiegebiet angegeben, wird davon + * ausgegangen, daß das normal gelernt werden soll */ + if(u->faction->magiegebiet != 0) { + mtyp = u->faction->magiegebiet; + } else { + /* Es wurde kein Magiegebiet angegeben und die Partei + * hat noch keins gewählt. */ + cmistake(u, u->thisorder, 178, MSG_MAGIC); continue; } + } + if (mtyp != u->faction->magiegebiet){ + /* Es wurde versucht, ein anderes Magiegebiet zu lernen + * als das der Partei */ + if (u->faction->magiegebiet != 0){ + cmistake(u, u->thisorder, 179, MSG_MAGIC); + continue; + } else { + /* Lernt zum ersten mal Magie und legt damit das + * Magiegebiet der Partei fest */ + u->faction->magiegebiet = mtyp; + } + } + create_mage(u, mtyp); + } else { + /* ist schon ein Magier und kein Vertrauter */ + if(u->faction->magiegebiet == 0){ + /* die Partei hat noch kein Magiegebiet gewählt. */ + mtyp = getmagicskill(); + if (mtyp == M_NONE){ + cmistake(u, u->thisorder, 178, MSG_MAGIC); + continue; + } else { + /* Legt damit das Magiegebiet der Partei fest */ + u->faction->magiegebiet = mtyp; + } + } } - if (studycost) { - money = get_pooled(u, r, R_SILVER); - money = min(money, studycost * u->number); - } - if (money < studycost * u->number) { - studycost = p; /* Ohne Univertreurung */ - money = min(money, studycost); - if (p>0 && money < studycost * u->number) { + } + if (sk == SK_ALCHEMY) { + maxalchemy = eff_skill(u, SK_ALCHEMY, r); + 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", + max_skill(u->faction, SK_ALCHEMY)); + mistake(u, u->thisorder, buf, MSG_EVENT); + continue; + } + } + if (studycost) { + money = get_pooled(u, r, R_SILVER); + money = min(money, studycost * u->number); + } + if (money < studycost * u->number) { + studycost = p; /* Ohne Univertreurung */ + money = min(money, studycost); + if (p>0 && money < studycost * u->number) { #ifdef PARTIAL_STUDY - cmistake(u, u->thisorder, 65, MSG_EVENT); - multi = money / (double)(studycost * u->number); + cmistake(u, u->thisorder, 65, MSG_EVENT); + multi = money / (double)(studycost * u->number); #else - cmistake(u, u->thisorder, 65, MSG_EVENT); - continue; /* nein, Silber reicht auch so nicht */ + cmistake(u, u->thisorder, 65, MSG_EVENT); + continue; /* nein, Silber reicht auch so nicht */ #endif - } } + } - if (teach==NULL) { - a = a_add(&u->attribs, a_new(&at_learning)); - teach = (teaching_info*)a->data.v; - teach->teachers[0] = 0; + if (teach==NULL) { + a = a_add(&u->attribs, a_new(&at_learning)); + teach = (teaching_info*)a->data.v; + teach->teachers[0] = 0; + } + if (money>0) { + use_pooled(u, r, R_SILVER, money); + add_message(&u->faction->msgs, msg_message("studycost", + "unit region cost skill", u, u->region, money, sk)); + } + + if (get_effect(u, oldpotiontype[P_WISE])) { + l = min(u->number, get_effect(u, oldpotiontype[P_WISE])); + teach->value += l * 10; + change_effect(u, oldpotiontype[P_WISE], -l); + } + if (get_effect(u, oldpotiontype[P_FOOL])) { + l = min(u->number, get_effect(u, oldpotiontype[P_FOOL])); + teach->value -= l * 30; + change_effect(u, oldpotiontype[P_FOOL], -l); + } + + warrior_skill = fspecial(u->faction, FS_WARRIOR); + if(warrior_skill > 0) { + if(sk == SK_CROSSBOW || sk == SK_LONGBOW + || sk == SK_CATAPULT || sk == SK_SWORD || sk == SK_SPEAR + || sk == SK_AUSDAUER || sk == SK_WEAPONLESS) + { + teach->value += u->number * (5+warrior_skill*5); + } else { + teach->value -= u->number * (5+warrior_skill*5); + teach->value = max(0, teach->value); } - if (money>0) { - use_pooled(u, r, R_SILVER, money); - add_message(&u->faction->msgs, msg_message("studycost", - "unit region cost skill", u, u->region, money, sk)); + } + + if (p != studycost) { + /* ist_in_gebaeude(r, u, BT_UNIVERSITAET) == 1) { */ + /* p ist Kosten ohne Uni, studycost mit; wenn + * p!=studycost, ist die Einheit zwangsweise + * in einer Uni */ + teach->value += u->number * 10; + } + + if (is_cursed(r->attribs,C_BADLEARN,0)) { + teach->value -= u->number * 10; + } + + days = (int)((u->number * 30 + teach->value) * multi); + + /* the artacademy currently improves the learning of entertainment + of all units in the region, to be able to make it cumulative with + with an academy */ + + if(buildingtype_exists(r, bt_find("artacademy"))) { + days *= 2; + } + + if (fval(u, UFL_HUNGER)) days /= 2; + + while (days) { + if (days>=u->number*30) { + learn_skill(u, sk, 1.0); + days -= u->number*30; + } else { + double chance = (double)days/u->number/30; + learn_skill(u, sk, chance); + days = 0; } - - if (get_effect(u, oldpotiontype[P_WISE])) { - l = min(u->number, get_effect(u, oldpotiontype[P_WISE])); - teach->value += l * 10; - change_effect(u, oldpotiontype[P_WISE], -l); - } - if (get_effect(u, oldpotiontype[P_FOOL])) { - l = min(u->number, get_effect(u, oldpotiontype[P_FOOL])); - teach->value -= l * 30; - change_effect(u, oldpotiontype[P_FOOL], -l); - } - - warrior_skill = fspecial(u->faction, FS_WARRIOR); - if(warrior_skill > 0) { - if(sk == SK_CROSSBOW || sk == SK_LONGBOW - || sk == SK_CATAPULT || sk == SK_SWORD || sk == SK_SPEAR - || sk == SK_AUSDAUER || sk == SK_WEAPONLESS) - { - teach->value += u->number * (5+warrior_skill*5); - } else { - teach->value -= u->number * (5+warrior_skill*5); - teach->value = max(0, teach->value); - } - } - - if (p != studycost) { - /* ist_in_gebaeude(r, u, BT_UNIVERSITAET) == 1) { */ - /* p ist Kosten ohne Uni, studycost mit; wenn - * p!=studycost, ist die Einheit zwangsweise - * in einer Uni */ - teach->value += u->number * 10; - } - - if (is_cursed(r->attribs,C_BADLEARN,0)) { - teach->value -= u->number * 10; - } - - days = (int)((u->number * 30 + teach->value) * multi); - - /* the artacademy currently improves the learning of entertainment - of all units in the region, to be able to make it cumulative with - with an academy */ - - if(buildingtype_exists(r, bt_find("artacademy"))) { - days *= 2; - } - - if (fval(u, UFL_HUNGER)) days /= 2; - - while (days) { - if (days>=u->number*30) { - learn_skill(u, sk, 1.0); - days -= u->number*30; - } else { - double chance = (double)days/u->number/30; - learn_skill(u, sk, chance); - days = 0; - } - } - if (a!=NULL) { - if (teach!=NULL) { - int index = 0; - while (teach->teachers[index] && index!=MAXTEACHERS) { - unit * teacher = teach->teachers[index++]; - if (teacher->faction != u->faction) { - add_message(&u->faction->msgs, msg_message("teach_student", - "teacher student skill", teacher, u, sk)); - add_message(&teacher->faction->msgs, msg_message("teach_teacher", - "teacher student skill level", teacher, u, sk, - effskill(u, sk))); - } + } + if (a!=NULL) { + if (teach!=NULL) { + int index = 0; + while (teach->teachers[index] && index!=MAXTEACHERS) { + unit * teacher = teach->teachers[index++]; + if (teacher->faction != u->faction) { + add_message(&u->faction->msgs, msg_message("teach_student", + "teacher student skill", teacher, u, sk)); + add_message(&teacher->faction->msgs, msg_message("teach_teacher", + "teacher student skill level", teacher, u, sk, + effskill(u, sk))); } } - a_remove(&u->attribs, a); - a = NULL; } + a_remove(&u->attribs, a); + a = NULL; + } - /* Anzeigen neuer Tränke */ - /* Spruchlistenaktualiesierung ist in Regeneration */ + /* Anzeigen neuer Tränke */ + /* Spruchlistenaktualiesierung ist in Regeneration */ - if (sk == SK_ALCHEMY) { - const potion_type * ptype; - faction * f = u->faction; - int skill = eff_skill(u, SK_ALCHEMY, r); - if (skill>maxalchemy) { - for (ptype=potiontypes; ptype; ptype=ptype->next) { - if (skill == ptype->level * 2) { - attrib * a = a_find(f->attribs, &at_showitem); - while (a && a->data.v != ptype) a=a->nexttype; - if (!a) { - a = a_add(&f->attribs, a_new(&at_showitem)); - a->data.v = (void*) ptype->itype; - } + if (sk == SK_ALCHEMY) { + const potion_type * ptype; + faction * f = u->faction; + int skill = eff_skill(u, SK_ALCHEMY, r); + if (skill>maxalchemy) { + for (ptype=potiontypes; ptype; ptype=ptype->next) { + if (skill == ptype->level * 2) { + attrib * a = a_find(f->attribs, &at_showitem); + while (a && a->data.v != ptype) a=a->nexttype; + if (!a) { + a = a_add(&f->attribs, a_new(&at_showitem)); + a->data.v = (void*) ptype->itype; } } } } + } } } } diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index ef068b7b6..066fc530c 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -1987,7 +1987,7 @@ attack(battle *b, troop ta, const att *a, int numattack) switch(a->type) { case AT_STANDARD: /* Waffen, mag. Gegenstände, Kampfzauber */ case AT_COMBATSPELL: - if (af->magic > 0) { + if (numattack==0 && af->magic > 0) { /* Magier versuchen immer erstmal zu zaubern, erst wenn das * fehlschlägt, wird af->magic == 0 und der Magier kämpft * konventionell weiter */ @@ -2027,11 +2027,11 @@ attack(battle *b, troop ta, const att *a, int numattack) } if (!td.fighter) return; - if(td.fighter->person[td.index].last_action < b->turn) { + if (td.fighter->person[td.index].last_action < b->turn) { td.fighter->person[td.index].last_action = b->turn; td.fighter->action_counter++; } - if(ta.fighter->person[ta.index].last_action < b->turn) { + if (ta.fighter->person[ta.index].last_action < b->turn) { ta.fighter->person[ta.index].last_action = b->turn; ta.fighter->action_counter++; } diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index 79f113847..5eeda38f5 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -4050,7 +4050,7 @@ sp_charmingsong(castorder *co) int tb = 0; /* wenn kein Ziel gefunden, Zauber abbrechen */ - if(pa->param[0]->flag == TARGET_NOTFOUND) return 0; + if (pa->param[0]->flag == TARGET_NOTFOUND) return 0; target = pa->param[0]->data.u; diff --git a/src/res/messages.xml b/src/res/messages.xml index 6f7dddedf..f35b6a02e 100644 --- a/src/res/messages.xml +++ b/src/res/messages.xml @@ -272,8 +272,10 @@ + - "$resource($item,1): $description" + "$resource($item,1) ($int($weight) GE): $description" + "$resource($item,1) ($int($weight) st): $description" diff --git a/src/scripts/samples.lua b/src/scripts/samples.lua index 873cd5de3..06d8bb05a 100644 --- a/src/scripts/samples.lua +++ b/src/scripts/samples.lua @@ -213,6 +213,14 @@ function test_parser() write_game("parser") end +function test_fail() + plain = terraform(0, 0, "plain") + skill = 5 + + f = add_faction("enno@eressea.de", "human", "de") + print(f) +end + test_fail() -- test_handler() -- test_parser() diff --git a/src/todo.txt b/src/todo.txt index 4f0007154..9e5d07e85 100644 --- a/src/todo.txt +++ b/src/todo.txt @@ -1,5 +1,4 @@ -The crash of the day: -giving units names or descriptions that exceed NAMESIZE/DISPLAYSIZE can be a bad thing. +weights in item descriptions [11:01] am besten wäre, wenn mailit nur die optionen, nicht das ganze script enthielte [11:01] und ein skript dann mailit als input nähme