Merge branch 'multiple_docks' into jgrpp
commit
ea84c8fd0c
@ -0,0 +1,37 @@
|
||||
/* $Id: dock.cpp $ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD 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 General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file dock.cpp Implementation of the dock base class. */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "core/pool_func.hpp"
|
||||
#include "dock_base.h"
|
||||
#include "station_base.h"
|
||||
|
||||
/** The pool of docks. */
|
||||
DockPool _dock_pool("Dock");
|
||||
INSTANTIATE_POOL_METHODS(Dock)
|
||||
|
||||
/**
|
||||
* Find a dock at a given tile.
|
||||
* @param tile Tile with a dock.
|
||||
* @return The dock in the given tile.
|
||||
* @pre IsDockTile()
|
||||
*/
|
||||
/* static */ Dock *Dock::GetByTile(TileIndex tile)
|
||||
{
|
||||
const Station *st = Station::GetByTile(tile);
|
||||
|
||||
for (Dock *d = st->GetPrimaryDock();; d = d->next) {
|
||||
if (d->sloped == tile || d->flat == tile) return d;
|
||||
assert(d->next != NULL);
|
||||
}
|
||||
|
||||
NOT_REACHED();
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* $Id: dock_base.h $ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD 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 General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file dock_base.h Base class for docks. */
|
||||
|
||||
#ifndef DOCK_BASE_H
|
||||
#define DOCK_BASE_H
|
||||
|
||||
#include "station_type.h"
|
||||
#include "tile_type.h"
|
||||
#include "core/pool_type.hpp"
|
||||
|
||||
typedef Pool<Dock, DockID, 32, 64000> DockPool;
|
||||
extern DockPool _dock_pool;
|
||||
|
||||
/** A Dock structure. */
|
||||
struct Dock : DockPool::PoolItem<&_dock_pool> {
|
||||
TileIndex sloped; ///< The sloped tile of the dock.
|
||||
TileIndex flat; ///< Position on the map of the flat tile.
|
||||
Dock *next; ///< Next dock of the given type at this station.
|
||||
|
||||
Dock(TileIndex s = INVALID_TILE, TileIndex f = INVALID_TILE) : sloped(s), flat(f), next(NULL) { }
|
||||
|
||||
~Dock() {}
|
||||
|
||||
inline Dock *GetNextDock() const { return this->next; }
|
||||
|
||||
static Dock *GetByTile(TileIndex tile);
|
||||
};
|
||||
|
||||
#define FOR_ALL_DOCKS_FROM(var, start) FOR_ALL_ITEMS_FROM(Dock, dock_index, var, start)
|
||||
#define FOR_ALL_DOCKS(var) FOR_ALL_DOCKS_FROM(var, 0)
|
||||
|
||||
#endif /* DOCK_BASE_H */
|
Loading…
Reference in New Issue