(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.

This commit is contained in:
rubidium
2007-01-10 18:56:51 +00:00
parent ce75f6549d
commit a7d0cdf95f
190 changed files with 2825 additions and 2208 deletions

View File

@@ -171,7 +171,7 @@ protected:
// rail transport is possible only on compatible rail types
if (IsRailTT()) {
RailType rail_type = GetTileRailType(m_new_tile, DiagdirToDiagTrackdir(m_exitdir));
RailType rail_type = GetTileRailType(m_new_tile, TrackdirToTrack(DiagdirToDiagTrackdir(m_exitdir)));
if (((1 << rail_type) & m_veh->u.rail.compatible_railtypes) == 0) {
// incompatible rail type
return false;

View File

@@ -3,33 +3,9 @@
#ifndef TRACK_DIR_HPP
#define TRACK_DIR_HPP
EXTERN_C_BEGIN
#include "../tile.h"
#include "../openttd.h"
#include "../map.h"
#include "../rail.h"
EXTERN_C_END
/** Helpers to allow to work with enum as with type safe bit set in C++ */
#define DECLARE_ENUM_AS_BIT_MASK(mask_t) \
FORCEINLINE mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((int)m1 | m2);} \
FORCEINLINE mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((int)m1 & m2);} \
FORCEINLINE mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((int)m1 ^ m2);} \
FORCEINLINE mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \
FORCEINLINE mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \
FORCEINLINE mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \
FORCEINLINE mask_t operator ~(mask_t m) {return (mask_t)(~(int)m);}
/** probably redundant enum combining operators (as we have conversion functions) */
#define DECLARE_ENUM_AS_BIT_INDEX(idx_t, mask_t) \
FORCEINLINE mask_t operator << (int m, idx_t i) {return (mask_t)(m << (int)i);} \
FORCEINLINE mask_t operator << (mask_t m, int i) {return (mask_t)(((int)m) << i);} \
FORCEINLINE mask_t operator >> (mask_t m, int i) {return (mask_t)(((int)m) >> i);}
DECLARE_ENUM_AS_BIT_MASK(TrackBits)
DECLARE_ENUM_AS_BIT_INDEX(Track, TrackBits)
DECLARE_ENUM_AS_BIT_MASK(TrackdirBits)
DECLARE_ENUM_AS_BIT_INDEX(Trackdir, TrackdirBits)
#endif /* TRACK_DIR_HPP */

View File

@@ -31,7 +31,7 @@ Trackdir YapfChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir)
* @param no_path_found [out] true is returned if no path can be found (returned Trackdir is only a 'guess')
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
*/
Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs, bool *path_not_found);
Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found);
/** Used by RV multistop feature to find the nearest road stop that has a free slot.
* @param v RV (its current tile will be the origin)

View File

@@ -7,7 +7,6 @@
#include "track_dir.hpp"
EXTERN_C_BEGIN
#include "../depot.h"
#include "../road_map.h"
#include "../tunnel_map.h"
@@ -22,12 +21,9 @@ EXTERN_C_BEGIN
#include "../pathfind.h"
#include "../waypoint.h"
#include "../debug.h"
EXTERN_C_END
EXTERN_C_BEGIN
extern Patches _patches_newgame;
extern uint64 _rdtsc(void);
EXTERN_C_END
extern Patches _patches_newgame;
extern uint64 _rdtsc(void);
#include <limits.h>
#include <new>

View File

@@ -3,9 +3,7 @@
#ifndef YAPF_BASE_HPP
#define YAPF_BASE_HPP
EXTERN_C_BEGIN
#include "../debug.h"
EXTERN_C_END
#include "fixedsizearray.hpp"
#include "blob.hpp"

View File

@@ -132,8 +132,8 @@ public:
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
inline bool PfCalcEstimate(Node& n)
{
int dx = abs(TileX(n.GetTile()) - TileX(m_destTile));
int dy = abs(TileY(n.GetTile()) - TileY(m_destTile));
int dx = delta(TileX(n.GetTile()), TileX(m_destTile));
int dy = delta(TileY(n.GetTile()), TileY(m_destTile));
assert(dx >= 0 && dy >= 0);
int dd = min(dx, dy);
int dxy = abs(dx - dy);

View File

@@ -195,7 +195,7 @@ public:
Trackdir trackdir = n.m_key.m_td;
TileType tile_type = GetTileType(tile);
RailType rail_type = GetTileRailType(tile, trackdir);
RailType rail_type = GetTileRailType(tile, TrackdirToTrack(trackdir));
bool target_seen = Yapf().PfDetectDestination(tile, trackdir);
@@ -252,7 +252,7 @@ public:
// if tail type changes, finish segment (cached segment can't contain more rail types)
{
RailType new_rail_type = GetTileRailType(F.m_new_tile, (Trackdir)FindFirstBit2x64(F.m_new_td_bits));
RailType new_rail_type = GetTileRailType(F.m_new_tile, TrackdirToTrack(FindFirstTrackdir(F.m_new_td_bits)));
if (new_rail_type != rail_type) {
break;
}

View File

@@ -103,14 +103,14 @@ public:
/// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 't';}
static Trackdir stChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs, bool *path_not_found)
static Trackdir stChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found)
{
// create pathfinder instance
Tpf pf;
return pf.ChooseRailTrack(v, tile, enterdir, trackdirs, path_not_found);
return pf.ChooseRailTrack(v, tile, enterdir, tracks, path_not_found);
}
FORCEINLINE Trackdir ChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs, bool *path_not_found)
FORCEINLINE Trackdir ChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found)
{
// set origin and destination nodes
Yapf().SetOrigin(v->tile, GetVehicleTrackdir(v), INVALID_TILE, INVALID_TRACKDIR, 1, true);
@@ -200,10 +200,10 @@ struct CYapfAnyDepotRail2 : CYapfT<CYapfRail_TypesT<CYapfAnyDepotRail2, CFollowT
struct CYapfAnyDepotRail3 : CYapfT<CYapfRail_TypesT<CYapfAnyDepotRail3, CFollowTrackRailNo90, CRailNodeListTrackDir, CYapfDestinationAnyDepotRailT , CYapfFollowAnyDepotRailT> > {};
Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs, bool *path_not_found)
Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found)
{
// default is YAPF type 2
typedef Trackdir (*PfnChooseRailTrack)(Vehicle*, TileIndex, DiagDirection, TrackdirBits, bool*);
typedef Trackdir (*PfnChooseRailTrack)(Vehicle*, TileIndex, DiagDirection, TrackBits, bool*);
PfnChooseRailTrack pfnChooseRailTrack = &CYapfRail2::stChooseRailTrack;
// check if non-default YAPF type needed
@@ -212,7 +212,7 @@ Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir,
else if (_patches.yapf.disable_node_optimization)
pfnChooseRailTrack = &CYapfRail1::stChooseRailTrack; // Trackdir, allow 90-deg
Trackdir td_ret = pfnChooseRailTrack(v, tile, enterdir, trackdirs, path_not_found);
Trackdir td_ret = pfnChooseRailTrack(v, tile, enterdir, tracks, path_not_found);
return td_ret;
}