Freeciv-3.1
Loading...
Searching...
No Matches
Functions | Variables
script_server.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <time.h>
#include "lua.h"
#include "lualib.h"
#include "tolua.h"
#include "astring.h"
#include "log.h"
#include "mem.h"
#include "registry.h"
#include "api_game_specenum.h"
#include "luascript.h"
#include "luascript_signal.h"
#include "luascript_func.h"
#include "tolua_common_a_gen.h"
#include "tolua_common_z_gen.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"

Go to the source code of this file.

Functions

static void script_server_vars_init (void)
 
static void script_server_vars_free (void)
 
static void script_server_vars_load (struct section_file *file)
 
static void script_server_vars_save (struct section_file *file)
 
static void script_server_code_init (void)
 
static void script_server_code_free (void)
 
static void script_server_code_load (struct section_file *file)
 
static void script_server_code_save (struct section_file *file)
 
static void script_server_signals_create (void)
 
static void script_server_functions_define (void)
 
static void script_server_cmd_reply (struct fc_lua *fcl, enum log_level level, const char *format,...) fc__attribute((__format__(__printf__
 
static void static bool script_server_do_string_shared (struct fc_lua *fcl, struct connection *caller, const char *str)
 
bool script_server_do_string (struct connection *caller, const char *str)
 
bool script_server_unsafe_do_string (struct connection *caller, const char *str)
 
bool script_server_load_file (const char *filename, char **buf)
 
static bool script_server_do_file_shared (struct fc_lua *fcl, struct connection *caller, const char *filename)
 
bool script_server_do_file (struct connection *caller, const char *filename)
 
bool script_server_unsafe_do_file (struct connection *caller, const char *filename)
 
void script_server_remove_exported_object (void *object)
 
bool script_server_init (void)
 
void script_server_free (void)
 
void script_server_state_load (struct section_file *file)
 
void script_server_state_save (struct section_file *file)
 
void script_server_signal_emit (const char *signal_name,...)
 
bool script_server_call (const char *func_name,...)
 

Variables

static struct fc_luafcl_main = NULL
 
static struct fc_luafcl_unsafe = NULL
 
static char * script_server_code = NULL
 

Function Documentation

◆ script_server_call()

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

Call a lua function.

Definition at line 595 of file script_server.c.

◆ script_server_cmd_reply()

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

Send the message via cmd_reply().

Definition at line 610 of file script_server.c.

Referenced by script_server_do_file_shared(), and script_server_do_string_shared().

◆ script_server_code_free()

static void script_server_code_free ( void  )
static

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

Definition at line 256 of file script_server.c.

Referenced by script_server_free().

◆ script_server_code_init()

static void script_server_code_init ( void  )
static

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

Definition at line 248 of file script_server.c.

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 267 of file script_server.c.

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 282 of file script_server.c.

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 188 of file script_server.c.

Referenced by lua_command(), and openload_script_file().

◆ 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 160 of file script_server.c.

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 112 of file script_server.c.

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 85 of file script_server.c.

Referenced by script_server_do_string(), and script_server_unsafe_do_string().

◆ script_server_free()

void script_server_free ( void  )

Free the scripting data.

Definition at line 366 of file script_server.c.

Referenced by load_rulesetdir(), and rulesets_deinit().

◆ script_server_functions_define()

static void script_server_functions_define ( void  )
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 586 of file script_server.c.

Referenced by script_server_init().

◆ script_server_init()

bool script_server_init ( void  )

Initialize the scripting state.

Definition at line 292 of file script_server.c.

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 129 of file script_server.c.

Referenced by openload_script_file().

◆ 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 207 of file script_server.c.

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

◆ script_server_signal_emit()

void script_server_signal_emit ( const char *  signal_name,
  ... 
)

◆ script_server_signals_create()

static void script_server_signals_create ( void  )
static

Declare any new signal types you need here.

Definition at line 420 of file script_server.c.

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 387 of file script_server.c.

Referenced by sg_load_script(), and 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 399 of file script_server.c.

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 196 of file script_server.c.

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 120 of file script_server.c.

Referenced by lua_command().

◆ script_server_vars_free()

static void script_server_vars_free ( void  )
static

Free the game script variables.

Definition at line 224 of file script_server.c.

Referenced by script_server_free().

◆ script_server_vars_init()

static void script_server_vars_init ( void  )
static

Initialize the game script variables.

Definition at line 216 of file script_server.c.

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 232 of file script_server.c.

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 240 of file script_server.c.

Referenced by script_server_state_save().

Variable Documentation

◆ fcl_main

struct fc_lua* fcl_main = NULL
static

◆ fcl_unsafe

struct fc_lua* fcl_unsafe = NULL
static

◆ script_server_code

char* script_server_code = NULL
static

Optional game script code (useful for scenarios).

Definition at line 63 of file script_server.c.

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