Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / server / src / server_share / npc_description_messages.cpp
blob6db67ef8248a8702fbd6ae5b2def22e0cb040c38
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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.
8 //
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/>.
17 #include "stdpch.h"
19 #include "nel/misc/types_nl.h"
20 #include "nel/misc/common.h"
21 #include "nel/misc/command.h"
22 #include "nel/misc/path.h"
23 #include "npc_description_messages.h"
24 #include "../ai_share/ai_share.h"
26 using namespace NLMISC;
27 using namespace std;
30 //---------------------------------------------------------------------------------------
31 // Stuff used for management of log messages
33 bool VerboseNpcDescriptionMsgLog=false;
34 #define LOG if (!VerboseNpcDescriptionMsgLog) {} else nlinfo
36 CNpcChatProfile::CNpcChatProfile(const CNpcChatProfile &other0, const CNpcChatProfile &other1)
38 uint i,j;
40 // run through shop types in other0 - trying to add to output shop type list
41 for (i=0;i<other0.getShopTypes().size();++i)
43 // not found in negator list so add to output list
44 _ShopTypes.push_back(other0._ShopTypes[i]);
47 // run through shop types in other1 - trying to add to output shop type list
48 for (i=0;i<other1._ShopTypes.size();++i)
50 // make sure shop type isn't already in output list
51 for (j=0;j<_ShopTypes.size();++j)
52 if (other1._ShopTypes[i]==_ShopTypes[j])
53 break;
54 if (j<_ShopTypes.size())
55 continue;
57 // not found in negator list or existing output list so add it now
58 _ShopTypes.push_back(other0._ShopTypes[i]);
61 // run through shop item types in other0 - trying to add to output shop item type list
62 for (i=0;i<other0._ExplicitSales.size();++i)
64 _ExplicitSales.push_back(other0._ExplicitSales[i]);
67 // run through shop item types in other1 - trying to add to output shop item type list
68 for (i=0;i<other1._ExplicitSales.size();++i)
70 // make sure shop item type isn't already in output list
71 for (j=0;j<_ExplicitSales.size();++j)
72 if (other1._ExplicitSales[i]==_ExplicitSales[j])
73 break;
74 if (j<_ExplicitSales.size())
75 continue;
77 // not found in negator list or existing output list so add it now
78 _ExplicitSales.push_back(other1._ExplicitSales[i]);
81 // run through missions in other0 - trying to add to output mission list
82 _Missions=other0._Missions;
83 for (i=0;i<other1._Missions.size();++i)
85 // make sure shop type isn't already in output list
86 for (j=0;j<_Missions.size();++j)
87 if (other1._Missions[i]==_Missions[j])
88 break;
89 if (j<_Missions.size())
90 continue;
92 // not found in existing output list so add it now
93 _Missions.push_back(other1._Missions[i]);
97 void CCustomElementId::serial(NLMISC::IStream &f)
99 f.serial(PrimAlias);
100 f.serial(Id);
103 void CScriptData::serial(NLMISC::IStream &f)
105 uint16 size;
106 if (f.isReading())
108 Scripts.clear();
109 f.serial(size);
111 uint32 i = 0;
112 for (; i < size; ++i)
114 //std::string tmpKey;
115 CCustomElementId tmpKey;
116 std::vector<std::string> tmpVal;
117 f.serial(tmpKey);
118 f.serialCont(tmpVal);
119 Scripts.insert(make_pair(tmpKey,tmpVal));
122 else
124 size = (uint16)Scripts.size();
125 f.serial(size);
126 for (TScripts::iterator it = Scripts.begin(); it != Scripts.end(); ++it)
128 //std::string tmp = it->first;
129 nlWrite(f, serial, it->first);
130 nlWrite(f, serialCont, it->second);
135 void CCustomLootTable::serial(NLMISC::IStream &f)
137 f.serial(LootSets);
138 f.serial(MoneyFactor);
139 f.serial(MoneyProba);
140 f.serial(MoneyBase);
143 void CCustomLootTableManager::serial(NLMISC::IStream &f)
145 uint16 size;
146 if (f.isReading())
148 Tables.clear();
149 f.serial(size);
151 uint32 i = 0;
152 for (; i < size; ++i)
154 //std::string tmpKey;
155 CCustomElementId tmpKey;
156 CCustomLootTable tmpVal;
157 f.serial(tmpKey);
158 f.serial(tmpVal);
159 Tables.insert(make_pair(tmpKey,tmpVal));
162 else
164 size = (uint16)Tables.size();
165 f.serial(size);
166 for (TCustomLootTable::iterator it = Tables.begin(); it != Tables.end(); ++it)
168 nlWrite(f, serial, it->first);
169 nlWrite(f, serial, it->second);
175 //---------------------------------------------------------------------------------------
176 // Control over verbose nature of logging
177 //---------------------------------------------------------------------------------------
179 NLMISC_COMMAND(verboseNpcDescriptionMsgLog,"Turn on or off or check the state of verbose AI->EGS NPC description message logging","")
181 if(args.size()>1)
182 return false;
184 if(args.size()==1)
186 if(args[0]==string("on")||args[0]==string("ON")||args[0]==string("true")||args[0]==string("TRUE")||args[0]==string("1"))
187 VerboseNpcDescriptionMsgLog=true;
189 if(args[0]==string("off")||args[0]==string("OFF")||args[0]==string("false")||args[0]==string("FALSE")||args[0]==string("0"))
190 VerboseNpcDescriptionMsgLog=false;
193 nlinfo("verbose Logging is %s",VerboseNpcDescriptionMsgLog?"ON":"OFF");
194 return true;