From 10cba7ae110868f9f9e843c6be64add596a0f856 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 25 Feb 2001 19:31:40 +0000 Subject: [PATCH] einbau der bugfixes aus dem aktuellen beta-branch in die dev-version --- src/common/gamecode/creport.c | 11 +- src/common/gamecode/economy.c | 6 +- src/common/gamecode/laws.c | 24 ++++- src/common/kernel/eressea.c | 7 +- src/common/kernel/eressea.h | 1 + src/common/kernel/item.h | 10 +- src/common/kernel/save.c | 28 ++---- src/common/triggers/killunit.c | 11 +- src/common/triggers/timeout.c | 5 +- src/common/util/umlaut.c | 34 +++++-- src/eressea/korrektur.c | 177 +++++++++++++++++++++++++++++++-- src/res/de/messages.txt | 3 +- 12 files changed, 247 insertions(+), 70 deletions(-) diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index 6f8bbd768..745aa1a66 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: creport.c,v 1.10 2001/02/24 12:50:47 enno Exp $ + * $Id: creport.c,v 1.11 2001/02/25 19:31:38 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) @@ -53,6 +53,7 @@ #include #include #include +#include /* util includes */ #include @@ -495,13 +496,7 @@ cr_output_unit(FILE * F, region * r, fprintf(F, "COMMANDS\n"); if(u->lastorder[0]) fprintf(F, "\"%s\"\n", u->lastorder); for (S = u->orders; S; S = S->next) { - switch (igetkeyword(S->s)) { - case K_LIEFERE: - case K_DEFAULT: - case K_RESERVE: - case K_KOMMENTAR: - case K_BUY: - case K_SELL: + if(is_persistent(S->s)) { fprintf(F, "\"%s\"\n", S->s); } } diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index c1da0eb38..e4ba50256 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: economy.c,v 1.7 2001/02/18 10:06:08 enno Exp $ + * $Id: economy.c,v 1.8 2001/02/25 19:31:38 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) @@ -827,7 +827,7 @@ dogive(region * r, unit * u, strlist * S, boolean liefere) /* if ((race[u->race].ec_flags & NOGIVE) || fval(u,FL_LOCKED)) {*/ if (race[u->race].ec_flags & NOGIVE) { - sprintf(buf, "%s geben nichts weg.", race[u->race].name[1]); + sprintf(buf, "%s geben nichts weg", race[u->race].name[1]); mistake(u, S->s, buf, MSG_COMMERCE); return; } @@ -840,7 +840,7 @@ dogive(region * r, unit * u, strlist * S, boolean liefere) /* Übergabe aller Kräuter */ if (findparam(s) == P_HERBS) { if (!(race[u->race].ec_flags & GIVEITEM)) { - sprintf(buf, "%s geben nichts weg.", race[u->race].name[1]); + sprintf(buf, "%s geben nichts weg", race[u->race].name[1]); mistake(u, S->s, buf, MSG_COMMERCE); return; } diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 8982cf9c1..15d6fd695 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: laws.c,v 1.28 2001/02/18 19:07:31 katze Exp $ + * $Id: laws.c,v 1.29 2001/02/25 19:31:38 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) @@ -1992,9 +1992,22 @@ instant_orders(void) s = getstrtoken(); if(findparam(s) == P_ANY) { - s = getstrtoken(); - if(findparam(s) == P_ZAUBER) { + param_t p = getparam(); + + if(p == P_ZAUBER) { a_removeall(&u->faction->attribs, &at_seenspell); + } else if(p == P_POTIONS) { + int skill = effskill(u, SK_ALCHEMY); + potion_type *pt; + int c = 0; + for(pt = potiontypes; pt; pt=pt->next) { + if(pt->level * 2 <= skill) { + c += display_potion(u->faction, u, pt); + } + } + if(c == 0) { + cmistake(u, S->s, 285, MSG_EVENT); + } } else { cmistake(u, S->s, 222, MSG_EVENT); } @@ -3004,9 +3017,10 @@ processorders (void) puts(" - Jihads setzen"); set_jihad(); - puts(" - neue Nummern und Reihenfolge"); - renumber(); + puts(" - Einheiten Sortieren"); reorder(); + puts(" - Neue Nummern"); + renumber(); puts(" - GM Kommandos"); gmcommands(); diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index c377065a5..e70343311 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: eressea.c,v 1.22 2001/02/24 12:50:48 enno Exp $ + * $Id: eressea.c,v 1.23 2001/02/25 19:31:39 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) @@ -109,7 +109,7 @@ const char *parameters[MAXPARAMS] = "REGION", "SCHIFF", "SILBER", - "Straßen", + "STRAßEN", "TEMPORÄRE", "FEIND", "FREUND", @@ -133,7 +133,8 @@ const char *parameters[MAXPARAMS] = "HINTER", "VOR", "ANZAHL", - "GEGENSTÄNDE" + "GEGENSTÄNDE", + "TRÄNKE" }; diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index dbb1a4f77..a8109f9b1 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -483,6 +483,7 @@ enum { P_BEFORE, P_NUMBER, P_ITEMS, + P_POTIONS, MAXPARAMS, NOPARAM = (param_t) - 1 }; diff --git a/src/common/kernel/item.h b/src/common/kernel/item.h index 25bc1730c..54fa73c34 100644 --- a/src/common/kernel/item.h +++ b/src/common/kernel/item.h @@ -125,7 +125,6 @@ typedef struct item_type { /* --- functions --- */ int (*use)(struct unit * user, const struct item_type * itype, const char * cmd); int (*give)(const struct unit * src, const struct unit * dest, const struct item_type * itm, int number, const char * cmd); - /* --- pointers --- */ struct item_type * next; } item_type; @@ -133,28 +132,25 @@ extern item_type * itemtypes; extern const item_type * finditemtype(const char * name, const struct locale * lang); typedef struct luxury_type { + struct luxury_type * next; const item_type * itype; int price; - /* --- pointers --- */ - struct luxury_type * next; } luxury_type; extern luxury_type * luxurytypes; typedef struct herb_type { + struct herb_type * next; const item_type * itype; terrain_t terrain; - /* --- pointers --- */ - struct herb_type * next; } herb_type; extern herb_type * herbtypes; typedef struct potion_type { + struct potion_type * next; const item_type * itype; int level; const char * text; int (*use)(struct unit *, const struct potion_type *, const char *); - /* --- pointers --- */ - struct potion_type * next; } potion_type; extern potion_type * potiontypes; diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index eaacb818c..d73baa64f 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: save.c,v 1.22 2001/02/24 12:50:48 enno Exp $ + * $Id: save.c,v 1.23 2001/02/25 19:31:39 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) @@ -100,8 +100,6 @@ rns(FILE * f, char *c, size_t size) extern unsigned int __at_hashkey(const char* s); -/* ------------------------------------------------------------- */ - FILE * cfopen(const char *filename, const char *mode) { @@ -208,26 +206,20 @@ rsf(FILE * F, char *s, size_t len) static void rs(FILE * F, char *s) { - while (nextc != '"') { - if (nextc == EOF) { - puts("Die Datei bricht vorzeitig ab."); - abort(); - } + boolean apos = false; + while (isspace(nextc)) rc(F); + if (nextc=='"') { + apos=true; rc(F); } - - rc(F); - - while (nextc != '"') { - if (nextc == EOF) { - puts("Die Datei bricht vorzeitig ab."); - abort(); - } + for (;;) { + if (nextc=='"') { + rc(F); + break; + } else if (!apos && isspace(nextc)) break; *s++ = (char)nextc; rc(F); } - - rc(F); *s = 0; } diff --git a/src/common/triggers/killunit.c b/src/common/triggers/killunit.c index ccc01f4d8..d8b076eae 100644 --- a/src/common/triggers/killunit.c +++ b/src/common/triggers/killunit.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: killunit.c,v 1.2 2001/01/26 16:19:41 enno Exp $ + * $Id: killunit.c,v 1.3 2001/02/25 19:31:39 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) @@ -48,18 +48,13 @@ static void killunit_write(const trigger * t, FILE * F) { unit * u = (unit*)t->data.v; - fprintf(F, "%s ", itoa36(u->no)); + write_unit_reference(u, F); } static int killunit_read(trigger * t, FILE * F) { - char zId[10]; - int i; - fscanf(F, "%s", zId); - i = atoi36(zId); - t->data.v = findunit(i); - if (t->data.v==NULL) ur_add((void*)i, &t->data.v, resolve_unit); + read_unit_reference((unit**)&t->data.v, F); return 1; } diff --git a/src/common/triggers/timeout.c b/src/common/triggers/timeout.c index 85e4575a9..f1b4a1b4a 100644 --- a/src/common/triggers/timeout.c +++ b/src/common/triggers/timeout.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: timeout.c,v 1.3 2001/02/20 22:54:05 enno Exp $ + * $Id: timeout.c,v 1.4 2001/02/25 19:31:39 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) @@ -55,9 +55,10 @@ timeout_handle(trigger * t, void * data) timeout_data * td = (timeout_data*)t->data.v; if (--td->timer==0) { handle_triggers(&td->triggers, NULL); + return -1; } unused(data); - return td->timer; + return 0; } static void diff --git a/src/common/util/umlaut.c b/src/common/util/umlaut.c index b17d10e9e..92b0f5571 100644 --- a/src/common/util/umlaut.c +++ b/src/common/util/umlaut.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: umlaut.c,v 1.7 2001/02/17 15:52:47 enno Exp $ + * $Id: umlaut.c,v 1.8 2001/02/25 19:31:39 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) @@ -63,7 +63,7 @@ addtoken(tnode * root, const char* str, void * id) if (c<'a' || c>'z') c = (char)tolower((unsigned char)c); index = ((unsigned char)c) % 32; next = root->next[index]; - if (!root->flags) root->id = id; + if (!(root->flags & LEAF)) root->id = id; while (next && next->c != c) next = next->nexthash; if (!next) { tref * ref; @@ -121,10 +121,32 @@ findtoken(tnode * tk, const char * str, void **result) tk = ref->node; } if (tk) { - if (tk->flags & LEAF || !(tk->flags & SHARED)) { - *result = tk->id; - return E_TOK_SUCCESS; - } + *result = tk->id; + return E_TOK_SUCCESS; } return E_TOK_NOMATCH; } + +#ifdef TEST_UMLAUT +#include +tnode root; + +int +main(int argc, char ** argv) +{ + char buf[1024]; + int i = 0; + for (;;) { + int k; + fgets(buf, sizeof(buf), stdin); + buf[strlen(buf)-1]=0; + if (findtoken(&root, buf, (void**)&k)==0) { + printf("%s returned %d\n", buf, k); + } else { + addtoken(&root, buf, (void*)++i); + printf("added %s=%d\n", buf, i); + } + } + return 0; +} +#endif diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index 4e1fc3e7b..b41e2021e 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: korrektur.c,v 1.28 2001/02/20 22:54:05 enno Exp $ + * $Id: korrektur.c,v 1.29 2001/02/25 19:31:39 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) @@ -53,6 +53,7 @@ /* util includes */ #include +#include #include #include #include @@ -1927,7 +1928,8 @@ undo_deadpeasants(void) } #endif -void +#if 0 +static void fix_targetregion_resolve(void) { region *r; @@ -1941,18 +1943,71 @@ fix_targetregion_resolve(void) } } } +#endif -void -fix_baumringel(void) +static void +fix_herbs(void) { + const char * plain_herbs[] = {"Flachwurz", "Würziger Wagemut", "Eulenauge", "Grüner Spinnerich", "Blauer Baumringel", "Elfenlieb"}; + const herb_type * htypes[6]; + int herbs[6]; + int hneed[6]; region *r; - const item_type *itype = finditemtype("Blauer Baumringel", NULL); - const herb_type *htype = resource2herb(itype->rtype); + int i, hsum = 0, left = 0; - for(r=regions; r; r=r->next) { - if(rterrain(r) == T_PLAIN && rand()%6 == 5) { - rsetherbtype(r, htype); + for (i=0;i!=6;++i) { + htypes[i] = resource2herb(finditemtype(plain_herbs[i], NULL)->rtype); + herbs[i] = 0; + } + + for (r=regions; r; r=r->next) if (rterrain(r) == T_PLAIN) { + const herb_type *htype = rherbtype(r); + assert(htype); + for (i=0;i!=6;++i) if (htypes[i]==htype) break; + assert(i!=6); + herbs[i]++; + hsum++; + } + + for (i=0;i!=6;++i) { + int hwant = hsum / (6-i); + hneed[i] = hwant - herbs[i]; + if (hneed[i]>0) left += hneed[i]; + hsum -= hwant; + } + + for (r=regions; r; r=r->next) if (rterrain(r) == T_PLAIN) { + const herb_type *htype = rherbtype(r); + assert(htype); + for (i=0;i!=6;++i) if (htypes[i]==htype) break; + assert(i!=6); + if (hneed[i]<0) { + int p; + int k = rand() % left; + for (p=0;p!=6;++p) if (hneed[p]>0) { + k-=hneed[p]; + if (k<0) break; + } + assert(p!=6); + hneed[p]--; + hneed[i]++; + left--; + rsetherbtype(r, htypes[p]); } + hsum++; + } + + for (i=0;i!=6;++i) herbs[i] = 0; + + for (r=regions; r; r=r->next) if (rterrain(r) == T_PLAIN) { + const herb_type *htype = rherbtype(r); + assert(htype); + for (i=0;i!=6;++i) if (htypes[i]==htype) break; + assert(i!=6); + herbs[i]++; + } + for (i=0;i!=6;++i) { + fprintf(stderr, "%s : %d\n", locale_string(NULL, resourcename(htypes[i]->itype->rtype, 0)), herbs[i]); } } @@ -1972,6 +2027,108 @@ set_atgm(faction * f) } #endif +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct handler_info { + char * event; + trigger * triggers; +} handler_info; + + +typedef struct timeout_data { + trigger * triggers; + int timer; + variant trigger_data; +} timeout_data; + +trigger * +get_timeout(trigger * td, trigger * tfind) +{ + trigger * t = td; + while (t) { + if (t->type==&tt_timeout) { + timeout_data * tdata = (timeout_data *)t->data.v; + trigger * tr = tdata->triggers; + while (tr) { + if (tr==tfind) break; + tr=tr->next; + } + if (tr==tfind) break; + } + t=t->next; + } + return t; +} + +static void +fix_timeouts(void) +{ + region * r; + for (r=regions;r;r=r->next) { + unit * u; + for (u=r->units;u;u=u->next) { + attrib * a = a_find(u->attribs, &at_eventhandler); + boolean toad = (u->race==RC_TOAD); + boolean keeper = (u->race==RC_IRONKEEPER); + while (a!=NULL) { + trigger * t; + handler_info * td = (handler_info *)a->data.v; + for (t=td->triggers;t;t=t->next) { + trigger ** tptr=&t->next; + while (*tptr) { + /* remove duplicates */ + if ((*tptr)->type==t->type) { + *tptr = (*tptr)->next; + } else tptr = &(*tptr)->next; + } + if (t->type == &tt_changerace || + t->type == &tt_changefaction || + t->type == &tt_createcurse || + t->type == &tt_createunit) + { + trigger * timer = get_timeout(td->triggers, t); + if (toad && t->type == &tt_changerace) { + toad = false; + } + if (timer==NULL) { + add_trigger(&u->attribs, "timer", trigger_timeout(1+(rand()%2), t)); + } + } + else if (t->type == &tt_killunit) { + if (u->race==RC_IRONKEEPER) { + trigger * timer = get_timeout(td->triggers, t); + keeper = false; + if (timer==NULL) { + add_trigger(&u->attribs, "timer", trigger_timeout(1+(rand()%2), t)); + } + } + } + } + a = a->nexttype; + } + if (keeper) { + int duration = 1+ (rand() % 2); + trigger * tkill = trigger_killunit(u); + add_trigger(&u->attribs, "timer", trigger_timeout(duration, tkill)); + } + if (toad) { + /* repair toad-only mage */ + int duration = 1+ (rand() % 2); + trigger * trestore = trigger_changerace(u, u->faction->race, u->faction->race); + if (rand()%10>2) t_add(&trestore, trigger_giveitem(u, olditemtype[I_TOADSLIME], 1)); + add_trigger(&u->attribs, "timer", trigger_timeout(duration, trestore)); + } + } + } +} + void korrektur(void) { @@ -1988,6 +2145,8 @@ korrektur(void) #endif fix_migrants(); fix_allies(); + do_once(atoi36("fhrb"), fix_herbs()); + do_once(atoi36("ftos"), fix_timeouts()); #ifndef SKILLFIX_SAVE fix_skills(); #endif diff --git a/src/res/de/messages.txt b/src/res/de/messages.txt index b4fbc19f2..8e30681f5 100644 --- a/src/res/de/messages.txt +++ b/src/res/de/messages.txt @@ -1,5 +1,5 @@ # Kommentare sind erlaubt. Endlich. -# $Id: messages.txt,v 1.3 2001/02/11 07:21:12 corwin Exp $ +# $Id: messages.txt,v 1.4 2001/02/25 19:31:40 enno Exp $ # Fehlermeldungen: msg_errors;errors:0;de;{string} @@ -284,6 +284,7 @@ error281;errors:0;de;{unit} in {region}: '{command}' - Gegen welche Rasse soll d error282;errors:0;de;{unit} in {region}: '{command}' - Gegen diese Rasse kann kein Jihad ausgerufen werden. error283;events:0;de;{unit} in {region}: '{command}' - Das Passwort darf nur Buchstaben und Ziffern enthalten. error284;errors:0;de;{unit} in {region}: '{command}' - Nur noch nicht gestärkte Untote können das Ziel dieses Zaubers sein. +error285;errors:0;de;{unit} in {region}: '{command}' - Diese Einheit kennt keine Trankrezepte. # Meldungen und Ereignisse msg_event;events:0;de;{string}