From 135d86d0ef1bcc3c6bbcf5fa8c56b91741b959e3 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 6 Feb 2022 07:15:15 +0200 Subject: [PATCH 46/46] fcdb lua: Generate access level objects See osdn #43710 Signed-off-by: Marko Lindqvist --- meson.build | 1 + server/scripting/Makefile.am | 2 ++ server/scripting/api_fcdb_specenum.c | 51 ++++++++++++++++++++++++++++ server/scripting/api_fcdb_specenum.h | 20 +++++++++++ server/scripting/script_fcdb.c | 3 ++ 5 files changed, 77 insertions(+) create mode 100644 server/scripting/api_fcdb_specenum.c create mode 100644 server/scripting/api_fcdb_specenum.h diff --git a/meson.build b/meson.build index 21feb5b093..a3d326382c 100644 --- a/meson.build +++ b/meson.build @@ -746,6 +746,7 @@ server_lib = static_library('fc_server', 'server/savegame/savemain.c', 'server/scripting/api_fcdb_auth.c', 'server/scripting/api_fcdb_base.c', + 'server/scripting/api_fcdb_specenum.c', 'server/scripting/api_server_base.c', 'server/scripting/api_server_edit.c', 'server/scripting/api_server_game_methods.c', diff --git a/server/scripting/Makefile.am b/server/scripting/Makefile.am index 8c34a87fc7..ba6aae7e65 100644 --- a/server/scripting/Makefile.am +++ b/server/scripting/Makefile.am @@ -41,6 +41,8 @@ dist_libscripting_fcdb_la_SOURCES = \ api_fcdb_auth.h \ api_fcdb_base.c \ api_fcdb_base.h \ + api_fcdb_specenum.c \ + api_fcdb_specenum.h \ script_fcdb.c \ script_fcdb.h \ tolua_fcdb_gen.c \ diff --git a/server/scripting/api_fcdb_specenum.c b/server/scripting/api_fcdb_specenum.c new file mode 100644 index 0000000000..bf40eeb97d --- /dev/null +++ b/server/scripting/api_fcdb_specenum.c @@ -0,0 +1,51 @@ +/***************************************************************************** + Freeciv - Copyright (C) 2010 - The Freeciv Project + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +*****************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +/* dependencies/lua */ +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" + +/* utility */ +#include "support.h" + +/* common/scriptcore */ +#include "api_specenum.h" + +/* common/networking */ +#include "connection.h" +#include "events.h" + +#include "api_fcdb_specenum.h" + + +/**********************************************************************//** + Define the __index function for each exported specenum type. +**************************************************************************/ +API_SPECENUM_DEFINE_INDEX(cmdlevel, "") + +/**********************************************************************//** + Load the specenum modules into Lua state L. +**************************************************************************/ +int api_fcdb_specenum_open(lua_State *L) +{ + API_SPECENUM_CREATE_TABLE(L, cmdlevel, "ALLOW"); + + return 0; +} diff --git a/server/scripting/api_fcdb_specenum.h b/server/scripting/api_fcdb_specenum.h new file mode 100644 index 0000000000..08530608cc --- /dev/null +++ b/server/scripting/api_fcdb_specenum.h @@ -0,0 +1,20 @@ +/***************************************************************************** + Freeciv - Copyright (C) 2010 - The Freeciv Project + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +*****************************************************************************/ +#ifndef FC__API_FCDB_SPECENUM_H +#define FC__API_FCDB_SPECENUM_H + +struct lua_State; + +int api_fcdb_specenum_open(lua_State *L); + +#endif /* FC__API_FCDB_SPECENUM_H */ diff --git a/server/scripting/script_fcdb.c b/server/scripting/script_fcdb.c index 8052c146b1..d65bf12414 100644 --- a/server/scripting/script_fcdb.c +++ b/server/scripting/script_fcdb.c @@ -58,6 +58,8 @@ #include "stdinhand.h" /* server/scripting */ +#include "api_fcdb_specenum.h" + #ifdef HAVE_FCDB #include /* <> so looked from the build directory first. */ #endif /* HAVE_FCDB */ @@ -244,6 +246,7 @@ bool script_fcdb_init(const char *fcdb_luafile) } tolua_common_a_open(fcl->state); + api_fcdb_specenum_open(fcl->state); tolua_game_open(fcl->state); #ifdef MESON_BUILD -- 2.34.1