[Widelands-dev] [Merge] lp:~widelands-dev/widelands/empire04_unused_key_return_on_dismantle into lp:widelands

2018-11-03 Thread GunChleoc
GunChleoc has proposed merging 
lp:~widelands-dev/widelands/empire04_unused_key_return_on_dismantle into 
lp:widelands.

Commit message:
Make dismantle button independent of buildable/enhanced. This fixes missing 
Dismantle buttons in Empire scenario 4.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/empire04_unused_key_return_on_dismantle/+merge/358273
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/empire04_unused_key_return_on_dismantle into 
lp:widelands.
=== modified file 'src/logic/map_objects/tribes/building.cc'
--- src/logic/map_objects/tribes/building.cc	2018-09-23 11:10:56 +
+++ src/logic/map_objects/tribes/building.cc	2018-11-03 16:33:17 +
@@ -60,6 +60,7 @@
: MapObjectDescr(init_type, table.get_string("name"), init_descname, table),
  egbase_(egbase),
  buildable_(false),
+ can_be_dismantled_(false),
  size_(BaseImmovable::SMALL),
  mine_(false),
  port_(false),
@@ -133,17 +134,22 @@
 		}
 	}
 
+// We define a building as buildable if it has a "buildcost" table.
+// A buildable building must also define "return_on_dismantle".
+// However, we support "return_on_dismantle" without "buildable", because this is used by custom scenario buildings.
+if (table.has_key("return_on_dismantle")) {
+return_dismantle_ = Buildcost(table.get_table("return_on_dismantle"), egbase_.tribes());
+}
 	if (table.has_key("buildcost")) {
 		buildable_ = true;
-		try {
-			buildcost_ = Buildcost(table.get_table("buildcost"), egbase_.tribes());
-			return_dismantle_ = Buildcost(table.get_table("return_on_dismantle"), egbase_.tribes());
-		} catch (const WException& e) {
-			throw wexception(
-			   "A buildable building must define \"buildcost\" and \"return_on_dismantle\": %s",
-			   e.what());
-		}
+if (!table.has_key("return_on_dismantle")) {
+throw wexception(
+			   "The building '%s' has a \"buildcost\" but no \"return_on_dismantle\"",
+			   name().c_str());
+}
+		buildcost_ = Buildcost(table.get_table("buildcost"), egbase_.tribes());
 	}
+
 	if (table.has_key("enhancement_cost")) {
 		enhanced_building_ = true;
 		try {
@@ -151,11 +157,12 @@
 			return_enhanced_ =
 			   Buildcost(table.get_table("return_on_dismantle_on_enhanced"), egbase_.tribes());
 		} catch (const WException& e) {
-			throw wexception("An enhanced building must define \"enhancement_cost\""
+			throw wexception("The enhanced building '%s' must define \"enhancement_cost\""
 			 "and \"return_on_dismantle_on_enhanced\": %s",
-			 e.what());
+			 name().c_str(), e.what());
 		}
 	}
+can_be_dismantled_ = (return_dismantle_.total() > 0 || return_enhanced_.total() > 0);
 
 	needs_seafaring_ = table.has_key("needs_seafaring") ? table.get_bool("needs_seafaring") : false;
 
@@ -310,7 +317,7 @@
 	const BuildingDescr& tmp_descr = descr();
 	if (tmp_descr.is_destructible()) {
 		caps |= PCap_Bulldoze;
-		if (tmp_descr.is_buildable() || tmp_descr.is_enhanced())
+		if (tmp_descr.can_be_dismantled())
 			caps |= PCap_Dismantle;
 	}
 	if (tmp_descr.enhancement() != INVALID_INDEX)

=== modified file 'src/logic/map_objects/tribes/building.h'
--- src/logic/map_objects/tribes/building.h	2018-09-25 06:32:35 +
+++ src/logic/map_objects/tribes/building.h	2018-11-03 16:33:17 +
@@ -73,6 +73,9 @@
 	bool is_buildable() const {
 		return buildable_;
 	}
+bool can_be_dismantled() const {
+		return can_be_dismantled_;
+	}
 	bool is_destructible() const {
 		return destructible_;
 	}
@@ -173,6 +176,7 @@
 
 private:
 	bool buildable_; // the player can build this himself
+bool can_be_dismantled_; // the player can dismantle this building
 	bool destructible_;  // the player can destruct this himself
 	Buildcost buildcost_;
 	Buildcost return_dismantle_;  // Returned wares on dismantle

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~hjd/widelands/clang-7 into lp:widelands

2018-11-03 Thread Hans Joachim Desserud
Hans Joachim Desserud has proposed merging lp:~hjd/widelands/clang-7 into 
lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~hjd/widelands/clang-7/+merge/358272

LLVM 7 was recently released, including a newer version of Clang. A repo making 
this available for travis builds has also been added [1], so our build matrix 
can be updated.

Replaced clang 5.0 with clang 7, to ensure that Widelands builds with the two 
most recent versions.


(I am not sure if our default shell script handles the version change from X.0 
to X, but let's see form the build logs how it works)

[1] 
https://github.com/travis-ci/apt-source-safelist/commit/25b38f72dcb0e2d995895390b904f4339ab1b8fc
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~hjd/widelands/clang-7 into lp:widelands.
=== modified file '.travis.yml'
--- .travis.yml	2018-05-02 16:41:45 +
+++ .travis.yml	2018-11-03 10:32:30 +
@@ -25,8 +25,8 @@
 key_url: "http://apt.llvm.org/llvm-snapshot.gpg.key;
   - sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.5 main"
 key_url: "http://apt.llvm.org/llvm-snapshot.gpg.key;
-  - llvm-toolchain-trusty-5.0
   - llvm-toolchain-trusty-6.0
+  - llvm-toolchain-trusty-7
 packages:
   - cmake
   - libboost-dev
@@ -59,22 +59,22 @@
   env: CLANG_VERSION="3.5" BUILD_TYPE="Debug"
 - os: linux
   compiler: clang
-  env: CLANG_VERSION="5.0" BUILD_TYPE="Debug"
-- os: linux
-  compiler: clang
   env: CLANG_VERSION="6.0" BUILD_TYPE="Debug"
 - os: linux
   compiler: clang
+  env: CLANG_VERSION="7" BUILD_TYPE="Debug"
+- os: linux
+  compiler: clang
   env: CLANG_VERSION="3.4" BUILD_TYPE="Release"
 - os: linux
   compiler: clang
   env: CLANG_VERSION="3.5" BUILD_TYPE="Release"
 - os: linux
   compiler: clang
-  env: CLANG_VERSION="5.0" BUILD_TYPE="Release"
-- os: linux
-  compiler: clang
   env: CLANG_VERSION="6.0" BUILD_TYPE="Release"
+- os: linux
+  compiler: clang
+  env: CLANG_VERSION="7" BUILD_TYPE="Release"
 ### LINUX + GCC BUILDS
 - os: linux
   compiler: gcc

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp