mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
Minor changes to avoid undefined behaviour warnings.
Avoid creating a reference from a nullptr. Avoid trying a malloc and memcpy into a 0 length buffer. Virtual trains should never be drawn.
This commit is contained in:
parent
a70b1e5e9e
commit
330a7327d6
@ -3664,8 +3664,11 @@ static void DuplicateTileTable(AirportSpec *as)
|
||||
MemCpyT(table_list[i], as->table[i], num_tiles);
|
||||
}
|
||||
as->table = table_list;
|
||||
HangarTileTable *depot_table = MallocT<HangarTileTable>(as->nof_depots);
|
||||
MemCpyT(depot_table, as->depot_table, as->nof_depots);
|
||||
HangarTileTable *depot_table = NULL;
|
||||
if (as->nof_depots > 0) {
|
||||
depot_table = MallocT<HangarTileTable>(as->nof_depots);
|
||||
MemCpyT(depot_table, as->depot_table, as->nof_depots);
|
||||
}
|
||||
as->depot_table = depot_table;
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ protected:
|
||||
/** stores track status (available trackdirs) for the new tile into m_new_td_bits */
|
||||
inline bool QueryNewTileTrackStatus()
|
||||
{
|
||||
CPerfStart perf(*m_pPerf);
|
||||
CPerfStart perf(m_pPerf);
|
||||
if (IsRailTT() && IsPlainRailTile(m_new_tile)) {
|
||||
m_new_td_bits = (TrackdirBits)(GetTrackBits(m_new_tile) * 0x101);
|
||||
} else {
|
||||
|
@ -51,7 +51,7 @@ struct CPerfStartReal
|
||||
{
|
||||
CPerformanceTimer *m_pperf;
|
||||
|
||||
inline CPerfStartReal(CPerformanceTimer& perf) : m_pperf(&perf)
|
||||
inline CPerfStartReal(CPerformanceTimer* perf) : m_pperf(perf)
|
||||
{
|
||||
if (m_pperf != NULL) m_pperf->Start();
|
||||
}
|
||||
@ -72,7 +72,7 @@ struct CPerfStartReal
|
||||
|
||||
struct CPerfStartFake
|
||||
{
|
||||
inline CPerfStartFake(CPerformanceTimer& perf) {}
|
||||
inline CPerfStartFake(CPerformanceTimer* perf) {}
|
||||
inline ~CPerfStartFake() {}
|
||||
inline void Stop() {}
|
||||
};
|
||||
|
@ -94,7 +94,7 @@ protected:
|
||||
public:
|
||||
inline int SlopeCost(TileIndex tile, Trackdir td)
|
||||
{
|
||||
CPerfStart perf_cost(Yapf().m_perf_slope_cost);
|
||||
CPerfStart perf_cost(&Yapf().m_perf_slope_cost);
|
||||
if (!stSlopeCost(tile, td)) return 0;
|
||||
return Yapf().PfGetSettings().rail_slope_penalty;
|
||||
}
|
||||
@ -280,7 +280,7 @@ public:
|
||||
{
|
||||
int cost = 0;
|
||||
/* if there is one-way signal in the opposite direction, then it is not our way */
|
||||
CPerfStart perf_cost(Yapf().m_perf_other_cost);
|
||||
CPerfStart perf_cost(&Yapf().m_perf_other_cost);
|
||||
if (IsTileType(tile, MP_RAILWAY)) {
|
||||
bool has_signal_against = HasSignalOnTrackdir(tile, ReverseTrackdir(trackdir));
|
||||
bool has_signal_along = HasSignalOnTrackdir(tile, trackdir);
|
||||
@ -402,7 +402,7 @@ public:
|
||||
assert(tf->m_new_tile == n.m_key.m_tile);
|
||||
assert((TrackdirToTrackdirBits(n.m_key.m_td) & tf->m_new_td_bits) != TRACKDIR_BIT_NONE);
|
||||
|
||||
CPerfStart perf_cost(Yapf().m_perf_cost);
|
||||
CPerfStart perf_cost(&Yapf().m_perf_cost);
|
||||
|
||||
/* Does the node have some parent node? */
|
||||
bool has_parent = (n.m_parent != NULL);
|
||||
|
@ -296,10 +296,10 @@ uint Vehicle::Crash(bool flooded)
|
||||
*/
|
||||
bool Vehicle::IsDrawn() const
|
||||
{
|
||||
return !(this->vehstatus & VS_HIDDEN) ||
|
||||
return !(HasBit(this->subtype, GVSF_VIRTUAL)) && (!(this->vehstatus & VS_HIDDEN) ||
|
||||
(IsTransparencySet(TO_TUNNELS) &&
|
||||
((this->type == VEH_TRAIN && Train::From(this)->track == TRACK_BIT_WORMHOLE) ||
|
||||
(this->type == VEH_ROAD && RoadVehicle::From(this)->state == RVSB_WORMHOLE)));
|
||||
(this->type == VEH_ROAD && RoadVehicle::From(this)->state == RVSB_WORMHOLE))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user