From 3067eb51eadaf9947471005d88042ee2cbfb8e56 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 13 Jan 2007 21:29:57 +0000 Subject: [PATCH] region-keys and some renaming. --- src/eressea/lua/eressea.cpp | 8 ++++---- src/eressea/lua/region.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/eressea/lua/eressea.cpp b/src/eressea/lua/eressea.cpp index befeddda5..7f3c67865 100644 --- a/src/eressea/lua/eressea.cpp +++ b/src/eressea/lua/eressea.cpp @@ -70,7 +70,7 @@ find_plane_id(const char * name) } static bool -get_flag(const char * name) +get_key(const char * name) { int flag = atoi36(name); attrib * a = find_key(global.attribs, flag); @@ -78,7 +78,7 @@ get_flag(const char * name) } static void -set_flag(const char * name, bool value) +set_key(const char * name, bool value) { int flag = atoi36(name); attrib * a = find_key(global.attribs, flag); @@ -252,8 +252,8 @@ bind_eressea(lua_State * L) def("set_string", &lua_setstring), def("get_string", &lua_getstring), - def("set_flag", &set_flag), - def("get_flag", &get_flag), + def("set_key", &set_key), + def("get_key", &get_key), def("get_gamename", &get_gamename), /* planes not really implemented */ diff --git a/src/eressea/lua/region.cpp b/src/eressea/lua/region.cpp index 878421244..06028bef5 100644 --- a/src/eressea/lua/region.cpp +++ b/src/eressea/lua/region.cpp @@ -13,6 +13,8 @@ #include #include +#include + // lua includes #include #include @@ -306,6 +308,27 @@ region_additem(region& r, const char * iname, int number) return -1; } +static bool +region_getkey(region& r, const char * name) +{ + int flag = atoi36(name); + attrib * a = find_key(r.attribs, flag); + return (a!=NULL); +} + +static void +region_setkey(region& r, const char * name, bool value) +{ + int flag = atoi36(name); + attrib * a = find_key(r.attribs, flag); + if (a==NULL && value) { + add_key(&r.attribs, flag); + } else if (a!=NULL && !value) { + a_remove(&r.attribs, a); + } +} + + void bind_region(lua_State * L) { @@ -326,6 +349,9 @@ bind_region(lua_State * L) .def("add_notice", ®ion_addnotice) .def("add_direction", ®ion_adddirection) + .def("get_key", ®ion_getkey) + .def("set_key", ®ion_setkey) + .def("get_flag", ®ion_getflag) .def("set_flag", ®ion_setflag)