Freeciv21
Develop your civilization from humble roots to a global empire
script_fcdb.cpp File Reference
#include <QStandardPaths>
#include "sol/sol.hpp"
#include "lua.h"
#include "log.h"
#include "luascript.h"
#include "luascript_types.h"
#include "tolua_common_a_gen.h"
#include "tolua_game_gen.h"
#include "auth.h"
#include "console.h"
#include "stdinhand.h"
#include "script_fcdb.h"
+ Include dependency graph for script_fcdb.cpp:

Go to the source code of this file.

Macros

#define SCRIPT_FCDB_LUA_FILE   "freeciv21/database.lua"
 

Functions

static bool script_fcdb_functions_check (const char *fcdb_luafile)
 fcdb callback functions that must be defined in the lua script 'database.lua': More...
 
static bool script_fcdb_database_init ()
 test and initialise the database. More...
 
static bool script_fcdb_database_free ()
 free the database. More...
 
static void script_fcdb_cmd_reply (struct fc_lua *lfcl, QtMsgType level, const char *format,...)
 Send the message via cmd_reply(). More...
 
static void script_fcdb_register_functions ()
 Registers FCDB-related functions in the Lua state. More...
 
bool script_fcdb_init (const QString &fcdb_luafile)
 Initialize the scripting state. More...
 
void script_fcdb_free ()
 Free the scripting data. More...
 
bool script_fcdb_do_string (struct connection *caller, const char *str)
 Parse and execute the script in str in the lua instance for the freeciv database. More...
 
bool script_fcdb_user_delegate_to (connection *pconn, player *pplayer, const char *delegate, bool &success)
 returns Bool, whether pconn is allowed to delegate player to delegate. More...
 
bool script_fcdb_user_exists (connection *pconn, bool &exists)
 Check if the user exists. More...
 
bool script_fcdb_user_save (connection *pconn, const char *password)
 Save a new user. More...
 
bool script_fcdb_user_take (connection *requester, connection *taker, player *player, bool will_observe, bool &success)
 returns Bool, whether requester is allowed to attach taker to pplayer. More...
 
bool script_fcdb_user_verify (connection *pconn, const char *username, bool &success)
 Check the credentials of the user. More...
 

Variables

static void static sol::state * fcl = nullptr
 Lua virtual machine state. More...
 
static fc_lua fcl_compat = fc_lua()
 Tolua compatibility. More...
 

Macro Definition Documentation

◆ SCRIPT_FCDB_LUA_FILE

#define SCRIPT_FCDB_LUA_FILE   "freeciv21/database.lua"

Definition at line 36 of file script_fcdb.cpp.

Function Documentation

◆ script_fcdb_cmd_reply()

static void script_fcdb_cmd_reply ( struct fc_lua lfcl,
QtMsgType  level,
const char *  format,
  ... 
)
static

Send the message via cmd_reply().

Definition at line 115 of file script_fcdb.cpp.

Referenced by script_fcdb_do_string().

◆ script_fcdb_database_free()

static bool script_fcdb_database_free ( )
static

free the database.

Definition at line 294 of file script_fcdb.cpp.

Referenced by script_fcdb_free().

◆ script_fcdb_database_init()

static bool script_fcdb_database_init ( )
static

test and initialise the database.

Definition at line 279 of file script_fcdb.cpp.

Referenced by script_fcdb_init().

◆ script_fcdb_do_string()

bool script_fcdb_do_string ( struct connection caller,
const char *  str 
)

Parse and execute the script in str in the lua instance for the freeciv database.

Definition at line 258 of file script_fcdb.cpp.

Referenced by fcdb_command().

◆ script_fcdb_free()

void script_fcdb_free ( )

Free the scripting data.

Definition at line 241 of file script_fcdb.cpp.

Referenced by fcdb_command(), fcdb_free(), and script_fcdb_init().

◆ script_fcdb_functions_check()

static bool script_fcdb_functions_check ( const char *  fcdb_luafile)
static

fcdb callback functions that must be defined in the lua script 'database.lua':

database_init:

  • test and initialise the database. database_free:
  • free the database.

user_exists(Connection pconn):

  • Check if the user exists. user_save(Connection pconn, String password):
  • Save a new user. user_verify(Connection pconn):
  • Check the credentials of the user. user_delegate_to(Connection pconn, Player pplayer, String delegate):
  • returns Bool, whether pconn is allowed to delegate player to delegate. user_take(Connection requester, Connection taker, Player pplayer, Bool observer):
  • returns Bool, whether requester is allowed to attach taker to pplayer. Check the existence of all needed functions.

Definition at line 78 of file script_fcdb.cpp.

Referenced by script_fcdb_init().

◆ script_fcdb_init()

bool script_fcdb_init ( const QString &  fcdb_luafile)

Initialize the scripting state.

Returns the status of the freeciv database lua state.

Definition at line 178 of file script_fcdb.cpp.

Referenced by fcdb_command(), and fcdb_init().

◆ script_fcdb_register_functions()

static void script_fcdb_register_functions ( )
static

Registers FCDB-related functions in the Lua state.

Definition at line 149 of file script_fcdb.cpp.

Referenced by script_fcdb_init().

◆ script_fcdb_user_delegate_to()

bool script_fcdb_user_delegate_to ( connection pconn,
player pplayer,
const char *  delegate,
bool &  success 
)

returns Bool, whether pconn is allowed to delegate player to delegate.

Definition at line 309 of file script_fcdb.cpp.

Referenced by delegate_command().

◆ script_fcdb_user_exists()

bool script_fcdb_user_exists ( connection pconn,
bool &  exists 
)

Check if the user exists.

Definition at line 327 of file script_fcdb.cpp.

Referenced by auth_user().

◆ script_fcdb_user_save()

bool script_fcdb_user_save ( connection pconn,
const char *  password 
)

Save a new user.

Definition at line 343 of file script_fcdb.cpp.

Referenced by auth_handle_reply().

◆ script_fcdb_user_take()

bool script_fcdb_user_take ( connection requester,
connection taker,
player player,
bool  will_observe,
bool &  success 
)

returns Bool, whether requester is allowed to attach taker to pplayer.

Definition at line 358 of file script_fcdb.cpp.

Referenced by is_allowed_to_take().

◆ script_fcdb_user_verify()

bool script_fcdb_user_verify ( connection pconn,
const char *  username,
bool &  success 
)

Check the credentials of the user.

Definition at line 375 of file script_fcdb.cpp.

Referenced by auth_handle_reply().

Variable Documentation

◆ fcl

void static sol::state* fcl = nullptr
static

◆ fcl_compat

fc_lua fcl_compat = fc_lua()
static

Tolua compatibility.

Definition at line 51 of file script_fcdb.cpp.

Referenced by script_fcdb_do_string(), and script_fcdb_init().