From b5778f1cfdc89528790fdaa1247b0d1a63d88835 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 8 Apr 2001 17:36:50 +0000 Subject: [PATCH] Updates aus aktueller Version in Dev-Version --- src/Makefile.include | 20 ++++++++++++++-- src/common/gamecode/laws.c | 22 ++++++++++++++++-- src/common/gamecode/report.c | 2 +- src/common/kernel/build.c | 15 +++++++++--- src/common/kernel/magic.c | 3 +-- src/common/kernel/movement.c | 3 +++ src/common/kernel/spell.c | 3 ++- src/eressea/korrektur.c | 45 ++++++++++++++++++++---------------- src/mapper/map_modify.c | 6 +---- src/mapper/mapper.c | 1 - src/mapper/mapper.h | 1 - 11 files changed, 83 insertions(+), 38 deletions(-) diff --git a/src/Makefile.include b/src/Makefile.include index ddeb651e4..18598c2f5 100644 --- a/src/Makefile.include +++ b/src/Makefile.include @@ -25,6 +25,9 @@ LDFLAGS = $(LIBS) LIBS = -L$(PUBLISH_DIR) +LINTFLAGS = -booltype boolean -boolops +posixlib +matchanyintegral \ + -predboolint -retvalint -retvalother -realcompare -exportlocal + ARCHITECTURE = Linux ## @@ -91,6 +94,14 @@ ifeq ($(CONFIG), dmalloc) LIBS += -ldmalloc endif +# ifeq ($(CONFIG), lint) +# BUILD_DIR = Lint-$(ARCHITECTURE) +# CC = lint +# CFLAGS = -I$(ERESSEA) $(INCLUDES) -booltype boolean -boolops +# LDFLAGS = +# LIBS = +# endif + # ## Dependencies @@ -130,10 +141,11 @@ recurse-subdirs-release:: subdirs-release publish-release recurse-subdirs-profile:: subdirs-profile publish-profile recurse-subdirs-dmalloc:: subdirs-dmalloc publish-dmalloc +recurse-lint:: lint recurse-clean:: clean recurse-depend:: depend -subdirs-debug subdirs-release subdirs-profile subdirs-dmalloc clean depend:: +subdirs-debug subdirs-release subdirs-profile subdirs-dmalloc lint clean depend:: @mkdir -p $(PUBLISH_DIR) @if [ -n "$(SUBDIRS)" ]; then \ for subdir in x-placeholder-dir $(SUBDIRS); do \ @@ -153,7 +165,10 @@ publish-dmalloc:: subdirs-dmalloc publish-debug publish-release publish-profile publish-dmalloc:: $(PUBLISH_DIR)/$(LIBRARY) $(PUBLISH_DIR)/$(BINARY) clean:: $(BUILD_DIR) $(PUBLISH_DIR) - rm -fr Release-$(ARCHITECTURE)/* Debug-$(ARCHITECTURE)/* Profile-$(ARCHITECTURE)/* Dmalloc-$(ARCHITECTURE)/* + rm -fr Release-$(ARCHITECTURE)/* Debug-$(ARCHITECTURE)/* Profile-$(ARCHITECTURE)/* Dmalloc-$(ARCHITECTURE)/* Lint-$(ARCHITECTURE)/* + +lint:: + $(LINT) -I$(ERESSEA) $(INCLUDES) $(LINTFLAGS) *.c $(BUILD_DIR) $(PUBLISH_DIR): @mkdir $@ @@ -174,3 +189,4 @@ ifeq ($(CONVERT_TRIGGERS), 1) CFLAGS += -DCONVERT_TRIGGER INCLUDES += -I. -I$(ERESSEA)/eressea/old endif + diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 9b6faba45..067b77808 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -364,7 +364,7 @@ live(region * r) void calculate_emigration(region *r) { - direction_t i; + direction_t i, j; int maxpeasants_here; int maxpeasants[MAXDIRECTIONS]; double wfactor, gfactor; @@ -387,6 +387,7 @@ calculate_emigration(region *r) if (fval(r, RF_ORCIFIED)==fval(c, RF_ORCIFIED)) { if (landregion(rterrain(c)) && landregion(rterrain(r))) { int wandering_peasants; + double vfactor; /* First let's calculate the peasants who wander off to less inhabited * regions. wfactor indicates the difference of population denity. @@ -405,8 +406,25 @@ calculate_emigration(region *r) gfactor = max(gfactor, 0); gfactor = min(gfactor, 1); + /* This calculates the influence of volcanos on peasant + * migration. */ + + if(rterrain(c) != T_VOLCANO) { + vfactor = 0.25; + } else { + vfactor = 1.00; + } + + for(j=0; j != MAXDIRECTIONS; j++) { + region *rv = rconnect(c, j); + if(rv && rterrain(rv) == T_VOLCANO) { + vfactor *= 0.5; + break; + } + } + wandering_peasants = (int) (rpeasants(r) * (gfactor + wfactor) - * PEASANTSWANDER_WEIGHT / 100.0); + * vfactor * PEASANTSWANDER_WEIGHT / 100.0); r->land->newpeasants -= wandering_peasants; c->land->newpeasants += wandering_peasants; diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 02e53603c..7386e9efc 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -1715,7 +1715,7 @@ report(FILE *F, faction * f) dh = 0; for(a=a_find(f->attribs, &at_faction_special); a; a=a->nexttype) { dh++; - if(fspecials[a->data.sa[0]].maxlevel) { + if(fspecials[a->data.sa[0]].maxlevel != 100) { sprintf(buf2, "%s (%d)", fspecials[a->data.sa[0]].name, a->data.sa[1]); } else { sprintf(buf2, "%s", fspecials[a->data.sa[0]].name); diff --git a/src/common/kernel/build.c b/src/common/kernel/build.c index 4adca8cfb..7a58dd77b 100644 --- a/src/common/kernel/build.c +++ b/src/common/kernel/build.c @@ -602,7 +602,8 @@ build(unit * u, const construction * ctype, int completed, int want) while (type->improvement!=NULL && type->improvement!=type && type->maxsize>0 && - type->maxsize<=completed) { + type->maxsize<=completed) + { completed -= type->maxsize; type = type->improvement; } @@ -763,9 +764,17 @@ build_building(unit * u, const building_type * btype, int want) if (b) built = b->size; if (want<=0 || want == INT_MAX) { if(b == NULL) { - want = btype->maxsize - built; + if(btype->maxsize > 0) { + want = btype->maxsize - built; + } else { + want = INT_MAX; + } } else { - want = b->type->maxsize - built; + if(b->type->maxsize > 0) { + want = b->type->maxsize - built; + } else { + want = INT_MAX; + } } } built = build(u, btype->construction, built, want); diff --git a/src/common/kernel/magic.c b/src/common/kernel/magic.c index 2cecad281..617fe2563 100644 --- a/src/common/kernel/magic.c +++ b/src/common/kernel/magic.c @@ -1,6 +1,5 @@ /* vi: set ts=2: * - * $Id: magic.c,v 1.12 2001/03/07 15:00:18 corwin Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -1480,7 +1479,7 @@ regeneration_magiepunkte(void) if (aura < auramax) { struct building * b = inside_building(u); const struct building_type * btype = b?b->type:NULL; - reg_aura = regeneration(u); + reg_aura = (double)regeneration(u); /* Magierturm erhöht die Regeneration um 50% */ if (btype == &bt_magictower) { diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index fc5f2d33c..b9a70eca5 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -1,5 +1,6 @@ /* vi: set ts=2: * + * $Id: movement.c,v 1.17 2001/04/08 17:36:48 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -2125,6 +2126,8 @@ follow(void) unit * uf = findunit(id); if (!a) { a = a_add(&u->attribs, make_follow(uf)); + } else { + a->data.v = uf; } } else if (a) { a_remove(&u->attribs, a); diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index 24175c4f8..023bbc766 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -1,5 +1,6 @@ /* vi: set ts=2: * + * $Id: spell.c,v 1.17 2001/04/08 17:36:48 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -3554,7 +3555,7 @@ sp_bloodsacrifice(castorder *co) return 0; } - get_mage(mage)->spellpoints += aura; + change_spellpoints(mage, aura); use_pooled(mage, mage->region, R_HITPOINTS, damage); add_message(&mage->faction->msgs, new_message(mage->faction, diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index 52ba6b7e4..c61bcabc4 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -1023,7 +1023,7 @@ show_newspells(void) * terminieren */ spellid_t newspellids[] = { - }; + SPL_NOSPELL }; /* die id's der neuen oder veränderten Sprüche werden in newspellids[] * abgelegt */ @@ -1596,32 +1596,36 @@ stats(void) static void fix_prices(void) { - FILE *fp; - char buf[256]; - char *token; - int x, y, p, i; region *r; puts(" - Korrigiere Handelsgüterpreise"); - fp = fopen("prices.fix", "r"); - if (fp==NULL) return; - - while(fgets(buf, 256, fp)!=NULL) { - token = strtok(buf, ":"); /* Name */ - token = strtok(NULL, ":"); x = atoi(token); - token = strtok(NULL, ":"); y = atoi(token); - r = findregion(x, y); - assert(r != NULL); - if(r->land) { - for(i = 0; oldluxurytype[i]!=NULL; i++) { - token = strtok(NULL, ":"); p = atoi(token); - r_setdemand(r, oldluxurytype[i], p); + for(r=regions; r; r=r->next) if(r->land) { + int sales = 0, buys = 0; + const luxury_type *sale, *ltype; + struct demand *dmd; + for (dmd=r->land->demands;dmd;dmd=dmd->next) { + if(dmd->value == 0) { + sales++; + sale = dmd->type; + } else { + buys++; + } + } + if(sales == 0) { + int c = 0; + for(ltype=luxurytypes; ltype; ltype=ltype->next) c++; + c = rand()%c; + for(ltype=luxurytypes; c>0; c--) ltype=ltype->next; + r_setdemand(r, ltype, 0); + sale = ltype; + } + if(buys == 0) { + for(ltype=luxurytypes; ltype; ltype=ltype->next) { + if(ltype != sale) r_setdemand(r, ltype, 1 + rand() % 5); } } } - - fclose(fp); } static void @@ -2171,6 +2175,7 @@ korrektur(void) do_once(atoi36("fhrb"), fix_herbs()); do_once(atoi36("ftos"), fix_timeouts()); do_once(atoi36("gmtst"), test_gmquest()); /* test gm quests */ + do_once(atoi36("fixsl"), fix_prices()); #ifndef SKILLFIX_SAVE fix_skills(); #endif diff --git a/src/mapper/map_modify.c b/src/mapper/map_modify.c index 9e73ded77..dca0769cb 100644 --- a/src/mapper/map_modify.c +++ b/src/mapper/map_modify.c @@ -1,6 +1,5 @@ /* vi: set ts=2: * - * $Id: map_modify.c,v 1.8 2001/04/01 06:58:44 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -1143,10 +1142,7 @@ settg(region *r) if (tradegood==NULL) tradegood = luxurytypes; for (ltype=luxurytypes; ltype; ltype=ltype->next) { - struct demand * dmd; - dmd = calloc(sizeof(struct demand), 1); - dmd->type = ltype; - if (ltype!=tradegood) dmd->value = 1 + rand() % 5; + if (ltype!=tradegood) r_setdemand(r, ltype, 1 + rand() % 5); ++g; } r_setdemand(r, tradegood, 0); diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index f118eb7a7..36bf1e8d8 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -1,6 +1,5 @@ /* vi: set ts=2: * - * $Id: mapper.c,v 1.14 2001/04/01 06:58:44 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) diff --git a/src/mapper/mapper.h b/src/mapper/mapper.h index 33ccd0280..faa7b51b4 100644 --- a/src/mapper/mapper.h +++ b/src/mapper/mapper.h @@ -1,6 +1,5 @@ /* vi: set ts=2: * - * $Id: mapper.h,v 1.5 2001/04/01 06:58:44 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)