Follow-up Comment #1, patch #2638 (project wesnoth):

(some more comments from Crab)

value_ = boost::shared_ptr<T>(new T(value_lua_->get())); // a copy is done
here. not a big deal, but it is possible to avoid that copy, by making lua
object return a boost::shared_ptr<T> 
assert(valid_); // is really assert (false) there


lua_aspect(readonly_context &context, const config &cfg, const std::string
&id) // this can be called directly by lua engine, 'ai::engine_ptr le =
context.get_engine_by_cfg(cfg); ai::lua_ai_context& l_ctx =
le->get_lua_ai_context(); ' is not needed, you can just add more constructor
arguments.


src/ai/composite/engine.hpp should not know, as far as possible, about
lua.'virtual lua_ai_context& get_lua_ai_context();' is not necessary



src/ai/composite/engine_lua.cpp , evaluate execute, do_play_stage - you have
memory leaks there!

src/ai/composite/engine_lua.cpp , engine_lua::do_parse_aspect_from_config -
you'll can use a modified version of the factory code - to add more
constructor arguments, such as any refs to lua ai stuff. or you can use an
init method.

engine_lua::evaluate - implement it, as well, it would allow far more easier
testing - (:f command now evaluates fai commands, you can hack in support for
lua evaluator for strings which start with "lua ")

src/ai/composite/stage.cpp - done properly, there would be no need for
default ctor for ministage


lua_ai_action_handler::handle // 'if (!luaW_toconfig(L, initial_top + 2,
cfg)) {' part is no longer needed


src/ai/lua/core.hpp // instead of 'typedef lua_object_base* lua_object_ptr;',
typedef it to smart pointer to base.

src/ai/lua/lua_object.hpp : I suggest to keep lua_object only as value
container (remove methods like 'chunk, l_ctx, get', leaving only code to store
a value and retrieve a stored value)

    _______________________________________________________

Reply to this item at:

  <http://gna.org/patch/?2638>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs

Reply via email to