forked from github/server
- Neues Script für Jadee/Wente-Gates, nur Braut/Bräutigam durchlassen
- SQL-Stream verbessert, File wird nur erzeugt wenn auch geschrieben wird.
This commit is contained in:
parent
565b78bcd4
commit
f1328bff7c
|
@ -121,8 +121,10 @@ restart_race(unit *u, const race * rc)
|
|||
order ** ordp = &u->orders;
|
||||
f->subscription = u->faction->subscription;
|
||||
fset(f, FFL_RESTART);
|
||||
if (f->subscription) fprintf(sqlstream, "UPDATE subscriptions set faction='%s', race='%s' where id=%u;\n",
|
||||
itoa36(f->no), dbrace(rc), f->subscription);
|
||||
if (f->subscription) {
|
||||
sql_print(("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;
|
||||
free_orders(&nu->orders);
|
||||
|
@ -1208,15 +1210,15 @@ parse_quit(void)
|
|||
char info[256];
|
||||
sprintf(info, "%d Einheiten, %d Personen, %d Silber",
|
||||
f->no_units, f->number, f->money);
|
||||
if (f->subscription) fprintf(sqlstream,
|
||||
"UPDATE subscriptions SET lastturn=%d, password='%s', info='%s' "
|
||||
"WHERE id=%u;\n",
|
||||
f->lastorders, f->override, info, f->subscription);
|
||||
if (f->subscription) {
|
||||
sql_print(("UPDATE subscriptions SET lastturn=%d, password='%s', info='%s' WHERE id=%u;\n",
|
||||
f->lastorders, f->override, info, f->subscription));
|
||||
}
|
||||
} else {
|
||||
if (f->subscription) fprintf(sqlstream,
|
||||
"UPDATE subscriptions SET status='ACTIVE', lastturn=%d, password='%s' "
|
||||
"WHERE id=%u;\n",
|
||||
f->lastorders, f->override, f->subscription);
|
||||
if (f->subscription) {
|
||||
sql_print(("UPDATE subscriptions SET status='ACTIVE', lastturn=%d, password='%s' WHERE id=%u;\n",
|
||||
f->lastorders, f->override, f->subscription));
|
||||
}
|
||||
}
|
||||
|
||||
if (NMRTimeout()>0 && turn - f->lastorders >= (NMRTimeout() - 1)) {
|
||||
|
@ -2797,9 +2799,10 @@ renumber_factions(void)
|
|||
for (rp=renum;rp;rp=rp->next) {
|
||||
f = rp->faction;
|
||||
a_remove(&f->attribs, rp->attrib);
|
||||
if (f->subscription) fprintf(sqlstream, "UPDATE subscriptions set faction='%s' where "
|
||||
"id=%u;\n", itoa36(rp->want),
|
||||
f->subscription);
|
||||
if (f->subscription) {
|
||||
sql_print(("UPDATE subscriptions set faction='%s' where id=%u;\n",
|
||||
itoa36(rp->want), f->subscription));
|
||||
}
|
||||
f->no = rp->want;
|
||||
register_faction_id(rp->want);
|
||||
fset(f, FF_NEWID);
|
||||
|
|
|
@ -2354,7 +2354,7 @@ kernel_done(void)
|
|||
translation_done();
|
||||
skill_done();
|
||||
gc_done();
|
||||
if (sqlstream!=NULL) sql_done();
|
||||
sql_done();
|
||||
}
|
||||
|
||||
const char * localenames[] = {
|
||||
|
@ -2494,14 +2494,12 @@ remove_empty_factions(boolean writedropouts)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (f->subscription) fprintf(sqlstream, "UPDATE subscriptions set status='DEAD' where "
|
||||
"id=%u\n;", f->subscription);
|
||||
if (f->subscription) {
|
||||
sql_print(("UPDATE subscriptions set status='DEAD' where id=%u\n;",
|
||||
f->subscription));
|
||||
}
|
||||
|
||||
*fp = f->next;
|
||||
/* stripfaction(f);
|
||||
* free(f);
|
||||
* Wir können die nicht löschen, weil sie evtl. noch in attributen
|
||||
* referenziert sind ! */
|
||||
}
|
||||
else fp = &(*fp)->next;
|
||||
}
|
||||
|
|
|
@ -49,30 +49,24 @@ info_name(const tnode * tnext, const char * str, void * data, struct order * ord
|
|||
unused(str);
|
||||
unused(data);
|
||||
unused(ord);
|
||||
if (sqlstream!=NULL) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
info_address(const tnode * tnext, const char * str, void * data, struct order * ord)
|
||||
{
|
||||
if (sqlstream!=NULL) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
info_phone(const tnode * tnext, const char * str, void * data, struct order * ord)
|
||||
{
|
||||
if (sqlstream!=NULL) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
info_vacation(const tnode * tnext, const char * str, void * data, struct order * ord)
|
||||
{
|
||||
|
||||
if (sqlstream!=NULL) {
|
||||
#ifdef SQLOUTPUT
|
||||
if (sqlstream!=NULL) {
|
||||
unit * u = (unit*)data;
|
||||
faction * f = u->faction;
|
||||
const char * email = sqlquote(igetstrtoken(str));
|
||||
|
@ -86,8 +80,8 @@ info_vacation(const tnode * tnext, const char * str, void * data, struct order *
|
|||
start.tm_year, start.tm_mon, start.tm_mday, itoa36(f->no));
|
||||
fprintf(sqlstream, "UPDATE factions SET vacation_end = '%04d-%02d-%02d' WHERE id = '%s';\n",
|
||||
end.tm_year, end.tm_mon, end.tm_mday, itoa36(f->no));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static tnode g_keys;
|
||||
|
@ -112,7 +106,6 @@ infocommands(void)
|
|||
}
|
||||
if (*rp==r) rp = &r->next;
|
||||
}
|
||||
fflush(sqlstream);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -77,7 +77,7 @@ unitmessage_write(const trigger * t, FILE * F)
|
|||
unitmessage_data * td = (unitmessage_data*)t->data.v;
|
||||
fprintf(F, "%s ", itoa36(td->target->no));
|
||||
fwritestr(F, td->string);
|
||||
fprintf(F, "%d %d ", td->type, td->level);
|
||||
fprintf(F, " %d %d ", td->type, td->level);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -24,18 +24,32 @@
|
|||
|
||||
#include "log.h"
|
||||
|
||||
FILE * sqlstream;
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static FILE * sqlstream = NULL;
|
||||
static char * sqlfilename = NULL;
|
||||
|
||||
void
|
||||
sql_init(const char * filename)
|
||||
{
|
||||
static boolean init = false;
|
||||
if (!init) {
|
||||
sqlstream = fopen(filename, "wt+");
|
||||
if (sqlstream==NULL) {
|
||||
log_error(("could not open file: %s\n", filename));
|
||||
if (sqlfilename!=NULL) free(sqlfilename);
|
||||
sqlfilename = strdup(filename);
|
||||
}
|
||||
|
||||
void
|
||||
_sql_print(const char * format, ...)
|
||||
{
|
||||
if (!sqlstream && sqlfilename) {
|
||||
sqlstream=fopen(sqlfilename, "wt+");
|
||||
free(sqlfilename);
|
||||
sqlfilename=NULL;
|
||||
}
|
||||
init = true;
|
||||
if (sqlstream!=NULL) {
|
||||
va_list marker;
|
||||
va_start(marker, format);
|
||||
vfprintf(sqlstream, format, marker);
|
||||
va_end(marker);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +57,9 @@ void
|
|||
sql_done(void)
|
||||
{
|
||||
if (sqlstream) fclose(sqlstream);
|
||||
/* TODO */
|
||||
if (sqlfilename) free(sqlfilename);
|
||||
sqlstream=NULL;
|
||||
sqlfilename=NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
|
|
|
@ -25,10 +25,12 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern FILE * sqlstream;
|
||||
extern void sql_init(const char * filename);
|
||||
extern void sql_done(void);
|
||||
extern const char * sqlquote(const char * str);
|
||||
extern void sql_init(const char * filename);
|
||||
extern void sql_done(void);
|
||||
extern const char * sqlquote(const char * str);
|
||||
extern void _sql_print(const char * format, ...);
|
||||
|
||||
#define sql_print(x) _sql_print x
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ lc_write(const struct attrib * a, FILE* F)
|
|||
|
||||
write_building_reference(b, F);
|
||||
fwritestr(F, fname);
|
||||
fputc(' ', F);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <attributes/key.h>
|
||||
|
||||
// kernel includes
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/magic.h>
|
||||
|
@ -232,7 +233,7 @@ unit_getregion(const unit& u)
|
|||
static void
|
||||
unit_setbuilding(unit& u, building& b)
|
||||
{
|
||||
leave(u.region, u);
|
||||
leave(u.region, &u);
|
||||
u.building = &b;
|
||||
}
|
||||
|
||||
|
|
|
@ -549,11 +549,11 @@ void
|
|||
confirm_newbies(void)
|
||||
{
|
||||
faction * f = factions;
|
||||
if (sqlstream==NULL) return;
|
||||
while (f) {
|
||||
if (!fval(f, FFL_DBENTRY)) {
|
||||
if (f->subscription) {
|
||||
fprintf(sqlstream, "UPDATE subscriptions SET status='ACTIVE', faction='%s', race='%s' WHERE id=%u;\n", itoa36(f->no), dbrace(f->race), f->subscription);
|
||||
sql_print(("UPDATE subscriptions SET status='ACTIVE', faction='%s', race='%s' WHERE id=%u;\n",
|
||||
itoa36(f->no), dbrace(f->race), f->subscription));
|
||||
fset(f, FFL_DBENTRY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,20 +6,29 @@ hellgate = nil
|
|||
peacegate = nil
|
||||
|
||||
function gate_exchange(b1, b2)
|
||||
local units = {}
|
||||
local units1 = {}
|
||||
local units2 = {}
|
||||
local u
|
||||
for u in b1.units do
|
||||
units[u.no] = u
|
||||
if u:get_flag("wdgt") then
|
||||
units1[u.no] = u
|
||||
end
|
||||
end
|
||||
for u in b2.units do
|
||||
u.region = b1.region
|
||||
u.building = b1
|
||||
if u:get_flag("wdgt") then
|
||||
units2[u.no] = u
|
||||
end
|
||||
for id in units do
|
||||
u = units[id]
|
||||
end
|
||||
for id in units1 do
|
||||
u = units1[id]
|
||||
u.region = b2.region
|
||||
u.building = b2
|
||||
end
|
||||
for id in units2 do
|
||||
u = units2[id]
|
||||
u.region = b1.region
|
||||
u.building = b1
|
||||
end
|
||||
end
|
||||
|
||||
function hellgate_action(b)
|
||||
|
|
Loading…
Reference in New Issue