2003-12-14 11:02:29 +01:00
|
|
|
#include <config.h>
|
|
|
|
#include <cstring>
|
|
|
|
#include <eressea.h>
|
|
|
|
|
|
|
|
// kernel includes
|
2003-12-14 17:34:00 +01:00
|
|
|
#include <gamecode/laws.h>
|
|
|
|
#include <kernel/save.h>
|
2003-12-14 11:02:29 +01:00
|
|
|
#include <kernel/unit.h>
|
2003-12-14 17:34:00 +01:00
|
|
|
#include <kernel/reports.h>
|
2003-12-14 11:02:29 +01:00
|
|
|
#include <util/language.h>
|
|
|
|
|
|
|
|
// lua includes
|
|
|
|
#include <lua.hpp>
|
|
|
|
#include <luabind/luabind.hpp>
|
|
|
|
#include <luabind/iterator_policy.hpp>
|
|
|
|
|
|
|
|
using namespace luabind;
|
|
|
|
|
2003-12-14 17:34:00 +01:00
|
|
|
static int
|
|
|
|
get_turn(void)
|
2003-12-14 11:02:29 +01:00
|
|
|
{
|
2003-12-14 17:34:00 +01:00
|
|
|
return turn;
|
2003-12-14 11:02:29 +01:00
|
|
|
}
|
|
|
|
|
2003-12-14 17:34:00 +01:00
|
|
|
static int
|
|
|
|
read_game(void)
|
2003-12-14 11:02:29 +01:00
|
|
|
{
|
2003-12-14 17:34:00 +01:00
|
|
|
return readgame(false);
|
2003-12-14 11:02:29 +01:00
|
|
|
}
|
|
|
|
|
2003-12-14 17:34:00 +01:00
|
|
|
static int
|
|
|
|
write_game(void)
|
2003-12-14 11:02:29 +01:00
|
|
|
{
|
2003-12-14 17:34:00 +01:00
|
|
|
char ztext[64];
|
|
|
|
|
|
|
|
free_units();
|
|
|
|
remove_empty_factions(true);
|
|
|
|
|
|
|
|
sprintf(ztext, "%s/%d", datapath(), turn);
|
|
|
|
writegame(ztext, 0);
|
|
|
|
return 0;
|
2003-12-14 11:02:29 +01:00
|
|
|
}
|
|
|
|
|
2003-12-14 17:34:00 +01:00
|
|
|
extern int writepasswd(void);
|
|
|
|
|
|
|
|
static int
|
|
|
|
write_reports()
|
|
|
|
{
|
|
|
|
reports();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int process_orders(void);
|
|
|
|
|
2003-12-14 11:02:29 +01:00
|
|
|
void
|
2003-12-14 17:34:00 +01:00
|
|
|
bind_eressea(lua_State * L)
|
2003-12-14 11:02:29 +01:00
|
|
|
{
|
|
|
|
module(L)[
|
2003-12-14 17:34:00 +01:00
|
|
|
def("read_game", &read_game),
|
|
|
|
def("write_game", &write_game),
|
|
|
|
def("write_passwords", &writepasswd),
|
|
|
|
def("write_reports", &write_reports),
|
|
|
|
def("read_orders", &readorders),
|
|
|
|
def("process_orders", &process_orders),
|
|
|
|
def("get_turn", &get_turn)
|
2003-12-14 11:02:29 +01:00
|
|
|
];
|
|
|
|
}
|