From 31ca0ce052bf5e26bcbb3fc197eb5e4794cb38c8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Jul 2015 13:42:15 +0200 Subject: [PATCH 1/4] fix a parser crash in the USE command. --- src/laws.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/laws.c b/src/laws.c index 40d224e7f..f85c8c063 100755 --- a/src/laws.c +++ b/src/laws.c @@ -3772,6 +3772,10 @@ int use_cmd(unit * u, struct order *ord) init_order(ord); t = gettoken(token, sizeof(token)); + if (!t) { + cmistake(u, ord, 43, MSG_PRODUCE); + return err; + } n = atoi((const char *)t); if (n == 0) { if (isparam(t, u->faction->locale, P_ANY)) { From a975073c0d686097263cac93269d83650d419642 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Jul 2015 14:39:13 +0200 Subject: [PATCH 2/4] fix an issue when reading pre-spellbook datafiles for E3. --- src/kernel/save.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index fdfe9aad9..928feedf2 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1119,7 +1119,7 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co *bookp = create_spellbook(0); sb = *bookp; } - if (global.data_version >= SPELLBOOK_VERSION || !spellbook_get(sb, sp)) { + if (level>0 && (global.data_version >= SPELLBOOK_VERSION || !spellbook_get(sb, sp))) { spellbook_add(sb, sp, level); } } From bfd93c68b24cf3ed6dd4e2125561dac0eda83b9e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Jul 2015 15:44:21 +0200 Subject: [PATCH 3/4] remove bogus assert --- src/battle.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/battle.c b/src/battle.c index 9761f2978..9608a382e 100644 --- a/src/battle.c +++ b/src/battle.c @@ -2297,7 +2297,6 @@ void do_attack(fighter * af) /* Wir suchen eine beliebige Feind-Einheit aus. An der können * wir feststellen, ob noch jemand da ist. */ int apr, attacks = attacks_per_round(ta); - assert(attacks <= RACE_ATTACKS); if (!count_enemies(b, af, FIGHT_ROW, LAST_ROW, SELECT_FIND)) break; From f054ea114bf529507143d24601386d72d4a706cc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Jul 2015 16:23:38 +0200 Subject: [PATCH 4/4] Bug 1861: increase MAXTEACHERS, warn if it is still too small. --- src/study.c | 7 ++++++- src/study.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/study.c b/src/study.c index 90d838bfb..467939dbf 100644 --- a/src/study.c +++ b/src/study.c @@ -42,6 +42,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include #include #include @@ -217,8 +218,12 @@ bool report, int *academy) } if (index < MAXTEACHERS) teach->teachers[index++] = teacher; - if (index < MAXTEACHERS) + if (index < MAXTEACHERS) { teach->teachers[index] = NULL; + } + else { + log_warning("MAXTEACHERS is too low at %d", MAXTEACHERS); + } teach->value += n; /* Solange Akademien groessenbeschraenkt sind, sollte Lehrer und diff --git a/src/study.h b/src/study.h index dce5c0b34..88a6daa5b 100644 --- a/src/study.h +++ b/src/study.h @@ -32,7 +32,7 @@ extern "C" { extern bool is_migrant(struct unit *u); extern int study_cost(struct unit *u, skill_t talent); -#define MAXTEACHERS 4 +#define MAXTEACHERS 8 typedef struct teaching_info { struct unit *teachers[MAXTEACHERS]; int value;