int SitRepPanel::NumVisibleSitrepsThisTurn() const { int count = 0; int client_empire_id = HumanClientApp::GetApp()->EmpireID(); // which empires to count sitreps for? std::vector<int> empire_ids; if (HumanClientApp::GetApp()->Empires().Lookup(client_empire_id)) { empire_ids.push_back(client_empire_id); } else { for (EmpireManager::const_iterator it = Empires().begin(); it != Empires().end(); ++it) empire_ids.push_back(it->first); } for (std::vector<int>::const_iterator empire_it = empire_ids.begin(); empire_it != empire_ids.end(); ++empire_it) { const Empire* empire = HumanClientApp::GetApp()->Empires().Lookup(*empire_it); if (!empire) continue; for (Empire::SitRepItr sitrep_it = empire->SitRepBegin(); sitrep_it != empire->SitRepEnd(); ++sitrep_it) { if (CurrentTurn() != sitrep_it->GetTurn()) continue; if (m_hidden_sitrep_templates.find(sitrep_it->GetTemplateString()) != m_hidden_sitrep_templates.end()) continue; ++count; } } return count; }
void SitRepPanel::GetTurnSitrepsFromEmpire(std::list<SitRepEntry>& append_list, int empire_id) const { // get id(s) of empires to get sitreps for std::vector<int> empire_ids; if (empire_id != ALL_EMPIRES) { if (Empires().Lookup(empire_id)) empire_ids.push_back(empire_id); } else { for (EmpireManager::iterator it = Empires().begin(); it != Empires().end(); ++it) empire_ids.push_back(it->first); } for (std::vector<int>::const_iterator it = empire_ids.begin(); it != empire_ids.end(); ++it) { const Empire* empire = Empires().Lookup(*it); if (!empire) continue; // loop through sitreps and add to current list for (Empire::SitRepItr sitrep_it = empire->SitRepBegin(); sitrep_it != empire->SitRepEnd(); ++sitrep_it) { if (!GetOptionsDB().Get<bool>("verbose-sitrep")) { if (!sitrep_it->Validate()) continue; } if (m_showing_turn != INVALID_GAME_TURN && m_showing_turn != sitrep_it->GetTurn()) continue; if (m_hidden_sitrep_templates.find(sitrep_it->GetTemplateString()) != m_hidden_sitrep_templates.end()) continue; append_list.push_back(*sitrep_it); } } }
///////////////////// // 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(); }
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; }
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; }
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(); }
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>(); }
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>(); }
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(); }
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(); }
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(); }
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(); } }
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(); }
boost::statechart::result PlayingGame::react(const Diplomacy& d) { TraceLogger(FSM) << "(HumanClientFSM) PlayingGame.Diplomacy"; DiplomaticMessage diplo_message; ExtractDiplomacyMessageData(d.m_message, diplo_message); Empires().SetDiplomaticMessage(diplo_message); return discard_event(); }
boost::statechart::result PlayingGame::react(const DiplomaticStatusUpdate& u) { TraceLogger(FSM) << "(HumanClientFSM) PlayingGame.DiplomaticStatusUpdate"; DiplomaticStatusUpdateInfo diplo_update; ExtractDiplomaticStatusMessageData(u.m_message, diplo_update); Empires().SetDiplomaticStatus(diplo_update.empire1_id, diplo_update.empire2_id, diplo_update.diplo_status); return discard_event(); }
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(); }
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(); }
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(); }
///////////////////// // PlayerListWnd // ///////////////////// PlayerListWnd::PlayerListWnd(GG::X x, GG::Y y, GG::X w, GG::Y h) : CUIWnd(UserString("PLAYERS_LIST_PANEL_TITLE"), x, y, w, h, GG::INTERACTIVE | GG::DRAGABLE | GG::ONTOP | GG::RESIZABLE | CLOSABLE), m_player_list(0) { m_player_list = new PlayerListBox(GG::X0, GG::Y0, ClientWidth(), ClientHeight()); m_player_list->SetHiliteColor(GG::CLR_ZERO); m_player_list->SetStyle(GG::LIST_NOSORT); GG::Connect(m_player_list->SelChangedSignal, &PlayerListWnd::PlayerSelectionChanged, this); GG::Connect(m_player_list->DoubleClickedSignal, &PlayerListWnd::PlayerDoubleClicked, this); GG::Connect(m_player_list->RightClickedSignal, &PlayerListWnd::PlayerRightClicked, this); AttachChild(m_player_list); boost::function<void(int, int)> update_this = boost::bind(&PlayerListWnd::Update, this); GG::Connect(Empires().DiplomaticStatusChangedSignal, update_this); GG::Connect(Empires().DiplomaticMessageChangedSignal, update_this); DoLayout(); Refresh(); }
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)); } } }
void ProductionWnd::UpdateInfoPanel() { const Empire* empire = Empires().Lookup(HumanClientApp::GetApp()->EmpireID()); if (!empire) return; const ProductionQueue& queue = empire->GetProductionQueue(); double PPs = empire->ProductionPoints(); double total_queue_cost = queue.TotalPPsSpent(); ProductionQueue::const_iterator underfunded_it = queue.UnderfundedProject(); double PPs_to_underfunded_projects = underfunded_it == queue.end() ? 0.0 : underfunded_it->allocated_pp; m_production_info_panel->Reset(PPs, total_queue_cost, queue.ProjectsInProgress(), PPs_to_underfunded_projects, queue.size()); }
int IssueBombardOrder(int ship_id, int planet_id) { int empire_id = AIClientApp::GetApp()->EmpireID(); // make sure ship_id is a ship... TemporaryPtr<const Ship> ship = GetShip(ship_id); if (!ship) { Logger().errorStream() << "AIInterface::IssueBombardOrder : passed an invalid ship_id"; return 0; } if (ship->TotalWeaponsDamage() <= 0) { Logger().errorStream() << "AIInterface::IssueBombardOrder : ship can't attack / bombard"; return 0; } if (!ship->OwnedBy(empire_id)) { Logger().errorStream() << "AIInterface::IssueBombardOrder : ship isn't owned by the order-issuing empire"; return 0; } // verify that planet exists and is occupied by another empire TemporaryPtr<const Planet> planet = GetPlanet(planet_id); if (!planet) { Logger().errorStream() << "AIInterface::IssueBombardOrder : no planet with passed planet_id"; return 0; } if (planet->OwnedBy(empire_id)) { Logger().errorStream() << "AIInterface::IssueBombardOrder : planet is already owned by the order-issuing empire"; return 0; } if (!planet->Unowned() && Empires().GetDiplomaticStatus(planet->Owner(), empire_id) != DIPLO_WAR) { Logger().errorStream() << "AIInterface::IssueBombardOrder : planet owned by an empire not at war with order-issuing empire"; return 0; } if (GetUniverse().GetObjectVisibilityByEmpire(planet_id, empire_id) < VIS_BASIC_VISIBILITY) { Logger().errorStream() << "AIInterface::IssueBombardOrder : 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) { Logger().errorStream() << "AIInterface::IssueBombardOrder : given id of ship not in a system"; return 0; } int planet_system_id = planet->SystemID(); if (ship_system_id != planet_system_id) { Logger().errorStream() << "AIInterface::IssueBombardOrder : given ids of ship and planet not in the same system"; return 0; } AIClientApp::GetApp()->Orders().IssueOrder(OrderPtr(new BombardOrder(empire_id, ship_id, planet_id))); return 1; }
void ResearchWnd::AddTechToQueueSlot(const std::string& tech_name) { if (!m_enabled) return; int empire_id = HumanClientApp::GetApp()->EmpireID(); const Empire* empire = Empires().Lookup(empire_id); if (!empire) return; const ResearchQueue& queue = empire->GetResearchQueue(); OrderSet& orders = HumanClientApp::GetApp()->Orders(); if (!queue.InQueue(tech_name)) orders.IssueOrder(OrderPtr(new ResearchQueueOrder(empire_id, tech_name, -1))); }
void ProductionWnd::DeleteQueueItem(GG::ListBox::iterator it) { if (!m_order_issuing_enabled) return; int client_empire_id = HumanClientApp::GetApp()->EmpireID(); Empire* empire = Empires().Lookup(client_empire_id); if (!empire) return; HumanClientApp::GetApp()->Orders().IssueOrder( OrderPtr(new ProductionQueueOrder(client_empire_id, std::distance(m_queue_lb->begin(), it)))); empire->UpdateProductionQueue(); }
void ProductionWnd::ChangeBuildQuantityBlockSlot(int queue_idx, int quantity, int blocksize) { if (!m_order_issuing_enabled) return; int client_empire_id = HumanClientApp::GetApp()->EmpireID(); Empire* empire = Empires().Lookup(client_empire_id); if (!empire) return; HumanClientApp::GetApp()->Orders().IssueOrder(OrderPtr( new ProductionQueueOrder(client_empire_id, queue_idx, quantity, blocksize))); empire->UpdateProductionQueue(); }
boost::statechart::result WaitingForTurnData::react(const TurnUpdate& msg) { if (TRACE_EXECUTION) Logger().debugStream() << "(HumanClientFSM) WaitingForTurnData.TurnUpdate"; ExtractMessageData(msg.m_message, Client().EmpireID(), Client().CurrentTurnRef(), Empires(), GetUniverse(), GetSpeciesManager(), Client().m_player_info); // if I am the host, do autosave if (Client().Networking().PlayerIsHost(Client().PlayerID())) Client().Autosave(); return transit<PlayingTurn>(); }
bool BuildingType::EnqueueLocation(int empire_id, int location_id) const { if (!m_enqueue_location) return ProductionLocation(empire_id, location_id); std::shared_ptr<const UniverseObject> location = GetUniverseObject(location_id); if (!location) return false; std::shared_ptr<const UniverseObject> source = Empires().GetSource(empire_id); if (!source) return false; return m_enqueue_location->Eval(ScriptingContext(source), location); }
void ModeratorActionsWnd::Refresh() { // todo: get currently selected empire, if any, reselect after refresh m_empire_drop->Clear(); for (EmpireManager::const_iterator it = Empires().begin(); it != Empires().end(); ++it) { const Empire* empire = it->second; GG::DropDownList::Row* row = new GG::DropDownList::Row(); CUILabel* label = new CUILabel(empire->Name(), GG::FORMAT_NOWRAP); label->SetTextColor(empire->Color()); row->push_back(label); m_empire_drop->Insert(row); } // no empire / monsters GG::DropDownList::Row* row = new GG::DropDownList::Row(); CUILabel* label = new CUILabel(UserString("UNOWNED"), GG::FORMAT_NOWRAP); label->SetTextColor(GG::CLR_RED); row->push_back(label); m_empire_drop->Insert(row); if (!m_empire_drop->Empty()) m_empire_drop->Select(m_empire_drop->begin()); }
boost::statechart::result WaitingForTurnData::react(const TurnUpdate& msg) { if (TRACE_EXECUTION) Logger().debugStream() << "(HumanClientFSM) WaitingForTurnData.TurnUpdate"; ExtractMessageData(msg.m_message, Client().EmpireID(), Client().CurrentTurnRef(), Empires(), GetUniverse(), GetSpeciesManager(), Client().m_player_info); // if I am the host, do autosave for (std::map<int, PlayerInfo>::const_iterator it = Client().m_player_info.begin(); it != Client().m_player_info.end(); ++it) if (it->second.host && it->first == Client().PlayerID()) Client().Autosave(); return transit<PlayingTurn>(); }
void ProductionWnd::AddBuildToQueueSlot(BuildType build_type, int design_id, int number, int location) { if (!m_order_issuing_enabled) return; int client_empire_id = HumanClientApp::GetApp()->EmpireID(); Empire* empire = Empires().Lookup(client_empire_id); if (!empire) return; HumanClientApp::GetApp()->Orders().IssueOrder(OrderPtr( new ProductionQueueOrder(client_empire_id, build_type, design_id, number, location))); empire->UpdateProductionQueue(); m_build_designator_wnd->CenterOnBuild(m_queue_lb->NumRows() - 1); }