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;
/* ------------------------------------------------------------- */
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
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;
strlist ** o=&u->orders;
f->subscription = u->faction->subscription;
fset(f, FFL_RESTART);
fprintf(sqlstream, "UPDATE subscriptions set faction='%s' where faction"
"='%s' and game=%d;\n", itoa36(u->faction->no), itoa36(f->no), GAME_ID);
if (f->subscription) fprintf(sqlstream, "UPDATE subscriptions set faction='%s', race='%s' where id=%u;\n",
itoa36(f->no), dbrace(rc), f->subscription);
f->magiegebiet = u->faction->magiegebiet;
f->options = u->faction->options;
freestrlist(nu->orders);
@ -1066,15 +1079,15 @@ quit(void)
char info[256];
sprintf(info, "%d Einheiten, %d Personen, %d Silber",
f->no_units, f->number, f->money);
fprintf(sqlstream,
if (f->subscription) fprintf(sqlstream,
"UPDATE subscriptions SET lastturn=%d, password='%s', info='%s' "
"WHERE game=%d AND faction='%s';\n",
f->lastorders, f->override, info, GAME_ID, itoa36(f->no));
"WHERE id=%u;\n",
f->lastorders, f->override, info, f->subscription);
} else {
fprintf(sqlstream,
if (f->subscription) fprintf(sqlstream,
"UPDATE subscriptions SET status='ACTIVE', lastturn=%d, password='%s' "
"WHERE game=%d AND faction='%s';\n",
f->lastorders, f->override, GAME_ID, itoa36(f->no));
"WHERE id=%u;\n",
f->lastorders, f->override, f->subscription);
}
if (turn - f->lastorders >= (NMRTIMEOUT - 1)) {
@ -2609,9 +2622,9 @@ renumber_factions(void)
for (rp=renum;rp;rp=rp->next) {
a_remove(&rp->faction->attribs, rp->attrib);
if (updatelog) fprintf(updatelog, "renum %s %s\n", itoa36(rp->faction->no), itoa36(rp->want));
fprintf(sqlstream, "UPDATE subscriptions set faction='%s' where "
"faction='%s' and game=%d;\n", itoa36(rp->want),
itoa36(rp->faction->no), GAME_ID);
if (f->subscription) fprintf(sqlstream, "UPDATE subscriptions set faction='%s' where "
"subscription=%u;\n", itoa36(rp->want),
f->subscription);
rp->faction->no = rp->want;
register_faction_id(rp->want);
fset(rp->faction, FF_NEWID);
@ -2878,8 +2891,8 @@ ageing(void)
if (is_cursed(u->attribs, C_OLDRACE, 0)){
curse *c = get_curse(u->attribs, ct_find("oldrace"));
if (c->duration == 1 && !(c->flag & CURSE_NOAGE)) {
u->race = new_race[c->effect];
u->irace = new_race[c->effect];
u->race = new_race[curse_geteffect(c)];
u->irace = new_race[curse_geteffect(c)];
}
}
}

View File

@ -3499,7 +3499,7 @@ do_battle(void)
list_continue(sl);
}
/* 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);
list_continue(sl);
}

View File

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

View File

@ -13,9 +13,7 @@
#ifndef CURSE_H
#define CURSE_H
/* ------------------------------------------------------------- */
/* Sprueche in der struct region und auf Einheiten, Schiffen oder Burgen
* (struct attribute)
*/
@ -80,6 +78,8 @@
*
* */
#include <util/variant.h>
/* ------------------------------------------------------------- */
/* Zauberwirkungen */
/* 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 vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */
struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */
int effect;
variant effect;
void *data; /* pointer auf spezielle curse-unterstructs*/
} curse;

View File

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

View File

@ -162,6 +162,7 @@ struct xml_stack;
#define OVERRIDE_VERSION 311
#define CURSETYPE_VERSION 312
#define ALLIANCES_VERSION 313
#define DBLINK_VERSION 314
#define MIN_VERSION TYPES_VERSION
#define UGROUPS_VERSION 400 /* nicht aktivieren, nicht fertig */
@ -860,8 +861,6 @@ typedef struct strlist {
char * s;
} strlist;
extern int max_unique_id;
#define UFL_DEBUG (1<<0)
#define UFL_ISNEW (1<<1) /* 2 */
#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);
struct faction *findfaction(int n);
struct faction *findfaction_unique_id(int unique_id);
struct faction *getfaction(void);
struct region *findregion(int x, int y);

View File

@ -87,16 +87,18 @@ unused_faction_id(void)
}
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;
unit *u;
faction *f;
assert(frace != new_race[RC_ORC]);
f = calloc(sizeof(faction), 1);
assert(frace != new_race[RC_ORC]);
f = calloc(sizeof(faction), 1);
set_string(&f->email, email);
set_string(&f->email, email);
if (password) {
set_string(&f->passw, password);
@ -113,6 +115,7 @@ addplayer(region *r, const char *email, const char * password, const struct race
f->race = frace;
f->magiegebiet = 0;
f->locale = loc;
f->subscription = subscription;
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);
@ -120,8 +123,6 @@ addplayer(region *r, const char *email, const char * password, const struct race
f->no = unused_faction_id();
register_faction_id(f->no);
f->unique_id = ++max_unique_id;
sprintf(buf, "%s %s", LOC(loc, "factiondefault"), factionid(f));
set_string(&f->name, buf);
fset(f, FL_UNNAMED);

View File

@ -24,7 +24,7 @@ typedef struct faction {
struct region *first;
struct region *last;
int no;
int unique_id;
int subscription;
unsigned int flags;
char *name;
char *banner;
@ -83,7 +83,9 @@ typedef struct faction_list {
extern const struct unit * random_unit_in_faction(const struct faction *f);
extern const char * factionname(const struct faction * f);
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 void destroyfaction(faction * f);

View File

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

View File

@ -149,6 +149,77 @@ rc(FILE * F)
#define rc(F) (nextc = getc(F))
#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
rds(FILE * F, char **ds)
{
@ -785,7 +856,7 @@ readgame(boolean backup)
#endif
turn = ri(F);
/* read_dynamictypes(); */
max_unique_id = ri(F);
/* max_unique_id = */ ri(F);
nextborder = ri(F);
/* Planes */
@ -1229,7 +1300,7 @@ writegame(char *path, char quiet)
wnl(F);
wi(F, turn);
wi(F, max_unique_id);
wi(F, 0/*max_unique_id*/);
wi(F, nextborder);
/* Write planes */
@ -1359,12 +1430,12 @@ curse_write(const attrib * a, FILE * f) {
if (c->magician){
mage_no = c->magician->no;
}else{
} else {
mage_no = -1;
}
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);
else if (c->type->typ == CURSETYP_UNIT) {
@ -1382,7 +1453,7 @@ curse_read(attrib * a, FILE * f) {
if (global.data_version >= CURSETYPE_VERSION) {
char cursename[64];
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);
} else {
int cspellid;
@ -1392,12 +1463,19 @@ curse_read(attrib * a, FILE * f) {
c->no = newunitid();
} else {
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));
}
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;
/* beim Einlesen sind noch nicht alle units da, muss also
@ -1969,7 +2047,10 @@ readfaction(FILE * F)
f->allies = NULL; /* mem leak */
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
if (global.data_version>=ALLIANCES_VERSION) {
int allianceid = rid(F);
@ -2006,13 +2087,6 @@ readfaction(FILE * F)
}
f->lastorders = 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) {
race_t rc = (char) ri(F);
f->race = new_race[rc];
@ -2087,7 +2161,7 @@ writefaction(FILE * F, const faction * f)
ursprung *ur;
wi36(F, f->no);
wi(F, f->unique_id);
wi(F, f->subscription);
#if defined(ALLIANCES) && RELEASE_VERSION>=ALLIANCES_VERSION
if (f->alliance) wi36(F, f->alliance->id);
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,
mage->faction->unique_id, 0);
(int)mage->faction, 0);
if (c==NULL) {
report_failure(mage, co->order);
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);
while (a) {
curse * c = (curse*)a->data.v;
int mod = c->effect;
int mod = curse_geteffect(c);
unit * mage = c->magician;
/* wir suchen jeweils den größten Bonus und den größten Malus */
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(cmd);
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)
{
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)
{
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;
for (order = u->orders; order; order = order->next)
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;
}

View File

@ -108,9 +108,9 @@ cinfo_dreamcurse(const struct locale * lang, const void * obj, typ_t typ, curse
unused(obj);
assert(typ == TYP_REGION);
if (c->effect > 0){
if (curse_geteffect(c) > 0){
msg = msg_message("curseinfo::gooddream", "id", c->no);
}else{
} else {
msg = msg_message("curseinfo::baddream", "id", c->no);
}
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;
if (self != 0){
if (c->effect > 100){
if (curse_geteffect(c) > 100){
sprintf(buf, "%s fühlt sich von starken magischen Energien "
"durchströmt. (%s)", u->name, curseid(c));
}else{
@ -324,7 +324,7 @@ cinfo_sparkle(const struct locale * lang, const void * obj, typ_t typ, struct cu
while (effects[end]!=NULL) ++end;
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(itoa36(c->no));
scat(")");

View File

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

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

@ -99,7 +99,7 @@
# define __EXTENSIONS__
#endif
#ifdef WIN32
#ifdef _MSC_VER
# include <common/util/windir.h>
# define HAVE_READDIR
#endif

View File

@ -1500,135 +1500,6 @@ init_mwarden(void)
}
#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
#include <items/lmsreward.h>
static void
@ -2393,9 +2264,9 @@ static int
dump_sql(void)
{
faction * f;
for (f=factions;f;f=f->next) {
if (f->unique_id==0) {
f->unique_id = ++max_unique_id;
if (sqlstream) for (f=factions;f;f=f->next) {
if (f->subscription==0) {
/* fprintf(sqlstream,) */
}
}
return 0;

View File

@ -586,9 +586,11 @@ confirm_newbies(void)
if (sqlstream==NULL) return;
while (f) {
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);
fset(f, FFL_DBENTRY);
}
if (f->subscription) {
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;
}
}

View File

@ -257,7 +257,8 @@ autoseed(struct regionlist * rlist)
newfaction ** nfp = &newfactions;
unit * u;
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
u->faction->alliance = nf->allies;
#endif
@ -357,7 +358,8 @@ mkisland(int nsize)
unit * u;
terraform(r, preferred_terrain(nextf->race));
++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
u->faction->alliance = nextf->allies;
#endif

View File

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

View File

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

View File

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