From 200201b384608f531ee744480352a38f7d941ea6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 27 Jul 2005 11:48:16 +0000 Subject: [PATCH] started limiting the maximum number of orders for a unit. removed num_migrants as it was not updated properly. --- src/common/kernel/eressea.c | 9 ++------- src/common/kernel/faction.h | 1 - src/common/kernel/save.c | 17 +++++++++++++++-- src/common/kernel/unit.c | 6 ------ src/eressea/korrektur.c | 1 - src/mapper/logging.c | 8 ++++---- src/mapper/map_modify.c | 2 +- src/mapper/mapper.c | 21 ++++++++++++--------- src/mapper/mapper.h | 2 +- 9 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index e19bfabaf..dcde05d1f 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -1209,7 +1209,7 @@ count_all(const faction * f) } if (f->num_people != n) { log_error(("Anzahl Personen für (%s) ist != num_people: %d statt %d.\n", - factionid(f), f->num_migrants, n)); + factionid(f), f->num_people, n)); return n; } #endif @@ -1231,13 +1231,8 @@ count_migrants (const faction * f) } u = u->nextF; } - if (f->num_migrants != n) { - log_error(("Anzahl Migranten für (%s) ist != num_migrants: %d statt %d.\n", - factionid(f), f->num_migrants, n)); - return n; - } #endif - return f->num_migrants; + return n; } int diff --git a/src/common/kernel/faction.h b/src/common/kernel/faction.h index bf85d8617..68491ec20 100644 --- a/src/common/kernel/faction.h +++ b/src/common/kernel/faction.h @@ -68,7 +68,6 @@ typedef struct faction { const struct race * race; magic_t magiegebiet; int newbies; - int num_migrants; /* Anzahl Migranten */ int num_people; /* Anzahl Personen ohne Monster */ int num_total; /* Anzahl Personen mit Monstern */ int options; diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index b0e7ef7e3..9b9a8162a 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -75,6 +75,8 @@ #define COMMENT_CHAR ';' #define ESCAPE_FIX +#define MAXORDERS 256 +#define MAXPERSISTENT 16 /* exported symbols symbols */ const char * xmlfile = "eressea.xml"; @@ -1024,7 +1026,7 @@ readunit(FILE * F) herb_t herb; potion_t potion; unit * u; - int number, n; + int number, n, p; n = rid(F); u = findunit(n); @@ -1114,9 +1116,20 @@ readunit(FILE * F) /* Persistente Befehle einlesen */ free_orders(&u->orders); freadstr(F, buf, sizeof(buf)); + p = n = 0; while (*buf != 0) { order * ord = parse_order(buf, u->faction->locale); - if (ord!=NULL) addlist(&u->orders, ord); + if (ord!=NULL) { + if (++norders, ord); + } else if (p==MAXPERSISTENT) { + log_error(("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT)); + } + } else if (n==MAXORDERS) { + log_error(("%s had %d or more orders\n", unitname(u), MAXPERSISTENT)); + } + } freadstr(F, buf, sizeof(buf)); } if (global.data_versionfaction != 0 || u->number > 0); #endif - if (u->faction && u->race != u->faction->race && playerrace(u->race) - && u->race != new_race[RC_SPELL] && u->race != new_race[RC_SPECIAL] - && !(is_cursed(u->attribs, C_SLAVE, 0))) - { - u->faction->num_migrants += count - u->number; - } if (playerrace(u->race)) { u->faction->num_people += count - u->number; diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index 6be303373..02210281c 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -242,7 +242,6 @@ no_teurefremde(boolean convert) if (convert) { u->race = u->faction->race; u->irace = u->faction->race; - u->faction->num_migrants -= u->number; sprintf(buf, "Die Götter segnen %s mit der richtigen Rasse", unitname(u)); addmessage(0, u->faction, buf, MSG_MESSAGE, ML_IMPORTANT); diff --git a/src/mapper/logging.c b/src/mapper/logging.c index 2c9deec3d..11ab39cab 100644 --- a/src/mapper/logging.c +++ b/src/mapper/logging.c @@ -40,10 +40,10 @@ log_read(const char * filename) while (!feof(log)) { if(fscanf(log, "%s", buf) == EOF) break; if (strcmp(buf, "UNIT")==0) { - int x, y; + short x, y; unit * u; region * r; - fscanf(log, "%s %d %d", buf, &x, &y); + fscanf(log, "%s %hd %hd", buf, &x, &y); u = readunit(log); r = findregion(x, y); if (r==NULL) { @@ -52,8 +52,8 @@ log_read(const char * filename) } if (u->region!=r) move_unit(u, r, NULL); } else if (strcmp(buf, "REGION")==0) { - int x, y; - fscanf(log, "%d %d", &x, &y); + short x, y; + fscanf(log, "%hd %hd", &x, &y); readregion(log, x, y); } else if (strcmp(buf, "FACTION")==0) { faction * f; diff --git a/src/mapper/map_modify.c b/src/mapper/map_modify.c index e8d950430..de8afcaa1 100644 --- a/src/mapper/map_modify.c +++ b/src/mapper/map_modify.c @@ -88,7 +88,7 @@ static terrain_t newblock[BLOCKSIZE][BLOCKSIZE]; static int g_maxluxuries; void -block_create(int x1, int y1, int size, char chaotisch, int special, char terrain) +block_create(short x1, short y1, int size, char chaotisch, int special, char terrain) { int local_climate, k; short x, y; diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index 9330527a7..10f2aa189 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -128,7 +128,8 @@ signal_init(void) } #endif /* ndef Win32 */ -int left = 0, top = 0, breit, hoch, tx=-999, ty=-999; +short left = 0, top = 0, tx=-999, ty=-999; +int breit, hoch; int MINX=0, MINY=0, MAXX=0, MAXY=0; boolean minimapx=false,minimapy=false; /* Karte nicht vert./hor. scrollen */ @@ -165,21 +166,23 @@ init_win(int x, int y) { clear(); refresh(); - breit=(SX-45)/2; hoch=SY-6; + breit = (short)(SX-45)/2; hoch = (short)SY-6; if (breit > MAXX-MINX+(MAXY-MINY)/2) { - left=MINX-(breit-MAXX-MINX)/2+y/2; - breit=MAXX-MINX+(MAXY-MINY)/2; + left = (short)(MINX-(breit-MAXX-MINX)/2+y/2); + breit = MAXX-MINX+(MAXY-MINY)/2; minimapx=true; } else { - left=x-breit/2+y/2; + left = (short)(x-breit/2+y/2); } if (hoch > MAXY-MINY) { minimapy=true; - top=MAXY+(hoch-MAXY-MINY)/2; - hoch=MAXY-MINY; - } else top=y+hoch/2; + top = (short)(MAXY+(hoch-MAXY-MINY)/2); + hoch = MAXY-MINY; + } else { + top = (short)(y+hoch/2); + } /* breit=(SX-45)/2; hoch=SY-6; */ /* zum Darstellen schon alles nehmen */ } @@ -406,7 +409,7 @@ drawmap(boolean maponly) { chtype rs; region *r; - x1=left; y1=top; + x1 = left; y1=top; if(maponly == false) { movexy(SX-36,SY-2); sprintf(buf, "%d gesetzt, %d Rest, %d Dropouts", numnewbies, listlen(newfactions), listlen(dropouts)); diff --git a/src/mapper/mapper.h b/src/mapper/mapper.h index 791ffc49a..89e8af547 100644 --- a/src/mapper/mapper.h +++ b/src/mapper/mapper.h @@ -115,7 +115,7 @@ typedef struct selection { struct selection * do_selection(struct selection * sel, const char * title, void (*perform)(struct selection *, void *), void * data); struct selection ** push_selection(struct selection ** p_sel, char * str, void * payload); void insert_selection(struct selection ** p_sel, struct selection * prev, char * str, void * payload); -void block_create(int x1, int y1, int size, char chaotisch, int special, char terrain); +void block_create(short x1, short y1, int size, char chaotisch, int special, char terrain); extern void read_orders(const char * filename); extern void read_dropouts(const char *filename);