Freeciv21
Develop your civilization from humble roots to a global empire
script_server.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  part of Freeciv21. Freeciv21 is free software: you can redistribute it
4  and/or modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation, either version 3 of the
6  License, or (at your option) any later version. You should have received
7  a copy of the GNU General Public License along with Freeciv21. If not,
8  see https://www.gnu.org/licenses/.
9 **************************************************************************/
10 
11 #pragma once
12 
13 // utility
14 #include "support.h"
15 
16 /* common/scriptcore */
17 #include "luascript_types.h"
18 
19 struct section_file;
20 struct connection;
21 
22 void script_server_remove_exported_object(void *object);
23 
24 // Script functions.
25 bool script_server_init();
26 void script_server_free();
27 
28 bool script_server_do_string(struct connection *caller, const char *str);
29 bool script_server_do_file(struct connection *caller, const char *filename);
30 bool script_server_load_file(const char *filename, char **buf);
31 
32 bool script_server_unsafe_do_string(struct connection *caller,
33  const char *str);
34 bool script_server_unsafe_do_file(struct connection *caller,
35  const char *filename);
36 
37 /* Script state i/o. */
38 void script_server_state_load(struct section_file *file);
39 void script_server_state_save(struct section_file *file);
40 
41 // Signals.
42 void script_server_signal_emit(const char *signal_name, ...);
43 
44 // Functions
45 bool script_server_call(const char *func_name, ...);
bool script_server_unsafe_do_string(struct connection *caller, const char *str)
Parse and execute the script in str in an unsafe instance.
void script_server_signal_emit(const char *signal_name,...)
Invoke all the callback functions attached to a given signal.
bool script_server_init()
Initialize the scripting state.
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.
bool script_server_call(const char *func_name,...)
Call a lua function.
void script_server_state_save(struct section_file *file)
Save the scripting state to file.
void script_server_free()
Free the scripting data.
void script_server_state_load(struct section_file *file)
Load the scripting state from file.
void script_server_remove_exported_object(void *object)
Mark any, if exported, full userdata representing 'object' in the current script state as 'Nonexisten...
bool script_server_unsafe_do_file(struct connection *caller, const char *filename)
Parse and execute the script at filename in an unsafe instance.
bool script_server_load_file(const char *filename, char **buf)
Load script to a buffer.
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.