← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~aber/widelands/bitset into lp:widelands

 

David Allwicher has proposed merging lp:~aber/widelands/bitset into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~aber/widelands/bitset/+merge/88267

Use less shift operations and thus improve the length of the lines.
-- 
https://code.launchpad.net/~aber/widelands/bitset/+merge/88267
Your team Widelands Developers is requested to review the proposed merge of lp:~aber/widelands/bitset into lp:widelands.
=== modified file 'src/logic/building.cc'
--- src/logic/building.cc	2011-11-30 21:38:37 +0000
+++ src/logic/building.cc	2012-01-11 20:04:29 +0000
@@ -322,7 +322,7 @@
 /**
  * \return a bitfield of commands the owning player can issue for this building.
  *
- * The bits are (1 << PCap_XXX).
+ * The bits are PCap_XXX.
  * By default, all buildings can be bulldozed. If a building should not be
  * destructible, "destructible=no" must be added to buildings conf.
  */
@@ -330,12 +330,12 @@
 	uint32_t caps = 0;
 	const Building_Descr & d = descr();
 	if (d.is_destructible()) {
-		caps |= 1 << PCap_Bulldoze;
+		caps |= PCap_Bulldoze;
 		if (d.is_buildable() or d.is_enhanced())
-			caps |= 1 << PCap_Dismantle;
+			caps |= PCap_Dismantle;
 	}
 	if (d.enhancements().size())
-		caps |= 1 << PCap_Enhancable;
+		caps |= PCap_Enhancable;
 	return caps;
 }
 

=== modified file 'src/logic/building.h'
--- src/logic/building.h	2011-11-30 21:38:37 +0000
+++ src/logic/building.h	2012-01-11 20:04:29 +0000
@@ -146,9 +146,9 @@
 public:
 	// Player capabilities: which commands can a player issue for this building?
 	enum {
-		PCap_Bulldoze = 0, // can bulldoze/remove this buildings
-		PCap_Dismantle = 1, // can dismantle this buildings
-		PCap_Enhancable = 3, // can be enhanced to something
+		PCap_Bulldoze = 1, // can bulldoze/remove this buildings
+		PCap_Dismantle = 1 << 1, // can dismantle this buildings
+		PCap_Enhancable = 1 << 2, // can be enhanced to something
 	};
 
 public:

=== modified file 'src/logic/partially_finished_building.cc'
--- src/logic/partially_finished_building.cc	2011-11-30 21:38:37 +0000
+++ src/logic/partially_finished_building.cc	2012-01-11 20:04:29 +0000
@@ -135,8 +135,8 @@
 uint32_t Partially_Finished_Building::get_playercaps() const throw () {
 	uint32_t caps = Building::get_playercaps();
 
-	caps |= 1 << PCap_Bulldoze;
-	caps &= ~(1 << PCap_Dismantle);
+	caps |= PCap_Bulldoze;
+	caps &= ~PCap_Dismantle;
 
 	return caps;
 }

=== modified file 'src/logic/player.cc'
--- src/logic/player.cc	2011-11-30 21:38:37 +0000
+++ src/logic/player.cc	2012-01-11 20:04:29 +0000
@@ -507,7 +507,7 @@
 
 		// Destroy, after extended security check
 		if (upcast(Building, building, imm)) {
-			if (!(building->get_playercaps() & (1 << Building::PCap_Bulldoze)))
+			if (!(building->get_playercaps() & Building::PCap_Bulldoze))
 				return;
 
 			Flag & flag = building->base_flag();
@@ -518,11 +518,7 @@
 				bulldozelist.push_back(&flag);
 		} else if (upcast(Flag, flag, imm)) {
 			if (Building * const flagbuilding = flag->get_building())
-				if
-					(!
-					 (flagbuilding->get_playercaps() &
-					  (1 << Building::PCap_Bulldoze)))
-				{
+				if (!(flagbuilding->get_playercaps() & Building::PCap_Bulldoze)) {
 					log
 						("Player trying to rip flag (%u) with undestroyable "
 						 "building (%u)\n",

=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc	2011-11-30 21:38:37 +0000
+++ src/wui/buildingwindow.cc	2012-01-11 20:04:29 +0000
@@ -178,7 +178,7 @@
 					 UI::Box::AlignCenter);
 			}
 
-		if (m_capscache & 1 << Widelands::Building::PCap_Enhancable) {
+		if (m_capscache & Widelands::Building::PCap_Enhancable) {
 			std::set<Widelands::Building_Index> const & enhancements =
 				m_building.enhancements();
 			Widelands::Tribe_Descr const & tribe  = owner.tribe();
@@ -207,7 +207,7 @@
 				}
 		}
 
-		if (m_capscache & (1 << Widelands::Building::PCap_Bulldoze)) {
+		if (m_capscache & Widelands::Building::PCap_Bulldoze) {
 			UI::Button * destroybtn =
 				new UI::Button
 					(capsbuttons, "destroy", 0, 0, 34, 34,
@@ -221,7 +221,7 @@
 				 UI::Box::AlignCenter);
 		}
 
-		if (m_capscache & (1 << Widelands::Building::PCap_Dismantle)) {
+		if (m_capscache & Widelands::Building::PCap_Dismantle) {
 			UI::Button * dismantlebtn =
 				new UI::Button
 					(capsbuttons, "dismantle", 0, 0, 34, 34,
@@ -325,7 +325,7 @@
 */
 void Building_Window::act_dismantle()
 {
-	if (m_building.get_playercaps() & (1 << Widelands::Building::PCap_Dismantle))
+	if (m_building.get_playercaps() & Widelands::Building::PCap_Dismantle)
 		igbase().game().send_player_dismantle(m_building);
 }
 
@@ -343,7 +343,7 @@
 */
 void Building_Window::act_enhance(Widelands::Building_Index const id)
 {
-	if (m_building.get_playercaps() & (1 << Widelands::Building::PCap_Enhancable))
+	if (m_building.get_playercaps() & Widelands::Building::PCap_Enhancable)
 		igbase().game().send_player_enhance_building (m_building, id);
 
 	die();

=== modified file 'src/wui/bulldozeconfirm.cc'
--- src/wui/bulldozeconfirm.cc	2012-01-11 18:15:03 +0000
+++ src/wui/bulldozeconfirm.cc	2012-01-11 20:04:29 +0000
@@ -114,7 +114,7 @@
 		 not building  ||
 		 not iaplayer().can_act(building->owner().player_number())
 		 or not
-		 (building->get_playercaps() & (1 << Widelands::Building::PCap_Bulldoze)))
+		 (building->get_playercaps() & Widelands::Building::PCap_Bulldoze))
 		die();
 }
 
@@ -132,7 +132,7 @@
 		(todestroy &&
 		 building &&
 		 iaplayer().can_act(building->owner().player_number()) and
-		 building->get_playercaps() & (1 << Widelands::Building::PCap_Bulldoze))
+		 building->get_playercaps() & Widelands::Building::PCap_Bulldoze)
 	{
 		game.send_player_bulldoze
 			(*todestroy, get_key_state(SDLK_LCTRL) or get_key_state(SDLK_RCTRL));

=== modified file 'src/wui/fieldaction.cc'
--- src/wui/fieldaction.cc	2011-11-30 21:38:37 +0000
+++ src/wui/fieldaction.cc	2012-01-11 20:04:29 +0000
@@ -374,7 +374,7 @@
 				if
 					(!building
 					 ||
-					 building->get_playercaps() & (1 << Building::PCap_Bulldoze))
+					 building->get_playercaps() & Building::PCap_Bulldoze)
 					add_button
 						(buildbox, "rip_flag",
 						 pic_ripflag,
@@ -750,7 +750,7 @@
 	Widelands::Editor_Game_Base & egbase = ibase().egbase();
 	if (upcast(Widelands::Flag, flag, m_node.field->get_immovable())) {
 		if (Building * const building = flag->get_building()) {
-			if (building->get_playercaps() & (1 << Building::PCap_Bulldoze))
+			if (building->get_playercaps() & Building::PCap_Bulldoze)
 				show_bulldoze_confirm
 					(ref_cast<Interactive_Player, Interactive_Base>(ibase()),
 					 *building,