1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2014 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
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/>.
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"
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"
43 using namespace NLMISC
;
44 using namespace NLNET
;
46 using namespace NLGEORGES
;
48 //-------------------------------------------------------------------------
51 std::map
<CSheetId
,CGpmSheets::CSheet
> CGpmSheets::_sheets
;
52 bool CGpmSheets::_initialised
=false;
55 //-------------------------------------------------------------------------
58 void CGpmSheets::init()
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
78 loadForm(filters
, IService::getInstance()->WriteFilesDirectory
.toString()+"gpms.packed_sheets", _sheets
, true);
85 //-------------------------------------------------------------------------
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 //-------------------------------------------------------------------------
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
;
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
);