Merge lp:~widelands-dev/widelands/bug-1395278-scripting into lp:widelands

Proposed by Klaus Halfmann
Status: Merged
Merged at revision: 7819
Proposed branch: lp:~widelands-dev/widelands/bug-1395278-scripting
Merge into: lp:widelands
Diff against target: 1396 lines (+269/-269)
18 files modified
src/scripting/logic.cc (+61/-61)
src/scripting/logic.h (+3/-3)
src/scripting/lua.h (+1/-1)
src/scripting/lua_bases.cc (+9/-9)
src/scripting/lua_bases.h (+6/-6)
src/scripting/lua_coroutine.cc (+41/-41)
src/scripting/lua_coroutine.h (+6/-6)
src/scripting/lua_game.cc (+22/-22)
src/scripting/lua_game.h (+6/-6)
src/scripting/lua_interface.cc (+20/-20)
src/scripting/lua_interface.h (+2/-2)
src/scripting/lua_map.cc (+24/-24)
src/scripting/lua_map.h (+14/-14)
src/scripting/lua_ui.cc (+41/-41)
src/scripting/lua_ui.h (+9/-9)
src/scripting/luna.h (+1/-1)
src/scripting/luna_impl.h (+1/-1)
src/sound/songset.h (+2/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1395278-scripting
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+285909@code.launchpad.net

Description of the change

* 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.

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

Code LGTM, but I have added some comments. Please have a look :)

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Hello GunChleoc, I cared for the copyright.

For the type of the player_num / player_index we shoud use the type you suggested, of course.
But this is
a) out of scope of the original bug.
b) I have no Idea what, especially in LUA, might break.-

We should delegate this to some other ticket.

BTW: Who ist the master of LUA in widelands.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 673. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/108855068.
Appveyor build 525. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1395278_scripting-525.

Revision history for this message
GunChleoc (gunchleoc) wrote :

SirVer is out master of everything, but I have worked a bit on Lua and saveloading as well, so I think this change should be fine. I have opened a new bug.

@bunnybot merge

Revision history for this message
GunChleoc (gunchleoc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/scripting/logic.cc'
2--- src/scripting/logic.cc 2015-01-31 16:03:59 +0000
3+++ src/scripting/logic.cc 2016-02-12 18:18:22 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright (C) 2006-2015 by the Widelands Development Team
7+ * Copyright (C) 2006-2016 by the Widelands Development Team
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11@@ -63,22 +63,22 @@
12 } // namespace
13
14 LuaEditorInterface::LuaEditorInterface(Widelands::EditorGameBase* g)
15- : m_factory(new EditorFactory())
16+ : factory_(new EditorFactory())
17 {
18- setup_for_editor_and_game(m_L, g);
19- LuaRoot::luaopen_wlroot(m_L, true);
20- LuaEditor::luaopen_wleditor(m_L);
21+ setup_for_editor_and_game(lua_state_, g);
22+ LuaRoot::luaopen_wlroot(lua_state_, true);
23+ LuaEditor::luaopen_wleditor(lua_state_);
24
25 // Push the factory class into the registry
26- lua_pushlightuserdata(m_L, reinterpret_cast<void*>(dynamic_cast<Factory*>(m_factory.get())));
27- lua_setfield(m_L, LUA_REGISTRYINDEX, "factory");
28+ lua_pushlightuserdata(lua_state_, reinterpret_cast<void*>(dynamic_cast<Factory*>(factory_.get())));
29+ lua_setfield(lua_state_, LUA_REGISTRYINDEX, "factory");
30 }
31
32 LuaEditorInterface::~LuaEditorInterface() {
33 }
34
35 std::unique_ptr<LuaTable> LuaEditorInterface::run_script(const std::string& script) {
36- return run_script_maybe_from_map(m_L, script);
37+ return run_script_maybe_from_map(lua_state_, script);
38 }
39
40 // Special handling of math.random.
41@@ -125,27 +125,27 @@
42 }
43
44 LuaGameInterface::LuaGameInterface(Widelands::Game * g)
45- : m_factory(new GameFactory())
46+ : factory_(new GameFactory())
47 {
48- setup_for_editor_and_game(m_L, g);
49+ setup_for_editor_and_game(lua_state_, g);
50
51 // Overwrite math.random
52- lua_getglobal(m_L, "math");
53- lua_pushcfunction(m_L, L_math_random);
54- lua_setfield(m_L, -2, "random");
55- lua_pop(m_L, 1); // pop "math"
56+ lua_getglobal(lua_state_, "math");
57+ lua_pushcfunction(lua_state_, L_math_random);
58+ lua_setfield(lua_state_, -2, "random");
59+ lua_pop(lua_state_, 1); // pop "math"
60
61- LuaRoot::luaopen_wlroot(m_L, false);
62- LuaGame::luaopen_wlgame(m_L);
63+ LuaRoot::luaopen_wlroot(lua_state_, false);
64+ LuaGame::luaopen_wlgame(lua_state_);
65
66 // Push the game into the registry
67- lua_pushlightuserdata(m_L, static_cast<void *>(g));
68- lua_setfield(m_L, LUA_REGISTRYINDEX, "game");
69+ lua_pushlightuserdata(lua_state_, static_cast<void *>(g));
70+ lua_setfield(lua_state_, LUA_REGISTRYINDEX, "game");
71
72 // Push the factory class into the registry
73 lua_pushlightuserdata
74- (m_L, reinterpret_cast<void *>(dynamic_cast<Factory *>(m_factory.get())));
75- lua_setfield(m_L, LUA_REGISTRYINDEX, "factory");
76+ (lua_state_, reinterpret_cast<void *>(dynamic_cast<Factory *>(factory_.get())));
77+ lua_setfield(lua_state_, LUA_REGISTRYINDEX, "factory");
78 }
79
80 LuaGameInterface::~LuaGameInterface() {
81@@ -153,7 +153,7 @@
82
83 LuaCoroutine* LuaGameInterface::read_coroutine(FileRead& fr) {
84 LuaCoroutine * rv = new LuaCoroutine(nullptr);
85- rv->read(m_L, fr);
86+ rv->read(lua_state_, fr);
87 return rv;
88 }
89
90@@ -167,77 +167,77 @@
91 uint32_t size)
92 {
93 // Clean out the garbage before loading.
94- lua_gc(m_L, LUA_GCCOLLECT, 0);
95+ lua_gc(lua_state_, LUA_GCCOLLECT, 0);
96
97- assert(lua_gettop(m_L) == 0); // S:
98- unpersist_object(m_L, fr, mol, size);
99- assert(lua_gettop(m_L) == 1); // S: unpersisted_object
100- luaL_checktype(m_L, -1, LUA_TTABLE);
101+ assert(lua_gettop(lua_state_) == 0); // S:
102+ unpersist_object(lua_state_, fr, mol, size);
103+ assert(lua_gettop(lua_state_) == 1); // S: unpersisted_object
104+ luaL_checktype(lua_state_, -1, LUA_TTABLE);
105
106 // Now, we have to merge all keys from the loaded table
107 // into the global table
108- lua_pushnil(m_L); // S: table nil
109- while (lua_next(m_L, 1) != 0) {
110+ lua_pushnil(lua_state_); // S: table nil
111+ while (lua_next(lua_state_, 1) != 0) {
112 // S: table key value
113- lua_rawgeti(m_L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); // S: table key value globals_table
114- lua_pushvalue(m_L, -3); // S: table key value globals_table key
115- lua_gettable(m_L, -2); // S: table key value globals_table value_in_globals
116- if (lua_compare(m_L, -1, -3, LUA_OPEQ)) {
117- lua_pop(m_L, 3); // S: table key
118+ lua_rawgeti(lua_state_, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); // S: table key value globals_table
119+ lua_pushvalue(lua_state_, -3); // S: table key value globals_table key
120+ lua_gettable(lua_state_, -2); // S: table key value globals_table value_in_globals
121+ if (lua_compare(lua_state_, -1, -3, LUA_OPEQ)) {
122+ lua_pop(lua_state_, 3); // S: table key
123 continue;
124 } else {
125 // Make this a global value
126- lua_pop(m_L, 1); // S: table key value globals_table
127- lua_pushvalue(m_L, -3); // S: table key value globals_table key
128- lua_pushvalue(m_L, -3); // S: table key value globals_table key value
129- lua_settable(m_L, -3); // S: table key value globals_table
130- lua_pop(m_L, 2); // S: table key
131+ lua_pop(lua_state_, 1); // S: table key value globals_table
132+ lua_pushvalue(lua_state_, -3); // S: table key value globals_table key
133+ lua_pushvalue(lua_state_, -3); // S: table key value globals_table key value
134+ lua_settable(lua_state_, -3); // S: table key value globals_table
135+ lua_pop(lua_state_, 2); // S: table key
136 }
137 }
138
139- lua_pop(m_L, 1); // pop the table returned by unpersist_object
140+ lua_pop(lua_state_, 1); // pop the table returned by unpersist_object
141
142 // Clean out the garbage before returning.
143- lua_gc(m_L, LUA_GCCOLLECT, 0);
144+ lua_gc(lua_state_, LUA_GCCOLLECT, 0);
145 }
146
147 uint32_t LuaGameInterface::write_global_env
148 (FileWrite & fw, Widelands::MapObjectSaver & mos)
149 {
150 // Clean out the garbage before writing.
151- lua_gc(m_L, LUA_GCCOLLECT, 0);
152+ lua_gc(lua_state_, LUA_GCCOLLECT, 0);
153
154 // Empty table + object to persist on the stack Stack
155- lua_newtable(m_L);
156- lua_rawgeti(m_L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS);
157+ lua_newtable(lua_state_);
158+ lua_rawgeti(lua_state_, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS);
159
160- uint32_t nwritten = persist_object(m_L, fw, mos);
161+ uint32_t nwritten = persist_object(lua_state_, fw, mos);
162
163 // Garbage collect once more, so we do not return unnecessary stuff.
164- lua_gc(m_L, LUA_GCCOLLECT, 0);
165+ lua_gc(lua_state_, LUA_GCCOLLECT, 0);
166
167 return nwritten;
168 }
169
170 std::unique_ptr<LuaTable> LuaGameInterface::get_hook(const std::string& name) {
171- lua_getglobal(m_L, "hooks");
172- if (lua_isnil(m_L, -1)) {
173- lua_pop(m_L, 1);
174- return std::unique_ptr<LuaTable>();
175- }
176-
177- lua_getfield(m_L, -1, name.c_str());
178- if (lua_isnil(m_L, -1)) {
179- lua_pop(m_L, 2);
180- return std::unique_ptr<LuaTable>();
181- }
182- lua_remove(m_L, -2);
183-
184- std::unique_ptr<LuaTable> return_value(new LuaTable(m_L));
185- lua_pop(m_L, 1);
186+ lua_getglobal(lua_state_, "hooks");
187+ if (lua_isnil(lua_state_, -1)) {
188+ lua_pop(lua_state_, 1);
189+ return std::unique_ptr<LuaTable>();
190+ }
191+
192+ lua_getfield(lua_state_, -1, name.c_str());
193+ if (lua_isnil(lua_state_, -1)) {
194+ lua_pop(lua_state_, 2);
195+ return std::unique_ptr<LuaTable>();
196+ }
197+ lua_remove(lua_state_, -2);
198+
199+ std::unique_ptr<LuaTable> return_value(new LuaTable(lua_state_));
200+ lua_pop(lua_state_, 1);
201 return return_value;
202 }
203
204 std::unique_ptr<LuaTable> LuaGameInterface::run_script(const std::string& script) {
205- return run_script_maybe_from_map(m_L, script);
206+ return run_script_maybe_from_map(lua_state_, script);
207 }
208
209=== modified file 'src/scripting/logic.h'
210--- src/scripting/logic.h 2015-01-31 16:03:59 +0000
211+++ src/scripting/logic.h 2016-02-12 18:18:22 +0000
212@@ -1,5 +1,5 @@
213 /*
214- * Copyright (C) 2006-2015 by the Widelands Development Team
215+ * Copyright (C) 2006-2016 by the Widelands Development Team
216 *
217 * This program is free software; you can redistribute it and/or
218 * modify it under the terms of the GNU General Public License
219@@ -37,7 +37,7 @@
220 std::unique_ptr<LuaTable> run_script(const std::string& script) override;
221
222 private:
223- std::unique_ptr<EditorFactory> m_factory;
224+ std::unique_ptr<EditorFactory> factory_;
225 };
226
227 class LuaGameInterface : public LuaInterface {
228@@ -61,7 +61,7 @@
229 (FileWrite &, Widelands::MapObjectSaver &);
230
231 private:
232- std::unique_ptr<GameFactory> m_factory;
233+ std::unique_ptr<GameFactory> factory_;
234 };
235
236 #endif // end of include guard: WL_SCRIPTING_LOGIC_H
237
238=== modified file 'src/scripting/lua.h'
239--- src/scripting/lua.h 2015-01-31 16:03:59 +0000
240+++ src/scripting/lua.h 2016-02-12 18:18:22 +0000
241@@ -1,5 +1,5 @@
242 /*
243- * Copyright (C) 2006-2015 by the Widelands Development Team
244+ * Copyright (C) 2006-2016 by the Widelands Development Team
245 *
246 * This program is free software; you can redistribute it and/or
247 * modify it under the terms of the GNU General Public License
248
249=== modified file 'src/scripting/lua_bases.cc'
250--- src/scripting/lua_bases.cc 2015-11-28 22:29:26 +0000
251+++ src/scripting/lua_bases.cc 2016-02-12 18:18:22 +0000
252@@ -1,5 +1,5 @@
253 /*
254- * Copyright (C) 2006-2010 by the Widelands Development Team
255+ * Copyright (C) 2006-2016 by the Widelands Development Team
256 *
257 * This program is free software; you can redistribute it and/or
258 * modify it under the terms of the GNU General Public License
259@@ -280,10 +280,10 @@
260 };
261
262 void LuaPlayerBase::__persist(lua_State * L) {
263- PERS_UINT32("player", m_pl);
264+ PERS_UINT32("player", player_number_);
265 }
266 void LuaPlayerBase::__unpersist(lua_State * L) {
267- UNPERS_UINT32("player", m_pl);
268+ UNPERS_UINT32("player", player_number_);
269 }
270
271 /*
272@@ -297,7 +297,7 @@
273 (RO) The number of this Player.
274 */
275 int LuaPlayerBase::get_number(lua_State * L) {
276- lua_pushuint32(L, m_pl);
277+ lua_pushuint32(L, player_number_);
278 return 1;
279 }
280
281@@ -578,7 +578,7 @@
282
283 get_egbase(L).conquer_area_no_building
284 (PlayerArea<Area<FCoords> >
285- (m_pl, Area<FCoords>
286+ (player_number_, Area<FCoords>
287 ((*get_user_class<LuaMaps::LuaField>(L, 2))->fcoords(L), radius))
288 );
289 return 0;
290@@ -643,11 +643,11 @@
291 Player & LuaPlayerBase::get
292 (lua_State * L, Widelands::EditorGameBase & egbase)
293 {
294- if (m_pl > MAX_PLAYERS)
295- report_error(L, "Illegal player number %i", m_pl);
296- Player * rv = egbase.get_player(m_pl);
297+ if (player_number_ > MAX_PLAYERS)
298+ report_error(L, "Illegal player number %i", player_number_);
299+ Player * rv = egbase.get_player(player_number_);
300 if (!rv)
301- report_error(L, "Player with the number %i does not exist", m_pl);
302+ report_error(L, "Player with the number %i does not exist", player_number_);
303 return *rv;
304 }
305
306
307=== modified file 'src/scripting/lua_bases.h'
308--- src/scripting/lua_bases.h 2015-04-11 08:58:15 +0000
309+++ src/scripting/lua_bases.h 2016-02-12 18:18:22 +0000
310@@ -1,5 +1,5 @@
311 /*
312- * Copyright (C) 2006-2010 by the Widelands Development Team
313+ * Copyright (C) 2006-2016 by the Widelands Development Team
314 *
315 * This program is free software; you can redistribute it and/or
316 * modify it under the terms of the GNU General Public License
317@@ -70,19 +70,19 @@
318
319
320 class LuaPlayerBase : public LuaBasesModuleClass {
321- Widelands::PlayerNumber m_pl;
322+ Widelands::PlayerNumber player_number_;
323 enum {NONE = -1};
324
325 public:
326 LUNA_CLASS_HEAD(LuaPlayerBase);
327
328
329- LuaPlayerBase() : m_pl(NONE) {}
330- LuaPlayerBase (lua_State * L) : m_pl(NONE) {
331+ LuaPlayerBase() : player_number_(NONE) {}
332+ LuaPlayerBase (lua_State * L) : player_number_(NONE) {
333 report_error(L, "Cannot instantiate a 'PlayerBase' directly!");
334 }
335 LuaPlayerBase(Widelands::PlayerNumber n) {
336- m_pl = n;
337+ player_number_ = n;
338 }
339 virtual ~LuaPlayerBase() {}
340
341@@ -114,7 +114,7 @@
342 Widelands::Player& get(lua_State* L, Widelands::EditorGameBase&);
343
344 protected:
345- inline Widelands::PlayerNumber player_number() {return m_pl;}
346+ inline Widelands::PlayerNumber player_number() {return player_number_;}
347 };
348
349 void luaopen_wlbases(lua_State *);
350
351=== modified file 'src/scripting/lua_coroutine.cc'
352--- src/scripting/lua_coroutine.cc 2015-10-18 20:23:10 +0000
353+++ src/scripting/lua_coroutine.cc 2016-02-12 18:18:22 +0000
354@@ -1,5 +1,5 @@
355 /*
356- * Copyright (C) 2006-2015 by the Widelands Development Team
357+ * Copyright (C) 2006-2016 by the Widelands Development Team
358 *
359 * This program is free software; you can redistribute it and/or
360 * modify it under the terms of the GNU General Public License
361@@ -60,92 +60,92 @@
362 } // namespace
363
364 LuaCoroutine::LuaCoroutine(lua_State * ms)
365- : m_L(ms), m_idx(LUA_REFNIL), m_ninput_args(0), m_nreturn_values(0)
366+ : lua_state_(ms), idx_(LUA_REFNIL), ninput_args_(0), nreturn_values_(0)
367 {
368- if (m_L) {
369- m_idx = reference_coroutine(m_L);
370+ if (lua_state_) {
371+ idx_ = reference_coroutine(lua_state_);
372 }
373 }
374
375 LuaCoroutine::~LuaCoroutine() {
376- unreference_coroutine(m_L, m_idx);
377+ unreference_coroutine(lua_state_, idx_);
378 }
379
380 int LuaCoroutine::get_status() {
381- return lua_status(m_L);
382+ return lua_status(lua_state_);
383 }
384
385 int LuaCoroutine::resume()
386 {
387- int rv = lua_resume(m_L, nullptr, m_ninput_args);
388- m_ninput_args = 0;
389- m_nreturn_values = lua_gettop(m_L);
390+ int rv = lua_resume(lua_state_, nullptr, ninput_args_);
391+ ninput_args_ = 0;
392+ nreturn_values_ = lua_gettop(lua_state_);
393
394 if (rv != 0 && rv != YIELDED) {
395- throw LuaError(lua_tostring(m_L, -1));
396+ throw LuaError(lua_tostring(lua_state_, -1));
397 }
398
399 return rv;
400 }
401
402 void LuaCoroutine::push_arg(const Widelands::Player * plr) {
403- to_lua<LuaGame::LuaPlayer>(m_L, new LuaGame::LuaPlayer(plr->player_number()));
404- m_ninput_args++;
405+ to_lua<LuaGame::LuaPlayer>(lua_state_, new LuaGame::LuaPlayer(plr->player_number()));
406+ ninput_args_++;
407 }
408
409 void LuaCoroutine::push_arg(const Widelands::Coords & coords) {
410- to_lua<LuaMaps::LuaField>(m_L, new LuaMaps::LuaField(coords));
411- ++m_nargs;
412- ++m_ninput_args;
413+ to_lua<LuaMaps::LuaField>(lua_state_, new LuaMaps::LuaField(coords));
414+ ++nargs_;
415+ ++ninput_args_;
416 }
417
418 void LuaCoroutine::push_arg(const Widelands::BuildingDescr* building_descr) {
419 assert(building_descr != nullptr);
420- to_lua<LuaMaps::LuaBuildingDescription>(m_L, new LuaMaps::LuaBuildingDescription(building_descr));
421- ++m_ninput_args;
422+ to_lua<LuaMaps::LuaBuildingDescription>(lua_state_, new LuaMaps::LuaBuildingDescription(building_descr));
423+ ++ninput_args_;
424 }
425
426 void LuaCoroutine::push_arg(const Widelands::WareDescr* ware_descr) {
427 assert(ware_descr != nullptr);
428- to_lua<LuaMaps::LuaWareDescription>(m_L, new LuaMaps::LuaWareDescription(ware_descr));
429- ++m_ninput_args;
430+ to_lua<LuaMaps::LuaWareDescription>(lua_state_, new LuaMaps::LuaWareDescription(ware_descr));
431+ ++ninput_args_;
432 }
433
434 void LuaCoroutine::push_arg(const Widelands::WorkerDescr* worker_descr) {
435 assert(worker_descr != nullptr);
436- to_lua<LuaMaps::LuaWorkerDescription>(m_L, new LuaMaps::LuaWorkerDescription(worker_descr));
437- ++m_ninput_args;
438+ to_lua<LuaMaps::LuaWorkerDescription>(lua_state_, new LuaMaps::LuaWorkerDescription(worker_descr));
439+ ++ninput_args_;
440 }
441
442 void LuaCoroutine::push_arg(const std::string& string) {
443 assert(!string.empty());
444- lua_pushstring(m_L, string);
445- ++m_ninput_args;
446+ lua_pushstring(lua_state_, string);
447+ ++ninput_args_;
448 }
449
450 std::string LuaCoroutine::pop_string() {
451- if (!m_nreturn_values) {
452+ if (!nreturn_values_) {
453 return "";
454 }
455- if (!lua_isstring(m_L, -1)) {
456+ if (!lua_isstring(lua_state_, -1)) {
457 throw LuaError("pop_string(), but no string on the stack.");
458 }
459- const std::string return_value = lua_tostring(m_L, -1);
460- lua_pop(m_L, 1);
461- --m_nreturn_values;
462+ const std::string return_value = lua_tostring(lua_state_, -1);
463+ lua_pop(lua_state_, 1);
464+ --nreturn_values_;
465 return return_value;
466 }
467
468 uint32_t LuaCoroutine::pop_uint32() {
469- if (!m_nreturn_values) {
470+ if (!nreturn_values_) {
471 return 0;
472 }
473- if (!lua_isnumber(m_L, -1)) {
474+ if (!lua_isnumber(lua_state_, -1)) {
475 throw LuaError("pop_uint32(), but no integer on the stack.");
476 }
477- const uint32_t return_value = luaL_checkuint32(m_L, -1);
478- lua_pop(m_L, 1);
479- --m_nreturn_values;
480+ const uint32_t return_value = luaL_checkuint32(lua_state_, -1);
481+ lua_pop(lua_state_, 1);
482+ --nreturn_values_;
483 return return_value;
484 }
485
486@@ -153,9 +153,9 @@
487 void LuaCoroutine::write(FileWrite& fw) {
488 fw.unsigned_8(kCoroutineDataPacketVersion);
489
490- fw.unsigned_32(m_ninput_args);
491- fw.unsigned_32(m_nreturn_values);
492- fw.unsigned_32(m_idx);
493+ fw.unsigned_32(ninput_args_);
494+ fw.unsigned_32(nreturn_values_);
495+ fw.unsigned_32(idx_);
496 }
497
498 void LuaCoroutine::read(lua_State* parent, FileRead& fr) {
499@@ -164,12 +164,12 @@
500 if (version != kCoroutineDataPacketVersion)
501 throw wexception("Unhandled data packet version: %i\n", version);
502
503- m_ninput_args = fr.unsigned_32();
504- m_nreturn_values = fr.unsigned_32();
505- m_idx = fr.unsigned_32();
506+ ninput_args_ = fr.unsigned_32();
507+ nreturn_values_ = fr.unsigned_32();
508+ idx_ = fr.unsigned_32();
509
510 lua_getglobal(parent, kReferenceTableName);
511- lua_rawgeti(parent, -1, m_idx);
512- m_L = luaL_checkthread(parent, -1);
513+ lua_rawgeti(parent, -1, idx_);
514+ lua_state_ = luaL_checkthread(parent, -1);
515 lua_pop(parent, 2);
516 }
517
518=== modified file 'src/scripting/lua_coroutine.h'
519--- src/scripting/lua_coroutine.h 2015-10-17 11:01:14 +0000
520+++ src/scripting/lua_coroutine.h 2016-02-12 18:18:22 +0000
521@@ -1,5 +1,5 @@
522 /*
523- * Copyright (C) 2006-2015 by the Widelands Development Team
524+ * Copyright (C) 2006-2016 by the Widelands Development Team
525 *
526 * This program is free software; you can redistribute it and/or
527 * modify it under the terms of the GNU General Public License
528@@ -79,11 +79,11 @@
529 void write(FileWrite&);
530 void read(lua_State*, FileRead&);
531
532- lua_State* m_L;
533- uint32_t m_idx;
534- uint32_t m_nargs;
535- uint32_t m_ninput_args;
536- uint32_t m_nreturn_values;
537+ lua_State* lua_state_;
538+ uint32_t idx_;
539+ uint32_t nargs_;
540+ uint32_t ninput_args_;
541+ uint32_t nreturn_values_;
542 };
543
544 #endif // end of include guard: WL_SCRIPTING_LUA_COROUTINE_H
545
546=== modified file 'src/scripting/lua_game.cc'
547--- src/scripting/lua_game.cc 2016-01-28 05:24:34 +0000
548+++ src/scripting/lua_game.cc 2016-02-12 18:18:22 +0000
549@@ -1,5 +1,5 @@
550 /*
551- * Copyright (C) 2006-2010 by the Widelands Development Team
552+ * Copyright (C) 2006-2016 by the Widelands Development Team
553 *
554 * This program is free software; you can redistribute it and/or
555 * modify it under the terms of the GNU General Public License
556@@ -958,14 +958,14 @@
557 };
558
559 LuaObjective::LuaObjective(const Widelands::Objective& o) {
560- m_name = o.name();
561+ name_ = o.name();
562 }
563
564 void LuaObjective::__persist(lua_State * L) {
565- PERS_STRING("name", m_name);
566+ PERS_STRING("name", name_);
567 }
568 void LuaObjective::__unpersist(lua_State * L) {
569- UNPERS_STRING("name", m_name);
570+ UNPERS_STRING("name", name_);
571 }
572
573
574@@ -1075,16 +1075,16 @@
575 Game & g = get_game(L);
576 // The next call checks if the Objective still exists
577 get(L, g);
578- g.map().mutable_objectives()->erase(m_name);
579+ g.map().mutable_objectives()->erase(name_);
580 return 0;
581 }
582
583 int LuaObjective::__eq(lua_State * L) {
584 const Map::Objectives& objectives = get_game(L).map().objectives();
585
586- const Map::Objectives::const_iterator me = objectives.find(m_name);
587+ const Map::Objectives::const_iterator me = objectives.find(name_);
588 const Map::Objectives::const_iterator other =
589- objectives.find((*get_user_class<LuaObjective>(L, 2))->m_name);
590+ objectives.find((*get_user_class<LuaObjective>(L, 2))->name_);
591
592 lua_pushboolean(L,
593 (me != objectives.end() && other != objectives.end()) &&
594@@ -1099,10 +1099,10 @@
595 */
596 Objective & LuaObjective::get(lua_State * L, Widelands::Game & g) {
597 Map::Objectives* objectives = g.map().mutable_objectives();
598- Map::Objectives::iterator i = objectives->find(m_name);
599+ Map::Objectives::iterator i = objectives->find(name_);
600 if (i == objectives->end()) {
601 report_error
602- (L, "Objective with name '%s' doesn't exist!", m_name.c_str());
603+ (L, "Objective with name '%s' doesn't exist!", name_.c_str());
604 }
605 return *i->second;
606 }
607@@ -1132,19 +1132,19 @@
608 };
609
610 LuaMessage::LuaMessage(uint8_t plr, MessageId id) {
611- m_plr = plr;
612- m_mid = id;
613+ player_number_ = plr;
614+ message_id_ = id;
615 }
616
617 void LuaMessage::__persist(lua_State * L) {
618- PERS_UINT32("player", m_plr);
619- PERS_UINT32("msg_idx", get_mos(L)->message_savers[m_plr - 1][m_mid].value());
620+ PERS_UINT32("player", player_number_);
621+ PERS_UINT32("msg_idx", get_mos(L)->message_savers[player_number_ - 1][message_id_].value());
622 }
623 void LuaMessage::__unpersist(lua_State * L) {
624- UNPERS_UINT32("player", m_plr);
625+ UNPERS_UINT32("player", player_number_);
626 uint32_t midx = 0;
627 UNPERS_UINT32("msg_idx", midx);
628- m_mid = MessageId(midx);
629+ message_id_ = MessageId(midx);
630 }
631
632 /*
633@@ -1220,7 +1220,7 @@
634 else if (s == "archived") status = Message::Status::kArchived;
635 else report_error(L, "Invalid message status <%s>!", s.c_str());
636
637- get_plr(L, get_game(L)).messages().set_message_status(m_mid, status);
638+ get_plr(L, get_game(L)).messages().set_message_status(message_id_, status);
639
640 return 0;
641 }
642@@ -1253,7 +1253,7 @@
643 ==========================================================
644 */
645 int LuaMessage::__eq(lua_State * L) {
646- lua_pushboolean(L, m_mid == (*get_user_class<LuaMessage>(L, 2))->m_mid);
647+ lua_pushboolean(L, message_id_ == (*get_user_class<LuaMessage>(L, 2))->message_id_);
648 return 1;
649 }
650
651@@ -1263,15 +1263,15 @@
652 ==========================================================
653 */
654 Player & LuaMessage::get_plr(lua_State * L, Widelands::Game & game) {
655- if (m_plr > MAX_PLAYERS)
656- report_error(L, "Illegal player number %i", m_plr);
657- Player * rv = game.get_player(m_plr);
658+ if (player_number_ > MAX_PLAYERS)
659+ report_error(L, "Illegal player number %i", player_number_);
660+ Player * rv = game.get_player(player_number_);
661 if (!rv)
662- report_error(L, "Player with the number %i does not exist", m_plr);
663+ report_error(L, "Player with the number %i does not exist", player_number_);
664 return *rv;
665 }
666 const Message & LuaMessage::get(lua_State * L, Widelands::Game & game) {
667- const Message * rv = get_plr(L, game).messages()[m_mid];
668+ const Message * rv = get_plr(L, game).messages()[message_id_];
669 if (!rv)
670 report_error(L, "This message has been deleted!");
671 return *rv;
672
673=== modified file 'src/scripting/lua_game.h'
674--- src/scripting/lua_game.h 2015-12-04 18:27:36 +0000
675+++ src/scripting/lua_game.h 2016-02-12 18:18:22 +0000
676@@ -1,5 +1,5 @@
677 /*
678- * Copyright (C) 2006-2010 by the Widelands Development Team
679+ * Copyright (C) 2006-2016 by the Widelands Development Team
680 *
681 * This program is free software; you can redistribute it and/or
682 * modify it under the terms of the GNU General Public License
683@@ -102,7 +102,7 @@
684 };
685
686 class LuaObjective : public LuaGameModuleClass {
687- std::string m_name;
688+ std::string name_;
689
690 public:
691 LUNA_CLASS_HEAD(LuaObjective);
692@@ -110,7 +110,7 @@
693 virtual ~LuaObjective() {}
694
695 LuaObjective(const Widelands::Objective& n);
696- LuaObjective() : m_name("") {}
697+ LuaObjective() : name_("") {}
698 LuaObjective(lua_State * L) {
699 report_error(L, "Cannot instantiate a '%s' directly!", className);
700 }
701@@ -144,15 +144,15 @@
702 };
703
704 class LuaMessage : public LuaGameModuleClass {
705- uint32_t m_plr;
706- Widelands::MessageId m_mid;
707+ uint32_t player_number_; // TODO(Hasi50): in CTor this is uint8_t, well
708+ Widelands::MessageId message_id_;
709
710 public:
711 LUNA_CLASS_HEAD(LuaMessage);
712 virtual ~LuaMessage() {}
713
714 LuaMessage(uint8_t, Widelands::MessageId);
715- LuaMessage() : m_plr(0), m_mid(0) {}
716+ LuaMessage() : player_number_(0), message_id_(0) {}
717 LuaMessage(lua_State * L) {
718 report_error(L, "Cannot instantiate a '%s' directly!", className);
719 }
720
721=== modified file 'src/scripting/lua_interface.cc'
722--- src/scripting/lua_interface.cc 2015-03-21 13:18:02 +0000
723+++ src/scripting/lua_interface.cc 2016-02-12 18:18:22 +0000
724@@ -1,5 +1,5 @@
725 /*
726- * Copyright (C) 2006-2010, 2013 by the Widelands Development Team
727+ * Copyright (C) 2006-2016 by the Widelands Development Team
728 *
729 * This program is free software; you can redistribute it and/or
730 * modify it under the terms of the GNU General Public License
731@@ -52,46 +52,46 @@
732
733
734 LuaInterface::LuaInterface() {
735- m_L = luaL_newstate();
736+ lua_state_ = luaL_newstate();
737
738 // Open the Lua libraries
739- open_lua_library(m_L, "", luaopen_base, false);
740- open_lua_library(m_L, LUA_TABLIBNAME, luaopen_table, true);
741- open_lua_library(m_L, LUA_STRLIBNAME, luaopen_string, true);
742- open_lua_library(m_L, LUA_MATHLIBNAME, luaopen_math, true);
743- open_lua_library(m_L, LUA_DBLIBNAME, luaopen_debug, true);
744- open_lua_library(m_L, LUA_COLIBNAME, luaopen_coroutine, true);
745+ open_lua_library(lua_state_, "", luaopen_base, false);
746+ open_lua_library(lua_state_, LUA_TABLIBNAME, luaopen_table, true);
747+ open_lua_library(lua_state_, LUA_STRLIBNAME, luaopen_string, true);
748+ open_lua_library(lua_state_, LUA_MATHLIBNAME, luaopen_math, true);
749+ open_lua_library(lua_state_, LUA_DBLIBNAME, luaopen_debug, true);
750+ open_lua_library(lua_state_, LUA_COLIBNAME, luaopen_coroutine, true);
751
752 // Push the instance of this class into the registry
753 // MSVC2008 requires that stored and retrieved types are
754 // same, so use LuaInterface* on both sides.
755 lua_pushlightuserdata
756- (m_L, reinterpret_cast<void *>(dynamic_cast<LuaInterface *>(this)));
757- lua_setfield(m_L, LUA_REGISTRYINDEX, "lua_interface");
758+ (lua_state_, reinterpret_cast<void *>(dynamic_cast<LuaInterface *>(this)));
759+ lua_setfield(lua_state_, LUA_REGISTRYINDEX, "lua_interface");
760
761 // Now our own
762- LuaGlobals::luaopen_globals(m_L);
763+ LuaGlobals::luaopen_globals(lua_state_);
764
765 // And helper methods.
766- LuaPath::luaopen_path(m_L);
767+ LuaPath::luaopen_path(lua_state_);
768
769 // Also push the "wl" and the "hooks" table.
770- lua_newtable(m_L);
771- lua_setglobal(m_L, "wl");
772+ lua_newtable(lua_state_);
773+ lua_setglobal(lua_state_, "wl");
774
775- lua_newtable(m_L);
776- lua_setglobal(m_L, "hooks");
777+ lua_newtable(lua_state_);
778+ lua_setglobal(lua_state_, "hooks");
779 }
780
781 LuaInterface::~LuaInterface() {
782- lua_close(m_L);
783+ lua_close(lua_state_);
784 }
785
786 void LuaInterface::interpret_string(const std::string& cmd) {
787- int rv = luaL_dostring(m_L, cmd.c_str());
788- check_return_value_for_errors(m_L, rv);
789+ int rv = luaL_dostring(lua_state_, cmd.c_str());
790+ check_return_value_for_errors(lua_state_, rv);
791 }
792
793 std::unique_ptr<LuaTable> LuaInterface::run_script(const std::string& path) {
794- return ::run_script(m_L, path, g_fs);
795+ return ::run_script(lua_state_, path, g_fs);
796 }
797
798=== modified file 'src/scripting/lua_interface.h'
799--- src/scripting/lua_interface.h 2015-01-31 16:03:59 +0000
800+++ src/scripting/lua_interface.h 2016-02-12 18:18:22 +0000
801@@ -1,5 +1,5 @@
802 /*
803- * Copyright (C) 2006-2010 by the Widelands Development Team
804+ * Copyright (C) 2006-2016 by the Widelands Development Team
805 *
806 * This program is free software; you can redistribute it and/or
807 * modify it under the terms of the GNU General Public License
808@@ -41,7 +41,7 @@
809 virtual std::unique_ptr<LuaTable> run_script(const std::string& script);
810
811 protected:
812- lua_State* m_L;
813+ lua_State* lua_state_;
814 };
815
816 #endif // end of include guard: WL_SCRIPTING_LUA_INTERFACE_H
817
818=== modified file 'src/scripting/lua_map.cc'
819--- src/scripting/lua_map.cc 2016-02-11 06:50:56 +0000
820+++ src/scripting/lua_map.cc 2016-02-12 18:18:22 +0000
821@@ -1,5 +1,5 @@
822 /*
823- * Copyright (C) 2006-2010, 2013 by the Widelands Development Team
824+ * Copyright (C) 2006-2016 by the Widelands Development Team
825 *
826 * This program is free software; you can redistribute it and/or
827 * modify it under the terms of the GNU General Public License
828@@ -2509,7 +2509,7 @@
829 Game & game = get_game(L);
830
831 uint32_t idx = 0;
832- if (MapObject* obj = m_ptr.get(game))
833+ if (MapObject* obj = ptr_.get(game))
834 idx = mos.get_object_file_index(*obj);
835
836 PERS_UINT32("file_index", idx);
837@@ -2519,10 +2519,10 @@
838 UNPERS_UINT32("file_index", idx);
839
840 if (!idx)
841- m_ptr = nullptr;
842+ ptr_ = nullptr;
843 else {
844 MapObjectLoader& mol = *get_mol(L);
845- m_ptr = &mol.get<MapObject>(idx);
846+ ptr_ = &mol.get<MapObject>(idx);
847 }
848 }
849
850@@ -2679,7 +2679,7 @@
851 return o;
852 }
853 MapObject* LuaMapObject::m_get_or_zero(EditorGameBase& egbase) {
854- return m_ptr.get(egbase);
855+ return ptr_.get(egbase);
856 }
857
858 /* RST
859@@ -4338,11 +4338,11 @@
860
861
862 void LuaField::__persist(lua_State * L) {
863- PERS_INT32("x", m_c.x); PERS_INT32("y", m_c.y);
864+ PERS_INT32("x", coords_.x); PERS_INT32("y", coords_.y);
865 }
866
867 void LuaField::__unpersist(lua_State * L) {
868- UNPERS_INT32("x", m_c.x); UNPERS_INT32("y", m_c.y);
869+ UNPERS_INT32("x", coords_.x); UNPERS_INT32("y", coords_.y);
870 }
871
872 /*
873@@ -4352,7 +4352,7 @@
874 */
875 // Hash is used to identify a class in a Set
876 int LuaField::get___hash(lua_State * L) {
877- const std::string pushme = (boost::format("%i_%i") % m_c.x % m_c.y).str();
878+ const std::string pushme = (boost::format("%i_%i") % coords_.x % coords_.y).str();
879 lua_pushstring(L, pushme.c_str());
880 return 1;
881 }
882@@ -4362,8 +4362,8 @@
883
884 (RO) The x/y coordinate of this field
885 */
886-int LuaField::get_x(lua_State * L) {lua_pushuint32(L, m_c.x); return 1;}
887-int LuaField::get_y(lua_State * L) {lua_pushuint32(L, m_c.y); return 1;}
888+int LuaField::get_x(lua_State * L) {lua_pushuint32(L, coords_.x); return 1;}
889+int LuaField::get_y(lua_State * L) {lua_pushuint32(L, coords_.y); return 1;}
890
891 /* RST
892 .. attribute:: height
893@@ -4430,13 +4430,13 @@
894 */
895 int LuaField::get_viewpoint_x(lua_State * L) {
896 int32_t px, py;
897- MapviewPixelFunctions::get_save_pix(get_egbase(L).map(), m_c, px, py);
898+ MapviewPixelFunctions::get_save_pix(get_egbase(L).map(), coords_, px, py);
899 lua_pushint32(L, px);
900 return 1;
901 }
902 int LuaField::get_viewpoint_y(lua_State * L) {
903 int32_t px, py;
904- MapviewPixelFunctions::get_save_pix(get_egbase(L).map(), m_c, px, py);
905+ MapviewPixelFunctions::get_save_pix(get_egbase(L).map(), coords_, px, py);
906 lua_pushint32(L, py);
907 return 1;
908 }
909@@ -4524,7 +4524,7 @@
910 to remove an immovable, you can use :func:`wl.map.MapObject.remove`.
911 */
912 int LuaField::get_immovable(lua_State * L) {
913- BaseImmovable * bi = get_egbase(L).map().get_immovable(m_c);
914+ BaseImmovable * bi = get_egbase(L).map().get_immovable(coords_);
915
916 if (!bi)
917 return 0;
918@@ -4627,7 +4627,7 @@
919 */
920 #define GET_X_NEIGHBOUR(X) int LuaField::get_ ##X(lua_State* L) { \
921 Coords n; \
922- get_egbase(L).map().get_ ##X(m_c, &n); \
923+ get_egbase(L).map().get_ ##X(coords_, &n); \
924 to_lua<LuaField>(L, new LuaField(n.x, n.y)); \
925 return 1; \
926 }
927@@ -4673,7 +4673,7 @@
928 iterate_players_existing(other_p, map.get_nrplayers(), egbase, plr)
929 claimers.push_back
930 (PlrInfluence(plr->player_number(), plr->military_influence
931- (map.get_index(m_c, map.get_width()))
932+ (map.get_index(coords_, map.get_width()))
933 )
934 );
935
936@@ -4700,12 +4700,12 @@
937 ==========================================================
938 */
939 int LuaField::__eq(lua_State * L) {
940- lua_pushboolean(L, (*get_user_class<LuaField>(L, -1))->m_c == m_c);
941+ lua_pushboolean(L, (*get_user_class<LuaField>(L, -1))->coords_ == coords_);
942 return 1;
943 }
944
945 int LuaField::__tostring(lua_State * L) {
946- const std::string pushme = (boost::format("Field(%i,%i)") % m_c.x % m_c.y).str();
947+ const std::string pushme = (boost::format("Field(%i,%i)") % coords_.x % coords_.y).str();
948 lua_pushstring(L, pushme);
949 return 1;
950 }
951@@ -4820,7 +4820,7 @@
952 (lua_State * L, uint32_t radius, uint32_t inner_radius)
953 {
954 Map & map = get_egbase(L).map();
955- HollowArea<Area<> > har(Area<>(m_c, radius), inner_radius);
956+ HollowArea<Area<> > har(Area<>(coords_, radius), inner_radius);
957
958 MapHollowRegion<Area<> > mr(map, har);
959
960@@ -4836,7 +4836,7 @@
961 }
962
963 const Widelands::FCoords LuaField::fcoords(lua_State * L) {
964- return get_egbase(L).map().get_fcoords(m_c);
965+ return get_egbase(L).map().get_fcoords(coords_);
966 }
967
968
969@@ -4864,11 +4864,11 @@
970 };
971
972 void LuaPlayerSlot::__persist(lua_State * L) {
973- PERS_UINT32("player", m_plr);
974+ PERS_UINT32("player", player_number_);
975 }
976
977 void LuaPlayerSlot::__unpersist(lua_State * L) {
978- UNPERS_UINT32("player", m_plr);
979+ UNPERS_UINT32("player", player_number_);
980 }
981
982 /*
983@@ -4882,7 +4882,7 @@
984 (RO) The name of the tribe suggested for this player in this map
985 */
986 int LuaPlayerSlot::get_tribe_name(lua_State * L) {
987- lua_pushstring(L, get_egbase(L).get_map()->get_scenario_player_tribe(m_plr));
988+ lua_pushstring(L, get_egbase(L).get_map()->get_scenario_player_tribe(player_number_));
989 return 1;
990 }
991
992@@ -4892,7 +4892,7 @@
993 (RO) The name for this player as suggested in this map
994 */
995 int LuaPlayerSlot::get_name(lua_State * L) {
996- lua_pushstring(L, get_egbase(L).get_map()->get_scenario_player_name(m_plr));
997+ lua_pushstring(L, get_egbase(L).get_map()->get_scenario_player_name(player_number_));
998 return 1;
999 }
1000
1001@@ -4905,7 +4905,7 @@
1002 wherever it want. This field is only centered when the game starts.
1003 */
1004 int LuaPlayerSlot::get_starting_field(lua_State * L) {
1005- to_lua<LuaField>(L, new LuaField(get_egbase(L).map().get_starting_pos(m_plr)));
1006+ to_lua<LuaField>(L, new LuaField(get_egbase(L).map().get_starting_pos(player_number_)));
1007 return 1;
1008 }
1009
1010
1011=== modified file 'src/scripting/lua_map.h'
1012--- src/scripting/lua_map.h 2016-01-22 19:53:32 +0000
1013+++ src/scripting/lua_map.h 2016-02-12 18:18:22 +0000
1014@@ -1,5 +1,5 @@
1015 /*
1016- * Copyright (C) 2006-2010 by the Widelands Development Team
1017+ * Copyright (C) 2006-2016 by the Widelands Development Team
1018 *
1019 * This program is free software; you can redistribute it and/or
1020 * modify it under the terms of the GNU General Public License
1021@@ -522,20 +522,20 @@
1022 }
1023
1024 class LuaMapObject : public LuaMapModuleClass {
1025- Widelands::ObjectPointer m_ptr;
1026+ Widelands::ObjectPointer ptr_;
1027
1028 public:
1029 LUNA_CLASS_HEAD(LuaMapObject);
1030
1031- LuaMapObject() : m_ptr(nullptr) {}
1032+ LuaMapObject() : ptr_(nullptr) {}
1033 LuaMapObject(Widelands::MapObject & mo) {
1034- m_ptr = &mo;
1035+ ptr_ = &mo;
1036 }
1037- LuaMapObject(lua_State * L) : m_ptr(nullptr) {
1038+ LuaMapObject(lua_State * L) : ptr_(nullptr) {
1039 report_error(L, "Cannot instantiate a '%s' directly!", className);
1040 }
1041 virtual ~LuaMapObject() {
1042- m_ptr = nullptr;
1043+ ptr_ = nullptr;
1044 }
1045
1046 void __persist(lua_State * L) override;
1047@@ -992,14 +992,14 @@
1048 #undef CASTED_GET
1049
1050 class LuaField : public LuaMapModuleClass {
1051- Widelands::Coords m_c;
1052+ Widelands::Coords coords_;
1053 public:
1054 LUNA_CLASS_HEAD(LuaField);
1055
1056 LuaField() {}
1057 LuaField (int16_t x, int16_t y) :
1058- m_c(Widelands::Coords(x, y)) {}
1059- LuaField (Widelands::Coords c) : m_c(c) {}
1060+ coords_(Widelands::Coords(x, y)) {}
1061+ LuaField (Widelands::Coords c) : coords_(c) {}
1062 LuaField(lua_State * L) {
1063 report_error(L, "Cannot instantiate a 'Field' directly!");
1064 }
1065@@ -1051,7 +1051,7 @@
1066 /*
1067 * C methods
1068 */
1069- inline const Widelands::Coords & coords() {return m_c;}
1070+ inline const Widelands::Coords & coords() {return coords_;}
1071 const Widelands::FCoords fcoords(lua_State * L);
1072
1073 private:
1074@@ -1060,14 +1060,14 @@
1075 };
1076
1077 class LuaPlayerSlot : public LuaMapModuleClass {
1078- Widelands::PlayerNumber m_plr;
1079+ Widelands::PlayerNumber player_number_;
1080
1081 public:
1082 LUNA_CLASS_HEAD(LuaPlayerSlot);
1083
1084- LuaPlayerSlot() : m_plr(0) {}
1085- LuaPlayerSlot(Widelands::PlayerNumber plr) : m_plr(plr) {}
1086- LuaPlayerSlot(lua_State * L) : m_plr(0) {
1087+ LuaPlayerSlot() : player_number_(0) {}
1088+ LuaPlayerSlot(Widelands::PlayerNumber plr) : player_number_(plr) {}
1089+ LuaPlayerSlot(lua_State * L) : player_number_(0) {
1090 report_error(L, "Cannot instantiate a 'PlayerSlot' directly!");
1091 }
1092 virtual ~LuaPlayerSlot() {}
1093
1094=== modified file 'src/scripting/lua_ui.cc'
1095--- src/scripting/lua_ui.cc 2015-08-06 17:14:34 +0000
1096+++ src/scripting/lua_ui.cc 2016-02-12 18:18:22 +0000
1097@@ -1,5 +1,5 @@
1098 /*
1099- * Copyright (C) 2006-2011 by the Widelands Development Team
1100+ * Copyright (C) 2006-20116 by the Widelands Development Team
1101 *
1102 * This program is free software; you can redistribute it and/or
1103 * modify it under the terms of the GNU General Public License
1104@@ -122,10 +122,10 @@
1105 }
1106 }
1107 int LuaPanel::get_buttons(lua_State * L) {
1108- assert(m_panel);
1109+ assert(panel_);
1110
1111 lua_newtable(L);
1112- _put_all_visible_buttons_into_table(L, m_panel);
1113+ _put_all_visible_buttons_into_table(L, panel_);
1114
1115 return 1;
1116 }
1117@@ -153,10 +153,10 @@
1118 }
1119 }
1120 int LuaPanel::get_tabs(lua_State * L) {
1121- assert(m_panel);
1122+ assert(panel_);
1123
1124 lua_newtable(L);
1125- _put_all_tabs_into_table(L, m_panel);
1126+ _put_all_tabs_into_table(L, panel_);
1127
1128 return 1;
1129 }
1130@@ -185,10 +185,10 @@
1131 }
1132 }
1133 int LuaPanel::get_windows(lua_State * L) {
1134- assert(m_panel);
1135+ assert(panel_);
1136
1137 lua_newtable(L);
1138- _put_all_visible_windows_into_table(L, m_panel);
1139+ _put_all_visible_windows_into_table(L, panel_);
1140
1141 return 1;
1142 }
1143@@ -199,27 +199,27 @@
1144 (RW) The current mouse position relative to this Panels position
1145 */
1146 int LuaPanel::get_mouse_position_x(lua_State * L) {
1147- assert(m_panel);
1148- lua_pushint32(L, m_panel->get_mouse_position().x);
1149+ assert(panel_);
1150+ lua_pushint32(L, panel_->get_mouse_position().x);
1151 return 1;
1152 }
1153 int LuaPanel::set_mouse_position_x(lua_State * L) {
1154- assert(m_panel);
1155- Point p = m_panel->get_mouse_position();
1156+ assert(panel_);
1157+ Point p = panel_->get_mouse_position();
1158 p.x = luaL_checkint32(L, -1);
1159- m_panel->set_mouse_pos(p);
1160+ panel_->set_mouse_pos(p);
1161 return 1;
1162 }
1163 int LuaPanel::get_mouse_position_y(lua_State * L) {
1164- assert(m_panel);
1165- lua_pushint32(L, m_panel->get_mouse_position().y);
1166+ assert(panel_);
1167+ lua_pushint32(L, panel_->get_mouse_position().y);
1168 return 1;
1169 }
1170 int LuaPanel::set_mouse_position_y(lua_State * L) {
1171- assert(m_panel);
1172- Point p = m_panel->get_mouse_position();
1173+ assert(panel_);
1174+ Point p = panel_->get_mouse_position();
1175 p.y = luaL_checkint32(L, -1);
1176- m_panel->set_mouse_pos(p);
1177+ panel_->set_mouse_pos(p);
1178 return 1;
1179 }
1180
1181@@ -229,23 +229,23 @@
1182 (RW) The dimensions of this panel in pixels
1183 */
1184 int LuaPanel::get_width(lua_State * L) {
1185- assert(m_panel);
1186- lua_pushint32(L, m_panel->get_w());
1187+ assert(panel_);
1188+ lua_pushint32(L, panel_->get_w());
1189 return 1;
1190 }
1191 int LuaPanel::set_width(lua_State * L) {
1192- assert(m_panel);
1193- m_panel->set_size(luaL_checkint32(L, -1), m_panel->get_h());
1194+ assert(panel_);
1195+ panel_->set_size(luaL_checkint32(L, -1), panel_->get_h());
1196 return 1;
1197 }
1198 int LuaPanel::get_height(lua_State * L) {
1199- assert(m_panel);
1200- lua_pushint32(L, m_panel->get_h());
1201+ assert(panel_);
1202+ lua_pushint32(L, panel_->get_h());
1203 return 1;
1204 }
1205 int LuaPanel::set_height(lua_State * L) {
1206- assert(m_panel);
1207- m_panel->set_size(m_panel->get_w(), luaL_checkint32(L, -1));
1208+ assert(panel_);
1209+ panel_->set_size(panel_->get_w(), luaL_checkint32(L, -1));
1210 return 1;
1211 }
1212
1213@@ -256,29 +256,29 @@
1214 parent's element inner canvas.
1215 */
1216 int LuaPanel::get_position_x(lua_State * L) {
1217- assert(m_panel);
1218- Point p = m_panel->to_parent(Point(0, 0));
1219+ assert(panel_);
1220+ Point p = panel_->to_parent(Point(0, 0));
1221
1222 lua_pushint32(L, p.x);
1223 return 1;
1224 }
1225 int LuaPanel::set_position_x(lua_State * L) {
1226- assert(m_panel);
1227- Point p(luaL_checkint32(L, -1) - m_panel->get_lborder(), m_panel->get_y());
1228- m_panel->set_pos(p);
1229+ assert(panel_);
1230+ Point p(luaL_checkint32(L, -1) - panel_->get_lborder(), panel_->get_y());
1231+ panel_->set_pos(p);
1232 return 1;
1233 }
1234 int LuaPanel::get_position_y(lua_State * L) {
1235- assert(m_panel);
1236- Point p = m_panel->to_parent(Point(0, 0));
1237+ assert(panel_);
1238+ Point p = panel_->to_parent(Point(0, 0));
1239
1240 lua_pushint32(L, p.y);
1241 return 1;
1242 }
1243 int LuaPanel::set_position_y(lua_State * L) {
1244- assert(m_panel);
1245- Point p(m_panel->get_x(), luaL_checkint32(L, -1) - m_panel->get_tborder());
1246- m_panel->set_pos(p);
1247+ assert(panel_);
1248+ Point p(panel_->get_x(), luaL_checkint32(L, -1) - panel_->get_tborder());
1249+ panel_->set_pos(p);
1250 return 1;
1251 }
1252
1253@@ -298,12 +298,12 @@
1254 :rtype: both are :class:`integers`
1255 */
1256 int LuaPanel::get_descendant_position(lua_State * L) {
1257- assert(m_panel);
1258+ assert(panel_);
1259
1260- UI::Panel * cur = (*get_base_user_class<LuaPanel>(L, 2))->m_panel;
1261+ UI::Panel * cur = (*get_base_user_class<LuaPanel>(L, 2))->panel_;
1262
1263 Point cp = Point(0, 0);
1264- while (cur && cur != m_panel) {
1265+ while (cur && cur != panel_) {
1266 cp += cur->to_parent(Point(0, 0));
1267 cur = cur->get_parent();
1268 }
1269@@ -482,8 +482,8 @@
1270 not use it any longer.
1271 */
1272 int LuaWindow::close(lua_State * /* L */) {
1273- delete m_panel;
1274- m_panel = nullptr;
1275+ delete panel_;
1276+ panel_ = nullptr;
1277 return 0;
1278 }
1279
1280@@ -526,7 +526,7 @@
1281 void LuaMapView::__unpersist(lua_State* L)
1282 {
1283 Widelands::Game & game = get_game(L);
1284- m_panel = game.get_ibase();
1285+ panel_ = game.get_ibase();
1286 }
1287
1288
1289
1290=== modified file 'src/scripting/lua_ui.h'
1291--- src/scripting/lua_ui.h 2015-01-31 16:03:59 +0000
1292+++ src/scripting/lua_ui.h 2016-02-12 18:18:22 +0000
1293@@ -1,5 +1,5 @@
1294 /*
1295- * Copyright (C) 2006-2010 by the Widelands Development Team
1296+ * Copyright (C) 2006-2016 by the Widelands Development Team
1297 *
1298 * This program is free software; you can redistribute it and/or
1299 * modify it under the terms of the GNU General Public License
1300@@ -40,14 +40,14 @@
1301
1302 class LuaPanel : public LuaUiModuleClass {
1303 protected:
1304- UI::Panel * m_panel;
1305+ UI::Panel * panel_;
1306
1307 public:
1308 LUNA_CLASS_HEAD(LuaPanel);
1309
1310- LuaPanel() : m_panel(nullptr) {}
1311- LuaPanel(UI::Panel * p) : m_panel(p) {}
1312- LuaPanel(lua_State * L) : m_panel(nullptr) {
1313+ LuaPanel() : panel_(nullptr) {}
1314+ LuaPanel(UI::Panel * p) : panel_(p) {}
1315+ LuaPanel(lua_State * L) : panel_(nullptr) {
1316 report_error(L, "Cannot instantiate a '%s' directly!", className);
1317 }
1318 virtual ~LuaPanel() {}
1319@@ -114,7 +114,7 @@
1320 /*
1321 * C Methods
1322 */
1323- UI::Button * get() {return static_cast<UI::Button *>(m_panel);}
1324+ UI::Button * get() {return static_cast<UI::Button *>(panel_);}
1325 };
1326
1327 class LuaTab : public LuaPanel {
1328@@ -140,7 +140,7 @@
1329 /*
1330 * C Methods
1331 */
1332- UI::Tab * get() {return static_cast<UI::Tab *>(m_panel);}
1333+ UI::Tab * get() {return static_cast<UI::Tab *>(panel_);}
1334 };
1335
1336 class LuaWindow : public LuaPanel {
1337@@ -165,7 +165,7 @@
1338 /*
1339 * C Methods
1340 */
1341- UI::Window * get() {return static_cast<UI::Window *>(m_panel);}
1342+ UI::Window * get() {return static_cast<UI::Window *>(panel_);}
1343 };
1344
1345
1346@@ -207,7 +207,7 @@
1347 /*
1348 * C Methods
1349 */
1350- InteractiveBase * get() {return static_cast<InteractiveBase *>(m_panel);}
1351+ InteractiveBase * get() {return static_cast<InteractiveBase *>(panel_);}
1352 };
1353
1354 void luaopen_wlui(lua_State *);
1355
1356=== modified file 'src/scripting/luna.h'
1357--- src/scripting/luna.h 2015-04-18 11:20:53 +0000
1358+++ src/scripting/luna.h 2016-02-12 18:18:22 +0000
1359@@ -1,5 +1,5 @@
1360 /*
1361- * Copyright (C) 2006-2010 by the Widelands Development Team
1362+ * Copyright (C) 2006-2016 by the Widelands Development Team
1363 *
1364 * This program is free software; you can redistribute it and/or
1365 * modify it under the terms of the GNU General Public License
1366
1367=== modified file 'src/scripting/luna_impl.h'
1368--- src/scripting/luna_impl.h 2015-01-31 16:03:59 +0000
1369+++ src/scripting/luna_impl.h 2016-02-12 18:18:22 +0000
1370@@ -1,5 +1,5 @@
1371 /*
1372- * Copyright (C) 2006-2010 by the Widelands Development Team
1373+ * Copyright (C) 2006-2016 by the Widelands Development Team
1374 *
1375 * This program is free software; you can redistribute it and/or
1376 * modify it under the terms of the GNU General Public License
1377
1378=== modified file 'src/sound/songset.h'
1379--- src/sound/songset.h 2014-07-05 16:41:51 +0000
1380+++ src/sound/songset.h 2016-02-12 18:18:22 +0000
1381@@ -1,5 +1,5 @@
1382 /*
1383- * Copyright (C) 2006, 2008 by the Widelands Development Team
1384+ * Copyright (C) 2006-2016 by the Widelands Development Team
1385 *
1386 * This program is free software; you can redistribute it and/or
1387 * modify it under the terms of the GNU General Public License
1388@@ -35,7 +35,7 @@
1389 * music, e.g. all songs that might be played while the main menu is being
1390 * shown. It is possible to access those songs one after another or in
1391 * random order. The fact that a Songset really contains several different
1392- * songs is hidden from the outside.\n
1393+ * songs is hidden from the outside.
1394 * A songset does not contain the audio data itself, to not use huge amounts of
1395 * memory. Instead, each song is loaded on request and the data is free()d
1396 * afterwards

Subscribers

People subscribed via source and target branches

to status/vote changes: