From aae9643d4a9ffc6a5936647dd2859a0d8fdb5677 Mon Sep 17 00:00:00 2001
From: cybermind <iddqd_mail@mail.ru>
Date: Sun, 12 May 2013 14:30:06 +0600
Subject: [PATCH] [-] Fixed bug when research don't modify the stats of
 non-ready buildings

---
 src/include/unit_find.h | 2 +-
 src/unit/unit_find.cpp  | 9 +++++----
 src/unit/upgrade.cpp    | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/include/unit_find.h b/src/include/unit_find.h
index a3186b5bc..b5be40e81 100644
--- a/src/include/unit_find.h
+++ b/src/include/unit_find.h
@@ -281,7 +281,7 @@ extern CUnit *FindIdleWorker(const CPlayer &player, const CUnit *last);
 extern bool FindTerrainType(int movemask, int resmask, int range,
 							const CPlayer &player, const Vec2i &startPos, Vec2i *pos);
 
-extern void FindUnitsByType(const CUnitType &type, std::vector<CUnit *> &units);
+extern void FindUnitsByType(const CUnitType &type, std::vector<CUnit *> &units, bool everybody = false);
 
 /// Find all units of this type of the player
 extern void FindPlayerUnitsByType(const CPlayer &player, const CUnitType &type, std::vector<CUnit *> &units);
diff --git a/src/unit/unit_find.cpp b/src/unit/unit_find.cpp
index 0480d17a7..c137a1739 100644
--- a/src/unit/unit_find.cpp
+++ b/src/unit/unit_find.cpp
@@ -509,15 +509,16 @@ CUnit *FindIdleWorker(const CPlayer &player, const CUnit *last)
 /**
 **  Find all units of type.
 **
-**  @param type   type of unit requested
-**  @param units  array in which we have to store the units
+**  @param type       type of unit requested
+**  @param units      array in which we have to store the units
+**  @param everybody  if true, include all units
 */
-void FindUnitsByType(const CUnitType &type, std::vector<CUnit *> &units)
+void FindUnitsByType(const CUnitType &type, std::vector<CUnit *> &units, bool everybody)
 {
 	for (CUnitManager::Iterator it = UnitManager.begin(); it != UnitManager.end(); ++it) {
 		CUnit &unit = **it;
 
-		if (unit.Type == &type && !unit.IsUnusable()) {
+		if (unit.Type == &type && !unit.IsUnusable(everybody)) {
 			units.push_back(&unit);
 		}
 	}
diff --git a/src/unit/upgrade.cpp b/src/unit/upgrade.cpp
index ed6ebb915..4c7e62fab 100644
--- a/src/unit/upgrade.cpp
+++ b/src/unit/upgrade.cpp
@@ -597,7 +597,7 @@ static void ApplyUpgradeModifier(CPlayer &player, const CUpgradeModifier *um)
 			if (varModified) {
 				std::vector<CUnit *> unitupgrade;
 
-				FindUnitsByType(*UnitTypes[z], unitupgrade);
+				FindUnitsByType(*UnitTypes[z], unitupgrade, true);
 				for (size_t j = 0; j != unitupgrade.size(); ++j) {
 					CUnit &unit = *unitupgrade[j];