widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #06085
[Merge] lp:~widelands-dev/widelands/bug-1395278-scripting into lp:widelands
Klaus Halfmann has proposed merging lp:~widelands-dev/widelands/bug-1395278-scripting into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1395278-scripting/+merge/285909
* Switch from m_<name> to <name>_ mostly in scripting
* Fixed a doc warning for clang in songset.h
I expanded some variables to more expressive names
like m_plr -> player_number_
As lua uses m_ for functions as well the code
should be more readable as well.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1395278-scripting into lp:widelands.
=== modified file 'src/scripting/logic.cc'
--- src/scripting/logic.cc 2015-01-31 16:03:59 +0000
+++ src/scripting/logic.cc 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2015 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -63,22 +63,22 @@
} // namespace
LuaEditorInterface::LuaEditorInterface(Widelands::EditorGameBase* g)
- : m_factory(new EditorFactory())
+ : factory_(new EditorFactory())
{
- setup_for_editor_and_game(m_L, g);
- LuaRoot::luaopen_wlroot(m_L, true);
- LuaEditor::luaopen_wleditor(m_L);
+ setup_for_editor_and_game(lua_state_, g);
+ LuaRoot::luaopen_wlroot(lua_state_, true);
+ LuaEditor::luaopen_wleditor(lua_state_);
// Push the factory class into the registry
- lua_pushlightuserdata(m_L, reinterpret_cast<void*>(dynamic_cast<Factory*>(m_factory.get())));
- lua_setfield(m_L, LUA_REGISTRYINDEX, "factory");
+ lua_pushlightuserdata(lua_state_, reinterpret_cast<void*>(dynamic_cast<Factory*>(factory_.get())));
+ lua_setfield(lua_state_, LUA_REGISTRYINDEX, "factory");
}
LuaEditorInterface::~LuaEditorInterface() {
}
std::unique_ptr<LuaTable> LuaEditorInterface::run_script(const std::string& script) {
- return run_script_maybe_from_map(m_L, script);
+ return run_script_maybe_from_map(lua_state_, script);
}
// Special handling of math.random.
@@ -125,27 +125,27 @@
}
LuaGameInterface::LuaGameInterface(Widelands::Game * g)
- : m_factory(new GameFactory())
+ : factory_(new GameFactory())
{
- setup_for_editor_and_game(m_L, g);
+ setup_for_editor_and_game(lua_state_, g);
// Overwrite math.random
- lua_getglobal(m_L, "math");
- lua_pushcfunction(m_L, L_math_random);
- lua_setfield(m_L, -2, "random");
- lua_pop(m_L, 1); // pop "math"
+ lua_getglobal(lua_state_, "math");
+ lua_pushcfunction(lua_state_, L_math_random);
+ lua_setfield(lua_state_, -2, "random");
+ lua_pop(lua_state_, 1); // pop "math"
- LuaRoot::luaopen_wlroot(m_L, false);
- LuaGame::luaopen_wlgame(m_L);
+ LuaRoot::luaopen_wlroot(lua_state_, false);
+ LuaGame::luaopen_wlgame(lua_state_);
// Push the game into the registry
- lua_pushlightuserdata(m_L, static_cast<void *>(g));
- lua_setfield(m_L, LUA_REGISTRYINDEX, "game");
+ lua_pushlightuserdata(lua_state_, static_cast<void *>(g));
+ lua_setfield(lua_state_, LUA_REGISTRYINDEX, "game");
// Push the factory class into the registry
lua_pushlightuserdata
- (m_L, reinterpret_cast<void *>(dynamic_cast<Factory *>(m_factory.get())));
- lua_setfield(m_L, LUA_REGISTRYINDEX, "factory");
+ (lua_state_, reinterpret_cast<void *>(dynamic_cast<Factory *>(factory_.get())));
+ lua_setfield(lua_state_, LUA_REGISTRYINDEX, "factory");
}
LuaGameInterface::~LuaGameInterface() {
@@ -153,7 +153,7 @@
LuaCoroutine* LuaGameInterface::read_coroutine(FileRead& fr) {
LuaCoroutine * rv = new LuaCoroutine(nullptr);
- rv->read(m_L, fr);
+ rv->read(lua_state_, fr);
return rv;
}
@@ -167,77 +167,77 @@
uint32_t size)
{
// Clean out the garbage before loading.
- lua_gc(m_L, LUA_GCCOLLECT, 0);
+ lua_gc(lua_state_, LUA_GCCOLLECT, 0);
- assert(lua_gettop(m_L) == 0); // S:
- unpersist_object(m_L, fr, mol, size);
- assert(lua_gettop(m_L) == 1); // S: unpersisted_object
- luaL_checktype(m_L, -1, LUA_TTABLE);
+ assert(lua_gettop(lua_state_) == 0); // S:
+ unpersist_object(lua_state_, fr, mol, size);
+ assert(lua_gettop(lua_state_) == 1); // S: unpersisted_object
+ luaL_checktype(lua_state_, -1, LUA_TTABLE);
// Now, we have to merge all keys from the loaded table
// into the global table
- lua_pushnil(m_L); // S: table nil
- while (lua_next(m_L, 1) != 0) {
+ lua_pushnil(lua_state_); // S: table nil
+ while (lua_next(lua_state_, 1) != 0) {
// S: table key value
- lua_rawgeti(m_L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); // S: table key value globals_table
- lua_pushvalue(m_L, -3); // S: table key value globals_table key
- lua_gettable(m_L, -2); // S: table key value globals_table value_in_globals
- if (lua_compare(m_L, -1, -3, LUA_OPEQ)) {
- lua_pop(m_L, 3); // S: table key
+ lua_rawgeti(lua_state_, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); // S: table key value globals_table
+ lua_pushvalue(lua_state_, -3); // S: table key value globals_table key
+ lua_gettable(lua_state_, -2); // S: table key value globals_table value_in_globals
+ if (lua_compare(lua_state_, -1, -3, LUA_OPEQ)) {
+ lua_pop(lua_state_, 3); // S: table key
continue;
} else {
// Make this a global value
- lua_pop(m_L, 1); // S: table key value globals_table
- lua_pushvalue(m_L, -3); // S: table key value globals_table key
- lua_pushvalue(m_L, -3); // S: table key value globals_table key value
- lua_settable(m_L, -3); // S: table key value globals_table
- lua_pop(m_L, 2); // S: table key
+ lua_pop(lua_state_, 1); // S: table key value globals_table
+ lua_pushvalue(lua_state_, -3); // S: table key value globals_table key
+ lua_pushvalue(lua_state_, -3); // S: table key value globals_table key value
+ lua_settable(lua_state_, -3); // S: table key value globals_table
+ lua_pop(lua_state_, 2); // S: table key
}
}
- lua_pop(m_L, 1); // pop the table returned by unpersist_object
+ lua_pop(lua_state_, 1); // pop the table returned by unpersist_object
// Clean out the garbage before returning.
- lua_gc(m_L, LUA_GCCOLLECT, 0);
+ lua_gc(lua_state_, LUA_GCCOLLECT, 0);
}
uint32_t LuaGameInterface::write_global_env
(FileWrite & fw, Widelands::MapObjectSaver & mos)
{
// Clean out the garbage before writing.
- lua_gc(m_L, LUA_GCCOLLECT, 0);
+ lua_gc(lua_state_, LUA_GCCOLLECT, 0);
// Empty table + object to persist on the stack Stack
- lua_newtable(m_L);
- lua_rawgeti(m_L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS);
+ lua_newtable(lua_state_);
+ lua_rawgeti(lua_state_, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS);
- uint32_t nwritten = persist_object(m_L, fw, mos);
+ uint32_t nwritten = persist_object(lua_state_, fw, mos);
// Garbage collect once more, so we do not return unnecessary stuff.
- lua_gc(m_L, LUA_GCCOLLECT, 0);
+ lua_gc(lua_state_, LUA_GCCOLLECT, 0);
return nwritten;
}
std::unique_ptr<LuaTable> LuaGameInterface::get_hook(const std::string& name) {
- lua_getglobal(m_L, "hooks");
- if (lua_isnil(m_L, -1)) {
- lua_pop(m_L, 1);
- return std::unique_ptr<LuaTable>();
- }
-
- lua_getfield(m_L, -1, name.c_str());
- if (lua_isnil(m_L, -1)) {
- lua_pop(m_L, 2);
- return std::unique_ptr<LuaTable>();
- }
- lua_remove(m_L, -2);
-
- std::unique_ptr<LuaTable> return_value(new LuaTable(m_L));
- lua_pop(m_L, 1);
+ lua_getglobal(lua_state_, "hooks");
+ if (lua_isnil(lua_state_, -1)) {
+ lua_pop(lua_state_, 1);
+ return std::unique_ptr<LuaTable>();
+ }
+
+ lua_getfield(lua_state_, -1, name.c_str());
+ if (lua_isnil(lua_state_, -1)) {
+ lua_pop(lua_state_, 2);
+ return std::unique_ptr<LuaTable>();
+ }
+ lua_remove(lua_state_, -2);
+
+ std::unique_ptr<LuaTable> return_value(new LuaTable(lua_state_));
+ lua_pop(lua_state_, 1);
return return_value;
}
std::unique_ptr<LuaTable> LuaGameInterface::run_script(const std::string& script) {
- return run_script_maybe_from_map(m_L, script);
+ return run_script_maybe_from_map(lua_state_, script);
}
=== modified file 'src/scripting/logic.h'
--- src/scripting/logic.h 2015-01-31 16:03:59 +0000
+++ src/scripting/logic.h 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2015 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -37,7 +37,7 @@
std::unique_ptr<LuaTable> run_script(const std::string& script) override;
private:
- std::unique_ptr<EditorFactory> m_factory;
+ std::unique_ptr<EditorFactory> factory_;
};
class LuaGameInterface : public LuaInterface {
@@ -61,7 +61,7 @@
(FileWrite &, Widelands::MapObjectSaver &);
private:
- std::unique_ptr<GameFactory> m_factory;
+ std::unique_ptr<GameFactory> factory_;
};
#endif // end of include guard: WL_SCRIPTING_LOGIC_H
=== modified file 'src/scripting/lua.h'
--- src/scripting/lua.h 2015-01-31 16:03:59 +0000
+++ src/scripting/lua.h 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2015 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
=== modified file 'src/scripting/lua_bases.cc'
--- src/scripting/lua_bases.cc 2015-11-28 22:29:26 +0000
+++ src/scripting/lua_bases.cc 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2010 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -280,10 +280,10 @@
};
void LuaPlayerBase::__persist(lua_State * L) {
- PERS_UINT32("player", m_pl);
+ PERS_UINT32("player", player_number_);
}
void LuaPlayerBase::__unpersist(lua_State * L) {
- UNPERS_UINT32("player", m_pl);
+ UNPERS_UINT32("player", player_number_);
}
/*
@@ -297,7 +297,7 @@
(RO) The number of this Player.
*/
int LuaPlayerBase::get_number(lua_State * L) {
- lua_pushuint32(L, m_pl);
+ lua_pushuint32(L, player_number_);
return 1;
}
@@ -578,7 +578,7 @@
get_egbase(L).conquer_area_no_building
(PlayerArea<Area<FCoords> >
- (m_pl, Area<FCoords>
+ (player_number_, Area<FCoords>
((*get_user_class<LuaMaps::LuaField>(L, 2))->fcoords(L), radius))
);
return 0;
@@ -643,11 +643,11 @@
Player & LuaPlayerBase::get
(lua_State * L, Widelands::EditorGameBase & egbase)
{
- if (m_pl > MAX_PLAYERS)
- report_error(L, "Illegal player number %i", m_pl);
- Player * rv = egbase.get_player(m_pl);
+ if (player_number_ > MAX_PLAYERS)
+ report_error(L, "Illegal player number %i", player_number_);
+ Player * rv = egbase.get_player(player_number_);
if (!rv)
- report_error(L, "Player with the number %i does not exist", m_pl);
+ report_error(L, "Player with the number %i does not exist", player_number_);
return *rv;
}
=== modified file 'src/scripting/lua_bases.h'
--- src/scripting/lua_bases.h 2015-04-11 08:58:15 +0000
+++ src/scripting/lua_bases.h 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2010 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -70,19 +70,19 @@
class LuaPlayerBase : public LuaBasesModuleClass {
- Widelands::PlayerNumber m_pl;
+ Widelands::PlayerNumber player_number_;
enum {NONE = -1};
public:
LUNA_CLASS_HEAD(LuaPlayerBase);
- LuaPlayerBase() : m_pl(NONE) {}
- LuaPlayerBase (lua_State * L) : m_pl(NONE) {
+ LuaPlayerBase() : player_number_(NONE) {}
+ LuaPlayerBase (lua_State * L) : player_number_(NONE) {
report_error(L, "Cannot instantiate a 'PlayerBase' directly!");
}
LuaPlayerBase(Widelands::PlayerNumber n) {
- m_pl = n;
+ player_number_ = n;
}
virtual ~LuaPlayerBase() {}
@@ -114,7 +114,7 @@
Widelands::Player& get(lua_State* L, Widelands::EditorGameBase&);
protected:
- inline Widelands::PlayerNumber player_number() {return m_pl;}
+ inline Widelands::PlayerNumber player_number() {return player_number_;}
};
void luaopen_wlbases(lua_State *);
=== modified file 'src/scripting/lua_coroutine.cc'
--- src/scripting/lua_coroutine.cc 2015-10-18 20:23:10 +0000
+++ src/scripting/lua_coroutine.cc 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2015 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -60,92 +60,92 @@
} // namespace
LuaCoroutine::LuaCoroutine(lua_State * ms)
- : m_L(ms), m_idx(LUA_REFNIL), m_ninput_args(0), m_nreturn_values(0)
+ : lua_state_(ms), idx_(LUA_REFNIL), ninput_args_(0), nreturn_values_(0)
{
- if (m_L) {
- m_idx = reference_coroutine(m_L);
+ if (lua_state_) {
+ idx_ = reference_coroutine(lua_state_);
}
}
LuaCoroutine::~LuaCoroutine() {
- unreference_coroutine(m_L, m_idx);
+ unreference_coroutine(lua_state_, idx_);
}
int LuaCoroutine::get_status() {
- return lua_status(m_L);
+ return lua_status(lua_state_);
}
int LuaCoroutine::resume()
{
- int rv = lua_resume(m_L, nullptr, m_ninput_args);
- m_ninput_args = 0;
- m_nreturn_values = lua_gettop(m_L);
+ int rv = lua_resume(lua_state_, nullptr, ninput_args_);
+ ninput_args_ = 0;
+ nreturn_values_ = lua_gettop(lua_state_);
if (rv != 0 && rv != YIELDED) {
- throw LuaError(lua_tostring(m_L, -1));
+ throw LuaError(lua_tostring(lua_state_, -1));
}
return rv;
}
void LuaCoroutine::push_arg(const Widelands::Player * plr) {
- to_lua<LuaGame::LuaPlayer>(m_L, new LuaGame::LuaPlayer(plr->player_number()));
- m_ninput_args++;
+ to_lua<LuaGame::LuaPlayer>(lua_state_, new LuaGame::LuaPlayer(plr->player_number()));
+ ninput_args_++;
}
void LuaCoroutine::push_arg(const Widelands::Coords & coords) {
- to_lua<LuaMaps::LuaField>(m_L, new LuaMaps::LuaField(coords));
- ++m_nargs;
- ++m_ninput_args;
+ to_lua<LuaMaps::LuaField>(lua_state_, new LuaMaps::LuaField(coords));
+ ++nargs_;
+ ++ninput_args_;
}
void LuaCoroutine::push_arg(const Widelands::BuildingDescr* building_descr) {
assert(building_descr != nullptr);
- to_lua<LuaMaps::LuaBuildingDescription>(m_L, new LuaMaps::LuaBuildingDescription(building_descr));
- ++m_ninput_args;
+ to_lua<LuaMaps::LuaBuildingDescription>(lua_state_, new LuaMaps::LuaBuildingDescription(building_descr));
+ ++ninput_args_;
}
void LuaCoroutine::push_arg(const Widelands::WareDescr* ware_descr) {
assert(ware_descr != nullptr);
- to_lua<LuaMaps::LuaWareDescription>(m_L, new LuaMaps::LuaWareDescription(ware_descr));
- ++m_ninput_args;
+ to_lua<LuaMaps::LuaWareDescription>(lua_state_, new LuaMaps::LuaWareDescription(ware_descr));
+ ++ninput_args_;
}
void LuaCoroutine::push_arg(const Widelands::WorkerDescr* worker_descr) {
assert(worker_descr != nullptr);
- to_lua<LuaMaps::LuaWorkerDescription>(m_L, new LuaMaps::LuaWorkerDescription(worker_descr));
- ++m_ninput_args;
+ to_lua<LuaMaps::LuaWorkerDescription>(lua_state_, new LuaMaps::LuaWorkerDescription(worker_descr));
+ ++ninput_args_;
}
void LuaCoroutine::push_arg(const std::string& string) {
assert(!string.empty());
- lua_pushstring(m_L, string);
- ++m_ninput_args;
+ lua_pushstring(lua_state_, string);
+ ++ninput_args_;
}
std::string LuaCoroutine::pop_string() {
- if (!m_nreturn_values) {
+ if (!nreturn_values_) {
return "";
}
- if (!lua_isstring(m_L, -1)) {
+ if (!lua_isstring(lua_state_, -1)) {
throw LuaError("pop_string(), but no string on the stack.");
}
- const std::string return_value = lua_tostring(m_L, -1);
- lua_pop(m_L, 1);
- --m_nreturn_values;
+ const std::string return_value = lua_tostring(lua_state_, -1);
+ lua_pop(lua_state_, 1);
+ --nreturn_values_;
return return_value;
}
uint32_t LuaCoroutine::pop_uint32() {
- if (!m_nreturn_values) {
+ if (!nreturn_values_) {
return 0;
}
- if (!lua_isnumber(m_L, -1)) {
+ if (!lua_isnumber(lua_state_, -1)) {
throw LuaError("pop_uint32(), but no integer on the stack.");
}
- const uint32_t return_value = luaL_checkuint32(m_L, -1);
- lua_pop(m_L, 1);
- --m_nreturn_values;
+ const uint32_t return_value = luaL_checkuint32(lua_state_, -1);
+ lua_pop(lua_state_, 1);
+ --nreturn_values_;
return return_value;
}
@@ -153,9 +153,9 @@
void LuaCoroutine::write(FileWrite& fw) {
fw.unsigned_8(kCoroutineDataPacketVersion);
- fw.unsigned_32(m_ninput_args);
- fw.unsigned_32(m_nreturn_values);
- fw.unsigned_32(m_idx);
+ fw.unsigned_32(ninput_args_);
+ fw.unsigned_32(nreturn_values_);
+ fw.unsigned_32(idx_);
}
void LuaCoroutine::read(lua_State* parent, FileRead& fr) {
@@ -164,12 +164,12 @@
if (version != kCoroutineDataPacketVersion)
throw wexception("Unhandled data packet version: %i\n", version);
- m_ninput_args = fr.unsigned_32();
- m_nreturn_values = fr.unsigned_32();
- m_idx = fr.unsigned_32();
+ ninput_args_ = fr.unsigned_32();
+ nreturn_values_ = fr.unsigned_32();
+ idx_ = fr.unsigned_32();
lua_getglobal(parent, kReferenceTableName);
- lua_rawgeti(parent, -1, m_idx);
- m_L = luaL_checkthread(parent, -1);
+ lua_rawgeti(parent, -1, idx_);
+ lua_state_ = luaL_checkthread(parent, -1);
lua_pop(parent, 2);
}
=== modified file 'src/scripting/lua_coroutine.h'
--- src/scripting/lua_coroutine.h 2015-10-17 11:01:14 +0000
+++ src/scripting/lua_coroutine.h 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2015 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -79,11 +79,11 @@
void write(FileWrite&);
void read(lua_State*, FileRead&);
- lua_State* m_L;
- uint32_t m_idx;
- uint32_t m_nargs;
- uint32_t m_ninput_args;
- uint32_t m_nreturn_values;
+ lua_State* lua_state_;
+ uint32_t idx_;
+ uint32_t nargs_;
+ uint32_t ninput_args_;
+ uint32_t nreturn_values_;
};
#endif // end of include guard: WL_SCRIPTING_LUA_COROUTINE_H
=== modified file 'src/scripting/lua_game.cc'
--- src/scripting/lua_game.cc 2016-01-28 05:24:34 +0000
+++ src/scripting/lua_game.cc 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2010 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -958,14 +958,14 @@
};
LuaObjective::LuaObjective(const Widelands::Objective& o) {
- m_name = o.name();
+ name_ = o.name();
}
void LuaObjective::__persist(lua_State * L) {
- PERS_STRING("name", m_name);
+ PERS_STRING("name", name_);
}
void LuaObjective::__unpersist(lua_State * L) {
- UNPERS_STRING("name", m_name);
+ UNPERS_STRING("name", name_);
}
@@ -1075,16 +1075,16 @@
Game & g = get_game(L);
// The next call checks if the Objective still exists
get(L, g);
- g.map().mutable_objectives()->erase(m_name);
+ g.map().mutable_objectives()->erase(name_);
return 0;
}
int LuaObjective::__eq(lua_State * L) {
const Map::Objectives& objectives = get_game(L).map().objectives();
- const Map::Objectives::const_iterator me = objectives.find(m_name);
+ const Map::Objectives::const_iterator me = objectives.find(name_);
const Map::Objectives::const_iterator other =
- objectives.find((*get_user_class<LuaObjective>(L, 2))->m_name);
+ objectives.find((*get_user_class<LuaObjective>(L, 2))->name_);
lua_pushboolean(L,
(me != objectives.end() && other != objectives.end()) &&
@@ -1099,10 +1099,10 @@
*/
Objective & LuaObjective::get(lua_State * L, Widelands::Game & g) {
Map::Objectives* objectives = g.map().mutable_objectives();
- Map::Objectives::iterator i = objectives->find(m_name);
+ Map::Objectives::iterator i = objectives->find(name_);
if (i == objectives->end()) {
report_error
- (L, "Objective with name '%s' doesn't exist!", m_name.c_str());
+ (L, "Objective with name '%s' doesn't exist!", name_.c_str());
}
return *i->second;
}
@@ -1132,19 +1132,19 @@
};
LuaMessage::LuaMessage(uint8_t plr, MessageId id) {
- m_plr = plr;
- m_mid = id;
+ player_number_ = plr;
+ message_id_ = id;
}
void LuaMessage::__persist(lua_State * L) {
- PERS_UINT32("player", m_plr);
- PERS_UINT32("msg_idx", get_mos(L)->message_savers[m_plr - 1][m_mid].value());
+ PERS_UINT32("player", player_number_);
+ PERS_UINT32("msg_idx", get_mos(L)->message_savers[player_number_ - 1][message_id_].value());
}
void LuaMessage::__unpersist(lua_State * L) {
- UNPERS_UINT32("player", m_plr);
+ UNPERS_UINT32("player", player_number_);
uint32_t midx = 0;
UNPERS_UINT32("msg_idx", midx);
- m_mid = MessageId(midx);
+ message_id_ = MessageId(midx);
}
/*
@@ -1220,7 +1220,7 @@
else if (s == "archived") status = Message::Status::kArchived;
else report_error(L, "Invalid message status <%s>!", s.c_str());
- get_plr(L, get_game(L)).messages().set_message_status(m_mid, status);
+ get_plr(L, get_game(L)).messages().set_message_status(message_id_, status);
return 0;
}
@@ -1253,7 +1253,7 @@
==========================================================
*/
int LuaMessage::__eq(lua_State * L) {
- lua_pushboolean(L, m_mid == (*get_user_class<LuaMessage>(L, 2))->m_mid);
+ lua_pushboolean(L, message_id_ == (*get_user_class<LuaMessage>(L, 2))->message_id_);
return 1;
}
@@ -1263,15 +1263,15 @@
==========================================================
*/
Player & LuaMessage::get_plr(lua_State * L, Widelands::Game & game) {
- if (m_plr > MAX_PLAYERS)
- report_error(L, "Illegal player number %i", m_plr);
- Player * rv = game.get_player(m_plr);
+ if (player_number_ > MAX_PLAYERS)
+ report_error(L, "Illegal player number %i", player_number_);
+ Player * rv = game.get_player(player_number_);
if (!rv)
- report_error(L, "Player with the number %i does not exist", m_plr);
+ report_error(L, "Player with the number %i does not exist", player_number_);
return *rv;
}
const Message & LuaMessage::get(lua_State * L, Widelands::Game & game) {
- const Message * rv = get_plr(L, game).messages()[m_mid];
+ const Message * rv = get_plr(L, game).messages()[message_id_];
if (!rv)
report_error(L, "This message has been deleted!");
return *rv;
=== modified file 'src/scripting/lua_game.h'
--- src/scripting/lua_game.h 2015-12-04 18:27:36 +0000
+++ src/scripting/lua_game.h 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2010 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -102,7 +102,7 @@
};
class LuaObjective : public LuaGameModuleClass {
- std::string m_name;
+ std::string name_;
public:
LUNA_CLASS_HEAD(LuaObjective);
@@ -110,7 +110,7 @@
virtual ~LuaObjective() {}
LuaObjective(const Widelands::Objective& n);
- LuaObjective() : m_name("") {}
+ LuaObjective() : name_("") {}
LuaObjective(lua_State * L) {
report_error(L, "Cannot instantiate a '%s' directly!", className);
}
@@ -144,15 +144,15 @@
};
class LuaMessage : public LuaGameModuleClass {
- uint32_t m_plr;
- Widelands::MessageId m_mid;
+ uint32_t player_number_; // TODO(Hasi50): in CTor this is uint8_t, well
+ Widelands::MessageId message_id_;
public:
LUNA_CLASS_HEAD(LuaMessage);
virtual ~LuaMessage() {}
LuaMessage(uint8_t, Widelands::MessageId);
- LuaMessage() : m_plr(0), m_mid(0) {}
+ LuaMessage() : player_number_(0), message_id_(0) {}
LuaMessage(lua_State * L) {
report_error(L, "Cannot instantiate a '%s' directly!", className);
}
=== modified file 'src/scripting/lua_interface.cc'
--- src/scripting/lua_interface.cc 2015-03-21 13:18:02 +0000
+++ src/scripting/lua_interface.cc 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2010, 2013 by the Widelands Development Team
+ * Copyright (C) 2006-2016, 2013 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -52,46 +52,46 @@
LuaInterface::LuaInterface() {
- m_L = luaL_newstate();
+ lua_state_ = luaL_newstate();
// Open the Lua libraries
- open_lua_library(m_L, "", luaopen_base, false);
- open_lua_library(m_L, LUA_TABLIBNAME, luaopen_table, true);
- open_lua_library(m_L, LUA_STRLIBNAME, luaopen_string, true);
- open_lua_library(m_L, LUA_MATHLIBNAME, luaopen_math, true);
- open_lua_library(m_L, LUA_DBLIBNAME, luaopen_debug, true);
- open_lua_library(m_L, LUA_COLIBNAME, luaopen_coroutine, true);
+ open_lua_library(lua_state_, "", luaopen_base, false);
+ open_lua_library(lua_state_, LUA_TABLIBNAME, luaopen_table, true);
+ open_lua_library(lua_state_, LUA_STRLIBNAME, luaopen_string, true);
+ open_lua_library(lua_state_, LUA_MATHLIBNAME, luaopen_math, true);
+ open_lua_library(lua_state_, LUA_DBLIBNAME, luaopen_debug, true);
+ open_lua_library(lua_state_, LUA_COLIBNAME, luaopen_coroutine, true);
// Push the instance of this class into the registry
// MSVC2008 requires that stored and retrieved types are
// same, so use LuaInterface* on both sides.
lua_pushlightuserdata
- (m_L, reinterpret_cast<void *>(dynamic_cast<LuaInterface *>(this)));
- lua_setfield(m_L, LUA_REGISTRYINDEX, "lua_interface");
+ (lua_state_, reinterpret_cast<void *>(dynamic_cast<LuaInterface *>(this)));
+ lua_setfield(lua_state_, LUA_REGISTRYINDEX, "lua_interface");
// Now our own
- LuaGlobals::luaopen_globals(m_L);
+ LuaGlobals::luaopen_globals(lua_state_);
// And helper methods.
- LuaPath::luaopen_path(m_L);
+ LuaPath::luaopen_path(lua_state_);
// Also push the "wl" and the "hooks" table.
- lua_newtable(m_L);
- lua_setglobal(m_L, "wl");
+ lua_newtable(lua_state_);
+ lua_setglobal(lua_state_, "wl");
- lua_newtable(m_L);
- lua_setglobal(m_L, "hooks");
+ lua_newtable(lua_state_);
+ lua_setglobal(lua_state_, "hooks");
}
LuaInterface::~LuaInterface() {
- lua_close(m_L);
+ lua_close(lua_state_);
}
void LuaInterface::interpret_string(const std::string& cmd) {
- int rv = luaL_dostring(m_L, cmd.c_str());
- check_return_value_for_errors(m_L, rv);
+ int rv = luaL_dostring(lua_state_, cmd.c_str());
+ check_return_value_for_errors(lua_state_, rv);
}
std::unique_ptr<LuaTable> LuaInterface::run_script(const std::string& path) {
- return ::run_script(m_L, path, g_fs);
+ return ::run_script(lua_state_, path, g_fs);
}
=== modified file 'src/scripting/lua_interface.h'
--- src/scripting/lua_interface.h 2015-01-31 16:03:59 +0000
+++ src/scripting/lua_interface.h 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2010 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -41,7 +41,7 @@
virtual std::unique_ptr<LuaTable> run_script(const std::string& script);
protected:
- lua_State* m_L;
+ lua_State* lua_state_;
};
#endif // end of include guard: WL_SCRIPTING_LUA_INTERFACE_H
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2016-02-11 06:50:56 +0000
+++ src/scripting/lua_map.cc 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2010, 2013 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -2509,7 +2509,7 @@
Game & game = get_game(L);
uint32_t idx = 0;
- if (MapObject* obj = m_ptr.get(game))
+ if (MapObject* obj = ptr_.get(game))
idx = mos.get_object_file_index(*obj);
PERS_UINT32("file_index", idx);
@@ -2519,10 +2519,10 @@
UNPERS_UINT32("file_index", idx);
if (!idx)
- m_ptr = nullptr;
+ ptr_ = nullptr;
else {
MapObjectLoader& mol = *get_mol(L);
- m_ptr = &mol.get<MapObject>(idx);
+ ptr_ = &mol.get<MapObject>(idx);
}
}
@@ -2679,7 +2679,7 @@
return o;
}
MapObject* LuaMapObject::m_get_or_zero(EditorGameBase& egbase) {
- return m_ptr.get(egbase);
+ return ptr_.get(egbase);
}
/* RST
@@ -4338,11 +4338,11 @@
void LuaField::__persist(lua_State * L) {
- PERS_INT32("x", m_c.x); PERS_INT32("y", m_c.y);
+ PERS_INT32("x", coords_.x); PERS_INT32("y", coords_.y);
}
void LuaField::__unpersist(lua_State * L) {
- UNPERS_INT32("x", m_c.x); UNPERS_INT32("y", m_c.y);
+ UNPERS_INT32("x", coords_.x); UNPERS_INT32("y", coords_.y);
}
/*
@@ -4352,7 +4352,7 @@
*/
// Hash is used to identify a class in a Set
int LuaField::get___hash(lua_State * L) {
- const std::string pushme = (boost::format("%i_%i") % m_c.x % m_c.y).str();
+ const std::string pushme = (boost::format("%i_%i") % coords_.x % coords_.y).str();
lua_pushstring(L, pushme.c_str());
return 1;
}
@@ -4362,8 +4362,8 @@
(RO) The x/y coordinate of this field
*/
-int LuaField::get_x(lua_State * L) {lua_pushuint32(L, m_c.x); return 1;}
-int LuaField::get_y(lua_State * L) {lua_pushuint32(L, m_c.y); return 1;}
+int LuaField::get_x(lua_State * L) {lua_pushuint32(L, coords_.x); return 1;}
+int LuaField::get_y(lua_State * L) {lua_pushuint32(L, coords_.y); return 1;}
/* RST
.. attribute:: height
@@ -4430,13 +4430,13 @@
*/
int LuaField::get_viewpoint_x(lua_State * L) {
int32_t px, py;
- MapviewPixelFunctions::get_save_pix(get_egbase(L).map(), m_c, px, py);
+ MapviewPixelFunctions::get_save_pix(get_egbase(L).map(), coords_, px, py);
lua_pushint32(L, px);
return 1;
}
int LuaField::get_viewpoint_y(lua_State * L) {
int32_t px, py;
- MapviewPixelFunctions::get_save_pix(get_egbase(L).map(), m_c, px, py);
+ MapviewPixelFunctions::get_save_pix(get_egbase(L).map(), coords_, px, py);
lua_pushint32(L, py);
return 1;
}
@@ -4524,7 +4524,7 @@
to remove an immovable, you can use :func:`wl.map.MapObject.remove`.
*/
int LuaField::get_immovable(lua_State * L) {
- BaseImmovable * bi = get_egbase(L).map().get_immovable(m_c);
+ BaseImmovable * bi = get_egbase(L).map().get_immovable(coords_);
if (!bi)
return 0;
@@ -4627,7 +4627,7 @@
*/
#define GET_X_NEIGHBOUR(X) int LuaField::get_ ##X(lua_State* L) { \
Coords n; \
- get_egbase(L).map().get_ ##X(m_c, &n); \
+ get_egbase(L).map().get_ ##X(coords_, &n); \
to_lua<LuaField>(L, new LuaField(n.x, n.y)); \
return 1; \
}
@@ -4673,7 +4673,7 @@
iterate_players_existing(other_p, map.get_nrplayers(), egbase, plr)
claimers.push_back
(PlrInfluence(plr->player_number(), plr->military_influence
- (map.get_index(m_c, map.get_width()))
+ (map.get_index(coords_, map.get_width()))
)
);
@@ -4700,12 +4700,12 @@
==========================================================
*/
int LuaField::__eq(lua_State * L) {
- lua_pushboolean(L, (*get_user_class<LuaField>(L, -1))->m_c == m_c);
+ lua_pushboolean(L, (*get_user_class<LuaField>(L, -1))->coords_ == coords_);
return 1;
}
int LuaField::__tostring(lua_State * L) {
- const std::string pushme = (boost::format("Field(%i,%i)") % m_c.x % m_c.y).str();
+ const std::string pushme = (boost::format("Field(%i,%i)") % coords_.x % coords_.y).str();
lua_pushstring(L, pushme);
return 1;
}
@@ -4820,7 +4820,7 @@
(lua_State * L, uint32_t radius, uint32_t inner_radius)
{
Map & map = get_egbase(L).map();
- HollowArea<Area<> > har(Area<>(m_c, radius), inner_radius);
+ HollowArea<Area<> > har(Area<>(coords_, radius), inner_radius);
MapHollowRegion<Area<> > mr(map, har);
@@ -4836,7 +4836,7 @@
}
const Widelands::FCoords LuaField::fcoords(lua_State * L) {
- return get_egbase(L).map().get_fcoords(m_c);
+ return get_egbase(L).map().get_fcoords(coords_);
}
@@ -4864,11 +4864,11 @@
};
void LuaPlayerSlot::__persist(lua_State * L) {
- PERS_UINT32("player", m_plr);
+ PERS_UINT32("player", player_number_);
}
void LuaPlayerSlot::__unpersist(lua_State * L) {
- UNPERS_UINT32("player", m_plr);
+ UNPERS_UINT32("player", player_number_);
}
/*
@@ -4882,7 +4882,7 @@
(RO) The name of the tribe suggested for this player in this map
*/
int LuaPlayerSlot::get_tribe_name(lua_State * L) {
- lua_pushstring(L, get_egbase(L).get_map()->get_scenario_player_tribe(m_plr));
+ lua_pushstring(L, get_egbase(L).get_map()->get_scenario_player_tribe(player_number_));
return 1;
}
@@ -4892,7 +4892,7 @@
(RO) The name for this player as suggested in this map
*/
int LuaPlayerSlot::get_name(lua_State * L) {
- lua_pushstring(L, get_egbase(L).get_map()->get_scenario_player_name(m_plr));
+ lua_pushstring(L, get_egbase(L).get_map()->get_scenario_player_name(player_number_));
return 1;
}
@@ -4905,7 +4905,7 @@
wherever it want. This field is only centered when the game starts.
*/
int LuaPlayerSlot::get_starting_field(lua_State * L) {
- to_lua<LuaField>(L, new LuaField(get_egbase(L).map().get_starting_pos(m_plr)));
+ to_lua<LuaField>(L, new LuaField(get_egbase(L).map().get_starting_pos(player_number_)));
return 1;
}
=== modified file 'src/scripting/lua_map.h'
--- src/scripting/lua_map.h 2016-01-22 19:53:32 +0000
+++ src/scripting/lua_map.h 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2010 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -522,20 +522,20 @@
}
class LuaMapObject : public LuaMapModuleClass {
- Widelands::ObjectPointer m_ptr;
+ Widelands::ObjectPointer ptr_;
public:
LUNA_CLASS_HEAD(LuaMapObject);
- LuaMapObject() : m_ptr(nullptr) {}
+ LuaMapObject() : ptr_(nullptr) {}
LuaMapObject(Widelands::MapObject & mo) {
- m_ptr = &mo;
+ ptr_ = &mo;
}
- LuaMapObject(lua_State * L) : m_ptr(nullptr) {
+ LuaMapObject(lua_State * L) : ptr_(nullptr) {
report_error(L, "Cannot instantiate a '%s' directly!", className);
}
virtual ~LuaMapObject() {
- m_ptr = nullptr;
+ ptr_ = nullptr;
}
void __persist(lua_State * L) override;
@@ -992,14 +992,14 @@
#undef CASTED_GET
class LuaField : public LuaMapModuleClass {
- Widelands::Coords m_c;
+ Widelands::Coords coords_;
public:
LUNA_CLASS_HEAD(LuaField);
LuaField() {}
LuaField (int16_t x, int16_t y) :
- m_c(Widelands::Coords(x, y)) {}
- LuaField (Widelands::Coords c) : m_c(c) {}
+ coords_(Widelands::Coords(x, y)) {}
+ LuaField (Widelands::Coords c) : coords_(c) {}
LuaField(lua_State * L) {
report_error(L, "Cannot instantiate a 'Field' directly!");
}
@@ -1051,7 +1051,7 @@
/*
* C methods
*/
- inline const Widelands::Coords & coords() {return m_c;}
+ inline const Widelands::Coords & coords() {return coords_;}
const Widelands::FCoords fcoords(lua_State * L);
private:
@@ -1060,14 +1060,14 @@
};
class LuaPlayerSlot : public LuaMapModuleClass {
- Widelands::PlayerNumber m_plr;
+ Widelands::PlayerNumber player_number_;
public:
LUNA_CLASS_HEAD(LuaPlayerSlot);
- LuaPlayerSlot() : m_plr(0) {}
- LuaPlayerSlot(Widelands::PlayerNumber plr) : m_plr(plr) {}
- LuaPlayerSlot(lua_State * L) : m_plr(0) {
+ LuaPlayerSlot() : player_number_(0) {}
+ LuaPlayerSlot(Widelands::PlayerNumber plr) : player_number_(plr) {}
+ LuaPlayerSlot(lua_State * L) : player_number_(0) {
report_error(L, "Cannot instantiate a 'PlayerSlot' directly!");
}
virtual ~LuaPlayerSlot() {}
=== modified file 'src/scripting/lua_ui.cc'
--- src/scripting/lua_ui.cc 2015-08-06 17:14:34 +0000
+++ src/scripting/lua_ui.cc 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2011 by the Widelands Development Team
+ * Copyright (C) 2006-20116 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -122,10 +122,10 @@
}
}
int LuaPanel::get_buttons(lua_State * L) {
- assert(m_panel);
+ assert(panel_);
lua_newtable(L);
- _put_all_visible_buttons_into_table(L, m_panel);
+ _put_all_visible_buttons_into_table(L, panel_);
return 1;
}
@@ -153,10 +153,10 @@
}
}
int LuaPanel::get_tabs(lua_State * L) {
- assert(m_panel);
+ assert(panel_);
lua_newtable(L);
- _put_all_tabs_into_table(L, m_panel);
+ _put_all_tabs_into_table(L, panel_);
return 1;
}
@@ -185,10 +185,10 @@
}
}
int LuaPanel::get_windows(lua_State * L) {
- assert(m_panel);
+ assert(panel_);
lua_newtable(L);
- _put_all_visible_windows_into_table(L, m_panel);
+ _put_all_visible_windows_into_table(L, panel_);
return 1;
}
@@ -199,27 +199,27 @@
(RW) The current mouse position relative to this Panels position
*/
int LuaPanel::get_mouse_position_x(lua_State * L) {
- assert(m_panel);
- lua_pushint32(L, m_panel->get_mouse_position().x);
+ assert(panel_);
+ lua_pushint32(L, panel_->get_mouse_position().x);
return 1;
}
int LuaPanel::set_mouse_position_x(lua_State * L) {
- assert(m_panel);
- Point p = m_panel->get_mouse_position();
+ assert(panel_);
+ Point p = panel_->get_mouse_position();
p.x = luaL_checkint32(L, -1);
- m_panel->set_mouse_pos(p);
+ panel_->set_mouse_pos(p);
return 1;
}
int LuaPanel::get_mouse_position_y(lua_State * L) {
- assert(m_panel);
- lua_pushint32(L, m_panel->get_mouse_position().y);
+ assert(panel_);
+ lua_pushint32(L, panel_->get_mouse_position().y);
return 1;
}
int LuaPanel::set_mouse_position_y(lua_State * L) {
- assert(m_panel);
- Point p = m_panel->get_mouse_position();
+ assert(panel_);
+ Point p = panel_->get_mouse_position();
p.y = luaL_checkint32(L, -1);
- m_panel->set_mouse_pos(p);
+ panel_->set_mouse_pos(p);
return 1;
}
@@ -229,23 +229,23 @@
(RW) The dimensions of this panel in pixels
*/
int LuaPanel::get_width(lua_State * L) {
- assert(m_panel);
- lua_pushint32(L, m_panel->get_w());
+ assert(panel_);
+ lua_pushint32(L, panel_->get_w());
return 1;
}
int LuaPanel::set_width(lua_State * L) {
- assert(m_panel);
- m_panel->set_size(luaL_checkint32(L, -1), m_panel->get_h());
+ assert(panel_);
+ panel_->set_size(luaL_checkint32(L, -1), panel_->get_h());
return 1;
}
int LuaPanel::get_height(lua_State * L) {
- assert(m_panel);
- lua_pushint32(L, m_panel->get_h());
+ assert(panel_);
+ lua_pushint32(L, panel_->get_h());
return 1;
}
int LuaPanel::set_height(lua_State * L) {
- assert(m_panel);
- m_panel->set_size(m_panel->get_w(), luaL_checkint32(L, -1));
+ assert(panel_);
+ panel_->set_size(panel_->get_w(), luaL_checkint32(L, -1));
return 1;
}
@@ -256,29 +256,29 @@
parent's element inner canvas.
*/
int LuaPanel::get_position_x(lua_State * L) {
- assert(m_panel);
- Point p = m_panel->to_parent(Point(0, 0));
+ assert(panel_);
+ Point p = panel_->to_parent(Point(0, 0));
lua_pushint32(L, p.x);
return 1;
}
int LuaPanel::set_position_x(lua_State * L) {
- assert(m_panel);
- Point p(luaL_checkint32(L, -1) - m_panel->get_lborder(), m_panel->get_y());
- m_panel->set_pos(p);
+ assert(panel_);
+ Point p(luaL_checkint32(L, -1) - panel_->get_lborder(), panel_->get_y());
+ panel_->set_pos(p);
return 1;
}
int LuaPanel::get_position_y(lua_State * L) {
- assert(m_panel);
- Point p = m_panel->to_parent(Point(0, 0));
+ assert(panel_);
+ Point p = panel_->to_parent(Point(0, 0));
lua_pushint32(L, p.y);
return 1;
}
int LuaPanel::set_position_y(lua_State * L) {
- assert(m_panel);
- Point p(m_panel->get_x(), luaL_checkint32(L, -1) - m_panel->get_tborder());
- m_panel->set_pos(p);
+ assert(panel_);
+ Point p(panel_->get_x(), luaL_checkint32(L, -1) - panel_->get_tborder());
+ panel_->set_pos(p);
return 1;
}
@@ -298,12 +298,12 @@
:rtype: both are :class:`integers`
*/
int LuaPanel::get_descendant_position(lua_State * L) {
- assert(m_panel);
+ assert(panel_);
- UI::Panel * cur = (*get_base_user_class<LuaPanel>(L, 2))->m_panel;
+ UI::Panel * cur = (*get_base_user_class<LuaPanel>(L, 2))->panel_;
Point cp = Point(0, 0);
- while (cur && cur != m_panel) {
+ while (cur && cur != panel_) {
cp += cur->to_parent(Point(0, 0));
cur = cur->get_parent();
}
@@ -482,8 +482,8 @@
not use it any longer.
*/
int LuaWindow::close(lua_State * /* L */) {
- delete m_panel;
- m_panel = nullptr;
+ delete panel_;
+ panel_ = nullptr;
return 0;
}
@@ -526,7 +526,7 @@
void LuaMapView::__unpersist(lua_State* L)
{
Widelands::Game & game = get_game(L);
- m_panel = game.get_ibase();
+ panel_ = game.get_ibase();
}
=== modified file 'src/scripting/lua_ui.h'
--- src/scripting/lua_ui.h 2015-01-31 16:03:59 +0000
+++ src/scripting/lua_ui.h 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2010 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -40,14 +40,14 @@
class LuaPanel : public LuaUiModuleClass {
protected:
- UI::Panel * m_panel;
+ UI::Panel * panel_;
public:
LUNA_CLASS_HEAD(LuaPanel);
- LuaPanel() : m_panel(nullptr) {}
- LuaPanel(UI::Panel * p) : m_panel(p) {}
- LuaPanel(lua_State * L) : m_panel(nullptr) {
+ LuaPanel() : panel_(nullptr) {}
+ LuaPanel(UI::Panel * p) : panel_(p) {}
+ LuaPanel(lua_State * L) : panel_(nullptr) {
report_error(L, "Cannot instantiate a '%s' directly!", className);
}
virtual ~LuaPanel() {}
@@ -114,7 +114,7 @@
/*
* C Methods
*/
- UI::Button * get() {return static_cast<UI::Button *>(m_panel);}
+ UI::Button * get() {return static_cast<UI::Button *>(panel_);}
};
class LuaTab : public LuaPanel {
@@ -140,7 +140,7 @@
/*
* C Methods
*/
- UI::Tab * get() {return static_cast<UI::Tab *>(m_panel);}
+ UI::Tab * get() {return static_cast<UI::Tab *>(panel_);}
};
class LuaWindow : public LuaPanel {
@@ -165,7 +165,7 @@
/*
* C Methods
*/
- UI::Window * get() {return static_cast<UI::Window *>(m_panel);}
+ UI::Window * get() {return static_cast<UI::Window *>(panel_);}
};
@@ -207,7 +207,7 @@
/*
* C Methods
*/
- InteractiveBase * get() {return static_cast<InteractiveBase *>(m_panel);}
+ InteractiveBase * get() {return static_cast<InteractiveBase *>(panel_);}
};
void luaopen_wlui(lua_State *);
=== modified file 'src/scripting/luna.h'
--- src/scripting/luna.h 2015-04-18 11:20:53 +0000
+++ src/scripting/luna.h 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2010 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
=== modified file 'src/scripting/luna_impl.h'
--- src/scripting/luna_impl.h 2015-01-31 16:03:59 +0000
+++ src/scripting/luna_impl.h 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2010 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
=== modified file 'src/sound/songset.h'
--- src/sound/songset.h 2014-07-05 16:41:51 +0000
+++ src/sound/songset.h 2016-02-12 17:03:35 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 by the Widelands Development Team
+ * Copyright (C) 2006-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -35,7 +35,7 @@
* music, e.g. all songs that might be played while the main menu is being
* shown. It is possible to access those songs one after another or in
* random order. The fact that a Songset really contains several different
- * songs is hidden from the outside.\n
+ * songs is hidden from the outside.
* A songset does not contain the audio data itself, to not use huge amounts of
* memory. Instead, each song is loaded on request and the data is free()d
* afterwards
Follow ups