diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 221dde231..da55b9df5 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.13 2001/02/12 22:39:56 enno Exp $ + * $Id: eressea.c,v 1.14 2001/02/13 02:58:51 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) @@ -1033,7 +1033,7 @@ igetstrtoken (const char *s1) s++; i = 0; - while (i < DISPLAYSIZE && *s && *s != ' ') { + while (*s && *s != ' ' && i < DISPLAYSIZE) { buf[i] = (*s); /* Hier wird space_replacement wieder in space zurueck diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index 0b3802e5d..720d690b7 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: item.c,v 1.9 2001/02/11 20:54:01 enno Exp $ + * $Id: item.c,v 1.10 2001/02/13 02:58:51 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) @@ -44,11 +44,21 @@ potion_type * potiontypes; item_type * itemtypes; herb_type * herbtypes; -attrib_type at_ptype = { "potion_type" }; -attrib_type at_wtype = { "weapon_type" }; -attrib_type at_ltype = { "luxury_type" }; -attrib_type at_itype = { "item_type" }; -attrib_type at_htype = { "herb_type" }; +#ifdef AT_PTYPE +static attrib_type at_ptype = { "potion_type" }; +#endif +#ifdef AT_WTYPE +static attrib_type at_wtype = { "weapon_type" }; +#endif +#ifdef AT_LTYPE +static attrib_type at_ltype = { "luxury_type" }; +#endif +#ifdef AT_ITYPE +static attrib_type at_itype = { "item_type" }; +#endif +#ifdef AT_HTYPE +static attrib_type at_htype = { "herb_type" }; +#endif static int res_changeaura(unit * u, const resource_type * rtype, int delta) @@ -158,7 +168,11 @@ it_register(item_type * itype) item_type ** p_itype = &itemtypes; while (*p_itype && *p_itype != itype) p_itype = &(*p_itype)->next; if (*p_itype==NULL) { +#ifdef AT_ITYPE a_add(&itype->rtype->attribs, a_new(&at_itype))->data.v = (void*) itype; +#else + itype->rtype->itype = itype; +#endif *p_itype = itype; rt_register(itype->rtype); } @@ -190,7 +204,11 @@ new_itemtype(resource_type * rtype, void lt_register(luxury_type * ltype) { +#ifdef AT_LTYPE a_add(<ype->itype->rtype->attribs, a_new(&at_ltype))->data.v = (void*) ltype; +#else + ltype->itype->rtype->ltype = ltype; +#endif ltype->next = luxurytypes; luxurytypes = ltype; } @@ -214,7 +232,11 @@ new_luxurytype(item_type * itype, int price) void wt_register(weapon_type * wtype) { +#ifdef AT_WTYPE a_add(&wtype->itype->rtype->attribs, a_new(&at_wtype))->data.v = (void*) wtype; +#else + wtype->itype->rtype->wtype = wtype; +#endif wtype->next = weapontypes; weapontypes = wtype; } @@ -250,7 +272,11 @@ new_weapontype(item_type * itype, void pt_register(potion_type * ptype) { +#ifdef AT_PTYPE a_add(&ptype->itype->rtype->attribs, a_new(&at_ptype))->data.v = (void*) ptype; +#else + ptype->itype->rtype->ptype = ptype; +#endif ptype->next = potiontypes; potiontypes = ptype; } @@ -276,7 +302,11 @@ new_potiontype(item_type * itype, void ht_register(herb_type * htype) { +#ifdef AT_HTYPE a_add(&htype->itype->rtype->attribs, a_new(&at_htype))->data.v = (void*) htype; +#else + htype->itype->rtype->htype = htype; +#endif htype->next = herbtypes; herbtypes = htype; } @@ -312,43 +342,68 @@ rt_register(resource_type * rtype) } const resource_type * -item2resource(const item_type * itype) { +item2resource(const item_type * itype) +{ return itype->rtype; } const item_type * -resource2item(const resource_type * rtype) { +resource2item(const resource_type * rtype) +{ +#ifdef AT_ITYPE attrib * a = a_find(rtype->attribs, &at_itype); if (a) return (const item_type *)a->data.v; return NULL; +#else + return rtype->itype; +#endif } const herb_type * -resource2herb(const resource_type * rtype) { +resource2herb(const resource_type * rtype) +{ +#ifdef AT_HTYPE attrib * a = a_find(rtype->attribs, &at_htype); if (a) return (const herb_type *)a->data.v; return NULL; +#else + return rtype->htype; +#endif } const weapon_type * resource2weapon(const resource_type * rtype) { +#ifdef AT_WTYPE attrib * a = a_find(rtype->attribs, &at_wtype); if (a) return (const weapon_type *)a->data.v; return NULL; +#else + return rtype->wtype; +#endif } const luxury_type * -resource2luxury(const resource_type * rtype) { +resource2luxury(const resource_type * rtype) +{ +#ifdef AT_LTYPE attrib * a = a_find(rtype->attribs, &at_ltype); if (a) return (const luxury_type *)a->data.v; return NULL; +#else + return rtype->ltype; +#endif } const potion_type * -resource2potion(const resource_type * rtype) { +resource2potion(const resource_type * rtype) +{ +#ifdef AT_PTYPE attrib * a = a_find(rtype->attribs, &at_ptype); if (a) return (const potion_type *)a->data.v; return NULL; +#else + return rtype->ptype; +#endif } resource_type * diff --git a/src/common/kernel/item.h b/src/common/kernel/item.h index 52a90e9df..aa63ec357 100644 --- a/src/common/kernel/item.h +++ b/src/common/kernel/item.h @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: item.h,v 1.3 2001/02/03 13:45:32 enno Exp $ + * $Id: item.h,v 1.4 2001/02/13 02:58:51 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,6 +37,11 @@ typedef struct item { * limited supply */ #define RTF_DYNAMIC (1<<3) /* dynamic type, must be saved */ +#undef AT_ITYPE /* should resource_type use an attribute for items ? */ +#undef AT_HTYPE /* should resource_type use an attribute for herbs ? */ +#undef AT_PTYPE /* should resource_type use an attribute for potions ? */ +#undef AT_LTYPE /* should resource_type use an attribute for luxuries ? */ +#undef AT_WTYPE /* should resource_type use an attribute for weapons ? */ /* flags for resource_type::name() */ #define NMF_PLURAL 0x01 @@ -55,6 +60,21 @@ typedef struct resource_type { struct attrib * attribs; struct resource_type * next; unsigned int hashkey; +#ifndef AT_ITYPE + struct item_type * itype; +#endif +#ifndef AT_HTYPE + struct herb_type * htype; +#endif +#ifndef AT_PTYPE + struct potion_type * ptype; +#endif +#ifndef AT_LTYPE + struct luxury_type * ltype; +#endif +#ifndef AT_WTYPE + struct weapon_type * wtype; +#endif } resource_type; extern resource_type * resourcetypes; extern const char* resourcename(const resource_type * rtype, int flags); diff --git a/src/common/util/umlaut.c b/src/common/util/umlaut.c index c186b5212..1cbc0d2dd 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.3 2001/02/10 10:40:12 enno Exp $ + * $Id: umlaut.c,v 1.4 2001/02/13 02:58:51 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) @@ -50,10 +50,12 @@ addtoken(tnode * root, const char* str, void * id) root->id = id; root->leaf=1; } else { - char c = (char)tolower(*(unsigned char*)str); - int index = ((unsigned char)c) % 32; - int i=0; - tnode * tk = root->next[index]; + tnode * tk; + int index, i = 0; + char c = *str; + if (c<'a' || c>'z') c = (char)tolower((unsigned char)c); + index = ((unsigned char)c) % 32; + tk = root->next[index]; if (root->id==E_TOK_NOMATCH) root->id = id; while (tk && tk->c != c) tk = tk->nexthash; if (!tk) { @@ -81,8 +83,11 @@ findtoken(tnode * tk, const char * str) if(*str == 0) return E_TOK_NOMATCH; while (*str) { - char c = (char)tolower(*str); - int index = ((unsigned char)c) % 32; + int index; + char c = *str; + if (c<'a' || c>'z') c = (char)tolower((unsigned char)c); + + index = ((unsigned char)c) % 32; tk = tk->next[index]; while (tk && tk->c!=c) tk = tk->nexthash; ++str; diff --git a/src/common/util/util-6.dsp b/src/common/util/util-6.dsp index fbb0cebbe..c3fe48464 100644 --- a/src/common/util/util-6.dsp +++ b/src/common/util/util-6.dsp @@ -167,6 +167,10 @@ SOURCE=.\lists.h # End Source File # Begin Source File +SOURCE=.\log.h +# End Source File +# Begin Source File + SOURCE=.\rand.h # End Source File # Begin Source File @@ -228,6 +232,10 @@ SOURCE=.\lists.c # End Source File # Begin Source File +SOURCE=.\log.c +# End Source File +# Begin Source File + SOURCE=.\rand.c # End Source File # Begin Source File diff --git a/src/eressea-6.opt b/src/eressea-6.opt index f1e03834b..5d1ac37d3 100644 Binary files a/src/eressea-6.opt and b/src/eressea-6.opt differ