forked from github/server
that stupid warning triggers too often for anyone to pay attention to it
This commit is contained in:
parent
802228db41
commit
7c2b1e3445
|
@ -1,7 +1,7 @@
|
||||||
/* vi: set ts=2:
|
/* vi: set ts=2:
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||||
* 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)
|
||||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||||
|
@ -27,81 +27,81 @@
|
||||||
**/
|
**/
|
||||||
|
|
||||||
typedef struct timeout_data {
|
typedef struct timeout_data {
|
||||||
trigger * triggers;
|
trigger * triggers;
|
||||||
int timer;
|
int timer;
|
||||||
variant trigger_data;
|
variant trigger_data;
|
||||||
} timeout_data;
|
} timeout_data;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
timeout_init(trigger * t)
|
timeout_init(trigger * t)
|
||||||
{
|
{
|
||||||
t->data.v = calloc(sizeof(timeout_data), 1);
|
t->data.v = calloc(sizeof(timeout_data), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
timeout_free(trigger * t)
|
timeout_free(trigger * t)
|
||||||
{
|
{
|
||||||
timeout_data * td = (timeout_data*)t->data.v;
|
timeout_data * td = (timeout_data*)t->data.v;
|
||||||
free_triggers(td->triggers);
|
free_triggers(td->triggers);
|
||||||
free(t->data.v);
|
free(t->data.v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
timeout_handle(trigger * t, void * data)
|
timeout_handle(trigger * t, void * data)
|
||||||
{
|
{
|
||||||
/* call an event handler on timeout.
|
/* call an event handler on timeout.
|
||||||
* data.v -> ( variant event, int timer )
|
* data.v -> ( variant event, int timer )
|
||||||
*/
|
*/
|
||||||
timeout_data * td = (timeout_data*)t->data.v;
|
timeout_data * td = (timeout_data*)t->data.v;
|
||||||
if (--td->timer==0) {
|
if (--td->timer==0) {
|
||||||
handle_triggers(&td->triggers, NULL);
|
handle_triggers(&td->triggers, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
unused(data);
|
unused(data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
timeout_write(const trigger * t, FILE * F)
|
timeout_write(const trigger * t, FILE * F)
|
||||||
{
|
{
|
||||||
timeout_data * td = (timeout_data*)t->data.v;
|
timeout_data * td = (timeout_data*)t->data.v;
|
||||||
fprintf(F, "%d ", td->timer);
|
fprintf(F, "%d ", td->timer);
|
||||||
write_triggers(F, td->triggers);
|
write_triggers(F, td->triggers);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
timeout_read(trigger * t, FILE * F)
|
timeout_read(trigger * t, FILE * F)
|
||||||
{
|
{
|
||||||
timeout_data * td = (timeout_data*)t->data.v;
|
timeout_data * td = (timeout_data*)t->data.v;
|
||||||
fscanf(F, "%d", &td->timer);
|
fscanf(F, "%d", &td->timer);
|
||||||
read_triggers(F, &td->triggers);
|
read_triggers(F, &td->triggers);
|
||||||
if (td->timer>10) {
|
if (td->timer>20) {
|
||||||
trigger * tr = td->triggers;
|
trigger * tr = td->triggers;
|
||||||
log_warning(("there is a timeout lasting for another %d turns\n", td->timer));
|
log_warning(("there is a timeout lasting for another %d turns\n", td->timer));
|
||||||
while (tr) {
|
while (tr) {
|
||||||
log_warning((" timeout triggers: %s\n", tr->type->name));
|
log_warning((" timeout triggers: %s\n", tr->type->name));
|
||||||
tr = tr->next;
|
tr = tr->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (td->triggers!=NULL && td->timer>0) return AT_READ_OK;
|
if (td->triggers!=NULL && td->timer>0) return AT_READ_OK;
|
||||||
return AT_READ_FAIL;
|
return AT_READ_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
trigger_type tt_timeout = {
|
trigger_type tt_timeout = {
|
||||||
"timeout",
|
"timeout",
|
||||||
timeout_init,
|
timeout_init,
|
||||||
timeout_free,
|
timeout_free,
|
||||||
timeout_handle,
|
timeout_handle,
|
||||||
timeout_write,
|
timeout_write,
|
||||||
timeout_read
|
timeout_read
|
||||||
};
|
};
|
||||||
|
|
||||||
trigger *
|
trigger *
|
||||||
trigger_timeout(int time, trigger * callbacks)
|
trigger_timeout(int time, trigger * callbacks)
|
||||||
{
|
{
|
||||||
trigger * t = t_new(&tt_timeout);
|
trigger * t = t_new(&tt_timeout);
|
||||||
timeout_data * td = (timeout_data*)t->data.v;
|
timeout_data * td = (timeout_data*)t->data.v;
|
||||||
td->triggers = callbacks;
|
td->triggers = callbacks;
|
||||||
td->timer = time;
|
td->timer = time;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue