1 #ifndef _Empire_h_
2 #define _Empire_h_
3 
4 #include "PopulationPool.h"
5 #include "ProductionQueue.h"
6 #include "ResearchQueue.h"
7 #include "ResourcePool.h"
8 #include "../util/Export.h"
9 #include "../universe/Meter.h"
10 
11 #include <GG/Clr.h>
12 
13 #include <string>
14 
15 struct UnlockableItem;
16 class Building;
17 class Planet;
18 class Ship;
19 class ShipDesign;
20 class SitRepEntry;
21 class ResourcePool;
22 class UniverseObject;
23 FO_COMMON_API extern const int INVALID_DESIGN_ID;
24 FO_COMMON_API extern const int INVALID_GAME_TURN;
25 FO_COMMON_API extern const int INVALID_OBJECT_ID;
26 FO_COMMON_API extern const int ALL_EMPIRES;
27 
28 
29 /** Class to maintain the state of a single empire. In both the client and
30   * server, Empires are managed by a subclass of EmpireManager, and can be
31   * accessed from other modules by using the EmpireManager::Lookup() method to
32   * obtain a pointer. */
33 class FO_COMMON_API Empire {
34 public:
35     // EmpireManagers must be friends so that they can have access to the constructor and keep it hidden from others
36     friend class EmpireManager;
37 
38     /** \name Iterator Types */ //@{
39     typedef std::set<int>::const_iterator               SystemIDItr;
40     typedef std::vector<SitRepEntry>::const_iterator    SitRepItr;
41     //@}
42 
43     /** \name Structors */ //@{
44     Empire(const std::string& name, const std::string& player_name, int ID, const GG::Clr& color, bool authenticated);  ///< basic constructor
45     ~Empire();
46     //@}
47 
48     /** \name Accessors */ //@{
49     const std::string&  Name() const;            ///< Returns the Empire's name
50     const std::string&  PlayerName() const;      ///< Returns the Empire's player's name
51     bool                IsAuthenticated() const; ///< Returns the Empire's player's authentication status
52     int                 EmpireID() const;        ///< Returns the Empire's unique numeric ID
53     const GG::Clr&      Color() const;           ///< Returns the Empire's color
54     int                 CapitalID() const;       ///< Returns the numeric ID of the empire's capital
55 
56     /** Return an object id that is owned by the empire or INVALID_OBJECT_ID. */
57     int                 SourceID() const;
58     /** Return an object that is owned by the empire or null.*/
59     std::shared_ptr<const UniverseObject> Source() const;
60 
61     std::string Dump() const;
62 
63     /** Returns the set of Tech names available to this empire. */
64     const std::map<std::string, int>& ResearchedTechs() const;
65 
66     /** Returns the set of BuildingType names availble to this empire. */
67     const std::set<std::string>& AvailableBuildingTypes() const;
68 
69     /** Returns the set of ShipDesign IDs available for this empire to build. */
70     std::set<int> AvailableShipDesigns() const;
71 
72     const std::set<int>&            ShipDesigns() const;                ///< Returns the set of all ship design ids of this empire
73     const std::set<std::string>&    AvailableShipParts() const;         ///< Returns the set of ship part names this empire that the empire can currently build
74     const std::set<std::string>&    AvailableShipHulls() const;         ///< Returns the set of ship hull names that that the empire can currently build
75 
76     const std::string&              TopPriorityEnqueuedTech() const;
77     const std::string&              MostExpensiveEnqueuedTech() const;
78     const std::string&              LeastExpensiveEnqueuedTech() const;
79     const std::string&              MostRPSpentEnqueuedTech() const;
80     const std::string&              MostRPCostLeftEnqueuedTech() const;
81 
82     const std::string&              TopPriorityResearchableTech() const;
83     const std::string&              MostExpensiveResearchableTech() const;
84     const std::string&              LeastExpensiveResearchableTech() const;
85     const std::string&              MostRPSpentResearchableTech() const;
86     const std::string&              MostRPCostLeftResearchableTech() const;
87 
88     const Meter*                                    GetMeter(const std::string& name) const;
meter_begin()89     std::map<std::string, Meter>::const_iterator    meter_begin() const { return m_meters.begin(); }
meter_end()90     std::map<std::string, Meter>::const_iterator    meter_end() const   { return m_meters.end(); }
91 
92     const ResearchQueue&    GetResearchQueue() const;                   ///< Returns the queue of techs being or queued to be researched.
93     const ProductionQueue&  GetProductionQueue() const;                 ///< Returns the queue of items being or queued to be produced.
94 
95     bool        ResearchableTech(const std::string& name) const;        ///< Returns true iff \a name is a tech that has not been researched, and has no unresearched prerequisites.
96     float       ResearchProgress(const std::string& name) const;        ///< Returns the RPs spent towards tech \a name if it has partial research progress, or 0.0 if it is already researched.
97     bool        TechResearched(const std::string& name) const;          ///< Returns true iff this tech has been completely researched.
98     bool        HasResearchedPrereqAndUnresearchedPrereq(const std::string& name) const;    ///< Returns true iff this tech has some but not all prerequisites researched
99     TechStatus  GetTechStatus(const std::string& name) const;           ///< Returns the status (researchable, researched, unresearchable) for this tech for this
100 
101     bool        BuildingTypeAvailable(const std::string& name) const;   ///< Returns true if the given building type is known to this empire, false if it is not
102     bool        ShipDesignAvailable(const ShipDesign& design) const;    ///< Returns true iff this ship design can be built by this empire.
103     bool        ShipDesignAvailable(int ship_design_id) const;          ///< Returns true iff this ship design can be built by this empire.  If no such ship design exists, returns false
104     bool        ShipDesignKept(int ship_design_id) const;               ///< Returns true iff the given ship design id is in the set of design ids of this empire.  That is, it has been added to this empire.
105     bool        ShipPartAvailable(const std::string& name) const;       ///< Returns true iff this ship part can be built by this empire.  If no such ship part exists, returns false
106     bool        ShipHullAvailable(const std::string& name) const;       ///< Returns true iff this ship hull can be built by this empire.  If no such ship hull exists, returns false
107 
108     float       ProductionStatus(int i) const;                          ///< Returns the PPs spent towards item \a i in the build queue if it has partial progress, -1.0 if there is no such index in the production queue.
109 
110     /** Returns the total cost per item (blocksize 1) and the minimum number of
111       * turns required to produce the indicated item, or (-1.0, -1) if the item
112       * is unknown, unavailable, or invalid. */
113     std::pair<float, int>   ProductionCostAndTime(const ProductionQueue::Element& element) const;
114     std::pair<float, int>   ProductionCostAndTime(const ProductionQueue::ProductionItem& item, int location_id) const;
115 
116     bool                    ProducibleItem(BuildType build_type, int location) const;  ///< Returns true iff this empire can produce the specified item at the specified location.
117     bool                    ProducibleItem(BuildType build_type, const std::string& name, int location) const;  ///< Returns true iff this empire can produce the specified item at the specified location.
118     bool                    ProducibleItem(BuildType build_type, int design_id, int location) const;            ///< Returns true iff this empire can produce the specified item at the specified location.
119     bool                    ProducibleItem(const ProductionQueue::ProductionItem& item, int location) const;    ///< Returns true iff this empire can produce the specified item at the specified location.
120 
121     bool                    EnqueuableItem(BuildType build_type, const std::string& name, int location) const;  ///< Returns true iff this empire can enqueue the specified item at the specified location.
122     bool                    EnqueuableItem(const ProductionQueue::ProductionItem& item, int location) const;    ///< Returns true iff this empire can enqueue the specified item at the specified location.
123 
124     bool                    HasExploredSystem(int ID) const;                            ///< returns  true if the given item is in the appropriate list, false if it is not.
125 
126     bool                    Eliminated() const;                                         ///< whether this empire has lost the game
127     bool                    Won() const;                                                ///< whether this empire has won the game
128     bool                    Ready() const;                                              ///< Returns readiness status of empire
129 
130     int                     NumSitRepEntries(int turn = INVALID_GAME_TURN) const;       ///< number of entries in the SitRep.
131 
132     /** Returns distance in jumps away from each system that this empire can
133       * propagate supply. */
134     const std::map<int, float>&             SystemSupplyRanges() const;
135 
136     /** Returns set of system ids that are able to propagate supply from one
137       * system to the next, or at which supply can be delivered to fleets if
138       * supply can reach the system from elsewhere, or in which planets can
139       * exchange supply between themselves (even if not leaving the system). */
140     const std::set<int>&                    SupplyUnobstructedSystems() const;
141 
142     /** Returns true if the specified lane travel is preserved against being blockaded (i.e., the empire
143      * has in the start system at least one fleet that meets the requirements to preserve the lane (which
144      * is determined in Empire::UpdateSupplyUnobstructedSystems(). */
145     const bool                              PreservedLaneTravel(int start_system_id, int dest_system_id) const;
146 
147     const std::set<int>&                    ExploredSystems() const;    ///< returns set of ids of systems that this empire has explored
148     const std::map<int, std::set<int>>      KnownStarlanes() const;     ///< returns map from system id (start) to set of system ids (endpoints) of all starlanes known to this empire
149     const std::map<int, std::set<int>>      VisibleStarlanes() const;   ///< returns map from system id (start) to set of system ids (endpoints) of all starlanes visible to this empire this turn
150 
151     SitRepItr               SitRepBegin() const;                ///< starting iterator for sitrep entries for this empire
152     SitRepItr               SitRepEnd() const;                  ///< end iterator for sitreps
153 
154     float                   ProductionPoints() const;           ///< Returns the empire's current production point output (this is available industry not including stockpile)
155 
156     /** Returns ResourcePool for \a resource_type or 0 if no such ResourcePool
157         exists. */
158     const std::shared_ptr<ResourcePool> GetResourcePool(ResourceType resource_type) const;
159 
160     float                   ResourceStockpile(ResourceType type) const;         ///< returns current stockpiled amount of resource \a type
161     float                   ResourceOutput(ResourceType type) const;            ///< returns amount of resource \a type being generated by ResourceCenters
162     float                   ResourceAvailable(ResourceType type) const;         ///< returns amount of resource \a type immediately available.  This = production + stockpile
163 
164     const PopulationPool&   GetPopulationPool() const;                          ///< Returns PopulationPool
165     float                   Population() const;                                 ///< returns total Population of empire
166     //@}
167 
168     /** \name Mutators */ //@{
169     /** If the object with id \a id is a planet owned by this empire, sets that
170       * planet to be this empire's capital, and otherwise does nothing. */
171     void SetCapitalID(int id);
172 
173     /** Returns the meter with the indicated \a name if it exists, or nullptr. */
174     Meter* GetMeter(const std::string& name);
175     void BackPropagateMeters();
176 
177     /** Adds \a tech to the research queue, placing it before position \a pos.
178       * If \a tech is already in the queue, it is moved to \a pos, then removed
179       * from its former position.  If \a pos < 0 or queue.size() <= pos, \a tech
180       * is placed at the end of the queue. If \a tech is already available, no
181       * action is taken. */
182     void PlaceTechInQueue(const std::string& name, int pos = -1);
183     /** Removes tech with \a name from the research queue, if it is in the
184       * research queue already. */
185     void RemoveTechFromQueue(const std::string& name);
186 
187     void PauseResearch(const std::string& name);
188     void ResumeResearch(const std::string& name);
189 
190     /** Sets research progress of tech with \a name to \a progress. */
191     void SetTechResearchProgress(const std::string& name, float progress);
192 
193     /** Adds the indicated build to the production queue, placing it before
194       * position \a pos.  If \a pos < 0 or queue.size() <= pos, the build is
195       * placed at the end of the queue. */
196     void PlaceProductionOnQueue(const ProductionQueue::ProductionItem& item,
197                                 boost::uuids::uuid uuid, int number,
198                                 int blocksize, int location, int pos = -1);
199 
200     /** Adds a copy of the production item at position \a index below it in
201       * the queue, with one less quantity. Sets the quantity of the production
202       * item at position \a index to 1, retaining its incomplete progress. */
203     void SplitIncompleteProductionItem(int index, boost::uuids::uuid uuid);
204     /** Adds a copy of the production item at position \a index below it in
205       * the queue, with no progress. */
206     void DuplicateProductionItem(int index, boost::uuids::uuid uuid);
207 
208     void SetProductionQuantity(int index, int quantity);     ///< Changes the remaining number to produce for queue item \a index to \a quantity
209     void SetProductionQuantityAndBlocksize(int index, int quantity, int blocksize);   ///< Changes the remaining number and blocksize to produce for queue item \a index to \a quantity and \a blocksize
210     void SetProductionRallyPoint(int index, int rally_point_id = INVALID_OBJECT_ID);  ///< Sets the rally point for ships produced by this produce, to which they are automatically ordered to move after they are produced.
211     void MoveProductionWithinQueue(int index, int new_index);///< Moves \a tech from the production queue, if it is in the production queue already.
212     void RemoveProductionFromQueue(int index);               ///< Removes the produce at position \a index in the production queue, if such an index exists.
213     void PauseProduction(int index);                         ///< Sets the production of produce at postion \a index paused, if such an index exists
214     void ResumeProduction(int index);                        ///< Sets the production of produce at postion \a index unpaused, if such an index exists
215     void AllowUseImperialPP(int index, bool allow=true);     ///< Allows or disallows the use of the imperial stockpile for production
216 
217     void AddNewlyResearchedTechToGrantAtStartOfNextTurn(const std::string& name);    ///< Inserts the given Tech into the Empire's list of innovations. Call ApplyAddedTech to make it effective.
218     void ApplyNewTechs();                            ///< Moves all Techs from the Empire's list of innovations into the Empire's list of available technologies.
219 
220     //! Adds a given producible item (Building, Ship Hull, Ship part) to the
221     //! list of available items.
222     void UnlockItem(const UnlockableItem& item);
223 
224     void AddBuildingType(const std::string& name);   ///< Inserts the given BuildingType into the Empire's list of available BuldingTypes.
225     //! Inserts the given ShipPart into the Empire's list of available ShipPart%s.
226     void AddShipPart(const std::string& name);
227 
228     //! Inserts the given ship ShipHull into the Empire's list of available
229     //! ShipHull%s.
230     void AddShipHull(const std::string& name);
231 
232     void AddExploredSystem(int ID);                  ///< Inserts the given ID into the Empire's list of explored systems.
233 
234     /** inserts given design id into the empire's set of designs in front of next design */
235     void AddShipDesign(int ship_design_id, int next_design_id = INVALID_DESIGN_ID);
236     int AddShipDesign(ShipDesign* ship_design);     ///< inserts given ShipDesign into the Universe, adds the design's id to the Empire's set of ids, and returns the new design's id, which is INVALID_OBJECT_ID on failure.  If successful, universe takes ownership of passed ShipDesign.
237 
238     std::string NewShipName();                              ///< generates a random ship name, appending II, III, etc., to it if it has been used before by this empire
239     void Eliminate();                                ///< Marks empire as eliminated and cleans up empire after it is eliminated.  Queues are cleared, capital is reset, and other state info not relevant to an eliminated empire is cleared
240     void Win(const std::string& reason);             ///< Marks this empire as having won for this reason, and sends the appropriate sitreps
241     void SetReady(bool ready);                       ///< Marks this empire with readiness status
242 
243     /** Inserts the a pointer to given SitRep entry into the empire's sitrep list.
244      *  \warning When you call this method, you are transferring ownership
245      *  of the entry object to the Empire.
246      *  The object pointed to by 'entry' will be deallocated when
247      *  the empire's sitrep is cleared.  Be careful you do not have any
248      *  references to SitRepEntries lying around when this happens.
249      *  You \a must pass in a dynamically allocated sitrep entry */
250     void AddSitRepEntry(const SitRepEntry& entry);
251     void ClearSitRep();                              ///< Clears all sitrep entries
252 
253     void RemoveTech(const std::string& name);        ///< Removes the given Tech from the empire's list
254 
255     //! Removes a given producible item (Building, Ship Hull, Ship Part) from
256     //! the list of available items.
257     void LockItem(const UnlockableItem& item);
258 
259     void RemoveBuildingType(const std::string& name);///< Removes the given BuildingType from the empire's list
260     //! Removes the given ShipPart from the empire's list
261     void RemoveShipPart(const std::string& name);
262 
263     //! Removes the given ShipHull from the empire's list
264     void RemoveShipHull(const std::string& name);
265 
266     void RemoveShipDesign(int ship_design_id);       ///< Removes the ShipDesign with the given id from the empire's set
267 
268     /** Calculates ranges that systems can send fleet and resource supplies,
269       * using the specified st of \a known_objects as the source for supply-
270       * producing objects and systems through which it can be propagated. */
271     void UpdateSystemSupplyRanges(const std::set<int>& known_objects);
272     /** Calculates ranges that systems can send fleet and resource supplies. */
273     void UpdateSystemSupplyRanges();
274     /** Calculates systems that can propagate supply (fleet or resource) using
275       * the specified set of \a known_systems */
276     void UpdateSupplyUnobstructedSystems(const std::set<int>& known_systems, bool precombat=false);
277     /** Calculates systems that can propagate supply using this empire's own /
278       * internal list of explored systems. */
279     void UpdateSupplyUnobstructedSystems(bool precombat=false);
280     /** Updates fleet ArrivalStarlane to flag fleets of this empire that are not blockaded post-combat
281      *  must be done after *all* noneliminated empires have updated their unobstructed systems* */
282     void UpdateUnobstructedFleets();
283     /** Records, in a list of pending updates, the start_system exit lane to the specified destination as accessible to this empire*/
284     void RecordPendingLaneUpdate(int start_system_id, int dest_system_id);
285     /** Processes all the pending lane access updates.  This is managed as a two step process to avoid order-of-processing issues. */
286     void UpdatePreservedLanes();
287 
288     /** Checks for production projects that have been completed, and places them
289       * at their respective production sites.  Which projects have been
290       * completed is determined by the results of previously-called Update() on
291       * the production queue (which determines how much PP each project receives
292       * but does not actually spend them).  This function spends the PP, removes
293       * complete items from the queue and creates the results in the universe. */
294     void CheckProductionProgress();
295     /** Checks for tech projects that have been completed, and returns a vector
296       * of the techs that should be added to the known techs list. */
297     std::vector<std::string> CheckResearchProgress();
298     /** Eventually : Will check for social projects that have been completed and
299       * / or process ongoing social projects... (not sure exactly what form
300       * "social projects" will take or how they will work).  Also will update
301       * the empire's trade stockpile to account for trade production and
302       * expenditures. Currently: Deducts cost of maintenance of buildings from
303       * empire's trade stockpile */
304     void CheckTradeSocialProgress();
305 
306     void SetColor(const GG::Clr& color);                 ///< Mutator for empire color
307     void SetName(const std::string& name);               ///< Mutator for empire name
308     void SetPlayerName(const std::string& player_name);  ///< Mutator for empire's player name
309 
310     void SetResourceStockpile(ResourceType resource_type, float stockpile); ///< Sets current \a stockpile amount of indicated \a resource_type
311 
312     /** Determines ResourceCenters that can provide resources for this empire and sets
313       * the supply groups used for each ResourcePool as appropriate for each resource.
314       * call UpdateResourceSupply before calling this. */
315     void InitResourcePools();
316 
317     /** Resets production of resources and calculates allocated resources (on
318       * each item in queues and overall) for each resource by calling
319       * UpdateResearchQueue, UpdateProductionQueue, UpdateTradeSpending.  Does
320       * not actually "spend" resources, but just determines how much and on what
321       * to spend.  Actual consumption of resources, removal of items from queue,
322       * processing of finished items and population growth happens in various
323       * Check(Whatever)Progress functions. */
324     void UpdateResourcePools();
325     /** Calls Update() on empire's research queue, which recalculates the RPs
326       * spent on and number of turns left for each tech in the queue. */
327     void UpdateResearchQueue();
328     /** Calls Update() on empire's production queue, which recalculates the PPs
329       * spent on and number of turns left for each project in the queue. */
330     void UpdateProductionQueue();
331     /** Eventually: Calls appropriate subsystem Update to calculate trade spent
332       * on social projects and maintenance of buildings.  Later call to
333       * CheckTradeSocialProgress() will then have the correct allocations of
334       * trade. Currently: Sums maintenance costs of all buildings owned by
335       * empire, sets m_maintenance_total_cost */
336     void UpdateTradeSpending();
337     /** Has m_population_pool recalculate all PopCenters' and empire's total
338       * expected population growth */
339     void UpdatePopulationGrowth();
340 
341     /** Resets empire meters. */
342     void ResetMeters();
343 
344     void UpdateOwnedObjectCounters();
345 
346     void SetAuthenticated(bool authenticated = true);
347 
348     void RecordShipShotDown(const Ship& ship);
349     void RecordShipLost(const Ship& ship);
350     void RecordShipScrapped(const Ship& ship);
351     void RecordBuildingScrapped(const Building& building);
352     void RecordPlanetInvaded(const Planet& planet);
353     void RecordPlanetDepopulated(const Planet& planet);
354 
355     int TotalShipsOwned() const;
356     int TotalShipPartsOwned() const;    ///< Total number of parts for all owned ships in this empire
357     int TotalBuildingsOwned() const;
358 
359     auto SpeciesShipsOwned() const -> const std::map<std::string, int>&
360     { return m_species_ships_owned; }
361 
362     auto ShipDesignsOwned() const -> const std::map<int, int>&
363     { return m_ship_designs_owned; }
364 
365     auto ShipPartsOwned() const -> const std::map<std::string, int>&
366     { return m_ship_parts_owned; }
367 
368     auto ShipPartClassOwned() const -> const std::map<ShipPartClass, int>&
369     { return m_ship_part_class_owned; }
370 
371     auto SpeciesColoniesOwned() const -> const std::map<std::string, int>&
372     { return m_species_colonies_owned; }
373 
374     auto OutpostsOwned() const -> int
375     { return m_outposts_owned; }
376 
377     auto BuildingTypesOwned() const -> const std::map<std::string, int>&
378     { return m_building_types_owned; }
379 
380     auto EmpireShipsDestroyed() const -> const std::map<int, int>&
381     { return m_empire_ships_destroyed; }
382 
383     auto ShipDesignsDestroyed() const -> const std::map<int, int>&
384     { return m_ship_designs_destroyed; }
385 
386     auto SpeciesShipsDestroyed() const -> const std::map<std::string, int>&
387     { return m_species_ships_destroyed; }
388 
389     auto SpeciesPlanetsInvaded() const -> const std::map<std::string, int>&
390     { return m_species_planets_invaded; }
391 
392     auto ShipDesignsInProduction() const -> const std::map<int, int>&
393     { return m_ship_designs_in_production; }
394 
395     auto SpeciesShipsProduced() const -> const std::map<std::string, int>&
396     { return m_species_ships_produced; }
397 
398     auto ShipDesignsProduced() const -> const std::map<int, int>&
399     { return m_ship_designs_produced; }
400 
401     auto SpeciesShipsLost() const -> const std::map<std::string, int>&
402     { return m_species_ships_lost; }
403 
404     auto ShipDesignsLost() const -> const std::map<int, int>&
405     { return m_ship_designs_lost; }
406 
407     auto SpeciesShipsScrapped() const -> const std::map<std::string, int>&
408     { return m_species_ships_scrapped; }
409 
410     auto ShipDesignsScrapped() const -> const std::map<int, int>&
411     { return m_ship_designs_scrapped; }
412 
413     auto SpeciesPlanetsDepoped() const -> const std::map<std::string, int>&
414     { return m_species_planets_depoped; }
415 
416     auto SpeciesPlanetsBombed() const -> const std::map<std::string, int>&
417     { return m_species_planets_bombed; }
418 
419     auto BuildingTypesProduced() const -> const std::map<std::string, int>&
420     { return m_building_types_produced; }
421 
422     auto BuildingTypesScrapped() const -> const std::map<std::string, int>&
423     { return m_building_types_scrapped; }
424     //@}
425 
426     /** Processes Builditems on queues of empires other than the indicated
427       * empires, at the location with id \a location_id and, as appropriate,
428       * adds them to the build queue of the indicated empires (if it is an
429       * empire), deletes them, or leaves them on the build queue of their
430       * current empire */
431     static void ConquerProductionQueueItemsAtLocation(int location_id, int empire_id);
432 
433     mutable boost::signals2::signal<void ()>  ShipDesignsChangedSignal;
434 
435 private:
436     void Init();
437 
438     int                             m_id = ALL_EMPIRES;         ///< Empire's unique numeric id
439     std::string                     m_name;                     ///< Empire's name
440     std::string                     m_player_name;              ///< Empire's Player's name
441     /** Empire's Player's authentication flag. Set if only player with empire's player's name
442         should play this empire. */
443     bool                            m_authenticated;
444     GG::Clr                         m_color;                    ///< Empire's color
445     int                             m_capital_id = INVALID_OBJECT_ID;  ///< the ID of the empire's capital planet
446 
447     /** The source id is the id of any object owned by the empire.  It is
448         mutable so that Source() can be const and still cache its result. */
449     mutable int                     m_source_id = INVALID_OBJECT_ID;
450 
451     bool                            m_eliminated = false;       ///< Whether the empire has lost
452     std::set<std::string>           m_victories;                ///< The ways that the empire has won, if any
453 
454     std::set<std::string>           m_newly_researched_techs;                ///< names of researched but not yet effective technologies, and turns on which they were acquired.
455     std::map<std::string, int>      m_techs;                    ///< names of researched technologies, and turns on which they were acquired.
456     std::map<std::string, Meter>    m_meters;                   ///< empire meters, including ratings scales used by species to judge empires
457 
458     ResearchQueue                   m_research_queue;           ///< the queue of techs being or waiting to be researched
459     std::map<std::string, float>    m_research_progress;        ///< progress of partially-researched techs; fully researched techs are removed
460 
461     ProductionQueue                 m_production_queue;         ///< the queue of items being or waiting to be built
462 
463     std::set<std::string>           m_available_building_types; ///< list of acquired BuildingType.  These are string names referencing BuildingType objects
464     //! List of acquired ShipPart referenced by name.
465     std::set<std::string>           m_available_ship_parts;
466 
467     //! List of acquired ship ShipHull referenced by name.
468     std::set<std::string>           m_available_ship_hulls;
469 
470     std::set<int>                   m_explored_systems;         ///< systems explored by this empire
471     std::set<int>                   m_known_ship_designs;       ///< ids of ship designs in the universe that this empire knows about
472 
473     std::vector<SitRepEntry>        m_sitrep_entries;           ///< The Empire's sitrep entries
474 
475     std::map<ResourceType, std::shared_ptr<ResourcePool>>
476                                     m_resource_pools;
477     PopulationPool                  m_population_pool;
478 
479     std::map<std::string, int>      m_ship_names_used;          ///< map from name to number of times used
480 
481     std::map<std::string, int>      m_species_ships_owned;      ///< how many ships of each species does this empire currently own?
482     std::map<int, int>              m_ship_designs_owned;       ///< how many ships of each design does this empire currently own?
483 
484     //! How many ShipPart%s are currently owned, indexed by ShipPart
485     std::map<std::string, int>      m_ship_parts_owned;
486 
487     std::map<ShipPartClass, int>    m_ship_part_class_owned;    ///< how many ship parts are currently owned, indexed by ShipPartClass
488     std::map<std::string, int>      m_species_colonies_owned;   ///< how many colonies of each species does this empire currently own?
489     int                             m_outposts_owned = 0;       ///< how many uncolonized outposts does this empire currently own?
490     std::map<std::string, int>      m_building_types_owned;     ///< how many buildings does this empire currently own?
491 
492     std::map<int, int>              m_ship_designs_in_production;   ///< how many ships of each design has this empire in active production in its production queue
493 
494     std::map<int, int>              m_empire_ships_destroyed;   ///< how many ships of each empire has this empire destroyed?
495     std::map<int, int>              m_ship_designs_destroyed;   ///< how many ships of each design has this empire destroyed?
496     std::map<std::string, int>      m_species_ships_destroyed;  ///< how many ships crewed by each species has this empire destroyed?
497     std::map<std::string, int>      m_species_planets_invaded;  ///< how many planets populated by each species has this empire captured?
498 
499     std::map<std::string, int>      m_species_ships_produced;   ///< how many ships crewed by each species has this empire produced?
500     std::map<int, int>              m_ship_designs_produced;    ///< how many ships of each design has this empire produced?
501     std::map<std::string, int>      m_species_ships_lost;       ///< how mahy ships crewed by each species has this empire lost in combat?
502     std::map<int, int>              m_ship_designs_lost;        ///< how many ships of each design has this empire lost in combat?
503     std::map<std::string, int>      m_species_ships_scrapped;   ///< how many ships crewed by each species has this empire scrapped?
504     std::map<int, int>              m_ship_designs_scrapped;    ///< how many ships of each design has this empire scrapped?
505 
506     std::map<std::string, int>      m_species_planets_depoped;  ///< how many planets populated by each species have depopulated while owned by this empire?
507     std::map<std::string, int>      m_species_planets_bombed;   ///< how many planets populated by each species has this empire bombarded?
508 
509     std::map<std::string, int>      m_building_types_produced;  ///< how many buildings of each type has this empire produced?
510     std::map<std::string, int>      m_building_types_scrapped;  ///< how many buildings of each type has this empire scrapped?
511 
512     // cached calculation results, returned by reference
513     std::map<int, float>            m_supply_system_ranges;         ///< number of starlane jumps away from each system (by id) supply can be conveyed.  This is the number due to a system's contents conveying supply and is computed and set by UpdateSystemSupplyRanges
514     std::set<int>                   m_supply_unobstructed_systems;  ///< ids of system that don't block supply from flowing
515     std::map<int, std::set<int>>    m_preserved_system_exit_lanes;  ///< for each system known to this empire, the set of exit lanes preserved for fleet travel even if otherwise blockaded
516     std::map<int, std::set<int>>    m_pending_system_exit_lanes;    ///< pending updates to m_preserved_system_exit_lanes
517     bool                            m_ready = false;                ///< readiness status of empire
518 
519     friend class boost::serialization::access;
520     Empire();
521     template <typename Archive>
522     void serialize(Archive& ar, const unsigned int version);
523 };
524 
525 #endif // _Empire_h_
526