const std::string& Fleet::PublicName(int empire_id) const { // Disclose real fleet name only to fleet owners. Rationale: a player might become suspicious if the incoming // foreign fleet is called "Decoy" if (Universe::ALL_OBJECTS_VISIBLE || empire_id == ALL_EMPIRES || OwnedBy(empire_id)) return Name(); else if (Unowned() && HasMonsters()) return UserString("MONSTERS"); else if (Unowned()) return UserString("FW_ROGUE_FLEET"); else return UserString("FW_FOREIGN_FLEET"); }
void Planet::PopGrowthProductionResearchPhase() { UniverseObject::PopGrowthProductionResearchPhase(); // do not do production if planet was just conquered if (m_just_conquered) m_just_conquered = false; else ResourceCenterPopGrowthProductionResearchPhase(); PopCenterPopGrowthProductionResearchPhase(); // check for planets with zero population. If they have any owners // then the planet has likely just starved. Regardless, resetting the // planet keeps things consistent. if (GetMeter(METER_POPULATION)->Current() == 0.0 && !Unowned()) { // generate starvation sitrep for empire that owns this depopulated planet if (Empire* empire = Empires().Lookup(this->Owner())) empire->AddSitRepEntry(CreatePlanetStarvedToDeathSitRep(this->ID())); // reset planet to empty and unowned Reset(); } else { GetMeter(METER_SHIELD)->SetCurrent(Planet::NextTurnCurrentMeterValue(METER_SHIELD)); GetMeter(METER_DEFENSE)->SetCurrent(Planet::NextTurnCurrentMeterValue(METER_SHIELD)); GetMeter(METER_TROOPS)->SetCurrent(Planet::NextTurnCurrentMeterValue(METER_SHIELD)); } StateChangedSignal(); }
bool Planet::HostileToEmpire(int empire_id) const { if (OwnedBy(empire_id)) return false; // Empire owned planets are hostile to ALL_EMPIRES if (empire_id == ALL_EMPIRES) return !Unowned(); // Unowned planets are only considered hostile if populated auto pop_meter = GetMeter(METER_TARGET_POPULATION); if (Unowned()) return pop_meter && (pop_meter->Current() != 0.0f); // both empires are normal empires return Empires().GetDiplomaticStatus(Owner(), empire_id) == DIPLO_WAR; }
const std::string& Ship::PublicName(int empire_id) const { // Disclose real ship name only to fleet owners. Rationale: a player who // doesn't know the design for a particular ship can easily guess it if the // ship's name is "Scout" // An exception is made for unowned monsters. if (GetUniverse().AllObjectsVisible() || empire_id == ALL_EMPIRES || OwnedBy(empire_id) || (IsMonster() && Owner() == ALL_EMPIRES)) return Name(); const ShipDesign* design = Design(); if (design) return design->Name(); else if (IsMonster()) return UserString("SM_MONSTER"); else if (!Unowned()) return UserString("FW_FOREIGN_SHIP"); else if (Unowned() && GetVisibility(empire_id) > VIS_NO_VISIBILITY) return UserString("FW_ROGUE_SHIP"); else return UserString("OBJ_SHIP"); }
std::string UniverseObject::Dump() const { TemporaryPtr<const System> system = GetSystem(this->SystemID()); std::stringstream os; os << boost::lexical_cast<std::string>(this->ObjectType()) << " " << this->ID() << ": " << this->Name(); if (system) { const std::string& sys_name = system->Name(); if (sys_name.empty()) os << " at: (System " << system->ID() << ")"; else os << " at: " << sys_name; } else { os << " at: (" << this->X() << ", " << this->Y() << ")"; int near_id = GetUniverse().NearestSystemTo(this->X(), this->Y()); TemporaryPtr<const System> system = GetSystem(near_id); if (system) { const std::string& sys_name = system->Name(); if (sys_name.empty()) os << " nearest (System " << system->ID() << ")"; else os << " nearest " << system->Name(); } } if (Unowned()) { os << " owner: (Unowned) "; } else { std::string empire_name = Empires().GetEmpireName(m_owner_empire_id); if (!empire_name.empty()) os << " owner: " << empire_name; else os << " owner: (Unknown Empire)"; } os << " created on turn: " << m_created_on_turn << " specials: "; for (std::map<std::string, std::pair<int, float> >::const_iterator it = m_specials.begin(); it != m_specials.end(); ++it) os << "(" << it->first << ", " << it->second.first << ", " << it->second.second << ") "; os << " Meters: "; for (std::map<MeterType, Meter>::const_iterator it = m_meters.begin(); it != m_meters.end(); ++it) os << UserString(EnumToString(it->first)) << ": " << it->second.Dump() << " "; return os.str(); }