subscription information is now imported from the database

This commit is contained in:
Enno Rehling 2002-11-02 14:10:52 +00:00
parent f0c3972219
commit 0ca87233d3
27 changed files with 208 additions and 270 deletions

View File

@ -101,16 +101,29 @@ extern int * age;
boolean nobattle = false; boolean nobattle = false;
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
static const char *
dbrace(const struct race * rc)
{
static char zText[32];
unsigned char * zPtr = (unsigned char*)zText;
strcpy(zText, LOC(find_locale("en"), rc_name(rc, 0)));
while (*zPtr) {
*zPtr = (unsigned char)toupper(*(int*)zPtr);
++zPtr;
}
return zText;
}
static void static void
restart(unit *u, const race * rc) restart(unit *u, const race * rc)
{ {
faction *f = addplayer(u->region, u->faction->email, u->faction->passw, rc, u->faction->locale)->faction; faction *f = addplayer(u->region, u->faction->email, u->faction->passw, rc, u->faction->locale, u->faction->subscription)->faction;
unit * nu = f->units; unit * nu = f->units;
strlist ** o=&u->orders; strlist ** o=&u->orders;
f->subscription = u->faction->subscription;
fset(f, FFL_RESTART); fset(f, FFL_RESTART);
fprintf(sqlstream, "UPDATE subscriptions set faction='%s' where faction" if (f->subscription) fprintf(sqlstream, "UPDATE subscriptions set faction='%s', race='%s' where id=%u;\n",
"='%s' and game=%d;\n", itoa36(u->faction->no), itoa36(f->no), GAME_ID); itoa36(f->no), dbrace(rc), f->subscription);
f->magiegebiet = u->faction->magiegebiet; f->magiegebiet = u->faction->magiegebiet;
f->options = u->faction->options; f->options = u->faction->options;
freestrlist(nu->orders); freestrlist(nu->orders);
@ -1066,15 +1079,15 @@ quit(void)
char info[256]; char info[256];
sprintf(info, "%d Einheiten, %d Personen, %d Silber", sprintf(info, "%d Einheiten, %d Personen, %d Silber",
f->no_units, f->number, f->money); f->no_units, f->number, f->money);
fprintf(sqlstream, if (f->subscription) fprintf(sqlstream,
"UPDATE subscriptions SET lastturn=%d, password='%s', info='%s' " "UPDATE subscriptions SET lastturn=%d, password='%s', info='%s' "
"WHERE game=%d AND faction='%s';\n", "WHERE id=%u;\n",
f->lastorders, f->override, info, GAME_ID, itoa36(f->no)); f->lastorders, f->override, info, f->subscription);
} else { } else {
fprintf(sqlstream, if (f->subscription) fprintf(sqlstream,
"UPDATE subscriptions SET status='ACTIVE', lastturn=%d, password='%s' " "UPDATE subscriptions SET status='ACTIVE', lastturn=%d, password='%s' "
"WHERE game=%d AND faction='%s';\n", "WHERE id=%u;\n",
f->lastorders, f->override, GAME_ID, itoa36(f->no)); f->lastorders, f->override, f->subscription);
} }
if (turn - f->lastorders >= (NMRTIMEOUT - 1)) { if (turn - f->lastorders >= (NMRTIMEOUT - 1)) {
@ -2609,9 +2622,9 @@ renumber_factions(void)
for (rp=renum;rp;rp=rp->next) { for (rp=renum;rp;rp=rp->next) {
a_remove(&rp->faction->attribs, rp->attrib); a_remove(&rp->faction->attribs, rp->attrib);
if (updatelog) fprintf(updatelog, "renum %s %s\n", itoa36(rp->faction->no), itoa36(rp->want)); if (updatelog) fprintf(updatelog, "renum %s %s\n", itoa36(rp->faction->no), itoa36(rp->want));
fprintf(sqlstream, "UPDATE subscriptions set faction='%s' where " if (f->subscription) fprintf(sqlstream, "UPDATE subscriptions set faction='%s' where "
"faction='%s' and game=%d;\n", itoa36(rp->want), "subscription=%u;\n", itoa36(rp->want),
itoa36(rp->faction->no), GAME_ID); f->subscription);
rp->faction->no = rp->want; rp->faction->no = rp->want;
register_faction_id(rp->want); register_faction_id(rp->want);
fset(rp->faction, FF_NEWID); fset(rp->faction, FF_NEWID);
@ -2878,8 +2891,8 @@ ageing(void)
if (is_cursed(u->attribs, C_OLDRACE, 0)){ if (is_cursed(u->attribs, C_OLDRACE, 0)){
curse *c = get_curse(u->attribs, ct_find("oldrace")); curse *c = get_curse(u->attribs, ct_find("oldrace"));
if (c->duration == 1 && !(c->flag & CURSE_NOAGE)) { if (c->duration == 1 && !(c->flag & CURSE_NOAGE)) {
u->race = new_race[c->effect]; u->race = new_race[curse_geteffect(c)];
u->irace = new_race[c->effect]; u->irace = new_race[curse_geteffect(c)];
} }
} }
} }

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* vi: set ts=2:
* *
* *
* Eressea PB(E)M host Copyright (C) 1998-2000 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* vi: set ts=2:
* *
* *
* Eressea PB(E)M host Copyright (C) 1998-2000 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)

View File

@ -3499,7 +3499,7 @@ do_battle(void)
list_continue(sl); list_continue(sl);
} }
/* Fehler: "Die Einheit ist mit uns alliert" */ /* Fehler: "Die Einheit ist mit uns alliert" */
if (calm_ct && curse_active(get_cursex(u->attribs, calm_ct, (void*)u2->faction->unique_id, cmp_curseeffect))) { if (calm_ct && curse_active(get_cursex(u->attribs, calm_ct, (void*)u2->faction, cmp_curseeffect))) {
cmistake(u, sl->s, 47, MSG_BATTLE); cmistake(u, sl->s, 47, MSG_BATTLE);
list_continue(sl); list_continue(sl);
} }

View File

@ -223,8 +223,7 @@ typedef struct cid {
boolean boolean
cmp_curseeffect(const curse * c, const void * data) cmp_curseeffect(const curse * c, const void * data)
{ {
int effect = (int)data; return (c->effect.v==data);
return (c->effect==effect);
} }
boolean boolean
@ -353,8 +352,8 @@ curse_changevigour(attrib **ap, curse *c, int vigour)
int int
curse_geteffect(const curse *c) curse_geteffect(const curse *c)
{ {
if (c) return c->effect; assert(c);
return 0; return c->effect.i;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -472,7 +471,7 @@ set_curse(unit *mage, attrib **ap, const curse_type *ct, int vigour,
c->flag = 0; c->flag = 0;
c->vigour = vigour; c->vigour = vigour;
c->duration = duration; c->duration = duration;
c->effect = effect; c->effect.i = effect;
c->magician = mage; c->magician = mage;
c->no = newunitid(); c->no = newunitid();
@ -523,10 +522,10 @@ create_curse(unit *magician, attrib **ap, const curse_type *ct, int vigour,
c->duration += duration; c->duration += duration;
} }
if(ct->mergeflags & M_SUMEFFECT){ if(ct->mergeflags & M_SUMEFFECT){
c->effect += effect; c->effect.i += effect;
} }
if(ct->mergeflags & M_MAXEFFECT){ if(ct->mergeflags & M_MAXEFFECT){
c->effect = max(c->effect, effect); c->effect.i = max(c->effect.i, effect);
} }
if(ct->mergeflags & M_VIGOUR){ if(ct->mergeflags & M_VIGOUR){
c->vigour = max(vigour, c->vigour); c->vigour = max(vigour, c->vigour);
@ -561,7 +560,7 @@ do_transfer_curse(curse *c, unit * u, unit * u2, int n)
int duration = c->duration; int duration = c->duration;
int vigour = c->vigour; int vigour = c->vigour;
unit *magician = c->magician; unit *magician = c->magician;
int effect = c->effect; int effect = c->effect.i;
int cursedmen = 0; int cursedmen = 0;
int men = 0; int men = 0;
boolean dogive = false; boolean dogive = false;

View File

@ -13,9 +13,7 @@
#ifndef CURSE_H #ifndef CURSE_H
#define CURSE_H #define CURSE_H
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
/* Sprueche in der struct region und auf Einheiten, Schiffen oder Burgen /* Sprueche in der struct region und auf Einheiten, Schiffen oder Burgen
* (struct attribute) * (struct attribute)
*/ */
@ -80,6 +78,8 @@
* *
* */ * */
#include <util/variant.h>
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
/* Zauberwirkungen */ /* Zauberwirkungen */
/* nicht vergessen curse_type zu aktualisieren und Reihenfolge beachten! /* nicht vergessen curse_type zu aktualisieren und Reihenfolge beachten!
@ -192,7 +192,7 @@ typedef struct curse {
int duration; /* Dauer der Verzauberung. Wird jede Runde vermindert */ int duration; /* Dauer der Verzauberung. Wird jede Runde vermindert */
int vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */ int vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */
struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */ struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */
int effect; variant effect;
void *data; /* pointer auf spezielle curse-unterstructs*/ void *data; /* pointer auf spezielle curse-unterstructs*/
} curse; } curse;

View File

@ -370,7 +370,6 @@ shipcapacity (const ship * sh)
return i; return i;
} }
int max_unique_id;
int quiet = 0; int quiet = 0;
FILE *debug; FILE *debug;
@ -1291,18 +1290,6 @@ getfaction (void)
return findfaction (getid()); return findfaction (getid());
} }
faction *
findfaction_unique_id (int unique_id)
{
faction *f;
for (f = factions; f; f = f->next)
if (f->unique_id == unique_id) {
return f;
}
return NULL;
}
unit * unit *
findunitr (const region * r, int n) findunitr (const region * r, int n)
{ {
@ -2412,8 +2399,8 @@ remove_empty_factions(boolean writedropouts)
} }
} }
} }
fprintf(sqlstream, "UPDATE subscriptions set status='DEAD' where " if (f->subscription) fprintf(sqlstream, "UPDATE subscriptions set status='DEAD' where "
"faction='%s' and game=%d\n;", itoa36(f->no), GAME_ID); "subscription=%u\n;", f->subscription);
*fp = f->next; *fp = f->next;
/* stripfaction(f); /* stripfaction(f);

View File

@ -162,7 +162,8 @@ struct xml_stack;
#define OVERRIDE_VERSION 311 #define OVERRIDE_VERSION 311
#define CURSETYPE_VERSION 312 #define CURSETYPE_VERSION 312
#define ALLIANCES_VERSION 313 #define ALLIANCES_VERSION 313
#define DBLINK_VERSION 314
#define MIN_VERSION TYPES_VERSION #define MIN_VERSION TYPES_VERSION
#define UGROUPS_VERSION 400 /* nicht aktivieren, nicht fertig */ #define UGROUPS_VERSION 400 /* nicht aktivieren, nicht fertig */
#define RELEASE_VERSION ALLIANCES_VERSION #define RELEASE_VERSION ALLIANCES_VERSION
@ -860,8 +861,6 @@ typedef struct strlist {
char * s; char * s;
} strlist; } strlist;
extern int max_unique_id;
#define UFL_DEBUG (1<<0) #define UFL_DEBUG (1<<0)
#define UFL_ISNEW (1<<1) /* 2 */ #define UFL_ISNEW (1<<1) /* 2 */
#define FL_LONGACTION (1<<2) /* 4 */ #define FL_LONGACTION (1<<2) /* 4 */
@ -1026,7 +1025,6 @@ extern int alliedfaction(const struct plane * pl, const struct faction * f, cons
extern int alliedgroup(const struct plane * pl, const struct faction * f, const struct ally * sf, const struct faction * f2, int mode); extern int alliedgroup(const struct plane * pl, const struct faction * f, const struct ally * sf, const struct faction * f2, int mode);
struct faction *findfaction(int n); struct faction *findfaction(int n);
struct faction *findfaction_unique_id(int unique_id);
struct faction *getfaction(void); struct faction *getfaction(void);
struct region *findregion(int x, int y); struct region *findregion(int x, int y);

View File

@ -87,17 +87,19 @@ unused_faction_id(void)
} }
unit * unit *
addplayer(region *r, const char *email, const char * password, const struct race * frace, const struct locale *loc) addplayer(region *r, const char *email, const char * password,
const struct race * frace, const struct locale *loc,
int subscription)
{ {
int i; int i;
unit *u; unit *u;
faction *f; faction *f;
assert(frace != new_race[RC_ORC]); assert(frace != new_race[RC_ORC]);
f = calloc(sizeof(faction), 1); f = calloc(sizeof(faction), 1);
set_string(&f->email, email); set_string(&f->email, email);
if (password) { if (password) {
set_string(&f->passw, password); set_string(&f->passw, password);
} else { } else {
@ -106,26 +108,25 @@ addplayer(region *r, const char *email, const char * password, const struct race
} }
for (i = 0; i < 6; i++) buf[i] = (char) (97 + rand() % 26); buf[i] = 0; for (i = 0; i < 6; i++) buf[i] = (char) (97 + rand() % 26); buf[i] = 0;
set_string(&f->override, buf); set_string(&f->override, buf);
f->lastorders = turn; f->lastorders = turn;
f->alive = 1; f->alive = 1;
f->age = 0; f->age = 0;
f->race = frace; f->race = frace;
f->magiegebiet = 0; f->magiegebiet = 0;
f->locale = loc; f->locale = loc;
f->subscription = subscription;
set_ursprung(f, 0, r->x, r->y); set_ursprung(f, 0, r->x, r->y);
f->options = Pow(O_REPORT) | Pow(O_ZUGVORLAGE) | Pow(O_SILBERPOOL) | Pow(O_COMPUTER) | Pow(O_COMPRESS) | Pow(O_ADRESSEN) | Pow(O_STATISTICS); f->options = Pow(O_REPORT) | Pow(O_ZUGVORLAGE) | Pow(O_SILBERPOOL) | Pow(O_COMPUTER) | Pow(O_COMPRESS) | Pow(O_ADRESSEN) | Pow(O_STATISTICS);
f->no = unused_faction_id(); f->no = unused_faction_id();
register_faction_id(f->no); register_faction_id(f->no);
f->unique_id = ++max_unique_id;
sprintf(buf, "%s %s", LOC(loc, "factiondefault"), factionid(f)); sprintf(buf, "%s %s", LOC(loc, "factiondefault"), factionid(f));
set_string(&f->name, buf); set_string(&f->name, buf);
fset(f, FL_UNNAMED); fset(f, FL_UNNAMED);
addlist(&factions, f); addlist(&factions, f);
u = createunit(r, f, 1, f->race); u = createunit(r, f, 1, f->race);

View File

@ -24,7 +24,7 @@ typedef struct faction {
struct region *first; struct region *first;
struct region *last; struct region *last;
int no; int no;
int unique_id; int subscription;
unsigned int flags; unsigned int flags;
char *name; char *name;
char *banner; char *banner;
@ -83,7 +83,9 @@ typedef struct faction_list {
extern const struct unit * random_unit_in_faction(const struct faction *f); extern const struct unit * random_unit_in_faction(const struct faction *f);
extern const char * factionname(const struct faction * f); extern const char * factionname(const struct faction * f);
extern void * resolve_faction(void * data); extern void * resolve_faction(void * data);
extern struct unit * addplayer(struct region *r, const char *email, const char* password, const struct race * frace, const struct locale *loc); extern struct unit * addplayer(struct region *r, const char *email,
const char* password, const struct race * frace,
const struct locale *loc, int subscription);
extern boolean checkpasswd(const faction * f, const char * passwd); extern boolean checkpasswd(const faction * f, const char * passwd);
extern void destroyfaction(faction * f); extern void destroyfaction(faction * f);

View File

@ -1252,7 +1252,7 @@ magic_resistance(unit *target)
if (mage!=NULL) { if (mage!=NULL) {
if (c->type == ct_find("goodmagicresistancezone")) { if (c->type == ct_find("goodmagicresistancezone")) {
if (alliedunit(mage, target->faction, HELP_GUARD)) { if (alliedunit(mage, target->faction, HELP_GUARD)) {
chance += c->effect; chance += curse_geteffect(c);
break; break;
} }
} }

View File

@ -149,6 +149,77 @@ rc(FILE * F)
#define rc(F) (nextc = getc(F)) #define rc(F) (nextc = getc(F))
#endif #endif
#define CONVERT_DBLINK
#ifdef CONVERT_DBLINK
typedef struct uniquenode {
struct uniquenode * next;
int id;
faction * f;
} uniquenode;
#define HASHSIZE 2047
static uniquenode * uniquehash[HASHSIZE];
static faction *
uniquefaction(int id)
{
uniquenode * node = uniquehash[id%HASHSIZE];
while (node && node->id!=id) node=node->next;
return node?node->f:NULL;
}
static void
addunique(int id, faction * f)
{
uniquenode * fnode = calloc(1, sizeof(uniquenode));
fnode->f = f;
fnode->id = id;
fnode->next = uniquehash[id%HASHSIZE];
uniquehash[id%HASHSIZE] = fnode;
}
typedef struct mapnode {
struct mapnode * next;
int fno;
int subscription;
} mapnode;
static mapnode * subscriptions[HASHSIZE];
void
convertunique(faction * f)
{
int unique = f->subscription;
static FILE * F = NULL;
mapnode * mnode;
addunique(unique, f);
if (F==NULL) {
static char zText[MAX_PATH];
strcat(strcpy(zText, basepath()), "/subscriptions");
F = fopen(zText, "r");
if (F==NULL) {
log_error(("could not open %s.\n", zText));
abort();
}
for (;;) {
char zFaction[5];
int subscription, fno;
if (fscanf(F, "%s %d", zFaction, &subscription)<=0) break;
mnode = calloc(1, sizeof(mapnode));
fno = atoi36(zFaction);
mnode->next = subscriptions[fno%HASHSIZE];
mnode->fno = fno;
mnode->subscription = subscription;
subscriptions[fno%HASHSIZE] = mnode;
}
}
mnode = subscriptions[f->no%HASHSIZE];
while (mnode!=NULL && mnode->fno!=f->no) mnode = mnode->next;
f->subscription = mnode->subscription;
}
#endif
void void
rds(FILE * F, char **ds) rds(FILE * F, char **ds)
{ {
@ -785,7 +856,7 @@ readgame(boolean backup)
#endif #endif
turn = ri(F); turn = ri(F);
/* read_dynamictypes(); */ /* read_dynamictypes(); */
max_unique_id = ri(F); /* max_unique_id = */ ri(F);
nextborder = ri(F); nextborder = ri(F);
/* Planes */ /* Planes */
@ -1229,7 +1300,7 @@ writegame(char *path, char quiet)
wnl(F); wnl(F);
wi(F, turn); wi(F, turn);
wi(F, max_unique_id); wi(F, 0/*max_unique_id*/);
wi(F, nextborder); wi(F, nextborder);
/* Write planes */ /* Write planes */
@ -1359,12 +1430,12 @@ curse_write(const attrib * a, FILE * f) {
if (c->magician){ if (c->magician){
mage_no = c->magician->no; mage_no = c->magician->no;
}else{ } else {
mage_no = -1; mage_no = -1;
} }
fprintf(f, "%d %s %d %d %d %d %d ", c->no, ct->cname, flag, fprintf(f, "%d %s %d %d %d %d %d ", c->no, ct->cname, flag,
c->duration, c->vigour, mage_no, c->effect); c->duration, c->vigour, mage_no, c->effect.i);
if (c->type->write) c->type->write(f, c); if (c->type->write) c->type->write(f, c);
else if (c->type->typ == CURSETYP_UNIT) { else if (c->type->typ == CURSETYP_UNIT) {
@ -1382,7 +1453,7 @@ curse_read(attrib * a, FILE * f) {
if (global.data_version >= CURSETYPE_VERSION) { if (global.data_version >= CURSETYPE_VERSION) {
char cursename[64]; char cursename[64];
fscanf(f, "%d %s %d %d %d %d %d ", &c->no, cursename, &c->flag, fscanf(f, "%d %s %d %d %d %d %d ", &c->no, cursename, &c->flag,
&c->duration, &c->vigour, &mageid, &c->effect); &c->duration, &c->vigour, &mageid, &c->effect.i);
ct = ct_find(cursename); ct = ct_find(cursename);
} else { } else {
int cspellid; int cspellid;
@ -1392,12 +1463,19 @@ curse_read(attrib * a, FILE * f) {
c->no = newunitid(); c->no = newunitid();
} else { } else {
fscanf(f, "%d %d %d %d %d %d %d ", &c->no, &cspellid, &c->flag, fscanf(f, "%d %d %d %d %d %d %d ", &c->no, &cspellid, &c->flag,
&c->duration, &c->vigour, &mageid, &c->effect); &c->duration, &c->vigour, &mageid, &c->effect.i);
} }
ct = ct_find(oldcursename(cspellid)); ct = ct_find(oldcursename(cspellid));
} }
assert(ct!=NULL); assert(ct!=NULL);
if (global.data_version<DBLINK_VERSION) {
static const curse_type * cmonster = NULL;
if (!cmonster) cmonster=ct_find("calmmonster");
if (ct==cmonster) {
c->effect.v = uniquefaction(c->effect.i);
}
}
c->type = ct; c->type = ct;
/* beim Einlesen sind noch nicht alle units da, muss also /* beim Einlesen sind noch nicht alle units da, muss also
@ -1969,7 +2047,10 @@ readfaction(FILE * F)
f->allies = NULL; /* mem leak */ f->allies = NULL; /* mem leak */
while (f->attribs) a_remove(&f->attribs, f->attribs); while (f->attribs) a_remove(&f->attribs, f->attribs);
} }
f->unique_id = ri(F); f->subscription = ri(F);
#ifdef CONVERT_DBLINK
convertunique(f);
#endif
#ifdef ALLIANCES #ifdef ALLIANCES
if (global.data_version>=ALLIANCES_VERSION) { if (global.data_version>=ALLIANCES_VERSION) {
int allianceid = rid(F); int allianceid = rid(F);
@ -2006,13 +2087,6 @@ readfaction(FILE * F)
} }
f->lastorders = ri(F); f->lastorders = ri(F);
f->age = ri(F); f->age = ri(F);
/*
if (sqlstream && f->age==0) {
fprintf(sqlstream,
"UPDATE users SET status='ACTIVE' where email='%s';\n",
f->email);
}
*/
if (global.data_version < NEWRACE_VERSION) { if (global.data_version < NEWRACE_VERSION) {
race_t rc = (char) ri(F); race_t rc = (char) ri(F);
f->race = new_race[rc]; f->race = new_race[rc];
@ -2087,7 +2161,7 @@ writefaction(FILE * F, const faction * f)
ursprung *ur; ursprung *ur;
wi36(F, f->no); wi36(F, f->no);
wi(F, f->unique_id); wi(F, f->subscription);
#if defined(ALLIANCES) && RELEASE_VERSION>=ALLIANCES_VERSION #if defined(ALLIANCES) && RELEASE_VERSION>=ALLIANCES_VERSION
if (f->alliance) wi36(F, f->alliance->id); if (f->alliance) wi36(F, f->alliance->id);
else wi36(F, 0); else wi36(F, 0);

View File

@ -4769,7 +4769,7 @@ sp_calm_monster(castorder *co)
} }
c = create_curse(mage, &target->attribs, ct_find("calmmonster"), force, duration, c = create_curse(mage, &target->attribs, ct_find("calmmonster"), force, duration,
mage->faction->unique_id, 0); (int)mage->faction, 0);
if (c==NULL) { if (c==NULL) {
report_failure(mage, co->order); report_failure(mage, co->order);
return 0; return 0;

View File

@ -979,7 +979,7 @@ att_modification(const unit *u, skill_t sk)
a = a_select(u->region->attribs, gbdream_ct, cmp_cursetype); a = a_select(u->region->attribs, gbdream_ct, cmp_cursetype);
while (a) { while (a) {
curse * c = (curse*)a->data.v; curse * c = (curse*)a->data.v;
int mod = c->effect; int mod = curse_geteffect(c);
unit * mage = c->magician; unit * mage = c->magician;
/* wir suchen jeweils den größten Bonus und den größten Malus */ /* wir suchen jeweils den größten Bonus und den größten Malus */
if (mod>0 && (mage==NULL || alliedunit(mage, u->faction, HELP_GUARD))) if (mod>0 && (mage==NULL || alliedunit(mage, u->faction, HELP_GUARD)))

View File

@ -48,13 +48,6 @@ info_name(const tnode * tnext, const char * str, void * data, const char * cmd)
unused(data); unused(data);
unused(cmd); unused(cmd);
if (sqlstream!=NULL) { if (sqlstream!=NULL) {
#ifdef SQLOUTPUT
unit * u = (unit*)data;
const char * name = sqlquote(igetstrtoken(str));
faction * f = u->faction;
fprintf(sqlstream, "UPDATE users SET firstname = '%s' WHERE id = %u;\n",
name, f->unique_id);
#endif
} }
} }
@ -62,13 +55,6 @@ static void
info_address(const tnode * tnext, const char * str, void * data, const char * cmd) info_address(const tnode * tnext, const char * str, void * data, const char * cmd)
{ {
if (sqlstream!=NULL) { if (sqlstream!=NULL) {
#ifdef SQLOUTPUT
unit * u = (unit*)data;
faction * f = u->faction;
const char * address = sqlquote(igetstrtoken(str));
fprintf(sqlstream, "UPDATE users SET address = '%s' WHERE id = %u;\n",
address, f->unique_id);
#endif
} }
} }
@ -76,13 +62,6 @@ static void
info_phone(const tnode * tnext, const char * str, void * data, const char * cmd) info_phone(const tnode * tnext, const char * str, void * data, const char * cmd)
{ {
if (sqlstream!=NULL) { if (sqlstream!=NULL) {
#ifdef SQLOUTPUT
unit * u = (unit*)data;
faction * f = u->faction;
const char * phone = sqlquote(igetstrtoken(str));
fprintf(sqlstream, "UPDATE users SET phone = '%s' WHERE id = %u;\n",
phone, f->unique_id);
#endif
} }
} }
@ -124,7 +103,7 @@ infocommands(void)
strlist * order; strlist * order;
for (order = u->orders; order; order = order->next) for (order = u->orders; order; order = order->next)
if (igetkeyword(order->s, u->faction->locale) == K_INFO) { if (igetkeyword(order->s, u->faction->locale) == K_INFO) {
do_command(&g_keys, u, order->s); /* do_command(&g_keys, u, order->s); */
} }
if (u==*up) up = &u->next; if (u==*up) up = &u->next;
} }

View File

@ -108,9 +108,9 @@ cinfo_dreamcurse(const struct locale * lang, const void * obj, typ_t typ, curse
unused(obj); unused(obj);
assert(typ == TYP_REGION); assert(typ == TYP_REGION);
if (c->effect > 0){ if (curse_geteffect(c) > 0){
msg = msg_message("curseinfo::gooddream", "id", c->no); msg = msg_message("curseinfo::gooddream", "id", c->no);
}else{ } else {
msg = msg_message("curseinfo::baddream", "id", c->no); msg = msg_message("curseinfo::baddream", "id", c->no);
} }
nr_render(msg, lang, buf, sizeof(buf), NULL); nr_render(msg, lang, buf, sizeof(buf), NULL);

View File

@ -88,7 +88,7 @@ cinfo_auraboost(const struct locale * lang, const void * obj, typ_t typ, struct
u = (struct unit *)obj; u = (struct unit *)obj;
if (self != 0){ if (self != 0){
if (c->effect > 100){ if (curse_geteffect(c) > 100){
sprintf(buf, "%s fühlt sich von starken magischen Energien " sprintf(buf, "%s fühlt sich von starken magischen Energien "
"durchströmt. (%s)", u->name, curseid(c)); "durchströmt. (%s)", u->name, curseid(c));
}else{ }else{
@ -324,7 +324,7 @@ cinfo_sparkle(const struct locale * lang, const void * obj, typ_t typ, struct cu
while (effects[end]!=NULL) ++end; while (effects[end]!=NULL) ++end;
if (end==begin) return 0; if (end==begin) return 0;
else sprintf(buf, effects[begin + c->effect % (end-begin)], u->name); else sprintf(buf, effects[begin + curse_geteffect(c) % (end-begin)], u->name);
scat(" ("); scat(" (");
scat(itoa36(c->no)); scat(itoa36(c->no));
scat(")"); scat(")");

View File

@ -16,19 +16,11 @@
#define EVENT_H #define EVENT_H
#include <stdio.h> #include <stdio.h>
#include "variant.h"
struct attrib; struct attrib;
struct trigger; struct trigger;
typedef union {
void *v;
int i;
char c;
short s;
short sa[2];
char ca[4];
} variant;
typedef struct trigger_type { typedef struct trigger_type {
const char * name; const char * name;
void (*initialize)(struct trigger *); void (*initialize)(struct trigger *);

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* vi: set ts=2:
* *
* *
* Eressea PB(E)M host Copyright (C) 1998-2000 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
@ -77,7 +77,7 @@ make_locale(const char * name)
static FILE * s_debug = NULL; static FILE * s_debug = NULL;
void void
debug_language(const char * log) debug_language(const char * log)
{ {
s_debug = fopen(log, "w+"); s_debug = fopen(log, "w+");
@ -182,7 +182,7 @@ reverse_lookup(const locale * lang, const char * str)
return str; return str;
} }
const char * const char *
mkname(const char * space, const char * name) mkname(const char * space, const char * name)
{ {
static char zBuffer[128]; static char zBuffer[128];
@ -194,8 +194,8 @@ mkname(const char * space, const char * name)
return zBuffer; return zBuffer;
} }
locale * locale *
nextlocale(const struct locale * lang) nextlocale(const struct locale * lang)
{ {
return lang->next; return lang->next;
} }

14
src/common/util/variant.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef STRUCT_VARIANT_H
#define STRUCT_VARIANT_H
typedef union {
void *v;
int i;
char c;
short s;
short sa[2];
char ca[4];
} variant;
#define VAR(x) ()
#endif

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* vi: set ts=2:
* *
* *
* Eressea PB(E)M host Copyright (C) 1998-2000 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
@ -26,7 +26,7 @@
/**** **** /**** ****
** Debugging Libraries ** ** Debugging Libraries **
**** ****/ **** ****/
/* /*
* MALLOCDBG is an integer >= 0 that specifies the level of * MALLOCDBG is an integer >= 0 that specifies the level of
* debugging. 0 = no debugging, >= 1 increasing levels of * debugging. 0 = no debugging, >= 1 increasing levels of
* debugging strength. * debugging strength.
@ -99,7 +99,7 @@
# define __EXTENSIONS__ # define __EXTENSIONS__
#endif #endif
#ifdef WIN32 #ifdef _MSC_VER
# include <common/util/windir.h> # include <common/util/windir.h>
# define HAVE_READDIR # define HAVE_READDIR
#endif #endif

View File

@ -1500,135 +1500,6 @@ init_mwarden(void)
} }
#endif #endif
#ifdef CONVERT_TRIGGER
#include "old/relation.h"
#include "old/trigger.h"
#include "old/trigger_internal.h"
#include <event.h>
#include <triggers/killunit.h>
#include <triggers/timeout.h>
#include <triggers/changerace.h>
#include <triggers/changefaction.h>
#include <triggers/createunit.h>
#include <triggers/giveitem.h>
#include <triggers/createcurse.h>
#include <triggers/shock.h>
typedef struct {
void *obj2;
typ_t typ2;
relation_t id;
spread_t spread;
} reldata;
extern timeout *all_timeouts;
static void
convert_triggers(void)
{
region * r=regions;
timeout * t;
while (r) {
unit * u = r->units;
while (u) {
attrib * a = a_find(u->attribs, &at_relation);
while (a) {
reldata *rel = (reldata *)a->data.v;
unit * u2 = (unit*)rel->obj2;
switch (rel->id) {
case REL_FAMILIAR:
if (u && u2) {
if (!playerrace(u->race) || (playerrace(u2->race) && u->race==RC_GOBLIN))
set_familiar(u2, u);
else
set_familiar(u, u2);
} else {
if (u2) fprintf(stderr, "WARNING: FAMILIAR info for %s may be broken!\n", unitname(u2));
if (u) fprintf(stderr, "WARNING: FAMILIAR info for %s may be broken!\n", unitname(u));
}
break;
case REL_CREATOR:
break;
case REL_TARGET:
fprintf(stderr, "WARNING: TARGET relation between %s and 0x%p not converted\n", unitname(u), u2);
break;
default:
fprintf(stderr, "WARNING: unknown relation %d between %s and 0x%p not converted\n", rel->id, unitname(u), u2);
break;
}
a = a->nexttype;
}
u = u->next;
}
r=r->next;
}
for (t=all_timeouts;t;t=t->next) {
actionlist * al = t->acts;
int time = t->ticks;
for (;al;al=al->next) {
action * act = al->act;
if (act) switch( act->atype ) {
case AC_DESTROY: {
/* conversion keeper */
unit * u = (unit*)act->obj;
trigger * tkill = trigger_killunit(u);
add_trigger(&u->attribs, "timer", trigger_timeout(time, tkill));
}
case AC_CHANGERACE: {
/* conversion for toads */
unit *u = (unit*)act->obj;
race_t race = (race_t)act->i[0];
race_t irace = (race_t)act->i[1];
trigger * trestore = trigger_changerace(u, race, irace);
if (rand()%10>2) t_add(&trestore, trigger_giveitem(u, olditemtype[I_TOADSLIME], 1));
add_trigger(&u->attribs, "timer", trigger_timeout(time, trestore));
break;
}
case AC_CHANGEIRACE: {
/* conversion for shapeshift */
unit *u = (unit*)act->obj;
race_t irace = (race_t)act->i[0];
trigger * trestore = trigger_changerace(u, NORACE, irace);
add_trigger(&u->attribs, "timer", trigger_timeout(time, trestore));
break;
}
case AC_CHANGEFACTION: {
/* charmingsong */
faction *f = findfaction_unique_id(act->i[0]);
unit *u = (unit*)act->obj;
trigger *trestore = trigger_changefaction(u, f);
add_trigger(&u->attribs, "timer", trigger_timeout(time, trestore));
add_trigger(&u->faction->attribs, "destroy", trigger_killunit(u));
add_trigger(&f->attribs, "destroy", trigger_killunit(u));
break;
}
case AC_CREATEUNIT: {
/* conversion summon_dragon */
faction *f = findfaction_unique_id(act->i[0]);
region *r = (region *)act->obj;
int number = act->i[1];
race_t race = (race_t)act->i[2];
trigger *tsummon = trigger_createunit(r, f, race, number);
add_trigger(&r->attribs, "timer", trigger_timeout(time, tsummon));
break;
}
case AC_CREATEMAGICBOOSTCURSE:{
/* delayed magic boost curse */
unit *mage = (unit*)act->obj;
trigger *tsummon = trigger_createcurse(mage, mage, C_AURA, 0, act->i[0], 6, 50, 1);
add_trigger(&mage->attribs, "timer", trigger_timeout(5, tsummon));
break;
}
default:
fprintf(stderr, "WARNING: timeout not converted\n");
}
}
}
}
#endif
#if 0 #if 0
#include <items/lmsreward.h> #include <items/lmsreward.h>
static void static void
@ -2393,9 +2264,9 @@ static int
dump_sql(void) dump_sql(void)
{ {
faction * f; faction * f;
for (f=factions;f;f=f->next) { if (sqlstream) for (f=factions;f;f=f->next) {
if (f->unique_id==0) { if (f->subscription==0) {
f->unique_id = ++max_unique_id; /* fprintf(sqlstream,) */
} }
} }
return 0; return 0;

View File

@ -586,9 +586,11 @@ confirm_newbies(void)
if (sqlstream==NULL) return; if (sqlstream==NULL) return;
while (f) { while (f) {
if (!fval(f, FFL_DBENTRY)) { if (!fval(f, FFL_DBENTRY)) {
fprintf(sqlstream, "UPDATE subscriptions SET status='ACTIVE', faction='%s' WHERE game=%d AND password='%s';\n", itoa36(f->no), GAME_ID, f->passw); if (f->subscription) {
fset(f, FFL_DBENTRY); fprintf(sqlstream, "UPDATE subscriptions SET status='ACTIVE', faction='%s' WHERE subscription=%u;\n", itoa36(f->no), f->subscription);
} fset(f, FFL_DBENTRY);
}
}
f = f->next; f = f->next;
} }
} }

View File

@ -257,7 +257,8 @@ autoseed(struct regionlist * rlist)
newfaction ** nfp = &newfactions; newfaction ** nfp = &newfactions;
unit * u; unit * u;
while (*nfp!=nf) nfp=&(*nfp)->next; while (*nfp!=nf) nfp=&(*nfp)->next;
u = addplayer(seeds[i].region, nf->email, nf->password, nf->race, nf->lang); u = addplayer(seeds[i].region, nf->email, nf->password, nf->race,
nf->lang, nf->subscription);
#ifdef ALLIANCES #ifdef ALLIANCES
u->faction->alliance = nf->allies; u->faction->alliance = nf->allies;
#endif #endif
@ -357,7 +358,8 @@ mkisland(int nsize)
unit * u; unit * u;
terraform(r, preferred_terrain(nextf->race)); terraform(r, preferred_terrain(nextf->race));
++isize; ++isize;
u = addplayer(r, nextf->email, nextf->password, nextf->race, nextf->lang); u = addplayer(r, nextf->email, nextf->password, nextf->race, nextf->lang,
nextf->subscription);
#ifdef ALLIANCES #ifdef ALLIANCES
u->faction->alliance = nextf->allies; u->faction->alliance = nextf->allies;
#endif #endif

View File

@ -23,6 +23,7 @@ typedef struct newfaction {
const struct locale * lang; const struct locale * lang;
const struct race * race; const struct race * race;
int bonus; int bonus;
int subscription;
boolean oldregions; boolean oldregions;
#ifdef ALLIANCES #ifdef ALLIANCES
struct alliance * allies; struct alliance * allies;

View File

@ -287,7 +287,8 @@ seed_dropouts(void)
if (u==NULL) while (*nfp) { if (u==NULL) while (*nfp) {
newfaction * nf = *nfp; newfaction * nf = *nfp;
if (nf->race==drop->race && !nf->bonus) { if (nf->race==drop->race && !nf->bonus) {
unit * u = addplayer(r, nf->email, nf->password, nf->race, nf->lang); unit * u = addplayer(r, nf->email, nf->password, nf->race, nf->lang,
nf->subscription);
#ifdef ALLIANCES #ifdef ALLIANCES
u->faction->alliance = nf->allies; u->faction->alliance = nf->allies;
#endif #endif
@ -317,14 +318,14 @@ read_newfactions(const char * filename)
faction * f = factions; faction * f = factions;
char race[20], email[64], lang[8], password[16]; char race[20], email[64], lang[8], password[16];
newfaction *nf; newfaction *nf;
int bonus; int bonus, subscription;
#ifdef ALLIANCES #ifdef ALLIANCES
int alliance; int alliance;
/* email;race;locale;startbonus;alliance */ /* email;race;locale;startbonus;subscription;alliance */
if (fscanf(F, "%s %s %s %d %s %d", email, race, lang, &bonus, password, &alliance)<=0) break; if (fscanf(F, "%s %s %s %d %s %d %d", email, race, lang, &bonus, &subscription, password, &alliance)<=0) break;
#else #else
/* email;race;locale;startbonus */ /* email;race;locale;startbonus;subscription */
if (fscanf(F, "%s %s %s %d %s", email, race, lang, &bonus, password)<=0) break; if (fscanf(F, "%s %s %s %d %s", email, race, lang, &bonus, &subscription, password)<=0) break;
#endif #endif
while (f) { while (f) {
if (strcmp(f->email, email)==0 && f->age==0) { if (strcmp(f->email, email)==0 && f->age==0) {
@ -341,6 +342,7 @@ read_newfactions(const char * filename)
nf->email = strdup(email); nf->email = strdup(email);
nf->password = strdup(password); nf->password = strdup(password);
nf->race = rc_find(race); nf->race = rc_find(race);
nf->subscription = subscription;
#ifdef ALLIANCES #ifdef ALLIANCES
{ {
struct alliance * al = findalliance(alliance); struct alliance * al = findalliance(alliance);
@ -401,7 +403,7 @@ NeuePartei(region * r)
newfaction * nf, **nfp; newfaction * nf, **nfp;
const struct locale * lang; const struct locale * lang;
const struct race * frace; const struct race * frace;
int late; int late, subscription = 0;
unit *u; unit *u;
const char * passwd = NULL; const char * passwd = NULL;
int locale_nr; int locale_nr;
@ -416,6 +418,7 @@ NeuePartei(region * r)
if (nf!=NULL) { if (nf!=NULL) {
frace = nf->race; frace = nf->race;
subscription = nf->subscription;
late = nf->bonus; late = nf->bonus;
lang = nf->lang; lang = nf->lang;
passwd = nf->password; passwd = nf->password;
@ -514,7 +517,7 @@ NeuePartei(region * r)
else nfp = &nf->next; else nfp = &nf->next;
} }
modified = 1; modified = 1;
u = addplayer(r, email, passwd, frace, lang); u = addplayer(r, email, passwd, frace, lang, subscription);
++numnewbies; ++numnewbies;
if(late) give_latestart_bonus(r, u, late); if(late) give_latestart_bonus(r, u, late);

View File

@ -1522,7 +1522,7 @@ makemonsters(void)
f->options = Pow(O_REPORT); f->options = Pow(O_REPORT);
f->no=MONSTER_FACTION; f->no=MONSTER_FACTION;
register_faction_id(f->no); register_faction_id(f->no);
f->unique_id = ++max_unique_id; f->subscription = 0;
f->name=strdup("Monster"); f->name=strdup("Monster");
f->passw=strdup("abc123"); f->passw=strdup("abc123");
f->override = strdup(itoa36(rand())); f->override = strdup(itoa36(rand()));