1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "outpost_building_sheet.h"
23 #include "nel/georges/u_form_elm.h"
26 using namespace NLMISC
;
27 using namespace NLGEORGES
;
30 // ****************************************************************************
31 COutpostBuildingSheet::TOBType
COutpostBuildingSheet::fromString( const string
& str
)
33 if (str
== "TownHall") return OB_TownHall
;
34 if (str
== "Driller") return OB_Driller
;
38 // ****************************************************************************
39 string
COutpostBuildingSheet::toString( TOBType type
)
41 if (type
== OB_TownHall
) return "TownHall";
42 if (type
== OB_Driller
) return "Driller";
46 // ****************************************************************************
47 COutpostBuildingSheet::COutpostBuildingSheet()
49 Type
= CEntitySheet::OUTPOST_BUILDING
;
53 MPLevelOfHighestExtractRate
= 0;
60 // ****************************************************************************
61 void COutpostBuildingSheet::build(const NLGEORGES::UFormElm
&root
)
64 root
.getValueByName (sType
, "type");
65 OBType
= fromString(sType
);
66 root
.getValueByName(CostDapper
, "cost_dapper");
67 root
.getValueByName(CostTime
, "cost_time");
71 if (OBType
== OB_Driller
)
73 MPLevelOfHighestExtractRate
= 50;
75 const UFormElm
*pDriller
;
76 if (root
.getNodeByName(&pDriller
, "driller") && pDriller
)
81 while (pDriller
->getNodeByName(&pMp
, "mp" + NLMISC::toString(i
)) && pMp
)
84 pMp
->getValueByName(sTmp
, "name");
85 CSheetId
sheetId(sTmp
);
86 if(sheetId
!=CSheetId::Unknown
)
87 Mps
.push_back(sheetId
);
93 for(uint i
=50;i
<=250;i
+=50)
96 if(pDriller
->getValueByName(tmp
, NLMISC::toString("quality_%03d", i
).c_str()))
101 MPLevelOfHighestExtractRate
= i
;
108 debug("key 'driller' not found.");
112 // Get the icon associated.
114 if(!root
.getValueByName (IconMain
, "icon"))
115 debug("key 'icon' not found.");
116 IconMain
= toLowerAscii(IconMain
);
117 IdIconMain
= ClientSheetsStrings
.add(IconMain
);
119 // Get the icon associated.
121 if(!root
.getValueByName (IconBack
, "icon background"))
122 debug("key 'icon background' not found.");
123 IconBack
= toLowerAscii(IconBack
);
124 IdIconBack
= ClientSheetsStrings
.add(IconBack
);
126 // Get the icon associated.
128 if(!root
.getValueByName (IconOver
, "icon overlay"))
129 debug("key 'icon overlay' not found.");
130 IconOver
= toLowerAscii(IconOver
);
131 IdIconOver
= ClientSheetsStrings
.add(IconOver
);
133 // Get the icon text associated.
135 if(!root
.getValueByName (IconText
, "text overlay"))
136 debug("key 'text overlay' not found.");
137 IdIconText
= ClientSheetsStrings
.add(IconText
);
140 // ****************************************************************************
141 void COutpostBuildingSheet::serial(NLMISC::IStream
&f
)
143 f
.serialEnum(OBType
);
144 f
.serial(CostDapper
);
146 f
.serial(MPLevelOfHighestExtractRate
);
148 ClientSheetsStrings
.serial(f
, IdIconMain
);
149 ClientSheetsStrings
.serial(f
, IdIconBack
);
150 ClientSheetsStrings
.serial(f
, IdIconOver
);
151 ClientSheetsStrings
.serial(f
, IdIconText
);