[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / src / game / GridStates.cpp
blob1bace7c27ceb72fa46afc14269862eee8b3d9a0b
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
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 General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "GridStates.h"
20 #include "GridNotifiers.h"
21 #include "ObjectAccessor.h"
22 #include "GameSystem/Grid.h"
23 #include "Log.h"
25 void
26 InvalidState::Update(Map &, NGridType &, GridInfo &, const uint32 &/*x*/, const uint32 &/*y*/, const uint32 &) const
30 void
31 ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 &x, const uint32 &y, const uint32 &t_diff) const
33 // Only check grid activity every (grid_expiry/10) ms, because it's really useless to do it every cycle
34 info.UpdateTimeTracker(t_diff);
35 if( info.getTimeTracker().Passed() )
37 if( grid.ActiveObjectsInGrid() == 0 && !m.PlayersNearGrid(x, y) )
39 ObjectGridStoper stoper(grid);
40 stoper.StopN();
41 grid.SetGridState(GRID_STATE_IDLE);
43 else
45 m.ResetGridExpiry(grid, 0.1f);
50 void
51 IdleState::Update(Map &m, NGridType &grid, GridInfo &, const uint32 &x, const uint32 &y, const uint32 &) const
53 m.ResetGridExpiry(grid);
54 grid.SetGridState(GRID_STATE_REMOVAL);
55 sLog.outDebug("Grid[%u,%u] on map %u moved to IDLE state", x, y, m.GetId());
58 void
59 RemovalState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 &x, const uint32 &y, const uint32 &t_diff) const
61 if(info.getUnloadFlag())
63 info.UpdateTimeTracker(t_diff);
64 if( info.getTimeTracker().Passed() )
66 if( !m.UnloadGrid(x, y, false) )
68 sLog.outDebug("Grid[%u,%u] for map %u differed unloading due to players nearby", x, y, m.GetId());
69 m.ResetGridExpiry(grid);