From 1556c077878f61f4c8180c786d96313758cc8355 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 8 Nov 2014 22:55:07 +0100 Subject: [PATCH 1/5] fix a crash when missing a token --- src/build.h | 2 +- src/kernel/magic.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/build.h b/src/build.h index 7eb5647df..1ab97b086 100644 --- a/src/build.h +++ b/src/build.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 3 -#define VERSION_BUILD 688 +#define VERSION_BUILD 689 diff --git a/src/kernel/magic.c b/src/kernel/magic.c index b609fcff6..ddd53acb0 100644 --- a/src/kernel/magic.c +++ b/src/kernel/magic.c @@ -2579,7 +2579,7 @@ static castorder *cast_cmd(unit * u, order * ord) } s = getstrtoken(); } - if (!s[0] || strlen(s) == 0) { + if (!s || !s[0] || strlen(s) == 0) { /* Fehler "Es wurde kein Zauber angegeben" */ cmistake(u, ord, 172, MSG_MAGIC); return 0; From 9d3b2f3da991c69e4e050652945d742120a4ce7a Mon Sep 17 00:00:00 2001 From: CTD Date: Tue, 11 Nov 2014 10:17:55 +0100 Subject: [PATCH 2/5] Flieger und Bewache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flieger können nur noch durch andere Flieger aufgehalten werden. Damit können Drachen auch in Bewachten Regionen plündern. --- src/move.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/move.c b/src/move.c index 4a9bd7ba7..d8c0f5cd2 100644 --- a/src/move.c +++ b/src/move.c @@ -913,6 +913,8 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r) int sk = eff_skill(u, SK_PERCEPTION, r); if (invisible(reisender, u) >= reisender->number) continue; + if (!u_race(u)->flags & RCF_FLY && u_race(reisender)->flags & RCF_FLY) + continue; if ((u->faction == reisender->faction) || (ucontact(u, reisender)) || (alliedunit(u, reisender->faction, HELP_GUARD))) guard_count = guard_count - u->number; else if (sk >= stealth) { @@ -962,6 +964,8 @@ static bool is_guardian_u(const unit * guard, unit * u, unsigned int mask) return false; if (!cansee(guard->faction, u->region, u, 0)) return false; + if (!u_race(guard)->flags & RCF_FLY && u_race(u)->flags & RCF_FLY) + return false; return true; } From f3cce58be546872b4c445d19ecacc568db832981 Mon Sep 17 00:00:00 2001 From: CTD Date: Tue, 11 Nov 2014 10:53:29 +0100 Subject: [PATCH 3/5] smal fixes for Linux --- src/move.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/move.c b/src/move.c index d8c0f5cd2..cd3f35d15 100644 --- a/src/move.c +++ b/src/move.c @@ -913,7 +913,7 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r) int sk = eff_skill(u, SK_PERCEPTION, r); if (invisible(reisender, u) >= reisender->number) continue; - if (!u_race(u)->flags & RCF_FLY && u_race(reisender)->flags & RCF_FLY) + if (!(u_race(u)->flags & RCF_FLY) && u_race(reisender)->flags & RCF_FLY) continue; if ((u->faction == reisender->faction) || (ucontact(u, reisender)) || (alliedunit(u, reisender->faction, HELP_GUARD))) guard_count = guard_count - u->number; @@ -964,7 +964,7 @@ static bool is_guardian_u(const unit * guard, unit * u, unsigned int mask) return false; if (!cansee(guard->faction, u->region, u, 0)) return false; - if (!u_race(guard)->flags & RCF_FLY && u_race(u)->flags & RCF_FLY) + if (!(u_race(guard)->flags & RCF_FLY) && u_race(u)->flags & RCF_FLY) return false; return true; From c20fb1353240109f1718c260269d2e98979c1a5b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 16 Nov 2014 12:40:08 +0100 Subject: [PATCH 4/5] buildno.h name change --- s/preview | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s/preview b/s/preview index eab88c921..ee0c35089 100755 --- a/s/preview +++ b/s/preview @@ -45,7 +45,7 @@ function assert_dir() { function version() { assert_dir $SOURCE cd $SOURCE -build=$(grep BUILD src/build.h | awk '{ print $3 }') +build=$(grep BUILD src/buildno.h | awk '{ print $3 }') echo "eressea build $build" } From 13b443ebb3f8d1b5d52a38ad06285c2e6e296f5f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 16 Nov 2014 12:46:55 +0100 Subject: [PATCH 5/5] fix crash (null pointer in make_cmd) --- src/build.h | 2 +- src/economy.c | 41 ++++++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/build.h b/src/build.h index 1ab97b086..691d9def3 100644 --- a/src/build.h +++ b/src/build.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 3 -#define VERSION_BUILD 689 +#define VERSION_BUILD 690 diff --git a/src/economy.c b/src/economy.c index 7f4bf506c..3faf3c5d5 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1788,11 +1788,11 @@ static void create_item(unit * u, const item_type * itype, int want) int make_cmd(unit * u, struct order *ord) { region *r = u->region; - const building_type *btype; - const ship_type *stype; - param_t p; - int m; - const item_type *itype; + const building_type *btype = 0; + const ship_type *stype = 0; + const item_type *itype = 0; + param_t p = NOPARAM; + int m = INT_MAX; const char *s; const struct locale *lang = u->faction->locale; char ibuf[16]; @@ -1802,17 +1802,19 @@ int make_cmd(unit * u, struct order *ord) assert(kwd == K_MAKE); s = getstrtoken(); - m = atoi((const char *)s); - sprintf(ibuf, "%d", m); - if (!strcmp(ibuf, (const char *)s)) { - /* first came a want-paramter */ - s = getstrtoken(); + if (s) { + m = atoi((const char *)s); + sprintf(ibuf, "%d", m); + if (!strcmp(ibuf, (const char *)s)) { + /* a quantity was given */ + s = getstrtoken(); + } else { + m = INT_MAX; + } + if (s) { + p = findparam(s, u->faction->locale); + } } - else { - m = INT_MAX; - } - - p = findparam(s, u->faction->locale); if (p == P_ROAD) { plane *pl = rplane(r); @@ -1851,10 +1853,11 @@ int make_cmd(unit * u, struct order *ord) * 'academy of arts', we need to figure out what the player meant. * This is not 100% safe. */ - stype = findshiptype(s, lang); - btype = findbuildingtype(s, lang); - itype = finditemtype(s, lang); - + if (s) { + stype = findshiptype(s, lang); + btype = findbuildingtype(s, lang); + itype = finditemtype(s, lang); + } if (itype != NULL && (btype != NULL || stype != NULL)) { if (itype->construction == NULL) { /* if the item cannot be made, we probably didn't mean to make it */