handelsgüterfix. faction rr bekommt gm-permissions. übersetzung alte->neue hashcodes. alte hashcodes aktiv.

This commit is contained in:
Enno Rehling 2001-02-10 19:24:05 +00:00
parent 0467736f70
commit 2bb8563278
16 changed files with 219 additions and 75 deletions

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: creation.c,v 1.4 2001/02/03 13:45:28 enno Exp $
* $Id: creation.c,v 1.5 2001/02/10 19:24:04 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)
@ -52,8 +52,6 @@
#include <stdlib.h>
#include <string.h>
static int g_maxluxuries;
/* eine insel pro 9x9 feld. das erste feld von (0,0) bis (8,8) */
/* Ozean und Grasland wird automatisch generiert (ein Ozean, darin eine Insel

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: economy.c,v 1.5 2001/02/10 14:17:59 enno Exp $
* $Id: economy.c,v 1.6 2001/02/10 19:24:04 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)
@ -1144,16 +1144,13 @@ maintain(building * b, boolean full)
return true;
}
void
static void
gebaeude_stuerzt_ein(region * r, building * b)
{
unit *u;
int n, i;
direction_t d;
int opfer = 0;
faction *f;
for (f = factions; f; f = f->next) freset(f, FL_DH);
sprintf(buf, "%s stürzte ein.", buildingname(b));
@ -1171,7 +1168,7 @@ gebaeude_stuerzt_ein(region * r, building * b)
if (u->building == b) {
int loss = 0;
fset(u->faction, FL_DH);
fset(u->faction, FL_MARK);
freset(u, FL_OWNER);
leave(r,u);
n = u->number;
@ -1197,10 +1194,14 @@ gebaeude_stuerzt_ein(region * r, building * b)
scat(" zu beklagen.");
} else buf[0] = 0;
addmessage(r, 0, buf, MSG_EVENT, ML_IMPORTANT);
for (f = factions; f; f = f->next)
if (fval(f, FL_DH))
for (u=r->units; u; u=u->next) {
faction * f = u->faction;
if (fval(f, FL_MARK)) {
freset(u->faction, FL_MARK);
add_message(&f->msgs,
new_message(f, "buildingcrash%r:region%b:building%s:opfer", r, b, buf));
}
}
destroy_building(b);
}

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: battle.c,v 1.9 2001/02/10 10:40:11 enno Exp $
* $Id: battle.c,v 1.10 2001/02/10 19:24:05 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)
@ -648,7 +648,7 @@ weapon_effskill(troop t, troop enemy, const weapon * w, boolean attacking, boole
if (riding(t) && (wtype==NULL || !fval(wtype, WTF_MISSILE))) {
skill += 2;
#ifdef BETA_CODE
skill = skillmod(urace(tu)->attribs, tu, tu->region, wtype->skill, skill, SMF_RIDING);
if (wtype) skill = skillmod(urace(tu)->attribs, tu, tu->region, wtype->skill, skill, SMF_RIDING);
#else
if (tu->race == RC_TROLL) skill--;
#endif

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: eressea.h,v 1.15 2001/02/10 14:18:00 enno Exp $
* $Id: eressea.h,v 1.16 2001/02/10 19:24:05 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)
@ -141,7 +141,7 @@ typedef struct settings {
} settings;
extern settings global;
#define RELEASE_VERSION NEWHASH_VERSION
#define RELEASE_VERSION NEWSOURCE_VERSION
#define ECHECK_VERSION "3.10"
/* changes from->to: 72->73: struct unit::lock entfernt.

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: message.c,v 1.4 2001/02/10 11:38:29 enno Exp $
* $Id: message.c,v 1.5 2001/02/10 19:24:05 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)
@ -193,7 +193,18 @@ mistake(const unit * u, const char *command, const char *comment, int mtype)
xmistake(u, command, gc_add(strdup(translate_regions(comment, u->faction))), mtype);
}
messagetype * messagetypes;
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: message.h,v 1.2 2001/01/26 16:19:40 enno Exp $
* $Id: message.h,v 1.3 2001/02/10 19:24:05 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)
@ -88,4 +88,6 @@ void read_msglevels(struct warning ** w, FILE * F);
void set_msglevel(struct warning ** warnings, const char * type, int level);
int get_msglevel(const struct warning * warnings, const msglevel * levels, const messagetype * mtype);
void debug_messagetypes(FILE * out);
#endif

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: region.c,v 1.7 2001/02/05 16:11:58 enno Exp $
* $Id: region.c,v 1.8 2001/02/10 19:24:05 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)
@ -346,12 +346,10 @@ reldirection(region * from, region * to)
void
free_regionlist(regionlist *rl)
{
regionlist *rl2;
while(rl != NULL) {
rl2 = rl;
rl = rl->next;
free(rl2);
while (rl) {
regionlist * rl2 = rl->next;
free(rl);
rl = rl2;
}
}

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: region.h,v 1.3 2001/02/03 13:45:32 enno Exp $
* $Id: region.h,v 1.4 2001/02/10 19:24:05 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)
@ -118,7 +118,7 @@ void runhash(struct region * r);
typedef struct regionlist {
struct regionlist *next;
struct region *region;
struct region *region;
} regionlist;
void free_regionlist(regionlist *rl);

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: render.c,v 1.4 2001/02/10 11:38:29 enno Exp $
* $Id: render.c,v 1.5 2001/02/10 19:24:05 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)
@ -255,7 +255,7 @@ render_immediate(const message * m, const char * find, localizer * l)
struct entry * e = m->type->entries;
++p;
if (*p=='$') {
int key;
unsigned int key;
eval * e;
++p;
while (*p!=' ') *f++ = *p++;

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: save.c,v 1.14 2001/02/10 15:27:09 corwin Exp $
* $Id: save.c,v 1.15 2001/02/10 19:24:05 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)
@ -961,7 +961,7 @@ readgame(boolean backup)
} else {
firstx=0;
firsty=0;
if (maxregions>0) n = min(n, maxregions)-1;
if (maxregions>0) maxregions = min(n, maxregions)-1;
}
}
if (maxregions==0) skip = true;

View File

@ -60,13 +60,19 @@ read_permissions(attrib * a, FILE * F)
return 1;
}
static struct attrib_type at_permissions = {
struct attrib_type at_permissions = {
"GM:permissions",
NULL, NULL, NULL,
write_permissions, read_permissions,
ATF_UNIQUE
};
attrib *
make_atpermissions(void)
{
return a_new(&at_permissions);
}
/**
** GM: CREATE <number> <itemtype>
**/
@ -95,7 +101,7 @@ static attrib_type at_gmcreate = {
write_gmcreate, read_gmcreate
};
static attrib *
attrib *
make_atgmcreate(const struct item_type * itype)
{
attrib * a = a_new(&at_gmcreate);
@ -175,21 +181,6 @@ init_gmcmd(void)
add_gmcommand(&g_cmds, "gm", &gm_command);
add_gmcommand(&g_cmds, "terraform", &gm_terraform);
add_gmcommand(&g_cmds, "create", &gm_create);
{
faction * f = findfaction(atoi36("rr"));
if (f) {
attrib * a = a_find(f->attribs, &at_permissions);
if (!a) {
item_type * itype;
a = a_add(&f->attribs, a_new(&at_permissions));
for (itype=itemtypes;itype;itype=itype->next) {
a_add((attrib**)&a->data.v, make_atgmcreate(itype));
}
a_add((attrib**)&a->data.v, make_key(atoi36("gmtf")));
}
}
}
}

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: goodies.c,v 1.4 2001/02/10 11:38:29 enno Exp $
* $Id: goodies.c,v 1.5 2001/02/10 19:24:05 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,7 +58,20 @@ intlist_find(int *i_p, int fi)
}
unsigned int
hashstring(const char* s)
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)
{
unsigned int key = 0;
int i = strlen(s);
@ -69,6 +82,15 @@ 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

View File

@ -54,6 +54,18 @@ Package=<4>
###############################################################################
Project: "echeck"=..\echeck\echeck.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "eressea"=".\eressea\eressea-6.dsp" - Package Owner=<4>
Package=<5>

Binary file not shown.

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: korrektur.c,v 1.19 2001/02/10 14:18:00 enno Exp $
* $Id: korrektur.c,v 1.20 2001/02/10 19:24:05 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)
@ -1204,36 +1204,134 @@ count_demand(const region *r)
{
struct demand *dmd;
int c = 0;
for (dmd=r->land->demands;dmd;dmd=dmd->next) c++;
if (r->land) {
for (dmd=r->land->demands;dmd;dmd=dmd->next) c++;
}
return c;
}
static void
fix_demand_region(const region *r)
static int
recurse_regions(region * r, regionlist **rlist, boolean(*fun)(const region * r))
{
direction_t d;
if (!fun(r)) return 0;
else {
int len = 0;
direction_t d;
regionlist * rl = calloc(sizeof(regionlist), 1);
rl->next = *rlist;
rl->region = r;
(*rlist) = rl;
fset(r, FL_MARK);
for (d=0;d!=MAXDIRECTIONS;++d) {
region * nr = rconnect(r, d);
if (nr && !fval(nr, FL_MARK)) len += recurse_regions(nr, rlist, fun);
}
return len+1;
}
}
for (d=0;d!=MAXDIRECTIONS;++d) {
region *nr = rconnect(r, d);
if (nr && nr->land && count_demand(nr) != 7) {
const luxury_type *sale=NULL;
const luxury_type *ltype;
struct demand *dmd, *dmd2;
static int maxluxuries = 0;
for(dmd = nr->land->demands; dmd; dmd=dmd->next)
if(dmd->value == 0) sale = dmd->type;
static boolean
f_nolux(const region * r)
{
if (r->land && count_demand(r) != maxluxuries) return true;
return false;
}
dmd2 = NULL;
for (ltype = luxurytypes;ltype;ltype=ltype->next) {
dmd = malloc(sizeof(struct demand));
dmd->type = ltype;
if(ltype == sale) {
dmd->value = 0;
} else {
dmd->value = 1+rand()%5;
static void
fix_demand_region(region *r)
{
regionlist *rl, *rlist = NULL;
static const luxury_type **mlux = 0, ** ltypes;
const luxury_type *sale = NULL;
int maxlux = 0;
recurse_regions(r, &rlist, f_nolux);
if (mlux==0) {
int i = 0;
if (maxluxuries==0) for (sale=luxurytypes;sale;sale=sale->next) {
maxluxuries++;
}
mlux = (const luxury_type **)gc_add(calloc(maxluxuries, sizeof(const luxury_type *)));
ltypes = (const luxury_type **)gc_add(calloc(maxluxuries, sizeof(const luxury_type *)));
for (sale=luxurytypes;sale;sale=sale->next) {
ltypes[i++] = sale;
}
}
else {
int i;
for (i=0;i!=maxluxuries;++i) mlux[i] = 0;
}
for (rl=rlist;rl;rl=rl->next) {
region * r = rl->region;
direction_t d;
for (d=0;d!=MAXDIRECTIONS;++d) {
region * nr = rconnect(r, d);
if (nr && nr->land && nr->land->demands) {
struct demand * dmd;
for (dmd = nr->land->demands;dmd;dmd=dmd->next) {
if (dmd->value == 0) {
int i;
for (i=0;i!=maxluxuries;++i) {
if (mlux[i]==NULL) {
maxlux = i;
mlux[i] = dmd->type;
break;
} else if (mlux[i]==dmd->type) {
break;
}
}
break;
}
}
}
}
freset(r, FL_MARK); /* undo recursive marker */
}
if (maxlux<2) {
int i;
for (i=maxlux;i!=2;++i) {
int j;
do {
int k = rand() % maxluxuries;
mlux[i] = ltypes[k];
for (j=0;j!=i;++j) {
if (mlux[j]==mlux[i]) break;
}
} while (j!=i);
}
maxlux=2;
}
for (rl=rlist;rl;rl=rl->next) {
region * r = rl->region;
setluxuries(r, mlux[rand() % maxlux]);
}
while (rlist) {
rl = rlist->next;
free(rlist);
rlist = rl;
}
}
extern attrib * make_atgmcreate(const struct item_type * itype);
extern attrib * make_atpermissions(void);
extern struct attrib_type at_permissions;
static void
make_gms(void)
{
faction * f = findfaction(atoi36("rr"));
if (f) {
attrib * a = a_find(f->attribs, &at_permissions);
if (!a) {
item_type * itype;
a = a_add(&f->attribs, make_atpermissions());
for (itype=itemtypes;itype;itype=itype->next) {
a_add((attrib**)&a->data.v, make_atgmcreate(itype));
}
a_add((attrib**)&a->data.v, make_key(atoi36("gmtf")));
}
}
}
@ -1241,9 +1339,14 @@ static void
fix_demand(void)
{
region *r;
const luxury_type *sale = NULL;
for (r=regions; r; r=r->next) if (r->land) {
if (count_demand(r) != 7) fix_demand_region(r);
if (maxluxuries==0) for (sale=luxurytypes;sale;sale=sale->next) ++maxluxuries;
for (r=regions; r; r=r->next) {
if ((r->land) && count_demand(r) != maxluxuries) {
fix_demand_region(r);
}
}
}
@ -1804,7 +1907,7 @@ korrektur(void)
#ifdef TEST_GM_COMMANDS
setup_gm_faction();
#endif
make_gms();
/* Wieder entfernen! */
do_once(atoi36("trgr"), fix_targetregion_resolve())

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: main.c,v 1.11 2001/02/05 16:27:07 enno Exp $
* $Id: main.c,v 1.12 2001/02/10 19:24:05 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)
@ -535,6 +535,12 @@ main(int argc, char *argv[])
kernel_init();
game_init();
{
FILE * F = fopen("c:\\messagetypes.txt", "wt");
debug_messagetypes(F);
fclose(F);
}
if ((i=readgame(false))!=0) return i;
if ((i=processturn(orders))!=0) return i;