Add infos into target window
[ryzomcore.git] / ryzom / server / src / entities_game_service / stables / stable.cpp
blob82b78dbf5555e423d339de4f0262880c5362848a
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/>.
19 #include "stdpch.h"
20 #include "stable.h"
22 // static members of CStable
23 CStable * CStable::_Instance = NULL;
25 using namespace std;
26 using namespace NLMISC;
27 using namespace NLNET;
29 NL_INSTANCE_COUNTER_IMPL(CStable);
31 //----------------------------------------------------------------------------
32 // ctor
33 //----------------------------------------------------------------------------
34 CStable::CStable()
39 //----------------------------------------------------------------------------
40 // dtor
41 //----------------------------------------------------------------------------
42 CStable::~CStable()
44 _Stables.clear();
45 delete _Instance;
46 _Instance = NULL;
49 //----------------------------------------------------------------------------
50 // add a stable
51 //----------------------------------------------------------------------------
52 void CStable::addStable( const std::string& stableName, uint16 placeId, const std::string& continent, float x, float y, float z, float theta )
54 TStableData sd;
56 sd.StableName = stableName;
57 sd.Continent = CONTINENT::toContinent( continent );
58 sd.StableExitX = sint32(x * 1000);
59 sd.StableExitY = sint32(y * 1000);
60 sd.StableExitZ = sint32(z * 1000);
61 sd.Theta = theta;
63 if( ! isStable( placeId ) )
65 _Stables.insert( make_pair(placeId, sd) );
67 else
69 nlwarning("<CStable::addStable> Stable name %s (PlaceId %u) already exist !!!", stableName.c_str(), placeId );
73 //----------------------------------------------------------------------------
74 // return stable entry point coordinate
75 //----------------------------------------------------------------------------
76 bool CStable::getStableData( uint16 placeId, TStableData& stableData ) const
78 TStableContainer::const_iterator it = _Stables.find( placeId );
79 if( it != _Stables.end() )
81 stableData = (*it).second;
82 return true;
84 return false;