Skip to content

Commit

Permalink
Added a new sitrep type to disambiguate between colonization and outp…
Browse files Browse the repository at this point in the history
…osting.
  • Loading branch information
geoffthemedio committed Feb 3, 2016
1 parent 262ddac commit 0d24819
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
7 changes: 6 additions & 1 deletion default/stringtables/en.txt
Expand Up @@ -4636,10 +4636,15 @@ SITREP_PLANET_DEPOPULATED_LABEL
Planet Destroyed

SITREP_PLANET_COLONIZED
%planet% has been colonized.
%planet% has been colonized with %species%.
SITREP_PLANET_COLONIZED_LABEL
Planet Colonized

SITREP_PLANET_OUTPOSTED
%planet% had an outpost established.
SITREP_PLANET_OUTPOSTED_LABEL
Planet Outposted

SITREP_NEW_COLONY_ESTABLISHED
On %planet%: A new %species% colony has been established.
SITREP_NEW_COLONY_ESTABLISHED_LABEL
Expand Down
15 changes: 13 additions & 2 deletions server/ServerApp.cpp
Expand Up @@ -2119,19 +2119,30 @@ namespace {
if (colonize_blocked)
continue;

// before actual colonization, which deletes the colony ship, store ship info for later use with sitrep generation
TemporaryPtr<Ship> ship = GetShip(colonizing_ship_id);
if (!ship)
ErrorLogger() << "HandleColonization couldn't get ship with id " << colonizing_ship_id;
const std::string& species_name = ship ? ship->SpeciesName() : "";
float colonist_capacity = ship ? ship->ColonyCapacity() : 0.0f;


// do colonization
if (!ColonizePlanet(colonizing_ship_id, planet_id))
continue; // skip sitrep if colonization failed

// record successful colonization
newly_colonize_planet_ids.push_back(planet_id);

// sitrep about colonization
// sitrep about colonization / outposting
Empire* empire = GetEmpire(colonizing_empire_id);
if (!empire) {
ErrorLogger() << "HandleColonization couldn't get empire with id " << colonizing_empire_id;
} else {
empire->AddSitRepEntry(CreatePlanetColonizedSitRep(planet_id));
if (species_name.empty() || colonist_capacity <= 0.0f)
empire->AddSitRepEntry(CreatePlanetOutpostedSitRep(planet_id));
else
empire->AddSitRepEntry(CreatePlanetColonizedSitRep(planet_id, species_name));
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion util/SitRepEntry.cpp
Expand Up @@ -251,8 +251,15 @@ SitRepEntry CreatePlanetDepopulatedSitRep(int planet_id) {
return sitrep;
}

SitRepEntry CreatePlanetColonizedSitRep(int planet_id) {
SitRepEntry CreatePlanetColonizedSitRep(int planet_id, const std::string& species) {
SitRepEntry sitrep(UserStringNop("SITREP_PLANET_COLONIZED"), "icons/sitrep/planet_colonized.png");
sitrep.AddVariable(VarText::PLANET_ID_TAG, boost::lexical_cast<std::string>(planet_id));
sitrep.AddVariable(VarText::SPECIES_TAG, species);
return sitrep;
}

SitRepEntry CreatePlanetOutpostedSitRep(int planet_id) {
SitRepEntry sitrep(UserStringNop("SITREP_PLANET_OUTPOSTED"), "icons/sitrep/planet_colonized.png");
sitrep.AddVariable(VarText::PLANET_ID_TAG, boost::lexical_cast<std::string>(planet_id));
return sitrep;
}
Expand Down
4 changes: 3 additions & 1 deletion util/SitRepEntry.h
Expand Up @@ -55,7 +55,9 @@ FO_COMMON_API SitRepEntry CreatePlanetCapturedSitRep(int planet_id, int empire_i
FO_COMMON_API SitRepEntry CreateCombatDamagedObjectSitRep(int object_id, int combat_system_id, int empire_id);
FO_COMMON_API SitRepEntry CreateCombatDestroyedObjectSitRep(int object_id, int combat_system_id, int empire_id);
SitRepEntry CreatePlanetDepopulatedSitRep(int planet_id);
FO_COMMON_API SitRepEntry CreatePlanetColonizedSitRep(int planet_id);
FO_COMMON_API SitRepEntry CreatePlanetColonizedSitRep(int planet_id, const std::string& species);
FO_COMMON_API SitRepEntry CreatePlanetOutpostedSitRep(int planet_id);

FO_COMMON_API SitRepEntry CreateFleetArrivedAtDestinationSitRep(int system_id, int fleet_id, int recipient_empire_id);
SitRepEntry CreateEmpireEliminatedSitRep(int empire_id);
SitRepEntry CreateVictorySitRep(const std::string& reason_string, int empire_id);
Expand Down

0 comments on commit 0d24819

Please sign in to comment.