neue hashfunktion uint ausgabe im cr

This commit is contained in:
Enno Rehling 2001-02-11 20:56:20 +00:00
parent 2bda7f556c
commit 0b6f03d7f4
10 changed files with 24 additions and 74 deletions

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: creport.c,v 1.6 2001/02/10 10:40:10 enno Exp $
* $Id: creport.c,v 1.7 2001/02/11 20:54:00 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)
@ -142,8 +142,8 @@ render_message(FILE * f, faction * receiver, message * m)
if (m->receiver && receiver!=m->receiver) return;
if (m->receiver && get_msglevel(receiver->warnings, receiver->msglevels, m->type) < msg_level(m))
return;
fprintf(f, "MESSAGE %d\n", receiver->index++);
fprintf(f, "%d;type\n", mt->hashkey);
fprintf(f, "MESSAGE %u\n", receiver->index++);
fprintf(f, "%u;type\n", mt->hashkey);
if (receiver->options & want(O_DEBUG)) {
fprintf(f, "%d;level\n", mt->level);
}
@ -225,7 +225,7 @@ cr_output_messages(FILE * F, message * msgs, faction * f)
if (get_msglevel(f->warnings, f->msglevels, mt) < m->level) continue;
#endif
if (mt!=last && (!m->receiver || f==m->receiver)) {
int index = mt->hashkey % CTMAXHASH;
unsigned int index = mt->hashkey % CTMAXHASH;
struct crtype * ct = crtypes[index];
last = mt;
while (ct && ct->mt->hashkey!=mt->hashkey) ct=ct->nexthash;

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: laws.c,v 1.18 2001/02/11 15:16:04 enno Exp $
* $Id: laws.c,v 1.19 2001/02/11 20:54:01 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)
@ -2111,7 +2111,7 @@ reorder_owners(region * r)
unit ** up=&r->units, ** useek;
building * b=NULL;
ship * sh=NULL;
int len = listlen(r->units);
size_t len = listlen(r->units);
for (b = r->buildings;b;b=b->next) {
unit ** ubegin = up;

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: item.c,v 1.8 2001/02/10 14:18:00 enno Exp $
* $Id: item.c,v 1.9 2001/02/11 20:54:01 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)
@ -30,6 +30,7 @@
/* util includes */
#include <functions.h>
#include <goodies.h>
/* libc includes */
#include <assert.h>
@ -49,9 +50,6 @@ attrib_type at_ltype = { "luxury_type" };
attrib_type at_itype = { "item_type" };
attrib_type at_htype = { "herb_type" };
extern int hashstring(const char* s);
static int
res_changeaura(unit * u, const resource_type * rtype, int delta)
{

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: message.c,v 1.5 2001/02/10 19:24:05 enno Exp $
* $Id: message.c,v 1.6 2001/02/11 20:54:01 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)
@ -30,6 +30,8 @@
#include "item.h"
#include "building.h"
#include <goodies.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdlib.h>
@ -49,8 +51,6 @@ typedef struct msg_setting {
int level;
} msg_setting;
extern int hashstring(const char* s);
/************ Compatibility function *************/
#define MAXSTRLEN (4*DISPLAYSIZE+3)
#include "region.h"
@ -195,17 +195,6 @@ mistake(const unit * u, const char *command, const char *comment, int mtype)
static messagetype * messagetypes;
extern unsigned int new_hashstring(const char* s);
void
debug_messagetypes(FILE * out)
{
messagetype * mt;
for (mt=messagetypes;mt;mt=mt->next) {
fprintf(out, "%u->%u;%s\n", mt->hashkey, new_hashstring(mt->name));
}
}
messagetype *
new_messagetype(const char * name, int level, const char * section)
{

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: render.c,v 1.5 2001/02/10 19:24:05 enno Exp $
* $Id: render.c,v 1.6 2001/02/11 20:56:20 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)
@ -357,7 +357,7 @@ render_immediate(const message * m, const char * find, localizer * l)
void
rendercr(FILE * f, messagetype * mt, const locale * lang)
{
fprintf(f, "\"%s\";%d\n", locale_string(lang, mt->name), mt->hashkey);
fprintf(f, "\"%s\";%u\n", locale_string(lang, mt->name), mt->hashkey);
}
static char *

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: arena.c,v 1.3 2001/02/02 08:40:46 enno Exp $
* $Id: arena.c,v 1.4 2001/02/11 20:54:01 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,13 +44,13 @@
#include <resolve.h>
#include <functions.h>
#include <event.h>
#include <goodies.h>
/* libc include */
#include <assert.h>
#include <stdlib.h>
#include <string.h>
extern int hashstring(const char* s);
/* exports: */
plane * arena = NULL;
@ -59,7 +59,7 @@ plane * arena = NULL;
/* local vars */
#define CENTRAL_VOLCANO 1
static int arena_id = 0;
static unsigned int arena_id = 0;
static region * arena_center = NULL;
static region * tower_region[6];
static region * start_region[6];

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: museum.c,v 1.2 2001/01/31 07:59:42 enno Exp $
* $Id: museum.c,v 1.3 2001/02/11 20:54:01 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)
@ -223,7 +223,7 @@ init_museum(void)
void
create_museum(void)
{
int museum_id = hashstring("museum");
unsigned int museum_id = hashstring("museum");
plane *museum = getplanebyid(museum_id);
region *r;
building *b;

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: goodies.c,v 1.5 2001/02/10 19:24:05 enno Exp $
* $Id: goodies.c,v 1.6 2001/02/11 20:54:01 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)
@ -58,20 +58,7 @@ intlist_find(int *i_p, int fi)
}
unsigned int
old_hashstring(const char* s)
{
int key = 0;
int i = strlen(s);
while (i) {
--i;
key = ((key >> 31) & 1) ^ (key << 1) ^ s[i];
}
return key & 0x7fff;
}
unsigned int
new_hashstring(const char* s)
hashstring(const char* s)
{
unsigned int key = 0;
int i = strlen(s);
@ -82,31 +69,6 @@ new_hashstring(const char* s)
return key;
}
unsigned int
hashstring(const char* s)
{
#if RELEASE_VERSION < NEWHASH_VERSION
return old_hashstring(s);
#else
return new_hashstring(s);
#endif
}
/* Standardfunktion aus Sedgewick: Algorithmen in C++ */
#define HASH_MAX 100001
int
hashstring_new(const char* s)
{
int key = 0;
int i = strlen(s);
while (i) {
--i;
key = (256 * key + s[i])%HASH_MAX;
}
return key /* & 0x7fffffff */;
}
char *
escape_string(char * str, char replace)
{

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: language.c,v 1.3 2001/02/10 11:38:29 enno Exp $
* $Id: language.c,v 1.4 2001/02/11 20:54:01 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)
@ -14,6 +14,8 @@
#include <config.h>
#include "language.h"
#include "goodies.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -22,7 +24,6 @@
#define SMAXHASH 512
/** importing **/
extern int hashstring(const char* s);
struct locale {
struct locale * next;

Binary file not shown.