From 7208bc388f17808691d04e11d2e944b960a6b717 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 24 May 2004 13:22:43 +0000 Subject: [PATCH] http://eressea.upb.de/mantis/bug_view_page.php?bug_id=0000038 - bei mehereren Lehrern kriegen alle eine Meldung, nicht nur der letzte --- src/common/gamecode/study.c | 43 +++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/common/gamecode/study.c b/src/common/gamecode/study.c index 4691b3251..cfedd095f 100644 --- a/src/common/gamecode/study.c +++ b/src/common/gamecode/study.c @@ -26,30 +26,30 @@ #include "eressea.h" #include "alchemy.h" -#include "item.h" -#include "faction.h" -#include "magic.h" #include "building.h" -#include "race.h" -#include "pool.h" -#include "region.h" -#include "unit.h" -#include "skill.h" -#include "message.h" -#include "plane.h" +#include "faction.h" +#include "item.h" #include "karma.h" -#include "rand.h" +#include "magic.h" +#include "message.h" #include "movement.h" +#include "plane.h" +#include "pool.h" +#include "race.h" +#include "rand.h" +#include "region.h" +#include "skill.h" +#include "unit.h" /* util includes */ #include /* libc includes */ -#include -#include -#include -#include #include +#include +#include +#include +#include #include #define TEACHNUMBER 10 @@ -132,9 +132,10 @@ study_cost(unit *u, int talent) /* ------------------------------------------------------------- */ +#define MAXTEACHERS 4 typedef struct teaching_info { - unit * teachers[4]; - int value; + unit * teachers[MAXTEACHERS]; + int value; } teaching_info; static void @@ -193,10 +194,10 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk, a = a_add(&student->attribs, a_new(&at_learning)); teach = (teaching_info*)a->data.v; } else { - while (teach->teachers[index]) ++index; + while (teach->teachers[index] && index!=MAXTEACHERS) ++index; } - teach->teachers[index] = teacher; - teach->teachers[index+1] = NULL; + if (indexteachers[index++] = teacher; + if (indexteachers[index] = NULL; teach->value += n; /* Solange Akademien größenbeschränkt sind, sollte Lehrer und @@ -705,7 +706,7 @@ learn(void) if (a!=NULL) { if (teach!=NULL) { int index = 0; - while (teach->teachers[index]) { + while (teach->teachers[index] && index!=MAXTEACHERS) { unit * teacher = teach->teachers[index++]; if (teacher->faction != u->faction) { add_message(&u->faction->msgs, msg_message("teach_student",