Merge lp:~widelands-dev/widelands/remove_nocom_logs_campaign_data into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8741
Proposed branch: lp:~widelands-dev/widelands/remove_nocom_logs_campaign_data
Merge into: lp:widelands
Diff against target: 57 lines (+7/-13)
1 file modified
src/scripting/lua_bases.cc (+7/-13)
To merge this branch: bzr merge lp:~widelands-dev/widelands/remove_nocom_logs_campaign_data
Reviewer Review Type Date Requested Status
Benedikt Straub review, test Approve
Review via email: mp+349088@code.launchpad.net

Commit message

Removed logs in campaign data that are no longer needed. Made some strings const.

To post a comment you must log in.
Revision history for this message
Benedikt Straub (nordfriese) wrote :

Compiled and tested, works as it should.
Code changes look good to me.

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

Thanks for the review :)

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3634. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/401193238.
Appveyor build 3433. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_remove_nocom_logs_campaign_data-3433.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/scripting/lua_bases.cc'
--- src/scripting/lua_bases.cc 2018-06-01 13:29:38 +0000
+++ src/scripting/lua_bases.cc 2018-07-07 11:07:24 +0000
@@ -338,7 +338,7 @@
338 If a table is an array, the map 'keys' will contain no mappings for the array's key_keys.338 If a table is an array, the map 'keys' will contain no mappings for the array's key_keys.
339*/339*/
340static void save_table_recursively(lua_State* L,340static void save_table_recursively(lua_State* L,
341 std::string depth,341 const std::string& depth,
342 std::map<std::string, const char*>* data,342 std::map<std::string, const char*>* data,
343 std::map<std::string, const char*>* keys,343 std::map<std::string, const char*>* keys,
344 std::map<std::string, const char*>* type,344 std::map<std::string, const char*>* type,
@@ -346,11 +346,11 @@
346 lua_pushnil(L);346 lua_pushnil(L);
347 uint32_t i = 0;347 uint32_t i = 0;
348 while (lua_next(L, -2) != 0) {348 while (lua_next(L, -2) != 0) {
349 std::string key_key = depth + "_" + std::to_string(i);349 const std::string key_key = depth + "_" + std::to_string(i);
350350
351 // check the value's type351 // check the value's type
352 const char* type_name = lua_typename(L, lua_type(L, -1));352 const char* type_name = lua_typename(L, lua_type(L, -1));
353 std::string t = std::string(type_name);353 const std::string t = std::string(type_name);
354354
355 (*type)[key_key] = type_name;355 (*type)[key_key] = type_name;
356356
@@ -461,7 +461,7 @@
461 and the key-value pair is written to the table as the correct type.461 and the key-value pair is written to the table as the correct type.
462*/462*/
463static void push_table_recursively(lua_State* L,463static void push_table_recursively(lua_State* L,
464 std::string depth,464 const std::string& depth,
465 Section* data_section,465 Section* data_section,
466 Section* keys_section,466 Section* keys_section,
467 Section* type_section,467 Section* type_section,
@@ -469,19 +469,13 @@
469 const uint32_t size = size_section->get_natural(depth.c_str());469 const uint32_t size = size_section->get_natural(depth.c_str());
470 lua_newtable(L);470 lua_newtable(L);
471 for (uint32_t i = 0; i < size; i++) {471 for (uint32_t i = 0; i < size; i++) {
472 std::string key_key_str(depth + '_' + std::to_string(i));472 const std::string key_key_str(depth + '_' + std::to_string(i));
473 const char* key_key = key_key_str.c_str();473 const char* key_key = key_key_str.c_str();
474
475 log("Checking whether a key for '%s' (data type is %s) exists ... ", key_key,
476 type_section->get_string(key_key)); // NOCOM remove this log
477 if (keys_section->has_val(key_key)) {474 if (keys_section->has_val(key_key)) {
478 // this is a table475 // This is a table
479 log("YES, the key is called '%s'.\n",
480 keys_section->get_string(key_key)); // NOCOM remove this log
481 lua_pushstring(L, keys_section->get_string(key_key));476 lua_pushstring(L, keys_section->get_string(key_key));
482 } else {477 } else {
483 // this must be an array478 // This must be an array
484 log("NO, [%i] will be used as key.\n", i + 1); // NOCOM remove this log
485 lua_pushinteger(L, i + 1);479 lua_pushinteger(L, i + 1);
486 }480 }
487481

Subscribers

People subscribed via source and target branches

to status/vote changes: