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/>.
21 #include "ai_keywords.h"
22 #include "nel/net/service.h"
24 using namespace NLMISC
;
25 using namespace NLNET
;
27 // singleton data instantiation
29 CKeywordSet
CAIKeywords::_botKeywords
;
30 CKeywordSet
CAIKeywords::_groupKeywords
;
31 CKeywordSet
CAIKeywords::_stateKeywords
;
33 void CAIKeywords::init()
35 updateKeywordsFromCfg();
38 static void loadKeywordsFromCfg(const char *varName
,CKeywordSet
&wordSet
)
40 // get hold of the config file variable
41 CConfigFile::CVar
*varPtr
;
42 varPtr
=IService::getInstance()->ConfigFile
.getVarPtr(std::string(varName
));
45 nlwarning("WARNING: Config file variable: %s not found",varName
);
49 // add config file variable contents to keyword set
50 for (uint32 i
=0;i
<varPtr
->size();++i
)
51 wordSet
.addKeywords(varPtr
->asString(i
));
54 void CAIKeywords::updateKeywordsFromCfg()
56 loadKeywordsFromCfg("KeywordsGroupNpc",_groupKeywords
);
57 loadKeywordsFromCfg("KeywordsBotNpc",_botKeywords
);
58 loadKeywordsFromCfg("KeywordsStateNpc",_stateKeywords
);
61 void CAIKeywords::display()
63 nlinfo ("bot keywords: %s",_botKeywords
.toString().c_str());
64 nlinfo ("group keywords: %s",_groupKeywords
.toString().c_str());
65 nlinfo ("state keywords: %s",_stateKeywords
.toString().c_str());