Changeset - r13839:005eeef9d2c1
[Not reviewed]
master
0 4 0
rubidium - 15 years ago 2009-12-02 16:38:33
rubidium@openttd.org
(svn r18378) -Codechange: move the pathfinder 'length' constants to pathfinder_type.h
4 files changed with 27 insertions and 36 deletions:
0 comments (0 inline, 0 general)
src/pathfinder/npf/npf.h
Show inline comments
 
@@ -22,42 +22,24 @@
 
#include "../../core/bitmath_func.hpp"
 
#include "../../transport_type.h"
 

	
 
/* mowing grass */
 
enum {
 
	NPF_HASH_BITS = 12, ///< The size of the hash used in pathfinding. Just changing this value should be sufficient to change the hash size. Should be an even value.
 
	/* Do no change below values */
 
	NPF_HASH_SIZE = 1 << NPF_HASH_BITS,
 
	NPF_HASH_HALFBITS = NPF_HASH_BITS / 2,
 
	NPF_HASH_HALFMASK = (1 << NPF_HASH_HALFBITS) - 1
 
};
 

	
 
/* For new pathfinding. Define here so it is globally available without having
 
 * to include npf.h */
 
enum {
 
	NPF_TILE_LENGTH = 100
 
};
 

	
 
enum {
 
	/**
 
	 * This penalty is the equivalent of "infite", which means that paths that
 
	 * get this penalty will be chosen, but only if there is no other route
 
	 * without it. Be careful with not applying this penalty to often, or the
 
	 * total path cost might overflow..
 
	 * For now, this is just a Very Big Penalty, we might actually implement
 
	 * this in a nicer way :-)
 
	 */
 
	NPF_INFINITE_PENALTY = 1000 * NPF_TILE_LENGTH
 
};
 

	
 
/* Meant to be stored in AyStar.targetdata */
 
struct NPFFindStationOrTileData {
 
	TileIndex dest_coords;   ///< An indication of where the station is, for heuristic purposes, or the target tile
 
	StationID station_index; ///< station index we're heading for, or INVALID_STATION when we're heading for a tile
 
	bool      reserve_path;  ///< Indicates whether the found path should be reserved
 
	const Vehicle *v;        ///< The vehicle we are pathfinding for
 
};
 

	
 
/* Indices into AyStar.userdata[] */
 
enum {
 
	NPF_TYPE = 0,  ///< Contains a TransportTypes value
 
	NPF_SUB_TYPE,  ///< Contains the sub transport type
src/pathfinder/pathfinder_type.h
Show inline comments
 
@@ -3,24 +3,50 @@
 
/*
 
 * 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 pathfinder_type.h General types related to pathfinders. */
 

	
 
#ifndef PATHFINDER_TYPE_H
 
#define PATHFINDER_TYPE_H
 

	
 
/** Length (penalty) of one tile with NPF */
 
static const int NPF_TILE_LENGTH = 100;
 

	
 
/**
 
 * This penalty is the equivalent of "infite", which means that paths that
 
 * get this penalty will be chosen, but only if there is no other route
 
 * without it. Be careful with not applying this penalty to often, or the
 
 * total path cost might overflow..
 
 */
 
static const int NPF_INFINITE_PENALTY = 1000 * NPF_TILE_LENGTH;
 

	
 

	
 
/** Length (penalty) of one tile with YAPF */
 
static const int YAPF_TILE_LENGTH = 100;
 

	
 
/** Length (penalty) of a corner with YAPF */
 
static const int YAPF_TILE_CORNER_LENGTH = 71;
 

	
 
/**
 
 * This penalty is the equivalent of "infite", which means that paths that
 
 * get this penalty will be chosen, but only if there is no other route
 
 * without it. Be careful with not applying this penalty to often, or the
 
 * total path cost might overflow..
 
 */
 
static const int YAPF_INFINITE_PENALTY = 1000 * YAPF_TILE_LENGTH;
 

	
 
/**
 
 * Helper container to find a depot
 
 */
 
struct FindDepotData {
 
	TileIndex tile;   ///< The tile of the depot
 
	uint best_length; ///< The distance towards the depot, or UINT_MAX if not found
 
	bool reverse;     ///< True if reversing is necessary for the train to get to this depot
 

	
 
	/**
 
	 * Create an instance of this structure.
 
	 * @param tile        the tile of the depot
 
	 * @param best_length the distance towards the depot, or UINT_MAX if not found
src/pathfinder/yapf/yapf.h
Show inline comments
 
@@ -96,29 +96,13 @@ bool YapfTrainCheckReverse(const Train *
 
 *
 
 * @param v    The train that needs to find a safe tile.
 
 * @param tile Last tile of the current reserved path.
 
 * @param td   Last trackdir of the current reserved path.
 
 * @param override_railtype Should all physically compatible railtypes be searched, even if the vehicle can't run on them on its own?
 
 * @return True if the path could be extended to a safe tile.
 
 */
 
bool YapfTrainFindNearestSafeTile(const Train *v, TileIndex tile, Trackdir td, bool override_railtype);
 

	
 
/** Use this function to notify YAPF that track layout (or signal configuration) has change */
 
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track);
 

	
 
/** Base tile length units */
 
enum {
 
	YAPF_TILE_LENGTH = 100,
 
	YAPF_TILE_CORNER_LENGTH = 71,
 

	
 
	/**
 
	 * This penalty is the equivalent of "infite", which means that paths that
 
	 * get this penalty will be chosen, but only if there is no other route
 
	 * without it. Be careful with not applying this penalty to often, or the
 
	 * total path cost might overflow..
 
	 * For now, this is just a Very Big Penalty, we might actually implement
 
	 * this in a nicer way :-)
 
	 */
 
	YAPF_INFINITE_PENALTY = 1000 * YAPF_TILE_LENGTH,
 
};
 

	
 
#endif /* YAPF_H */
src/settings.cpp
Show inline comments
 
@@ -22,26 +22,25 @@
 
 * @see SaveLoad
 
 */
 

	
 
#include "stdafx.h"
 
#include "currency.h"
 
#include "screenshot.h"
 
#include "variables.h"
 
#include "network/network.h"
 
#include "network/network_func.h"
 
#include "settings_internal.h"
 
#include "command_func.h"
 
#include "console_func.h"
 
#include "pathfinder/npf/npf.h"
 
#include "pathfinder/yapf/yapf.h"
 
#include "pathfinder/pathfinder_type.h"
 
#include "genworld.h"
 
#include "train.h"
 
#include "news_func.h"
 
#include "window_func.h"
 
#include "strings_func.h"
 
#include "vehicle_func.h"
 
#include "sound_func.h"
 
#include "company_func.h"
 
#include "rev.h"
 
#ifdef WITH_FREETYPE
 
#include "fontcache.h"
 
#endif
0 comments (0 inline, 0 general)