The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
core.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2016 by Yurii Chernyi <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef AI_LUA_CORE_HPP
16 #define AI_LUA_CORE_HPP
17 
18 #include <boost/shared_ptr.hpp>
19 
20 struct lua_State;
21 class game_lua_kernel;
22 class config;
23 
24 
25 
26 namespace ai {
27 
28 class engine_lua;
31 
32 /**
33  * Proxy table for the AI context
34  */
36 {
37 private:
39  int num_;
40  int side_;
41  lua_ai_context(lua_State *l, int num, int side) : L(l), num_(num), side_(side)
42  {
43  }
44  static lua_ai_context* create(lua_State *L, char const *code, engine_lua *engine);
45 public:
47  void update_state();
48  void get_persistent_data(config &) const;
49  void set_persistent_data(const config &);
50  void get_arguments(config &) const;
51  void set_arguments(const config &);
52  void push_ai_table();
53  static void init(lua_State *L);
54  friend class ::game_lua_kernel;
55  friend class lua_ai_load;
56 };
57 
59 {
61  static int refcount;
62 public:
64  lua_ai_load(lua_ai_context& ctx, bool read_only);
65  ~lua_ai_load();
66 };
67 
68 /**
69  * Proxy class for calling AI action handlers defined in Lua.
70  */
72 {
73 private:
76  int num_;
77  lua_ai_action_handler(lua_State *l, lua_ai_context &context, int num) : L(l), context_(context),num_(num)
78  {
79  }
80  static lua_ai_action_handler* create(lua_State *L, char const *code, lua_ai_context &context);
81 public:
83  void handle(const config &cfg, bool read_only, lua_object_ptr l_obj);
84  friend class ::game_lua_kernel;
85 };
86 
87 }//of namespace ai
88 
89 #endif
boost::shared_ptr< lua_object_base > lua_object_ptr
Definition: core.hpp:29
void get_persistent_data(config &) const
Definition: core.cpp:95
lua_ai_context & context_
Definition: core.hpp:75
static lua_ai_context * create(lua_State *L, char const *code, engine_lua *engine)
Definition: core.cpp:979
void handle(const config &cfg, bool read_only, lua_object_ptr l_obj)
Definition: core.cpp:1106
GLdouble l
Definition: glew.h:6966
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:57
void set_arguments(const config &)
Definition: core.cpp:81
void set_persistent_data(const config &)
Definition: core.cpp:109
bool was_readonly
Definition: core.hpp:63
Proxy table for the AI context.
Definition: core.hpp:35
static lua_ai_action_handler * create(lua_State *L, char const *code, lua_ai_context &context)
Definition: core.cpp:1022
lua_ai_load(lua_ai_context &ctx, bool read_only)
Definition: core.cpp:1049
GLuint num
Definition: glew.h:2552
static int refcount
Definition: core.hpp:61
void push_ai_table()
Definition: core.cpp:134
static void init(lua_State *L)
Definition: core.cpp:59
lua_ai_context(lua_State *l, int num, int side)
Definition: core.hpp:41
void get_arguments(config &) const
Definition: core.cpp:67
Proxy class for calling AI action handlers defined in Lua.
Definition: core.hpp:71
lua_ai_action_handler(lua_State *l, lua_ai_context &context, int num)
Definition: core.hpp:77
lua_State * L
Definition: core.hpp:38
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
lua_State * L
Definition: core.hpp:60
void update_state()
Definition: core.cpp:1000