Total ohne Not mal wieder eine grosse Umstellung gemacht: Diesmal am Parser.

Okay, natuerlich habe ich damit was im Sinne: Das ist eine Vorbereitung auf voll geskriptete, neu zugefuegte Befehle und anderes Processing (aus Skripten). Fuer ein neues Spiel.

Hoffen wir, dass nicht zuviel kaputtgeht :-)
This commit is contained in:
Enno Rehling 2006-08-12 19:15:16 +00:00
parent 150a1e38b0
commit ed70863843
30 changed files with 1176 additions and 1175 deletions

View File

@ -995,93 +995,86 @@ gebaeude_stuerzt_ein(region * r, building * b)
}
void
maintain_buildings(boolean crash)
maintain_buildings(region * r, boolean crash)
{
region * r;
for (r = regions; r; r = r->next) {
building **bp = &r->buildings;
while (*bp) {
building * b = *bp;
boolean maintained = maintain(b, !crash);
building **bp = &r->buildings;
while (*bp) {
building * b = *bp;
boolean maintained = maintain(b, !crash);
/* the second time, send a message */
if (crash) {
if (!maintained && (rng_int() % 100 < EINSTURZCHANCE)) {
gebaeude_stuerzt_ein(r, b);
continue;
} else if (!fval(b, BLD_WORKING)) {
unit * u = buildingowner(r, b);
const char * msgtype = maintained?"maintenance_nowork":"maintenance_none";
struct message * msg = msg_message(msgtype, "building", b);
/* the second time, send a message */
if (crash) {
if (!maintained && (rng_int() % 100 < EINSTURZCHANCE)) {
gebaeude_stuerzt_ein(r, b);
continue;
} else if (!fval(b, BLD_WORKING)) {
unit * u = buildingowner(r, b);
const char * msgtype = maintained?"maintenance_nowork":"maintenance_none";
struct message * msg = msg_message(msgtype, "building", b);
if (u) {
add_message(&u->faction->msgs, msg);
r_addmessage(r, u->faction, msg);
} else {
add_message(&r->msgs, msg);
}
msg_release(msg);
if (u) {
add_message(&u->faction->msgs, msg);
r_addmessage(r, u->faction, msg);
} else {
add_message(&r->msgs, msg);
}
msg_release(msg);
}
bp=&b->next;
}
}
bp=&b->next;
}
}
void
economics(void)
economics(region *r)
{
region *r;
unit *u;
request *recruitorders = NULL;
/* Geben vor Selbstmord (doquit)! Hier alle unmittelbaren Befehle.
* Rekrutieren vor allen Einnahmequellen. Bewachen JA vor Steuern
* eintreiben. */
* Rekrutieren vor allen Einnahmequellen. Bewachen JA vor Steuern
* eintreiben. */
for (r = regions; r; r = r->next) if (r->units) {
request *recruitorders = NULL;
for (u = r->units; u; u = u->next) {
order * ord;
boolean destroyed = false;
for (ord = u->orders; ord; ord = ord->next) {
switch (get_keyword(ord)) {
case K_DESTROY:
if (!destroyed) {
if (destroy_cmd(u, ord)!=0) ord = NULL;
destroyed = true;
}
break;
case K_GIVE:
case K_LIEFERE:
give_cmd(u, ord);
break;
case K_FORGET:
forget_cmd(u, ord);
break;
}
if (u->orders==NULL) break;
}
}
/* RECRUIT orders */
for (u = r->units; u; u = u->next) {
order * ord;
for (ord = u->orders; ord; ord = ord->next) {
if (get_keyword(ord) == K_RECRUIT) {
recruit(u, ord, &recruitorders);
for (u = r->units; u; u = u->next) {
order * ord;
boolean destroyed = false;
for (ord = u->orders; ord; ord = ord->next) {
switch (get_keyword(ord)) {
case K_DESTROY:
if (!destroyed) {
if (destroy_cmd(u, ord)!=0) ord = NULL;
destroyed = true;
}
break;
}
case K_GIVE:
case K_LIEFERE:
give_cmd(u, ord);
break;
case K_FORGET:
forget_cmd(u, ord);
break;
}
if (u->orders==NULL) break;
}
}
/* RECRUIT orders */
for (u = r->units; u; u = u->next) {
order * ord;
for (ord = u->orders; ord; ord = ord->next) {
if (get_keyword(ord) == K_RECRUIT) {
recruit(u, ord, &recruitorders);
break;
}
}
if (recruitorders) expandrecruit(r, recruitorders);
}
if (recruitorders) expandrecruit(r, recruitorders);
remove_empty_units_in_region(r);
}
/* ------------------------------------------------------------- */

View File

@ -47,11 +47,11 @@ extern int income(const struct unit * u);
/* Wieviel Fremde eine Partei pro Woche aufnehmen kann */
#define MAXNEWBIES 5
void economics(void);
void economics(struct region *r);
void produce(void);
enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC };
void maintain_buildings(boolean crash);
void maintain_buildings(struct region * r, boolean crash);
extern void add_spende(struct faction * f1, struct faction * f2, int betrag, struct region * r);
#ifdef __cplusplus

File diff suppressed because it is too large Load Diff

View File

@ -761,23 +761,16 @@ monster_learn(unit *u)
}
void
monsters_kill_peasants(void)
monsters_kill_peasants(unit * u)
{
region *r;
unit *u;
for (r = regions; r; r = r->next) {
for (u = r->units; u; u = u->next) if(!fval(u, UFL_MOVED)) {
if (u->race->flags & RCF_SCAREPEASANTS) {
scared_by_monster(u);
}
if (u->race->flags & RCF_KILLPEASANTS) {
eaten_by_monster(u);
}
if (u->race->flags & RCF_ABSORBPEASANTS) {
absorbed_by_monster(u);
}
}
if (u->race->flags & RCF_SCAREPEASANTS) {
scared_by_monster(u);
}
if (u->race->flags & RCF_KILLPEASANTS) {
eaten_by_monster(u);
}
if (u->race->flags & RCF_ABSORBPEASANTS) {
absorbed_by_monster(u);
}
}

View File

@ -29,7 +29,7 @@ extern "C" {
void age_illusion(struct unit *u);
void monsters_kill_peasants(void);
void monsters_kill_peasants(struct unit * u);
void plan_monsters(void);
struct unit *random_unit(const struct region * r);

View File

@ -459,9 +459,8 @@ sink_ship(region * r, ship * sh, const char *name, char spy, unit * saboteur)
sprintf(buf, (dead == 1) ? person_lost_msg : persons_lost_msg,
dead, unitname(u), unit_dies_msg);
}
if (dead == u->number)
/* the poor creature, she dies */
{
if (dead == u->number) {
/* the poor creature, she dies */
*ui = u->next;
destroy_unit(u);
}

View File

@ -439,11 +439,10 @@ teach(unit * u, struct order * ord)
}
/* ------------------------------------------------------------- */
void
learn(void)
int
learn_cmd(unit * u, order * ord)
{
region *r;
unit *u;
region *r = u->region;
int p;
magic_t mtyp;
int l;
@ -451,286 +450,281 @@ learn(void)
/* lernen nach lehren */
for (r = regions; r; r = r->next) {
for (u = r->units; u; u = u->next) {
int days;
if (fval(r->terrain, SEA_REGION)) {
/* sonderbehandlung aller die auf Ozeanen lernen können */
if (u->race!=new_race[RC_AQUARIAN] && !(u->race->flags & RCF_SWIM)) {
continue;
int days;
double multi = 1.0;
attrib * a = NULL;
teaching_info * teach = NULL;
int money = 0;
skill_t sk;
int maxalchemy = 0;
if (fval(r->terrain, SEA_REGION)) {
/* sonderbehandlung aller die auf Ozeanen lernen können */
if (u->race!=new_race[RC_AQUARIAN] && !(u->race->flags & RCF_SWIM)) {
return 0;
}
}
if (fval(u, UFL_LONGACTION)) return 0;
if (u->race == new_race[RC_INSECT] && r_insectstalled(r)
&& !is_cursed(u->attribs, C_KAELTESCHUTZ,0)) {
return 0;
}
if (fval(u, UFL_LONGACTION)) {
cmistake(u, ord, 52, MSG_PRODUCE);
return 0;
}
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, ord, buf, MSG_EVENT);
return 0;
}
init_tokens(ord);
skip_token();
sk = getskill(u->faction->locale);
if (sk < 0) {
cmistake(u, ord, 77, MSG_EVENT);
return 0;
}
if (SkillCap(sk) && SkillCap(sk) <= effskill(u, sk)) {
cmistake(u, ord, 77, MSG_EVENT);
return 0;
}
/* Hack: Talente mit Malus -99 können nicht gelernt werden */
if (u->race->bonus[sk] == -99) {
cmistake(u, ord, 77, MSG_EVENT);
return 0;
}
/* snotlings können Talente nur bis T8 lernen */
if (u->race == new_race[RC_SNOTLING]){
if (get_level(u, sk) >= 8){
cmistake(u, ord, 308, MSG_EVENT);
return 0;
}
}
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, ord, buf, MSG_EVENT);
return 0;
}
/* 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, ord, 106, MSG_MAGIC);
return 0;
}
if (is_familiar(u)){
/* Vertraute zählen nicht zu den Magiern einer Partei,
* können aber nur Graue Magie lernen */
mtyp = M_GRAU;
if (!is_mage(u)) 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, ord, buf, MSG_EVENT);
return 0;
}
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, ord, 178, MSG_MAGIC);
return 0;
}
}
if (fval(u, UFL_LONGACTION)) continue;
if (get_keyword(u->thisorder) == K_STUDY) {
double multi = 1.0;
attrib * a = NULL;
teaching_info * teach = NULL;
int money = 0;
skill_t sk;
int maxalchemy = 0;
if (mtyp != u->faction->magiegebiet){
/* Es wurde versucht, ein anderes Magiegebiet zu lernen
* als das der Partei */
if (u->faction->magiegebiet != 0){
cmistake(u, ord, 179, MSG_MAGIC);
return 0;
} else {
/* Lernt zum ersten mal Magie und legt damit das
* Magiegebiet der Partei fest */
u->faction->magiegebiet = mtyp;
}
}
if (!is_mage(u)) 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, ord, 178, MSG_MAGIC);
return 0;
} 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, ord, buf, MSG_EVENT);
return 0;
}
}
if (studycost) {
int cost = studycost * u->number;
money = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, cost);
money = min(money, cost);
}
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, ord, 65, MSG_EVENT);
multi = money / (double)(studycost * u->number);
#else
cmistake(u, ord, 65, MSG_EVENT);
return 0; /* nein, Silber reicht auch so nicht */
#endif
}
}
if (u->race == new_race[RC_INSECT] && r_insectstalled(r)
&& !is_cursed(u->attribs, C_KAELTESCHUTZ,0)) {
continue;
}
if (fval(u, UFL_LONGACTION)) {
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;
}
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, oldresourcetype[R_SILVER], GET_DEFAULT, money);
ADDMSG(&u->faction->msgs, msg_message("studycost",
"unit region cost skill", u, u->region, money, sk));
}
init_tokens(u->thisorder);
skip_token();
sk = getskill(u->faction->locale);
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);
}
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;
}
}
#ifdef KARMA_MODULE
l = fspecial(u->faction, FS_WARRIOR);
if (l > 0) {
if (sk == SK_CROSSBOW || sk == SK_LONGBOW
|| sk == SK_CATAPULT || sk == SK_MELEE || sk == SK_SPEAR
|| sk == SK_AUSDAUER || sk == SK_WEAPONLESS)
{
teach->value += u->number * 5 * (l+1);
} else {
teach->value -= u->number * 5 * (l+1);
teach->value = max(0, teach->value);
}
}
#endif /* KARMA_MODULE */
p = studycost = study_cost(u, sk);
a = a_find(u->attribs, &at_learning);
if (a!=NULL) {
teach = (teaching_info*)a->data.v;
}
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;
}
/* 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 (is_cursed(r->attribs, C_BADLEARN,0)) {
teach->value -= u->number * 10;
}
if (btype == bt_find("academy")) {
studycost = max(50, studycost * 2);
}
}
days = (int)((u->number * 30 + teach->value) * multi);
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 (!is_mage(u)) 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_mage(u)) 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);
continue;
}
}
if (studycost) {
int cost = studycost * u->number;
money = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, cost);
money = min(money, cost);
}
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);
#else
cmistake(u, u->thisorder, 65, MSG_EVENT);
continue; /* nein, Silber reicht auch so nicht */
#endif
}
}
/* 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 (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, oldresourcetype[R_SILVER], GET_DEFAULT, money);
ADDMSG(&u->faction->msgs, msg_message("studycost",
"unit region cost skill", u, u->region, money, sk));
if (sk == SK_ENTERTAINMENT && 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) {
ADDMSG(&u->faction->msgs, msg_message("teach_student",
"teacher student skill", teacher, u, sk));
ADDMSG(&teacher->faction->msgs, msg_message("teach_teacher",
"teacher student skill level", teacher, u, sk,
effskill(u, sk)));
}
}
}
a_remove(&u->attribs, a);
a = NULL;
}
fset(u, UFL_LONGACTION);
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);
}
/* Anzeigen neuer Tränke */
/* Spruchlistenaktualiesierung ist in Regeneration */
#ifdef KARMA_MODULE
l = fspecial(u->faction, FS_WARRIOR);
if (l > 0) {
if (sk == SK_CROSSBOW || sk == SK_LONGBOW
|| sk == SK_CATAPULT || sk == SK_MELEE || sk == SK_SPEAR
|| sk == SK_AUSDAUER || sk == SK_WEAPONLESS)
{
teach->value += u->number * 5 * (l+1);
} else {
teach->value -= u->number * 5 * (l+1);
teach->value = max(0, teach->value);
}
}
#endif /* KARMA_MODULE */
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 (sk == SK_ENTERTAINMENT && 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) {
ADDMSG(&u->faction->msgs, msg_message("teach_student",
"teacher student skill", teacher, u, sk));
ADDMSG(&teacher->faction->msgs, msg_message("teach_teacher",
"teacher student skill level", teacher, u, sk,
effskill(u, sk)));
}
}
}
a_remove(&u->attribs, a);
a = NULL;
}
fset(u, UFL_LONGACTION);
/* 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->type==&at_showitem && a->data.v != ptype) a=a->next;
if (a==NULL || a->type!=&at_showitem) {
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->type==&at_showitem && a->data.v != ptype) a=a->next;
if (a==NULL || a->type!=&at_showitem) {
a = a_add(&f->attribs, a_new(&at_showitem));
a->data.v = (void*) ptype->itype;
}
}
}
@ -738,54 +732,50 @@ learn(void)
}
}
void
teaching(void)
teaching(region *r)
{
region *r;
/* das sind alles befehle, die 30 tage brauchen, und die in thisorder
* stehen! von allen 30-tage befehlen wird einfach der letzte verwendet
* (dosetdefaults).
*
* lehren vor lernen. */
for (r = regions; r; r = r->next) {
unit *u;
unit *u;
for (u = r->units; u; u = u->next) {
for (u = r->units; u; u = u->next) {
if (u->race == new_race[RC_SPELL] || fval(u, UFL_LONGACTION))
if (u->race == new_race[RC_SPELL] || fval(u, UFL_LONGACTION))
continue;
if (fval(r->terrain, SEA_REGION)
&& u->race != new_race[RC_AQUARIAN]
&& !(u->race->flags & RCF_SWIM))
continue;
if (fval(r->terrain, SEA_REGION)
&& u->race != new_race[RC_AQUARIAN]
&& !(u->race->flags & RCF_SWIM))
continue;
if (u->race == new_race[RC_INSECT] && r_insectstalled(r)
&& !is_cursed(u->attribs, C_KAELTESCHUTZ,0)) {
continue;
}
if (u->race == new_race[RC_INSECT] && r_insectstalled(r)
&& !is_cursed(u->attribs, C_KAELTESCHUTZ,0)) {
switch (get_keyword(u->thisorder)) {
case K_TEACH:
if (fval(u, UFL_LONGACTION)) {
cmistake(u, u->thisorder, 52, MSG_PRODUCE);
continue;
}
switch (get_keyword(u->thisorder)) {
case K_TEACH:
if (fval(u, UFL_LONGACTION)) {
cmistake(u, u->thisorder, 52, MSG_PRODUCE);
continue;
} else {
static const curse_type * gbdream_ct = NULL;
if (gbdream_ct==0) gbdream_ct = ct_find("gbdream");
if (gbdream_ct) {
if (get_curse(u->region->attribs, gbdream_ct)) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, u->thisorder, "gbdream_noteach", ""));
continue;
}
} else {
static const curse_type * gbdream_ct = NULL;
if (gbdream_ct==0) gbdream_ct = ct_find("gbdream");
if (gbdream_ct) {
if (get_curse(u->region->attribs, gbdream_ct)) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, u->thisorder, "gbdream_noteach", ""));
continue;
}
}
teach(u, u->thisorder);
break;
}
}
teach(u, u->thisorder);
break;
}
}
}

View File

@ -19,8 +19,8 @@
extern "C" {
#endif
extern void teaching(void);
extern void learn(void);
extern void teaching(struct region * r);
extern int learn_cmd(struct unit * u, struct order * ord);
extern magic_t getmagicskill(void);
extern boolean is_migrant(struct unit *u);

View File

@ -3988,106 +3988,101 @@ battle_flee(battle * b)
}
void
do_battle(void)
do_battle(region * r)
{
region *r;
#ifdef SMALL_BATTLE_MESSAGES
char smallbuf[512];
#endif
battle *b = NULL;
boolean fighting = false;
ship * sh;
building *bu;
for (r=regions;r!=NULL;r=r->next) {
battle *b = NULL;
boolean fighting = false;
ship * sh;
building *bu;
/* int *rows; */
fighting = init_battle(r, &b);
fighting = init_battle(r, &b);
if (b==NULL) return;
if (b==NULL) continue;
/* Bevor wir die alliierten hineinziehen, sollten wir schauen, *
* Ob jemand fliehen kann. Dann erübrigt sich das ganze ja
* vielleicht schon. */
print_header(b);
if (!fighting) {
/* Niemand mehr da, Kampf kann nicht stattfinden. */
message * m = msg_message("battle::aborted", "");
message_all(b, m);
msg_release(m);
free_battle(b);
free(b);
continue;
}
join_allies(b);
/* Bevor wir die alliierten hineinziehen, sollten wir schauen, *
* Ob jemand fliehen kann. Dann erübrigt sich das ganze ja
* vielleicht schon. */
print_header(b);
if (!fighting) {
/* Niemand mehr da, Kampf kann nicht stattfinden. */
message * m = msg_message("battle::aborted", "");
message_all(b, m);
msg_release(m);
free_battle(b);
free(b);
return;
}
join_allies(b);
#ifdef HEROES
make_heroes(b);
make_heroes(b);
#endif
/* Alle Mann raus aus der Burg! */
for (bu=r->buildings; bu!=NULL; bu=bu->next) bu->sizeleft = bu->size;
/* Alle Mann raus aus der Burg! */
for (bu=r->buildings; bu!=NULL; bu=bu->next) bu->sizeleft = bu->size;
/* make sure no ships are damaged initially */
for (sh=r->ships; sh; sh=sh->next) freset(sh, SF_DAMAGED);
/* make sure no ships are damaged initially */
for (sh=r->ships; sh; sh=sh->next) freset(sh, SF_DAMAGED);
/* Gibt es eine Taktikrunde ? */
if (cv_size(&b->leaders)) {
b->turn = 0;
b->has_tactics_turn = true;
} else {
b->turn = 1;
b->has_tactics_turn = false;
}
/* Gibt es eine Taktikrunde ? */
if (cv_size(&b->leaders)) {
b->turn = 0;
b->has_tactics_turn = true;
} else {
b->turn = 1;
b->has_tactics_turn = false;
}
if (b->region->flags & RF_COMBATDEBUG) battle_stats(bdebug, b);
if (b->region->flags & RF_COMBATDEBUG) battle_stats(bdebug, b);
/* PRECOMBATSPELLS */
do_combatmagic(b, DO_PRECOMBATSPELL);
/* PRECOMBATSPELLS */
do_combatmagic(b, DO_PRECOMBATSPELL);
print_stats(b); /* gibt die Kampfaufstellung aus */
printf("%s (%d, %d) : ", rname(r, NULL), r->x, r->y);
print_stats(b); /* gibt die Kampfaufstellung aus */
printf("%s (%d, %d) : ", rname(r, NULL), r->x, r->y);
#ifdef SMALL_BATTLE_MESSAGES
if (b->nfighters <= 30) {
b->small = true;
} else {
b->small = false;
}
if (b->nfighters <= 30) {
b->small = true;
} else {
b->small = false;
}
#endif
for (;battle_report(b) && b->turn<=COMBAT_TURNS;++b->turn) {
char lbuf[256];
for (;battle_report(b) && b->turn<=COMBAT_TURNS;++b->turn) {
char lbuf[256];
sprintf(lbuf, "*** Runde: %d", b->turn);
battledebug(lbuf);
sprintf(lbuf, "*** Runde: %d", b->turn);
battledebug(lbuf);
battle_flee(b);
battle_update(b);
battle_attacks(b);
battle_flee(b);
battle_update(b);
battle_attacks(b);
#ifdef KARMA_MODULE
/* Regeneration */
for (fi=0;fi!=b->nfighters;++fi) {
fighter *fig = b->fighters[fi];
/* Regeneration */
for (fi=0;fi!=b->nfighters;++fi) {
fighter *fig = b->fighters[fi];
if (fspecial(fig->unit->faction, FS_REGENERATION)) {
fig->fighting = fig->alive - fig->removed;
if (fig->fighting == 0) continue;
do_regenerate(fig);
}
if (fspecial(fig->unit->faction, FS_REGENERATION)) {
fig->fighting = fig->alive - fig->removed;
if (fig->fighting == 0) continue;
do_regenerate(fig);
}
}
#endif /* KARMA_MODULE */
}
}
printf("\n");
printf("\n");
/* Auswirkungen berechnen: */
aftermath(b);
/* Hier ist das Gefecht beendet, und wir können die
* Hilfsstrukturen * wieder löschen: */
/* Auswirkungen berechnen: */
aftermath(b);
/* Hier ist das Gefecht beendet, und wir können die
* Hilfsstrukturen * wieder löschen: */
if (b) {
free_battle(b);
free(b);
}
if (b) {
free_battle(b);
free(b);
}
}

View File

@ -206,7 +206,7 @@ extern "C" {
extern const troop no_troop;
extern void do_battle(void);
extern void do_battle(struct region * r);
/* for combar spells and special attacks */
enum { SELECT_ADVANCE = 0x1, SELECT_DISTANCE = 0x2, SELECT_FIND = 0x4 };

View File

@ -281,18 +281,14 @@ siege_cmd(unit * u, order * ord)
}
void
do_siege(void)
do_siege(region *r)
{
region *r;
if (fval(r->terrain, LAND_REGION)) {
unit *u;
for (r = regions; r; r = r->next) {
if (fval(r->terrain, LAND_REGION)) {
unit *u;
for (u = r->units; u; u = u->next) {
if (get_keyword(u->thisorder) == K_BESIEGE) {
siege_cmd(u, u->thisorder);
}
for (u = r->units; u; u = u->next) {
if (get_keyword(u->thisorder) == K_BESIEGE) {
siege_cmd(u, u->thisorder);
}
}
}
@ -1106,26 +1102,6 @@ mayboard(const unit * u, const ship * sh)
}
void
remove_contacts(void)
{
region *r;
for (r = regions; r; r = r->next) {
unit *u;
for (u = r->units; u; u = u->next) {
attrib * a = (attrib *)a_find(u->attribs, &at_contact);
while (a!=NULL &&a->type==&at_contact) {
attrib * ar = a;
a = a->next;
a_remove(&u->attribs, ar);
}
}
}
}
int
leave_cmd(unit * u, struct order * ord)
{
@ -1255,93 +1231,87 @@ enter_building(unit * u, order * ord, int id, boolean report)
}
void
do_misc(boolean lasttry)
do_misc(region * r, boolean lasttry)
{
region *r;
unit **uptr, *uc;
/* lasttry: Fehler nur im zweiten Versuch melden. Sonst konfus. */
for (uc = r->units; uc; uc = uc->next) {
order * ord;
for (ord = uc->orders; ord; ord = ord->next) {
switch (get_keyword(ord)) {
case K_CONTACT:
contact_cmd(uc, ord, lasttry);
break;
}
}
}
for (r = regions; r; r = r->next) {
unit **uptr, *uc;
for (uptr = &r->units; *uptr;) {
unit * u = *uptr;
order ** ordp = &u->orders;
for (uc = r->units; uc; uc = uc->next) {
order * ord;
for (ord = uc->orders; ord; ord = ord->next) {
switch (get_keyword(ord)) {
case K_CONTACT:
contact_cmd(uc, ord, lasttry);
while (*ordp) {
order * ord = *ordp;
if (get_keyword(ord) == K_ENTER) {
param_t p;
int id;
unit * ulast = NULL;
init_tokens(ord);
skip_token();
p = getparam(u->faction->locale);
id = getid();
switch (p) {
case P_BUILDING:
case P_GEBAEUDE:
if (u->building && u->building->no==id) break;
if (enter_building(u, ord, id, lasttry)) {
unit *ub;
for (ub=u;ub;ub=ub->next) {
if (ub->building==u->building) {
ulast = ub;
}
}
}
break;
case P_SHIP:
if (u->ship && u->ship->no==id) break;
if (enter_ship(u, ord, id, lasttry)) {
unit *ub;
ulast = u;
for (ub=u;ub;ub=ub->next) {
if (ub->ship==u->ship) {
ulast = ub;
}
}
}
break;
default:
if (lasttry) cmistake(u, ord, 79, MSG_MOVE);
}
if (ulast!=NULL) {
/* Wenn wir hier angekommen sind, war der Befehl
* erfolgreich und wir löschen ihn, damit er im
* zweiten Versuch nicht nochmal ausgeführt wird. */
*ordp = ord->next;
ord->next = NULL;
free_order(ord);
if (ulast!=u) {
/* put u behind ulast so it's the last unit in the building */
*uptr = u->next;
u->next = ulast->next;
ulast->next = u;
}
break;
}
}
if (*ordp==ord) ordp = &ord->next;
}
for (uptr = &r->units; *uptr;) {
unit * u = *uptr;
order ** ordp = &u->orders;
while (*ordp) {
order * ord = *ordp;
if (get_keyword(ord) == K_ENTER) {
param_t p;
int id;
unit * ulast = NULL;
init_tokens(ord);
skip_token();
p = getparam(u->faction->locale);
id = getid();
switch (p) {
case P_BUILDING:
case P_GEBAEUDE:
if (u->building && u->building->no==id) break;
if (enter_building(u, ord, id, lasttry)) {
unit *ub;
for (ub=u;ub;ub=ub->next) {
if (ub->building==u->building) {
ulast = ub;
}
}
}
break;
case P_SHIP:
if (u->ship && u->ship->no==id) break;
if (enter_ship(u, ord, id, lasttry)) {
unit *ub;
ulast = u;
for (ub=u;ub;ub=ub->next) {
if (ub->ship==u->ship) {
ulast = ub;
}
}
}
break;
default:
if (lasttry) cmistake(u, ord, 79, MSG_MOVE);
}
if (ulast!=NULL) {
/* Wenn wir hier angekommen sind, war der Befehl
* erfolgreich und wir löschen ihn, damit er im
* zweiten Versuch nicht nochmal ausgeführt wird. */
*ordp = ord->next;
ord->next = NULL;
free_order(ord);
if (ulast!=u) {
/* put u behind ulast so it's the last unit in the building */
*uptr = u->next;
u->next = ulast->next;
ulast->next = u;
}
break;
}
}
if (*ordp==ord) ordp = &ord->next;
}
if (*uptr==u) uptr = &u->next;
}
if (*uptr==u) uptr = &u->next;
}
}

View File

@ -62,7 +62,7 @@ extern int leave_cmd(struct unit * u, struct order * ord);
extern boolean can_contact(const struct region *r, const struct unit *u, const struct unit *u2);
void do_siege(void);
void do_siege(struct region *r);
void build_road(struct region * r, struct unit * u, int size, direction_t d);
void create_ship(struct region * r, struct unit * u, const struct ship_type * newtype, int size, struct order * ord);
void continue_ship(struct region * r, struct unit * u, int size);
@ -70,8 +70,7 @@ void continue_ship(struct region * r, struct unit * u, int size);
struct building * getbuilding(const struct region * r);
struct ship *getship(const struct region * r);
void remove_contacts(void);
void do_misc(boolean tries);
void do_misc(struct region *r, boolean tries);
void reportevent(struct region * r, char *s);

View File

@ -496,7 +496,7 @@ destroy_building(building * b)
/* Stattdessen nur aus Liste entfernen, aber im Speicher halten. */
choplist(&b->region->buildings, b);
handle_event(&b->attribs, "destroy", b);
handle_event(b->attribs, "destroy", b);
}
extern attrib_type at_icastle;

View File

@ -2539,9 +2539,9 @@ remove_empty_units_in_region(region *r)
faction * f = u->faction;
if (!fval(f, FFL_NOTIMEOUT) && f->age > MaxAge()) set_number(u, 0);
}
if ((u->number == 0 && u->race != new_race[RC_SPELL])
|| (u->age <= 0 && u->race == new_race[RC_SPELL])) {
if ((u->number == 0 && u->race != new_race[RC_SPELL]) || (u->age <= 0 && u->race == new_race[RC_SPELL])) {
destroy_unit(u);
if (u->number==0) remove_unit(u);
}
if (*up==u) up=&u->next;
}

View File

@ -253,7 +253,7 @@ destroyfaction(faction * f)
}
f->alive = 0;
/* no way! f->units = NULL; */
handle_event(&f->attribs, "destroy", f);
handle_event(f->attribs, "destroy", f);
for (ff = factions; ff; ff = ff->next) {
group *g;
ally *sf, *sfn;

View File

@ -124,8 +124,8 @@ give_item(int want, const item_type * itype, unit * src, unit * dest, struct ord
}
#endif
#endif
handle_event(&src->attribs, "give", dest);
handle_event(&dest->attribs, "receive", src);
handle_event(src->attribs, "give", dest);
handle_event(dest->attribs, "receive", src);
#if defined(MUSEUM_MODULE) && defined(TODO)
/* TODO: Einen Trigger für den museums-warden benutzen! */
if (a_find(dest->attribs, &at_warden)) {

View File

@ -2807,6 +2807,7 @@ magic(void)
for (spellrank = 0; spellrank < MAX_SPELLRANK; spellrank++) {
free_castorders(cll[spellrank]);
}
remove_empty_units();
}
const char *

View File

@ -2524,83 +2524,81 @@ movement(void)
* FOLLOW SHIP is a long order, and doesn't need to be treated in here.
*/
void
follow_unit(void)
follow_unit(unit * u)
{
region * r;
region * r = u->region;
attrib * a = NULL;
order * ord;
for (r=regions;r;r=r->next) {
unit * u;
if (fval(u, UFL_LONGACTION) || LongHunger(u)) return;
for (u=r->units;u;u=u->next) {
attrib * a;
order * ord;
for (ord=u->orders;ord;ord=ord->next) {
const struct locale * lang = u->faction->locale;
if (fval(u, UFL_LONGACTION) || LongHunger(u)) continue;
a = a_find(u->attribs, &at_follow);
for (ord=u->orders;ord;ord=ord->next) {
const struct locale * lang = u->faction->locale;
if (get_keyword(ord) == K_FOLLOW) {
init_tokens(ord);
skip_token();
if (getparam(lang) == P_UNIT) {
int id = read_unitid(u->faction, r);
if (get_keyword(ord) == K_FOLLOW) {
init_tokens(ord);
skip_token();
if (getparam(lang) == P_UNIT) {
int id = read_unitid(u->faction, r);
if (a!=NULL) {
a = a_find(u->attribs, &at_follow);
}
if (id>0) {
unit * uf = findunit(id);
if (!a) {
a = a_add(&u->attribs, make_follow(uf));
} else {
a->data.v = uf;
}
} else if (a) {
a_remove(&u->attribs, a);
a = NULL;
}
if (id>0) {
unit * uf = findunit(id);
if (!a) {
a = a_add(&u->attribs, make_follow(uf));
} else {
a->data.v = uf;
}
}
}
if (a && !fval(u, UFL_MOVED|UFL_NOTMOVING)) {
unit * u2 = a->data.v;
boolean follow = false;
if (!u2 || u2->region!=r || !cansee(u->faction, r, u2, 0))
continue;
switch (get_keyword(u2->thisorder)) {
case K_MOVE:
case K_ROUTE:
case K_DRIVE:
follow = true;
break;
default:
for (ord=u2->orders;ord;ord=ord->next) {
switch (get_keyword(ord)) {
case K_FOLLOW:
case K_PIRACY:
follow = true;
break;
default:
continue;
}
break;
}
break;
}
if (!follow) {
attrib * a2 = a_find(u2->attribs, &at_follow);
if (a2!=NULL) {
unit * u3 = a2->data.v;
follow = (u3 && u2->region == u2->region);
}
}
if (follow) {
fset(u, UFL_FOLLOWING);
fset(u2, UFL_FOLLOWED);
set_order(&u->thisorder, NULL);
} else if (a) {
a_remove(&u->attribs, a);
a = NULL;
}
}
}
}
if (a && !fval(u, UFL_MOVED|UFL_NOTMOVING)) {
unit * u2 = a->data.v;
boolean follow = false;
if (!u2 || u2->region!=r || !cansee(u->faction, r, u2, 0)) {
return;
}
switch (get_keyword(u2->thisorder)) {
case K_MOVE:
case K_ROUTE:
case K_DRIVE:
follow = true;
break;
default:
for (ord=u2->orders;ord;ord=ord->next) {
switch (get_keyword(ord)) {
case K_FOLLOW:
case K_PIRACY:
follow = true;
break;
default:
continue;
}
break;
}
break;
}
if (!follow) {
attrib * a2 = a_find(u2->attribs, &at_follow);
if (a2!=NULL) {
unit * u3 = a2->data.v;
follow = (u3 && u2->region == u2->region);
}
}
if (follow) {
fset(u, UFL_FOLLOWING);
fset(u2, UFL_FOLLOWED);
set_order(&u->thisorder, NULL);
}
}
}

View File

@ -61,7 +61,7 @@ extern void travelthru(const struct unit * u, struct region * r);
extern struct ship * move_ship(struct ship * sh, struct region * from, struct region * to, struct region_list * route);
extern int walkingcapacity(const struct unit * u);
extern void follow_unit(void);
extern void follow_unit(struct unit * u);
struct building_type;
boolean buildingtype_exists(const struct region * r, const struct building_type * bt);

View File

@ -260,38 +260,27 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
}
void
init_pool(void)
int
reserve_cmd(unit * u, struct order *ord)
{
unit *u;
region *r;
if (u->number > 0 && (urace(u)->ec_flags & GETITEM)) {
int use, count = geti();
const resource_type * rtype;
/* Falls jemand diese Listen erweitert hat, muß er auch den R_* enum
* erweitert haben. */
for (r = regions; r; r = r->next) {
for (u = r->units; u; u = u->next) {
order * ord;
for (ord=u->orders; ord; ord=ord->next) {
if (u->number > 0 && (urace(u)->ec_flags & GETITEM) && get_keyword(ord) == K_RESERVE) {
int use, count = geti();
const resource_type * rtype;
init_tokens(ord);
skip_token();
count = geti();
init_tokens(ord);
skip_token();
count = geti();
rtype = findresourcetype(getstrtoken(), u->faction->locale);
if (rtype == NULL) return 0;
rtype = findresourcetype(getstrtoken(), u->faction->locale);
if (rtype == NULL) continue;
new_set_resvalue(u, rtype, 0); /* make sure the pool is empty */
use = use_pooled(u, rtype, GET_DEFAULT, count);
if (use) {
new_set_resvalue(u, rtype, use);
change_resource(u, rtype, use);
}
}
}
new_set_resvalue(u, rtype, 0); /* make sure the pool is empty */
use = use_pooled(u, rtype, GET_DEFAULT, count);
if (use) {
new_set_resvalue(u, rtype, use);
change_resource(u, rtype, use);
}
}
return 0;
}

View File

@ -46,7 +46,7 @@ int change_resource(struct unit * u, const struct resource_type * res, int chang
int get_reservation(const struct unit * u, const struct resource_type * res);
int change_reservation(struct unit * u, const struct resource_type * res, int value);
void init_pool(void);
int reserve_cmd(struct unit *u, struct order *ord);
/** init_pool
* initialisiert den regionalen Pool.

View File

@ -199,7 +199,7 @@ destroy_ship(ship * sh)
}
sunhash(sh);
choplist(&r->ships, sh);
handle_event(&sh->attribs, "destroy", sh);
handle_event(sh->attribs, "destroy", sh);
}
const char *

View File

@ -178,6 +178,17 @@ distribute_items(unit * u)
}
}
void
remove_unit(unit * u)
{
region * r = u->region;
assert(u->number==0);
uunhash(u);
if (r) choplist(&r->units, u);
u->next = udestroy;
udestroy = u;
}
void
destroy_unit(unit * u)
{
@ -261,17 +272,13 @@ destroy_unit(unit * u)
u->race = u->irace = new_race[RC_ZOMBIE];
} else {
if (u->number) set_number(u, 0);
handle_event(&u->attribs, "destroy", u);
handle_event(u->attribs, "destroy", u);
if (r && !fval(r->terrain, SEA_REGION)) {
rsetmoney(r, rmoney(r) + get_money(u));
}
dhash(u->no, u->faction);
u_setfaction(u, NULL);
if (r) leave(r, u);
uunhash(u);
if (r) choplist(&r->units, u);
u->next = udestroy;
udestroy = u;
}
}

View File

@ -189,6 +189,7 @@ extern int get_modifier(const struct unit * u, skill_t sk, int lvl, const struct
/* Einheiten werden nicht wirklich zerstört. */
extern void destroy_unit(struct unit * u);
extern void remove_unit(struct unit * u);
extern void distribute_items(struct unit * u);
/* see resolve.h */

View File

@ -88,36 +88,29 @@ xe_giveballon(unit *u, struct order *ord)
fset(u2, UFL_OWNER);
}
void
xecmd(void)
int
xecmd(unit * u, order * ord)
{
faction *f;
faction *f = u->faction;
for(f=factions; f; f=f->next) {
if(a_find(f->attribs, &at_xontormiaexpress)) {
unit *u;
for(u=f->units; u; u=u->nextF) {
order * ord;
for (ord=u->orders; ord; ord=ord->next) {
if (get_keyword(ord) == K_XE) {
init_tokens(ord);
skip_token();
switch(findparam(getstrtoken(),f->locale)) {
case P_XEPOTION:
xe_givepotion(u, ord);
break;
case P_XEBALLOON:
xe_giveballon(u, ord);
break;
case P_XELAEN:
xe_givelaen(u, ord);
break;
}
}
}
if (a_find(f->attribs, &at_xontormiaexpress)) {
if (get_keyword(ord) == K_XE) {
init_tokens(ord);
skip_token();
switch(findparam(getstrtoken(),f->locale)) {
case P_XEPOTION:
xe_givepotion(u, ord);
break;
case P_XEBALLOON:
xe_giveballon(u, ord);
break;
case P_XELAEN:
xe_givelaen(u, ord);
break;
}
}
}
return 0;
}
#endif

View File

@ -18,7 +18,7 @@ extern "C" {
#ifdef XECMD_MODULE
extern attrib_type at_xontormiaexpress;
void xecmd(void);
int xecmd(struct unit * u, struct order * ord);
#endif
#ifdef __cplusplus

View File

@ -200,20 +200,20 @@ add_trigger(struct attrib ** ap, const char * eventname, struct trigger * t)
}
void
handle_event(attrib ** attribs, const char * eventname, void * data)
handle_event(attrib * attribs, const char * eventname, void * data)
{
while (*attribs) {
if ((*attribs)->type==&at_eventhandler) break;
attribs = &(*attribs)->next;
while (attribs) {
if (attribs->type==&at_eventhandler) break;
attribs = attribs->nexttype;
}
while (*attribs && (*attribs)->type==&at_eventhandler) {
handler_info * tl = (handler_info*)(*attribs)->data.v;
while (attribs && attribs->type==&at_eventhandler) {
handler_info * tl = (handler_info*)attribs->data.v;
if (!strcmp(tl->event, eventname)) {
handler_info * tl = (handler_info*)(*attribs)->data.v;
handler_info * tl = (handler_info*)attribs->data.v;
handle_triggers(&tl->triggers, data);
break;
}
attribs = &(*attribs)->next;
attribs = attribs->next;
}
}

View File

@ -58,7 +58,7 @@ extern void add_trigger(struct attrib ** ap, const char * eventname, struct trig
extern void remove_triggers(struct attrib ** ap, const char * eventname, const trigger_type * tt);
extern struct trigger ** get_triggers(struct attrib * ap, const char * eventname);
/* calls handle() for each of these. e.g. used in timeout */
extern void handle_event(struct attrib ** attribs, const char * eventname, void * data);
extern void handle_event(struct attrib * attribs, const char * eventname, void * data);
/* functions for making complex triggers: */
extern void free_triggers(trigger * triggers); /* release all these triggers */

View File

@ -232,7 +232,9 @@ region_remove(region& r)
while (*rp) {
if (*rp==&r) {
while (r.units) {
destroy_unit(r.units);
unit * u = r.units;
destroy_unit(u);
remove_unit(u);
}
*rp = r.next;
#ifdef FAST_CONNECT

View File

@ -1465,6 +1465,7 @@ showunits(region * r)
if (yes_no(0, lbuf, 'n')) {
modified = 1;
destroy_unit(clipunit);
if (clipunit->number==0) remove_unit(clipunit);
clipunit = 0;
clipregion = 0;
for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next)