From d778222324832bbd5284ba93de984284edea7772 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 16 Apr 2005 11:15:47 +0000 Subject: [PATCH] =?UTF-8?q?-=20Drachen=20in=20leeren=20Regionen=20suche=20?= =?UTF-8?q?ein=20neues=20Ziel.=20-=20kleine=20Aufr=C3=A4umarbeiten.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/gamecode/laws.c | 6 ++++-- src/common/gamecode/monster.c | 12 ++++++++++-- src/common/gamecode/report.c | 23 +++++++++++++++++++++++ src/common/kernel/building.c | 23 ----------------------- src/common/kernel/building.h | 1 - 5 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 209089913..63f6dc382 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -1037,10 +1037,12 @@ EnhancedQuit(void) static int quit(unit * u, struct order * ord) { + const char * passwd; init_tokens(ord); skip_token(); /* skip keyword */ - if (checkpasswd(u->faction, getstrtoken(), false)) { + passwd = getstrtoken(); + if (checkpasswd(u->faction, passwd, false)) { if (EnhancedQuit()) { int f2_id = getid(); @@ -1069,7 +1071,7 @@ quit(unit * u, struct order * ord) } else { cmistake(u, ord, 86, MSG_EVENT); log_warning(("STIRB mit falschem Passwort für Partei %s: %s\n", - factionid(u->faction), ord)); + factionid(u->faction), passwd)); } return 0; } diff --git a/src/common/gamecode/monster.c b/src/common/gamecode/monster.c index 04c5ec05a..4170e6043 100644 --- a/src/common/gamecode/monster.c +++ b/src/common/gamecode/monster.c @@ -812,11 +812,13 @@ check_overpopulated(unit *u) static void plan_dragon(unit * u) { - attrib *ta; + attrib * ta = a_find(u->attribs, &at_targetregion); + region * r = u->region; region * tr = NULL; int horses = get_resource(u,R_HORSE); int capacity = walkingcapacity(u); item ** itmp = &u->items; + boolean move = false; if (horses > 0) { change_resource(u, R_HORSE, - min(horses,(u->number*2))); @@ -832,7 +834,13 @@ plan_dragon(unit * u) } if (*itmp==itm) itmp=&itm->next; } - if (rand() % 100 < 4) { + + if (ta==NULL) { + move |= (r->land==0 || r->land->peasants==0); /* when no peasants, move */ + move |= (r->land==0 || r->land->money==0); /* when no money, move */ + } + move |= chance(0.04); /* 4% chance to change your mind */ + if (move) { /* dragon gets bored and looks for a different place to go */ ta = set_new_dragon_target(u, u->region, DRAGON_RANGE); } diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index c7fd8ca0a..4493b7414 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -1552,6 +1552,29 @@ durchreisende(FILE * F, const region * r, const faction * f) } } +static int +buildingmaintenance(const building * b, const resource_type * rtype) +{ + const building_type * bt = b->type; + int c, cost=0; + static boolean init = false; + static const curse_type * nocost_ct; + if (!init) { init = true; nocost_ct = ct_find("nocost"); } + if (curse_active(get_curse(b->attribs, nocost_ct))) { + return 0; + } + for (c=0;bt->maintenance && bt->maintenance[c].number;++c) { + const maintenance * m = bt->maintenance + c; + if (m->rtype==rtype) { + if (fval(m, MTF_VARIABLE)) + cost += (b->size * m->number); + else + cost += m->number; + } + } + return cost; +} + static void order_template(FILE * F, faction * f) { diff --git a/src/common/kernel/building.c b/src/common/kernel/building.c index 76641f676..9f8f6fb42 100644 --- a/src/common/kernel/building.c +++ b/src/common/kernel/building.c @@ -188,29 +188,6 @@ buildingtype(const building * b, int bsize) return s; } -int -buildingmaintenance(const building * b, const resource_type * rtype) -{ - const building_type * bt = b->type; - int c, cost=0; - static boolean init = false; - static const curse_type * nocost_ct; - if (!init) { init = true; nocost_ct = ct_find("nocost"); } - if (curse_active(get_curse(b->attribs, nocost_ct))) { - return 0; - } - for (c=0;bt->maintenance && bt->maintenance[c].number;++c) { - const maintenance * m = bt->maintenance + c; - if (m->rtype==rtype) { - if (fval(m, MTF_VARIABLE)) - cost += (b->size * m->number); - else - cost += m->number; - } - } - return cost; -} - #define BMAXHASH 7919 static building *buildhash[BMAXHASH]; void diff --git a/src/common/kernel/building.h b/src/common/kernel/building.h index 8cf1ca6b8..c690d5920 100644 --- a/src/common/kernel/building.h +++ b/src/common/kernel/building.h @@ -110,7 +110,6 @@ extern void add_buildinglist(building_list **bl, struct building *b); extern struct attrib_type at_building_generic_type; extern const char * buildingtype(const struct building * b, int bsize); extern const char * buildingname(const struct building * b); -extern int buildingmaintenance(const building * b, const struct resource_type * rtype); extern int buildingcapacity(const struct building * b); extern struct building *new_building(const struct building_type * typ, struct region * r, const struct locale * lang); void build_building(struct unit * u, const struct building_type * typ, int size);