// Ryzom - MMORPG Framework
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
#include "nel/misc/types_nl.h"
#include "nel/misc/file.h"
#include "nel/misc/config_file.h"
#include "string.h"
#include
#include
using namespace std;
using namespace NLMISC;
// define macro for outputone code line
#define outLine( s )\
{\
out = string(s);\
fo.serialBuffer( (uint8 *) const_cast< char * >(out.c_str()), out.size() );\
}\
// set of code
static set Codes;
struct CSkill
{
string SkillName;
string NormalizedSkillName;
CSkill *ParentSkillPtr;
string ParentSkill;
uint16 MaxValue;
string Code;
uint8 StageType;
string MainCategory;
string SecondaryCategory;
vector Children;
CSkill() : ParentSkillPtr(NULL),MaxValue(0),StageType(0)
{}
CSkill(const CSkill &skill)
{
*this = skill;
}
CSkill &operator=(const CSkill &skill)
{
SkillName = skill.SkillName;
NormalizedSkillName = skill.NormalizedSkillName;
ParentSkillPtr = skill.ParentSkillPtr;
ParentSkill = skill.ParentSkill;
MaxValue = skill.MaxValue;
Code = skill.Code;
StageType = skill.StageType;
MainCategory = skill.MainCategory;
SecondaryCategory = skill.SecondaryCategory;
Children = skill.Children;
return *this;
}
void skillName(string name)
{
SkillName = name;
/* // fast correction to avoid strange cases when names end with a ' '
sint i = SkillName.size();
for ( ; i > 0; i-- )
{
if ( SkillName[i-1] != ' ' )
break;
}
SkillName.resize( i );
uint idxSpace;
char c[2];
c[0] = SkillName.substr( 0, 1).c_str()[0] - 32;
c[1] = 0;
NormalizedSkillName = string( c ) + SkillName.substr( 1 );
while( ( idxSpace = NormalizedSkillName.find(" ") ) != string::npos )
{
string skillNameTmp = NormalizedSkillName.substr( 0, idxSpace );
if( idxSpace < ( SkillName.size() - 1 ) )
{
c[0] = (*NormalizedSkillName.substr( idxSpace + 1, 1 ).c_str());
if( c[0] >= 'a' ) c[0] -= 32;
skillNameTmp = skillNameTmp + string( c ) + NormalizedSkillName.substr( idxSpace + 2 );
}
NormalizedSkillName = skillNameTmp;
}
*/
NormalizedSkillName = SkillName;
}
void buildCode()
{
if (ParentSkillPtr != NULL)
Code = ParentSkillPtr->Code + Code;
Codes.insert( Code );
for (uint i = 0 ; i < Children.size() ; ++i)
Children[i]->buildCode();
}
void writeInSheet(COFile &fo)
{
/*
*/
string out;
out = string(" \n");
fo.serialBuffer( (uint8 *) const_cast< char * >(out.c_str()), out.size() );
out = string(" \n");
fo.serialBuffer( (uint8 *) const_cast< char * >(out.c_str()), out.size() );
out = string(" \n");
fo.serialBuffer( (uint8 *) const_cast< char * >(out.c_str()), out.size() );
out = string(" \n");
fo.serialBuffer( (uint8 *) const_cast< char * >(out.c_str()), out.size() );
out = string(" \n");
fo.serialBuffer( (uint8 *) const_cast< char * >(out.c_str()), out.size() );
if (ParentSkillPtr != NULL)
{
out = string(" \n");
}
else
{
out = string(" \n");
}
fo.serialBuffer( (uint8 *) const_cast< char * >(out.c_str()), out.size() );
if( !Children.empty())
{
out = string(" \n");
fo.serialBuffer( (uint8 *) const_cast< char * >(out.c_str()), out.size() );
for (uint i = 0 ; i < Children.size() ; ++i)
{
out = string(" NormalizedSkillName + string("\" Value=\"")+ Children[i]->SkillName + string("\"/>\n");
fo.serialBuffer( (uint8 *) const_cast< char * >(out.c_str()), out.size() );
}
out = string(" \n");
fo.serialBuffer( (uint8 *) const_cast< char * >(out.c_str()), out.size() );
}
out = string(" \n");
fo.serialBuffer( (uint8 *) const_cast< char * >(out.c_str()), out.size() );
for (uint i = 0 ; i < Children.size() ; ++i)
Children[i]->writeInSheet(fo);
}
};
struct CSkillTree
{
void buildCode()
{
for (uint i = 0 ; i < RootSkills.size() ; ++i)
RootSkills[i]->buildCode();
}
vector RootSkills;
};
static CSkillTree SkillTree;
static map< string, CSkill> SkillNameToStruct;
char separators[] = ";,";
//-----------------------------------------------
// main
//
//-----------------------------------------------
sint main( sint argc, char ** argv )
{
/////////////////////////////////////////////////////////////////////////////////////
// Somes working variables
char buffer[4096];
// vector contained selector category
vector< string > selector;
/////////////////////////////////////////////////////////////////////////////////////
// Check number of arguments
if( argc < 4 )
{
printf("Create a file .typ for george contained a subset of skills\n\n");
printf("SKILL_EXTRACTOR