2018-09-25 18:07:02 +02:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <platform.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gamedb.h"
|
|
|
|
|
2018-09-25 19:15:03 +02:00
|
|
|
#include "kernel/config.h"
|
|
|
|
#include "kernel/calendar.h"
|
2018-09-25 18:07:02 +02:00
|
|
|
#include "kernel/faction.h"
|
2018-09-25 19:15:03 +02:00
|
|
|
#include "kernel/db/driver.h"
|
2018-09-25 18:07:02 +02:00
|
|
|
|
2018-09-25 18:52:29 +02:00
|
|
|
int gamedb_update(void)
|
2018-09-25 18:07:02 +02:00
|
|
|
{
|
|
|
|
faction *f;
|
2018-09-25 18:52:29 +02:00
|
|
|
int err;
|
|
|
|
const char *dbname;
|
2018-09-25 18:07:02 +02:00
|
|
|
|
2018-09-25 18:52:29 +02:00
|
|
|
dbname = config_get("game.dbname");
|
|
|
|
|
|
|
|
err = db_driver_open(DB_GAME, dbname);
|
|
|
|
if (err == 0) {
|
|
|
|
for (f = factions; f; f = f->next) {
|
2018-10-24 09:27:48 +02:00
|
|
|
int uid = db_driver_faction_save(f->uid, f->no, turn,
|
|
|
|
faction_getemail(f),
|
|
|
|
faction_getpassword(f));
|
2018-09-25 18:52:29 +02:00
|
|
|
if (uid > 0) {
|
|
|
|
f->uid = uid;
|
|
|
|
}
|
2018-09-25 18:07:02 +02:00
|
|
|
}
|
2018-09-25 18:52:29 +02:00
|
|
|
db_driver_close(DB_GAME);
|
2018-09-25 18:07:02 +02:00
|
|
|
}
|
2018-09-25 18:52:29 +02:00
|
|
|
return err;
|
2018-09-25 18:07:02 +02:00
|
|
|
}
|