forked from github/server
noone needs this
This commit is contained in:
parent
a45f59168b
commit
8bb8488e6a
|
@ -1,30 +0,0 @@
|
|||
SUBDIRS =
|
||||
LIBNAME = e-compat
|
||||
EXENAME =
|
||||
|
||||
## cheating: we link all attributes/items/etc for all the games. TODO - don't.
|
||||
SOURCES = $(wildcard *.c)
|
||||
OBJECTS = $(SOURCES:%.c=$(BUILD_DIR)/%.o)
|
||||
|
||||
include $(ERESSEA_SRC)/Makefile.include
|
||||
|
||||
##
|
||||
## more definitions
|
||||
##
|
||||
|
||||
INCLUDES += \
|
||||
-I../../common \
|
||||
-I../../common/util \
|
||||
-I../../common/kernel
|
||||
|
||||
LIBRARIES = $(LIBNAMES:%=$(PUBLISH_DIR)/lib%.a)
|
||||
|
||||
LIBS += $(LIBNAMES:%=-l%) -lm
|
||||
|
||||
# library:
|
||||
$(BUILD_DIR)/$(LIBRARY):: $(BUILD_DIR) $(OBJECTS)
|
||||
$(AR) $(ARFLAGS) $@ $(OBJECTS)
|
||||
$(INSTALL) $@ $(PUBLISH_DIR)/
|
||||
|
||||
$(PUBLISH_DIR)/$(LIBRARY): $(BUILD_DIR)/$(LIBRARY)
|
||||
$(INSTALL) $< $@
|
|
@ -1,28 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea-pbem.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef SPREAD_H
|
||||
#define SPREAD_H
|
||||
|
||||
/* Verhalten von Attibuten auf Units bei GIB PERSONEN */
|
||||
|
||||
typedef enum {
|
||||
SPREAD_NEVER, /* Wird nie mit übertragen */
|
||||
SPREAD_ALWAYS, /* Wird immer mit übertragen */
|
||||
SPREAD_MODULO, /* Personenweise Weitergabe */
|
||||
SPREAD_CHANCE, /* Ansteckungschance je nach Mengenverhältnis */
|
||||
SPREAD_TRANSFER /* Attribut wird nicht kopiert, sondern "wandert" */
|
||||
} spread_t;
|
||||
|
||||
#endif /* SPREAD_H */
|
|
@ -1,21 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea-pbem.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef _CR_H
|
||||
#define _CR_H
|
||||
|
||||
void cr_faction(FILE * out, struct faction * f);
|
||||
void cr_region(FILE * out, struct region * r);
|
||||
|
||||
#endif
|
|
@ -1,107 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <eressea.h>
|
||||
#include "order.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
void
|
||||
append_order(orders * os, order * o)
|
||||
{
|
||||
assert(o->next==NULL);
|
||||
if (os->end==NULL) os->list = o;
|
||||
else *(os->end) = o;
|
||||
os->end = &o->next;
|
||||
}
|
||||
|
||||
order *
|
||||
remove_order(orders * os, order * o)
|
||||
{
|
||||
order ** op = &os->list;
|
||||
while (*op && o!=*op) op=&(*op)->next;
|
||||
assert(*op);
|
||||
if (o->next==NULL) os->end=op;
|
||||
*op = o->next;
|
||||
o->next = NULL;
|
||||
return o;
|
||||
}
|
||||
|
||||
void
|
||||
free_order(order * o)
|
||||
{
|
||||
if (o->data.v) {
|
||||
char ** ca = (char**)o->data.v;
|
||||
while (*ca) free(*(ca++));
|
||||
free(o->data.v);
|
||||
}
|
||||
free(o);
|
||||
}
|
||||
|
||||
#define MAXPARAM 128
|
||||
|
||||
#include "eressea.h"
|
||||
|
||||
order *
|
||||
new_order(const char * cmd)
|
||||
{
|
||||
const char * params[MAXPARAM+1];
|
||||
char ** cp;
|
||||
int i;
|
||||
order * o = calloc(sizeof(order), 1);
|
||||
o->type = igetkeyword(cmd);
|
||||
for (i=0;i!=MAXPARAM;++i) {
|
||||
const char * s = getstrtoken();
|
||||
if (s==NULL || *s==0) break;
|
||||
params[i] = strdup(s);
|
||||
}
|
||||
cp = malloc(sizeof(const char*)*(i+1));
|
||||
memcpy(cp, params, sizeof(const char*)*i);
|
||||
cp[i]=NULL;
|
||||
o->data.v = (void*) cp;
|
||||
return o;
|
||||
}
|
||||
|
||||
const char *
|
||||
order_string(const order * o, char * buf, size_t len)
|
||||
{
|
||||
char * c;
|
||||
static char retval[4096];
|
||||
size_t slen;
|
||||
if (buf==NULL) {
|
||||
buf = retval;
|
||||
len=4096;
|
||||
}
|
||||
c = buf;
|
||||
strncpy(c, locale_string(u->faction->locale, keywords[o->type]), len);
|
||||
slen = strlen(c);
|
||||
len -= slen;
|
||||
c += slen;
|
||||
if (o->data.v) {
|
||||
char ** cp = o->data.v;
|
||||
while (*cp) {
|
||||
slen = strlen(*cp);
|
||||
*c = ' ';
|
||||
if (slen>len-2) {
|
||||
strncpy(c+1, *cp, len-1);
|
||||
break;
|
||||
}
|
||||
strncpy(c+1, *cp, len);
|
||||
len -= slen+1;
|
||||
c += slen+1;
|
||||
}
|
||||
}
|
||||
buf[len-1] = '\0';
|
||||
return buf;
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea-pbem.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
#ifndef ORDER_H
|
||||
#define ORDER_H
|
||||
|
||||
#define order_t int
|
||||
|
||||
typedef union {
|
||||
void * v;
|
||||
int i;
|
||||
char c;
|
||||
short s;
|
||||
short sa[2];
|
||||
char ca[4];
|
||||
} variant;
|
||||
|
||||
typedef struct order {
|
||||
struct order * next;
|
||||
order_t type;
|
||||
variant data;
|
||||
} order;
|
||||
|
||||
typedef struct orders {
|
||||
order * list;
|
||||
order ** end;
|
||||
} orders;
|
||||
|
||||
extern void append_order(orders * os, order * o);
|
||||
extern order * new_order(const char * cmd);
|
||||
extern void free_order(order * o);
|
||||
extern const char * order_string(const order * o, char * buffer, size_t buffersize);
|
||||
|
||||
#endif
|
|
@ -1,245 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea-pbem.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "pointertags.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct ptrlist {
|
||||
struct ptrlist *next;
|
||||
|
||||
void *objPP;
|
||||
typ_t typ;
|
||||
} ptrlist;
|
||||
|
||||
typedef struct {
|
||||
tag_t tag;
|
||||
|
||||
ptrlist *ptrs;
|
||||
} ptrref;
|
||||
|
||||
static ptrlist *freelist;
|
||||
|
||||
/* at_pointer_tag */
|
||||
|
||||
static void
|
||||
tag_init(attrib *a)
|
||||
{
|
||||
a->data.v = calloc(1, sizeof(ptrref));
|
||||
}
|
||||
|
||||
static void
|
||||
tag_done(attrib *a)
|
||||
{
|
||||
ptrref *ref;
|
||||
ptrlist *p;
|
||||
|
||||
ref = (ptrref *)a->data.v;
|
||||
while( (p = ref->ptrs) != NULL ) {
|
||||
ref->ptrs = p->next;
|
||||
p->next = freelist;
|
||||
freelist = p;
|
||||
}
|
||||
free(ref);
|
||||
}
|
||||
|
||||
attrib_type at_pointer_tag = {
|
||||
"pointer tags",
|
||||
tag_init,
|
||||
tag_done,
|
||||
NULL, /* age */
|
||||
NO_WRITE, /* write */
|
||||
NO_READ, /* read */
|
||||
};
|
||||
|
||||
static ptrref *
|
||||
find_ref(attrib **ap, tag_t tag)
|
||||
{
|
||||
attrib *a;
|
||||
ptrref *ref;
|
||||
|
||||
a = a_find(*ap, &at_pointer_tag);
|
||||
while( a ) {
|
||||
ref = (ptrref *)a->data.v;
|
||||
|
||||
if( ref->tag == tag )
|
||||
return ref;
|
||||
a = a->nexttype;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static ptrref *
|
||||
make_ref(attrib **ap, tag_t tag)
|
||||
{
|
||||
attrib *a;
|
||||
ptrref *ref;
|
||||
|
||||
ref = find_ref(ap, tag);
|
||||
if( !ref ) {
|
||||
a = a_new(&at_pointer_tag);
|
||||
a_add(ap, a);
|
||||
ref = (ptrref *)a->data.v;
|
||||
ref->ptrs = NULL;
|
||||
ref->tag = tag;
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tag_pointer(void *objPP, typ_t typ, tag_t tag)
|
||||
{
|
||||
void *obj;
|
||||
attrib **ap;
|
||||
ptrref *ref;
|
||||
ptrlist *p;
|
||||
|
||||
obj = typdata[typ].ppget(objPP);
|
||||
if( !obj )
|
||||
return;
|
||||
ap = typdata[typ].getattribs(obj);
|
||||
ref = make_ref(ap, tag);
|
||||
|
||||
if( (p = freelist) != NULL )
|
||||
freelist = p->next;
|
||||
else
|
||||
p = calloc(1, sizeof(ptrlist));
|
||||
p->objPP = objPP;
|
||||
p->typ = typ;
|
||||
|
||||
p->next = ref->ptrs;
|
||||
ref->ptrs = p;
|
||||
}
|
||||
|
||||
void
|
||||
untag_pointer(void *objPP, typ_t typ, tag_t tag)
|
||||
{
|
||||
void *obj;
|
||||
attrib **ap;
|
||||
ptrref *ref;
|
||||
ptrlist *p, **prevP;
|
||||
|
||||
obj = typdata[typ].ppget(objPP);
|
||||
if( !obj )
|
||||
return;
|
||||
ap = typdata[typ].getattribs(obj);
|
||||
|
||||
ref = find_ref(ap, tag);
|
||||
if( !ref )
|
||||
return;
|
||||
|
||||
prevP = &ref->ptrs;
|
||||
for( p = ref->ptrs; p; p = p->next ) {
|
||||
if( p->objPP == objPP ) {
|
||||
*prevP = p->next; /* unlink */
|
||||
|
||||
p->next = freelist; /* p freigeben */
|
||||
freelist = p;
|
||||
return;
|
||||
}
|
||||
prevP = &p->next;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
count_tagged_pointers(void *obj, typ_t typ, tag_t tag)
|
||||
{
|
||||
attrib **ap;
|
||||
ptrref *ref;
|
||||
ptrlist *p;
|
||||
int count;
|
||||
|
||||
if( !obj )
|
||||
return 0;
|
||||
ap = typdata[typ].getattribs(obj);
|
||||
ref = find_ref(ap, tag);
|
||||
if( !ref )
|
||||
return 0;
|
||||
|
||||
count = 0;
|
||||
for( p = ref->ptrs; p; p = p->next )
|
||||
++count;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int
|
||||
count_all_pointers(void *obj, typ_t typ)
|
||||
{
|
||||
tag_t tag;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
for( tag = 0; tag < MAXTAGS; tag++ )
|
||||
count += count_tagged_pointers(obj, typ, tag);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
change_tagged_pointers(void *obj1, typ_t typ, tag_t tag, void *obj2)
|
||||
{
|
||||
attrib **ap;
|
||||
ptrref *ref1, *ref2 = NULL;
|
||||
ptrlist *p;
|
||||
|
||||
if( !obj1 )
|
||||
return;
|
||||
|
||||
ap = typdata[typ].getattribs(obj1);
|
||||
ref1 = find_ref(ap, tag);
|
||||
if( !ref1 )
|
||||
return;
|
||||
if( obj2 ) {
|
||||
ap = typdata[typ].getattribs(obj2);
|
||||
ref2 = make_ref(ap, tag);
|
||||
}
|
||||
|
||||
while( (p = ref1->ptrs) != NULL ) {
|
||||
ref1->ptrs = p->next;
|
||||
|
||||
typdata[typ].ppset(p->objPP, obj2);
|
||||
if( obj2 ) {
|
||||
p->next = ref2->ptrs; /* Referenz jetzt bei obj2 */
|
||||
ref2->ptrs = p;
|
||||
} else {
|
||||
p->next = freelist; /* p freigeben */
|
||||
freelist = p;
|
||||
}
|
||||
}
|
||||
/* Wir lassen das Attrib mit der leeren Pointer-Liste beim
|
||||
* Objekt bestehen, das erspart eine De- und Neu-Allokation,
|
||||
* wenn nochmal Pointer auf dieses Objekt so ge'tag't werden.
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
change_all_pointers(void *obj1, typ_t typ, void *obj2)
|
||||
{
|
||||
tag_t tag;
|
||||
|
||||
for( tag = 0; tag < MAXTAGS; tag++ )
|
||||
change_tagged_pointers(obj1, typ, tag, obj2);
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea-pbem.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#if !(defined(OLD_TRIGGER) || defined(CONVERT_TRIGGER))
|
||||
# error "Do not include unless for old code or to enable conversion"
|
||||
#endif
|
||||
|
||||
#ifndef POINTERTAGS_H
|
||||
#define POINTERTAGS_H
|
||||
|
||||
/* Tags */
|
||||
typedef enum {
|
||||
TAG_NORMAL, /* Std-Tag, Ptr wird NULL, wenn Objekt vernichtet wird */
|
||||
TAG_RELATION, /*unit* in relation-Attribs */
|
||||
|
||||
/* Achtung: neue Tags nur über dieser Zeile anfügen, aber unter bereits
|
||||
* bestehenden! Die Reihenfolge nicht verändern! */
|
||||
MAXTAGS,
|
||||
TAG_NOTAG = -1
|
||||
} tag_t;
|
||||
|
||||
#ifndef OBJTYPES_H
|
||||
#include <objtypes.h>
|
||||
#endif
|
||||
|
||||
extern void tag_pointer(void *objPP, typ_t typ, tag_t tag);
|
||||
extern void untag_pointer(void *objPP, typ_t typ, tag_t tag);
|
||||
|
||||
extern void change_all_pointers(void *obj1, typ_t typ, void *obj2);
|
||||
|
||||
extern int count_all_pointers(void *obj, typ_t typ);
|
||||
extern int count_tagged_pointers(void *obj, typ_t typ, tag_t tag);
|
||||
|
||||
#include "attrib.h"
|
||||
extern attrib_type at_pointer_tag;
|
||||
|
||||
#if defined(OLD_TRIGGER) || defined (CONVERT_TRIGGER)
|
||||
extern void add_ID_resolve2(obj_ID id, void *objPP, typ_t typ, tag_t tag);
|
||||
#endif
|
||||
|
||||
#endif /* POINTERTAGS_H */
|
|
@ -1,261 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea-pbem.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "eressea.h"
|
||||
#include "relation.h"
|
||||
#if defined(OLD_TRIGGER) || defined(CONVERT_TRIGGER)
|
||||
/* util includes */
|
||||
#include <attrib.h>
|
||||
|
||||
#include "pointertags.h"
|
||||
#include <objtypes.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct {
|
||||
void *obj2;
|
||||
typ_t typ2;
|
||||
relation_t id;
|
||||
spread_t spread;
|
||||
} reldata;
|
||||
|
||||
static void
|
||||
rel_init(attrib *a)
|
||||
{
|
||||
reldata *rel;
|
||||
|
||||
rel = calloc(1, sizeof(reldata));
|
||||
rel->obj2 = NULL;
|
||||
a->data.v = (void *)rel;
|
||||
}
|
||||
|
||||
static void
|
||||
rel_done(attrib *a)
|
||||
{
|
||||
#ifdef OLD_TRIGGER
|
||||
reldata *rel = (reldata *)a->data.v;
|
||||
if( rel->obj2 )
|
||||
untag_pointer(&rel->obj2, rel->typ2, TAG_RELATION);
|
||||
free(rel);
|
||||
#else
|
||||
unused(a);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef OLD_TRIGGER
|
||||
static void
|
||||
rel_save(const attrib *a, FILE *f)
|
||||
{
|
||||
reldata *rel = (reldata *)a->data.v;
|
||||
obj_ID id;
|
||||
ID_fun fun = typdata[rel->typ2].getID;
|
||||
|
||||
id = fun(rel->obj2);
|
||||
write_ID(f, id);
|
||||
fprintf(f, "%d %d %d ", rel->typ2, rel->id, rel->spread);
|
||||
}
|
||||
#endif
|
||||
static int
|
||||
rel_load(attrib *a, FILE *f)
|
||||
{
|
||||
reldata *rel = (reldata *)a->data.v;
|
||||
obj_ID id;
|
||||
|
||||
id = read_ID(f);
|
||||
fscanf(f, "%d %d %d ", (int *)&rel->typ2, (int *)&rel->id, (int *)&rel->spread);
|
||||
add_ID_resolve2(id, &rel->obj2, rel->typ2, TAG_RELATION);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef OLD_TRIGGER
|
||||
/* garbage collection */
|
||||
static int
|
||||
rel_age(attrib *a)
|
||||
{
|
||||
reldata *rel = (reldata *)a->data.v;
|
||||
return (rel->obj2 != NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
attrib_type at_relation = {
|
||||
"unit_relations",
|
||||
rel_init,
|
||||
rel_done,
|
||||
#ifdef CONVERT_TRIGGER
|
||||
NULL, NULL,
|
||||
#else
|
||||
rel_age,
|
||||
rel_save,
|
||||
#endif
|
||||
rel_load,
|
||||
};
|
||||
|
||||
attrib_type at_relbackref = {
|
||||
"unit_relations_back_reference",
|
||||
rel_init,
|
||||
rel_done,
|
||||
#ifdef CONVERT_TRIGGER
|
||||
NULL, NULL,
|
||||
#else
|
||||
rel_age,
|
||||
rel_save,
|
||||
#endif
|
||||
rel_load,
|
||||
};
|
||||
|
||||
static attrib *
|
||||
find_rel(attrib **ap, relation_t id, attrib_type *atype)
|
||||
{
|
||||
attrib *a;
|
||||
reldata *rel;
|
||||
|
||||
a = a_find(*ap, atype);
|
||||
while( a ) {
|
||||
rel = (reldata *)a->data.v;
|
||||
if( rel->id == id )
|
||||
return a;
|
||||
a = a->nexttype;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
rel_create(void *obj1, typ_t typ1,
|
||||
relation_t id,
|
||||
void *obj2, typ_t typ2,
|
||||
spread_t spread,
|
||||
attrib_type *atype)
|
||||
{
|
||||
attrib *a;
|
||||
attrib **ap;
|
||||
reldata *rel;
|
||||
|
||||
ap = typdata[typ1].getattribs(obj1);
|
||||
a = find_rel(ap, id, atype);
|
||||
if( !a ) {
|
||||
a = a_new(atype);
|
||||
a_add(ap, a);
|
||||
rel = (reldata *)a->data.v;
|
||||
rel->id = id;
|
||||
} else {
|
||||
rel = (reldata *)a->data.v;
|
||||
if( rel->obj2 )
|
||||
untag_pointer(&rel->obj2, rel->typ2, TAG_RELATION);
|
||||
}
|
||||
rel->obj2 = obj2;
|
||||
tag_pointer(&rel->obj2, typ2, TAG_RELATION);
|
||||
rel->typ2 = typ2;
|
||||
rel->spread = spread;
|
||||
}
|
||||
|
||||
static reldata *
|
||||
rel_get(const void *obj, typ_t typ,
|
||||
relation_t id,
|
||||
attrib_type *atype)
|
||||
{
|
||||
attrib *a;
|
||||
attrib **ap;
|
||||
|
||||
ap = typdata[typ].getattribs((void *)obj);
|
||||
a = find_rel(ap, id, atype);
|
||||
if( a )
|
||||
return (reldata *)(a->data.v);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*********************************************************
|
||||
PUBLIC FUNCTIONS
|
||||
*********************************************************/
|
||||
|
||||
void *
|
||||
get_relation2(const void *obj, typ_t typ, relation_t id, typ_t *typ2P)
|
||||
{
|
||||
reldata *rel;
|
||||
|
||||
rel = rel_get(obj, typ, id, &at_relation);
|
||||
if( rel ) {
|
||||
if( typ2P )
|
||||
*typ2P = rel->typ2;
|
||||
return rel->obj2;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
get_relation(const void *obj, typ_t typ, relation_t id)
|
||||
{
|
||||
typ_t dummy;
|
||||
return get_relation2(obj, typ, id, &dummy);
|
||||
}
|
||||
|
||||
void *
|
||||
get_rev_relation2(void *obj, typ_t typ, relation_t id, typ_t *typ2P)
|
||||
{
|
||||
reldata *rel;
|
||||
|
||||
rel = rel_get(obj, typ, id, &at_relbackref);
|
||||
if( rel ) {
|
||||
if( typ2P )
|
||||
*typ2P = rel->typ2;
|
||||
return rel->obj2;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
get_rev_relation(void *obj, typ_t typ, relation_t id)
|
||||
{
|
||||
typ_t dummy;
|
||||
return get_rev_relation2(obj, typ, id, &dummy);
|
||||
}
|
||||
|
||||
void
|
||||
create_relation(void *obj1, typ_t typ1,
|
||||
relation_t id,
|
||||
void *obj2, typ_t typ2,
|
||||
spread_t spread)
|
||||
{
|
||||
rel_create(obj1, typ1, id, obj2, typ2, spread, &at_relation);
|
||||
rel_create(obj2, typ2, id, obj1, typ1, SPREAD_TRANSFER, &at_relbackref);
|
||||
}
|
||||
|
||||
void
|
||||
remove_relation(void *obj, typ_t typ, relation_t id)
|
||||
{
|
||||
attrib **ap;
|
||||
attrib *a;
|
||||
|
||||
ap = typdata[typ].getattribs(obj);
|
||||
a = find_rel(ap, id, &at_relation);
|
||||
if( a ) {
|
||||
reldata *rel = (reldata *)a->data.v;
|
||||
obj = rel->obj2; /* Objekt mit Backref-Attrib */
|
||||
a_remove(ap, a); /* Relation entfernen */
|
||||
if( obj ) {
|
||||
ap = typdata[typ].getattribs(obj);
|
||||
a = find_rel(ap, id, &at_relbackref);
|
||||
if( a )
|
||||
a_remove(ap, a); /* Backref entfernen */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,59 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea-pbem.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#if !(defined(OLD_TRIGGER) || defined(CONVERT_TRIGGER))
|
||||
# error "Do not include unless for old code or to enable conversion"
|
||||
#endif
|
||||
|
||||
#ifndef RELATION_H
|
||||
#define RELATION_H
|
||||
#if defined(OLD_TRIGGER) || defined(CONVERT_TRIGGER)
|
||||
/* Einfache Beziehungen zwischen Objekten herstellen ("ich verfolge A",
|
||||
* "B ist mein Vater", "X ist mein Heimatort"). Werden automatisch
|
||||
* gespeichert und geladen. Jedes Objekt kann von jedem Relations-Typ
|
||||
* (d.h. von jeder REL_XXX-Id) nur je eine besitzen. Will man einem
|
||||
* Objekt zwei "gleiche" Relationen anhängen ("meine Väter sind C und D"),
|
||||
* so nehme man zwei Ids:
|
||||
* create_relation(u, TYP_UNIT, REL_DADDY1, uC, TYP_UNIT, SPREAD_ALWAYS);
|
||||
* create_relation(u, TYP_UNIT, REL_DADDY2, uD, TYP_UNIT, SPREAD_ALWAYS);
|
||||
*
|
||||
* Relations werden automatisch gelöscht, wenn das referierte Objekt
|
||||
* zerstört wird.
|
||||
*/
|
||||
|
||||
#include "objtypes.h"
|
||||
#include "attrspread.h"
|
||||
|
||||
typedef enum {
|
||||
REL_TARGET, /* Objekt ist mein Ziel */
|
||||
REL_CREATOR, /* Objekt hat mich erschaffen */
|
||||
REL_FAMILIAR, /* Zauberer: Objekt ist Vertrauter */
|
||||
|
||||
MAXRELATIONS
|
||||
} relation_t;
|
||||
|
||||
void create_relation(void *obj1, typ_t typ1, relation_t id,
|
||||
void *obj2, typ_t typ2, spread_t spread);
|
||||
void remove_relation(void *obj1, typ_t typ1, relation_t id);
|
||||
void *get_relation(const void *obj, typ_t typ, relation_t id);
|
||||
void *get_relation2(const void *obj, typ_t typ, relation_t id, typ_t *typ2P);
|
||||
/* umgekehrte Richtung */
|
||||
void *get_rev_relation(void *obj, typ_t typ, relation_t id);
|
||||
void *get_rev_relation2(void *obj, typ_t typ, relation_t id, typ_t *typ2P);
|
||||
|
||||
#include "attrib.h"
|
||||
extern attrib_type at_relation;
|
||||
extern attrib_type at_relbackref;
|
||||
#endif
|
||||
#endif
|
|
@ -1,118 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
#ifdef COMPATIBILITY
|
||||
/* ------------------------------------------------------------- */
|
||||
void
|
||||
use_teleportcrystal(region * r, unit * mage, strlist * cmdstrings)
|
||||
{
|
||||
region *target_region = NULL;
|
||||
unit *target_unit;
|
||||
strlist *S;
|
||||
target_unit = getunit(r, mage);
|
||||
|
||||
if (target_unit == NULL) {
|
||||
cmistake(mage, cmdstrings->s, 64, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
target_region = findunitregion(target_unit);
|
||||
|
||||
if (target_unit->faction != mage->faction) {
|
||||
int kontaktiert = 0;
|
||||
|
||||
/* Nun kommt etwas reichlich krankes, um den KONTAKTIERE-Befehl
|
||||
* des Ziels zu überprüfen. */
|
||||
|
||||
if(allied(target_unit, mage->faction, HELP_FIGHT)) {
|
||||
kontaktiert = 1;
|
||||
} else {
|
||||
for (S = target_unit->orders; S; S = S->next) {
|
||||
if (strncasecmp("KON", S->s, 3) == 0) {
|
||||
char *c;
|
||||
int kontakt = -1;
|
||||
/* Soweit, sogut. S->s ist also ein
|
||||
* KONTAKTIERE. Nun gilt es, herauszufinden,
|
||||
* wer kontaktiert wird. Das ist nicht trivial. */
|
||||
|
||||
/* Zuerst muß der Parameter herausoperiert
|
||||
* werden. */
|
||||
|
||||
/* Leerzeichen finden */
|
||||
|
||||
for (c = S->s; *c != 0; c++) {
|
||||
if (isspace((int)*c) != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Wenn ein Leerzeichen da ist, ist *c != 0 und
|
||||
* zeigt auf das Leerzeichen. */
|
||||
|
||||
if (*c == 0) {
|
||||
continue;
|
||||
}
|
||||
kontakt = atoi(c);
|
||||
|
||||
if (kontakt == mage->no) {
|
||||
kontaktiert = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (kontaktiert == 0) {
|
||||
/* Fehler: "Die Ziel-Einheit hat keinen Kontakt mit uns
|
||||
* aufgenommen" */
|
||||
cmistake(mage, cmdstrings->s, 72, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!can_survive(target_unit, r)) {
|
||||
cmistake(mage, cmdstrings->s, 231, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Zahl prüfen */
|
||||
|
||||
if (get_item(mage, I_TELEPORTCRYSTAL) < target_unit->number) {
|
||||
/* Fehler: "Die Einheit hat nicht mehr genug Kristalle fuer so
|
||||
* viele Personen" */
|
||||
cmistake(mage, cmdstrings->s, 141, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
/* Kristalle abziehen */
|
||||
|
||||
set_item(mage, I_TELEPORTCRYSTAL,
|
||||
get_item(mage, I_TELEPORTCRYSTAL) - target_unit->number);
|
||||
|
||||
/* Einheit verschieben. Diesmal ohne großen Aufwand, da ja
|
||||
* immer nur ans Ende der aktuellen Region angehängt werden
|
||||
* kann. */
|
||||
|
||||
move_unit(target_unit, r, NULL);
|
||||
|
||||
/* Langen Befehl der Einheit löschen, sonst sind Mehrfachzauber
|
||||
* möglich */
|
||||
|
||||
set_string(&target_unit->thisorder, "");
|
||||
|
||||
/* Meldung an die Parteien */
|
||||
|
||||
add_message(&mage->faction->msgs, new_message(mage->faction,
|
||||
"teleport_success%u:unit%r:source%r:target", target_unit, target_region, r));
|
||||
if (target_unit->faction != mage->faction) {
|
||||
add_message(&target_unit->faction->msgs, new_message(target_unit->faction,
|
||||
"teleport_success%u:unit%r:source%r:target", target_unit, target_region, r));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,12 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
extern void use_teleportcrystal(region * r, unit * mage, strlist * cmdstrings)
|
|
@ -1,916 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea-pbem.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <eressea.h>
|
||||
#include "trigger.h"
|
||||
|
||||
#include <item.h>
|
||||
#include <faction.h>
|
||||
#include <unit.h>
|
||||
#include <region.h>
|
||||
#include <save.h>
|
||||
#include <magic.h>
|
||||
#include <spell.h>
|
||||
|
||||
#include <resolve.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(OLD_TRIGGER) || defined(CONVERT_TRIGGER)
|
||||
|
||||
#define NULLSTRING "<iuw_null>"
|
||||
|
||||
static int action_resid;
|
||||
static int timeout_resid;
|
||||
static int trigger_resid;
|
||||
|
||||
static int
|
||||
make_id(int *itemidP, int *globalidP)
|
||||
{
|
||||
if( *(itemidP) <= 0 ) {
|
||||
(*globalidP)++;
|
||||
*itemidP = *globalidP;
|
||||
}
|
||||
return *itemidP;
|
||||
}
|
||||
|
||||
#define action_id(a) make_id(&(a)->resid, &action_resid)
|
||||
#define trigger_id(t) make_id(&(t)->resid, &trigger_resid)
|
||||
#define timeout_id(t) make_id(&(t)->resid, &timeout_resid)
|
||||
|
||||
/********** action attribute **********/
|
||||
|
||||
static action *all_actions;
|
||||
|
||||
static void
|
||||
action_init(attrib *a)
|
||||
{
|
||||
action *act;
|
||||
|
||||
act = calloc(1, sizeof(action));
|
||||
act->next = all_actions;
|
||||
all_actions = act;
|
||||
act->magic = ACTION_MAGIC;
|
||||
a->data.v = act;
|
||||
}
|
||||
|
||||
static void
|
||||
action_done(attrib *a)
|
||||
{
|
||||
action *act = (action *)a->data.v;
|
||||
|
||||
if( act->string )
|
||||
free(act->string);
|
||||
free(act);
|
||||
}
|
||||
#ifdef OLD_TRIGGER
|
||||
static void
|
||||
action_save(const attrib *a, FILE *f)
|
||||
{
|
||||
action *act = (action *)a->data.v;
|
||||
int nints, j;
|
||||
|
||||
fprintf(f, "%d ", action_id(act));
|
||||
fprintf(f, "%d ", (int)act->atype);
|
||||
write_ID(f, get_ID(act->obj, act->typ));
|
||||
fprintf(f, "%d ", (int)act->typ);
|
||||
#if RELEASE_VERSION < ACTIONFIX1_VERSION
|
||||
fprintf(f, "%d %d ", act->i[0], act->i[1]);
|
||||
#else
|
||||
for( nints = 0, j = 0; j < ACTION_INTS; j++ ) {
|
||||
if( act->i[j] != 0 )
|
||||
nints = j+1;
|
||||
}
|
||||
fprintf(f, "%d ", nints);
|
||||
for( j = 0; j < nints; j++ )
|
||||
fprintf(f, "%d ", act->i[j]);
|
||||
#endif
|
||||
fprintf(f, "%s\n", act->string ? estring(act->string) : NULLSTRING);
|
||||
}
|
||||
#endif
|
||||
static int
|
||||
action_load(attrib *a, FILE *f)
|
||||
{
|
||||
action *act = (action *)a->data.v;
|
||||
int i, j, nints;
|
||||
obj_ID id;
|
||||
|
||||
fscanf(f, "%d", &i); act->resid = -(i);
|
||||
fscanf(f, "%d", &i); act->atype = i;
|
||||
id = read_ID(f);
|
||||
fscanf(f, "%d", &i); act->typ = i;
|
||||
add_ID_resolve(id, &act->obj, act->typ);
|
||||
|
||||
if( global.data_version < ACTIONFIX1_VERSION )
|
||||
fscanf(f, "%d %d", &act->i[0], &act->i[1]);
|
||||
else {
|
||||
fscanf(f, "%d", &nints);
|
||||
assert(nints <= ACTION_INTS);
|
||||
for( j = 0; j < nints ; j++ )
|
||||
fscanf(f, "%d", &act->i[j]);
|
||||
}
|
||||
fscanf(f, "%s", buf);
|
||||
if( strcmp(buf, NULLSTRING) != 0 )
|
||||
act->string = strdup(cstring(buf));
|
||||
else
|
||||
act->string = NULL;
|
||||
|
||||
#if 0
|
||||
/* speziell für Runde 199->200 */
|
||||
iuw_fix_action(act);
|
||||
#endif
|
||||
|
||||
/* irace fix für AC_CHANGERACE */
|
||||
if (act->atype == AC_CHANGERACE){
|
||||
if (!act->i[1]){
|
||||
act->i[1] = act->i[0];
|
||||
while (act->i[1] == RC_DAEMON){
|
||||
act->i[1] = rand()%11;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* garbage collection */
|
||||
#ifdef OLD_TRIGGER
|
||||
static int
|
||||
action_age(attrib *a)
|
||||
{
|
||||
action *act = (action *)a->data.v;
|
||||
|
||||
if( act->atype == AC_NONE ) {
|
||||
change_all_pointers(act, TYP_ACTION, NULL); /* zur Sicherheit */
|
||||
return 0; /* dieses Attrib kann gelöscht werden */
|
||||
}
|
||||
|
||||
/* wenn keine Auslöser (old_trigger/Timeouts) mehr auf uns zeigen, dann
|
||||
* kann sie auch gelöscht werden.
|
||||
*/
|
||||
return (count_all_pointers(act, TYP_ACTION) != 0);
|
||||
}
|
||||
#endif
|
||||
attrib_type at_action = {
|
||||
"event_action",
|
||||
action_init,
|
||||
action_done,
|
||||
#ifdef CONVERT_TRIGGER
|
||||
NULL, NULL,
|
||||
#else
|
||||
action_age,
|
||||
action_save,
|
||||
#endif
|
||||
action_load,
|
||||
};
|
||||
|
||||
void *
|
||||
action_resolve(void *pp)
|
||||
{
|
||||
int id = (int)pp;
|
||||
action *a;
|
||||
|
||||
for( a = all_actions; a != NULL; a = a->next ) {
|
||||
if( a->resid == -(id) ) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
#ifdef DIE
|
||||
assert(0);
|
||||
#else
|
||||
fprintf(stderr, "WARNING: could not resolve action %d\n", id);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static action *
|
||||
alloc_action(action_t atype, void *obj2, typ_t typ2, spread_t spr2)
|
||||
{
|
||||
attrib *a;
|
||||
attrib **ap;
|
||||
action *act;
|
||||
|
||||
ap = typdata[typ2].getattribs(obj2);
|
||||
a = a_new(&at_action);
|
||||
a_add(ap, a);
|
||||
|
||||
act = (action *)a->data.v;
|
||||
act->atype = atype;
|
||||
act->obj = obj2;
|
||||
act->typ = typ2;
|
||||
act->spread = spr2;
|
||||
|
||||
return act;
|
||||
}
|
||||
|
||||
/********** actionlist **********/
|
||||
|
||||
static actionlist *
|
||||
new_actionlist_entry(actionlist **al_startP)
|
||||
{
|
||||
actionlist *al;
|
||||
al = calloc(1, sizeof(actionlist));
|
||||
|
||||
al->next = (*al_startP);
|
||||
(*al_startP) = al;
|
||||
return al;
|
||||
}
|
||||
|
||||
static void
|
||||
add_actionlist_entry(actionlist **al_startP, action *a)
|
||||
{
|
||||
actionlist *al;
|
||||
al = new_actionlist_entry(al_startP);
|
||||
al->act = a;
|
||||
tag_pointer(&al->act, TYP_ACTION, TAG_NORMAL);
|
||||
}
|
||||
|
||||
static void
|
||||
free_actionlist_entry(actionlist *al)
|
||||
{
|
||||
#if 0
|
||||
if( al->act )
|
||||
untag_pointer(&al->act, TYP_ACTION, TAG_NORMAL);
|
||||
free(al);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
free_actionlist(actionlist *al_start)
|
||||
{
|
||||
actionlist *al;
|
||||
|
||||
while( (al = al_start)!=NULL ) {
|
||||
al_start = al->next;
|
||||
free_actionlist_entry(al);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
save_actionlist(actionlist *al_start, FILE *f)
|
||||
{
|
||||
actionlist *al;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
for( al = al_start; al != NULL; al = al->next ) {
|
||||
if( al->act && al->act->atype != AC_NONE )
|
||||
++count;
|
||||
}
|
||||
|
||||
fprintf(f, " %d\n", count);
|
||||
for( al = al_start; al != NULL; al = al->next ) {
|
||||
if( al->act && al->act->atype != AC_NONE )
|
||||
save_action_pointer(f, al->act, TAG_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
static actionlist *
|
||||
load_actionlist(FILE *f)
|
||||
{
|
||||
actionlist *al, *al_start = NULL;
|
||||
int count;
|
||||
|
||||
fscanf(f, "%d", &count);
|
||||
while( count-- ) {
|
||||
al = new_actionlist_entry(&al_start);
|
||||
load_action_pointer(f, &al->act);
|
||||
}
|
||||
return al_start;
|
||||
}
|
||||
|
||||
/********** old_trigger attribute **********/
|
||||
|
||||
static old_trigger *all_triggers;
|
||||
|
||||
static void
|
||||
trigger_init(attrib *a)
|
||||
{
|
||||
old_trigger *t;
|
||||
|
||||
t = calloc(1, sizeof(old_trigger));
|
||||
a->data.v = t;
|
||||
}
|
||||
|
||||
static void
|
||||
trigger_done(attrib *a)
|
||||
{
|
||||
old_trigger *t = (old_trigger *)a->data.v;
|
||||
free_actionlist(t->acts);
|
||||
while (t->attribs) {
|
||||
a_remove(&t->attribs, t->attribs);
|
||||
}
|
||||
free(t);
|
||||
}
|
||||
#ifdef OLD_TRIGGER
|
||||
static void
|
||||
trigger_save(const attrib *a, FILE *f)
|
||||
{
|
||||
old_trigger *t = (old_trigger *)a->data.v;
|
||||
|
||||
fprintf(f, "%d ", trigger_id(t));
|
||||
write_ID(f, get_ID(t->obj, t->typ));
|
||||
fprintf(f, "%d ", (int)t->typ);
|
||||
fprintf(f, "%d ", (int)t->condition);
|
||||
save_actionlist(t->acts, f);
|
||||
}
|
||||
#endif
|
||||
static int
|
||||
trigger_load(attrib *a, FILE *f)
|
||||
{
|
||||
old_trigger *t = (old_trigger *)a->data.v;
|
||||
int i;
|
||||
obj_ID id;
|
||||
|
||||
fscanf(f, "%d", &i); t->resid = -(i);
|
||||
id = read_ID(f);
|
||||
fscanf(f, "%d", &i); t->typ = i;
|
||||
add_ID_resolve(id, &t->obj, t->typ);
|
||||
fscanf(f, "%d", &i); t->condition = i;
|
||||
t->acts = load_actionlist(f);
|
||||
return 1;
|
||||
}
|
||||
#ifdef OLD_TRIGGER
|
||||
/* garbage collection */
|
||||
static int
|
||||
trigger_age(attrib *a)
|
||||
{
|
||||
old_trigger *t = (old_trigger *)a->data.v;
|
||||
actionlist *al;
|
||||
int count;
|
||||
|
||||
if( t->condition == TR_NONE ) {
|
||||
change_all_pointers(t, TYP_TRIGGER, NULL); /* zur Sicherheit */
|
||||
return 0;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
for( al = t->acts; al != NULL; al = al->next ) {
|
||||
if( al->act != NULL )
|
||||
++count;
|
||||
}
|
||||
/* wenn keine Aktionen mehr von diesem old_trigger abhängen, dann
|
||||
* kann dieses Attrib gelöscht werden.
|
||||
*/
|
||||
return (count != 0);
|
||||
}
|
||||
#endif
|
||||
attrib_type at_trigger = {
|
||||
"event_trigger",
|
||||
trigger_init,
|
||||
trigger_done,
|
||||
#ifdef CONVERT_TRIGGER
|
||||
NULL, NULL,
|
||||
#else
|
||||
trigger_age,
|
||||
trigger_save,
|
||||
#endif
|
||||
trigger_load,
|
||||
};
|
||||
|
||||
|
||||
void *
|
||||
trigger_resolve(void * data)
|
||||
{
|
||||
int id = (int)data;
|
||||
old_trigger *a;
|
||||
|
||||
for( a = all_triggers; a != NULL; a = a->next ) {
|
||||
if( a->resid == -(id) ) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
#ifdef DIE
|
||||
assert(0);
|
||||
#else
|
||||
fprintf(stderr, "WARNING: could not resolve old_trigger %d\n", id);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/********** timeout **********/
|
||||
|
||||
timeout *all_timeouts;
|
||||
|
||||
static timeout *
|
||||
alloc_timeout(int ticks)
|
||||
{
|
||||
timeout *t;
|
||||
|
||||
t = calloc(1, sizeof(timeout));
|
||||
t->next = all_timeouts;
|
||||
all_timeouts = t;
|
||||
t->ticks = ticks;
|
||||
return t;
|
||||
}
|
||||
|
||||
/******************************************************/
|
||||
|
||||
static actionlist *datalist, *deathlist;
|
||||
|
||||
static void
|
||||
prepare_actions(actionlist **al_startP)
|
||||
{
|
||||
actionlist *al;
|
||||
|
||||
while( (al = *al_startP)!=NULL ) {
|
||||
*al_startP = al->next; /* unlink */
|
||||
/* TODO */
|
||||
if( !al->act ) continue;
|
||||
if( al->act->atype == AC_DESTROY ) {
|
||||
al->next = deathlist;
|
||||
deathlist = al;
|
||||
} else {
|
||||
al->next = datalist;
|
||||
datalist = al;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
do_actions(void)
|
||||
{
|
||||
actionlist *al;
|
||||
action *act;
|
||||
static int in_progress;
|
||||
|
||||
if( in_progress )
|
||||
return;
|
||||
in_progress = 1;
|
||||
|
||||
for(;;) {
|
||||
if( datalist ) {
|
||||
al = datalist;
|
||||
datalist = al->next;
|
||||
} else if( deathlist ) {
|
||||
al = deathlist;
|
||||
deathlist = al->next;
|
||||
} else
|
||||
break; /* keine Einträge mehr in den Listen */
|
||||
|
||||
act = al->act;
|
||||
free_actionlist_entry(al);
|
||||
if( !act )
|
||||
continue;
|
||||
|
||||
switch( act->atype ) {
|
||||
case AC_NONE:
|
||||
break;
|
||||
case AC_DESTROY:
|
||||
if( typdata[act->typ].destroy )
|
||||
typdata[act->typ].destroy(act->obj);
|
||||
break;
|
||||
case AC_REMOVECURSE: {
|
||||
attrib **ap;
|
||||
ap = typdata[act->typ].getattribs(act->obj);
|
||||
remove_curse(ap, (curse_t)act->i[0], act->i[1]);
|
||||
break;
|
||||
}
|
||||
case AC_REMOVERELATION:
|
||||
remove_relation(act->obj, act->typ, act->i[0]);
|
||||
break;
|
||||
case AC_SENDMESSAGE: {
|
||||
unit *u;
|
||||
assert(act->typ == TYP_UNIT);
|
||||
u = (unit*)act->obj;
|
||||
addmessage(u->region, u->faction, act->string, act->i[0], act->i[1]);
|
||||
break;
|
||||
}
|
||||
case AC_CHANGERACE: {
|
||||
unit *u;
|
||||
assert(act->typ == TYP_UNIT);
|
||||
u = (unit*)act->obj;
|
||||
if(u->race == RC_TOAD && rand()%100 > 20){
|
||||
change_item(u, I_TOADSLIME, 1);
|
||||
}
|
||||
u->race = (race_t)act->i[0];
|
||||
u->irace = (race_t)act->i[1];
|
||||
break;
|
||||
}
|
||||
case AC_CHANGEIRACE: {
|
||||
unit *u;
|
||||
assert(act->typ == TYP_UNIT);
|
||||
u = (unit*)act->obj;
|
||||
u->irace = (race_t)act->i[0];
|
||||
break;
|
||||
}
|
||||
case AC_SHOCK:
|
||||
assert(act->typ == TYP_UNIT);
|
||||
do_shock((unit*)act->obj, "");
|
||||
break;
|
||||
case AC_CHANGEFACTION: {
|
||||
faction *f;
|
||||
assert(act->typ == TYP_UNIT);
|
||||
f = findfaction_unique_id(act->i[0]);
|
||||
u_setfaction((unit*)act->obj, f);
|
||||
break;
|
||||
}
|
||||
case AC_CREATEUNIT:{
|
||||
faction *f;
|
||||
f = findfaction_unique_id(act->i[0]);
|
||||
createunit((region *)act->obj, f, act->i[1], (race_t)act->i[2]);
|
||||
break;
|
||||
}
|
||||
case AC_CREATEMAGICBOOSTCURSE:{
|
||||
unit *mage = (unit*)act->obj;
|
||||
create_curse(mage, &mage->attribs, C_AURA, 0, act->i[0], 6, 50, 1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
remove_action(act);
|
||||
}
|
||||
|
||||
in_progress = 0;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
PUBLIC FUNCTIONS
|
||||
***************************************************************/
|
||||
|
||||
struct old_trigger *
|
||||
create_trigger(void *obj1, typ_t typ1, spread_t spread1, trigger_t condition)
|
||||
{
|
||||
attrib *a;
|
||||
attrib **ap;
|
||||
old_trigger *t;
|
||||
|
||||
ap = typdata[typ1].getattribs(obj1);
|
||||
a = a_new(&at_trigger);
|
||||
a_add(ap, a);
|
||||
|
||||
t = (old_trigger *)a->data.v;
|
||||
t->obj = obj1;
|
||||
t->typ = typ1;
|
||||
t->condition = condition;
|
||||
t->spread = spread1;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
attrib *
|
||||
a_find_by_vdata(attrib *attrs, const attrib_type *atP, void *vdata)
|
||||
{
|
||||
attrib *a;
|
||||
|
||||
a = a_find(attrs, atP);
|
||||
while( a ) {
|
||||
if( a->data.v == vdata )
|
||||
return a;
|
||||
a = a->nexttype;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
remove_trigger(old_trigger *t)
|
||||
{
|
||||
#if 0
|
||||
attrib *a;
|
||||
attrib **ap;
|
||||
#endif
|
||||
|
||||
if( t ) {
|
||||
change_all_pointers(t, TYP_TRIGGER, NULL);
|
||||
t->condition = TR_NONE;
|
||||
/* die Struktur selber bleibt bis zum Ende des Programms im
|
||||
* Speicher, weil evtl noch Stackvariablen hierauf zeigen.
|
||||
*/
|
||||
#if 0
|
||||
ap = typdata[t->typ].getattribs(t->obj);
|
||||
a = a_find_by_vdata(*ap, &at_trigger, (void *)t);
|
||||
assert(a != NULL);
|
||||
a_remove(ap, a);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
extern void ur_add2(int id, void ** ptrptr, typ_t typ, tag_t tag, resolve_fun fun);
|
||||
|
||||
void
|
||||
do_trigger(void *obj1, typ_t typ1, trigger_t condition)
|
||||
{
|
||||
#if 0
|
||||
attrib *a, *next_a;
|
||||
attrib **ap;
|
||||
old_trigger *t;
|
||||
|
||||
assert(condition != TR_NONE);
|
||||
|
||||
ap = typdata[typ1].getattribs(obj1);
|
||||
a = a_find(*ap, &at_trigger);
|
||||
while( a ) {
|
||||
next_a = a->nexttype;
|
||||
t = (old_trigger *)a->data.v;
|
||||
|
||||
if( t->condition == condition ) {
|
||||
prepare_actions(&t->acts);
|
||||
t->condition = TR_NONE;
|
||||
#if 0
|
||||
a_remove(ap, a);
|
||||
#endif
|
||||
}
|
||||
a = next_a;
|
||||
}
|
||||
do_actions();
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************************************/
|
||||
|
||||
struct timeout *
|
||||
create_timeout(int ticks)
|
||||
{
|
||||
return alloc_timeout(ticks+1);
|
||||
}
|
||||
|
||||
void
|
||||
remove_timeout(timeout *t)
|
||||
{
|
||||
if( t ) {
|
||||
change_all_pointers(t, TYP_TIMEOUT, NULL);
|
||||
/* die Timeout-Struktur selber bleibt noch bis zum Ende des
|
||||
* Programms erhalten, weil evtl noch Stackvariablen hierauf
|
||||
* zeigen.
|
||||
*/
|
||||
t->ticks = -1;
|
||||
free_actionlist(t->acts);
|
||||
t->acts = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
save_timeout_pointer(FILE *f, timeout *ptr, tag_t tag)
|
||||
{
|
||||
if( ptr && ptr->ticks < 0 )
|
||||
ptr = NULL;
|
||||
fprintf(f, " %d %d ", ptr ? timeout_id(ptr) : 0, (int)tag);
|
||||
}
|
||||
|
||||
void
|
||||
save_timeouts(FILE *f)
|
||||
{
|
||||
timeout *t;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
for( t = all_timeouts; t != NULL; t = t->next ) {
|
||||
if( t->ticks > 0 )
|
||||
++count;
|
||||
}
|
||||
|
||||
fprintf(f, "\n%d\n", count);
|
||||
for( t = all_timeouts; t != NULL; t = t->next ) {
|
||||
if( t->ticks > 0 ) {
|
||||
fprintf(f, " %d", timeout_id(t));
|
||||
fprintf(f, " %d", t->ticks);
|
||||
save_actionlist(t->acts, f);
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
load_timeouts(FILE *f)
|
||||
{
|
||||
timeout *t;
|
||||
int count, ticks, id;
|
||||
|
||||
fscanf(f, "%d", &count);
|
||||
while( count-- ) {
|
||||
fscanf(f, "%d", &id);
|
||||
fscanf(f, "%d", &ticks);
|
||||
|
||||
t = alloc_timeout(ticks);
|
||||
t->resid = -(id);
|
||||
t->acts = load_actionlist(f);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************/
|
||||
|
||||
void
|
||||
link_action_trigger(struct action *a, struct old_trigger *t)
|
||||
{
|
||||
add_actionlist_entry(&t->acts, a);
|
||||
}
|
||||
|
||||
void
|
||||
link_action_timeout(struct action *a, struct timeout *t)
|
||||
{
|
||||
add_actionlist_entry(&t->acts, a);
|
||||
}
|
||||
|
||||
/******************************************/
|
||||
|
||||
void
|
||||
countdown_timeouts(void)
|
||||
{
|
||||
timeout *t;
|
||||
|
||||
for( t = all_timeouts; t != NULL; t = t->next ) {
|
||||
t->ticks--;
|
||||
if( t->ticks == 0 )
|
||||
prepare_actions(&t->acts);
|
||||
}
|
||||
do_actions();
|
||||
}
|
||||
|
||||
/********************************************************/
|
||||
|
||||
void
|
||||
save_action_pointer(FILE *f, action *ptr, tag_t tag)
|
||||
{
|
||||
if( ptr && ptr->atype == AC_NONE )
|
||||
ptr = NULL;
|
||||
fprintf(f, " %d %d ", ptr ? action_id(ptr) : 0, (int)tag);
|
||||
}
|
||||
|
||||
int
|
||||
load_action_pointer(FILE *f, action **ptrP)
|
||||
{
|
||||
int id, tag;
|
||||
|
||||
fscanf(f, "%d %d", &id, &tag);
|
||||
if( id )
|
||||
/* TODO: cast void ** richtig? */
|
||||
ur_add2(id, (void **)ptrP, TYP_ACTION, (tag_t)tag, action_resolve);
|
||||
else
|
||||
*ptrP = NULL;
|
||||
return id;
|
||||
}
|
||||
|
||||
void
|
||||
remove_all_actions(void *obj, typ_t typ)
|
||||
{
|
||||
attrib *a;
|
||||
attrib **ap;
|
||||
action *act;
|
||||
|
||||
ap = typdata[typ].getattribs(obj);
|
||||
a = a_find(*ap, &at_action);
|
||||
while( a ) {
|
||||
act = (action *)a->data.v;
|
||||
change_all_pointers(act, TYP_ACTION, NULL);
|
||||
act->atype = AC_NONE;
|
||||
a = a->nexttype;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
remove_action(action *act)
|
||||
{
|
||||
#if 0
|
||||
attrib **ap;
|
||||
attrib *a;
|
||||
#endif
|
||||
|
||||
if( act ) {
|
||||
change_all_pointers(act, TYP_ACTION, NULL);
|
||||
act->atype = AC_NONE;
|
||||
/* die Aktionsstruktur selber bleibt noch erhalten und wird erst
|
||||
* beim Garbage Collect vorm Speichern gelöscht, weil evtl noch
|
||||
* lokale Stackvariablen auf diese Struktur zeigen.
|
||||
*/
|
||||
#if 0
|
||||
ap = typdata[act->typ].getattribs(act->obj);
|
||||
a = a_find_by_vdata(*ap, &at_action, (void *)act);
|
||||
assert(a != NULL);
|
||||
a_remove(ap, a);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/************ Frontends für die einzelnen Aktionen *************/
|
||||
|
||||
struct action *
|
||||
action_destroy(void *obj2, typ_t typ2, spread_t spr2)
|
||||
{
|
||||
return alloc_action(AC_DESTROY, obj2, typ2, spr2);
|
||||
}
|
||||
|
||||
struct action *
|
||||
action_removecurse(void *obj2, typ_t typ2, spread_t spr2, curse_t id, int id2)
|
||||
{
|
||||
action *ac;
|
||||
ac = alloc_action(AC_REMOVECURSE, obj2, typ2, spr2);
|
||||
ac->i[0] = (int)id;
|
||||
ac->i[1] = id2;
|
||||
return ac;
|
||||
}
|
||||
|
||||
struct action *
|
||||
action_removerelation(void *obj2, typ_t typ2, spread_t spr2, relation_t id)
|
||||
{
|
||||
action *ac;
|
||||
ac = alloc_action(AC_REMOVERELATION, obj2, typ2, spr2);
|
||||
ac->i[0] = (int)id;
|
||||
return ac;
|
||||
}
|
||||
|
||||
struct action *
|
||||
action_sendmessage(void *obj2, typ_t typ2, spread_t spr2,
|
||||
char *m, msg_t mtype, int mlevel)
|
||||
{
|
||||
action *ac;
|
||||
assert(typ2 == TYP_UNIT);
|
||||
ac = alloc_action(AC_SENDMESSAGE, obj2, typ2, spr2);
|
||||
ac->string = strdup(m);
|
||||
ac->i[0] = (int)mtype;
|
||||
ac->i[1] = mlevel;
|
||||
return ac;
|
||||
}
|
||||
|
||||
struct action *
|
||||
action_changeirace(void *obj2, typ_t typ2, spread_t spr2,
|
||||
race_t race)
|
||||
{
|
||||
action *ac;
|
||||
assert(typ2 == TYP_UNIT);
|
||||
ac = alloc_action(AC_CHANGEIRACE, obj2, typ2, spr2);
|
||||
ac->i[0] = (int)race;
|
||||
return ac;
|
||||
}
|
||||
|
||||
struct action *
|
||||
action_changerace(void *obj2, typ_t typ2, spread_t spr2,
|
||||
race_t race, race_t irace)
|
||||
{
|
||||
action *ac;
|
||||
assert(typ2 == TYP_UNIT);
|
||||
ac = alloc_action(AC_CHANGERACE, obj2, typ2, spr2);
|
||||
ac->i[0] = (int)race;
|
||||
ac->i[1] = (int)irace;
|
||||
return ac;
|
||||
}
|
||||
|
||||
struct action *
|
||||
action_shock(void *obj2, typ_t typ2, spread_t spr2)
|
||||
{
|
||||
action *ac;
|
||||
assert(typ2 == TYP_UNIT);
|
||||
ac = alloc_action(AC_SHOCK, obj2, typ2, spr2);
|
||||
return ac;
|
||||
}
|
||||
|
||||
struct action *
|
||||
action_changefaction(void *obj2, typ_t typ2, spread_t spr2,
|
||||
int unique_id)
|
||||
{
|
||||
action *ac;
|
||||
assert(typ2 == TYP_UNIT);
|
||||
ac = alloc_action(AC_CHANGEFACTION, obj2, typ2, spr2);
|
||||
ac->i[0] = unique_id;
|
||||
return ac;
|
||||
}
|
||||
|
||||
struct action *
|
||||
action_createunit(void *obj2, typ_t typ2, spread_t spr2,
|
||||
int fno, int number, race_t race)
|
||||
{
|
||||
action *ac;
|
||||
assert(typ2 == TYP_REGION);
|
||||
ac = alloc_action(AC_CREATEUNIT, obj2, typ2, spr2);
|
||||
ac->i[0] = fno;
|
||||
ac->i[1] = number;
|
||||
ac->i[2] = race;
|
||||
return ac;
|
||||
}
|
||||
|
||||
struct action *
|
||||
action_createmagicboostcurse(void *obj2, typ_t typ2, spread_t spr2, int power)
|
||||
{
|
||||
action *ac;
|
||||
assert(typ2 == TYP_UNIT);
|
||||
ac = alloc_action(AC_CREATEMAGICBOOSTCURSE, obj2, typ2, spr2);
|
||||
ac->i[0] = power;
|
||||
return ac;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,94 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea-pbem.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#if !(defined(OLD_TRIGGER) || defined(CONVERT_TRIGGER))
|
||||
# error "Do not include unless for old code or to enable conversion"
|
||||
#endif
|
||||
|
||||
#ifndef TRIGGER_H
|
||||
#define TRIGGER_H
|
||||
|
||||
#include "relation.h"
|
||||
#include "attrspread.h"
|
||||
|
||||
/* Ausloeser/Conditions */
|
||||
typedef enum {
|
||||
TR_NONE, /* wird intern benutzt, nicht verwenden */
|
||||
TR_DESTRUCT, /* wenn das Objekt stirbt/zerstört wird */
|
||||
|
||||
MAX_TRIGGER_T /* must be last */
|
||||
} trigger_t;
|
||||
|
||||
#include "trigger_internal.h"
|
||||
|
||||
|
||||
/* old_trigger functions */
|
||||
|
||||
old_trigger *create_trigger(void *obj1, typ_t typ1, spread_t spread1,
|
||||
trigger_t condition);
|
||||
void remove_trigger(old_trigger *t);
|
||||
|
||||
void do_trigger(void *obj1, typ_t typ1, trigger_t condition);
|
||||
|
||||
|
||||
/* timeout functions */
|
||||
#include "pointertags.h"
|
||||
timeout *create_timeout(int ticks);
|
||||
void remove_timeout(timeout *t);
|
||||
void save_timeout_pointer(FILE *f, timeout *t, tag_t tag);
|
||||
|
||||
void save_timeouts(FILE *f);
|
||||
void load_timeouts(FILE *f);
|
||||
void countdown_timeouts(void);
|
||||
|
||||
|
||||
/* link */
|
||||
|
||||
void link_action_trigger(action *a, old_trigger *t);
|
||||
void link_action_timeout(action *a, timeout *t);
|
||||
|
||||
|
||||
/* action functions */
|
||||
|
||||
void remove_action(action *a);
|
||||
void remove_all_actions(void *obj, typ_t typ);
|
||||
void save_action_pointer(FILE *f, action *a, tag_t tag);
|
||||
int load_action_pointer(FILE *f, action **aP);
|
||||
|
||||
|
||||
action *action_destroy(void *obj2, typ_t typ2, spread_t spread2);
|
||||
action *action_removecurse(void *obj2, typ_t typ2, spread_t spread2,
|
||||
curse_t id, int id2);
|
||||
action *action_removerelation(void *obj2, typ_t typ2, spread_t spread2,
|
||||
relation_t id);
|
||||
action *action_sendmessage(void *obj2, typ_t typ2, spread_t spread2,
|
||||
char *m, msg_t mtype, int mlevel);
|
||||
action *action_changeirace(void *obj2, typ_t typ2, spread_t spread2,
|
||||
race_t race);
|
||||
action *action_changerace(void *obj2, typ_t typ2, spread_t spread2,
|
||||
race_t race, race_t irace);
|
||||
action *action_shock(void *obj2, typ_t typ2, spread_t spread2);
|
||||
action *action_changefaction(void *obj2, typ_t typ2, spread_t spread2,
|
||||
int unique_faction_id);
|
||||
struct action * action_createunit(void *obj2, typ_t typ2, spread_t spr2,
|
||||
int fno, int number, race_t race);
|
||||
struct action * action_createmagicboostcurse(void *obj2, typ_t typ2, spread_t spr2,
|
||||
int power);
|
||||
|
||||
#include "attrib.h"
|
||||
|
||||
extern attrib_type at_trigger;
|
||||
extern attrib_type at_action;
|
||||
|
||||
#endif /* TRIGGER_H */
|
|
@ -1,87 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea-pbem.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#if !(defined(OLD_TRIGGER) || defined(CONVERT_TRIGGER))
|
||||
# error "Do not include unless for old code or to enable conversion"
|
||||
#endif
|
||||
|
||||
#ifndef TRIGGER_INTERNAL_H
|
||||
#define TRIGGER_INTERNAL_H
|
||||
|
||||
#ifndef OBJTYPES_H
|
||||
# include <old/objtypes.h>
|
||||
#endif
|
||||
typedef enum {
|
||||
AC_NONE, /* wird intern verwendet, nicht benutzen! */
|
||||
AC_DESTROY,
|
||||
AC_REMOVECURSE,
|
||||
AC_REMOVERELATION,
|
||||
AC_SENDMESSAGE,
|
||||
AC_CHANGERACE,
|
||||
AC_SHOCK,
|
||||
AC_CHANGEFACTION,
|
||||
AC_CREATEUNIT,
|
||||
AC_CHANGEIRACE,
|
||||
AC_CREATEMAGICBOOSTCURSE,
|
||||
|
||||
MAX_ACTION_T
|
||||
} action_t;
|
||||
|
||||
#define ACTION_MAGIC 0xC0DEBABE
|
||||
typedef struct action {
|
||||
int magic;
|
||||
struct action *next; /* Link in globaler action-List */
|
||||
int resid; /* temporäre resolve-id */
|
||||
attrib *attribs; /* für pointertags */
|
||||
|
||||
action_t atype;
|
||||
|
||||
void *obj; /* points to self */
|
||||
typ_t typ;
|
||||
spread_t spread;
|
||||
|
||||
/* arguments */
|
||||
#define ACTION_INTS 4
|
||||
int i[ACTION_INTS];
|
||||
char *string;
|
||||
} action;
|
||||
|
||||
typedef struct actionlist {
|
||||
struct actionlist *next;
|
||||
action *act;
|
||||
} actionlist;
|
||||
|
||||
typedef struct old_trigger {
|
||||
struct old_trigger *next; /* Link in globaler old_trigger-List */
|
||||
int resid; /* temporäre resolve-id */
|
||||
attrib *attribs; /* für pointertags */
|
||||
|
||||
void *obj; /* points to self */
|
||||
typ_t typ;
|
||||
|
||||
trigger_t condition;
|
||||
spread_t spread;
|
||||
actionlist *acts;
|
||||
} old_trigger;
|
||||
|
||||
typedef struct timeout {
|
||||
struct timeout *next;
|
||||
int resid; /* temporäre resolve-id */
|
||||
attrib *attribs; /* für pointertags */
|
||||
|
||||
int ticks;
|
||||
actionlist *acts;
|
||||
} timeout;
|
||||
|
||||
#endif /* TRIGGER_INTERNAL_H */
|
Loading…
Reference in New Issue