From 0986e9162b4b63205e6e2427205d35483bacbefe Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 30 Jan 2001 23:16:17 +0000 Subject: [PATCH] GM Kommandos CREATE und TERRAFORM funktionieren und sind getestet. USE_GM_COMMANDS defninieren, und TEST_GMCOMMANDS, um eine Partei "gms" zu erzeugen. cool. --- src/common/gamecode/creation.c | 4 +-- src/common/gamecode/report.c | 41 +++++++++++++++++-------- src/common/kernel/eressea.c | 5 ++-- src/common/kernel/render.c | 21 ++++++++++--- src/common/kernel/save.c | 20 +------------ src/common/kernel/save.h | 3 +- src/common/modules/Makefile~ | 26 ---------------- src/common/modules/gmcmd.c | 55 ++++++++++++++++++++++++++++------ src/enno.mk | 4 +-- src/eressea/Makefile | 1 - src/eressea/korrektur.c | 9 +++++- src/eressea/main.c | 14 +-------- src/mapper/Makefile | 2 ++ 13 files changed, 111 insertions(+), 94 deletions(-) delete mode 100644 src/common/modules/Makefile~ diff --git a/src/common/gamecode/creation.c b/src/common/gamecode/creation.c index 17d8203cc..71dcb8d3e 100644 --- a/src/common/gamecode/creation.c +++ b/src/common/gamecode/creation.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: creation.c,v 1.2 2001/01/26 16:19:39 enno Exp $ + * $Id: creation.c,v 1.3 2001/01/30 23:16:16 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) @@ -79,7 +79,7 @@ createmonsters(void) return; } f = (faction *) calloc(1, sizeof(faction)); - + f->no = MONSTER_FACTION; /* alles ist auf null gesetzt, ausser dem folgenden. achtung - partei * no 0 muss keine orders einreichen! */ diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 54f4a11b6..eaaa70ae7 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: report.c,v 1.4 2001/01/28 08:50:46 enno Exp $ + * $Id: report.c,v 1.5 2001/01/30 23:16:16 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) @@ -3067,6 +3067,26 @@ writemonument(void) #endif } +static void +writeadresses() +{ + faction *f; + FILE * F; + char zText[MAX_PATH]; + sprintf(zText, "%s/adressen", basepath()); + F = cfopen(zText, "w"); + if (!F) return; + + /* adressen liste */ + + for (f = factions; f; f = f->next) { + if (f->no != MONSTER_FACTION) { + fprintf(F, "%s:%s:%s\n", factionname(f), f->email, f->banner); + } + } + fclose(F); +} + static void writeforward(void) { @@ -3095,7 +3115,7 @@ writeforward(void) void report_summary(summary * s, summary * o, boolean full) { - FILE * F; + FILE * F = NULL; int i, newplayers = 0; faction * f; int nmrs[ORDERGAP]; @@ -3210,30 +3230,25 @@ report_summary(summary * s, summary * o, boolean full) fclose(F); - if (!full) { + if (full) { + FILE * F; #ifdef PLAYER_CSV region * r; #endif - FILE * F; - char zText[MAX_PATH]; - if (full) { - sprintf(zText, "%s/adressen", basepath()); - F = cfopen(zText, "w"); - } - if (!F) return; printf("Schreibe Liste der Adressen (adressen)...\n"); - writeadresses("adressen"); + writeadresses(); writeforward(); - fclose(F); { + char zText[MAX_PATH]; sprintf(zText, "%s/datum", basepath()); F = cfopen(zText, "w"); + if (!F) return; } - if (!F) return; printf("Schreibe Datum (datum)...\n"); fputs(gamedate2(), F); fclose(F); + #ifdef PLAYER_CSV { strcpy(zText, "%s/players", basepath()); diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index b7357a8cd..b4c5d0495 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.4 2001/01/28 08:50:46 enno Exp $ + * $Id: eressea.c,v 1.5 2001/01/30 23:16:16 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) @@ -202,7 +202,8 @@ const char *keywords[MAXKEYWORDS] = "OPFERE", "BETEN", "SORTIEREN", - "JIHAD" + "JIHAD", + "GM" }; const char *report_options[MAX_MSG] = diff --git a/src/common/kernel/render.c b/src/common/kernel/render.c index ff7abb74f..488cb47fd 100644 --- a/src/common/kernel/render.c +++ b/src/common/kernel/render.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: render.c,v 1.2 2001/01/26 16:19:40 enno Exp $ + * $Id: render.c,v 1.3 2001/01/30 23:16:17 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) @@ -222,6 +222,14 @@ v_mage_de(const locale * l, void * data) { return i>1?unitname((unit*)i):"Jemand"; } +static const char * +v_unknown(const locale * l, void * data) { + unused(l); + unused(data); + /* TODO: i==1 getarnt, wilder Hack */ + return "[an error occured]"; +} + const char * v_dir(const locale * l, void * data) { int i = (int)data; @@ -264,9 +272,13 @@ render_immediate(const message * m, const char * find, localizer * l) for (e = l->evaluators[key % RMAXHASH];e;e=e->nexthash) { if (!strcmp(e->name, function)) break; } - assert(e || !"unknown function"); + if (!e) { + fun = v_unknown; + fprintf(stderr, "WARNING: unknown function for rendering %s\n", function); + } + else fun = e->fun; } - fun = e->fun; + else fun = e->fun; ++p; } while (*p!='}') { @@ -475,7 +487,8 @@ de_render_casualties(const message * m, const locale * lang) } static const char * -v_travel(const locale * l, void * data) { +v_travel(const locale * l, void * data) +{ int i = (int)data; unused(l); switch(i) { diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index 703072896..9bcce968d 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.5 2001/01/28 08:01:52 enno Exp $ + * $Id: save.c,v 1.6 2001/01/30 23:16:17 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) @@ -2064,24 +2064,6 @@ curse_read(attrib * a, FILE * f) { struct fjord { int size; faction * f; } fjord[3]; - -void -writeadresses(const char * name) -{ - faction *f; - FILE * F = cfopen(name, "w"); - - if (!F) return; - /* adressen liste */ - - for (f = factions; f; f = f->next) { - if (f->no != MONSTER_FACTION) { - fprintf(F, "%s:%s:%s\n", factionname(f), f->email, f->banner); - } - } - fclose(F); -} - /* ------------------------------------------------------------- */ extern attrib_type at_traveldir_new; diff --git a/src/common/kernel/save.h b/src/common/kernel/save.h index 2107caeb4..151b5919c 100644 --- a/src/common/kernel/save.h +++ b/src/common/kernel/save.h @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: save.h,v 1.2 2001/01/26 16:19:40 enno Exp $ + * $Id: save.h,v 1.3 2001/01/30 23:16:17 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) @@ -37,7 +37,6 @@ int readorders(const char *); int creategame(void); void initgame(void); int readgame(boolean backup); -void writeadresses(const char * name); void writegame(char *path, char quiet); extern void rsf(FILE * F, char *s, size_t len); diff --git a/src/common/modules/Makefile~ b/src/common/modules/Makefile~ deleted file mode 100644 index 11be6bee5..000000000 --- a/src/common/modules/Makefile~ +++ /dev/null @@ -1,26 +0,0 @@ -SUBDIRS = - -LIBRARY = libe-modules.a -BINARY = - -SOURCES = $(wildcard *.c) -OBJECTS = $(SOURCES:%.c=$(BUILD_DIR)/%.o) - -include $(ERESSEA)/Makefile.include - -## more definitions - -INCLUDES += -I../util -I../kernel -I../gamecode -I.. - -# library: -$(BUILD_DIR)/$(LIBRARY):: $(BUILD_DIR) $(OBJECTS) - $(AR) $(ARFLAGS) $@ $(OBJECTS) - -$(PUBLISH_DIR)/$(LIBRARY): $(BUILD_DIR)/$(LIBRARY) - $(INSTALL) $< $@ - -# executable: -#$(BUILD_DIR)/$(BINARY):: $(OBJECTS) -# $(LD) $(LDFLAGS) -o $@ $(OBJECTS) -# $(INSTALL) $@ $(PUBLISH_DIR)/ - diff --git a/src/common/modules/gmcmd.c b/src/common/modules/gmcmd.c index bdf00be41..45efb68da 100644 --- a/src/common/modules/gmcmd.c +++ b/src/common/modules/gmcmd.c @@ -108,8 +108,8 @@ gm_create(const char * str, struct unit * u) { int i; attrib * permissions = a_find(u->faction->attribs, &at_permissions); - if (!permissions) permissions = (attrib*)permissions->data.v; - + if (permissions) permissions = (attrib*)permissions->data.v; + if (!permissions) return; i = atoi(igetstrtoken(str)); if (i>0) { @@ -125,7 +125,7 @@ gm_create(const char * str, struct unit * u) struct attrib * find_key(struct attrib * attribs, int key) { - attrib * a = a_find((attrib*)attribs->data.v, &at_key); + attrib * a = a_find(attribs, &at_key); while (a && a->data.i!=key) a=a->nexttype; return a; } @@ -162,6 +162,7 @@ gm_command(const char * cmd, struct unit * u) while (isalnum(*c)) ++c; i = min(16, c-cmd); strncpy(zText, cmd, i); + zText[i]=0; cm = (command*)findtoken(&g_keys, zText); if (cm && cm->perform) cm->perform(++c, u); } @@ -177,13 +178,14 @@ init_gmcmd(void) { faction * f = findfaction(atoi36("rr")); - attrib * a = a_find(f->attribs, &at_permissions); - if (!a) { - a = a_add(&f->attribs, a_new(&at_permissions)); - a_add((attrib**)&a->data.v, make_atgmcreate(&it_demonseye)); - a_add((attrib**)&a->data.v, make_key(atoi36("gmtf"))); + if (f) { + attrib * a = a_find(f->attribs, &at_permissions); + if (!a) { + a = a_add(&f->attribs, a_new(&at_permissions)); + a_add((attrib**)&a->data.v, make_atgmcreate(&it_demonseye)); + a_add((attrib**)&a->data.v, make_key(atoi36("gmtf"))); + } } - } } @@ -211,3 +213,38 @@ gmcommands(void) if (*rp==r) rp = &r->next; } } +#ifdef TEST_GM_COMMANDS +void +setup_gm_faction(void) +{ + int i = atoi36("gms")-1; + faction * f = factions; + unit * newunit; + region * r = regions; + attrib * a; + + do { + f = findfaction(++i); + } while (f); + + f = (faction *) calloc(1, sizeof(faction)); + f->no = i; + set_string(&f->email, "gms@eressea-pbem.de"); + set_string(&f->passw, "geheim"); + set_string(&f->name, "GMs"); + f->alive = 1; + f->options |= (1 << O_REPORT); + f->options |= (1 << O_COMPUTER); + addlist(&factions, f); + + a = a_add(&f->attribs, a_new(&at_permissions)); + a_add((attrib**)&a->data.v, make_atgmcreate(&it_demonseye)); + a_add((attrib**)&a->data.v, make_key(atoi36("gmtf"))); + + while (r && !r->land) r=r->next; + newunit = createunit(r, f, 1, RC_DAEMON); + set_string(&newunit->name, "Flamdring, Gott des Feuers"); + set_money(newunit, 100); + fset(newunit, FL_ISNEW); +} +#endif diff --git a/src/enno.mk b/src/enno.mk index d225ca3a3..660234d4f 100644 --- a/src/enno.mk +++ b/src/enno.mk @@ -2,9 +2,9 @@ ## enable some new features in the source: # -CONVERT_TRIGGERS = 1 +# CONVERT_TRIGGERS = 1 -CFLAGS += -DUSE_GM_COMMANDS +CFLAGS += -DUSE_GM_COMMANDS -DTEST_GM_COMMANDS LD=gcc AR=ar diff --git a/src/eressea/Makefile b/src/eressea/Makefile index cf21e8360..6700cead3 100644 --- a/src/eressea/Makefile +++ b/src/eressea/Makefile @@ -50,7 +50,6 @@ LIBS += $(LIBNAMES:%=-l%) -lm $(BUILD_DIR)/$(BINARY):: subdirs-$(CONFIG) $(BUILD_DIR) $(OBJECTS) $(LD) -o $@ $(OBJECTS) $(LDFLAGS) - $(INSTALL) $@ $(PUBLISH_DIR)/ $(PUBLISH_DIR)/$(BINARY): $(BUILD_DIR)/$(BINARY) $(INSTALL) $< $@ diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index dd83050aa..4360e21e3 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: korrektur.c,v 1.5 2001/01/28 08:01:52 enno Exp $ + * $Id: korrektur.c,v 1.6 2001/01/30 23:16:17 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) @@ -1744,9 +1744,16 @@ lms_special(unit * u) /* TODO: Trollstärke-gürtel und trigger an die einheit geben */ } +#include +void setup_gm_faction(void); + void korrektur(void) { +#ifdef TEST_GM_COMMANDS + setup_gm_faction(); +#endif + /* Wieder entfernen! */ /* fix_herbtypes(); */ diff --git a/src/eressea/main.c b/src/eressea/main.c index 0579d51c9..97daf7343 100644 --- a/src/eressea/main.c +++ b/src/eressea/main.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: main.c,v 1.5 2001/01/30 20:26:05 enno Exp $ + * $Id: main.c,v 1.6 2001/01/30 23:16:17 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) @@ -612,10 +612,6 @@ main(int argc, char *argv[]) } break; #endif - case 'a': - writeadresses("adressen"); - exit(0); - break; case '#': score(); @@ -641,7 +637,6 @@ main(int argc, char *argv[]) "-x n : Lädt nur die ersten n regionen\n" "-g befehlsdatei : verarbeitet Spielleiterbefehle\n" "-v befehlsdatei : verarbeitet automatisch die angegebene Befehlsdatei\n" - "-a : gibt Adressenliste aus\n" "-# : gibt Scoreliste aus\n" "-d datadir : gibt das datenverzeichnis an\n" "-o reportdir : gibt das reportverzeichnis an\n" @@ -674,13 +669,6 @@ main(int argc, char *argv[]) fgets(buf, 1024, stdin); switch (buf[0]) { - case 'a': - puts("Schreibe Liste der Adressen..."); - writeadresses("adressen"); - - fclose(F); - break; - case 'c': korrektur(); break; diff --git a/src/mapper/Makefile b/src/mapper/Makefile index 55ccb388c..40e2e1934 100644 --- a/src/mapper/Makefile +++ b/src/mapper/Makefile @@ -32,3 +32,5 @@ $(BUILD_DIR)/$(BINARY):: $(BUILD_DIR) $(OBJECTS) $(LD) -o $@ $(OBJECTS) $(LDFLAGS) $(INSTALL) $@ $(PUBLISH_DIR)/ +$(PUBLISH_DIR)/$(BINARY): $(BUILD_DIR)/$(BINARY) + $(INSTALL) $< $@