- bei mehereren Lehrern kriegen alle eine Meldung, nicht nur der letzte
This commit is contained in:
Enno Rehling 2004-05-24 13:22:43 +00:00
parent ccf0fe9bf7
commit 7208bc388f
1 changed files with 22 additions and 21 deletions

View File

@ -26,30 +26,30 @@
#include "eressea.h" #include "eressea.h"
#include "alchemy.h" #include "alchemy.h"
#include "item.h"
#include "faction.h"
#include "magic.h"
#include "building.h" #include "building.h"
#include "race.h" #include "faction.h"
#include "pool.h" #include "item.h"
#include "region.h"
#include "unit.h"
#include "skill.h"
#include "message.h"
#include "plane.h"
#include "karma.h" #include "karma.h"
#include "rand.h" #include "magic.h"
#include "message.h"
#include "movement.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 */ /* util includes */
#include <base36.h> #include <base36.h>
/* libc includes */ /* libc includes */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <assert.h> #include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h> #include <math.h>
#define TEACHNUMBER 10 #define TEACHNUMBER 10
@ -132,9 +132,10 @@ study_cost(unit *u, int talent)
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
#define MAXTEACHERS 4
typedef struct teaching_info { typedef struct teaching_info {
unit * teachers[4]; unit * teachers[MAXTEACHERS];
int value; int value;
} teaching_info; } teaching_info;
static void 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)); a = a_add(&student->attribs, a_new(&at_learning));
teach = (teaching_info*)a->data.v; teach = (teaching_info*)a->data.v;
} else { } else {
while (teach->teachers[index]) ++index; while (teach->teachers[index] && index!=MAXTEACHERS) ++index;
} }
teach->teachers[index] = teacher; if (index<MAXTEACHERS) teach->teachers[index++] = teacher;
teach->teachers[index+1] = NULL; if (index<MAXTEACHERS) teach->teachers[index] = NULL;
teach->value += n; teach->value += n;
/* Solange Akademien größenbeschränkt sind, sollte Lehrer und /* Solange Akademien größenbeschränkt sind, sollte Lehrer und
@ -705,7 +706,7 @@ learn(void)
if (a!=NULL) { if (a!=NULL) {
if (teach!=NULL) { if (teach!=NULL) {
int index = 0; int index = 0;
while (teach->teachers[index]) { while (teach->teachers[index] && index!=MAXTEACHERS) {
unit * teacher = teach->teachers[index++]; unit * teacher = teach->teachers[index++];
if (teacher->faction != u->faction) { if (teacher->faction != u->faction) {
add_message(&u->faction->msgs, msg_message("teach_student", add_message(&u->faction->msgs, msg_message("teach_student",