From fdd28835b5b0fa15e6c09f4a0eecda5ce3fbd7c8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Nov 2017 07:51:31 +0100 Subject: [PATCH 01/10] Shifting signed 32-bit value by 31 bits is undefined behaviour --- src/kernel/build.test.c | 2 +- src/kernel/item.c | 6 +++--- src/kernel/pool.c | 4 ++-- src/kernel/race.h | 8 ++++---- src/kernel/xmlreader.c | 8 ++++---- src/modules/autoseed.c | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/kernel/build.test.c b/src/kernel/build.test.c index 8cd408b09..f0970ec06 100644 --- a/src/kernel/build.test.c +++ b/src/kernel/build.test.c @@ -207,7 +207,7 @@ static void test_build_building_with_golem(CuTest *tc) { const building_type *btype; u = setup_build(&bf); - bf.rc->flags |= RCF_STONEGOLEM; + bf.rc->ec_flags |= ECF_STONEGOLEM; btype = bt_find("castle"); assert(btype); assert(btype->construction); diff --git a/src/kernel/item.c b/src/kernel/item.c index 89c532297..fdc9b45d1 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -105,10 +105,10 @@ static int res_changepeasants(unit * u, const resource_type * rtype, int delta) } static int golem_factor(const unit *u, const resource_type *rtype) { - if (rtype == get_resourcetype(R_STONE) && (u_race(u)->flags & RCF_STONEGOLEM)) { + if (rtype == get_resourcetype(R_STONE) && (u_race(u)->ec_flags & ECF_STONEGOLEM)) { return GOLEM_STONE; } - if (rtype == get_resourcetype(R_IRON) && (u_race(u)->flags & RCF_IRONGOLEM)) { + if (rtype == get_resourcetype(R_IRON) && (u_race(u)->ec_flags & ECF_IRONGOLEM)) { return GOLEM_IRON; } return 0; @@ -665,7 +665,7 @@ static int mod_dwarves_only(const unit * u, const region * r, skill_t sk, int value) { UNUSED_ARG(r); - if (u_race(u) == get_race(RC_DWARF) || (u_race(u)->flags & RCF_IRONGOLEM)) { + if (u_race(u) == get_race(RC_DWARF) || (u_race(u)->ec_flags & ECF_IRONGOLEM)) { return value; } return -118; diff --git a/src/kernel/pool.c b/src/kernel/pool.c index c252be566..d85846f64 100644 --- a/src/kernel/pool.c +++ b/src/kernel/pool.c @@ -88,9 +88,9 @@ int get_reservation(const unit * u, const item_type * itype) { reservation *res = u->reservations; - if (itype->rtype == get_resourcetype(R_STONE) && (u_race(u)->flags & RCF_STONEGOLEM)) + if (itype->rtype == get_resourcetype(R_STONE) && (u_race(u)->ec_flags & ECF_STONEGOLEM)) return (u->number * GOLEM_STONE); - if (itype->rtype == get_resourcetype(R_IRON) && (u_race(u)->flags & RCF_IRONGOLEM)) + if (itype->rtype == get_resourcetype(R_IRON) && (u_race(u)->ec_flags & ECF_IRONGOLEM)) return (u->number * GOLEM_IRON); while (res && res->type != itype) res = res->next; diff --git a/src/kernel/race.h b/src/kernel/race.h index 2990c2158..1203eaed2 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -226,11 +226,9 @@ extern "C" { #define RCF_CANSAIL (1<<24) /* Einheit darf Schiffe betreten */ #define RCF_INVISIBLE (1<<25) /* not visible in any report */ #define RCF_SHIPSPEED (1<<26) /* race gets +1 on shipspeed */ -#define RCF_STONEGOLEM (1<<27) /* race gets stonegolem properties */ -#define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */ +#define RCF_MIGRANTS (1<<27) /* may have migrant units (human bonus) */ +#define RCF_FAMILIAR (1<<28) /* may be a familiar */ #define RCF_ATTACK_MOVED (1<<29) /* may attack if it has moved */ -#define RCF_MIGRANTS (1<<30) /* may have migrant units (human bonus) */ -#define RCF_FAMILIAR (1<<31) /* may be a familiar */ /* Economic flags */ #define ECF_GIVEPERSON (1<<2) /* �bergibt Personen */ @@ -238,6 +236,8 @@ extern "C" { #define ECF_GETITEM (1<<4) /* nimmt Gegenst�nde an */ #define ECF_REC_ETHEREAL (1<<7) /* Rekrutiert aus dem Nichts */ #define ECF_REC_UNLIMITED (1<<8) /* Rekrutiert ohne Limit */ +#define ECF_STONEGOLEM (1<<9) /* race gets stonegolem properties */ +#define ECF_IRONGOLEM (1<<10) /* race gets irongolem properties */ /* Battle-Flags */ #define BF_EQUIPMENT (1<<0) /* Kann Ausr�stung benutzen */ diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 18bdedebc..92112ddb6 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1434,10 +1434,6 @@ static int parse_races(xmlDocPtr doc) rc->flags |= RCF_DRAGON; if (xml_bvalue(node, "shipspeed", false)) rc->flags |= RCF_SHIPSPEED; - if (xml_bvalue(node, "stonegolem", false)) - rc->flags |= RCF_STONEGOLEM; - if (xml_bvalue(node, "irongolem", false)) - rc->flags |= RCF_IRONGOLEM; if (xml_bvalue(node, "giveperson", false)) rc->ec_flags |= ECF_GIVEPERSON; @@ -1449,6 +1445,10 @@ static int parse_races(xmlDocPtr doc) rc->ec_flags |= ECF_REC_ETHEREAL; if (xml_bvalue(node, "recruitunlimited", false)) rc->ec_flags |= ECF_REC_UNLIMITED; + if (xml_bvalue(node, "stonegolem", false)) + rc->ec_flags |= ECF_STONEGOLEM; + if (xml_bvalue(node, "irongolem", false)) + rc->ec_flags |= ECF_IRONGOLEM; if (xml_bvalue(node, "equipment", false)) rc->battle_flags |= BF_EQUIPMENT; /* TODO: invert this flag, so rc_get_or_create gets simpler */ diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index fd9ef2f19..4e5ec96fc 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -155,7 +155,7 @@ newfaction *read_newfactions(const char *filename) email[0] = '\0'; password[0] = '\0'; - if (sscanf(buf, "%54s %20s %8s %16s %d %d", email, race, lang, + if (sscanf(buf, "%54s %19s %8s %16s %d %d", email, race, lang, password, &subscription, &alliance) < 3) { break; } From 923f01190c76291b0876a200b083541a8207c547 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Nov 2017 07:52:56 +0100 Subject: [PATCH 02/10] sscanf format was too big --- src/modules/autoseed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 4e5ec96fc..24153870a 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -155,7 +155,7 @@ newfaction *read_newfactions(const char *filename) email[0] = '\0'; password[0] = '\0'; - if (sscanf(buf, "%54s %19s %8s %16s %d %d", email, race, lang, + if (sscanf(buf, "%54s %19s %7s %15s %d %d", email, race, lang, password, &subscription, &alliance) < 3) { break; } From 8a638859fd83613374199014d3421b088b978f7f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Nov 2017 08:24:56 +0100 Subject: [PATCH 03/10] fix memory access in rc_setoption --- src/economy.test.c | 4 +++- src/kernel/race.c | 17 +++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/economy.test.c b/src/economy.test.c index 6303b2ae8..47194ef86 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -217,7 +217,7 @@ static unit *setup_trade_unit(CuTest *tc, region *r, const struct race *rc) { } static void test_trade_insect(CuTest *tc) { - /* Insekten können in Wüsten und Sümpfen auch ohne Burgen handeln. */ + /* Insekten k�nnen in W�sten und S�mpfen auch ohne Burgen handeln. */ unit *u; region *r; const item_type *it_luxury; @@ -239,6 +239,8 @@ static void test_trade_insect(CuTest *tc) { LOC(u->faction->locale, resourcename(it_luxury->rtype, 0)))); set_item(u, it_silver, 10); + CuAssertPtrEquals(tc, r, u->region); + CuAssertPtrEquals(tc, (void *)it_luxury, (void *)r_luxury(u->region)); produce(u->region); CuAssertIntEquals(tc, 1, get_item(u, it_luxury)); CuAssertIntEquals(tc, 5, get_item(u, it_silver)); diff --git a/src/kernel/race.c b/src/kernel/race.c index a73c0e699..ceb2029c4 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -106,17 +106,18 @@ static void rc_setoption(race *rc, int k, const char *value) { rc->options->key[1] = RCO_NONE; v = rc->options->value; } else { - for (i=0;!v && i < MAXOPTIONS && rc->options->key[i]!=RCO_NONE;++i) { + for (i=0;!v && i < MAXOPTIONS;++i) { if (rc->options->key[i]==key) { v = rc->options->value+i; + break; } - } - if (!v) { - assert(ioptions->value+i; - rc->options->key[i] = key; - if (i+1options->key[i+1]=RCO_NONE; + if (rc->options->key[i]==RCO_NONE) { + v = rc->options->value+i; + rc->options->key[i] = key; + if (i+1 < MAXOPTIONS) { + rc->options->key[i+1]=RCO_NONE; + } + break; } } } From af9f263266f2adf28e3f5e5c28d200affeec7b0c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Nov 2017 08:41:17 +0100 Subject: [PATCH 04/10] add cppcheck to travis build --- .travis.yml | 1 + s/travis-build | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 78aaf3648..a6b898c6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ addons: - libsqlite3-dev - libxml2-dev - valgrind + - cppcheck os: - linux notifications: diff --git a/s/travis-build b/s/travis-build index 438f2ce36..aa29be7fc 100755 --- a/s/travis-build +++ b/s/travis-build @@ -22,6 +22,7 @@ s/cmake-init s/build cd $ROOT inifile +cppcheck --quiet --error-exitcode=1 src s/runtests -V - integration_tests + From e6c11e222331653f559bd3dd94dc11162c8ba272 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Nov 2017 08:51:06 +0100 Subject: [PATCH 05/10] workaround for cppcheck false-positive --- src/orderfile.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/orderfile.c b/src/orderfile.c index 0db6a0cba..a82b599a0 100644 --- a/src/orderfile.c +++ b/src/orderfile.c @@ -101,7 +101,7 @@ static unit *unitorders(input *in, faction *f) } } } - /* Nun wird der Befehl erzeut und eingehängt */ + /* Nun wird der Befehl erzeut und eingeh�ngt */ *ordp = parse_order(s, u->faction->locale); if (*ordp) { ordp = &(*ordp)->next; @@ -136,7 +136,7 @@ static faction *factionorders(void) return 0; } /* Die Partei hat sich zumindest gemeldet, so dass sie noch - * nicht als untätig gilt */ + * nicht als unt�tig gilt */ f->lastorders = turn; } @@ -151,6 +151,7 @@ int read_orders(input *in) const char *b; int nfactions = 0; struct faction *f = NULL; + const struct locale *lang = default_locale; /* TODO: recognize UTF8 BOM */ b = in->getbuf(in->data); @@ -160,7 +161,6 @@ int read_orders(input *in) while (b) { char token[128]; - const struct locale *lang = f ? f->locale : default_locale; param_t p; const char *s; init_tokens_str(b); @@ -171,6 +171,7 @@ int read_orders(input *in) case P_FACTION: f = factionorders(); if (f) { + lang = f->locale; ++nfactions; } @@ -200,12 +201,13 @@ int read_orders(input *in) /* Falls in unitorders() abgebrochen wird, steht dort entweder eine neue * Partei, eine neue Einheit oder das File-Ende. Das switch() wird erneut * durchlaufen, und die entsprechende Funktion aufgerufen. Man darf buf - * auf alle Fälle nicht überschreiben! Bei allen anderen Einträgen hier - * muss buf erneut gefüllt werden, da die betreffende Information in nur - * einer Zeile steht, und nun die nächste gelesen werden muss. */ + * auf alle F�lle nicht �berschreiben! Bei allen anderen Eintr�gen hier + * muss buf erneut gef�llt werden, da die betreffende Information in nur + * einer Zeile steht, und nun die n�chste gelesen werden muss. */ case P_NEXT: f = NULL; + lang = default_locale; b = in->getbuf(in->data); break; From e0bd5c2c7b07e9045a6b939eaa3d758f2708f5ff Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Nov 2017 14:44:02 +0100 Subject: [PATCH 06/10] abort on OOM --- src/attributes/dict.c | 8 +++++++- src/attributes/key.c | 8 +++++++- src/kernel/alliance.c | 3 ++- src/kernel/item.c | 4 +++- src/util/attrib.c | 7 ++++++- src/util/message.c | 6 ++++-- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/attributes/dict.c b/src/attributes/dict.c index f95555734..666742286 100644 --- a/src/attributes/dict.c +++ b/src/attributes/dict.c @@ -135,7 +135,13 @@ static void dict_upgrade(attrib **alist, attrib *abegin) { assert(!"invalid input"); } if (i == 4) { - keys = realloc(keys, sizeof(int) * (n + i + 1)); + int *k; + k = realloc(keys, sizeof(int) * (n + i + 1)); + if (!k) { + free(keys); + abort(); + } + keys = k; memcpy(keys + n + 1, val, sizeof(val)); n += i; i = 0; diff --git a/src/attributes/key.c b/src/attributes/key.c index 00f81a80e..61bbb4599 100644 --- a/src/attributes/key.c +++ b/src/attributes/key.c @@ -123,8 +123,14 @@ static int a_readkeys(attrib * a, void *owner, gamedata *data) { if (e != n) { int sz = keys_size(n); if (e > sz) { + int *k; sz = keys_size(e); - keys = realloc(keys, sizeof(int)*(2 * sz + 1)); + k = realloc(keys, sizeof(int)*(2 * sz + 1)); + if (!k) { + free(keys); + abort(); + } + keys = k; keys[0] = e; } } diff --git a/src/kernel/alliance.c b/src/kernel/alliance.c index 910670d10..34a3ed62f 100644 --- a/src/kernel/alliance.c +++ b/src/kernel/alliance.c @@ -89,7 +89,8 @@ alliance *new_alliance(int id, const char *name) { al->flags |= ALF_NON_ALLIED; } al->next = alliances; - return alliances = al; + alliances = al; + return al; } alliance *findalliance(int id) diff --git a/src/kernel/item.c b/src/kernel/item.c index fdc9b45d1..6c5286813 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -340,8 +340,10 @@ void it_set_appearance(item_type *itype, const char *appearance) { assert(itype); assert(itype->rtype); if (appearance) { + char plural[32]; itype->_appearance[0] = strdup(appearance); - itype->_appearance[1] = strcat(strcpy((char *)malloc(strlen((char *)appearance) + 3), (char *)appearance), "_p"); + snprintf(plural, "%29s_p", appearance); + itype->_appearance[1] = strdup(plural); } else { itype->_appearance[0] = 0; itype->_appearance[1] = 0; diff --git a/src/util/attrib.c b/src/util/attrib.c index b6214fdd6..10ec660f8 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -119,7 +119,12 @@ int a_readstring(attrib * a, void *owner, struct gamedata *data) do { e = READ_STR(data->store, buf, sizeof(buf)); if (result) { - result = realloc(result, len + DISPLAYSIZE - 1); + char *tmp = realloc(result, len + DISPLAYSIZE - 1); + if (!tmp) { + free(result); + abort(); + } + result = tmp; strcpy(result + len, buf); len += DISPLAYSIZE - 1; } diff --git a/src/util/message.c b/src/util/message.c index c5285835e..9056ee139 100644 --- a/src/util/message.c +++ b/src/util/message.c @@ -61,7 +61,7 @@ arg_type *find_argtype(const char *name) message_type *mt_new(const char *name, const char *args[]) { int i, nparameters = 0; - message_type *mtype = (message_type *)malloc(sizeof(message_type)); + message_type *mtype; assert(name != NULL); if (name == NULL) { @@ -72,6 +72,7 @@ message_type *mt_new(const char *name, const char *args[]) /* count the number of parameters */ while (args[nparameters]) ++nparameters; } + mtype = (message_type *)malloc(sizeof(message_type)); mtype->key = 0; mtype->name = strdup(name); mtype->nparameters = nparameters; @@ -143,13 +144,14 @@ static void free_arg(const arg_type * atype, variant data) message *msg_create(const struct message_type *mtype, variant args[]) { int i; - message *msg = (message *)malloc(sizeof(message)); + message *msg; assert(mtype != NULL); if (mtype == NULL) { log_error("Trying to create message with type=0x0\n"); return NULL; } + msg = (message *)malloc(sizeof(message)); msg->type = mtype; msg->parameters = (variant *)(mtype->nparameters ? calloc(mtype->nparameters, sizeof(variant)) : NULL); msg->refcount = 1; From 7c69bfa4109d955c37a8a2fecf80200c8a136216 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Nov 2017 14:50:19 +0100 Subject: [PATCH 07/10] snprintf usage --- src/kernel/item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/item.c b/src/kernel/item.c index 6c5286813..9d750cb2f 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -342,7 +342,7 @@ void it_set_appearance(item_type *itype, const char *appearance) { if (appearance) { char plural[32]; itype->_appearance[0] = strdup(appearance); - snprintf(plural, "%29s_p", appearance); + snprintf(plural, sizeof(plural), "%s_p", appearance); itype->_appearance[1] = strdup(plural); } else { itype->_appearance[0] = 0; From 4fa9e041bf889dbf2ed054975e7b233526f43ecd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Nov 2017 14:57:04 +0100 Subject: [PATCH 08/10] fix cppcheck report (missing curly race) --- s/travis-build | 1 + src/direction.h | 1 + src/keyword.h | 1 + 3 files changed, 3 insertions(+) diff --git a/s/travis-build b/s/travis-build index aa29be7fc..4c5237fdf 100755 --- a/s/travis-build +++ b/s/travis-build @@ -22,6 +22,7 @@ s/cmake-init s/build cd $ROOT inifile +cppcheck --version cppcheck --quiet --error-exitcode=1 src s/runtests -V integration_tests diff --git a/src/direction.h b/src/direction.h index 8f0932aaf..14ced4c1c 100644 --- a/src/direction.h +++ b/src/direction.h @@ -30,5 +30,6 @@ extern "C" extern const char * directions[]; #ifdef __cplusplus +} #endif #endif diff --git a/src/keyword.h b/src/keyword.h index 9be7f9f4e..ebdd4d5e7 100644 --- a/src/keyword.h +++ b/src/keyword.h @@ -87,5 +87,6 @@ extern "C" const char *keyword(keyword_t kwd); #ifdef __cplusplus +} #endif #endif From 36809d1f9a574715c9a2806ab08eb34ff627e366 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Nov 2017 16:49:35 +0100 Subject: [PATCH 09/10] fix coverity resource leaks --- src/kernel/order.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/kernel/order.c b/src/kernel/order.c index a48825333..66fc0cfbb 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -279,27 +279,13 @@ void close_orders(void) { } } -static order *create_order_i(order *ord, keyword_t kwd, const char *sptr, bool persistent, +static void create_order_i(order *ord, keyword_t kwd, const char *sptr, bool persistent, bool noerror, const struct locale *lang) { int lindex; assert(ord); - if (kwd == NOKEYWORD || keyword_disabled(kwd)) { - log_error("trying to create an order for disabled keyword %s.", keyword(kwd)); - return NULL; - } - - /* if this is just nonsense, then we skip it. */ - if (lomem) { - switch (kwd) { - case K_KOMMENTAR: - case NOKEYWORD: - return NULL; - default: - break; - } - } + assert(kwd != NOKEYWORD && !keyword_disabled(kwd)); lindex = locale_index(lang); assert(lindex < MAXLOCALES); @@ -318,8 +304,6 @@ static order *create_order_i(order *ord, keyword_t kwd, const char *sptr, bool p while (isspace(*(unsigned char *)sptr)) ++sptr; ord->data = create_data(kwd, sptr, lindex); - - return ord; } order *create_order(keyword_t kwd, const struct locale * lang, @@ -377,7 +361,8 @@ order *create_order(keyword_t kwd, const struct locale * lang, zBuffer[0] = 0; } ord = (order *)malloc(sizeof(order)); - return create_order_i(ord, kwd, zBuffer, false, false, lang); + create_order_i(ord, kwd, zBuffer, false, false, lang); + return ord; } order *parse_order(const char *s, const struct locale * lang) @@ -409,7 +394,8 @@ order *parse_order(const char *s, const struct locale * lang) } if (kwd != NOKEYWORD) { order *ord = (order *)malloc(sizeof(order)); - return create_order_i(ord, kwd, sptr, persistent, noerror, lang); + create_order_i(ord, kwd, sptr, persistent, noerror, lang); + return ord; } } return NULL; From ff2f83c371babcff1b37ee72c6dc1f09eee66dec Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Nov 2017 17:03:12 +0100 Subject: [PATCH 10/10] order leak in recruit_dracoids, do not build a study order --- src/monsters.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/monsters.c b/src/monsters.c index 8bcf59b8b..3b02b2be2 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -9,7 +9,7 @@ * based on: * * Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace - * Atlantis v1.7 Copyright 1996 by Alex Schröder + * Atlantis v1.7 Copyright 1996 by Alex Schr�der * * This program may not be used, modified or distributed without * prior permission by the authors of Eressea. @@ -74,7 +74,7 @@ #include #include -#define DRAGON_RANGE 20 /* max. Distanz zum nächsten Drachenziel */ +#define DRAGON_RANGE 20 /* max. Distanz zum n�chsten Drachenziel */ #define MOVE_PERCENT 25 /* chance fuer bewegung */ #define MAXILLUSION_TEXTS 3 @@ -359,11 +359,11 @@ static direction_t random_neighbour(region * r, unit * u) } } - /* Zufällig eine auswählen */ + /* Zuf�llig eine ausw�hlen */ rr = rng_int() % c; - /* Durchzählen */ + /* Durchz�hlen */ c = 0; for (i = 0; i != MAXDIRECTIONS; i++) { @@ -400,11 +400,11 @@ static direction_t treeman_neighbour(region * r) if (c == 0) { return NODIRECTION; } - /* Zufällig eine auswählen */ + /* Zuf�llig eine ausw�hlen */ rr = rng_int() % c; - /* Durchzählen */ + /* Durchz�hlen */ c = -1; for (i = 0; i != MAXDIRECTIONS; i++) { @@ -559,7 +559,7 @@ static order *monster_learn(unit * u) return NULL; } - /* Monster lernt ein zufälliges Talent aus allen, in denen es schon + /* Monster lernt ein zuf�lliges Talent aus allen, in denen es schon * Lerntage hat. */ for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) { if (sv->level > 0) @@ -605,7 +605,6 @@ static void recruit_dracoids(unit * dragon, int size) faction *f = dragon->faction; region *r = dragon->region; const struct item *weapon = NULL; - order *new_order = NULL; unit *un = create_unit(r, f, size, get_race(RC_DRACOID), 0, NULL, NULL); fset(un, UFL_ISNEW | UFL_MOVED); @@ -617,15 +616,10 @@ static void recruit_dracoids(unit * dragon, int size) setstatus(un, ST_FIGHT); for (weapon = un->items; weapon; weapon = weapon->next) { const weapon_type *wtype = weapon->type->rtype->wtype; - if (wtype && (wtype->flags & WTF_MISSILE)) { + if (wtype && wtype->flags & WTF_MISSILE) { setstatus(un, ST_BEHIND); + break; } - new_order = create_order(K_STUDY, f->locale, "'%s'", - skillname(weapon->type->rtype->wtype->skill, f->locale)); - } - - if (new_order != NULL) { - addlist(&un->orders, new_order); } } @@ -653,7 +647,7 @@ static order *plan_dragon(unit * u) if (rc == rc_wyrm && !move) { unit *u2; for (u2 = r->units; u2; u2 = u2->next) { - /* wyrme sind einzelgänger */ + /* wyrme sind einzelg�nger */ if (u2 == u) { /* we do not make room for newcomers, so we don't need to look at them */ break; @@ -750,11 +744,11 @@ void plan_monsters(faction * f) attrib *ta; order *long_order = NULL; - /* Ab hier nur noch Befehle für NPC-Einheiten. */ + /* Ab hier nur noch Befehle f�r NPC-Einheiten. */ if (u->faction!=f) continue; - /* Befehle müssen jede Runde neu gegeben werden: */ + /* Befehle m�ssen jede Runde neu gegeben werden: */ free_orders(&u->orders); if (skill_enabled(SK_PERCEPTION)) { /* Monster bekommen jede Runde ein paar Tage Wahrnehmung dazu */ @@ -823,7 +817,7 @@ void plan_monsters(faction * f) } } if (long_order == NULL && unit_can_study(u)) { - /* Einheiten, die Waffenlosen Kampf lernen könnten, lernen es um + /* Einheiten, die Waffenlosen Kampf lernen k�nnten, lernen es um * zu bewachen: */ if (rc->bonus[SK_WEAPONLESS] != -99) { if (effskill(u, SK_WEAPONLESS, 0) < 1) { @@ -868,7 +862,7 @@ unit *spawn_seaserpent(region *r, faction *f) { } /** - * Drachen und Seeschlangen können entstehen + * Drachen und Seeschlangen k�nnen entstehen */ void spawn_dragons(void) { @@ -917,7 +911,7 @@ void spawn_dragons(void) } } -/** Untote können entstehen */ +/** Untote k�nnen entstehen */ void spawn_undead(void) { region *r; @@ -937,7 +931,7 @@ void spawn_undead(void) message *msg; unit *u; /* es ist sinnfrei, wenn irgendwo im Wald 3er-Einheiten Untote entstehen. - * Lieber sammeln lassen, bis sie mindestens 5% der Bevölkerung sind, und + * Lieber sammeln lassen, bis sie mindestens 5% der Bev�lkerung sind, und * dann erst auferstehen. */ int undead = unburied / (rng_int() % 2 + 1); const race *rc = NULL; @@ -995,7 +989,7 @@ void spawn_undead(void) else { int i = deathcount(r); if (i) { - /* Gräber verwittern, 3% der Untoten finden die ewige Ruhe */ + /* Gr�ber verwittern, 3% der Untoten finden die ewige Ruhe */ deathcounts(r, (int)(-i * 0.03)); } }