Add infos into target window
[ryzomcore.git] / ryzom / server / src / gpm_service / sheets.cpp
blob079f439a34e320f0358929c6d413a6bb947db5e5
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2014 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "stdpch.h"
24 // Misc
25 #include "nel/misc/path.h"
26 #include "nel/misc/file.h"
27 #include "nel/misc/smart_ptr.h"
28 #include "nel/misc/command.h"
29 // Georges
30 #include "nel/georges/u_form.h"
31 #include "nel/georges/u_form_elm.h"
32 #include "nel/georges/u_form_loader.h"
33 #include "nel/georges/load_form.h"
35 #include "nel/net/service.h"
36 // Local
37 #include "sheets.h"
40 ///////////
41 // USING //
42 ///////////
43 using namespace NLMISC;
44 using namespace NLNET;
45 using namespace std;
46 using namespace NLGEORGES;
48 //-------------------------------------------------------------------------
49 // the singleton data
51 std::map<CSheetId,CGpmSheets::CSheet> CGpmSheets::_sheets;
52 bool CGpmSheets::_initialised=false;
55 //-------------------------------------------------------------------------
56 // init
58 void CGpmSheets::init()
60 if (_initialised)
61 return;
63 CSheetId::init(0);
65 std::vector<std::string> filters;
66 filters.push_back("creature");
67 filters.push_back("player");
69 // if the 'GeorgePaths' config file var exists then we try to perform a mini-scan for sheet files
70 if (IService::isServiceInitialized() && (IService::getInstance()->ConfigFile.getVarPtr(std::string("GeorgePaths"))!=NULL))
72 loadForm(filters, IService::getInstance()->WriteFilesDirectory.toString()+"gpms.packed_sheets", _sheets, false, false);
75 // if we haven't succeeded in minimal scan (or 'GeorgePaths' wasn't found in config file) then perform standard scan
76 if (_sheets.empty())
78 loadForm(filters, IService::getInstance()->WriteFilesDirectory.toString()+"gpms.packed_sheets", _sheets, true);
81 _initialised=true;
85 //-------------------------------------------------------------------------
86 // display
88 void CGpmSheets::display()
90 nlassert(_initialised);
92 std::map<CSheetId,CGpmSheets::CSheet>::iterator it;
93 for(it=_sheets.begin();it!=_sheets.end();++it)
95 nlinfo("SHEET:%s Walk:%f Run:%f Radius:%f Height:%f Bounding:%f Scale:%f",(*it).first.toString().c_str(),
96 (*it).second.WalkSpeed, (*it).second.RunSpeed, (*it).second.Radius, (*it).second.Height, (*it).second.BoundingRadius, (*it).second.Scale);
101 //-------------------------------------------------------------------------
102 // lookup
104 const CGpmSheets::CSheet *CGpmSheets::lookup( CSheetId id )
106 nlassert(_initialised);
108 // setup an iterator and lookup the sheet id in the map
109 std::map<CSheetId,CGpmSheets::CSheet>::iterator it;
110 it=_sheets.find(id);
112 // if we found a valid entry return a pointer to the creature record otherwise 0
113 if (it!=_sheets.end())
114 return &((*it).second);
115 else
116 return 0;