From 474431fb0d25615bf20a75c4ce950436b302ea28 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 May 2008 16:47:54 +0000 Subject: [PATCH] - prevent enslaved units from FORGET - prevent promotion of foreign races - prevent charming of units with limited skills also: - rename teure_talente to has_limited_skills - move frame_regions to autoseed.c - some output for korrektur.c --- src/common/gamecode/economy.c | 21 ++++++---- src/common/gamecode/give.c | 4 +- src/common/gamecode/laws.c | 2 +- src/common/kernel/eressea.c | 2 +- src/common/kernel/eressea.h | 2 +- src/common/modules/autoseed.c | 23 +++++++++++ src/common/modules/wormhole.c | 2 +- src/common/spells/spells.c | 10 ++++- src/eressea/korrektur.c | 76 +++++++++++++++-------------------- 9 files changed, 83 insertions(+), 59 deletions(-) diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 1914417e4..bc04e2527 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -843,18 +843,23 @@ give_cmd(unit * u, order * ord) static int forget_cmd(unit * u, order * ord) { - skill_t sk; - const char *s; - + skill_t sk; + const char *s; + + if (is_cursed(u->attribs, C_SLAVE, 0)) { + /* charmed units shouldn't be losing their skills */ + return 0; + } + init_tokens(ord); skip_token(); s = getstrtoken(); - if ((sk = findskill(s, u->faction->locale)) != NOSKILL) { - ADDMSG(&u->faction->msgs, - msg_message("forget", "unit skill", u, sk)); - set_level(u, sk, 0); - } + if ((sk = findskill(s, u->faction->locale)) != NOSKILL) { + ADDMSG(&u->faction->msgs, + msg_message("forget", "unit skill", u, sk)); + set_level(u, sk, 0); + } return 0; } diff --git a/src/common/gamecode/give.c b/src/common/gamecode/give.c index 3e98ed970..d9cc5fd4f 100644 --- a/src/common/gamecode/give.c +++ b/src/common/gamecode/give.c @@ -195,7 +195,7 @@ give_men(int n, unit * u, unit * u2, struct order * ord) } else if (count_migrants(u2->faction) + n > count_maxmigrants(u2->faction)) { error = 128; } - else if (teure_talente(u) || teure_talente(u2)) { + else if (has_limited_skills(u) || has_limited_skills(u2)) { error = 154; } else if (u2->number!=0) { error = 139; @@ -363,7 +363,7 @@ give_unit(unit * u, unit * u2, order * ord) cmistake(u, ord, 128, MSG_COMMERCE); return; } - if (teure_talente(u)) { + if (has_limited_skills(u)) { cmistake(u, ord, 154, MSG_COMMERCE); return; } diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 874c7342c..747d616d4 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -2242,7 +2242,7 @@ promotion_cmd(unit * u, struct order * ord) maxheroes(u->faction), countheroes(u->faction))); return 0; } - if (!playerrace(u->race)) { + if (u->race!=u->faction->race) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "heroes_race", "race", u->race)); return 0; diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 152648ec2..10005de45 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -2886,7 +2886,7 @@ lovar(double xpct_x2) } boolean -teure_talente (const struct unit * u) +has_limited_skills (const struct unit * u) { if (has_skill(u, SK_MAGIC) || has_skill(u, SK_ALCHEMY) || has_skill(u, SK_TACTICS) || has_skill(u, SK_HERBALISM) || diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 79bc134e1..7d1ac8fda 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -250,7 +250,7 @@ extern int count_all(const struct faction * f); extern int count_migrants (const struct faction * f); extern int count_maxmigrants(const struct faction * f); -extern boolean teure_talente(const struct unit * u); +extern boolean has_limited_skills(const struct unit * u); extern const struct race * findrace(const char *, const struct locale *); int eff_stealth(const struct unit * u, const struct region * r); diff --git a/src/common/modules/autoseed.c b/src/common/modules/autoseed.c index 2561f9e5f..9e32d09c3 100644 --- a/src/common/modules/autoseed.c +++ b/src/common/modules/autoseed.c @@ -505,6 +505,27 @@ free_newfaction(newfaction * nf) /** create new island with up to nsize players * returns the number of players placed on the new island. */ +static void +frame_regions(int age, terrain_t terrain) +{ + region * r = regions; + for (r=regions;r;r=r->next) { + direction_t d; + if (r->ageplanep) continue; + if (rterrain(r)==terrain) continue; + + for (d=0;d!=MAXDIRECTIONS;++d) { + region * rn = rconnect(r, d); + if (rn==NULL) { + rn = new_region(r->x+delta_x[d], r->y+delta_y[d], 0); + terraform(rn, terrain); + rn->age=r->age; + } + } + } +} + int autoseed(newfaction ** players, int nsize, boolean new_island) { @@ -516,6 +537,8 @@ autoseed(newfaction ** players, int nsize, boolean new_island) int psize = 0; /* players on this island */ const terrain_type * volcano_terrain = get_terrain("volcano"); + frame_regions(16, T_FIREWALL); + if (listlen(*players)next) { if (u->building==data->entry) { message * m = NULL; - if (u->number>maxtransport || teure_talente(u)) { + if (u->number>maxtransport || has_limited_skills(u)) { m = msg_message("wormhole_requirements", "unit region", u, u->region); } else if (data->exit!=NULL) { move_unit(u, data->exit->region, NULL); diff --git a/src/common/spells/spells.c b/src/common/spells/spells.c index 7a1368c2d..88faad950 100644 --- a/src/common/spells/spells.c +++ b/src/common/spells/spells.c @@ -3845,6 +3845,12 @@ sp_charmingsong(castorder *co) /* Die Einheit ist eine der unsrigen */ cmistake(mage, co->order, 45, MSG_MAGIC); } + /* niemand mit teurem Talent */ + if (has_limited_skills(target)) { + ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, + "spellfail_noexpensives", "target", target)); + return 0; + } /* Magieresistensbonus für mehr als Stufe Personen */ if (target->number > force) { @@ -3884,7 +3890,7 @@ sp_charmingsong(castorder *co) create_curse(mage, &target->attribs, ct_find("slavery"), force, duration, zero_effect, 0); /* setze Partei um und lösche langen Befehl aus Sicherheitsgründen */ - u_setfaction(target,mage->faction); + u_setfaction(target, mage->faction); set_order(&target->thisorder, NULL); /* setze Parteitarnung, damit nicht sofort klar ist, wer dahinter @@ -4113,7 +4119,7 @@ sp_migranten(castorder *co) return 0; } /* niemand mit teurem Talent */ - if (teure_talente(target)) { + if (has_limited_skills(target)) { ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, "spellfail_noexpensives", "target", target)); return 0; diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index f9fd3b21e..1b800c064 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -281,6 +281,8 @@ static void fix_firewalls(void) { region * r = regions; + int fixes = 0; + while (r) { direction_t d; for (d=0;d!=MAXDIRECTIONS;++d) { @@ -295,6 +297,7 @@ fix_firewalls(void) log_warning(("firewall between regions %s and %s was bugged. removed.\n", regionname(r, NULL), regionname(r2, NULL))); b = get_borders(r, r2); + ++fixes; } else { b = b->next; } @@ -306,6 +309,7 @@ fix_firewalls(void) } r = r->next; } + log_printf("fixed %u firewalls.\n", fixes); } static void @@ -472,6 +476,7 @@ static void fix_gates(void) { region * r; + int fixes = 0; for (r=regions;r;r=r->next) { unit * u; building * b; @@ -492,6 +497,7 @@ fix_gates(void) } remove_triggers(&u->attribs, "timer", &tt_gate); remove_triggers(&u->attribs, "create", &tt_unguard); + ++fixes; } } for (b=r->buildings;b;b=b->next) { @@ -510,10 +516,12 @@ fix_gates(void) add_trigger(&bgate->attribs, "create", trigger_unguard(bgate)); fset(bgate, BLD_UNGUARDED); } + ++fixes; } } } } + log_printf("fixed %u gates.\n", fixes); } static int @@ -562,48 +570,6 @@ road_decay(void) return 0; } -static void -frame_regions(void) -{ -#ifdef AGE_FIX - unsigned short ocean_age = (unsigned short)turn; -#endif - region * r = regions; - for (r=regions;r;r=r->next) { - direction_t d; -#ifdef AGE_FIX - if (rterrain(r) == T_OCEAN && r->age==0) { - unsigned short age = 0; - direction_t d; - for (d=0;d!=MAXDIRECTIONS;++d) { - region * rn = rconnect(r, d); - if (rn && rn->age>age) { - age = rn->age; - } - } - if (age!=0 && age < ocean_age) { - ocean_age = age; - } - r->age = ocean_age; - } else if (r->age>ocean_age) { - ocean_age = r->age; - } -#endif - if (r->age<16) continue; - if (r->planep) continue; - if (rterrain(r)==T_FIREWALL) continue; - - for (d=0;d!=MAXDIRECTIONS;++d) { - region * rn = rconnect(r, d); - if (rn==NULL) { - rn = new_region(r->x+delta_x[d], r->y+delta_y[d], 0); - terraform(rn, T_FIREWALL); - rn->age=r->age; - } - } - } -} - #if GLOBAL_WARMING static void @@ -917,6 +883,7 @@ static void fix_toads(void) { region * r; + int fixes = 0; const struct race * toad = rc_find("toad"); for (r=regions;r!=NULL;r=r->next) { @@ -942,12 +909,35 @@ fix_toads(void) if (!found) { log_error(("fixed toad %s.\n", unitname(u))); u->race=u->faction->race; + ++fixes; } } } } + log_printf("fixed %u toads.\n", fixes); } +#ifdef REMOVE_ILLEGAL_MIGRANT_HEROES +static void +fix_heroes(void) +{ + region * r; + int fixes = 0; + + for (r=regions;r!=NULL;r=r->next) { + unit * u; + for (u=r->units; u; u=u->next) { + if (u->race!=u->faction->race) { + log_error(("fixed race for hero %s (%s).\n", unitname(u), u->race->_name[0])); + u->race=u->faction->race; + ++fixes; + } + } + } + log_printf("fixed %u heroes.\n", fixes); +} +#endif + static void fix_groups(void) { @@ -995,7 +985,6 @@ korrektur(void) do_once("chgt", &fix_chaosgates); do_once("atrx", &fix_attribflags); do_once("asfi", &fix_astral_firewalls); - frame_regions(); #if GLOBAL_WARMING if (get_gamedate(turn, NULL)->season == SEASON_SUMMER) { global_warming(); @@ -1005,6 +994,7 @@ korrektur(void) fix_firewalls(); fix_gates(); fix_toads(); + /* fix_heroes(); */ verify_owners(false); /* fix_herbtypes(); */ /* In Vin 3+ können Parteien komplett übergeben werden. */