2001-04-26 19:41:06 +02:00
|
|
|
/* vi: set ts=2:
|
|
|
|
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
|
|
|
| | Enno Rehling <enno@eressea-pbem.de>
|
|
|
|
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
2003-07-29 11:48:03 +02:00
|
|
|
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
2001-04-26 19:41:06 +02:00
|
|
|
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
|
|
|
+-------------------+ Stefan Reich <reich@halbling.de>
|
|
|
|
|
|
|
|
This program may not be used, modified or distributed
|
|
|
|
without prior permission by the authors of Eressea.
|
|
|
|
|
|
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include <eressea.h>
|
|
|
|
|
2004-06-21 18:45:27 +02:00
|
|
|
#ifdef INFOCMD_MODULE
|
2001-04-26 19:41:06 +02:00
|
|
|
#include "infocmd.h"
|
|
|
|
|
|
|
|
#include "command.h"
|
|
|
|
|
|
|
|
/* kernel includes */
|
2004-06-21 18:45:27 +02:00
|
|
|
#include <kernel/order.h>
|
|
|
|
#include <kernel/faction.h>
|
|
|
|
#include <kernel/region.h>
|
|
|
|
#include <kernel/unit.h>
|
|
|
|
#include <kernel/save.h>
|
2001-12-10 01:13:39 +01:00
|
|
|
|
|
|
|
/* util includes */
|
|
|
|
#include <base36.h>
|
|
|
|
#include <sql.h>
|
2001-04-26 19:41:06 +02:00
|
|
|
|
|
|
|
/* libc includes */
|
|
|
|
#include <string.h>
|
2001-12-10 01:13:39 +01:00
|
|
|
#include <time.h>
|
2001-04-26 19:41:06 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
static void
|
2004-06-21 18:45:27 +02:00
|
|
|
info_email(const tnode * tnext, const char * str, void * data, struct order * ord)
|
2001-12-10 01:13:39 +01:00
|
|
|
{
|
|
|
|
unused(str);
|
|
|
|
unused(data);
|
2004-06-21 18:45:27 +02:00
|
|
|
unused(ord);
|
2001-12-10 01:13:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-06-21 18:45:27 +02:00
|
|
|
info_name(const tnode * tnext, const char * str, void * data, struct order * ord)
|
2001-04-26 19:41:06 +02:00
|
|
|
{
|
2002-09-02 22:36:12 +02:00
|
|
|
unused(tnext);
|
|
|
|
unused(str);
|
|
|
|
unused(data);
|
2004-06-21 18:45:27 +02:00
|
|
|
unused(ord);
|
2001-04-26 19:41:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-06-21 18:45:27 +02:00
|
|
|
info_address(const tnode * tnext, const char * str, void * data, struct order * ord)
|
2001-12-10 01:13:39 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-06-21 18:45:27 +02:00
|
|
|
info_phone(const tnode * tnext, const char * str, void * data, struct order * ord)
|
2001-04-26 19:41:06 +02:00
|
|
|
{
|
2001-12-10 01:13:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-06-21 18:45:27 +02:00
|
|
|
info_vacation(const tnode * tnext, const char * str, void * data, struct order * ord)
|
2001-12-10 01:13:39 +01:00
|
|
|
{
|
|
|
|
|
2002-08-25 10:03:50 +02:00
|
|
|
#ifdef SQLOUTPUT
|
2004-07-10 19:16:15 +02:00
|
|
|
if (sqlstream!=NULL) {
|
2002-09-02 22:36:12 +02:00
|
|
|
unit * u = (unit*)data;
|
|
|
|
faction * f = u->faction;
|
|
|
|
const char * email = sqlquote(igetstrtoken(str));
|
|
|
|
int duration = atoi(getstrtoken());
|
|
|
|
time_t start_time = time(NULL);
|
|
|
|
time_t end_time = start_time + 60*60*24*duration;
|
|
|
|
struct tm start = *localtime(&start_time);
|
|
|
|
struct tm end = *localtime(&end_time);
|
2001-12-10 01:13:39 +01:00
|
|
|
fprintf(sqlstream, "UPDATE factions SET vacation = '%s' WHERE id = '%s';\n", email, itoa36(f->no));
|
|
|
|
fprintf(sqlstream, "UPDATE factions SET vacation_start = '%04d-%02d-%02d' WHERE id = '%s';\n",
|
|
|
|
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));
|
2001-04-26 19:41:06 +02:00
|
|
|
}
|
2004-07-10 19:16:15 +02:00
|
|
|
#endif
|
2001-04-26 19:41:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static tnode g_keys;
|
2002-09-02 22:36:12 +02:00
|
|
|
static tnode g_info;
|
2001-04-26 19:41:06 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
infocommands(void)
|
|
|
|
{
|
|
|
|
region ** rp = ®ions;
|
|
|
|
while (*rp) {
|
|
|
|
region * r = *rp;
|
|
|
|
unit **up = &r->units;
|
2004-06-21 18:45:27 +02:00
|
|
|
while (*up) {
|
|
|
|
unit * u = *up;
|
|
|
|
order * ord;
|
|
|
|
for (ord = u->orders; ord; ord = ord->next) {
|
|
|
|
if (get_keyword(ord) == K_INFO) {
|
|
|
|
do_command(&g_keys, u, ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (u==*up) up = &u->next;
|
|
|
|
}
|
|
|
|
if (*rp==r) rp = &r->next;
|
|
|
|
}
|
2001-04-26 19:41:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-12-10 01:13:39 +01:00
|
|
|
init_info(void)
|
2001-04-26 19:41:06 +02:00
|
|
|
{
|
2002-09-02 22:36:12 +02:00
|
|
|
add_command(&g_keys, &g_info, "info", NULL);
|
2001-12-10 01:13:39 +01:00
|
|
|
|
2002-09-02 22:36:12 +02:00
|
|
|
add_command(&g_info, NULL, "email", &info_email);
|
|
|
|
add_command(&g_info, NULL, "name", &info_name);
|
|
|
|
add_command(&g_info, NULL, "adresse", &info_address);
|
|
|
|
add_command(&g_info, NULL, "telefon", &info_phone);
|
|
|
|
add_command(&g_info, NULL, "urlaub", &info_vacation);
|
2001-04-26 19:41:06 +02:00
|
|
|
}
|
2004-06-21 18:45:27 +02:00
|
|
|
#endif /* INFOCMD_MODULE */
|
|
|
|
|