Merge branch 'master' into jgrpp-nrt

Merge NRT feature

# Conflicts:
#	docs/landscape.html
#	docs/landscape_grid.html
#	src/bridge_map.h
#	src/build_vehicle_gui.cpp
#	src/company_base.h
#	src/company_cmd.cpp
#	src/misc_gui.cpp
#	src/newgrf.cpp
#	src/newgrf_engine.cpp
#	src/pathfinder/follow_track.hpp
#	src/pathfinder/npf/npf.cpp
#	src/road_cmd.cpp
#	src/road_func.h
#	src/road_gui.cpp
#	src/road_map.h
#	src/road_type.h
#	src/roadveh_cmd.cpp
#	src/saveload/afterload.cpp
#	src/saveload/company_sl.cpp
#	src/script/api/script_bridge.cpp
#	src/table/newgrf_debug_data.h
#	src/tile_cmd.h
#	src/town_cmd.cpp
#	src/tunnel_map.h
#	src/tunnelbridge_cmd.cpp
This commit is contained in:
Jonathan G Rennison
2019-07-11 19:45:56 +01:00
177 changed files with 4839 additions and 1461 deletions

View File

@@ -13,29 +13,9 @@
#define ROAD_FUNC_H
#include "core/bitmath_func.hpp"
#include "road_type.h"
#include "road.h"
#include "economy_func.h"
/**
* Iterate through each set RoadType in a RoadTypes value.
* For more informations see FOR_EACH_SET_BIT_EX.
*
* @param var Loop index variable that stores fallowing set road type. Must be of type RoadType.
* @param road_types The value to iterate through (any expression).
*
* @see FOR_EACH_SET_BIT_EX
*/
#define FOR_EACH_SET_ROADTYPE(var, road_types) FOR_EACH_SET_BIT_EX(RoadType, var, RoadTypes, road_types)
/**
* Whether the given roadtype is valid.
* @param rt the roadtype to check for validness
* @return true if and only if valid
*/
static inline bool IsValidRoadType(RoadType rt)
{
return rt == ROADTYPE_ROAD || rt == ROADTYPE_TRAM;
}
#include "transparency.h"
/**
* Whether the given roadtype is valid.
@@ -47,32 +27,6 @@ static inline bool IsValidRoadBits(RoadBits r)
return r < ROAD_END;
}
/**
* Maps a RoadType to the corresponding RoadTypes value
*
* @param rt the roadtype to get the roadtypes from
* @return the roadtypes with the given roadtype
*/
static inline RoadTypes RoadTypeToRoadTypes(RoadType rt)
{
assert(IsValidRoadType(rt));
return (RoadTypes)(1 << rt);
}
/**
* Returns the RoadTypes which are not present in the given RoadTypes
*
* This function returns the complement of a given RoadTypes.
*
* @param r The given RoadTypes
* @return The complement of the given RoadTypes
*/
static inline RoadTypes ComplementRoadTypes(RoadTypes r)
{
return (RoadTypes)(ROADTYPES_ALL ^ r);
}
/**
* Calculate the complement of a RoadBits value
*
@@ -167,27 +121,53 @@ static inline RoadBits AxisToRoadBits(Axis a)
* Calculates the maintenance cost of a number of road bits.
* @param roadtype Road type to get the cost for.
* @param num Number of road bits.
* @param total_num Total number of road bits of all road/tram-types.
* @return Total cost.
*/
static inline Money RoadMaintenanceCost(RoadType roadtype, uint32 num)
static inline Money RoadMaintenanceCost(RoadType roadtype, uint32 num, uint32 total_num)
{
assert(IsValidRoadType(roadtype));
return (_price[PR_INFRASTRUCTURE_ROAD] * (roadtype == ROADTYPE_TRAM ? 3 : 2) * num * (1 + IntSqrt(num))) >> 9; // 2 bits fraction for the multiplier and 7 bits scaling.
assert(roadtype < ROADTYPE_END);
return (_price[PR_INFRASTRUCTURE_ROAD] * GetRoadTypeInfo(roadtype)->maintenance_multiplier * num * (1 + IntSqrt(total_num))) >> 12;
}
bool HasRoadTypesAvail(const CompanyID company, const RoadTypes rts);
bool ValParamRoadType(const RoadType rt);
RoadTypes GetCompanyRoadtypes(const CompanyID company);
/**
* Test if a road type has catenary
* @param roadtype Road type to test
*/
static inline bool HasRoadCatenary(RoadType roadtype)
{
assert(roadtype < ROADTYPE_END);
return HasBit(GetRoadTypeInfo(roadtype)->flags, ROTF_CATENARY);
}
/**
* Test if we should draw road catenary
* @param roadtype Road type to test
*/
static inline bool HasRoadCatenaryDrawn(RoadType roadtype)
{
return HasRoadCatenary(roadtype) && !IsInvisibilitySet(TO_CATENARY);
}
bool HasRoadTypeAvail(CompanyID company, RoadType roadtype);
bool ValParamRoadType(RoadType roadtype);
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces = true);
RoadTypes GetRoadTypes(bool introduces);
RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, Date date);
void UpdateLevelCrossing(TileIndex tile, bool sound = true, bool force_close = false);
bool IsCrossingOccupiedByRoadVehicle(TileIndex t);
void UpdateCompanyRoadInfrastructure(RoadType rt, Owner o, int count);
struct TileInfo;
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rit, uint road_offset, uint tram_offset);
inline void NotifyRoadLayoutChanged()
{
_road_layout_change_counter++;
}
void NotifyRoadLayoutChangedIfTileNonLeaf(TileIndex tile, RoadType rt, RoadBits present_bits);
void NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(TileIndex start, TileIndex end, DiagDirection start_dir, RoadType rt);
void NotifyRoadLayoutChangedIfTileNonLeaf(TileIndex tile, RoadTramType rtt, RoadBits present_bits);
void NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(TileIndex start, TileIndex end, DiagDirection start_dir, RoadTramType rtt);
#endif /* ROAD_FUNC_H */