本文整理匯總了C++中Empires函數的典型用法代碼示例。如果您正苦於以下問題:C++ Empires函數的具體用法?C++ Empires怎麽用?C++ Empires使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Empires函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: CUIWnd
/////////////////////
// PlayerListWnd //
/////////////////////
PlayerListWnd::PlayerListWnd(const std::string& config_name) :
CUIWnd(UserString("PLAYERS_LIST_PANEL_TITLE"),
GG::INTERACTIVE | GG::DRAGABLE | GG::ONTOP | GG::RESIZABLE | CLOSABLE | PINABLE,
config_name),
m_player_list(nullptr)
{
m_player_list = new PlayerListBox();
m_player_list->SetHiliteColor(GG::CLR_ZERO);
m_player_list->SetStyle(GG::LIST_NOSORT);
m_player_list->SelRowsChangedSignal.connect(
boost::bind(&PlayerListWnd::PlayerSelectionChanged, this, _1));
m_player_list->DoubleClickedRowSignal.connect(
boost::bind(&PlayerListWnd::PlayerDoubleClicked, this, _1, _2, _3));
m_player_list->RightClickedRowSignal.connect(
boost::bind(&PlayerListWnd::PlayerRightClicked, this, _1, _2, _3));
AttachChild(m_player_list);
Empires().DiplomaticStatusChangedSignal.connect(
boost::bind(&PlayerListWnd::Update, this));
Empires().DiplomaticMessageChangedSignal.connect(
boost::bind(&PlayerListWnd::Update, this));
DoLayout();
Refresh();
}
示例2: Empires
int ModeratorActionsWnd::EmpireIDFromIndex(std::size_t i) const {
if (i == static_cast<std::size_t>(-1) ||
i >= static_cast<std::size_t>(Empires().NumEmpires()))
{ return ALL_EMPIRES; }
EmpireManager::const_iterator it = Empires().begin();
std::advance(it, i);
return it->first;
}
示例3: IssueGiveObjectToEmpireOrder
int IssueGiveObjectToEmpireOrder(int object_id, int recipient_id) {
int empire_id = AIClientApp::GetApp()->EmpireID();
if (Empires().Lookup(recipient_id) == 0) {
Logger().errorStream() << "AIInterface::IssueGiveObjectToEmpireOrder : given invalid recipient empire id";
return 0;
}
if (Empires().GetDiplomaticStatus(empire_id, recipient_id) != DIPLO_PEACE) {
Logger().errorStream() << "AIInterface::IssueGiveObjectToEmpireOrder : attempting to give to empire not at peace";
return 0;
}
TemporaryPtr<UniverseObject> obj = GetUniverseObject(object_id);
if (!obj) {
Logger().errorStream() << "AIInterface::IssueGiveObjectToEmpireOrder : passed invalid object id";
return 0;
}
if (!obj->OwnedBy(empire_id)) {
Logger().errorStream() << "AIInterface::IssueGiveObjectToEmpireOrder : passed object not owned by player";
return 0;
}
if (obj->ObjectType() != OBJ_FLEET && obj->ObjectType() != OBJ_PLANET) {
Logger().errorStream() << "AIInterface::IssueGiveObjectToEmpireOrder : passed object that is not a fleet or planet";
return 0;
}
TemporaryPtr<System> system = GetSystem(obj->SystemID());
if (!system) {
Logger().errorStream() << "AIInterface::IssueGiveObjectToEmpireOrder : couldn't get system of object";
return 0;
}
// can only give to empires with something present to receive the gift
bool recipient_has_something_here = false;
std::vector<TemporaryPtr<const UniverseObject> > system_objects =
Objects().FindObjects<const UniverseObject>(system->ObjectIDs());
for (std::vector<TemporaryPtr<const UniverseObject> >::const_iterator it = system_objects.begin();
it != system_objects.end(); ++it)
{
TemporaryPtr<const UniverseObject> obj = *it;
if (obj->Owner() == recipient_id) {
recipient_has_something_here = true;
break;
}
}
if (!recipient_has_something_here) {
Logger().errorStream() << "AIInterface::IssueGiveObjectToEmpireOrder : recipient empire has nothing in system";
return 0;
}
AIClientApp::GetApp()->Orders().IssueOrder(OrderPtr(
new GiveObjectToEmpireOrder(empire_id, object_id, recipient_id)));
return 1;
}
示例4: InitEmpires
void InitEmpires(const std::map<int, PlayerSetupData>& player_setup_data)
{
DebugLogger() << "Initializing " << player_setup_data.size() << " empires";
// copy empire colour table, so that individual colours can be removed after they're used
std::vector<GG::Clr> colors = EmpireColors();
// create empire objects and do some basic initilization for each player
int player_i = 0;
for (std::map<int, PlayerSetupData>::const_iterator setup_data_it = player_setup_data.begin();
setup_data_it != player_setup_data.end(); ++setup_data_it, ++player_i)
{
int player_id = setup_data_it->first;
if (player_id == Networking::INVALID_PLAYER_ID)
ErrorLogger() << "InitEmpires player id (" << player_id << ") is invalid";
// use player ID for empire ID so that the calling code can get the
// correct empire for each player ID in player_setup_data
int empire_id = player_id;
std::string player_name = setup_data_it->second.m_player_name;
GG::Clr empire_colour = setup_data_it->second.m_empire_color;
// validate or generate empire colour
// ensure no other empire gets auto-assigned this colour automatically
std::vector<GG::Clr>::iterator color_it = std::find(colors.begin(), colors.end(), empire_colour);
if (color_it != colors.end())
colors.erase(color_it);
// if no colour already set, do so automatically
if (empire_colour == GG::Clr(0, 0, 0, 0)) {
if (!colors.empty()) {
// take next colour from list
empire_colour = colors[0];
colors.erase(colors.begin());
} else {
// as a last resort, make up a colour
empire_colour = GG::FloatClr(static_cast<float>(RandZeroToOne()), static_cast<float>(RandZeroToOne()),
static_cast<float>(RandZeroToOne()), 1.0f);
}
}
// set generic default empire name
std::string empire_name = UserString("EMPIRE") + boost::lexical_cast<std::string>(empire_id);
DebugLogger() << "Universe::InitEmpires creating new empire" << " with ID: " << empire_id
<< " for player: " << player_name << " (with player id: " << player_id << ")";
// create new Empire object through empire manager
Empires().CreateEmpire(empire_id, empire_name, player_name, empire_colour);
}
Empires().ResetDiplomacy();
}
示例5: ExtractMessageData
boost::statechart::result WaitingForTurnData::react(const GameStart& msg) {
if (TRACE_EXECUTION) Logger().debugStream() << "(HumanClientFSM) WaitingForTurnData.GameStart";
bool loaded_game_data;
bool ui_data_available;
SaveGameUIData ui_data;
bool save_state_string_available;
std::string save_state_string; // ignored - used by AI but not by human client
OrderSet orders;
ExtractMessageData(msg.m_message, Client().m_single_player_game, Client().EmpireIDRef(),
Client().CurrentTurnRef(), Empires(), GetUniverse(),
GetSpeciesManager(), Client().m_player_info, orders,
loaded_game_data, ui_data_available, ui_data,
save_state_string_available, save_state_string);
Client().StartGame();
std::swap(Client().Orders(), orders); // bring back orders planned in the current turn, they will be applied later, after some basic turn initialization
if (loaded_game_data && ui_data_available)
Client().m_ui->RestoreFromSaveData(ui_data);
// if I am the host on the first turn, do an autosave. on later turns, will
// have just loaded save, so don't need to autosave. might also have just
// loaded a turn 1 autosave, but not sure how to check for that here...
if (Client().CurrentTurn() == 1 && Client().Networking().PlayerIsHost(Client().PlayerID()))
Client().Autosave();
return transit<PlayingTurn>();
}
示例6: TraceLogger
boost::statechart::result WaitingForTurnData::react(const TurnUpdate& msg) {
TraceLogger(FSM) << "(HumanClientFSM) PlayingGame.TurnUpdate";
int current_turn = INVALID_GAME_TURN;
try {
ExtractTurnUpdateMessageData(msg.m_message, Client().EmpireID(), current_turn,
Empires(), GetUniverse(), GetSpeciesManager(),
GetCombatLogManager(), GetSupplyManager(), Client().Players());
} catch (...) {
Client().GetClientUI().GetMessageWnd()->HandleLogMessage(UserString("ERROR_PROCESSING_SERVER_MESSAGE") + "\n");
return discard_event();
}
DebugLogger(FSM) << "Extracted TurnUpdate message for turn: " << current_turn;
Client().SetCurrentTurn(current_turn);
// if I am the host, do autosave
if (Client().Networking().PlayerIsHost(Client().PlayerID()))
Client().Autosave();
Client().HandleTurnUpdate();
return transit<PlayingTurn>();
}
示例7: ResourceCenterPopGrowthProductionResearchPhase
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 a species set, then
// they probably just starved
if (!SpeciesName().empty() && GetMeter(METER_POPULATION)->Current() == 0.0) {
// generate starvation sitrep for empire that owns this depopulated planet
if (Empire* empire = Empires().Lookup(this->Owner()))
empire->AddSitRepEntry(CreatePlanetStarvedToDeathSitRep(this->ID()));
// remove species
SetSpecies("");
}
GetMeter(METER_SHIELD)->SetCurrent(Planet::NextTurnCurrentMeterValue(METER_SHIELD));
GetMeter(METER_DEFENSE)->SetCurrent(Planet::NextTurnCurrentMeterValue(METER_DEFENSE));
GetMeter(METER_TROOPS)->SetCurrent(Planet::NextTurnCurrentMeterValue(METER_TROOPS));
GetMeter(METER_REBEL_TROOPS)->SetCurrent(Planet::NextTurnCurrentMeterValue(METER_REBEL_TROOPS));
StateChangedSignal();
}
示例8: Logger
void MessageWnd::HandlePlayerChatMessage(const std::string& text, int sender_player_id, int recipient_player_id) {
const ClientApp* app = ClientApp::GetApp();
if (!app) {
Logger().errorStream() << "MessageWnd::HandlePlayerChatMessage couldn't get client app!";
return;
}
const std::map<int, PlayerInfo>& players = app->Players();
std::map<int, PlayerInfo>::const_iterator player_it = players.find(sender_player_id);
if (player_it == players.end()) {
Logger().errorStream() << "MessageWnd::HandlePlayerChatMessage couldn't message sending player with id: " << sender_player_id;
return;
}
const std::string& sender_name = player_it->second.name;
const int& sender_empire_id = player_it->second.empire_id;
GG::Clr sender_colour(ClientUI::TextColor());
if (const Empire* sender_empire = Empires().Lookup(sender_empire_id))
sender_colour = sender_empire->Color();
std::string wrapped_text = RgbaTag(sender_colour) + sender_name + ": " + text + "</rgba>";
*m_display += wrapped_text + "\n";
m_display_show_time = GG::GUI::GetGUI()->Ticks();
}
示例9: ResourceCenterPopGrowthProductionResearchPhase
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();
}
示例10: OrderPtr
void ResearchWnd::QueueItemMoved(GG::ListBox::Row* row, std::size_t position) {
if (QueueRow* queue_row = boost::polymorphic_downcast<QueueRow*>(row)) {
int empire_id = HumanClientApp::GetApp()->EmpireID();
HumanClientApp::GetApp()->Orders().IssueOrder(
OrderPtr(new ResearchQueueOrder(empire_id, queue_row->tech_name, position)));
if (Empire* empire = Empires().Lookup(empire_id))
empire->UpdateResearchQueue();
}
}
示例11: ExtractMessageData
boost::statechart::result PlayingGame::react(const Diplomacy& d) {
if (TRACE_EXECUTION) DebugLogger() << "(HumanClientFSM) PlayingGame.Diplomacy";
DiplomaticMessage diplo_message;
ExtractMessageData(d.m_message, diplo_message);
Empires().SetDiplomaticMessage(diplo_message);
return discard_event();
}
示例12: UpdateProductionQueue
void UpdateProductionQueue() {
int empire_id = AIClientApp::GetApp()->EmpireID();
Empire* empire = Empires().Lookup(empire_id);
if (!empire) {
Logger().errorStream() << "AIInterface::UpdateProductionQueue : couldn't get empire with id " << empire_id;
return;
}
empire->UpdateProductionQueue();
}
示例13: ValidateEmpireID
void BombardOrder::ExecuteImpl() const {
ValidateEmpireID();
int empire_id = EmpireID();
TemporaryPtr<Ship> ship = GetShip(m_ship);
if (!ship) {
ErrorLogger() << "BombardOrder::ExecuteImpl couldn't get ship with id " << m_ship;
return;
}
if (!ship->CanBombard()) {
ErrorLogger() << "BombardOrder::ExecuteImpl got ship that can't bombard";
return;
}
if (!ship->OwnedBy(empire_id)) {
ErrorLogger() << "BombardOrder::ExecuteImpl got ship that isn't owned by the order-issuing empire";
return;
}
TemporaryPtr<Planet> planet = GetPlanet(m_planet);
if (!planet) {
ErrorLogger() << "BombardOrder::ExecuteImpl couldn't get planet with id " << m_planet;
return;
}
if (planet->OwnedBy(empire_id)) {
ErrorLogger() << "BombardOrder::ExecuteImpl given planet that is already owned by the order-issuing empire";
return;
}
if (!planet->Unowned() && Empires().GetDiplomaticStatus(planet->Owner(), empire_id) != DIPLO_WAR) {
ErrorLogger() << "BombardOrder::ExecuteImpl given planet owned by an empire not at war with order-issuing empire";
return;
}
if (GetUniverse().GetObjectVisibilityByEmpire(m_planet, empire_id) < VIS_BASIC_VISIBILITY) {
ErrorLogger() << "BombardOrder::ExecuteImpl given planet that empire reportedly has insufficient visibility of, but will be allowed to proceed pending investigation";
//return;
}
int ship_system_id = ship->SystemID();
if (ship_system_id == INVALID_OBJECT_ID) {
ErrorLogger() << "BombardOrder::ExecuteImpl given id of ship not in a system";
return;
}
int planet_system_id = planet->SystemID();
if (ship_system_id != planet_system_id) {
ErrorLogger() << "BombardOrder::ExecuteImpl given ids of ship and planet not in the same system";
return;
}
// note: multiple ships, from same or different empires, can invade the same planet on the same turn
DebugLogger() << "BombardOrder::ExecuteImpl set for ship " << m_ship << " "
<< ship->Name() << " to bombard planet " << m_planet << " " << planet->Name();
planet->SetIsAboutToBeBombarded(true);
ship->SetBombardPlanet(m_planet);
if (TemporaryPtr<Fleet> fleet = GetFleet(ship->FleetID()))
fleet->StateChangedSignal();
}
示例14: ResearchQueueOrder
void ResearchWnd::DeleteQueueItem(GG::ListBox::iterator it) {
if (!m_enabled)
return;
int empire_id = HumanClientApp::GetApp()->EmpireID();
OrderSet& orders = HumanClientApp::GetApp()->Orders();
if (QueueRow* queue_row = boost::polymorphic_downcast<QueueRow*>(*it))
orders.IssueOrder(OrderPtr(new ResearchQueueOrder(empire_id, queue_row->tech_name)));
if (Empire* empire = Empires().Lookup(empire_id))
empire->UpdateResearchQueue();
}
示例15: FindGameWords
void MessageWndEdit::FindGameWords() {
// add player and empire names
for (std::map<int, Empire*>::value_type& entry : Empires()) {
m_game_words.insert(entry.second->Name());
m_game_words.insert(entry.second->PlayerName());
}
// add system names
for (std::shared_ptr<System> system : GetUniverse().Objects().FindObjects<System>()) {
if (system->Name() != "")
m_game_words.insert(system->Name());
}
// add ship names
for (std::shared_ptr<Ship> ship : GetUniverse().Objects().FindObjects<Ship>()) {
if (ship->Name() != "")
m_game_words.insert(ship->Name());
}
// add ship design names
for (const auto& design : GetPredefinedShipDesignManager().GetOrderedShipDesigns()) {
if (!design->Name().empty())
m_game_words.insert(UserString(design->Name()));
}
// add specials names
for (const std::string& special_name : SpecialNames()) {
if (special_name != "")
m_game_words.insert(UserString(special_name));
}
// add species names
for (const std::map<std::string, Species*>::value_type& entry : GetSpeciesManager()) {
if (entry.second->Name() != "")
m_game_words.insert(UserString(entry.second->Name()));
}
// add techs names
for (const std::string& tech_name : GetTechManager().TechNames()) {
if (tech_name != "")
m_game_words.insert(UserString(tech_name));
}
// add building type names
for (const auto& entry : GetBuildingTypeManager()) {
if (entry.second->Name() != "")
m_game_words.insert(UserString(entry.second->Name()));
}
// add ship hulls
for (const auto& design : GetPredefinedShipDesignManager().GetOrderedShipDesigns()) {
if (!design->Hull().empty())
m_game_words.insert(UserString(design->Hull()));
}
// add ship parts
for (const auto& design : GetPredefinedShipDesignManager().GetOrderedShipDesigns()) {
for (const std::string& part_name : design->Parts()) {
if (part_name != "")
m_game_words.insert(UserString(part_name));
}
}
}