Freeciv21
Develop your civilization from humble roots to a global empire
script_server.cpp File Reference
#include <cstdarg>
#include <ctime>
#include <sys/stat.h>
#include "lua.h"
#include "tolua.h"
#include "log.h"
#include "registry.h"
#include "registry_ini.h"
#include "api_game_specenum.h"
#include "luascript.h"
#include "luascript_func.h"
#include "luascript_signal.h"
#include "tolua_game_gen.h"
#include "tolua_signal_gen.h"
#include "console.h"
#include "stdinhand.h"
#include "tolua_server_gen.h"
#include "script_server.h"
+ Include dependency graph for script_server.cpp:

Go to the source code of this file.

Functions

static void script_server_vars_init ()
 Initialize the game script variables. More...
 
static void script_server_vars_free ()
 Free the game script variables. More...
 
static void script_server_vars_load (struct section_file *file)
 Load the game script variables in file. More...
 
static void script_server_vars_save (struct section_file *file)
 Save the game script variables to file. More...
 
static void script_server_code_init ()
 Initialize the optional game script code (useful for scenarios). More...
 
static void script_server_code_free ()
 Free the optional game script code (useful for scenarios). More...
 
static void script_server_code_load (struct section_file *file)
 Load the optional game script code from file (useful for scenarios). More...
 
static void script_server_code_save (struct section_file *file)
 Save the optional game script code to file (useful for scenarios). More...
 
static void script_server_signals_create ()
 Declare any new signal types you need here. More...
 
static void script_server_functions_define ()
 Add server callback functions; these must be defined in the lua script '[rulesetdir]/script.lua': More...
 
static void script_server_cmd_reply (struct fc_lua *fcl, QtMsgType level, const char *format,...)
 Send the message via cmd_reply(). More...
 
static void static bool script_server_do_string_shared (struct fc_lua *fcl, struct connection *caller, const char *str)
 Parse and execute the script in str in the context of the specified instance. More...
 
bool script_server_do_string (struct connection *caller, const char *str)
 Parse and execute the script in str in the same instance as the ruleset. More...
 
bool script_server_unsafe_do_string (struct connection *caller, const char *str)
 Parse and execute the script in str in an unsafe instance. More...
 
bool script_server_load_file (const char *filename, char **buf)
 Load script to a buffer. More...
 
static bool script_server_do_file_shared (struct fc_lua *fcl, struct connection *caller, const char *filename)
 Parse and execute the script at filename in the context of the specified instance. More...
 
bool script_server_do_file (struct connection *caller, const char *filename)
 Parse and execute the script at filename in the same instance as the ruleset. More...
 
bool script_server_unsafe_do_file (struct connection *caller, const char *filename)
 Parse and execute the script at filename in an unsafe instance. More...
 
void script_server_remove_exported_object (void *object)
 Mark any, if exported, full userdata representing 'object' in the current script state as 'Nonexistent'. More...
 
bool script_server_init ()
 Initialize the scripting state. More...
 
void script_server_free ()
 Free the scripting data. More...
 
void script_server_state_load (struct section_file *file)
 Load the scripting state from file. More...
 
void script_server_state_save (struct section_file *file)
 Save the scripting state to file. More...
 
void script_server_signal_emit (const char *signal_name,...)
 Invoke all the callback functions attached to a given signal. More...
 
bool script_server_call (const char *func_name,...)
 Call a lua function. More...
 

Variables

static struct fc_luafcl_main = nullptr
 Lua virtual machine states. More...
 
static struct fc_luafcl_unsafe = nullptr
 
static char * script_server_code = nullptr
 Optional game script code (useful for scenarios). More...
 

Function Documentation

◆ script_server_call()

bool script_server_call ( const char *  func_name,
  ... 
)

Call a lua function.

Definition at line 525 of file script_server.cpp.

◆ script_server_cmd_reply()

static void script_server_cmd_reply ( struct fc_lua fcl,
QtMsgType  level,
const char *  format,
  ... 
)
static

Send the message via cmd_reply().

Definition at line 540 of file script_server.cpp.

Referenced by script_server_do_file_shared(), and script_server_do_string_shared().

◆ script_server_code_free()

static void script_server_code_free ( )
static

Free the optional game script code (useful for scenarios).

Definition at line 241 of file script_server.cpp.

Referenced by script_server_free().

◆ script_server_code_init()

static void script_server_code_init ( )
static

Initialize the optional game script code (useful for scenarios).

Definition at line 236 of file script_server.cpp.

Referenced by script_server_init().

◆ script_server_code_load()

static void script_server_code_load ( struct section_file file)
static

Load the optional game script code from file (useful for scenarios).

Definition at line 252 of file script_server.cpp.

Referenced by script_server_state_load().

◆ script_server_code_save()

static void script_server_code_save ( struct section_file file)
static

Save the optional game script code to file (useful for scenarios).

Definition at line 267 of file script_server.cpp.

Referenced by script_server_state_save().

◆ script_server_do_file()

bool script_server_do_file ( struct connection caller,
const char *  filename 
)

Parse and execute the script at filename in the same instance as the ruleset.

Definition at line 178 of file script_server.cpp.

Referenced by lua_command().

◆ script_server_do_file_shared()

static bool script_server_do_file_shared ( struct fc_lua fcl,
struct connection caller,
const char *  filename 
)
static

Parse and execute the script at filename in the context of the specified instance.

Definition at line 150 of file script_server.cpp.

Referenced by script_server_do_file(), and script_server_unsafe_do_file().

◆ script_server_do_string()

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

Parse and execute the script in str in the same instance as the ruleset.

Definition at line 101 of file script_server.cpp.

Referenced by lua_command().

◆ script_server_do_string_shared()

static void static bool script_server_do_string_shared ( struct fc_lua fcl,
struct connection caller,
const char *  str 
)
static

Parse and execute the script in str in the context of the specified instance.

Definition at line 74 of file script_server.cpp.

Referenced by script_server_do_string(), and script_server_unsafe_do_string().

◆ script_server_free()

void script_server_free ( )

Free the scripting data.

Definition at line 337 of file script_server.cpp.

Referenced by load_rulesetdir(), and rulesets_deinit().

◆ script_server_functions_define()

static void script_server_functions_define ( )
static

Add server callback functions; these must be defined in the lua script '[rulesetdir]/script.lua':

respawn_callback (optional):

  • callback lua function for the respawn command

Definition at line 516 of file script_server.cpp.

Referenced by script_server_init().

◆ script_server_init()

bool script_server_init ( )

Initialize the scripting state.

Definition at line 277 of file script_server.cpp.

Referenced by load_rulesetdir().

◆ script_server_load_file()

bool script_server_load_file ( const char *  filename,
char **  buf 
)

Load script to a buffer.

Definition at line 118 of file script_server.cpp.

◆ script_server_remove_exported_object()

void script_server_remove_exported_object ( void *  object)

Mark any, if exported, full userdata representing 'object' in the current script state as 'Nonexistent'.

This changes the type of the lua variable.

Definition at line 197 of file script_server.cpp.

Referenced by player_limit_to_max_rates(), remove_city(), and server_remove_unit_full().

◆ script_server_signal_emit()

◆ script_server_signals_create()

static void script_server_signals_create ( )
static

Declare any new signal types you need here.

Definition at line 391 of file script_server.cpp.

Referenced by script_server_init().

◆ script_server_state_load()

void script_server_state_load ( struct section_file file)

Load the scripting state from file.

Definition at line 358 of file script_server.cpp.

Referenced by sg_load_script().

◆ script_server_state_save()

void script_server_state_save ( struct section_file file)

Save the scripting state to file.

Definition at line 370 of file script_server.cpp.

Referenced by sg_save_script().

◆ script_server_unsafe_do_file()

bool script_server_unsafe_do_file ( struct connection caller,
const char *  filename 
)

Parse and execute the script at filename in an unsafe instance.

Definition at line 186 of file script_server.cpp.

Referenced by lua_command().

◆ script_server_unsafe_do_string()

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

Parse and execute the script in str in an unsafe instance.

Definition at line 109 of file script_server.cpp.

Referenced by lua_command().

◆ script_server_vars_free()

static void script_server_vars_free ( )
static

Free the game script variables.

Definition at line 213 of file script_server.cpp.

Referenced by script_server_free().

◆ script_server_vars_init()

static void script_server_vars_init ( )
static

Initialize the game script variables.

Definition at line 206 of file script_server.cpp.

Referenced by script_server_init().

◆ script_server_vars_load()

static void script_server_vars_load ( struct section_file file)
static

Load the game script variables in file.

Definition at line 220 of file script_server.cpp.

Referenced by script_server_state_load().

◆ script_server_vars_save()

static void script_server_vars_save ( struct section_file file)
static

Save the game script variables to file.

Definition at line 228 of file script_server.cpp.

Referenced by script_server_state_save().

Variable Documentation

◆ fcl_main

◆ fcl_unsafe

◆ script_server_code

char* script_server_code = nullptr
static

Optional game script code (useful for scenarios).

Definition at line 52 of file script_server.cpp.

Referenced by script_server_code_free(), script_server_code_init(), script_server_code_load(), and script_server_code_save().