// 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 "stdpch.h"
#include "sbrick_sheet.h"
#include "nel/georges/u_form_elm.h"
#include "nel/misc/common.h"
#include "nel/misc/algo.h"
#include "item_sheet.h"
#include "game_share/brick_flags.h"
using namespace std;
using namespace NLMISC;
using namespace NLGEORGES;
// ***************************************************************************
// Easy Macro to translate .typ enum
#define TRANSLATE_ENUM( _Var_, _unknown_, _func_, _key_) \
_Var_ = _unknown_; \
if( !root.getValueByName(val, _key_)) \
debug("Key '" _key_ "' not found."); \
else if( (_Var_ = _func_(val)) == _unknown_ ) \
debug(#_Var_ " Unknown: " + val);
// Same but no error if the result of enum is _unknown_
#define TRANSLATE_ENUM_NODB( _Var_, _unknown_, _func_, _key_) \
_Var_ = _unknown_; \
if( !root.getValueByName(val, _key_)) \
debug( toString("Key '%s' not found.", _key_) ); \
else \
_Var_ = _func_(val);
// Easy macro to translate value from georges
#define TRANSLATE_VAL( _Var_, _key_ ) \
if(!root.getValueByName(_Var_, _key_)) \
debug( string("key '") + string(_key_) + string("' not found.") );
// ***************************************************************************
static void strRemoveChar(string &str, char c)
{
str.erase( remove(str.begin(), str.end(), c), str.end() );
}
// ***************************************************************************
void CSBrickSheet::build (const NLGEORGES::UFormElm &root)
{
string sTmp;
uint i;
// read the array of skills
string skillUseStr;
TRANSLATE_VAL(skillUseStr, "Basics.Skill");
while(strFindReplace(skillUseStr, ":", " "));
std::vector listSkill;
splitString(skillUseStr," ",listSkill);
// build the req skill array
UsedSkills.clear();
UsedSkills.reserve(listSkill.size());
for(i=0;i0 )
{
CFaberPlan::CItemPartMP mpVal;
mpVal.Quantity= mpQuantity;
// No error if unknown: filter not used (all MPs match)
TRANSLATE_ENUM_NODB( mpVal.FaberTypeFilter, RM_FABER_TYPE::Unknown, RM_FABER_TYPE::toFaberType,
toString("faber.Create.MP %d", k+1).c_str() );
// Add this req MP.
FaberPlan.ItemPartMps.push_back(mpVal);
}
// else subsequents MP slots are not used
else
break;
}
// Formula MPs. Try all MP1 .. 5 slots. Stop when not valid
for (uint k=0; k< MAX_FABER_REQ_MP; ++k)
{
sint32 mpQuantity= 0;
root.getValueByName(mpQuantity, toString("faber.Create.Quantity formula %d", k+1).c_str() );
// if the req quantity is not 0
if ( mpQuantity>0 )
{
CFaberPlan::CFormulaMP mpVal;
mpVal.Quantity= mpQuantity;
// No error if unknown: filter not used (all MPs match)
TRANSLATE_VAL(val, toString("faber.Create.MP formula %d", k+1).c_str());
mpVal.ItemRequired.buildSheetId(val);
// Add this req MP.
FaberPlan.FormulaMps.push_back(mpVal);
}
// else subsequents MP slots are not used
else
break;
}
}
// read minmax range/cast time when guigui ready
TRANSLATE_VAL(MinCastTime, "Basics.MinCastTime");
TRANSLATE_VAL(MaxCastTime, "Basics.MaxCastTime");
TRANSLATE_VAL(MinRange, "Basics.MinRange");
TRANSLATE_VAL(MaxRange, "Basics.MaxRange");
// Read SPCost
TRANSLATE_VAL(SPCost, "Basics.SPCost");
// Read AvoidCyclic
TRANSLATE_VAL(AvoidCyclic, "Basics.AvoidCyclic");
// Read UsableWithEmptyHands
TRANSLATE_VAL(UsableWithEmptyHands, "Basics.UsableWithEmptyHands");
// Read Action Nature
string val;
TRANSLATE_ENUM(ActionNature, ACTNATURE::UNKNOWN, ACTNATURE::toActionNature, "Basics.Action Nature");
// Read CivRestriction
TRANSLATE_ENUM(CivRestriction, EGSPD::CPeople::Common, EGSPD::CPeople::fromString, "Basics.CivRestriction");
// **** parse properties, to precompute the Bricks Flags.
BrickRequiredFlags= 0;
for(i=0;i strList;
strList.reserve(10);
splitString(text, ":", strList);
for(uint k=1;k listBrick;
listBrick.clear();
splitString(brickReqStr," ",listBrick);
// build the req skill array
RequiredBricks.clear();
RequiredBricks.reserve(listBrick.size());
for(i=0;i= BRICK_FAMILIES::BeginInterface && BrickFamily<= BRICK_FAMILIES::EndInterface && IndexInFamily!=63) ||
Level==0 );
}