mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 19:25:29 +00:00
Strip trailing whitespace.
This commit is contained in:
parent
b63e80c61c
commit
d9a28eccae
@ -167,8 +167,8 @@ public:
|
||||
virtual boost::shared_ptr<T> get_ptr() const
|
||||
{
|
||||
if (!valid_) {
|
||||
if (!(valid_variant_ || valid_lua_)) {
|
||||
recalculate();
|
||||
if (!(valid_variant_ || valid_lua_)) {
|
||||
recalculate();
|
||||
}
|
||||
|
||||
if (!valid_ ) {
|
||||
@ -397,7 +397,7 @@ protected:
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class lua_aspect : public typesafe_aspect<T>
|
||||
class lua_aspect : public typesafe_aspect<T>
|
||||
{
|
||||
public:
|
||||
lua_aspect(readonly_context &context, const config &cfg, const std::string &id, boost::shared_ptr<lua_ai_context>& l_ctx)
|
||||
@ -405,7 +405,7 @@ public:
|
||||
, handler_()
|
||||
{
|
||||
std::string value;
|
||||
if (cfg.has_attribute("value"))
|
||||
if (cfg.has_attribute("value"))
|
||||
{
|
||||
value = cfg["value"].str();
|
||||
if (value == "yes") // @TODO for Nephro or Crab: get rid of this workaround
|
||||
@ -413,17 +413,17 @@ public:
|
||||
value = "true";
|
||||
}
|
||||
value = "return " + value;
|
||||
}
|
||||
else if (cfg.has_attribute("code"))
|
||||
{
|
||||
}
|
||||
else if (cfg.has_attribute("code"))
|
||||
{
|
||||
value = cfg["code"].str();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// error
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
handler_ = boost::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(value.c_str(), *l_ctx));
|
||||
}
|
||||
|
||||
@ -516,7 +516,7 @@ public:
|
||||
: lua_aspect_factory( name )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
aspect_ptr get_new_instance( readonly_context &context, const config &cfg, const std::string &id, boost::shared_ptr<lua_ai_context>& l_ctx)
|
||||
{
|
||||
boost::shared_ptr<ASPECT> _a(new ASPECT(context,cfg,id,l_ctx));
|
||||
|
@ -65,14 +65,14 @@ public:
|
||||
virtual double evaluate()
|
||||
{
|
||||
serialized_evaluation_state_ = config();
|
||||
|
||||
|
||||
lua_int_obj l_obj = lua_int_obj(new lua_object<int>());
|
||||
|
||||
|
||||
if (evaluation_action_handler_) {
|
||||
evaluation_action_handler_->handle(serialized_evaluation_state_, true, l_obj);
|
||||
} else {
|
||||
return BAD_SCORE;
|
||||
}
|
||||
}
|
||||
|
||||
return *(l_obj->get());
|
||||
}
|
||||
@ -119,7 +119,7 @@ public:
|
||||
{
|
||||
gamestate_observer gs_o;
|
||||
lua_int_obj l_obj = lua_int_obj(new lua_object<int>());
|
||||
|
||||
|
||||
if (action_handler_) {
|
||||
action_handler_->handle(serialized_evaluation_state_, false, l_obj);
|
||||
}
|
||||
@ -196,12 +196,12 @@ void engine_lua::do_parse_aspect_from_config( const config &cfg, const std::stri
|
||||
{
|
||||
const std::string aspect_factory_key = id+"*lua_aspect"; // @note: factory key for a lua_aspect
|
||||
lua_aspect_factory::factory_map::iterator f = lua_aspect_factory::get_list().find(aspect_factory_key);
|
||||
|
||||
|
||||
if (f == lua_aspect_factory::get_list().end()){
|
||||
ERR_AI_LUA << "side "<<ai_.get_side()<< " : UNKNOWN aspect["<<aspect_factory_key<<"]" << std::endl;
|
||||
DBG_AI_LUA << "config snippet contains: " << std::endl << cfg << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
aspect_ptr new_aspect = f->second->get_new_instance(ai_,cfg,id,lua_ai_context_);
|
||||
if (!new_aspect) {
|
||||
ERR_AI_LUA << "side "<<ai_.get_side()<< " : UNABLE TO CREATE aspect, key=["<<aspect_factory_key<<"]"<< std::endl;
|
||||
|
@ -45,13 +45,13 @@ public:
|
||||
* and parse several (usually, 1) stages out of it
|
||||
*/
|
||||
virtual void do_parse_stage_from_config( ai_context &context, const config &cfg, std::back_insert_iterator<std::vector< stage_ptr > > b );
|
||||
|
||||
|
||||
/**
|
||||
* Taka a config (with engine=lua in it)
|
||||
* and parse several (usually, 1) aspects out of it
|
||||
*/
|
||||
void do_parse_aspect_from_config( const config &cfg, const std::string &id, std::back_insert_iterator<std::vector< aspect_ptr > > b );
|
||||
|
||||
|
||||
virtual std::string evaluate(const std::string &str);
|
||||
|
||||
/**
|
||||
@ -65,7 +65,7 @@ public:
|
||||
* , like access to game state and movement/attack routines.
|
||||
*/
|
||||
virtual void set_ai_context(ai_context *context);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
@ -56,7 +56,7 @@ static lg::log_domain log_ai_engine_lua("ai/engine/lua");
|
||||
static char const aisKey = 0;
|
||||
|
||||
namespace ai {
|
||||
|
||||
|
||||
void lua_ai_context::init(lua_State *L)
|
||||
{
|
||||
// Create the ai elements table.
|
||||
@ -268,29 +268,29 @@ static int cfun_ai_get_attack_depth(lua_State *L)
|
||||
static int cfun_ai_get_avoid(lua_State *L)
|
||||
{
|
||||
std::set<map_location> locs;
|
||||
terrain_filter avoid = get_readonly_context(L).get_avoid();
|
||||
terrain_filter avoid = get_readonly_context(L).get_avoid();
|
||||
avoid.get_locations(locs, true); // is it true here?
|
||||
|
||||
|
||||
int sz = locs.size();
|
||||
lua_createtable(L, sz, 0); // create a table that we'll use as an array
|
||||
|
||||
std::set<map_location>::iterator it = locs.begin();
|
||||
lua_createtable(L, sz, 0); // create a table that we'll use as an array
|
||||
|
||||
std::set<map_location>::iterator it = locs.begin();
|
||||
for (int i = 0; it != locs.end(); ++it, ++i)
|
||||
{
|
||||
lua_pushinteger(L, i + 1); // Index for the map location
|
||||
lua_createtable(L, 2, 0); // Table for a single map location
|
||||
|
||||
lua_pushstring(L, "x");
|
||||
lua_pushinteger(L, it->x);
|
||||
|
||||
lua_pushstring(L, "x");
|
||||
lua_pushinteger(L, it->x);
|
||||
lua_settable(L, -3);
|
||||
|
||||
|
||||
lua_pushstring(L, "y");
|
||||
lua_pushinteger(L, it->y);
|
||||
lua_settable(L, -3);
|
||||
|
||||
lua_settable(L, -3);
|
||||
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ static int cfun_ai_get_leader_aggression(lua_State *L)
|
||||
static int cfun_ai_get_leader_goal(lua_State *L)
|
||||
{
|
||||
config goal = get_readonly_context(L).get_leader_goal();
|
||||
luaW_pushconfig(L, goal);
|
||||
luaW_pushconfig(L, goal);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -392,7 +392,7 @@ static int cfun_ai_get_simple_targeting(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cfun_ai_get_support_villages(lua_State *L)
|
||||
static int cfun_ai_get_support_villages(lua_State *L)
|
||||
{
|
||||
bool support_villages = get_readonly_context(L).get_support_villages();
|
||||
lua_pushboolean(L, support_villages);
|
||||
@ -417,51 +417,51 @@ static int cfun_ai_get_villages_per_scout(lua_State *L)
|
||||
static void push_map_location(lua_State *L, const map_location& ml)
|
||||
{
|
||||
lua_createtable(L, 2, 0);
|
||||
|
||||
|
||||
lua_pushstring(L, "x");
|
||||
lua_pushinteger(L, ml.x);
|
||||
lua_rawset(L, -3);
|
||||
|
||||
lua_pushstring(L, "y");
|
||||
lua_pushinteger(L, ml.y);
|
||||
lua_rawset(L, -3);
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
|
||||
static void push_move_map(lua_State *L, const move_map& m)
|
||||
{
|
||||
move_map::const_iterator it = m.begin();
|
||||
|
||||
int index = 1;
|
||||
|
||||
|
||||
int index = 1;
|
||||
|
||||
lua_createtable(L, 0, 0); // the main table
|
||||
|
||||
|
||||
do {
|
||||
map_location key = it->first;
|
||||
|
||||
|
||||
push_map_location(L, key);
|
||||
lua_createtable(L, 0, 0);
|
||||
|
||||
|
||||
while (key == it->first) {
|
||||
|
||||
|
||||
push_map_location(L, it->second);
|
||||
lua_rawseti(L, -2, index);
|
||||
|
||||
|
||||
++index;
|
||||
++it;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
lua_settable(L, -3);
|
||||
|
||||
index = 1;
|
||||
|
||||
|
||||
index = 1;
|
||||
|
||||
} while (it != m.end());
|
||||
}
|
||||
|
||||
static int cfun_ai_get_dstsrc(lua_State *L)
|
||||
{
|
||||
move_map dst_src = get_readonly_context(L).get_dstsrc();
|
||||
push_move_map(L, dst_src);
|
||||
push_move_map(L, dst_src);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -473,14 +473,14 @@ static int cfun_ai_get_srcdst(lua_State *L)
|
||||
}
|
||||
|
||||
static int cfun_ai_get_enemy_dstsrc(lua_State *L)
|
||||
{
|
||||
{
|
||||
move_map enemy_dst_src = get_readonly_context(L).get_enemy_dstsrc();
|
||||
push_move_map(L, enemy_dst_src);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cfun_ai_get_enemy_srcdst(lua_State *L)
|
||||
{
|
||||
{
|
||||
move_map enemy_src_dst = get_readonly_context(L).get_enemy_dstsrc();
|
||||
push_move_map(L, enemy_src_dst);
|
||||
return 1;
|
||||
@ -611,7 +611,7 @@ lua_ai_context::~lua_ai_context()
|
||||
|
||||
void lua_ai_action_handler::handle(config &cfg, bool configOut, lua_object_ptr l_obj)
|
||||
{
|
||||
int initial_top = lua_gettop(L);//get the old stack size
|
||||
int initial_top = lua_gettop(L);//get the old stack size
|
||||
|
||||
// Load the user function from the registry.
|
||||
lua_pushlightuserdata(L, (void *)&aisKey);//stack size is now 1 [-1: ais_table key]
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
namespace ai {
|
||||
|
||||
lua_object_base::lua_object_base()
|
||||
lua_object_base::lua_object_base()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
@ -56,10 +56,10 @@ public:
|
||||
}
|
||||
|
||||
boost::shared_ptr<T> get()
|
||||
{
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
|
||||
void store(lua_State* L, int n)
|
||||
{
|
||||
this->value_ = boost::shared_ptr<T>(to_type(L, n));
|
||||
@ -68,7 +68,7 @@ public:
|
||||
protected:
|
||||
|
||||
// A group of functions that deal with the translation of the results to C++
|
||||
boost::shared_ptr<T> to_type(lua_State *, int)
|
||||
boost::shared_ptr<T> to_type(lua_State *, int)
|
||||
{
|
||||
return boost::shared_ptr<T>();
|
||||
}
|
||||
@ -77,25 +77,25 @@ protected:
|
||||
};
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr<double> lua_object<double>::to_type(lua_State *L, int n)
|
||||
inline boost::shared_ptr<double> lua_object<double>::to_type(lua_State *L, int n)
|
||||
{
|
||||
return boost::shared_ptr<double>(new double(lua_tonumber(L, n)));
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr<std::string> lua_object<std::string>::to_type(lua_State *L, int n)
|
||||
inline boost::shared_ptr<std::string> lua_object<std::string>::to_type(lua_State *L, int n)
|
||||
{
|
||||
return boost::shared_ptr<std::string>(new std::string(lua_tostring(L, n)));
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr<bool> lua_object<bool>::to_type(lua_State *L, int n)
|
||||
inline boost::shared_ptr<bool> lua_object<bool>::to_type(lua_State *L, int n)
|
||||
{
|
||||
return boost::shared_ptr<bool>(new bool(lua_toboolean(L, n)));
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
inline boost::shared_ptr<int> lua_object<int>::to_type(lua_State *L, int n)
|
||||
inline boost::shared_ptr<int> lua_object<int>::to_type(lua_State *L, int n)
|
||||
{
|
||||
return boost::shared_ptr<int>(new int(lua_tonumber(L, n)));
|
||||
}
|
||||
@ -105,7 +105,7 @@ inline boost::shared_ptr< std::vector<std::string> > lua_object< std::vector<std
|
||||
{
|
||||
boost::shared_ptr< std::vector<std::string> > v = boost::shared_ptr< std::vector<std::string> >(new std::vector<std::string>());
|
||||
int l = lua_objlen(L, n);
|
||||
for (int i = 1; i < l + 1; ++i)
|
||||
for (int i = 1; i < l + 1; ++i)
|
||||
{
|
||||
lua_pushinteger(L, i);
|
||||
lua_gettable(L, n);
|
||||
@ -113,7 +113,7 @@ inline boost::shared_ptr< std::vector<std::string> > lua_object< std::vector<std
|
||||
lua_settop(L, n);
|
||||
v->push_back(s);
|
||||
}
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ static register_lua_aspect_factory< lua_aspect<double> >
|
||||
|
||||
static register_lua_aspect_factory< lua_aspect<int> >
|
||||
attack_depth__lua_aspect_factory("attack_depth*lua_aspect");
|
||||
|
||||
|
||||
static register_lua_aspect_factory< lua_aspect<terrain_filter> >
|
||||
avoid__lua_aspect_factory("avoid*lua_aspect");
|
||||
|
||||
@ -376,7 +376,7 @@ static register_lua_aspect_factory< lua_aspect<std::string> >
|
||||
|
||||
static register_lua_aspect_factory< lua_aspect<double> >
|
||||
leader_aggression__lua_aspect_factory("leader_aggression*lua_aspect");
|
||||
|
||||
|
||||
static register_lua_aspect_factory< lua_aspect<config> >
|
||||
leader_goal__lua_aspect_factory("leader_goal*lua_aspect");
|
||||
|
||||
@ -412,7 +412,7 @@ static register_lua_aspect_factory< lua_aspect<double> >
|
||||
|
||||
static register_lua_aspect_factory< lua_aspect<int> >
|
||||
villages_per_scout__lua_aspect_factory("villages_per_scout*lua_aspect");
|
||||
|
||||
|
||||
static register_lua_aspect_factory< lua_aspect< std::vector<std::string> > >
|
||||
recruitment_pattern__lua_aspect_factory("recruitment_pattern*lua_aspect");
|
||||
|
||||
|
@ -212,7 +212,7 @@ commandline_options::commandline_options ( int argc, char** argv ) :
|
||||
("smallgui", "")
|
||||
;
|
||||
visible_.add(general_opts).add(campaign_opts).add(display_opts).add(logging_opts).add(multiplayer_opts).add(preprocessor_opts).add(proxy_opts);
|
||||
|
||||
|
||||
all_.add(visible_).add(hidden_);
|
||||
|
||||
po::positional_options_description positional;
|
||||
|
@ -89,7 +89,7 @@ private:
|
||||
void set_unit_data();
|
||||
|
||||
void mark_completed_campaigns(std::vector<config>& campaigns);
|
||||
|
||||
|
||||
editor::EXIT_STATUS start_editor(const std::string& filename);
|
||||
|
||||
//this should get destroyed *after* the video, since we want
|
||||
|
@ -105,7 +105,7 @@ void set_fullscreen(CVideo& video, const bool ison)
|
||||
if(video.isFullScreen() != ison) {
|
||||
const int flags = ison ? FULL_SCREEN : 0;
|
||||
int bpp = video.bppForMode(res.first, res.second, flags);
|
||||
|
||||
|
||||
if(bpp > 0) {
|
||||
video.setMode(res.first,res.second,bpp,flags);
|
||||
if(disp) {
|
||||
|
@ -573,7 +573,7 @@ void wml_animation_internal(unit_animator &animator, const vconfig &cfg, const m
|
||||
}
|
||||
}
|
||||
animator.add_animation(&*u, cfg["flag"], u->get_location(),
|
||||
secondary_loc, cfg["value"], cfg["with_bars"].to_bool(),
|
||||
secondary_loc, cfg["value"], cfg["with_bars"].to_bool(),
|
||||
cfg["text"], text_color, hits, primary, secondary,
|
||||
cfg["value_second"]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user