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"
26 InvalidState::Update(Map
&, NGridType
&, GridInfo
&, const uint32
&x
, const uint32
&y
, const uint32
&) const
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
);
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());
46 RemovalState::Update(Map
&m
, NGridType
&grid
, GridInfo
&info
, const uint32
&x
, const uint32
&y
, const uint32
&t_diff
) const
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
);