You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
3.3 KiB
C++
117 lines
3.3 KiB
C++
13 years ago
|
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||
|
//
|
||
|
// This program is free software: you can redistribute it and/or modify
|
||
|
// it under the terms of the GNU Affero General Public License as
|
||
|
// published by the Free Software Foundation, either version 3 of the
|
||
|
// License, or (at your option) any later version.
|
||
|
//
|
||
|
// This program is distributed in the hope that it will be useful,
|
||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
// GNU Affero General Public License for more details.
|
||
|
//
|
||
|
// You should have received a copy of the GNU Affero General Public License
|
||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
|
||
|
|
||
|
|
||
|
#include "stdpch.h"
|
||
|
|
||
|
// Misc
|
||
|
#include "nel/misc/path.h"
|
||
|
#include "nel/misc/file.h"
|
||
|
#include "nel/misc/smart_ptr.h"
|
||
|
#include "nel/misc/command.h"
|
||
|
// Georges
|
||
|
#include "nel/georges/u_form.h"
|
||
|
#include "nel/georges/u_form_elm.h"
|
||
|
#include "nel/georges/u_form_loader.h"
|
||
|
#include "nel/georges/load_form.h"
|
||
|
|
||
|
#include "nel/net/service.h"
|
||
|
// Local
|
||
|
#include "sheets.h"
|
||
|
|
||
|
|
||
|
///////////
|
||
|
// USING //
|
||
|
///////////
|
||
|
using namespace NLMISC;
|
||
|
using namespace NLNET;
|
||
|
using namespace std;
|
||
|
using namespace NLGEORGES;
|
||
|
|
||
|
//-------------------------------------------------------------------------
|
||
|
// the singleton data
|
||
|
|
||
11 years ago
|
std::map<CSheetId,CGpmSheets::CSheet> CGpmSheets::_sheets;
|
||
|
bool CGpmSheets::_initialised=false;
|
||
13 years ago
|
|
||
|
|
||
|
//-------------------------------------------------------------------------
|
||
|
// init
|
||
|
|
||
11 years ago
|
void CGpmSheets::init()
|
||
13 years ago
|
{
|
||
|
if (_initialised)
|
||
|
return;
|
||
|
|
||
|
CSheetId::init(0);
|
||
|
|
||
|
std::vector<std::string> filters;
|
||
|
filters.push_back("creature");
|
||
|
filters.push_back("player");
|
||
|
|
||
11 years ago
|
// if the 'GeorgePaths' config file var exists then we try to perform a mini-scan for sheet files
|
||
|
if (IService::isServiceInitialized() && (IService::getInstance()->ConfigFile.getVarPtr(std::string("GeorgePaths"))!=NULL))
|
||
|
{
|
||
|
loadForm(filters, IService::getInstance()->WriteFilesDirectory.toString()+"gpms.packed_sheets", _sheets, false, false);
|
||
|
}
|
||
|
|
||
|
// if we haven't succeeded in minimal scan (or 'GeorgePaths' wasn't found in config file) then perform standard scan
|
||
|
if (_sheets.empty())
|
||
|
{
|
||
|
loadForm(filters, IService::getInstance()->WriteFilesDirectory.toString()+"gpms.packed_sheets", _sheets, true);
|
||
|
}
|
||
13 years ago
|
|
||
|
_initialised=true;
|
||
|
}
|
||
|
|
||
|
|
||
|
//-------------------------------------------------------------------------
|
||
|
// display
|
||
|
|
||
11 years ago
|
void CGpmSheets::display()
|
||
13 years ago
|
{
|
||
|
nlassert(_initialised);
|
||
|
|
||
11 years ago
|
std::map<CSheetId,CGpmSheets::CSheet>::iterator it;
|
||
13 years ago
|
for(it=_sheets.begin();it!=_sheets.end();++it)
|
||
|
{
|
||
|
nlinfo("SHEET:%s Walk:%f Run:%f Radius:%f Height:%f Bounding:%f Scale:%f",(*it).first.toString().c_str(),
|
||
|
(*it).second.WalkSpeed, (*it).second.RunSpeed, (*it).second.Radius, (*it).second.Height, (*it).second.BoundingRadius, (*it).second.Scale);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
//-------------------------------------------------------------------------
|
||
|
// lookup
|
||
|
|
||
11 years ago
|
const CGpmSheets::CSheet *CGpmSheets::lookup( CSheetId id )
|
||
13 years ago
|
{
|
||
|
nlassert(_initialised);
|
||
|
|
||
|
// setup an iterator and lookup the sheet id in the map
|
||
11 years ago
|
std::map<CSheetId,CGpmSheets::CSheet>::iterator it;
|
||
13 years ago
|
it=_sheets.find(id);
|
||
|
|
||
|
// if we found a valid entry return a pointer to the creature record otherwise 0
|
||
|
if (it!=_sheets.end())
|
||
|
return &((*it).second);
|
||
|
else
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
|