#include #include #include "objects.h" // kernel includes #include #include #include #include // lua includes #ifdef _MSC_VER #pragma warning (push) #pragma warning (disable: 4127) #endif #include #include #include #if LUABIND_BETA >= 7 # include #endif #ifdef _MSC_VER #pragma warning (pop) #endif #include #include using namespace luabind; static std::ostream& operator<<(std::ostream& stream, const ship& sh) { stream << sh.name; stream << " (" << itoa36(sh.no) << ")"; stream << ", " << sh.type->name; stream << " size " << sh.size; return stream; } static bool operator==(const ship& a, const ship& sh) { return a.no==sh.no; } static ship * add_ship(const char * sname, region& r) { const ship_type * stype = st_find(sname); ship * sh = new_ship(stype, NULL, &r); sh->size = stype->construction->maxsize; return sh; } static int ship_maxsize(const ship& s) { return s.type->construction->maxsize; } const char * ship_gettype(const ship& s) { return s.type->name[0]; } int ship_getweight(const ship& s) { int w, c; getshipweight(&s, &w, &c); return w; } int ship_getcapacity(const ship& s) { return shipcapacity(&s); } static void ship_setregion(ship& sh, region& r) { move_ship(&sh, sh.region, &r, NULL); } static region * ship_getregion(const ship& sh) { return sh.region; } void bind_ship(lua_State * L) { module(L)[ def("get_ship", &findship), def("add_ship", &add_ship), class_("ship") .def(self == ship()) .def(tostring(self)) .property("type", &ship_gettype) .property("weight", &ship_getweight) .property("capacity", &ship_getcapacity) .property("maxsize", &ship_maxsize) .def_readonly("name", &ship::name) .property("region", &ship_getregion, &ship_setregion) .def_readonly("id", &ship::no) .def_readonly("info", &ship::display) .def_readwrite("damage", &ship::damage) .def_readwrite("size", &ship::size) .def_readwrite("coast", &ship::coast) .property("objects", &eressea::get_objects) ]; }