region-keys and some renaming.

This commit is contained in:
Enno Rehling 2007-01-13 21:29:57 +00:00
parent 229706e6e4
commit 3067eb51ea
2 changed files with 30 additions and 4 deletions

View File

@ -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 */

View File

@ -13,6 +13,8 @@
#include <kernel/terrain.h>
#include <kernel/unit.h>
#include <attributes/key.h>
// lua includes
#include <lua.hpp>
#include <luabind/luabind.hpp>
@ -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", &region_addnotice)
.def("add_direction", &region_adddirection)
.def("get_key", &region_getkey)
.def("set_key", &region_setkey)
.def("get_flag", &region_getflag)
.def("set_flag", &region_setflag)