From: <geo...@us...> - 2007-12-19 06:04:58
|
Revision: 2267 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2267&view=rev Author: geoffthemedio Date: 2007-12-18 22:04:57 -0800 (Tue, 18 Dec 2007) Log Message: ----------- -Initial commit of reworked ShipDesign class. Temporary equivalents of old struct members are present as accessor functions so that the rest of the code that uses ShipDesign is relatively unaffected, but these will eventually be replaced, as appropriate. -Added "battle fleet" to every empire at start of game that contains a Mark I -Fixed missing ship images on production screen Modified Paths: -------------- trunk/FreeOrion/AI/ReferenceAI.cpp trunk/FreeOrion/Empire/Empire.cpp trunk/FreeOrion/UI/BuildDesignatorWnd.cpp trunk/FreeOrion/UI/ClientUI.cpp trunk/FreeOrion/UI/CombatWnd.cpp trunk/FreeOrion/UI/FleetWnd.cpp trunk/FreeOrion/UI/ProductionWnd.cpp trunk/FreeOrion/UI/SidePanel.cpp trunk/FreeOrion/combat/CombatSystem.cpp trunk/FreeOrion/default/eng_stringtable.txt trunk/FreeOrion/universe/Enums.h trunk/FreeOrion/universe/Ship.cpp trunk/FreeOrion/universe/ShipDesign.cpp trunk/FreeOrion/universe/ShipDesign.h trunk/FreeOrion/universe/Universe.cpp trunk/FreeOrion/util/Order.cpp Modified: trunk/FreeOrion/AI/ReferenceAI.cpp =================================================================== --- trunk/FreeOrion/AI/ReferenceAI.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/AI/ReferenceAI.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -48,10 +48,10 @@ const ShipDesign *design = ship->Design(); // give orders according to type of ship in fleet - if (design->name == "Scout") { + if (design->Name() == "Scout") { Explore(fleet); - } else if (design->name == "Colony Ship") { + } else if (design->Name() == "Colony Ship") { ColonizeSomewhere(fleet); } Modified: trunk/FreeOrion/Empire/Empire.cpp =================================================================== --- trunk/FreeOrion/Empire/Empire.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/Empire/Empire.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -356,7 +356,7 @@ { if (build_type == BT_SHIP) { const ShipDesign* ship_design = GetShipDesign(design_id); - name = ship_design->name; + name = ship_design->Name(); } else { name = "???"; } @@ -791,7 +791,7 @@ const ShipDesign* ship_design = GetShipDesign(design_id); if (!ship_design) break; - return std::make_pair(ship_design->cost, 5); // v0.3 only + return std::make_pair(ship_design->Cost(), 5); // v0.3 only } default: break; @@ -1378,7 +1378,7 @@ int ship_id = universe.Insert(ship); #if 0 const ShipDesign* ship_design = GetShipDesign(m_production_queue[i].item.design_id); - std::string ship_name(ship_design->name); + std::string ship_name(ship_design->Name()); ship_name += boost::lexical_cast<std::string>(ship_id); ship->Rename(ship_name); #else Modified: trunk/FreeOrion/UI/BuildDesignatorWnd.cpp =================================================================== --- trunk/FreeOrion/UI/BuildDesignatorWnd.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/UI/BuildDesignatorWnd.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -352,13 +352,13 @@ assert(design); turns = 5; // this is a kludge for v0.3 only boost::tie(cost_per_turn, turns) = empire->ProductionCostAndTime(BT_SHIP, m_item_design_id); - item_name_str = design->name; + item_name_str = design->Name(); description_str = str(format(UserString("PRODUCTION_DETAIL_SHIP_DESCRIPTION_STR")) - % design->description - % design->attack - % design->defense - % design->speed); - graphic = ClientUI::GetTexture(ClientUI::ArtDir() / design->graphic); + % design->Description() + % design->Attack() + % design->Defense() + % design->Speed()); + graphic = ClientUI::GetTexture(ClientUI::ArtDir() / design->Graphic()); } else if (m_build_type == BT_ORBITAL) { turns = DEFENSE_BASE_BUILD_TURNS; cost_per_turn = DEFENSE_BASE_BUILD_COST; @@ -812,12 +812,12 @@ // icon GG::StaticGraphic* icon = new GG::StaticGraphic(0, 0, icon_col_width, row_height, - ClientUI::GetTexture(ClientUI::ArtDir() / ship_design->graphic), + ClientUI::GetTexture(ClientUI::ArtDir() / ship_design->Graphic()), GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); row->push_back(dynamic_cast<GG::Control*>(icon)); // ship design name - row->push_back(ship_design->name, default_font, ClientUI::TextColor()); + row->push_back(ship_design->Name(), default_font, ClientUI::TextColor()); // cost / turn, and minimum production turns const std::pair<double, int> cost_time = empire->ProductionCostAndTime(BT_SHIP, ship_design_id); Modified: trunk/FreeOrion/UI/ClientUI.cpp =================================================================== --- trunk/FreeOrion/UI/ClientUI.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/UI/ClientUI.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -94,7 +94,7 @@ boost::shared_ptr<GG::Texture> ClientUI::ShipIcon(int design_id) { const ShipDesign* design = GetShipDesign(design_id); - boost::shared_ptr<GG::Texture> texture = ClientUI::GetTexture(ArtDir() / "icons" / (design->name + ".png"), true); + boost::shared_ptr<GG::Texture> texture = ClientUI::GetTexture(ArtDir() / design->Graphic(), true); if (texture) return texture; return ClientUI::GetTexture(ArtDir() / "icons" / "Scout.png", true); } Modified: trunk/FreeOrion/UI/CombatWnd.cpp =================================================================== --- trunk/FreeOrion/UI/CombatWnd.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/UI/CombatWnd.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -19,129 +19,124 @@ } } -class CombatInfoControl : public GG::Control -{ - public: - CombatInfoControl(int w, int h,const CombatUpdateMessage &combat_info) : +class CombatInfoControl : public GG::Control { +public: + CombatInfoControl(int w, int h, const CombatUpdateMessage& combat_info) : Control(0, 0, w, h, GG::Flags<GG::WndFlag>()), m_combat_info(combat_info) {} - void Update(const CombatUpdateMessage &combat_info) {m_combat_info=combat_info;} + void Update(const CombatUpdateMessage &combat_info) {m_combat_info = combat_info;} virtual void Render() { - const int ITEM_WIDTH = 230; - const GG::Rect item_txt[4] ={GG::Rect( 7,27,100,45), - GG::Rect( 4,84, 81,99), - GG::Rect(124,49,205,67), - GG::Rect(124,78,205,96)}, - item_img_topic ( 24,48,24+40,48+40), - item_img_arrow_split ( 65,40,65+64,40+64), - rc_txt_empire ( 25, 6,500,19); - const GG::Clr border_color = GG::FloatClr(0.5f,0.5f,0.5f,1.0f); - const GG::Clr bg_color = GG::FloatClr(0.25f,0.25f,0.25f,1.0f); - const GG::Clr bg_item_color = GG::FloatClr(0.15f,0.15f,0.15f,1.0f); + const int ITEM_WIDTH = 230; + const GG::Rect item_txt[4] = {GG::Rect( 7,27,100,45), + GG::Rect( 4,84, 81,99), + GG::Rect(124,49,205,67), + GG::Rect(124,78,205,96)}, + item_img_topic ( 24,48,24+40,48+40), + item_img_arrow_split ( 65,40,65+64,40+64), + rc_txt_empire ( 25, 6,500,19); + const GG::Clr border_color = GG::FloatClr(0.5f,0.5f,0.5f,1.0f); + const GG::Clr bg_color = GG::FloatClr(0.25f,0.25f,0.25f,1.0f); + const GG::Clr bg_item_color = GG::FloatClr(0.15f,0.15f,0.15f,1.0f); - GG::Pt ul(UpperLeft()),lr(LowerRight()); - GG::FlatRectangle(ul.x+1,ul.y+1,lr.x,lr.y,bg_color,border_color,2); + GG::Pt ul(UpperLeft()),lr(LowerRight()); + GG::FlatRectangle(ul.x+1,ul.y+1,lr.x,lr.y,bg_color,border_color,2); - boost::shared_ptr<GG::Font> font = HumanClientApp::GetApp()->GetFont(ClientUI::Font(), static_cast<int>(ClientUI::Pts()*1.0)); - GG::Flags<GG::TextFormat> format = GG::FORMAT_LEFT | GG::FORMAT_VCENTER; - std::string text; + boost::shared_ptr<GG::Font> font = HumanClientApp::GetApp()->GetFont(ClientUI::Font(), static_cast<int>(ClientUI::Pts()*1.0)); + GG::Flags<GG::TextFormat> format = GG::FORMAT_LEFT | GG::FORMAT_VCENTER; + std::string text; - GG::SubTexture img_topic[3],img_ship_civil,img_planet,img_arrow_split; + GG::SubTexture img_topic[3], img_ship_civil, img_planet, img_arrow_split; - img_topic[0] = GetSubTexture(ClientUI::ArtDir() / "misc" / "mark2icon.png"); - img_topic[1] = GetSubTexture(ClientUI::ArtDir() / "misc" / "colonyicon.png"); - img_topic[2] = GetSubTexture(ClientUI::ArtDir() / "icons" / "colonymarker.png"); - img_arrow_split = GetSubTexture(ClientUI::ArtDir() / "misc" / "forkedarrow.png"); + img_topic[0] = GetSubTexture(ClientUI::ArtDir() / "misc" / "mark2icon.png"); + img_topic[1] = GetSubTexture(ClientUI::ArtDir() / "misc" / "colonyicon.png"); + img_topic[2] = GetSubTexture(ClientUI::ArtDir() / "icons" / "colonymarker.png"); + img_arrow_split = GetSubTexture(ClientUI::ArtDir() / "misc" / "forkedarrow.png"); - int y=ul.y; + int y = ul.y; - GG::Rect rc; + GG::Rect rc; - rc = GG::Rect(ul+GG::Pt(20,5),ul+GG::Pt(500,25)); - font = HumanClientApp::GetApp()->GetFont(ClientUI::Font(), static_cast<int>(ClientUI::Pts()*1.0)); - glColor(ClientUI::TextColor()); - format = GG::FORMAT_LEFT | GG::FORMAT_BOTTOM; - font->RenderText(rc.UpperLeft(),rc.LowerRight(),UserString("COMBAT_BATTLE"), format, 0); + rc = GG::Rect(ul+GG::Pt(20,5),ul+GG::Pt(500,25)); + font = HumanClientApp::GetApp()->GetFont(ClientUI::Font(), static_cast<int>(ClientUI::Pts()*1.0)); + glColor(ClientUI::TextColor()); + format = GG::FORMAT_LEFT | GG::FORMAT_BOTTOM; + font->RenderText(rc.UpperLeft(),rc.LowerRight(),UserString("COMBAT_BATTLE"), format, 0); - rc = GG::Rect(ul+GG::Pt(20+50,5),ul+GG::Pt(500,28)); - font = HumanClientApp::GetApp()->GetFont(ClientUI::Font(), static_cast<int>(ClientUI::Pts()*1.7)); - glColor(ClientUI::TextColor()); - format = GG::FORMAT_LEFT | GG::FORMAT_BOTTOM; - font->RenderText(rc.UpperLeft(),rc.LowerRight(),boost::io::str(boost::format(UserString("COMBAT_SYSTEM")) % m_combat_info.m_system), format, 0); + rc = GG::Rect(ul+GG::Pt(20+50,5),ul+GG::Pt(500,28)); + font = HumanClientApp::GetApp()->GetFont(ClientUI::Font(), static_cast<int>(ClientUI::Pts()*1.7)); + glColor(ClientUI::TextColor()); + format = GG::FORMAT_LEFT | GG::FORMAT_BOTTOM; + font->RenderText(rc.UpperLeft(),rc.LowerRight(),boost::io::str(boost::format(UserString("COMBAT_SYSTEM")) % m_combat_info.m_system), format, 0); - for(unsigned int i=0;i<m_combat_info.m_opponents.size();i++,y+=font->Height()+2) - { - CombatUpdateMessage::EmpireCombatInfo *eci = &m_combat_info.m_opponents[i]; + for (unsigned int i = 0; i < m_combat_info.m_opponents.size(); i++, y += font->Height()+2) { + CombatUpdateMessage::EmpireCombatInfo *eci = &m_combat_info.m_opponents[i]; - GG::Rect area (ul.x+20,ul.y+30+i*110,ul.x+20+ITEM_WIDTH*3,ul.y+30+(i+1)*110-5); - struct - { - std::string txt; - GG::Flags<GG::TextFormat> format; - GG::Clr bg_clr; - GG::Clr border_clr; - unsigned int border_width; - } entries[3][4] = - { - { - {UserString("COMBAT_MILITARY_SHIPS") ,GG::FORMAT_CENTER | GG::FORMAT_VCENTER,GG::CLR_BLACK ,border_color ,1}, - {boost::lexical_cast<std::string>(eci->combat_ships ) + UserString("COMBAT_REMAINING"),GG::FORMAT_CENTER | GG::FORMAT_VCENTER,GG::CLR_ZERO ,GG::CLR_ZERO ,0}, - {boost::lexical_cast<std::string>(eci->combat_ships_retreated) + UserString("COMBAT_RETREATED"),GG::FORMAT_LEFT | GG::FORMAT_VCENTER,(0==eci->combat_ships_retreated)?GG::CLR_ZERO:GG::CLR_ZERO ,GG::CLR_ZERO ,0}, - {boost::lexical_cast<std::string>(eci->combat_ships_destroyed) + UserString("COMBAT_DESTROYED"),GG::FORMAT_LEFT | GG::FORMAT_VCENTER,(0==eci->combat_ships_destroyed)?GG::CLR_ZERO:GG::CLR_RED ,GG::CLR_ZERO ,0} - }, - { - {UserString("COMBAT_CIVILIAN_SHIPS") ,GG::FORMAT_CENTER | GG::FORMAT_VCENTER,GG::CLR_BLACK ,border_color ,1}, - {boost::lexical_cast<std::string>(eci->non_combat_ships )+UserString("COMBAT_REMAINING") ,GG::FORMAT_CENTER | GG::FORMAT_VCENTER,(0==0)?GG::CLR_ZERO:GG::CLR_ZERO ,GG::CLR_ZERO ,0}, - {boost::lexical_cast<std::string>(eci->non_combat_ships_retreated)+UserString("COMBAT_RETREATED") ,GG::FORMAT_LEFT | GG::FORMAT_VCENTER,(0==eci->non_combat_ships_retreated)?GG::CLR_ZERO : GG::Clr(128,64,64,255) ,GG::CLR_ZERO ,0}, - {boost::lexical_cast<std::string>(eci->non_combat_ships_destroyed)+UserString("COMBAT_DESTROYED") ,GG::FORMAT_LEFT | GG::FORMAT_VCENTER,(0==eci->non_combat_ships_destroyed)?GG::CLR_ZERO : GG::CLR_RED ,GG::CLR_ZERO ,0} - }, - { - {UserString("COMBAT_PLANETS") ,GG::FORMAT_CENTER | GG::FORMAT_VCENTER,GG::CLR_BLACK ,border_color ,1}, - {boost::lexical_cast<std::string>(eci->planets )+UserString("COMBAT_REMAINING") ,GG::FORMAT_CENTER | GG::FORMAT_VCENTER,(0==0)?GG::CLR_ZERO:GG::CLR_ZERO ,GG::CLR_ZERO ,0}, - {boost::lexical_cast<std::string>(eci->planets_defenseless)+UserString("COMBAT_DEFENSELESS") ,GG::FORMAT_LEFT | GG::FORMAT_VCENTER,(0==eci->planets_defenseless)?GG::CLR_ZERO:GG::CLR_ZERO ,GG::CLR_ZERO ,0}, - {boost::lexical_cast<std::string>(eci->planets_lost )+UserString("COMBAT_LOST") ,GG::FORMAT_LEFT | GG::FORMAT_VCENTER,(0==eci->planets_lost )?GG::CLR_ZERO:GG::CLR_RED ,GG::CLR_ZERO ,0} - } - }; - - GG::FlatRectangle(area.Left(), area.Top(), area.Right()+2, area.Bottom(),bg_item_color,border_color, 2); + GG::Rect area (ul.x+20,ul.y+30+i*110,ul.x+20+ITEM_WIDTH*3,ul.y+30+(i+1)*110-5); + struct { + std::string txt; + GG::Flags<GG::TextFormat> format; + GG::Clr bg_clr; + GG::Clr border_clr; + unsigned int border_width; + } entries[3][4] = + { + { + {UserString("COMBAT_MILITARY_SHIPS") ,GG::FORMAT_CENTER | GG::FORMAT_VCENTER,GG::CLR_BLACK ,border_color ,1}, + {boost::lexical_cast<std::string>(eci->combat_ships ) + UserString("COMBAT_REMAINING"),GG::FORMAT_CENTER | GG::FORMAT_VCENTER,GG::CLR_ZERO ,GG::CLR_ZERO ,0}, + {boost::lexical_cast<std::string>(eci->combat_ships_retreated) + UserString("COMBAT_RETREATED"),GG::FORMAT_LEFT | GG::FORMAT_VCENTER,(0==eci->combat_ships_retreated)?GG::CLR_ZERO:GG::CLR_ZERO ,GG::CLR_ZERO ,0}, + {boost::lexical_cast<std::string>(eci->combat_ships_destroyed) + UserString("COMBAT_DESTROYED"),GG::FORMAT_LEFT | GG::FORMAT_VCENTER,(0==eci->combat_ships_destroyed)?GG::CLR_ZERO:GG::CLR_RED ,GG::CLR_ZERO ,0} + }, + { + {UserString("COMBAT_CIVILIAN_SHIPS") ,GG::FORMAT_CENTER | GG::FORMAT_VCENTER,GG::CLR_BLACK ,border_color ,1}, + {boost::lexical_cast<std::string>(eci->non_combat_ships )+UserString("COMBAT_REMAINING") ,GG::FORMAT_CENTER | GG::FORMAT_VCENTER,(0==0)?GG::CLR_ZERO:GG::CLR_ZERO ,GG::CLR_ZERO ,0}, + {boost::lexical_cast<std::string>(eci->non_combat_ships_retreated)+UserString("COMBAT_RETREATED") ,GG::FORMAT_LEFT | GG::FORMAT_VCENTER,(0==eci->non_combat_ships_retreated)?GG::CLR_ZERO : GG::Clr(128,64,64,255) ,GG::CLR_ZERO ,0}, + {boost::lexical_cast<std::string>(eci->non_combat_ships_destroyed)+UserString("COMBAT_DESTROYED") ,GG::FORMAT_LEFT | GG::FORMAT_VCENTER,(0==eci->non_combat_ships_destroyed)?GG::CLR_ZERO : GG::CLR_RED ,GG::CLR_ZERO ,0} + }, + { + {UserString("COMBAT_PLANETS") ,GG::FORMAT_CENTER | GG::FORMAT_VCENTER,GG::CLR_BLACK ,border_color ,1}, + {boost::lexical_cast<std::string>(eci->planets )+UserString("COMBAT_REMAINING") ,GG::FORMAT_CENTER | GG::FORMAT_VCENTER,(0==0)?GG::CLR_ZERO:GG::CLR_ZERO ,GG::CLR_ZERO ,0}, + {boost::lexical_cast<std::string>(eci->planets_defenseless)+UserString("COMBAT_DEFENSELESS") ,GG::FORMAT_LEFT | GG::FORMAT_VCENTER,(0==eci->planets_defenseless)?GG::CLR_ZERO:GG::CLR_ZERO ,GG::CLR_ZERO ,0}, + {boost::lexical_cast<std::string>(eci->planets_lost )+UserString("COMBAT_LOST") ,GG::FORMAT_LEFT | GG::FORMAT_VCENTER,(0==eci->planets_lost )?GG::CLR_ZERO:GG::CLR_RED ,GG::CLR_ZERO ,0} + } + }; + + GG::FlatRectangle(area.Left(), area.Top(), area.Right()+2, area.Bottom(),bg_item_color,border_color, 2); - font = HumanClientApp::GetApp()->GetFont(ClientUI::Font(), static_cast<int>(ClientUI::Pts()*1.2)); + font = HumanClientApp::GetApp()->GetFont(ClientUI::Font(), static_cast<int>(ClientUI::Pts()*1.2)); - rc = GG::Rect(area.UpperLeft()+rc_txt_empire.UpperLeft(),area.UpperLeft()+rc_txt_empire.LowerRight()); - glColor(ClientUI::TextColor());format = GG::FORMAT_LEFT | GG::FORMAT_VCENTER; - font->RenderText(rc.UpperLeft(),rc.LowerRight(),m_combat_info.m_opponents[i].empire, format, 0); + rc = GG::Rect(area.UpperLeft()+rc_txt_empire.UpperLeft(),area.UpperLeft()+rc_txt_empire.LowerRight()); + glColor(ClientUI::TextColor());format = GG::FORMAT_LEFT | GG::FORMAT_VCENTER; + font->RenderText(rc.UpperLeft(),rc.LowerRight(),m_combat_info.m_opponents[i].empire, format, 0); - for(unsigned int c=0;c<3;c++) - { - GG::Rect col (area.Left()+c*ITEM_WIDTH, area.Top(),area.Left()+(c+1)*ITEM_WIDTH, area.Bottom()); - - GG::FlatRectangle(col.Left(), col.Top()+38, col.Right()+2, col.Bottom(), GG::CLR_ZERO,border_color, 2); - glColor(ClientUI::TextColor()); + for (unsigned int c = 0; c < 3; c++) { + GG::Rect col (area.Left()+c*ITEM_WIDTH, area.Top(),area.Left()+(c+1)*ITEM_WIDTH, area.Bottom()); + + GG::FlatRectangle(col.Left(), col.Top()+38, col.Right()+2, col.Bottom(), GG::CLR_ZERO,border_color, 2); + glColor(ClientUI::TextColor()); - img_topic[c] .OrthoBlit(col.UpperLeft()+item_img_topic .UpperLeft(),col.UpperLeft()+item_img_topic .LowerRight()); - img_arrow_split .OrthoBlit(col.UpperLeft()+item_img_arrow_split.UpperLeft(),col.UpperLeft()+item_img_arrow_split.LowerRight()); + img_topic[c] .OrthoBlit(col.UpperLeft()+item_img_topic .UpperLeft(),col.UpperLeft()+item_img_topic .LowerRight()); + img_arrow_split .OrthoBlit(col.UpperLeft()+item_img_arrow_split.UpperLeft(),col.UpperLeft()+item_img_arrow_split.LowerRight()); - font = HumanClientApp::GetApp()->GetFont(ClientUI::Font(), static_cast<int>(ClientUI::Pts()*1.0)); - for(unsigned int j=0;j<4;j++) - { - rc = GG::Rect(col.UpperLeft()+item_txt[j].UpperLeft(),col.UpperLeft()+item_txt[j].LowerRight()); - GG::FlatRectangle(rc.Left(), rc.Top(), rc.Right(), rc.Bottom(),entries[c][j].bg_clr,entries[c][j].border_clr,entries[c][j].border_width); - glColor(ClientUI::TextColor()); - font->RenderText(rc.UpperLeft(),rc.LowerRight(),entries[c][j].txt, entries[c][j].format, 0); - } + font = HumanClientApp::GetApp()->GetFont(ClientUI::Font(), static_cast<int>(ClientUI::Pts()*1.0)); + for (unsigned int j = 0; j < 4; j++) { + rc = GG::Rect(col.UpperLeft()+item_txt[j].UpperLeft(),col.UpperLeft()+item_txt[j].LowerRight()); + GG::FlatRectangle(rc.Left(), rc.Top(), rc.Right(), rc.Bottom(),entries[c][j].bg_clr,entries[c][j].border_clr,entries[c][j].border_width); + glColor(ClientUI::TextColor()); + font->RenderText(rc.UpperLeft(),rc.LowerRight(),entries[c][j].txt, entries[c][j].format, 0); + } + } } - } } const std::string& System() const {return m_combat_info.m_system;} - private: + +private: CombatUpdateMessage m_combat_info; - }; struct CombatInfoRow : public GG::ListBox::Row @@ -161,33 +156,28 @@ // CombatWnd //////////////////////////////////////////////// CombatWnd::CombatWnd(int x,int y) - : CUIWnd(UserString("COMBAT_WINDOW_TITLE"),x,y, WIDTH, HEIGHT, GG::ONTOP | GG::CLICKABLE | GG::DRAGABLE | GG::RESIZABLE | MINIMIZABLE) +: CUIWnd(UserString("COMBAT_WINDOW_TITLE"), x, y, WIDTH, HEIGHT, GG::ONTOP | GG::CLICKABLE | GG::DRAGABLE | GG::RESIZABLE | MINIMIZABLE) { - m_combats_lb = new CUIListBox(0,0,ClientWidth(),ClientHeight(),GG::CLR_ZERO,GG::CLR_ZERO); - AttachChild(m_combats_lb); + m_combats_lb = new CUIListBox(0, 0, ClientWidth(), ClientHeight(), GG::CLR_ZERO, GG::CLR_ZERO); + AttachChild(m_combats_lb); } CombatWnd::~CombatWnd( ) -{ -} +{} -void CombatWnd::UpdateCombatTurnProgress(const std::string& message) -{ - std::stringstream stream(message); - XMLDoc doc; - doc.ReadDoc(stream); +void CombatWnd::UpdateCombatTurnProgress(const std::string& message) { + std::stringstream stream(message); + XMLDoc doc; + doc.ReadDoc(stream); - CombatUpdateMessage msg(doc.root_node.Child("combat-update-message")); - int r; - for(r=0;r<m_combats_lb->NumRows();r++) - if(static_cast<CombatInfoRow&>(m_combats_lb->GetRow(r)).System()==msg.m_system) - { - static_cast<CombatInfoRow&>(m_combats_lb->GetRow(r)).Update(msg); - break; - } + CombatUpdateMessage msg(doc.root_node.Child("combat-update-message")); + int r; + for (r = 0; r < m_combats_lb->NumRows(); r++) + if (static_cast<CombatInfoRow&>(m_combats_lb->GetRow(r)).System() == msg.m_system) { + static_cast<CombatInfoRow&>(m_combats_lb->GetRow(r)).Update(msg); + break; + } - if(r>=m_combats_lb->NumRows()) - m_combats_lb->Insert(new CombatInfoRow(m_combats_lb->Width() - ClientUI::ScrollWidth(),msg)); - - + if (r >= m_combats_lb->NumRows()) + m_combats_lb->Insert(new CombatInfoRow(m_combats_lb->Width() - ClientUI::ScrollWidth(), msg)); } Modified: trunk/FreeOrion/UI/FleetWnd.cpp =================================================================== --- trunk/FreeOrion/UI/FleetWnd.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/UI/FleetWnd.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -159,7 +159,7 @@ std::string design_name; const ShipDesign* design = m_ship->Design(); if (design) { - design_name = design->name; + design_name = design->Name(); std::string::size_type space = design_name.find(' '); if (space != std::string::npos) { design_name[space] = '_'; @@ -178,7 +178,7 @@ SetShipIcon(); m_ship_name_text->SetText(m_ship->Name()); - m_ship_strength_stat->SetValue(design ? design->attack : UNKNOWN_UI_DISPLAY_VALUE); + m_ship_strength_stat->SetValue(design ? design->Attack() : UNKNOWN_UI_DISPLAY_VALUE); const int ICON_SPACING = 5; const int ICON_SZ = Height() - SHIP_NAME_HT - 1; @@ -195,7 +195,7 @@ DeleteChild(m_damage_stat); m_damage_stat = 0; } - if (m_ship->Design() && design->colonize) { + if (m_ship->Design() && design->Colonize()) { if (!m_colonizer_icon) { m_colonizer_icon = new GG::StaticGraphic(x_position, SHIP_NAME_HT, ICON_SZ, ICON_SZ, ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "colonymarker.png"), @@ -426,7 +426,7 @@ const ShipDesign* design = ship->Design(); std::string design_name; if (design) { - design_name = design->name; + design_name = design->Name(); std::string::size_type space = design_name.find(' '); if (space != std::string::npos) { design_name[space] = '_'; @@ -460,9 +460,9 @@ Ship* ship = GetUniverse().Object<Ship>(*it); const ShipDesign* design = ship->Design(); if (design) { - if (design->colonize) + if (design->Colonize()) contains_colony_ship = true; - attack_strength += design->attack; + attack_strength += design->Attack(); attack_factor_unknown = false; } // TODO: account for damaged ships once damage system is in place @@ -900,7 +900,7 @@ { Ship* ship = GetUniverse().Object<Ship>(ship_id); const ShipDesign* design = ship->Design(); - return UserString("FW_SHIP_CLASS") + " \"" + (design ? design->name : UserString("FW_UNKNOWN_DESIGN_NAME")) + "\""; + return UserString("FW_SHIP_CLASS") + " \"" + (design ? design->Name() : UserString("FW_UNKNOWN_DESIGN_NAME")) + "\""; } Modified: trunk/FreeOrion/UI/ProductionWnd.cpp =================================================================== --- trunk/FreeOrion/UI/ProductionWnd.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/UI/ProductionWnd.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -186,7 +186,7 @@ name_text = UserString(build.item.name); } else if (build.item.build_type == BT_SHIP) { graphic = ClientUI::ShipIcon(build.item.design_id); - name_text = GetShipDesign(build.item.design_id)->name; + name_text = GetShipDesign(build.item.design_id)->Name(); } else if (build.item.build_type == BT_ORBITAL) { graphic = ClientUI::GetTexture(ClientUI::ArtDir() / "misc" / "base1.png"); // this is a kludge for v0.3 only name_text = UserString(build.item.name); Modified: trunk/FreeOrion/UI/SidePanel.cpp =================================================================== --- trunk/FreeOrion/UI/SidePanel.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/UI/SidePanel.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -652,7 +652,7 @@ continue; } - if (design->colonize) return s; + if (design->Colonize()) return s; } } return 0; // no ships found... Modified: trunk/FreeOrion/combat/CombatSystem.cpp =================================================================== --- trunk/FreeOrion/combat/CombatSystem.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/combat/CombatSystem.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -153,13 +153,13 @@ eci.non_combat_ships_destroyed = 0; for(unsigned int i = 0;i<empire_combat_forces[e].destroyed_ships.size();i++) - if(empire_combat_forces[e].destroyed_ships[i]->Design()->attack>0) + if(empire_combat_forces[e].destroyed_ships[i]->Design()->Attack()>0) eci.combat_ships_destroyed++; else eci.non_combat_ships_destroyed++; for(unsigned int i = 0;i<empire_combat_forces[e].retreated_ships.size();i++) - if(empire_combat_forces[e].retreated_ships[i]->Design()->attack>0) + if(empire_combat_forces[e].retreated_ships[i]->Design()->Attack()>0) eci.combat_ships_retreated++; else eci.non_combat_ships_retreated++; @@ -204,9 +204,9 @@ Ship *shp = GetUniverse().Object<Ship>(*shp_it); if(shp->IsArmed()) - cahp.combat_ships .push_back(std::pair<Ship*,unsigned int> (shp,shp->Design()->defense)); + cahp.combat_ships .push_back(std::pair<Ship*,unsigned int> (shp,shp->Design()->Defense())); else - cahp.non_combat_ships.push_back(std::pair<Ship*,unsigned int> (shp,shp->Design()->defense)); + cahp.non_combat_ships.push_back(std::pair<Ship*,unsigned int> (shp,shp->Design()->Defense())); } } for(unsigned int i=0; i<assets[e].planets.size(); i++) @@ -271,7 +271,7 @@ { Ship *shp = empire_combat_forces[e].combat_ships[i].first; - damage_done[e] += small_int_dist()%(shp->Design()->attack+1); + damage_done[e] += small_int_dist() % (static_cast<int>(shp->Design()->Attack()) + 1); } #ifdef DEBUG_COMBAT Modified: trunk/FreeOrion/default/eng_stringtable.txt =================================================================== --- trunk/FreeOrion/default/eng_stringtable.txt 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/default/eng_stringtable.txt 2007-12-19 06:04:57 UTC (rev 2267) @@ -1188,6 +1188,9 @@ FW_HOME_FLEET Home Fleet +FW_BATTLE_FLEET +Battle Fleet + # the name that is used for fleets the player does not control FW_FOREIGN_FLEET Foreign fleet Modified: trunk/FreeOrion/universe/Enums.h =================================================================== --- trunk/FreeOrion/universe/Enums.h 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/universe/Enums.h 2007-12-19 06:04:57 UTC (rev 2267) @@ -438,6 +438,7 @@ GG_ENUM_STREAM_IN(BuildType) GG_ENUM_STREAM_OUT(BuildType) +/** Types of resources that planets can produce */ enum ResourceType { INVALID_RESOURCE_TYPE = -1, RE_FOOD, @@ -493,7 +494,10 @@ ECT_UNKNOWN_CAUSE, ECT_TECH, ECT_BUILDING, - ECT_SPECIAL + ECT_SPECIAL, + ECT_SHIP_PART, + ECT_SHIP_HULL }; + #endif // _Enums_h_ Modified: trunk/FreeOrion/universe/Ship.cpp =================================================================== --- trunk/FreeOrion/universe/Ship.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/universe/Ship.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -74,12 +74,12 @@ bool Ship::IsArmed() const { - return Design()->attack > 0; + return Design()->Attack() > 0; } double Ship::Speed() const { - return Design()->speed; + return Design()->Speed(); } const std::string& Ship::PublicName(int empire_id) const Modified: trunk/FreeOrion/universe/ShipDesign.cpp =================================================================== --- trunk/FreeOrion/universe/ShipDesign.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/universe/ShipDesign.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -9,22 +9,172 @@ using boost::lexical_cast; //////////////////////////////////////////////// +// PartType +//////////////////////////////////////////////// +PartType::PartType() : + m_name("generic part type") +{} + +//////////////////////////////////////////////// +// HullType +//////////////////////////////////////////////// +HullType::HullType() : + m_name("generic hull type") +{} + +//////////////////////////////////////////////// +// Free Function +//////////////////////////////////////////////// +const ShipDesign* GetShipDesign(int ship_design_id) +{ + return GetUniverse().GetShipDesign(ship_design_id); +} + +//////////////////////////////////////////////// // ShipDesign //////////////////////////////////////////////// -ShipDesign::ShipDesign() : - empire(-1), - name(""), - description(""), - cost(10000000.0), - speed(50.0), - colonize(false), - attack(0), - defense(0), - graphic("") +ShipDesign::ShipDesign() : + m_id(UniverseObject::INVALID_OBJECT_ID), + m_name(""), + m_designed_by_empire_id(-1), + m_designed_on_turn(UniverseObject::INVALID_OBJECT_AGE), + m_hull(""), + m_parts(), + m_graphic(""), + m_3D_model("") +{} + +ShipDesign::ShipDesign(int id, std::string name, int designed_by_empire_id, int designed_on_turn, + std::string hull, std::vector<std::string> parts, std::string graphic, + std::string model) : + m_id(id), + m_name(name), + m_designed_by_empire_id(designed_by_empire_id), + m_designed_on_turn(designed_on_turn), + m_hull(hull), + m_parts(parts), + m_graphic(graphic), + m_3D_model(model) +{} + +std::string ShipDesign::Name() const { + return m_name; } + +int ShipDesign::DesignedByEmpire() const +{ + return m_designed_by_empire_id; +} -const ShipDesign* GetShipDesign(int ship_design_id) +void ShipDesign::SetID(int id) { - return GetUniverse().GetShipDesign(ship_design_id); + // TODO: figure out if this requires a bunch of adjustments to ships using this design + m_id = id; } + +void ShipDesign::Rename(const std::string& name) +{ + m_name = name; +} + +std::string ShipDesign::Graphic() const +{ + if (m_name == "Scout") + return "misc/scout1.png"; + if (m_name == "Colony Ship") + return "misc/colony1.png"; + if (m_name == "Mark I") + return "misc/mark1.png"; + if (m_name == "Mark II") + return "misc/mark2.png"; + if (m_name == "Mark III") + return "misc/mark3.png"; + if (m_name == "Mark IV") + return "misc/mark4.png"; + return ""; +} + +std::string ShipDesign::Description() const +{ + if (m_name == "Scout") + return "Small and cheap unarmed vessel designed for recon and exploration."; + if (m_name == "Colony Ship") + return "Huge unarmed vessel capable of delivering millions of citizens safely to new colony sites."; + if (m_name == "Mark I") + return "Affordable armed patrol frigate."; + if (m_name == "Mark II") + return "Cruiser with storng defensive and offensive capabilities."; + if (m_name == "Mark III") + return "Advanced cruiser with heavy weaponry and armor to do the dirty work."; + if (m_name == "Mark IV") + return "Massive state-of-art warship armed and protected with the latest technolgy. Priced accordingly."; + return "A nonspecific ship"; +} + +double ShipDesign::Defense() const +{ + if (m_name == "Mark I") + return 1.0; + if (m_name == "Mark II") + return 2.0; + if (m_name == "Mark III") + return 3.0; + if (m_name == "Mark IV") + return 5.0; + return 1.0; +} + +double ShipDesign::Speed() const +{ + if (m_name == "Scout") + return 80.0; + if (m_name == "Colony Ship") + return 50.0; + if (m_name == "Mark I") + return 50.0; + if (m_name == "Mark II") + return 40.0; + if (m_name == "Mark III") + return 30.0; + if (m_name == "Mark IV") + return 25.0; + return 50.0; +} + +double ShipDesign::Attack() const +{ + if (m_name == "Mark I") + return 2.0; + if (m_name == "Mark II") + return 5.0; + if (m_name == "Mark III") + return 10.0; + if (m_name == "Mark IV") + return 15.0; + return 0.0; +} + +bool ShipDesign::Colonize() const +{ + if (m_name == "Colony Ship") + return true; + return false; +} + +double ShipDesign::Cost() const +{ + if (m_name == "Scout") + return 10.0; + if (m_name == "Colony Ship") + return 50.0; + if (m_name == "Mark I") + return 20.0; + if (m_name == "Mark II") + return 40.0; + if (m_name == "Mark III") + return 60.0; + if (m_name == "Mark IV") + return 80.0; + return 0; +} Modified: trunk/FreeOrion/universe/ShipDesign.h =================================================================== --- trunk/FreeOrion/universe/ShipDesign.h 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/universe/ShipDesign.h 2007-12-19 06:04:57 UTC (rev 2267) @@ -2,36 +2,142 @@ #ifndef _ShipDesign_h_ #define _ShipDesign_h_ -#include <boost/serialization/access.hpp> -#include <boost/serialization/nvp.hpp> +#include "Effect.h" -#include <string> +/** A type of ship part */ +class PartType { +public: + /** \name Structors */ //@{ + PartType(); + //@} + /** \name Accessors */ //@{ + std::string Name() const; ///< returns name of part + std::string Description() const; ///< returns stringtable entry name of description -/** a class representing a ship design */ -struct ShipDesign -{ + std::string UpgradesTo() const; ///< returns name of part that this part can be upgraded to. may return an empty string if there is no such upgrade + + double Mass() const; ///< returns mass of part + double Power() const; ///< returns how good the part is at its function. might be weapon or shield strength, or cargo hold capacity + double Range() const; ///< returns the range of a part. may not have meaning for all part types. + + std::string Graphic() const; ///< returns graphic that represents part in UI + std::string Animation() const; ///< returns name of animation that is played when part activates in battle + + const std::vector<boost::shared_ptr<const Effect::EffectsGroup> >& + Effects() const; ///< returns the EffectsGroups that encapsulate the effects this part has + //@} + +private: + std::string m_name; + std::string m_description; + std::string m_upgrade; + + double m_mass; + double m_power; + double m_range; + + std::vector<boost::shared_ptr<const Effect::EffectsGroup> > + m_effects; + + std::string m_graphic; + std::string m_battle_animation; + + friend class boost::serialization::access; + template <class Archive> + void serialize(Archive& ar, const unsigned int version); +}; + +class HullType { +public: /** \name Structors */ //@{ + HullType(); + //@} + + /** \name Accessors */ //@{ + std::string Name() const; ///< returns name of hull + std::string Description() const; ///< returns stringtable entry name of description + + double Mass() const; ///< returns mass of hull + double Speed() const; ///< returns speed (?) of hull + + int NumberSlots(); ///< returns number of part slots in hull + + const std::vector<boost::shared_ptr<const Effect::EffectsGroup> >& + Effects() const; ///< returns the EffectsGroups that encapsulate the effects this part hull has + //@} + +private: + std::string m_name; + std::string m_description; + double m_mass; + double m_speed; + + int m_number_slots; + + std::vector<boost::shared_ptr<const Effect::EffectsGroup> > + m_effects; + std::string m_graphic; + + friend class boost::serialization::access; + template <class Archive> + void serialize(Archive& ar, const unsigned int version); +}; + +class ShipDesign { +public: + /** \name Structors */ //@{ ShipDesign(); ///< default ctor + ShipDesign(int id, std::string name, int designed_by_empire_id, int designed_on_turn, + std::string hull, std::vector<std::string> parts, std::string graphic, + std::string model); //@} - int empire; ///< the empire that designed this ship - std::string name; ///< the name of the design - std::string description; ///< short description of the design, will maybe last after v.2 - double cost; ///< the cost per turn of the design, in PP - double speed; ///< the number of map-units the ship can move in one turn - bool colonize; ///< whether or not the ship is capable of creating a new colony + /** \name Accessors */ //@{ + int ID() const; ///< returns id number of design + std::string Name() const; ///< returns name of design + std::string Description() const; ///< returns description of design + int DesignedByEmpire() const; ///< returns id of empire that created design + int DesginedOnTurn() const; ///< returns turn on which design was created - ///////////////////////////////////////////////////////////////////////////// - // V0.3 ONLY!!!! - int attack; ///< the attack value of the design - int defense; ///< the defense value of the design - std::string graphic; ///< the name of the grapic file for this ship design - // V0.3 ONLY!!!! - ///////////////////////////////////////////////////////////////////////////// + double StarlaneSpeed() const; ///< returns design speed along starlanes + double BattleSpeed() const; ///< returns design speed on the battle map + double Mass() const; ///< returns design mass + + /////// TEMPORARY /////// + double Defense() const; + double Speed() const; + double Attack() const; + bool Colonize() const; + double Cost() const; + /////// TEMPORARY /////// + + std::string Hull() const; ///< returns name of hull on which design is based + const std::vector<std::string> Parts() const; ///< returns vector of names of parts in design + + std::string Graphic() const; ///< returns filename of graphic for design + std::string Model() const; ///< returns filename of 3D model that represents ships of design //@} + /** \name Mutators */ //@{ + void SetID(int id); ///< sets the ID number of the design to \a id + void Rename(const std::string& name); ///< renames this design to \a name + //@} + private: + int m_id; + + std::string m_name; + + int m_designed_by_empire_id; + int m_designed_on_turn; + + std::string m_hull; + std::vector<std::string> m_parts; + + std::string m_graphic; + std::string m_3D_model; + friend class boost::serialization::access; template <class Archive> void serialize(Archive& ar, const unsigned int version); @@ -45,17 +151,28 @@ // template implementations template <class Archive> +void PartType::serialize(Archive& ar, const unsigned int version) +{ + ar & BOOST_SERIALIZATION_NVP(m_name); +} + +template <class Archive> +void HullType::serialize(Archive& ar, const unsigned int version) +{ + ar & BOOST_SERIALIZATION_NVP(m_name); +} + +template <class Archive> void ShipDesign::serialize(Archive& ar, const unsigned int version) { - ar & BOOST_SERIALIZATION_NVP(empire) - & BOOST_SERIALIZATION_NVP(name) - & BOOST_SERIALIZATION_NVP(description) - & BOOST_SERIALIZATION_NVP(cost) - & BOOST_SERIALIZATION_NVP(speed) - & BOOST_SERIALIZATION_NVP(colonize) - & BOOST_SERIALIZATION_NVP(attack) - & BOOST_SERIALIZATION_NVP(defense) - & BOOST_SERIALIZATION_NVP(graphic); + ar & BOOST_SERIALIZATION_NVP(m_id) + & BOOST_SERIALIZATION_NVP(m_name) + & BOOST_SERIALIZATION_NVP(m_designed_by_empire_id) + & BOOST_SERIALIZATION_NVP(m_designed_on_turn) + & BOOST_SERIALIZATION_NVP(m_hull) + & BOOST_SERIALIZATION_NVP(m_parts) + & BOOST_SERIALIZATION_NVP(m_graphic) + & BOOST_SERIALIZATION_NVP(m_3D_model); } #endif // _ShipDesign_h_ Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/universe/Universe.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -529,7 +529,8 @@ bool retval = false; if (ship_design) { - if ( id < UniverseObject::MAX_ID) { + if (id < UniverseObject::MAX_ID) { + ship_design->SetID(id); m_ship_designs[id] = ship_design; retval = true; } @@ -2823,78 +2824,37 @@ // create the empire's initial ship designs // for now, the order that these are created need to match // the enums for ship designs in ships.h - ShipDesign* design = new ShipDesign(); - design->name = "Scout"; - design->attack = 0; - design->defense = 1; - design->cost = 10; - design->speed = 80.0; - design->colonize = false; - design->empire = empire_id; - design->description = "Small and cheap unarmed vessel designed for recon and exploration."; - design->graphic = "misc/scout1.png"; + ShipDesign* design = new ShipDesign(UniverseObject::INVALID_OBJECT_ID, "Scout", empire_id, 0, + "HULL", std::vector<std::string>(), "graphic", "model"); int scout_design_id = empire->AddShipDesign(design); + design->SetID(scout_design_id); - design = new ShipDesign(); - design->name = "Colony Ship"; - design->attack = 0; - design->defense = 1; - design->cost = 50; - design->speed = 35.0; - design->colonize = true; - design->empire = empire_id; - design->description = "Huge unarmed vessel capable of delivering millions of citizens safely to new colony sites."; - design->graphic = "misc/colony1.png"; + design = new ShipDesign(UniverseObject::INVALID_OBJECT_ID, "Colony Ship", empire_id, 0, + "HULL", std::vector<std::string>(), "graphic", "model"); int colony_ship_design_id = empire->AddShipDesign(design); + design->SetID(colony_ship_design_id); - design = new ShipDesign(); - design->name = "Mark I"; - design->attack = 2; - design->defense = 1; - design->cost = 20; - design->speed = 50.0; - design->colonize = false; - design->empire = empire_id; - design->description = "Affordable armed patrol frigate."; - design->graphic = "misc/mark1.png"; - empire->AddShipDesign(design); + design = new ShipDesign(UniverseObject::INVALID_OBJECT_ID, "Mark I", empire_id, 0, + "HULL", std::vector<std::string>(), "graphic", "model"); + int mark_I_design_id = empire->AddShipDesign(design); + design->SetID(mark_I_design_id); - design = new ShipDesign(); - design->name = "Mark II"; - design->attack = 5; - design->defense = 2; - design->cost = 40; - design->speed = 40.0; - design->colonize = false; - design->empire = empire_id; - design->description = "Cruiser with storng defensive and offensive capabilities."; - design->graphic = "misc/mark2.png"; - empire->AddShipDesign(design); + design = new ShipDesign(UniverseObject::INVALID_OBJECT_ID, "Mark II", empire_id, 0, + "HULL", std::vector<std::string>(), "graphic", "model"); + int temp = empire->AddShipDesign(design); + design->SetID(temp); - design = new ShipDesign(); - design->name = "Mark III"; - design->attack = 10; - design->defense = 3; - design->cost = 75; - design->speed = 30.0; - design->colonize = false; - design->empire = empire_id; - design->description = "Advanced cruiser with heavy weaponry and armor to do the dirty work."; - design->graphic = "misc/mark3.png"; - empire->AddShipDesign(design); + design = new ShipDesign(UniverseObject::INVALID_OBJECT_ID, "Mark III", empire_id, 0, + "HULL", std::vector<std::string>(), "graphic", "model"); + temp = empire->AddShipDesign(design); + design->SetID(temp); - design = new ShipDesign(); - design->name = "Mark IV"; - design->attack = 15; - design->defense = 5; - design->cost = 140; - design->speed = 25.0; - design->colonize = false; - design->empire = empire_id; - design->description = "Massive state-of-art warship armed and protected with the latest technolgy. Priced accordingly."; - design->graphic = "misc/mark4.png"; - empire->AddShipDesign(design); + design = new ShipDesign(UniverseObject::INVALID_OBJECT_ID, "Mark IV", empire_id, 0, + "HULL", std::vector<std::string>(), "graphic", "model"); + temp = empire->AddShipDesign(design); + design->SetID(temp); + // create the empire's starting fleet Fleet* home_fleet = new Fleet(UserString("FW_HOME_FLEET"), home_system->X(), home_system->Y(), empire_id); Insert(home_fleet); @@ -2916,6 +2876,16 @@ ship->Rename(empire->NewShipName()); ship_id = Insert(ship); home_fleet->AddShip(ship_id); + + // create a battle fleet + Fleet* battle_fleet = new Fleet(UserString("FW_BATTLE_FLEET"), home_system->X(), home_system->Y(), empire_id); + Insert(battle_fleet); + home_system->Insert(battle_fleet); + + ship = new Ship(empire_id, mark_I_design_id); + ship->Rename(empire->NewShipName()); + ship_id = Insert(ship); + battle_fleet->AddShip(ship_id); } #else throw std::runtime_error("Non-server called Universe::GenerateEmpires; only server should call this while creating the universe"); Modified: trunk/FreeOrion/util/Order.cpp =================================================================== --- trunk/FreeOrion/util/Order.cpp 2007-12-18 23:59:29 UTC (rev 2266) +++ trunk/FreeOrion/util/Order.cpp 2007-12-19 06:04:57 UTC (rev 2267) @@ -671,7 +671,7 @@ empire->RemoveShipDesign(m_design_id); } else if (m_create_new_design) { - if (m_ship_design.empire != EmpireID()) + if (m_ship_design.DesignedByEmpire() != EmpireID()) throw std::runtime_error("Tried to create a new ShipDesign designed by another empire"); Universe& universe = GetUniverse(); |