1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "skills_tree_sheet.h"
21 #include "nel/georges/u_form_elm.h"
22 #include "nel/misc/common.h"
25 using namespace NLMISC
;
26 using namespace NLGEORGES
;
28 // ***************************************************************************
29 void CSkillsTreeSheet::build(const UFormElm
&item
)
31 const UFormElm
*arraySkillElt
= NULL
;
32 if( item
.getNodeByName( &arraySkillElt
, "SkillData" ) )
37 nlverify( arraySkillElt
->getArraySize( NbSkills
) );
39 //nlassert( NbSkills == SKILLS::NUM_SKILLS );
41 SkillsTree
.resize( std::max(NbSkills
, (uint
) SKILLS::NUM_SKILLS
));
43 for( uint i
= 0; i
< NbSkills
; ++i
)
45 const UFormElm
* SkillElt
= NULL
;
46 if( ! ( arraySkillElt
->getArrayNode( &SkillElt
, i
) && SkillElt
) )
48 nlwarning("<CSkillsTreeSheet::build> can't get array node of SkillElt in sheet");
54 SkillElt
->getValueByName( SkillName
, "Skill" );
55 SKILLS::ESkills skill
= SKILLS::toSkill( SkillName
);
56 //nlassert( skill != SKILLS::unknown );
57 if (skill
== SKILLS::unknown
)
61 SkillsTree
[ skill
].Skill
= skill
;
64 if( ! SkillElt
->getValueByName( SkillsTree
[ skill
].SkillCode
, "SkillCode" ) )
66 nlwarning("<CSkillsTreeSheet::build> can't get node SkillCode in sheet");
70 if( ! SkillElt
->getValueByName( SkillsTree
[ skill
].MaxSkillValue
, "MaxSkillValue" ) )
72 nlwarning("<CSkillsTreeSheet::build> can't get node MaxSkillValue in sheet");
76 if( ! SkillElt
->getValueByName( SkillsTree
[ skill
].StageType
, "Type of Stage" ) )
78 nlwarning("<CSkillsTreeSheet::build> can't get node 'Type of Stage' in sheet");
82 if( ! SkillElt
->getValueByName( SkillName
, "ParentSkill" ) )
84 nlwarning("<CSkillsTreeSheet::build> can't get node ParentSkills in sheet");
88 SkillsTree
[ skill
].ParentSkill
= SKILLS::toSkill( SkillName
);
92 const UFormElm
*arrayChildSkillElt
= NULL
;
93 if( SkillElt
->getNodeByName( &arrayChildSkillElt
, "ChildSkills" ) )
95 if( arrayChildSkillElt
)
98 nlverify( arrayChildSkillElt
->getArraySize( NbChildSkills
) );
100 SkillsTree
[ skill
].ChildSkills
.resize( NbChildSkills
);
102 for( uint j
= 0; j
< NbChildSkills
; ++j
)
104 string childSkillName
;
105 arrayChildSkillElt
->getArrayValue( childSkillName
, j
);
106 SKILLS::ESkills childSkill
= SKILLS::toSkill( childSkillName
);
107 //nlassert( childSkill != SKILLS::unknown );
108 SkillsTree
[ skill
].ChildSkills
[ j
] = childSkill
;