forked from github/server
lua extensions:
- building.type - tostring for ships stricter const's
This commit is contained in:
parent
bcab633424
commit
29ea980738
|
@ -96,7 +96,7 @@ building_setregion(building& b, region& r)
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::ostream&
|
static std::ostream&
|
||||||
operator<<(std::ostream& stream, building& b)
|
operator<<(std::ostream& stream, const building& b)
|
||||||
{
|
{
|
||||||
stream << b.name;
|
stream << b.name;
|
||||||
stream << " (" << itoa36(b.no) << ")";
|
stream << " (" << itoa36(b.no) << ")";
|
||||||
|
@ -132,6 +132,10 @@ building_units(const building& b) {
|
||||||
return eressea::list<unit *, unit *, buildingunit>(u);
|
return eressea::list<unit *, unit *, buildingunit>(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
building_gettype(const building& b) {
|
||||||
|
return b.type->_name;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bind_building(lua_State * L)
|
bind_building(lua_State * L)
|
||||||
|
@ -148,6 +152,7 @@ bind_building(lua_State * L)
|
||||||
.property("info", &building_getinfo, &building_setinfo)
|
.property("info", &building_getinfo, &building_setinfo)
|
||||||
.property("units", &building_units, return_stl_iterator)
|
.property("units", &building_units, return_stl_iterator)
|
||||||
.property("region", &building_getregion, &building_setregion)
|
.property("region", &building_getregion, &building_setregion)
|
||||||
|
.def("type", &building_gettype)
|
||||||
.def_readonly("id", &building::no)
|
.def_readonly("id", &building::no)
|
||||||
.def_readwrite("size", &building::size)
|
.def_readwrite("size", &building::size)
|
||||||
.def("add_action", &building_addaction)
|
.def("add_action", &building_addaction)
|
||||||
|
|
|
@ -74,7 +74,7 @@ faction_locale(const faction& f)
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::ostream&
|
static std::ostream&
|
||||||
operator<<(std::ostream& stream, faction& f)
|
operator<<(std::ostream& stream, const faction& f)
|
||||||
{
|
{
|
||||||
stream << factionname(&f);
|
stream << factionname(&f);
|
||||||
return stream;
|
return stream;
|
||||||
|
|
|
@ -80,7 +80,7 @@ region_addnotice(region& r, const char * str)
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::ostream&
|
static std::ostream&
|
||||||
operator<<(std::ostream& stream, region& r)
|
operator<<(std::ostream& stream, const region& r)
|
||||||
{
|
{
|
||||||
stream << regionname(&r, NULL) << ", " << region_getterrain(r);
|
stream << regionname(&r, NULL) << ", " << region_getterrain(r);
|
||||||
return stream;
|
return stream;
|
||||||
|
|
|
@ -10,8 +10,27 @@
|
||||||
#include <luabind/luabind.hpp>
|
#include <luabind/luabind.hpp>
|
||||||
#include <luabind/iterator_policy.hpp>
|
#include <luabind/iterator_policy.hpp>
|
||||||
|
|
||||||
|
#include <util/base36.h>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
using namespace luabind;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bind_ship(lua_State * L)
|
bind_ship(lua_State * L)
|
||||||
{
|
{
|
||||||
|
@ -19,6 +38,8 @@ bind_ship(lua_State * L)
|
||||||
def("get_ship", &findship),
|
def("get_ship", &findship),
|
||||||
|
|
||||||
class_<struct ship>("ship")
|
class_<struct ship>("ship")
|
||||||
|
.def(self == ship())
|
||||||
|
.def(tostring(self))
|
||||||
.def_readonly("name", &ship::name)
|
.def_readonly("name", &ship::name)
|
||||||
.def_readonly("region", &ship::region)
|
.def_readonly("region", &ship::region)
|
||||||
.def_readonly("id", &ship::no)
|
.def_readonly("id", &ship::no)
|
||||||
|
|
|
@ -325,7 +325,7 @@ set_flag(unit& u, const char * name, bool value)
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::ostream&
|
static std::ostream&
|
||||||
operator<<(std::ostream& stream, unit& u)
|
operator<<(std::ostream& stream, const unit& u)
|
||||||
{
|
{
|
||||||
const char * rcname = get_racename(u.attribs);
|
const char * rcname = get_racename(u.attribs);
|
||||||
stream << u.name << " (" << itoa36(u.no) << "), " << u.number << " " << u.race->_name[0];
|
stream << u.name << " (" << itoa36(u.no) << "), " << u.number << " " << u.race->_name[0];
|
||||||
|
|
Loading…
Reference in New Issue