forked from github/server
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:
parent
150a1e38b0
commit
ed70863843
|
@ -995,10 +995,8 @@ gebaeude_stuerzt_ein(region * r, building * b)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
maintain_buildings(boolean crash)
|
maintain_buildings(region * r, boolean crash)
|
||||||
{
|
{
|
||||||
region * r;
|
|
||||||
for (r = regions; r; r = r->next) {
|
|
||||||
building **bp = &r->buildings;
|
building **bp = &r->buildings;
|
||||||
while (*bp) {
|
while (*bp) {
|
||||||
building * b = *bp;
|
building * b = *bp;
|
||||||
|
@ -1026,22 +1024,18 @@ maintain_buildings(boolean crash)
|
||||||
bp=&b->next;
|
bp=&b->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
economics(void)
|
economics(region *r)
|
||||||
{
|
{
|
||||||
region *r;
|
|
||||||
unit *u;
|
unit *u;
|
||||||
|
request *recruitorders = NULL;
|
||||||
|
|
||||||
/* Geben vor Selbstmord (doquit)! Hier alle unmittelbaren Befehle.
|
/* Geben vor Selbstmord (doquit)! Hier alle unmittelbaren Befehle.
|
||||||
* Rekrutieren vor allen Einnahmequellen. Bewachen JA vor Steuern
|
* Rekrutieren vor allen Einnahmequellen. Bewachen JA vor Steuern
|
||||||
* eintreiben. */
|
* eintreiben. */
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) if (r->units) {
|
|
||||||
request *recruitorders = NULL;
|
|
||||||
|
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
order * ord;
|
order * ord;
|
||||||
boolean destroyed = false;
|
boolean destroyed = false;
|
||||||
|
@ -1080,8 +1074,7 @@ economics(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recruitorders) expandrecruit(r, recruitorders);
|
if (recruitorders) expandrecruit(r, recruitorders);
|
||||||
|
remove_empty_units_in_region(r);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
|
@ -47,11 +47,11 @@ extern int income(const struct unit * u);
|
||||||
/* Wieviel Fremde eine Partei pro Woche aufnehmen kann */
|
/* Wieviel Fremde eine Partei pro Woche aufnehmen kann */
|
||||||
#define MAXNEWBIES 5
|
#define MAXNEWBIES 5
|
||||||
|
|
||||||
void economics(void);
|
void economics(struct region *r);
|
||||||
void produce(void);
|
void produce(void);
|
||||||
|
|
||||||
enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC };
|
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);
|
extern void add_spende(struct faction * f1, struct faction * f2, int betrag, struct region * r);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -1196,12 +1196,7 @@ parse_restart(void)
|
||||||
/* Clear away debris of destroyed factions */
|
/* Clear away debris of destroyed factions */
|
||||||
|
|
||||||
puts(" - beseitige leere Einheiten und leere Parteien...");
|
puts(" - beseitige leere Einheiten und leere Parteien...");
|
||||||
|
|
||||||
remove_empty_units();
|
remove_empty_units();
|
||||||
|
|
||||||
/* Auskommentiert: Wenn factions gelöscht werden, zeigen
|
|
||||||
* Spendenpointer ins Leere. */
|
|
||||||
/* remove_empty_factions(); */
|
|
||||||
}
|
}
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -1798,71 +1793,6 @@ deliverMail(faction * f, region * r, unit * u, const char *s, unit * receiver)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
prepare_mail_cmd(unit * u, struct order * ord)
|
|
||||||
{
|
|
||||||
const char *s;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
init_tokens(ord);
|
|
||||||
skip_token(); /* skip the keyword */
|
|
||||||
s = getstrtoken();
|
|
||||||
|
|
||||||
/* Falls kein Parameter, ist das eine Einheitsnummer;
|
|
||||||
* das Füllwort "AN" muß wegfallen, da gültige Nummer! */
|
|
||||||
|
|
||||||
if (strcasecmp(s, "to") == 0) s = getstrtoken();
|
|
||||||
else if (strcasecmp(s, "an") == 0) s = getstrtoken();
|
|
||||||
|
|
||||||
switch (findparam(s, u->faction->locale)) {
|
|
||||||
case P_REGION:
|
|
||||||
break;
|
|
||||||
case P_FACTION:
|
|
||||||
break;
|
|
||||||
case P_UNIT:
|
|
||||||
{
|
|
||||||
region *r = u->region;
|
|
||||||
unit *u2;
|
|
||||||
boolean see = false;
|
|
||||||
|
|
||||||
n = getid();
|
|
||||||
|
|
||||||
for (u2=r->units; u2; u2=u2->next) {
|
|
||||||
if (u2->no == n && cansee(u->faction, r, u2, 0)) {
|
|
||||||
see = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (see == false) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
s = getstrtoken();
|
|
||||||
if (!s[0]) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
u2 = findunitr(r,n);
|
|
||||||
if(u2 && cansee(u->faction, r, u2, 0)) {
|
|
||||||
event_arg args[3];
|
|
||||||
args[0].data.v = (void*)s;
|
|
||||||
args[0].type = "string";
|
|
||||||
args[1].data.v = (void*)u;
|
|
||||||
args[1].type = "unit";
|
|
||||||
args[2].type = NULL;
|
|
||||||
handle_event(&u2->attribs, "message", args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case P_BUILDING:
|
|
||||||
case P_GEBAEUDE:
|
|
||||||
break;
|
|
||||||
case P_SHIP:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mailunit(region * r, unit * u, int n, struct order * ord, const char * s)
|
mailunit(region * r, unit * u, int n, struct order * ord, const char * s)
|
||||||
{
|
{
|
||||||
|
@ -1971,9 +1901,21 @@ mail_cmd(unit * u, struct order * ord)
|
||||||
if (!s[0]) {
|
if (!s[0]) {
|
||||||
cmistake(u, ord, 30, MSG_MESSAGE);
|
cmistake(u, ord, 30, MSG_MESSAGE);
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
attrib * a = a_find(u2->attribs, &at_eventhandler);
|
||||||
|
if (a!=NULL) {
|
||||||
|
event_arg args[3];
|
||||||
|
args[0].data.v = (void*)s;
|
||||||
|
args[0].type = "string";
|
||||||
|
args[1].data.v = (void*)u;
|
||||||
|
args[1].type = "unit";
|
||||||
|
args[2].type = NULL;
|
||||||
|
handle_event(a, "message", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
mailunit(r, u, n, ord, s);
|
mailunit(r, u, n, ord, s);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case P_BUILDING:
|
case P_BUILDING:
|
||||||
|
@ -2167,43 +2109,6 @@ send_cmd(unit * u, struct order * ord)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
set_passw(void)
|
|
||||||
{
|
|
||||||
region *r;
|
|
||||||
puts(" - setze Passwörter, Adressen und Format, Abstimmungen");
|
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
|
||||||
unit *u;
|
|
||||||
for (u = r->units; u; u = u->next) {
|
|
||||||
struct order * ord;
|
|
||||||
for (ord = u->orders; ord; ord = ord->next) {
|
|
||||||
switch (get_keyword(ord)) {
|
|
||||||
case NOKEYWORD:
|
|
||||||
cmistake(u, ord, 22, MSG_EVENT);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case K_BANNER:
|
|
||||||
if (banner_cmd(u, ord)!=0) ord = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case K_EMAIL:
|
|
||||||
if (email_cmd(u, ord)!=0) ord = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case K_PASSWORD:
|
|
||||||
if (password_cmd(u, ord)!=0) ord = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case K_SEND:
|
|
||||||
if (send_cmd(u, ord)!=0) ord = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
display_item(faction *f, unit *u, const item_type * itype)
|
display_item(faction *f, unit *u, const item_type * itype)
|
||||||
{
|
{
|
||||||
|
@ -2667,7 +2572,6 @@ instant_orders(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parse(K_GROUP, group_cmd, false);
|
|
||||||
for (r = regions; r; r = r->next) {
|
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) {
|
||||||
|
@ -2774,12 +2678,8 @@ guard_on_cmd(unit * u, struct order * ord)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sinkships(void)
|
sinkships(region * r)
|
||||||
{
|
{
|
||||||
region *r;
|
|
||||||
|
|
||||||
/* Unbemannte Schiffe können sinken */
|
|
||||||
for (r = regions; r; r = r->next) {
|
|
||||||
ship *sh;
|
ship *sh;
|
||||||
|
|
||||||
list_foreach(ship, r->ships, sh) {
|
list_foreach(ship, r->ships, sh) {
|
||||||
|
@ -2795,7 +2695,6 @@ sinkships(void)
|
||||||
}
|
}
|
||||||
list_next(sh);
|
list_next(sh);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* The following functions do not really belong here: */
|
/* The following functions do not really belong here: */
|
||||||
#include "eressea.h"
|
#include "eressea.h"
|
||||||
|
@ -3064,19 +2963,13 @@ declare_war(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static int
|
||||||
renumber(void)
|
renumber_cmd(unit * u, order * ord)
|
||||||
{
|
{
|
||||||
region *r;
|
|
||||||
const char * s;
|
const char * s;
|
||||||
unit * u;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (r=regions;r;r=r->next) {
|
|
||||||
for (u=r->units;u;u=u->next) {
|
|
||||||
faction * f = u->faction;
|
faction * f = u->faction;
|
||||||
struct order * ord;
|
|
||||||
for (ord = u->orders; ord; ord = ord->next) if (get_keyword(ord)==K_NUMBER) {
|
|
||||||
init_tokens(ord);
|
init_tokens(ord);
|
||||||
skip_token();
|
skip_token();
|
||||||
s = getstrtoken();
|
s = getstrtoken();
|
||||||
|
@ -3100,17 +2993,17 @@ renumber(void)
|
||||||
i = atoi36(s);
|
i = atoi36(s);
|
||||||
if (i<=0 || i>MAX_UNIT_NR) {
|
if (i<=0 || i>MAX_UNIT_NR) {
|
||||||
cmistake(u, ord, 114, MSG_EVENT);
|
cmistake(u, ord, 114, MSG_EVENT);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forbiddenid(i)) {
|
if (forbiddenid(i)) {
|
||||||
cmistake(u, ord, 116, MSG_EVENT);
|
cmistake(u, ord, 116, MSG_EVENT);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(findunitg(i, r)) {
|
if (findunitg(i, u->region)) {
|
||||||
cmistake(u, ord, 115, MSG_EVENT);
|
cmistake(u, ord, 115, MSG_EVENT);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uunhash(u);
|
uunhash(u);
|
||||||
|
@ -3125,11 +3018,11 @@ renumber(void)
|
||||||
case P_SHIP:
|
case P_SHIP:
|
||||||
if (!u->ship) {
|
if (!u->ship) {
|
||||||
cmistake(u,ord,144,MSG_EVENT);
|
cmistake(u,ord,144,MSG_EVENT);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
if (!fval(u, UFL_OWNER)) {
|
if (!fval(u, UFL_OWNER)) {
|
||||||
cmistake(u,ord,146,MSG_EVENT);
|
cmistake(u,ord,146,MSG_EVENT);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
s = getstrtoken();
|
s = getstrtoken();
|
||||||
if(s == NULL || *s == 0) {
|
if(s == NULL || *s == 0) {
|
||||||
|
@ -3138,11 +3031,11 @@ renumber(void)
|
||||||
i = atoi36(s);
|
i = atoi36(s);
|
||||||
if (i<=0 || i>MAX_CONTAINER_NR) {
|
if (i<=0 || i>MAX_CONTAINER_NR) {
|
||||||
cmistake(u,ord,114,MSG_EVENT);
|
cmistake(u,ord,114,MSG_EVENT);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
if (findship(i) || findbuilding(i)) {
|
if (findship(i) || findbuilding(i)) {
|
||||||
cmistake(u,ord,115,MSG_EVENT);
|
cmistake(u,ord,115,MSG_EVENT);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sunhash(u->ship);
|
sunhash(u->ship);
|
||||||
|
@ -3154,11 +3047,11 @@ renumber(void)
|
||||||
case P_GEBAEUDE:
|
case P_GEBAEUDE:
|
||||||
if (!u->building) {
|
if (!u->building) {
|
||||||
cmistake(u,ord,145,MSG_EVENT);
|
cmistake(u,ord,145,MSG_EVENT);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
if(!fval(u, UFL_OWNER)) {
|
if(!fval(u, UFL_OWNER)) {
|
||||||
cmistake(u,ord,148,MSG_EVENT);
|
cmistake(u,ord,148,MSG_EVENT);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
s = getstrtoken();
|
s = getstrtoken();
|
||||||
if(*s == 0) {
|
if(*s == 0) {
|
||||||
|
@ -3167,11 +3060,11 @@ renumber(void)
|
||||||
i = atoi36(s);
|
i = atoi36(s);
|
||||||
if (i<=0 || i>MAX_CONTAINER_NR) {
|
if (i<=0 || i>MAX_CONTAINER_NR) {
|
||||||
cmistake(u,ord,114,MSG_EVENT);
|
cmistake(u,ord,114,MSG_EVENT);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
if(findship(i) || findbuilding(i)) {
|
if(findship(i) || findbuilding(i)) {
|
||||||
cmistake(u,ord,115,MSG_EVENT);
|
cmistake(u,ord,115,MSG_EVENT);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bunhash(u->building);
|
bunhash(u->building);
|
||||||
|
@ -3182,10 +3075,7 @@ renumber(void)
|
||||||
default:
|
default:
|
||||||
cmistake(u, ord, 239, MSG_EVENT);
|
cmistake(u, ord, 239, MSG_EVENT);
|
||||||
}
|
}
|
||||||
}
|
return 0;
|
||||||
}
|
|
||||||
}
|
|
||||||
renumber_factions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static building *
|
static building *
|
||||||
|
@ -3260,7 +3150,7 @@ age_building(building * b)
|
||||||
}
|
}
|
||||||
|
|
||||||
a_age(&b->attribs);
|
a_age(&b->attribs);
|
||||||
handle_event(&b->attribs, "timer", b);
|
handle_event(b->attribs, "timer", b);
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
@ -3302,7 +3192,7 @@ ageing(void)
|
||||||
/* Factions */
|
/* Factions */
|
||||||
for (f=factions;f;f=f->next) {
|
for (f=factions;f;f=f->next) {
|
||||||
a_age(&f->attribs);
|
a_age(&f->attribs);
|
||||||
handle_event(&f->attribs, "timer", f);
|
handle_event(f->attribs, "timer", f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Regionen */
|
/* Regionen */
|
||||||
|
@ -3312,13 +3202,13 @@ ageing(void)
|
||||||
ship ** sp;
|
ship ** sp;
|
||||||
|
|
||||||
a_age(&r->attribs);
|
a_age(&r->attribs);
|
||||||
handle_event(&r->attribs, "timer", r);
|
handle_event(r->attribs, "timer", r);
|
||||||
|
|
||||||
/* Einheiten */
|
/* Einheiten */
|
||||||
for (up=&r->units;*up;) {
|
for (up=&r->units;*up;) {
|
||||||
unit * u = *up;
|
unit * u = *up;
|
||||||
a_age(&u->attribs);
|
a_age(&u->attribs);
|
||||||
if (u==*up) handle_event(&u->attribs, "timer", u);
|
if (u==*up) handle_event(u->attribs, "timer", u);
|
||||||
if (u==*up) up = &(*up)->next;
|
if (u==*up) up = &(*up)->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3326,7 +3216,7 @@ ageing(void)
|
||||||
for (sp=&r->ships;*sp;) {
|
for (sp=&r->ships;*sp;) {
|
||||||
ship * s = *sp;
|
ship * s = *sp;
|
||||||
a_age(&s->attribs);
|
a_age(&s->attribs);
|
||||||
if (s==*sp) handle_event(&s->attribs, "timer", s);
|
if (s==*sp) handle_event(s->attribs, "timer", s);
|
||||||
if (s==*sp) sp = &(*sp)->next;
|
if (s==*sp) sp = &(*sp)->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3467,14 +3357,8 @@ new_units (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setdefaults (void)
|
setdefaults(unit *u)
|
||||||
{
|
{
|
||||||
region *r;
|
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
|
||||||
unit *u;
|
|
||||||
|
|
||||||
for (u = r->units; u; u = u->next) {
|
|
||||||
order *ord;
|
order *ord;
|
||||||
boolean trade = false;
|
boolean trade = false;
|
||||||
boolean hunger = LongHunger(u);
|
boolean hunger = LongHunger(u);
|
||||||
|
@ -3540,7 +3424,7 @@ setdefaults (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hunger) continue;
|
if (hunger) return;
|
||||||
|
|
||||||
/* Wenn die Einheit handelt, muß der Default-Befehl gelöscht
|
/* Wenn die Einheit handelt, muß der Default-Befehl gelöscht
|
||||||
* werden. */
|
* werden. */
|
||||||
|
@ -3572,8 +3456,6 @@ setdefaults (void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
use_item(unit * u, const item_type * itype, int amount, struct order * ord)
|
use_item(unit * u, const item_type * itype, int amount, struct order * ord)
|
||||||
|
@ -3861,166 +3743,354 @@ claim_cmd(unit * u, struct order * ord)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct processor {
|
||||||
|
struct processor * next;
|
||||||
|
int priority;
|
||||||
|
enum { PR_GLOBAL, PR_REGION, PR_UNIT, PR_ORDER } type;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
keyword_t kword;
|
||||||
|
boolean thisorder;
|
||||||
|
int (*process)(struct unit *, struct order *);
|
||||||
|
} per_order;
|
||||||
|
struct {
|
||||||
|
void (*process)(struct unit *);
|
||||||
|
} per_unit;
|
||||||
|
struct {
|
||||||
|
void (*process)(struct region *);
|
||||||
|
} per_region;
|
||||||
|
struct {
|
||||||
|
void (*process)(void);
|
||||||
|
} global;
|
||||||
|
} data;
|
||||||
|
const char * name;
|
||||||
|
} processor;
|
||||||
|
|
||||||
|
static processor * processors;
|
||||||
|
|
||||||
|
void
|
||||||
|
add_proc_order(int priority, keyword_t kword, int (*parser)(struct unit *, struct order *), boolean thisorder, const char * name)
|
||||||
|
{
|
||||||
|
processor **pproc = &processors;
|
||||||
|
processor *proc;
|
||||||
|
|
||||||
|
while (*pproc) {
|
||||||
|
proc = *pproc;
|
||||||
|
if (proc->priority>priority) break;
|
||||||
|
else if (proc->priority==priority && proc->type>=PR_ORDER) break;
|
||||||
|
pproc = &proc->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
proc = malloc(sizeof(processor));
|
||||||
|
proc->priority = priority;
|
||||||
|
proc->type = PR_ORDER;
|
||||||
|
proc->data.per_order.process = parser;
|
||||||
|
proc->data.per_order.kword = kword;
|
||||||
|
proc->data.per_order.thisorder = thisorder;
|
||||||
|
proc->name = name;
|
||||||
|
proc->next = *pproc;
|
||||||
|
*pproc = proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
add_proc_global(int priority, void (*process)(void), const char * name)
|
||||||
|
{
|
||||||
|
processor **pproc = &processors;
|
||||||
|
processor *proc;
|
||||||
|
|
||||||
|
while (*pproc) {
|
||||||
|
proc = *pproc;
|
||||||
|
if (proc->priority>priority) break;
|
||||||
|
else if (proc->priority==priority && proc->type>=PR_GLOBAL) break;
|
||||||
|
pproc = &proc->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
proc = malloc(sizeof(processor));
|
||||||
|
proc->priority = priority;
|
||||||
|
proc->type = PR_GLOBAL;
|
||||||
|
proc->data.global.process = process;
|
||||||
|
proc->name = name;
|
||||||
|
proc->next = *pproc;
|
||||||
|
*pproc = proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
add_proc_region(int priority, void (*process)(region *), const char * name)
|
||||||
|
{
|
||||||
|
processor **pproc = &processors;
|
||||||
|
processor *proc;
|
||||||
|
|
||||||
|
while (*pproc) {
|
||||||
|
proc = *pproc;
|
||||||
|
if (proc->priority>priority) break;
|
||||||
|
else if (proc->priority==priority && proc->type>=PR_REGION) break;
|
||||||
|
pproc = &proc->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
proc = malloc(sizeof(processor));
|
||||||
|
proc->priority = priority;
|
||||||
|
proc->type = PR_REGION;
|
||||||
|
proc->data.per_region.process = process;
|
||||||
|
proc->name = name;
|
||||||
|
proc->next = *pproc;
|
||||||
|
*pproc = proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
add_proc_unit(int priority, void (*process)(unit *), const char * name)
|
||||||
|
{
|
||||||
|
processor **pproc = &processors;
|
||||||
|
processor *proc;
|
||||||
|
|
||||||
|
while (*pproc) {
|
||||||
|
proc = *pproc;
|
||||||
|
if (proc->priority>priority) break;
|
||||||
|
else if (proc->priority==priority && proc->type>=PR_UNIT) break;
|
||||||
|
pproc = &proc->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
proc = malloc(sizeof(processor));
|
||||||
|
proc->priority = priority;
|
||||||
|
proc->type = PR_UNIT;
|
||||||
|
proc->data.per_unit.process = process;
|
||||||
|
proc->name = name;
|
||||||
|
proc->next = *pproc;
|
||||||
|
*pproc = proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
process(void)
|
||||||
|
{
|
||||||
|
processor *proc = processors;
|
||||||
|
while (proc) {
|
||||||
|
int prio = proc->priority;
|
||||||
|
region *r;
|
||||||
|
processor *pglobal = proc;
|
||||||
|
|
||||||
|
printf("- Step %u\n", prio);
|
||||||
|
while (proc && proc->priority==prio) {
|
||||||
|
if (proc->name) printf(" - %s\n", proc->name);
|
||||||
|
proc = proc->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (pglobal && pglobal->priority==prio && pglobal->type==PR_GLOBAL) {
|
||||||
|
pglobal->data.global.process();
|
||||||
|
pglobal = pglobal->next;
|
||||||
|
}
|
||||||
|
if (pglobal==NULL || pglobal->priority!=prio) continue;
|
||||||
|
|
||||||
|
for (r = regions; r; r = r->next) {
|
||||||
|
unit **up;
|
||||||
|
processor *pregion = pglobal;
|
||||||
|
|
||||||
|
while (pregion && pregion->priority==prio && pregion->type==PR_REGION) {
|
||||||
|
pregion->data.per_region.process(r);
|
||||||
|
pregion = pregion->next;
|
||||||
|
}
|
||||||
|
if (pregion==NULL || pregion->priority!=prio) continue;
|
||||||
|
|
||||||
|
for (up=&r->units;*up;) {
|
||||||
|
unit * u = *up;
|
||||||
|
processor *porder, *punit = pregion;
|
||||||
|
|
||||||
|
while (punit && punit->priority==prio && punit->type==PR_UNIT) {
|
||||||
|
punit->data.per_unit.process(u);
|
||||||
|
punit = punit->next;
|
||||||
|
}
|
||||||
|
if (punit==NULL || punit->priority!=prio) continue;
|
||||||
|
|
||||||
|
porder = punit;
|
||||||
|
while (porder && porder->priority==prio && porder->type==PR_ORDER) {
|
||||||
|
order ** ordp = &u->orders;
|
||||||
|
if (porder->data.per_order.thisorder) ordp = &u->thisorder;
|
||||||
|
while (*ordp) {
|
||||||
|
order * ord = *ordp;
|
||||||
|
if (get_keyword(ord) == porder->data.per_order.kword) {
|
||||||
|
porder->data.per_order.process(u, ord);
|
||||||
|
}
|
||||||
|
if (*ordp==ord) ordp=&ord->next;
|
||||||
|
}
|
||||||
|
porder = porder->next;
|
||||||
|
}
|
||||||
|
assert(*up==u);
|
||||||
|
up=&u->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void enter_1(region * r) { do_misc(r, false); }
|
||||||
|
static void enter_2(region * r) { do_misc(r, true); }
|
||||||
|
static void maintain_buildings_1(region * r) { maintain_buildings(r, false); }
|
||||||
|
static void maintain_buildings_2(region * r) { maintain_buildings(r,true); }
|
||||||
|
static void reset_moved(unit * u) { freset(u, UFL_MOVED); }
|
||||||
|
|
||||||
|
static void reset_rng(void) {
|
||||||
|
if (turn == 0) rng_init((int)time(0));
|
||||||
|
else rng_init(turn);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
processorders (void)
|
processorders (void)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r;
|
||||||
|
int p;
|
||||||
|
|
||||||
set_passw(); /* und pruefe auf illegale Befehle */
|
p = 10;
|
||||||
|
add_proc_global(p, &new_units, "Neue Einheiten erschaffen");
|
||||||
|
|
||||||
puts(" - neue Einheiten erschaffen...");
|
p+=10;
|
||||||
new_units();
|
add_proc_unit(p, &setdefaults, "Default-Befehle");
|
||||||
|
add_proc_order(p, K_BANNER, &banner_cmd, false, NULL);
|
||||||
|
add_proc_order(p, K_EMAIL, &email_cmd, false, NULL);
|
||||||
|
add_proc_order(p, K_PASSWORD, &password_cmd, false, NULL);
|
||||||
|
add_proc_order(p, K_SEND, &send_cmd, false, NULL);
|
||||||
|
add_proc_order(p, K_GROUP, &group_cmd, false, NULL);
|
||||||
|
|
||||||
puts(" - Defaults und Instant-Befehle...");
|
p+=10;
|
||||||
setdefaults();
|
add_proc_unit(p, &reset_moved, "Instant-Befehle");
|
||||||
instant_orders();
|
add_proc_order(p, K_QUIT, &quit_cmd, false, NULL);
|
||||||
|
add_proc_order(p, K_URSPRUNG, &origin_cmd, false, NULL);
|
||||||
if (alliances!=NULL) alliancekick();
|
add_proc_order(p, K_ALLY, &ally_cmd, false, NULL);
|
||||||
|
add_proc_order(p, K_PREFIX, &prefix_cmd, false, NULL);
|
||||||
parse(K_MAIL, prepare_mail_cmd, false);
|
add_proc_order(p, K_SYNONYM, &synonym_cmd, false, NULL);
|
||||||
parse(K_MAIL, mail_cmd, false);
|
add_proc_order(p, K_SETSTEALTH, &setstealth_cmd, false, NULL);
|
||||||
puts(" - Parteien altern");
|
add_proc_order(p, K_STATUS, &status_cmd, false, NULL);
|
||||||
age_factions();
|
add_proc_order(p, K_COMBAT, &combatspell_cmd, false, NULL);
|
||||||
|
add_proc_order(p, K_DISPLAY, &display_cmd, false, NULL);
|
||||||
puts(" - Benutzen");
|
add_proc_order(p, K_NAME, &name_cmd, false, NULL);
|
||||||
parse(K_CLAIM, claim_cmd, false);
|
add_proc_order(p, K_GUARD, &guard_off_cmd, false, NULL);
|
||||||
parse(K_USE, use_cmd, false);
|
add_proc_order(p, K_RESHOW, &reshow_cmd, false, NULL);
|
||||||
|
#ifdef KARMA_MODULE
|
||||||
puts(" - Kontaktieren, Betreten von Schiffen und Gebäuden (1.Versuch)");
|
add_proc_order(p, K_WEREWOLF, &setwere_cmd, false, NULL);
|
||||||
do_misc(false);
|
#endif /* KARMA_MODULE */
|
||||||
|
|
||||||
if (alliances!=NULL) {
|
if (alliances!=NULL) {
|
||||||
puts(" - Testen der Allianzbedingungen");
|
p+=10;
|
||||||
alliancevictory();
|
add_proc_global(p, &alliancekick, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
p+=10;
|
||||||
|
add_proc_global(p, &age_factions, "Parteienalter++");
|
||||||
|
add_proc_order(p, K_MAIL, &mail_cmd, false, "Botschaften");
|
||||||
|
add_proc_order(p, K_CLAIM, &claim_cmd, false, NULL);
|
||||||
|
|
||||||
|
p+=10; /* all claims must be done before we can USE */
|
||||||
|
add_proc_region(p, &enter_1, "Kontaktieren & Betreten (1. Versuch)");
|
||||||
|
add_proc_order(p, K_USE, &use_cmd, false, "Benutzen");
|
||||||
|
|
||||||
|
if (alliances!=NULL) {
|
||||||
|
p+=10; /* in case USE changes it */
|
||||||
|
add_proc_global(p, &alliancevictory, "Testen der Allianzbedingungen");
|
||||||
}
|
}
|
||||||
|
|
||||||
puts(" - GM Kommandos");
|
|
||||||
#ifdef INFOCMD_MODULE
|
#ifdef INFOCMD_MODULE
|
||||||
infocommands();
|
add_proc_global(p, &infocommands, NULL);
|
||||||
#endif
|
#endif
|
||||||
gmcommands();
|
add_proc_global(p, &gmcommands, "GM Kommandos");
|
||||||
|
|
||||||
puts(" - Verlassen");
|
p += 10; /* in case it has any effects on allincevictories */
|
||||||
parse(K_LEAVE, leave_cmd, false);
|
add_proc_order(p, K_LEAVE, &leave_cmd, false, "Verlassen");
|
||||||
|
|
||||||
puts(" - Kontakte löschen");
|
|
||||||
remove_contacts();
|
|
||||||
|
|
||||||
|
if (!nobattle) {
|
||||||
#ifdef KARMA_MODULE
|
#ifdef KARMA_MODULE
|
||||||
puts(" - Jihad-Angriffe");
|
p+=10;
|
||||||
jihad_attacks();
|
add_proc_global(p, &jihad_attacks, "Jihad-Angriffe");
|
||||||
#endif
|
#endif
|
||||||
|
add_proc_region(p, &do_battle, "Attackieren");
|
||||||
puts(" - Attackieren");
|
|
||||||
if (nobattle == false) do_battle();
|
|
||||||
if (turn == 0) rng_init((int)time(0));
|
|
||||||
else rng_init(turn);
|
|
||||||
|
|
||||||
puts(" - Belagern");
|
|
||||||
do_siege();
|
|
||||||
|
|
||||||
puts(" - Initialisieren des Pools, Reservieren");
|
|
||||||
init_pool();
|
|
||||||
|
|
||||||
puts(" - Kontaktieren, Betreten von Schiffen und Gebäuden (2.Versuch)");
|
|
||||||
do_misc(false);
|
|
||||||
|
|
||||||
puts(" - Folge auf Einheiten ersetzen");
|
|
||||||
follow_unit();
|
|
||||||
|
|
||||||
if (turn == 0) rng_init((int)time(0));
|
|
||||||
else rng_init(turn);
|
|
||||||
|
|
||||||
puts(" - Zerstören, Geben, Rekrutieren, Vergessen");
|
|
||||||
economics();
|
|
||||||
remove_empty_units();
|
|
||||||
|
|
||||||
puts(" - Gebäudeunterhalt (1. Versuch)");
|
|
||||||
maintain_buildings(false);
|
|
||||||
|
|
||||||
puts(" - Sterben, Neustart");
|
|
||||||
quit();
|
|
||||||
parse_restart();
|
|
||||||
|
|
||||||
puts(" - Zaubern");
|
|
||||||
magic();
|
|
||||||
remove_empty_units();
|
|
||||||
|
|
||||||
if (!global.disabled[K_TEACH]) {
|
|
||||||
puts(" - Lehren");
|
|
||||||
teaching();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
puts(" - Lernen");
|
p+=10; /* after combat, reset rng */
|
||||||
learn();
|
add_proc_global(p, &reset_rng, NULL);
|
||||||
|
add_proc_region(p, &do_siege, "Belagern");
|
||||||
|
|
||||||
puts(" - Produzieren, Geldverdienen, Handeln, Anwerben");
|
p+=10; /* can't allow reserve before siege (weapons) */
|
||||||
produce();
|
add_proc_region(p, &enter_2, "Kontaktieren & Betreten (2. Versuch)");
|
||||||
|
add_proc_order(p, K_RESERVE, &reserve_cmd, false, "Reservieren");
|
||||||
|
add_proc_unit(p, &follow_unit, "Folge auf Einheiten setzen");
|
||||||
|
|
||||||
puts(" - Kontaktieren, Betreten von Schiffen und Gebäuden (3.Versuch)");
|
p+=10; /* rest rng again before economics */
|
||||||
do_misc(true);
|
add_proc_global(p, &reset_rng, NULL);
|
||||||
|
add_proc_region(p, &economics, "Zerstören, Geben, Rekrutieren, Vergessen");
|
||||||
|
|
||||||
puts(" - Schiffe sinken");
|
p+=10;
|
||||||
sinkships();
|
add_proc_region(p, &maintain_buildings_1, "Gebäudeunterhalt (1. Versuch)");
|
||||||
|
|
||||||
puts(" - Bewegungen");
|
p+=10; /* QUIT fuer sich alleine */
|
||||||
movement();
|
add_proc_global(p, &quit, "Sterben");
|
||||||
|
add_proc_global(p, &parse_restart, "Neustart");
|
||||||
|
|
||||||
puts(" - Bewache (an)");
|
p+=10;
|
||||||
parse(K_GUARD, guard_on_cmd, false);
|
add_proc_global(p, &magic, "Zaubern");
|
||||||
|
|
||||||
puts(" - Zufallsbegegnungen");
|
p+=10;
|
||||||
encounters();
|
if (!global.disabled[K_TEACH]) {
|
||||||
|
add_proc_region(p, &teaching, "Lehren");
|
||||||
|
}
|
||||||
|
add_proc_order(p, K_STUDY, &learn_cmd, true, "Lernen");
|
||||||
|
|
||||||
if (turn == 0) rng_init((int)time(0));
|
p+=10;
|
||||||
else rng_init(turn);
|
add_proc_global(p, &produce, "Produktion, Handel, Rekruten");
|
||||||
|
|
||||||
puts(" - Monster fressen und vertreiben Bauern");
|
p+=10;
|
||||||
monsters_kill_peasants();
|
add_proc_region(p, &enter_2, "Kontaktieren & Betreten (3. Versuch)");
|
||||||
|
|
||||||
puts(" - random events");
|
p+=10;
|
||||||
randomevents();
|
add_proc_region(p, &sinkships, "Schiffe sinken");
|
||||||
|
|
||||||
puts(" - newspaper commands");
|
p+=10;
|
||||||
|
add_proc_global(p, &movement, "Bewegungen");
|
||||||
|
|
||||||
|
p+=10;
|
||||||
|
add_proc_order(p, K_GUARD, &guard_on_cmd, false, "Bewache (an)");
|
||||||
#ifdef XECMD_MODULE
|
#ifdef XECMD_MODULE
|
||||||
xecmd();
|
/* can do together with guard */
|
||||||
|
add_proc_order(p, K_LEAVE, &xecmd, false, "Zeitung");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
puts(" - regeneration (healing & aura)");
|
p+=10;
|
||||||
monthly_healing();
|
add_proc_global(p, &encounters, "Zufallsbegegnungen");
|
||||||
regeneration_magiepunkte();
|
p+=10;
|
||||||
|
add_proc_global(p, &reset_rng, NULL);
|
||||||
|
add_proc_unit(p, &monsters_kill_peasants, "Monster fressen und vertreiben Bauern");
|
||||||
|
|
||||||
puts(" - Defaults setzen");
|
p+=10;
|
||||||
defaultorders();
|
add_proc_global(p, &randomevents, "Zufallsereignisse");
|
||||||
|
|
||||||
puts(" - Unterhaltskosten, Nachfrage, Seuchen, Wachstum, Auswanderung");
|
p+=10;
|
||||||
demographics();
|
add_proc_global(p, &monthly_healing, "Regeneration (HP)");
|
||||||
|
add_proc_global(p, ®eneration_magiepunkte, "Regeneration (Aura)");
|
||||||
|
add_proc_global(p, &defaultorders, "Defaults setzen");
|
||||||
|
add_proc_global(p, &demographics, "Nahrung, Seuchen, Wachstum, Wanderung");
|
||||||
|
|
||||||
puts(" - Gebäudeunterhalt (2. Versuch)");
|
p+=10;
|
||||||
maintain_buildings(true);
|
add_proc_region(p, &maintain_buildings_2, "Gebäudeunterhalt (2. Versuch)");
|
||||||
|
|
||||||
|
p+=10;
|
||||||
|
add_proc_global(p, &reorder, "Einheiten sortieren");
|
||||||
#ifdef KARMA_MODULE
|
#ifdef KARMA_MODULE
|
||||||
puts(" - Jihads setzen");
|
p+=10;
|
||||||
karma();
|
add_proc_global(p, &karma, "Jihads setzen");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
puts(" - Einheiten Sortieren");
|
|
||||||
reorder();
|
|
||||||
#ifdef ALLIANCEJOIN
|
#ifdef ALLIANCEJOIN
|
||||||
alliancejoin();
|
p+=10;
|
||||||
|
add_proc_global(p, &alliancejoin, "Allianzen");
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENEMIES
|
#ifdef ENEMIES
|
||||||
puts(" - Krieg & Frieden");
|
p+=10;
|
||||||
declare_war();
|
add_proc_global(p, &declare_war, "Krieg & Frieden");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HEROES
|
#ifdef HEROES
|
||||||
puts(" - Heldenbeförderung");
|
add_proc_order(p, K_PROMOTION, &promotion_cmd, false, "Heldenbeförderung");
|
||||||
parse(K_PROMOTION, promotion_cmd, false);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
puts(" - Neue Nummern");
|
p+=10;
|
||||||
renumber();
|
add_proc_global(p, &renumber_factions, "Neue Nummern");
|
||||||
|
add_proc_order(p, K_NUMBER, &renumber_cmd, false, "Neue Nummern (Einheiten)");
|
||||||
|
|
||||||
|
process();
|
||||||
|
/*************************************************/
|
||||||
|
|
||||||
for (r = regions;r;r=r->next) reorder_owners(r);
|
for (r = regions;r;r=r->next) reorder_owners(r);
|
||||||
|
|
||||||
puts(" - Attribute altern");
|
puts(" - Attribute altern");
|
||||||
|
|
|
@ -761,13 +761,8 @@ monster_learn(unit *u)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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) {
|
if (u->race->flags & RCF_SCAREPEASANTS) {
|
||||||
scared_by_monster(u);
|
scared_by_monster(u);
|
||||||
}
|
}
|
||||||
|
@ -778,8 +773,6 @@ monsters_kill_peasants(void)
|
||||||
absorbed_by_monster(u);
|
absorbed_by_monster(u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
check_overpopulated(unit *u)
|
check_overpopulated(unit *u)
|
||||||
|
|
|
@ -29,7 +29,7 @@ extern "C" {
|
||||||
|
|
||||||
void age_illusion(struct unit *u);
|
void age_illusion(struct unit *u);
|
||||||
|
|
||||||
void monsters_kill_peasants(void);
|
void monsters_kill_peasants(struct unit * u);
|
||||||
void plan_monsters(void);
|
void plan_monsters(void);
|
||||||
struct unit *random_unit(const struct region * r);
|
struct unit *random_unit(const struct region * r);
|
||||||
|
|
||||||
|
|
|
@ -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,
|
sprintf(buf, (dead == 1) ? person_lost_msg : persons_lost_msg,
|
||||||
dead, unitname(u), unit_dies_msg);
|
dead, unitname(u), unit_dies_msg);
|
||||||
}
|
}
|
||||||
if (dead == u->number)
|
if (dead == u->number) {
|
||||||
/* the poor creature, she dies */
|
/* the poor creature, she dies */
|
||||||
{
|
|
||||||
*ui = u->next;
|
*ui = u->next;
|
||||||
destroy_unit(u);
|
destroy_unit(u);
|
||||||
}
|
}
|
||||||
|
|
|
@ -439,11 +439,10 @@ teach(unit * u, struct order * ord)
|
||||||
}
|
}
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
int
|
||||||
learn(void)
|
learn_cmd(unit * u, order * ord)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r = u->region;
|
||||||
unit *u;
|
|
||||||
int p;
|
int p;
|
||||||
magic_t mtyp;
|
magic_t mtyp;
|
||||||
int l;
|
int l;
|
||||||
|
@ -451,17 +450,7 @@ learn(void)
|
||||||
|
|
||||||
/* lernen nach lehren */
|
/* lernen nach lehren */
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
|
||||||
for (u = r->units; u; u = u->next) {
|
|
||||||
int days;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fval(u, UFL_LONGACTION)) continue;
|
|
||||||
if (get_keyword(u->thisorder) == K_STUDY) {
|
|
||||||
double multi = 1.0;
|
double multi = 1.0;
|
||||||
attrib * a = NULL;
|
attrib * a = NULL;
|
||||||
teaching_info * teach = NULL;
|
teaching_info * teach = NULL;
|
||||||
|
@ -469,42 +458,50 @@ learn(void)
|
||||||
skill_t sk;
|
skill_t sk;
|
||||||
int maxalchemy = 0;
|
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)
|
if (u->race == new_race[RC_INSECT] && r_insectstalled(r)
|
||||||
&& !is_cursed(u->attribs, C_KAELTESCHUTZ,0)) {
|
&& !is_cursed(u->attribs, C_KAELTESCHUTZ,0)) {
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
if (fval(u, UFL_LONGACTION)) {
|
if (fval(u, UFL_LONGACTION)) {
|
||||||
cmistake(u, u->thisorder, 52, MSG_PRODUCE);
|
cmistake(u, ord, 52, MSG_PRODUCE);
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((u->race->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) {
|
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)));
|
sprintf(buf, "%s können nichts lernen", LOC(default_locale, rc_name(u->race, 1)));
|
||||||
mistake(u, u->thisorder, buf, MSG_EVENT);
|
mistake(u, ord, buf, MSG_EVENT);
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
init_tokens(u->thisorder);
|
init_tokens(ord);
|
||||||
skip_token();
|
skip_token();
|
||||||
sk = getskill(u->faction->locale);
|
sk = getskill(u->faction->locale);
|
||||||
|
|
||||||
if (sk < 0) {
|
if (sk < 0) {
|
||||||
cmistake(u, u->thisorder, 77, MSG_EVENT);
|
cmistake(u, ord, 77, MSG_EVENT);
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
if (SkillCap(sk) && SkillCap(sk) <= effskill(u, sk)) {
|
if (SkillCap(sk) && SkillCap(sk) <= effskill(u, sk)) {
|
||||||
cmistake(u, u->thisorder, 77, MSG_EVENT);
|
cmistake(u, ord, 77, MSG_EVENT);
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Hack: Talente mit Malus -99 können nicht gelernt werden */
|
/* Hack: Talente mit Malus -99 können nicht gelernt werden */
|
||||||
if (u->race->bonus[sk] == -99) {
|
if (u->race->bonus[sk] == -99) {
|
||||||
cmistake(u, u->thisorder, 77, MSG_EVENT);
|
cmistake(u, ord, 77, MSG_EVENT);
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
/* snotlings können Talente nur bis T8 lernen */
|
/* snotlings können Talente nur bis T8 lernen */
|
||||||
if (u->race == new_race[RC_SNOTLING]){
|
if (u->race == new_race[RC_SNOTLING]){
|
||||||
if (get_level(u, sk) >= 8){
|
if (get_level(u, sk) >= 8){
|
||||||
cmistake(u, u->thisorder, 308, MSG_EVENT);
|
cmistake(u, ord, 308, MSG_EVENT);
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,8 +516,8 @@ learn(void)
|
||||||
* studycost darf hier noch nicht durch Akademie erhöht sein */
|
* studycost darf hier noch nicht durch Akademie erhöht sein */
|
||||||
if (studycost > 0 && !ExpensiveMigrants() && is_migrant(u)) {
|
if (studycost > 0 && !ExpensiveMigrants() && is_migrant(u)) {
|
||||||
sprintf(buf, "Migranten können keine kostenpflichtigen Talente lernen");
|
sprintf(buf, "Migranten können keine kostenpflichtigen Talente lernen");
|
||||||
mistake(u, u->thisorder, buf, MSG_EVENT);
|
mistake(u, ord, buf, MSG_EVENT);
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Akademie: */
|
/* Akademie: */
|
||||||
{
|
{
|
||||||
|
@ -534,8 +531,8 @@ learn(void)
|
||||||
|
|
||||||
if (sk == SK_MAGIC) {
|
if (sk == SK_MAGIC) {
|
||||||
if (u->number > 1){
|
if (u->number > 1){
|
||||||
cmistake(u, u->thisorder, 106, MSG_MAGIC);
|
cmistake(u, ord, 106, MSG_MAGIC);
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
if (is_familiar(u)){
|
if (is_familiar(u)){
|
||||||
/* Vertraute zählen nicht zu den Magiern einer Partei,
|
/* Vertraute zählen nicht zu den Magiern einer Partei,
|
||||||
|
@ -549,8 +546,8 @@ learn(void)
|
||||||
{
|
{
|
||||||
sprintf(buf, "Es kann maximal %d Magier pro Partei geben",
|
sprintf(buf, "Es kann maximal %d Magier pro Partei geben",
|
||||||
max_skill(u->faction, SK_MAGIC));
|
max_skill(u->faction, SK_MAGIC));
|
||||||
mistake(u, u->thisorder, buf, MSG_EVENT);
|
mistake(u, ord, buf, MSG_EVENT);
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
mtyp = getmagicskill();
|
mtyp = getmagicskill();
|
||||||
if (mtyp == M_NONE || mtyp == M_GRAU) {
|
if (mtyp == M_NONE || mtyp == M_GRAU) {
|
||||||
|
@ -561,16 +558,16 @@ learn(void)
|
||||||
} else {
|
} else {
|
||||||
/* Es wurde kein Magiegebiet angegeben und die Partei
|
/* Es wurde kein Magiegebiet angegeben und die Partei
|
||||||
* hat noch keins gewählt. */
|
* hat noch keins gewählt. */
|
||||||
cmistake(u, u->thisorder, 178, MSG_MAGIC);
|
cmistake(u, ord, 178, MSG_MAGIC);
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mtyp != u->faction->magiegebiet){
|
if (mtyp != u->faction->magiegebiet){
|
||||||
/* Es wurde versucht, ein anderes Magiegebiet zu lernen
|
/* Es wurde versucht, ein anderes Magiegebiet zu lernen
|
||||||
* als das der Partei */
|
* als das der Partei */
|
||||||
if (u->faction->magiegebiet != 0){
|
if (u->faction->magiegebiet != 0){
|
||||||
cmistake(u, u->thisorder, 179, MSG_MAGIC);
|
cmistake(u, ord, 179, MSG_MAGIC);
|
||||||
continue;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
/* Lernt zum ersten mal Magie und legt damit das
|
/* Lernt zum ersten mal Magie und legt damit das
|
||||||
* Magiegebiet der Partei fest */
|
* Magiegebiet der Partei fest */
|
||||||
|
@ -584,8 +581,8 @@ learn(void)
|
||||||
/* die Partei hat noch kein Magiegebiet gewählt. */
|
/* die Partei hat noch kein Magiegebiet gewählt. */
|
||||||
mtyp = getmagicskill();
|
mtyp = getmagicskill();
|
||||||
if (mtyp == M_NONE){
|
if (mtyp == M_NONE){
|
||||||
cmistake(u, u->thisorder, 178, MSG_MAGIC);
|
cmistake(u, ord, 178, MSG_MAGIC);
|
||||||
continue;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
/* Legt damit das Magiegebiet der Partei fest */
|
/* Legt damit das Magiegebiet der Partei fest */
|
||||||
u->faction->magiegebiet = mtyp;
|
u->faction->magiegebiet = mtyp;
|
||||||
|
@ -600,8 +597,8 @@ learn(void)
|
||||||
max_skill(u->faction, SK_ALCHEMY)) {
|
max_skill(u->faction, SK_ALCHEMY)) {
|
||||||
sprintf(buf, "Es kann maximal %d Alchemisten pro Partei geben",
|
sprintf(buf, "Es kann maximal %d Alchemisten pro Partei geben",
|
||||||
max_skill(u->faction, SK_ALCHEMY));
|
max_skill(u->faction, SK_ALCHEMY));
|
||||||
mistake(u, u->thisorder, buf, MSG_EVENT);
|
mistake(u, ord, buf, MSG_EVENT);
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (studycost) {
|
if (studycost) {
|
||||||
|
@ -614,11 +611,11 @@ learn(void)
|
||||||
money = min(money, studycost);
|
money = min(money, studycost);
|
||||||
if (p>0 && money < studycost * u->number) {
|
if (p>0 && money < studycost * u->number) {
|
||||||
#ifdef PARTIAL_STUDY
|
#ifdef PARTIAL_STUDY
|
||||||
cmistake(u, u->thisorder, 65, MSG_EVENT);
|
cmistake(u, ord, 65, MSG_EVENT);
|
||||||
multi = money / (double)(studycost * u->number);
|
multi = money / (double)(studycost * u->number);
|
||||||
#else
|
#else
|
||||||
cmistake(u, u->thisorder, 65, MSG_EVENT);
|
cmistake(u, ord, 65, MSG_EVENT);
|
||||||
continue; /* nein, Silber reicht auch so nicht */
|
return 0; /* nein, Silber reicht auch so nicht */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -734,22 +731,16 @@ learn(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
teaching(void)
|
teaching(region *r)
|
||||||
{
|
{
|
||||||
region *r;
|
|
||||||
/* das sind alles befehle, die 30 tage brauchen, und die in thisorder
|
/* das sind alles befehle, die 30 tage brauchen, und die in thisorder
|
||||||
* stehen! von allen 30-tage befehlen wird einfach der letzte verwendet
|
* stehen! von allen 30-tage befehlen wird einfach der letzte verwendet
|
||||||
* (dosetdefaults).
|
* (dosetdefaults).
|
||||||
*
|
*
|
||||||
* lehren vor lernen. */
|
* 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) {
|
||||||
|
@ -788,4 +779,3 @@ teaching(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void teaching(void);
|
extern void teaching(struct region * r);
|
||||||
extern void learn(void);
|
extern int learn_cmd(struct unit * u, struct order * ord);
|
||||||
|
|
||||||
extern magic_t getmagicskill(void);
|
extern magic_t getmagicskill(void);
|
||||||
extern boolean is_migrant(struct unit *u);
|
extern boolean is_migrant(struct unit *u);
|
||||||
|
|
|
@ -3988,23 +3988,19 @@ battle_flee(battle * b)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
do_battle(void)
|
do_battle(region * r)
|
||||||
{
|
{
|
||||||
region *r;
|
|
||||||
#ifdef SMALL_BATTLE_MESSAGES
|
#ifdef SMALL_BATTLE_MESSAGES
|
||||||
char smallbuf[512];
|
char smallbuf[512];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (r=regions;r!=NULL;r=r->next) {
|
|
||||||
battle *b = NULL;
|
battle *b = NULL;
|
||||||
boolean fighting = false;
|
boolean fighting = false;
|
||||||
ship * sh;
|
ship * sh;
|
||||||
building *bu;
|
building *bu;
|
||||||
/* int *rows; */
|
|
||||||
|
|
||||||
fighting = init_battle(r, &b);
|
fighting = init_battle(r, &b);
|
||||||
|
|
||||||
if (b==NULL) continue;
|
if (b==NULL) return;
|
||||||
|
|
||||||
/* Bevor wir die alliierten hineinziehen, sollten wir schauen, *
|
/* Bevor wir die alliierten hineinziehen, sollten wir schauen, *
|
||||||
* Ob jemand fliehen kann. Dann erübrigt sich das ganze ja
|
* Ob jemand fliehen kann. Dann erübrigt sich das ganze ja
|
||||||
|
@ -4017,7 +4013,7 @@ do_battle(void)
|
||||||
msg_release(m);
|
msg_release(m);
|
||||||
free_battle(b);
|
free_battle(b);
|
||||||
free(b);
|
free(b);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
join_allies(b);
|
join_allies(b);
|
||||||
#ifdef HEROES
|
#ifdef HEROES
|
||||||
|
@ -4090,4 +4086,3 @@ do_battle(void)
|
||||||
free(b);
|
free(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ extern "C" {
|
||||||
|
|
||||||
extern const troop no_troop;
|
extern const troop no_troop;
|
||||||
|
|
||||||
extern void do_battle(void);
|
extern void do_battle(struct region * r);
|
||||||
|
|
||||||
/* for combar spells and special attacks */
|
/* for combar spells and special attacks */
|
||||||
enum { SELECT_ADVANCE = 0x1, SELECT_DISTANCE = 0x2, SELECT_FIND = 0x4 };
|
enum { SELECT_ADVANCE = 0x1, SELECT_DISTANCE = 0x2, SELECT_FIND = 0x4 };
|
||||||
|
|
|
@ -281,11 +281,8 @@ siege_cmd(unit * u, order * ord)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
do_siege(void)
|
do_siege(region *r)
|
||||||
{
|
{
|
||||||
region *r;
|
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
|
||||||
if (fval(r->terrain, LAND_REGION)) {
|
if (fval(r->terrain, LAND_REGION)) {
|
||||||
unit *u;
|
unit *u;
|
||||||
|
|
||||||
|
@ -296,7 +293,6 @@ do_siege(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -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
|
int
|
||||||
leave_cmd(unit * u, struct order * ord)
|
leave_cmd(unit * u, struct order * ord)
|
||||||
{
|
{
|
||||||
|
@ -1255,13 +1231,8 @@ enter_building(unit * u, order * ord, int id, boolean report)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
do_misc(boolean lasttry)
|
do_misc(region * r, boolean lasttry)
|
||||||
{
|
{
|
||||||
region *r;
|
|
||||||
|
|
||||||
/* lasttry: Fehler nur im zweiten Versuch melden. Sonst konfus. */
|
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
|
||||||
unit **uptr, *uc;
|
unit **uptr, *uc;
|
||||||
|
|
||||||
for (uc = r->units; uc; uc = uc->next) {
|
for (uc = r->units; uc; uc = uc->next) {
|
||||||
|
@ -1344,4 +1315,3 @@ do_misc(boolean lasttry)
|
||||||
if (*uptr==u) uptr = &u->next;
|
if (*uptr==u) uptr = &u->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -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);
|
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 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 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);
|
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 building * getbuilding(const struct region * r);
|
||||||
struct ship *getship(const struct region * r);
|
struct ship *getship(const struct region * r);
|
||||||
|
|
||||||
void remove_contacts(void);
|
void do_misc(struct region *r, boolean tries);
|
||||||
void do_misc(boolean tries);
|
|
||||||
|
|
||||||
void reportevent(struct region * r, char *s);
|
void reportevent(struct region * r, char *s);
|
||||||
|
|
||||||
|
|
|
@ -496,7 +496,7 @@ destroy_building(building * b)
|
||||||
|
|
||||||
/* Stattdessen nur aus Liste entfernen, aber im Speicher halten. */
|
/* Stattdessen nur aus Liste entfernen, aber im Speicher halten. */
|
||||||
choplist(&b->region->buildings, b);
|
choplist(&b->region->buildings, b);
|
||||||
handle_event(&b->attribs, "destroy", b);
|
handle_event(b->attribs, "destroy", b);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern attrib_type at_icastle;
|
extern attrib_type at_icastle;
|
||||||
|
|
|
@ -2539,9 +2539,9 @@ remove_empty_units_in_region(region *r)
|
||||||
faction * f = u->faction;
|
faction * f = u->faction;
|
||||||
if (!fval(f, FFL_NOTIMEOUT) && f->age > MaxAge()) set_number(u, 0);
|
if (!fval(f, FFL_NOTIMEOUT) && f->age > MaxAge()) set_number(u, 0);
|
||||||
}
|
}
|
||||||
if ((u->number == 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])) {
|
||||||
|| (u->age <= 0 && u->race == new_race[RC_SPELL])) {
|
|
||||||
destroy_unit(u);
|
destroy_unit(u);
|
||||||
|
if (u->number==0) remove_unit(u);
|
||||||
}
|
}
|
||||||
if (*up==u) up=&u->next;
|
if (*up==u) up=&u->next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,7 @@ destroyfaction(faction * f)
|
||||||
}
|
}
|
||||||
f->alive = 0;
|
f->alive = 0;
|
||||||
/* no way! f->units = NULL; */
|
/* no way! f->units = NULL; */
|
||||||
handle_event(&f->attribs, "destroy", f);
|
handle_event(f->attribs, "destroy", f);
|
||||||
for (ff = factions; ff; ff = ff->next) {
|
for (ff = factions; ff; ff = ff->next) {
|
||||||
group *g;
|
group *g;
|
||||||
ally *sf, *sfn;
|
ally *sf, *sfn;
|
||||||
|
|
|
@ -124,8 +124,8 @@ give_item(int want, const item_type * itype, unit * src, unit * dest, struct ord
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
handle_event(&src->attribs, "give", dest);
|
handle_event(src->attribs, "give", dest);
|
||||||
handle_event(&dest->attribs, "receive", src);
|
handle_event(dest->attribs, "receive", src);
|
||||||
#if defined(MUSEUM_MODULE) && defined(TODO)
|
#if defined(MUSEUM_MODULE) && defined(TODO)
|
||||||
/* TODO: Einen Trigger für den museums-warden benutzen! */
|
/* TODO: Einen Trigger für den museums-warden benutzen! */
|
||||||
if (a_find(dest->attribs, &at_warden)) {
|
if (a_find(dest->attribs, &at_warden)) {
|
||||||
|
|
|
@ -2807,6 +2807,7 @@ magic(void)
|
||||||
for (spellrank = 0; spellrank < MAX_SPELLRANK; spellrank++) {
|
for (spellrank = 0; spellrank < MAX_SPELLRANK; spellrank++) {
|
||||||
free_castorders(cll[spellrank]);
|
free_castorders(cll[spellrank]);
|
||||||
}
|
}
|
||||||
|
remove_empty_units();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
|
|
@ -2524,19 +2524,14 @@ movement(void)
|
||||||
* FOLLOW SHIP is a long order, and doesn't need to be treated in here.
|
* FOLLOW SHIP is a long order, and doesn't need to be treated in here.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
follow_unit(void)
|
follow_unit(unit * u)
|
||||||
{
|
{
|
||||||
region * r;
|
region * r = u->region;
|
||||||
|
attrib * a = NULL;
|
||||||
for (r=regions;r;r=r->next) {
|
|
||||||
unit * u;
|
|
||||||
|
|
||||||
for (u=r->units;u;u=u->next) {
|
|
||||||
attrib * a;
|
|
||||||
order * ord;
|
order * ord;
|
||||||
|
|
||||||
if (fval(u, UFL_LONGACTION) || LongHunger(u)) continue;
|
if (fval(u, UFL_LONGACTION) || LongHunger(u)) return;
|
||||||
a = a_find(u->attribs, &at_follow);
|
|
||||||
for (ord=u->orders;ord;ord=ord->next) {
|
for (ord=u->orders;ord;ord=ord->next) {
|
||||||
const struct locale * lang = u->faction->locale;
|
const struct locale * lang = u->faction->locale;
|
||||||
|
|
||||||
|
@ -2546,6 +2541,10 @@ follow_unit(void)
|
||||||
if (getparam(lang) == P_UNIT) {
|
if (getparam(lang) == P_UNIT) {
|
||||||
int id = read_unitid(u->faction, r);
|
int id = read_unitid(u->faction, r);
|
||||||
|
|
||||||
|
if (a!=NULL) {
|
||||||
|
a = a_find(u->attribs, &at_follow);
|
||||||
|
}
|
||||||
|
|
||||||
if (id>0) {
|
if (id>0) {
|
||||||
unit * uf = findunit(id);
|
unit * uf = findunit(id);
|
||||||
if (!a) {
|
if (!a) {
|
||||||
|
@ -2565,8 +2564,9 @@ follow_unit(void)
|
||||||
unit * u2 = a->data.v;
|
unit * u2 = a->data.v;
|
||||||
boolean follow = false;
|
boolean follow = false;
|
||||||
|
|
||||||
if (!u2 || u2->region!=r || !cansee(u->faction, r, u2, 0))
|
if (!u2 || u2->region!=r || !cansee(u->faction, r, u2, 0)) {
|
||||||
continue;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (get_keyword(u2->thisorder)) {
|
switch (get_keyword(u2->thisorder)) {
|
||||||
case K_MOVE:
|
case K_MOVE:
|
||||||
|
@ -2602,5 +2602,3 @@ follow_unit(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -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 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 int walkingcapacity(const struct unit * u);
|
||||||
|
|
||||||
extern void follow_unit(void);
|
extern void follow_unit(struct unit * u);
|
||||||
|
|
||||||
struct building_type;
|
struct building_type;
|
||||||
boolean buildingtype_exists(const struct region * r, const struct building_type * bt);
|
boolean buildingtype_exists(const struct region * r, const struct building_type * bt);
|
||||||
|
|
|
@ -260,19 +260,10 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
int
|
||||||
init_pool(void)
|
reserve_cmd(unit * u, struct order *ord)
|
||||||
{
|
{
|
||||||
unit *u;
|
if (u->number > 0 && (urace(u)->ec_flags & GETITEM)) {
|
||||||
region *r;
|
|
||||||
|
|
||||||
/* 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();
|
int use, count = geti();
|
||||||
const resource_type * rtype;
|
const resource_type * rtype;
|
||||||
|
|
||||||
|
@ -281,7 +272,7 @@ init_pool(void)
|
||||||
count = geti();
|
count = geti();
|
||||||
|
|
||||||
rtype = findresourcetype(getstrtoken(), u->faction->locale);
|
rtype = findresourcetype(getstrtoken(), u->faction->locale);
|
||||||
if (rtype == NULL) continue;
|
if (rtype == NULL) return 0;
|
||||||
|
|
||||||
new_set_resvalue(u, rtype, 0); /* make sure the pool is empty */
|
new_set_resvalue(u, rtype, 0); /* make sure the pool is empty */
|
||||||
use = use_pooled(u, rtype, GET_DEFAULT, count);
|
use = use_pooled(u, rtype, GET_DEFAULT, count);
|
||||||
|
@ -290,8 +281,6 @@ init_pool(void)
|
||||||
change_resource(u, rtype, use);
|
change_resource(u, rtype, use);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return 0;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 get_reservation(const struct unit * u, const struct resource_type * res);
|
||||||
int change_reservation(struct unit * u, const struct resource_type * res, int value);
|
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
|
/** init_pool
|
||||||
* initialisiert den regionalen Pool.
|
* initialisiert den regionalen Pool.
|
||||||
|
|
|
@ -199,7 +199,7 @@ destroy_ship(ship * sh)
|
||||||
}
|
}
|
||||||
sunhash(sh);
|
sunhash(sh);
|
||||||
choplist(&r->ships, sh);
|
choplist(&r->ships, sh);
|
||||||
handle_event(&sh->attribs, "destroy", sh);
|
handle_event(sh->attribs, "destroy", sh);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
|
|
@ -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
|
void
|
||||||
destroy_unit(unit * u)
|
destroy_unit(unit * u)
|
||||||
{
|
{
|
||||||
|
@ -261,17 +272,13 @@ destroy_unit(unit * u)
|
||||||
u->race = u->irace = new_race[RC_ZOMBIE];
|
u->race = u->irace = new_race[RC_ZOMBIE];
|
||||||
} else {
|
} else {
|
||||||
if (u->number) set_number(u, 0);
|
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)) {
|
if (r && !fval(r->terrain, SEA_REGION)) {
|
||||||
rsetmoney(r, rmoney(r) + get_money(u));
|
rsetmoney(r, rmoney(r) + get_money(u));
|
||||||
}
|
}
|
||||||
dhash(u->no, u->faction);
|
dhash(u->no, u->faction);
|
||||||
u_setfaction(u, NULL);
|
u_setfaction(u, NULL);
|
||||||
if (r) leave(r, u);
|
if (r) leave(r, u);
|
||||||
uunhash(u);
|
|
||||||
if (r) choplist(&r->units, u);
|
|
||||||
u->next = udestroy;
|
|
||||||
udestroy = u;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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. */
|
/* Einheiten werden nicht wirklich zerstört. */
|
||||||
extern void destroy_unit(struct unit * u);
|
extern void destroy_unit(struct unit * u);
|
||||||
|
extern void remove_unit(struct unit * u);
|
||||||
extern void distribute_items(struct unit * u);
|
extern void distribute_items(struct unit * u);
|
||||||
|
|
||||||
/* see resolve.h */
|
/* see resolve.h */
|
||||||
|
|
|
@ -88,17 +88,12 @@ xe_giveballon(unit *u, struct order *ord)
|
||||||
fset(u2, UFL_OWNER);
|
fset(u2, UFL_OWNER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
xecmd(void)
|
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)) {
|
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) {
|
if (get_keyword(ord) == K_XE) {
|
||||||
init_tokens(ord);
|
init_tokens(ord);
|
||||||
skip_token();
|
skip_token();
|
||||||
|
@ -115,9 +110,7 @@ xecmd(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return 0;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,7 +18,7 @@ extern "C" {
|
||||||
|
|
||||||
#ifdef XECMD_MODULE
|
#ifdef XECMD_MODULE
|
||||||
extern attrib_type at_xontormiaexpress;
|
extern attrib_type at_xontormiaexpress;
|
||||||
void xecmd(void);
|
int xecmd(struct unit * u, struct order * ord);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -200,20 +200,20 @@ add_trigger(struct attrib ** ap, const char * eventname, struct trigger * t)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
handle_event(attrib ** attribs, const char * eventname, void * data)
|
handle_event(attrib * attribs, const char * eventname, void * data)
|
||||||
{
|
{
|
||||||
while (*attribs) {
|
while (attribs) {
|
||||||
if ((*attribs)->type==&at_eventhandler) break;
|
if (attribs->type==&at_eventhandler) break;
|
||||||
attribs = &(*attribs)->next;
|
attribs = attribs->nexttype;
|
||||||
}
|
}
|
||||||
while (*attribs && (*attribs)->type==&at_eventhandler) {
|
while (attribs && attribs->type==&at_eventhandler) {
|
||||||
handler_info * tl = (handler_info*)(*attribs)->data.v;
|
handler_info * tl = (handler_info*)attribs->data.v;
|
||||||
if (!strcmp(tl->event, eventname)) {
|
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);
|
handle_triggers(&tl->triggers, data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
attribs = &(*attribs)->next;
|
attribs = attribs->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 void remove_triggers(struct attrib ** ap, const char * eventname, const trigger_type * tt);
|
||||||
extern struct trigger ** get_triggers(struct attrib * ap, const char * eventname);
|
extern struct trigger ** get_triggers(struct attrib * ap, const char * eventname);
|
||||||
/* calls handle() for each of these. e.g. used in timeout */
|
/* 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: */
|
/* functions for making complex triggers: */
|
||||||
extern void free_triggers(trigger * triggers); /* release all these triggers */
|
extern void free_triggers(trigger * triggers); /* release all these triggers */
|
||||||
|
|
|
@ -232,7 +232,9 @@ region_remove(region& r)
|
||||||
while (*rp) {
|
while (*rp) {
|
||||||
if (*rp==&r) {
|
if (*rp==&r) {
|
||||||
while (r.units) {
|
while (r.units) {
|
||||||
destroy_unit(r.units);
|
unit * u = r.units;
|
||||||
|
destroy_unit(u);
|
||||||
|
remove_unit(u);
|
||||||
}
|
}
|
||||||
*rp = r.next;
|
*rp = r.next;
|
||||||
#ifdef FAST_CONNECT
|
#ifdef FAST_CONNECT
|
||||||
|
|
|
@ -1465,6 +1465,7 @@ showunits(region * r)
|
||||||
if (yes_no(0, lbuf, 'n')) {
|
if (yes_no(0, lbuf, 'n')) {
|
||||||
modified = 1;
|
modified = 1;
|
||||||
destroy_unit(clipunit);
|
destroy_unit(clipunit);
|
||||||
|
if (clipunit->number==0) remove_unit(clipunit);
|
||||||
clipunit = 0;
|
clipunit = 0;
|
||||||
clipregion = 0;
|
clipregion = 0;
|
||||||
for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next)
|
for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next)
|
||||||
|
|
Loading…
Reference in New Issue