widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #07295
[Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
Klaus Halfmann has proposed merging lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1571009 in widelands: "Work area radius: 45xxxxxxx in bzr7962[trunk]"
https://bugs.launchpad.net/widelands/+bug/1571009
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug_1571009_work_area_radius/+merge/292066
This fixes 1571009 and adds some more Docs for the WorkareaInfo.
Im not usre about the Lua-Mapping, perhaps returning some kind of null might be better?
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands.
=== modified file 'src/logic/map_objects/tribes/workarea_info.h'
--- src/logic/map_objects/tribes/workarea_info.h 2015-11-28 22:29:26 +0000
+++ src/logic/map_objects/tribes/workarea_info.h 2016-04-16 12:42:55 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2008 by the Widelands Development Team
+ * Copyright (C) 2005-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
@@ -25,9 +25,22 @@
#include <set>
#include <string>
-// This type is used to store information about workareas. It stores radii and
-// for each radius a set of strings. Each string contains a description of an
-// activity (or similar) that can be performed within the radius.
+/** The WorkareaInfo stores radii and for each radius a set of strings.
+ *
+ * A Workarea is a "circle" around a building that this building affects
+ * or is needed by this building, e.g. Areas for Mines, Fields of a Farm.
+ * Worareads are shown on the Map when clicking on a building.
+ *
+ * Each string contains a description of an activity (or similar) i
+ * that can be performed within the radius.
+ *
+ * TODO(Hasi50): In fact this complex idea of a workarea is not used.
+ * I do knot know of any building that has different sizes of workareas
+ * during its liftimer. LuaBuildingDescription::get_workarea_radiu does not use it
+ * and the GUI does not show it.
+ *
+ * So we should just use a simple unit8 perhaps?
+ */
using WorkareaInfo = std::map<uint32_t, std::set<std::string>>;
#endif // end of include guard: WL_LOGIC_MAP_OBJECTS_TRIBES_WORKAREA_INFO_H
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2016-04-11 06:45:29 +0000
+++ src/scripting/lua_map.cc 2016-04-16 12:42:55 +0000
@@ -1871,10 +1871,16 @@
/* RST
.. attribute:: workarea_radius
- (RO) the workarea_radius of the building as an int.
+ (RO) the first workarea_radius of the building as an int,
+ 0 in case bulding has no workareas
*/
int LuaBuildingDescription::get_workarea_radius(lua_State * L) {
- lua_pushinteger(L, get()->workarea_info_.begin()->first);
+ const WorkareaInfo& workareaInfo = get()->workarea_info_;
+ if (!workareaInfo.empty()) {
+ lua_pushinteger(L, workareaInfo.begin()->first);
+ } else {
+ lua_pushinteger(L, 0);
+ }
return 1;
}
Follow ups
-
[Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: noreply, 2016-04-23
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: GunChleoc, 2016-04-23
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: Klaus Halfmann, 2016-04-23
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: GunChleoc, 2016-04-18
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: Tino, 2016-04-17
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: Klaus Halfmann, 2016-04-17
-
[Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: bunnybot, 2016-04-17
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: GunChleoc, 2016-04-17
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: GunChleoc, 2016-04-17
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: GunChleoc, 2016-04-17
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: Miroslav Remák, 2016-04-17
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: GunChleoc, 2016-04-17
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: Klaus Halfmann, 2016-04-17
-
[Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: bunnybot, 2016-04-16
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: Miroslav Remák, 2016-04-16
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: Klaus Halfmann, 2016-04-16
-
Re: [Merge] lp:~widelands-dev/widelands/bug_1571009_work_area_radius into lp:widelands
From: Miroslav Remák, 2016-04-16