Add infos into target window
[ryzomcore.git] / ryzom / server / src / ags_test / sheets.cpp
blob78cc06bd08fbf98cbbe1e342ae616698ae8c063b
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/>.
20 // Misc
21 #include "nel/misc/path.h"
22 #include "nel/misc/file.h"
23 #include "nel/misc/smart_ptr.h"
24 #include "nel/misc/command.h"
25 #include "nel/misc/path.h"
26 // Georges
27 #include "nel/georges/u_form.h"
28 #include "nel/georges/u_form_elm.h"
29 #include "nel/georges/u_form_loader.h"
30 #include "nel/georges/load_form.h"
31 // Local
32 #include "sheets.h"
35 ///////////
36 // USING //
37 ///////////
38 using namespace NLMISC;
39 using namespace std;
40 using namespace NLGEORGES;
42 namespace AGS_TEST
45 //-------------------------------------------------------------------------
46 // the singleton data
48 std::map<CSheetId,CSheets::CSheet> CSheets::_Sheets;
49 bool CSheets::_Initialised=false;
51 //-------------------------------------------------------------------------
52 // init
54 void CSheets::init()
56 if (_Initialised)
57 return;
59 std::vector<std::string> filters;
60 filters.push_back("creature");
61 filters.push_back("player");
63 loadForm(filters, "data_shard/ags_test.packed_sheets", _Sheets);
65 _Initialised=true;
69 //-------------------------------------------------------------------------
70 // display
72 void CSheets::display(NLMISC::CLog *log)
74 nlassert(_Initialised);
76 std::map<CSheetId,CSheets::CSheet>::iterator it;
77 for(it=_Sheets.begin();it!=_Sheets.end();++it)
79 log->displayNL("SHEET:%s Walk:%f Run:%f Radius:%f Height:%f Bounding:%f Type:%s ChatType: %s",(*it).first.toString().c_str(),
80 (*it).second.WalkSpeed,
81 (*it).second.RunSpeed,
82 (*it).second.Radius,
83 (*it).second.Height,
84 (*it).second.BoundingRadius,
85 // (*it).second.Name.c_str(),
86 (*it).second.isNpc?"NPC": "CREATURE",
87 (std::string()+((*it).second.CanChatTP?"TP ":"")+((*it).second.CanChatTrade?"MERCHANT ":"")+((*it).second.CanChatMission?"MISSION ":"")).c_str()
93 //-------------------------------------------------------------------------
94 // lookup
96 const CSheets::CSheet *CSheets::lookup( CSheetId id )
98 nlassert(_Initialised);
100 // setup an iterator and lookup the sheet id in the map
101 std::map<CSheetId,CSheets::CSheet>::iterator it=_Sheets.find(id);
103 // if we found a valid entry return a pointer to the creature record otherwise 0
104 if (it!=_Sheets.end())
105 return &((*it).second);
106 else
107 return NULL;
110 } //namespace AGS_TEST