- 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
This commit is contained in:
Enno Rehling 2008-05-13 16:47:54 +00:00
parent 76497abc92
commit 474431fb0d
9 changed files with 83 additions and 59 deletions

View file

@ -843,18 +843,23 @@ give_cmd(unit * u, order * ord)
static int static int
forget_cmd(unit * u, order * ord) forget_cmd(unit * u, order * ord)
{ {
skill_t sk; skill_t sk;
const char *s; const char *s;
if (is_cursed(u->attribs, C_SLAVE, 0)) {
/* charmed units shouldn't be losing their skills */
return 0;
}
init_tokens(ord); init_tokens(ord);
skip_token(); skip_token();
s = getstrtoken(); s = getstrtoken();
if ((sk = findskill(s, u->faction->locale)) != NOSKILL) { if ((sk = findskill(s, u->faction->locale)) != NOSKILL) {
ADDMSG(&u->faction->msgs, ADDMSG(&u->faction->msgs,
msg_message("forget", "unit skill", u, sk)); msg_message("forget", "unit skill", u, sk));
set_level(u, sk, 0); set_level(u, sk, 0);
} }
return 0; return 0;
} }

View file

@ -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)) { } else if (count_migrants(u2->faction) + n > count_maxmigrants(u2->faction)) {
error = 128; error = 128;
} }
else if (teure_talente(u) || teure_talente(u2)) { else if (has_limited_skills(u) || has_limited_skills(u2)) {
error = 154; error = 154;
} else if (u2->number!=0) { } else if (u2->number!=0) {
error = 139; error = 139;
@ -363,7 +363,7 @@ give_unit(unit * u, unit * u2, order * ord)
cmistake(u, ord, 128, MSG_COMMERCE); cmistake(u, ord, 128, MSG_COMMERCE);
return; return;
} }
if (teure_talente(u)) { if (has_limited_skills(u)) {
cmistake(u, ord, 154, MSG_COMMERCE); cmistake(u, ord, 154, MSG_COMMERCE);
return; return;
} }

View file

@ -2242,7 +2242,7 @@ promotion_cmd(unit * u, struct order * ord)
maxheroes(u->faction), countheroes(u->faction))); maxheroes(u->faction), countheroes(u->faction)));
return 0; return 0;
} }
if (!playerrace(u->race)) { if (u->race!=u->faction->race) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "heroes_race", "race", ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "heroes_race", "race",
u->race)); u->race));
return 0; return 0;

View file

@ -2886,7 +2886,7 @@ lovar(double xpct_x2)
} }
boolean 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) || if (has_skill(u, SK_MAGIC) || has_skill(u, SK_ALCHEMY) ||
has_skill(u, SK_TACTICS) || has_skill(u, SK_HERBALISM) || has_skill(u, SK_TACTICS) || has_skill(u, SK_HERBALISM) ||

View file

@ -250,7 +250,7 @@ extern int count_all(const struct faction * f);
extern int count_migrants (const struct faction * f); extern int count_migrants (const struct faction * f);
extern int count_maxmigrants(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 *); extern const struct race * findrace(const char *, const struct locale *);
int eff_stealth(const struct unit * u, const struct region * r); int eff_stealth(const struct unit * u, const struct region * r);

View file

@ -505,6 +505,27 @@ free_newfaction(newfaction * nf)
/** create new island with up to nsize players /** create new island with up to nsize players
* returns the number of players placed on the new island. * 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->age<age) continue;
if (r->planep) 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 int
autoseed(newfaction ** players, int nsize, boolean new_island) 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 */ int psize = 0; /* players on this island */
const terrain_type * volcano_terrain = get_terrain("volcano"); const terrain_type * volcano_terrain = get_terrain("volcano");
frame_regions(16, T_FIREWALL);
if (listlen(*players)<MINFACTIONS) return 0; if (listlen(*players)<MINFACTIONS) return 0;
if (!new_island) { if (!new_island) {

View file

@ -77,7 +77,7 @@ wormhole_age(struct attrib * a)
for (;u!=NULL && maxtransport!=0;u=u->next) { for (;u!=NULL && maxtransport!=0;u=u->next) {
if (u->building==data->entry) { if (u->building==data->entry) {
message * m = NULL; 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); m = msg_message("wormhole_requirements", "unit region", u, u->region);
} else if (data->exit!=NULL) { } else if (data->exit!=NULL) {
move_unit(u, data->exit->region, NULL); move_unit(u, data->exit->region, NULL);

View file

@ -3845,6 +3845,12 @@ sp_charmingsong(castorder *co)
/* Die Einheit ist eine der unsrigen */ /* Die Einheit ist eine der unsrigen */
cmistake(mage, co->order, 45, MSG_MAGIC); 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 */ /* Magieresistensbonus für mehr als Stufe Personen */
if (target->number > force) { 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); create_curse(mage, &target->attribs, ct_find("slavery"), force, duration, zero_effect, 0);
/* setze Partei um und lösche langen Befehl aus Sicherheitsgründen */ /* 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); set_order(&target->thisorder, NULL);
/* setze Parteitarnung, damit nicht sofort klar ist, wer dahinter /* setze Parteitarnung, damit nicht sofort klar ist, wer dahinter
@ -4113,7 +4119,7 @@ sp_migranten(castorder *co)
return 0; return 0;
} }
/* niemand mit teurem Talent */ /* niemand mit teurem Talent */
if (teure_talente(target)) { if (has_limited_skills(target)) {
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
"spellfail_noexpensives", "target", target)); "spellfail_noexpensives", "target", target));
return 0; return 0;

View file

@ -281,6 +281,8 @@ static void
fix_firewalls(void) fix_firewalls(void)
{ {
region * r = regions; region * r = regions;
int fixes = 0;
while (r) { while (r) {
direction_t d; direction_t d;
for (d=0;d!=MAXDIRECTIONS;++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", log_warning(("firewall between regions %s and %s was bugged. removed.\n",
regionname(r, NULL), regionname(r2, NULL))); regionname(r, NULL), regionname(r2, NULL)));
b = get_borders(r, r2); b = get_borders(r, r2);
++fixes;
} else { } else {
b = b->next; b = b->next;
} }
@ -306,6 +309,7 @@ fix_firewalls(void)
} }
r = r->next; r = r->next;
} }
log_printf("fixed %u firewalls.\n", fixes);
} }
static void static void
@ -472,6 +476,7 @@ static void
fix_gates(void) fix_gates(void)
{ {
region * r; region * r;
int fixes = 0;
for (r=regions;r;r=r->next) { for (r=regions;r;r=r->next) {
unit * u; unit * u;
building * b; building * b;
@ -492,6 +497,7 @@ fix_gates(void)
} }
remove_triggers(&u->attribs, "timer", &tt_gate); remove_triggers(&u->attribs, "timer", &tt_gate);
remove_triggers(&u->attribs, "create", &tt_unguard); remove_triggers(&u->attribs, "create", &tt_unguard);
++fixes;
} }
} }
for (b=r->buildings;b;b=b->next) { for (b=r->buildings;b;b=b->next) {
@ -510,10 +516,12 @@ fix_gates(void)
add_trigger(&bgate->attribs, "create", trigger_unguard(bgate)); add_trigger(&bgate->attribs, "create", trigger_unguard(bgate));
fset(bgate, BLD_UNGUARDED); fset(bgate, BLD_UNGUARDED);
} }
++fixes;
} }
} }
} }
} }
log_printf("fixed %u gates.\n", fixes);
} }
static int static int
@ -562,48 +570,6 @@ road_decay(void)
return 0; 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 #if GLOBAL_WARMING
static void static void
@ -917,6 +883,7 @@ static void
fix_toads(void) fix_toads(void)
{ {
region * r; region * r;
int fixes = 0;
const struct race * toad = rc_find("toad"); const struct race * toad = rc_find("toad");
for (r=regions;r!=NULL;r=r->next) { for (r=regions;r!=NULL;r=r->next) {
@ -942,12 +909,35 @@ fix_toads(void)
if (!found) { if (!found) {
log_error(("fixed toad %s.\n", unitname(u))); log_error(("fixed toad %s.\n", unitname(u)));
u->race=u->faction->race; 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 static void
fix_groups(void) fix_groups(void)
{ {
@ -995,7 +985,6 @@ korrektur(void)
do_once("chgt", &fix_chaosgates); do_once("chgt", &fix_chaosgates);
do_once("atrx", &fix_attribflags); do_once("atrx", &fix_attribflags);
do_once("asfi", &fix_astral_firewalls); do_once("asfi", &fix_astral_firewalls);
frame_regions();
#if GLOBAL_WARMING #if GLOBAL_WARMING
if (get_gamedate(turn, NULL)->season == SEASON_SUMMER) { if (get_gamedate(turn, NULL)->season == SEASON_SUMMER) {
global_warming(); global_warming();
@ -1005,6 +994,7 @@ korrektur(void)
fix_firewalls(); fix_firewalls();
fix_gates(); fix_gates();
fix_toads(); fix_toads();
/* fix_heroes(); */
verify_owners(false); verify_owners(false);
/* fix_herbtypes(); */ /* fix_herbtypes(); */
/* In Vin 3+ können Parteien komplett übergeben werden. */ /* In Vin 3+ können Parteien komplett übergeben werden. */