GM Kommandos CREATE und TERRAFORM funktionieren und sind getestet. USE_GM_COMMANDS defninieren, und TEST_GMCOMMANDS, um eine Partei "gms" zu erzeugen. cool.

This commit is contained in:
Enno Rehling 2001-01-30 23:16:17 +00:00
parent f0fb8d42dd
commit 0986e9162b
13 changed files with 111 additions and 94 deletions

View File

@ -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! */

View File

@ -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;
}
printf("Schreibe Datum (datum)...\n");
fputs(gamedate2(), F);
fclose(F);
#ifdef PLAYER_CSV
{
strcpy(zText, "%s/players", basepath());

View File

@ -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] =

View File

@ -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);
}
fun = e->fun;
else 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) {

View File

@ -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;

View File

@ -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);

View File

@ -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)/

View File

@ -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"));
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

View File

@ -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

View File

@ -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) $< $@

View File

@ -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 <modules/gmcmd.h>
void setup_gm_faction(void);
void
korrektur(void)
{
#ifdef TEST_GM_COMMANDS
setup_gm_faction();
#endif
/* Wieder entfernen! */
/* fix_herbtypes(); */

View File

@ -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;

View File

@ -32,3 +32,5 @@ $(BUILD_DIR)/$(BINARY):: $(BUILD_DIR) $(OBJECTS)
$(LD) -o $@ $(OBJECTS) $(LDFLAGS)
$(INSTALL) $@ $(PUBLISH_DIR)/
$(PUBLISH_DIR)/$(BINARY): $(BUILD_DIR)/$(BINARY)
$(INSTALL) $< $@