forked from github/server
neue hashfunktion
This commit is contained in:
parent
102bd9cf02
commit
93620b8c56
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: message.c,v 1.3 2001/02/09 13:53:51 corwin Exp $
|
||||
* $Id: message.c,v 1.4 2001/02/10 11:38:29 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)
|
||||
|
@ -208,8 +208,8 @@ new_messagetype(const char * name, int level, const char * section)
|
|||
messagetype * mt2 = messagetypes;
|
||||
while(mt2 && mt2->hashkey != mt->hashkey) mt2 = mt2->next;
|
||||
if (mt2) {
|
||||
fprintf(stderr, "duplicate hashkey for messagetype %s and %s\n",
|
||||
name, mt2->name);
|
||||
fprintf(stderr, "duplicate hashkey %u for messagetype %s and %s\n",
|
||||
mt->hashkey, name, mt2->name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: render.c,v 1.3 2001/01/30 23:16:17 enno Exp $
|
||||
* $Id: render.c,v 1.4 2001/02/10 11:38:29 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,7 +48,7 @@ int lastint = 0;
|
|||
|
||||
typedef struct localizer {
|
||||
struct localizer * nexthash;
|
||||
int hashkey;
|
||||
unsigned int hashkey;
|
||||
const locale * lang;
|
||||
struct renderer * renderers[RMAXHASH];
|
||||
struct eval * evaluators[RMAXHASH];
|
||||
|
@ -58,14 +58,14 @@ typedef const char* (*eval_fun)(const locale * lang, void *);
|
|||
typedef char * (*render_fun)(const message * m, const locale * lang);
|
||||
|
||||
typedef struct renderer {
|
||||
int hashkey;
|
||||
unsigned int hashkey;
|
||||
render_fun fun;
|
||||
char * name;
|
||||
struct renderer * nexthash;
|
||||
} renderer;
|
||||
|
||||
typedef struct eval {
|
||||
int hashkey;
|
||||
unsigned int hashkey;
|
||||
eval_fun fun;
|
||||
const char * name;
|
||||
struct eval * nexthash;
|
||||
|
@ -74,12 +74,10 @@ typedef struct eval {
|
|||
#define LMAXHASH 32
|
||||
localizer * localizers[LMAXHASH];
|
||||
|
||||
extern int hashstring(const char * name);
|
||||
|
||||
static localizer *
|
||||
get_localizer(const locale * lang)
|
||||
{
|
||||
int hkey = locale_hashkey(lang);
|
||||
unsigned int hkey = locale_hashkey(lang);
|
||||
int id = hkey % LMAXHASH;
|
||||
localizer * find = localizers[id];
|
||||
while (find && find->lang!=lang) find = find->nexthash;
|
||||
|
@ -96,8 +94,8 @@ get_localizer(const locale * lang)
|
|||
void
|
||||
add_renderfun(const char * name, localizer * l, render_fun fun)
|
||||
{
|
||||
int hkey = hashstring(name);
|
||||
int id = hkey % RMAXHASH;
|
||||
unsigned int hkey = hashstring(name);
|
||||
unsigned int id = hkey % RMAXHASH;
|
||||
renderer * find = l->renderers[id];
|
||||
while (find && find->hashkey!=hkey) find=find->nexthash;
|
||||
if (!find) {
|
||||
|
@ -114,8 +112,8 @@ add_renderfun(const char * name, localizer * l, render_fun fun)
|
|||
void
|
||||
add_evalfun(const char * name, localizer * l, eval_fun fun)
|
||||
{
|
||||
int hkey = hashstring(name);
|
||||
int id = hkey % RMAXHASH;
|
||||
unsigned int hkey = hashstring(name);
|
||||
unsigned int id = hkey % RMAXHASH;
|
||||
eval * find = l->evaluators[id];
|
||||
while (find && find->hashkey!=hkey) find=find->nexthash;
|
||||
if (!find) {
|
||||
|
@ -376,8 +374,8 @@ render_default(const message * m, const locale * lang)
|
|||
static render_fun
|
||||
get_renderfun(const char * name, const localizer * l)
|
||||
{
|
||||
int hkey = hashstring(name);
|
||||
int id = hkey % RMAXHASH;
|
||||
unsigned int hkey = hashstring(name);
|
||||
unsigned int id = hkey % RMAXHASH;
|
||||
renderer * find = l->renderers[id];
|
||||
while (find && find->hashkey!=hkey) find=find->nexthash;
|
||||
if (find && !strcmp(find->name, name)) return find->fun;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: goodies.c,v 1.3 2001/02/09 13:53:52 corwin Exp $
|
||||
* $Id: goodies.c,v 1.4 2001/02/10 11:38:29 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)
|
||||
|
@ -57,17 +57,16 @@ intlist_find(int *i_p, int fi)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
unsigned int
|
||||
hashstring(const char* s)
|
||||
{
|
||||
int key = 0;
|
||||
unsigned int key = 0;
|
||||
int i = strlen(s);
|
||||
|
||||
while (i) {
|
||||
--i;
|
||||
key = ((key >> 31) & 1) ^ (key << 1) ^ s[i];
|
||||
while (i>0) {
|
||||
key = (s[--i] + key*37);
|
||||
}
|
||||
return key & 0x7fff;
|
||||
return key;
|
||||
}
|
||||
|
||||
/* Standardfunktion aus Sedgewick: Algorithmen in C++ */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: goodies.h,v 1.2 2001/01/26 16:19:41 enno Exp $
|
||||
* $Id: goodies.h,v 1.3 2001/02/10 11:38:29 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)
|
||||
|
@ -18,7 +18,7 @@
|
|||
extern int *intlist_init(void);
|
||||
extern int *intlist_add(int *i_p, int i);
|
||||
extern int *intlist_find(int *i_p, int i);
|
||||
extern int hashstring(const char* s);
|
||||
extern unsigned int hashstring(const char* s);
|
||||
extern char *escape_string(char * str, char replace);
|
||||
extern char *unescape_string(char * str, char replace);
|
||||
/* grammar constants: */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: language.c,v 1.2 2001/01/26 16:19:41 enno Exp $
|
||||
* $Id: language.c,v 1.3 2001/02/10 11:38:29 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)
|
||||
|
@ -26,10 +26,10 @@ extern int hashstring(const char* s);
|
|||
|
||||
struct locale {
|
||||
struct locale * next;
|
||||
int hashkey;
|
||||
unsigned int hashkey;
|
||||
const char * name;
|
||||
struct locale_string {
|
||||
int hashkey;
|
||||
unsigned int hashkey;
|
||||
struct locale_string * nexthash;
|
||||
char * str;
|
||||
char * key;
|
||||
|
@ -39,7 +39,7 @@ struct locale {
|
|||
static locale * locales;
|
||||
static locale * default_locale;
|
||||
|
||||
int
|
||||
unsigned int
|
||||
locale_hashkey(const locale * lang)
|
||||
{
|
||||
if (lang==NULL) lang = default_locale;
|
||||
|
@ -49,7 +49,7 @@ locale_hashkey(const locale * lang)
|
|||
locale *
|
||||
find_locale(const char * name)
|
||||
{
|
||||
int hkey = hashstring(name);
|
||||
unsigned int hkey = hashstring(name);
|
||||
locale * l = locales;
|
||||
while (l && l->hashkey!=hkey) l=l->next;
|
||||
return l;
|
||||
|
@ -58,7 +58,7 @@ find_locale(const char * name)
|
|||
locale *
|
||||
make_locale(const char * name)
|
||||
{
|
||||
int hkey = hashstring(name);
|
||||
unsigned int hkey = hashstring(name);
|
||||
locale * l = calloc(sizeof(locale), 1);
|
||||
#ifndef NDEBUG
|
||||
locale * lp = locales;
|
||||
|
@ -76,8 +76,8 @@ make_locale(const char * name)
|
|||
const char *
|
||||
locale_string(const locale * lang, const char * key)
|
||||
{
|
||||
int hkey = hashstring(key);
|
||||
int id = hkey % SMAXHASH;
|
||||
unsigned int hkey = hashstring(key);
|
||||
unsigned int id = hkey % SMAXHASH;
|
||||
struct locale_string * find;
|
||||
|
||||
if (key==NULL || *key==0) return NULL;
|
||||
|
@ -102,8 +102,8 @@ void
|
|||
locale_setstring(locale * lang, const char * key, const char * value)
|
||||
{
|
||||
int nval = atoi(key);
|
||||
int hkey = nval?nval:hashstring(key);
|
||||
int id = hkey % SMAXHASH;
|
||||
unsigned int hkey = nval?nval:hashstring(key);
|
||||
unsigned int id = hkey % SMAXHASH;
|
||||
struct locale_string * find;
|
||||
|
||||
if (lang==NULL) lang = default_locale;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: language.h,v 1.2 2001/01/26 16:19:41 enno Exp $
|
||||
* $Id: language.h,v 1.3 2001/02/10 11:38:29 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)
|
||||
|
@ -23,7 +23,7 @@ extern locale * make_locale(const char * key);
|
|||
/** operations on locales: **/
|
||||
extern const char * locale_string(const locale * lang, const char * key);
|
||||
extern void locale_setstring(locale * lang, const char * key, const char * value);
|
||||
extern int locale_hashkey(const locale * lang);
|
||||
extern unsigned int locale_hashkey(const locale * lang);
|
||||
extern const char * locale_name(const locale * lang);
|
||||
|
||||
extern const char * reverse_lookup(const locale * lang, const char * str);
|
||||
|
|
|
@ -236,10 +236,6 @@ SOURCE=.\resolve.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\translation.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\umlaut.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -22,3 +22,18 @@ Es gibt einen Zauber (Ferne Vision) der Einheiten vom Typ RC_SPELL erzeugt, aber
|
|||
- Wie komplex macht man einen Curse?
|
||||
siehe vorangegangener Absatz. Generell gilt hier: Lieber zwei vielseitige Dinge machen, als ein unflexibles - der curse sollte lediglich der container seiin, der die wirkung aufrechterhält (das attribut an der region überwacht, und per trigger-funktion bei ende des curse oder antimagie entfernt). die eigentliche wirkung kann man in ein separates attribut stecken, dann ist sie auch in anderen kontexten als zauberei verwendbar (gebaüde oder items mit der gleichen wirkung, z.b.). Tests sollten so wenig wie möglich auf einen curse gehen (in fact, eigentlich nur bei der antimagie) sondern immer auf die wirkung (das attribut).
|
||||
|
||||
- wie benenne ich Sourcedateien?
|
||||
lang drüber nachgedacht, bin ich zum schluss gekommen: kleinbuchstaben, keien unterstriche. Es kann sich nie jemand merken, ob testplayer oder test_player jetzt richtig ist, und wir kommen sicher selten in die situation, das wir zwischen opium_bringen.c und opi_umbringen.c unterscheiden müssen.
|
||||
|
||||
- wie benenne ich variablen?
|
||||
da gilt das gleiceh wie bei den files, mit einer ausnahme: typspezifikation, also zum beispiel at_ für attributstypen, mit einem unterstrich. dann ist auch klar, was at_work ist: ein attribut, das was mit arbeit zu tun hat, keine boolean-variable die sagt ob man auf der arbeit ist.
|
||||
|
||||
- faction::units
|
||||
Die Variable funktioniert und kann benutzt werden. folgendes:
|
||||
for (r=regions;r;r=r->next) for (u=r->units;u;u=u->next) if (u->faction==f) {}
|
||||
schreibt sich viel einfacher so:
|
||||
for (u=f->units;u;u=u->nextF) {}
|
||||
und ja, es wird garantiert, das das funktioiniert, und regionsreihenfolge einhalten tut es auch. weshalb wahlloses erzeugen von einheiten per calloc und ohne createunit() aufruf schon seit längerem ein NoNo ist.
|
||||
|
||||
- buffer length
|
||||
Namen von attributen, hashcodes für items, usw. sollten kurz sein. schliesslich landen sie im Datenfile. Eine Funktion, die sie einlädt, sollte mit 32 byte speicherbedarf rechnen.
|
||||
|
|
Binary file not shown.
|
@ -42,6 +42,18 @@ Package=<4>
|
|||
|
||||
###############################################################################
|
||||
|
||||
Project: "doc"=.\doc\doc.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "eressea"=".\eressea\eressea-6.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
|
@ -171,6 +183,21 @@ Package=<4>
|
|||
|
||||
###############################################################################
|
||||
|
||||
Project: "translator"=.\tools\translator.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name util
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "triggers"=".\common\triggers\triggers-6.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
|
|
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: attributes.c,v 1.5 2001/02/04 08:38:14 enno Exp $
|
||||
* $Id: attributes.c,v 1.6 2001/02/10 11:38:29 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)
|
||||
|
@ -24,14 +24,15 @@
|
|||
#include <attributes/follow.h>
|
||||
#include <attributes/iceberg.h>
|
||||
#include <attributes/hate.h>
|
||||
#include <attributes/overrideroads.h>
|
||||
|
||||
/* util includes */
|
||||
#include <attrib.h>
|
||||
extern attrib_type at_roads_override;
|
||||
|
||||
void
|
||||
init_attributes(void)
|
||||
{
|
||||
at_register(&at_roads_override);
|
||||
at_register(&at_overrideroads);
|
||||
/* at_iceberg */
|
||||
init_iceberg();
|
||||
/* at_key */
|
||||
|
|
|
@ -1036,6 +1036,8 @@ SOURCE=..\common\attributes\orcification.c
|
|||
|
||||
!ELSEIF "$(CFG)" == "eressea - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\common\attributes\Debug"
|
||||
|
||||
!ELSEIF "$(CFG)" == "eressea - Win32 Conversion"
|
||||
|
||||
# PROP Intermediate_Dir "..\common\attributes\Conversion"
|
||||
|
@ -1050,6 +1052,52 @@ SOURCE=..\common\attributes\orcification.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\common\attributes\overrideroads.c
|
||||
|
||||
!IF "$(CFG)" == "eressea - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "..\common\attributes\Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "eressea - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\common\attributes\Debug"
|
||||
|
||||
!ELSEIF "$(CFG)" == "eressea - Win32 Conversion"
|
||||
|
||||
# PROP Intermediate_Dir "..\common\attributes\Conversion"
|
||||
|
||||
!ELSEIF "$(CFG)" == "eressea - Win32 Profile"
|
||||
|
||||
# PROP Intermediate_Dir "..\common\attributes\Profile"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\common\attributes\overrideroads.h
|
||||
|
||||
!IF "$(CFG)" == "eressea - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "..\common\attributes\Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "eressea - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\common\attributes\Debug"
|
||||
|
||||
!ELSEIF "$(CFG)" == "eressea - Win32 Conversion"
|
||||
|
||||
# PROP Intermediate_Dir "..\common\attributes\Conversion"
|
||||
|
||||
!ELSEIF "$(CFG)" == "eressea - Win32 Profile"
|
||||
|
||||
# PROP Intermediate_Dir "..\common\attributes\Profile"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\common\attributes\reduceproduction.c
|
||||
|
||||
!IF "$(CFG)" == "eressea - Win32 Release"
|
||||
|
|
Loading…
Reference in New Issue