[2771] Applied MaNGOS coding style (see trunk/bcpp.cfg).
[mangos-git.git] / src / game / GridStates.cpp
blobd633973073bd7c5de9b27aaa636d60c563040727
1 /*
2 * Copyright (C) 2005,2006 MaNGOS <http://www.mangosproject.org/>
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 if( grid.ObjectsInGrid() == 0 && !ObjectAccessor::Instance().PlayersNearGrid(x, y, m.GetId()) )
34 grid.SetGridState(GRID_STATE_IDLE);
37 void
38 IdleState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 &x, const uint32 &y, const uint32 &) const
40 m.ResetGridExpiry(info);
41 grid.SetGridState(GRID_STATE_REMOVAL);
42 sLog.outDebug("Grid[%u,%u] on map %u moved to IDLE state", x, y, m.GetId());
45 void
46 RemovalState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 &x, const uint32 &y, const uint32 &t_diff) const
48 if(info.i_unloadflag)
50 info.i_timer.Update(t_diff);
51 if( info.i_timer.Passed() )
53 if( !m.UnloadGrid(x, y) )
55 sLog.outDebug("Grid[%u,%u] for map %u differed unloading due to players nearby", x, y, m.GetId());
56 m.ResetGridExpiry(info);