Change various asserts to not be included in release builds

This commit is contained in:
Jonathan G Rennison 2022-10-22 12:34:54 +01:00
parent 071ac374e8
commit 29a1e49c28
53 changed files with 522 additions and 520 deletions

View File

@ -527,7 +527,7 @@ class btree_node {
// be a leaf.
bool is_root() const { return parent()->leaf(); }
void make_root() {
assert(parent()->is_root());
dbg_assert(parent()->is_root());
fields_.parent = fields_.parent->parent();
}
@ -1266,7 +1266,7 @@ class btree : public Params::key_compare {
}
void delete_internal_node(node_type *node) {
node->destroy();
assert(node != root());
dbg_assert(node != root());
mutable_internal_allocator()->deallocate(
reinterpret_cast<char*>(node), sizeof(internal_fields));
}
@ -1422,7 +1422,7 @@ class btree : public Params::key_compare {
// btree_node methods
template <typename P>
inline void btree_node<P>::insert_value(int i, const value_type &x) {
assert(i <= count());
dbg_assert(i <= count());
value_init(count(), x);
for (int j = count(); j > i; --j) {
value_swap(j, this, j - 1);
@ -1442,7 +1442,7 @@ inline void btree_node<P>::insert_value(int i, const value_type &x) {
template <typename P>
inline void btree_node<P>::remove_value(int i) {
if (!leaf()) {
assert(child(i + 1)->count() == 0);
dbg_assert(child(i + 1)->count() == 0);
for (int j = i + 1; j < count(); ++j) {
*mutable_child(j) = child(j + 1);
child(j)->set_position(j);
@ -1459,11 +1459,11 @@ inline void btree_node<P>::remove_value(int i) {
template <typename P>
void btree_node<P>::rebalance_right_to_left(btree_node *src, int to_move) {
assert(parent() == src->parent());
assert(position() + 1 == src->position());
assert(src->count() >= count());
assert(to_move >= 1);
assert(to_move <= src->count());
dbg_assert(parent() == src->parent());
dbg_assert(position() + 1 == src->position());
dbg_assert(src->count() >= count());
dbg_assert(to_move >= 1);
dbg_assert(to_move <= src->count());
// Make room in the left node for the new values.
for (int i = 0; i < to_move; ++i) {
@ -1493,7 +1493,7 @@ void btree_node<P>::rebalance_right_to_left(btree_node *src, int to_move) {
set_child(1 + count() + i, src->child(i));
}
for (int i = 0; i <= src->count() - to_move; ++i) {
assert(i + to_move <= src->max_count());
dbg_assert(i + to_move <= src->max_count());
src->set_child(i, src->child(i + to_move));
*src->mutable_child(i + to_move) = NULL;
}
@ -1506,11 +1506,11 @@ void btree_node<P>::rebalance_right_to_left(btree_node *src, int to_move) {
template <typename P>
void btree_node<P>::rebalance_left_to_right(btree_node *dest, int to_move) {
assert(parent() == dest->parent());
assert(position() + 1 == dest->position());
assert(count() >= dest->count());
assert(to_move >= 1);
assert(to_move <= count());
dbg_assert(parent() == dest->parent());
dbg_assert(position() + 1 == dest->position());
dbg_assert(count() >= dest->count());
dbg_assert(to_move >= 1);
dbg_assert(to_move <= count());
// Make room in the right node for the new values.
for (int i = 0; i < to_move; ++i) {
@ -1551,7 +1551,7 @@ void btree_node<P>::rebalance_left_to_right(btree_node *dest, int to_move) {
template <typename P>
void btree_node<P>::split(btree_node *dest, int insert_position) {
assert(dest->count() == 0);
dbg_assert(dest->count() == 0);
// We bias the split based on the position being inserted. If we're
// inserting at the beginning of the left node then bias the split to put
@ -1565,7 +1565,7 @@ void btree_node<P>::split(btree_node *dest, int insert_position) {
dest->set_count(count() / 2);
}
set_count(count() - dest->count());
assert(count() >= 1);
dbg_assert(count() >= 1);
// Move values from the left sibling to the right sibling.
for (int i = 0; i < dest->count(); ++i) {
@ -1583,7 +1583,7 @@ void btree_node<P>::split(btree_node *dest, int insert_position) {
if (!leaf()) {
for (int i = 0; i <= dest->count(); ++i) {
assert(child(count() + i + 1) != NULL);
dbg_assert(child(count() + i + 1) != NULL);
dest->set_child(i, child(count() + i + 1));
*mutable_child(count() + i + 1) = NULL;
}
@ -1592,8 +1592,8 @@ void btree_node<P>::split(btree_node *dest, int insert_position) {
template <typename P>
void btree_node<P>::merge(btree_node *src) {
assert(parent() == src->parent());
assert(position() + 1 == src->position());
dbg_assert(parent() == src->parent());
dbg_assert(position() + 1 == src->position());
// Move the delimiting value to the left node.
value_init(count());
@ -1624,7 +1624,7 @@ void btree_node<P>::merge(btree_node *src) {
template <typename P>
void btree_node<P>::swap(btree_node *x) {
assert(leaf() == x->leaf());
dbg_assert(leaf() == x->leaf());
// Swap the values.
for (int i = count(); i < x->count(); ++i) {
@ -1666,10 +1666,10 @@ void btree_node<P>::swap(btree_node *x) {
template <typename N, typename R, typename P>
void btree_iterator<N, R, P>::increment_slow() {
if (node->leaf()) {
assert(position >= node->count());
dbg_assert(position >= node->count());
self_type save(*this);
while (position == node->count() && !node->is_root()) {
assert(node->parent()->child(node->position()) == node);
dbg_assert(node->parent()->child(node->position()) == node);
position = node->position();
node = node->parent();
}
@ -1677,7 +1677,7 @@ void btree_iterator<N, R, P>::increment_slow() {
*this = save;
}
} else {
assert(position < node->count());
dbg_assert(position < node->count());
node = node->child(position + 1);
while (!node->leaf()) {
node = node->child(0);
@ -1706,10 +1706,10 @@ void btree_iterator<N, R, P>::increment_by(int count) {
template <typename N, typename R, typename P>
void btree_iterator<N, R, P>::decrement_slow() {
if (node->leaf()) {
assert(position <= -1);
dbg_assert(position <= -1);
self_type save(*this);
while (position < 0 && !node->is_root()) {
assert(node->parent()->child(node->position()) == node);
dbg_assert(node->parent()->child(node->position()) == node);
position = node->position() - 1;
node = node->parent();
}
@ -1717,7 +1717,7 @@ void btree_iterator<N, R, P>::decrement_slow() {
*this = save;
}
} else {
assert(position >= 0);
dbg_assert(position >= 0);
node = node->child(position);
while (!node->leaf()) {
node = node->child(node->count());
@ -1870,8 +1870,8 @@ typename btree<P>::iterator btree<P>::erase(iterator iter) {
// Deletion of a value on an internal node. Swap the key with the largest
// value of our left child. This is easy, we just decrement iter.
iterator tmp_iter(iter--);
assert(iter.node->leaf());
assert(!compare_keys(tmp_iter.key(), iter.key()));
dbg_assert(iter.node->leaf());
dbg_assert(!compare_keys(tmp_iter.key(), iter.key()));
iter.node->value_swap(iter.position, tmp_iter.node, tmp_iter.position);
internal_delete = true;
--*mutable_size();
@ -1975,15 +1975,15 @@ void btree<P>::swap(self_type &x) {
template <typename P>
void btree<P>::verify() const {
if (root() != NULL) {
assert(size() == internal_verify(root(), NULL, NULL));
assert(leftmost() == (++const_iterator(root(), -1)).node);
assert(rightmost() == (--const_iterator(root(), root()->count())).node);
assert(leftmost()->leaf());
assert(rightmost()->leaf());
dbg_assert(size() == internal_verify(root(), NULL, NULL));
dbg_assert(leftmost() == (++const_iterator(root(), -1)).node);
dbg_assert(rightmost() == (--const_iterator(root(), root()->count())).node);
dbg_assert(leftmost()->leaf());
dbg_assert(rightmost()->leaf());
} else {
assert(size() == 0);
assert(leftmost() == NULL);
assert(rightmost() == NULL);
dbg_assert(size() == 0);
dbg_assert(leftmost() == NULL);
dbg_assert(rightmost() == NULL);
}
}
@ -1991,7 +1991,7 @@ template <typename P>
void btree<P>::rebalance_or_split(iterator *iter) {
node_type *&node = iter->node;
int &insert_position = iter->position;
assert(node->count() == node->max_count());
dbg_assert(node->count() == node->max_count());
// First try to make room on the node by rebalancing.
node_type *parent = node->parent();
@ -2011,14 +2011,14 @@ void btree<P>::rebalance_or_split(iterator *iter) {
((left->count() + to_move) < left->max_count())) {
left->rebalance_right_to_left(node, to_move);
assert(node->max_count() - node->count() == to_move);
dbg_assert(node->max_count() - node->count() == to_move);
insert_position = insert_position - to_move;
if (insert_position < 0) {
insert_position = insert_position + left->count() + 1;
node = left;
}
assert(node->count() < node->max_count());
dbg_assert(node->count() < node->max_count());
return;
}
}
@ -2044,7 +2044,7 @@ void btree<P>::rebalance_or_split(iterator *iter) {
node = right;
}
assert(node->count() < node->max_count());
dbg_assert(node->count() < node->max_count());
return;
}
}
@ -2064,7 +2064,7 @@ void btree<P>::rebalance_or_split(iterator *iter) {
parent = new_internal_root_node();
parent->set_child(0, root());
*mutable_root() = parent;
assert(*mutable_rightmost() == parent->child(0));
dbg_assert(*mutable_rightmost() == parent->child(0));
} else {
// The root node is an internal node. We do not want to create a new root
// node because the root node is special and holds the size of the tree
@ -2168,7 +2168,7 @@ void btree<P>::try_shrink() {
}
// Deleted the last item on the root node, shrink the height of the tree.
if (root()->leaf()) {
assert(size() == 0);
dbg_assert(size() == 0);
delete_leaf_node(root());
*mutable_root() = NULL;
} else {
@ -2214,7 +2214,7 @@ btree<P>::internal_insert(iterator iter, const value_type &v) {
if (iter.node->max_count() < kNodeValues) {
// Insertion into the root where the root is smaller that the full node
// size. Simply grow the size of the root node.
assert(iter.node == root());
dbg_assert(iter.node == root());
iter.node = new_leaf_root_node(
std::min<int>(kNodeValues, 2 * iter.node->max_count()));
iter.node->swap(root());
@ -2369,23 +2369,23 @@ void btree<P>::internal_dump(
template <typename P>
int btree<P>::internal_verify(
const node_type *node, const key_type *lo, const key_type *hi) const {
assert(node->count() > 0);
assert(node->count() <= node->max_count());
dbg_assert(node->count() > 0);
dbg_assert(node->count() <= node->max_count());
if (lo) {
assert(!compare_keys(node->key(0), *lo));
dbg_assert(!compare_keys(node->key(0), *lo));
}
if (hi) {
assert(!compare_keys(*hi, node->key(node->count() - 1)));
dbg_assert(!compare_keys(*hi, node->key(node->count() - 1)));
}
for (int i = 1; i < node->count(); ++i) {
assert(!compare_keys(node->key(i), node->key(i - 1)));
dbg_assert(!compare_keys(node->key(i), node->key(i - 1)));
}
int count = node->count();
if (!node->leaf()) {
for (int i = 0; i <= node->count(); ++i) {
assert(node->child(i) != NULL);
assert(node->child(i)->parent() == node);
assert(node->child(i)->position() == i);
dbg_assert(node->child(i) != NULL);
dbg_assert(node->child(i)->parent() == node);
dbg_assert(node->child(i)->position() == i);
count += internal_verify(
node->child(i),
(i == 0) ? lo : &node->key(i - 1),

View File

@ -122,13 +122,13 @@ class safe_btree_iterator {
// This reference value is potentially invalidated by any non-const
// method on the tree; it is NOT safe.
reference operator*() const {
assert(generation_ > 0);
dbg_assert(generation_ > 0);
return iter().operator*();
}
// This pointer value is potentially invalidated by any non-const
// method on the tree; it is NOT safe.
pointer operator->() const {
assert(generation_ > 0);
dbg_assert(generation_ > 0);
return iter().operator->();
}

View File

@ -281,7 +281,7 @@ SQInteger SQSharedState::CollectGarbage(SQVM *vm)
SQGCMarkerQueue queue;
queue.Enqueue(vms);
#ifdef WITH_ASSERT
#ifdef WITH_FULL_ASSERTS
SQInteger x = _table(_thread(_root_vm)->_roottable)->CountUsed();
#endif
_refs_table.EnqueueMarkObject(queue);
@ -329,7 +329,7 @@ SQInteger SQSharedState::CollectGarbage(SQVM *vm)
t = t->_next;
}
_gc_chain = tchain;
#ifdef WITH_ASSERT
#ifdef WITH_FULL_ASSERTS
SQInteger z = _table(_thread(_root_vm)->_roottable)->CountUsed();
assert(z == x);
#endif

View File

@ -299,7 +299,7 @@ struct SpecializedStation : public BaseStation {
*/
static inline T *From(BaseStation *st)
{
assert(IsExpected(st));
dbg_assert(IsExpected(st));
return (T *)st;
}
@ -310,7 +310,7 @@ struct SpecializedStation : public BaseStation {
*/
static inline const T *From(const BaseStation *st)
{
assert(IsExpected(st));
dbg_assert(IsExpected(st));
return (const T *)st;
}

View File

@ -89,7 +89,7 @@ bool HasBridgeFlatRamp(Slope tileh, Axis axis);
*/
static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
{
assert(i < lengthof(_bridge));
dbg_assert(i < lengthof(_bridge));
return &_bridge[i];
}

View File

@ -125,7 +125,7 @@ CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16 count, So
source_xy(source_xy),
loaded_at_xy(0)
{
assert(count != 0);
dbg_assert(count != 0);
this->source_type = source_type;
}
@ -152,7 +152,7 @@ CargoPacket::CargoPacket(uint16 count, byte days_in_transit, StationID source, T
source_xy(source_xy),
loaded_at_xy(loaded_at_xy)
{
assert(count != 0);
dbg_assert(count != 0);
this->source_type = source_type;
}
@ -227,7 +227,7 @@ void CargoPacket::Merge(CargoPacket *cp)
*/
void CargoPacket::Reduce(uint count)
{
assert(count < this->count);
dbg_assert(count < this->count);
this->feeder_share -= this->FeederShare(count);
if (this->flags & CPF_HAS_DEFERRED_PAYMENT) {
IterateCargoPacketDeferredPayments(this->index, false, [&](Money &payment, CompanyID cid, VehicleType type) {
@ -335,7 +335,7 @@ void CargoList<Tinst, Tcont>::OnCleanPool()
template <class Tinst, class Tcont>
void CargoList<Tinst, Tcont>::RemoveFromCache(const CargoPacket *cp, uint count)
{
assert(count <= cp->count);
dbg_assert(count <= cp->count);
this->count -= count;
this->cargo_days_in_transit -= cp->days_in_transit * count;
}
@ -406,8 +406,8 @@ template <class Tinst, class Tcont>
*/
void VehicleCargoList::Append(CargoPacket *cp, MoveToAction action)
{
assert(cp != nullptr);
assert(action == MTA_LOAD ||
dbg_assert(cp != nullptr);
dbg_assert(action == MTA_LOAD ||
(action == MTA_KEEP && this->action_counts[MTA_LOAD] == 0));
this->AddToMeta(cp, action);
@ -541,7 +541,7 @@ void VehicleCargoList::AddToCache(const CargoPacket *cp)
*/
void VehicleCargoList::RemoveFromMeta(const CargoPacket *cp, MoveToAction action, uint count)
{
assert(count <= this->action_counts[action]);
dbg_assert(count <= this->action_counts[action]);
this->AssertCountConsistency();
this->RemoveFromCache(cp, count);
this->action_counts[action] -= count;
@ -632,7 +632,7 @@ void VehicleCargoList::SetTransferLoadPlace(TileIndex xy)
bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8 order_flags, const GoodsEntry *ge, CargoPayment *payment)
{
this->AssertCountConsistency();
assert(this->action_counts[MTA_LOAD] == 0);
dbg_assert(this->action_counts[MTA_LOAD] == 0);
this->action_counts[MTA_TRANSFER] = this->action_counts[MTA_DELIVER] = this->action_counts[MTA_KEEP] = 0;
Iterator it = this->packets.begin();
uint sum = 0;
@ -642,7 +642,7 @@ bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationID
bool force_keep = (order_flags & OUFB_NO_UNLOAD) != 0;
bool force_unload = (order_flags & OUFB_UNLOAD) != 0;
bool force_transfer = (order_flags & (OUFB_TRANSFER | OUFB_UNLOAD)) != 0;
assert(this->count > 0 || it == this->packets.end());
dbg_assert(this->count > 0 || it == this->packets.end());
while (sum < this->count) {
CargoPacket *cp = *it;
@ -716,7 +716,7 @@ bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationID
this->action_counts[action] += cp->count;
sum += cp->count;
}
assert(this->packets.empty());
dbg_assert(this->packets.empty());
this->packets = std::move(transfer_deliver);
this->packets.insert(this->packets.end(), keep.begin(), keep.end());
this->AssertCountConsistency();
@ -899,7 +899,7 @@ uint VehicleCargoList::RerouteFromSource(uint max_move, VehicleCargoList *dest,
*/
void StationCargoList::Append(CargoPacket *cp, StationID next)
{
assert(cp != nullptr);
dbg_assert(cp != nullptr);
this->AddToCache(cp);
StationCargoPacketMap::List &list = this->packets[next];

View File

@ -34,7 +34,7 @@ enum ClearGround {
*/
static inline bool IsSnowTile(TileIndex t)
{
assert_tile(IsTileType(t, MP_CLEAR), t);
dbg_assert_tile(IsTileType(t, MP_CLEAR), t);
return HasBit(_m[t].m3, 4);
}
@ -46,7 +46,7 @@ static inline bool IsSnowTile(TileIndex t)
*/
static inline ClearGround GetRawClearGround(TileIndex t)
{
assert_tile(IsTileType(t, MP_CLEAR), t);
dbg_assert_tile(IsTileType(t, MP_CLEAR), t);
return (ClearGround)GB(_m[t].m5, 2, 3);
}
@ -82,7 +82,7 @@ static inline bool IsClearGround(TileIndex t, ClearGround ct)
*/
static inline uint GetClearDensity(TileIndex t)
{
assert_tile(IsTileType(t, MP_CLEAR), t);
dbg_assert_tile(IsTileType(t, MP_CLEAR), t);
return GB(_m[t].m5, 0, 2);
}
@ -94,7 +94,7 @@ static inline uint GetClearDensity(TileIndex t)
*/
static inline void AddClearDensity(TileIndex t, int d)
{
assert_tile(IsTileType(t, MP_CLEAR), t); // XXX incomplete
dbg_assert_tile(IsTileType(t, MP_CLEAR), t); // XXX incomplete
_m[t].m5 += d;
}
@ -106,7 +106,7 @@ static inline void AddClearDensity(TileIndex t, int d)
*/
static inline void SetClearDensity(TileIndex t, uint d)
{
assert_tile(IsTileType(t, MP_CLEAR), t);
dbg_assert_tile(IsTileType(t, MP_CLEAR), t);
SB(_m[t].m5, 0, 2, d);
}
@ -119,7 +119,7 @@ static inline void SetClearDensity(TileIndex t, uint d)
*/
static inline uint GetClearCounter(TileIndex t)
{
assert_tile(IsTileType(t, MP_CLEAR), t);
dbg_assert_tile(IsTileType(t, MP_CLEAR), t);
return GB(_m[t].m5, 5, 3);
}
@ -131,7 +131,7 @@ static inline uint GetClearCounter(TileIndex t)
*/
static inline void AddClearCounter(TileIndex t, int c)
{
assert_tile(IsTileType(t, MP_CLEAR), t); // XXX incomplete
dbg_assert_tile(IsTileType(t, MP_CLEAR), t); // XXX incomplete
_m[t].m5 += c << 5;
}
@ -143,7 +143,7 @@ static inline void AddClearCounter(TileIndex t, int c)
*/
static inline void SetClearCounter(TileIndex t, uint c)
{
assert_tile(IsTileType(t, MP_CLEAR), t); // XXX incomplete
dbg_assert_tile(IsTileType(t, MP_CLEAR), t); // XXX incomplete
SB(_m[t].m5, 5, 3, c);
}
@ -157,7 +157,7 @@ static inline void SetClearCounter(TileIndex t, uint c)
*/
static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
{
assert_tile(IsTileType(t, MP_CLEAR), t); // XXX incomplete
dbg_assert_tile(IsTileType(t, MP_CLEAR), t); // XXX incomplete
_m[t].m5 = 0 << 5 | type << 2 | density;
}
@ -170,7 +170,7 @@ static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint den
*/
static inline uint GetFieldType(TileIndex t)
{
assert_tile(GetClearGround(t) == CLEAR_FIELDS, t);
dbg_assert_tile(GetClearGround(t) == CLEAR_FIELDS, t);
return GB(_m[t].m3, 0, 4);
}
@ -182,7 +182,7 @@ static inline uint GetFieldType(TileIndex t)
*/
static inline void SetFieldType(TileIndex t, uint f)
{
assert_tile(GetClearGround(t) == CLEAR_FIELDS, t); // XXX incomplete
dbg_assert_tile(GetClearGround(t) == CLEAR_FIELDS, t); // XXX incomplete
SB(_m[t].m3, 0, 4, f);
}
@ -194,7 +194,7 @@ static inline void SetFieldType(TileIndex t, uint f)
*/
static inline IndustryID GetIndustryIndexOfField(TileIndex t)
{
assert_tile(GetClearGround(t) == CLEAR_FIELDS, t);
dbg_assert_tile(GetClearGround(t) == CLEAR_FIELDS, t);
return(IndustryID) _m[t].m2;
}
@ -206,7 +206,7 @@ static inline IndustryID GetIndustryIndexOfField(TileIndex t)
*/
static inline void SetIndustryIndexOfField(TileIndex t, IndustryID i)
{
assert_tile(GetClearGround(t) == CLEAR_FIELDS, t);
dbg_assert_tile(GetClearGround(t) == CLEAR_FIELDS, t);
_m[t].m2 = i;
}
@ -220,7 +220,7 @@ static inline void SetIndustryIndexOfField(TileIndex t, IndustryID i)
*/
static inline uint GetFence(TileIndex t, DiagDirection side)
{
assert_tile(IsClearGround(t, CLEAR_FIELDS), t);
dbg_assert_tile(IsClearGround(t, CLEAR_FIELDS), t);
switch (side) {
default: NOT_REACHED();
case DIAGDIR_SE: return GB(_m[t].m4, 2, 3);
@ -239,7 +239,7 @@ static inline uint GetFence(TileIndex t, DiagDirection side)
*/
static inline void SetFence(TileIndex t, DiagDirection side, uint h)
{
assert_tile(IsClearGround(t, CLEAR_FIELDS), t);
dbg_assert_tile(IsClearGround(t, CLEAR_FIELDS), t);
switch (side) {
default: NOT_REACHED();
case DIAGDIR_SE: SB(_m[t].m4, 2, 3, h); break;
@ -299,7 +299,7 @@ static inline void MakeField(TileIndex t, uint field_type, IndustryID industry)
*/
static inline void MakeSnow(TileIndex t, uint density = 0)
{
assert_tile(GetClearGround(t) != CLEAR_SNOW, t);
dbg_assert_tile(GetClearGround(t) != CLEAR_SNOW, t);
SetBit(_m[t].m3, 4);
if (GetRawClearGround(t) == CLEAR_FIELDS) {
SetClearGroundDensity(t, CLEAR_GRASS, density);
@ -315,7 +315,7 @@ static inline void MakeSnow(TileIndex t, uint density = 0)
*/
static inline void ClearSnow(TileIndex t)
{
assert_tile(GetClearGround(t) == CLEAR_SNOW, t);
dbg_assert_tile(GetClearGround(t) == CLEAR_SNOW, t);
ClrBit(_m[t].m3, 4);
SetClearDensity(t, 3);
}

View File

@ -118,7 +118,7 @@ class Kdtree {
}
this->Build(elements.begin(), elements.end());
assert(initial_count == this->Count());
dbg_assert(initial_count == this->Count());
return true;
}
@ -209,7 +209,7 @@ class Kdtree {
CoordT ec = this->xyfunc(element, dim);
/* Which side to remove from */
size_t next = (ec < nc) ? n.left : n.right;
assert(next != INVALID_NODE); // node must exist somewhere and must be found before a leaf is reached
dbg_assert(next != INVALID_NODE); // node must exist somewhere and must be found before a leaf is reached
/* Descend */
size_t new_branch = this->RemoveRecursive(element, next, level + 1);
if (new_branch != next) {
@ -317,7 +317,7 @@ class Kdtree {
return this->unbalanced > this->Count() / 4;
}
/** Verify that the invariant is true for a sub-tree, assert if not */
/** Verify that the invariant is true for a sub-tree, dbg_assert if not */
void CheckInvariant(size_t node_idx, int level, CoordT min_x, CoordT max_x, CoordT min_y, CoordT max_y)
{
if (node_idx == INVALID_NODE) return;
@ -326,10 +326,10 @@ class Kdtree {
CoordT cx = this->xyfunc(n.element, 0);
CoordT cy = this->xyfunc(n.element, 1);
assert(cx >= min_x);
assert(cx < max_x);
assert(cy >= min_y);
assert(cy < max_y);
dbg_assert(cx >= min_x);
dbg_assert(cx < max_x);
dbg_assert(cy >= min_y);
dbg_assert(cy < max_y);
if (level % 2 == 0) {
// split in dimension 0 = x
@ -431,7 +431,7 @@ public:
/** Get number of elements stored in tree */
size_t Count() const
{
assert(this->free_list.size() <= this->nodes.size());
dbg_assert(this->free_list.size() <= this->nodes.size());
return this->nodes.size() - this->free_list.size();
}
@ -442,7 +442,7 @@ public:
*/
T FindNearest(CoordT x, CoordT y) const
{
assert(this->Count() > 0);
dbg_assert(this->Count() > 0);
CoordT xy[2] = { x, y };
return this->FindNearestRecursive(xy, this->root, 0).first;
@ -460,8 +460,8 @@ public:
template <typename Outputter>
void FindContained(CoordT x1, CoordT y1, CoordT x2, CoordT y2, const Outputter &outputter) const
{
assert(x1 < x2);
assert(y1 < y2);
dbg_assert(x1 < x2);
dbg_assert(y1 < y2);
if (this->Count() == 0) return;

View File

@ -35,9 +35,9 @@ DEFINE_POOL_METHOD(inline)::Pool(const char *name) :
first_free(0),
first_unused(0),
items(0),
#ifdef WITH_ASSERT
#ifdef WITH_FULL_dbg_assertS
checked(0),
#endif /* WITH_ASSERT */
#endif /* WITH_FULL_dbg_assertS */
cleaning(false),
data(nullptr),
free_bitmap(nullptr),
@ -52,8 +52,8 @@ DEFINE_POOL_METHOD(inline)::Pool(const char *name) :
*/
DEFINE_POOL_METHOD(inline void)::ResizeFor(size_t index)
{
assert(index >= this->size);
assert(index < Tmax_size);
dbg_assert(index >= this->size);
dbg_assert(index < Tmax_size);
size_t new_size = std::min(Tmax_size, Align(index + 1, std::max<uint>(64, Tgrowth_step)));
@ -88,14 +88,14 @@ DEFINE_POOL_METHOD(inline size_t)::FindFirstFree()
return this->first_unused;
}
assert(this->first_unused == this->size);
dbg_assert(this->first_unused == this->size);
if (this->first_unused < Tmax_size) {
this->ResizeFor(this->first_unused);
return this->first_unused;
}
assert(this->first_unused == Tmax_size);
dbg_assert(this->first_unused == Tmax_size);
return NO_FREE_ITEM;
}
@ -109,14 +109,14 @@ DEFINE_POOL_METHOD(inline size_t)::FindFirstFree()
*/
DEFINE_POOL_METHOD(inline void *)::AllocateItem(size_t size, size_t index)
{
assert(this->data[index] == nullptr);
dbg_assert(this->data[index] == nullptr);
this->first_unused = std::max(this->first_unused, index + 1);
this->items++;
Titem *item;
if (Tcache && this->alloc_cache != nullptr) {
assert(sizeof(Titem) == size);
dbg_assert(sizeof(Titem) == size);
item = (Titem *)this->alloc_cache;
this->alloc_cache = this->alloc_cache->next;
if (Tzero) {
@ -145,10 +145,10 @@ DEFINE_POOL_METHOD(void *)::GetNew(size_t size)
{
size_t index = this->FindFirstFree();
#ifdef WITH_ASSERT
assert(this->checked != 0);
#ifdef WITH_FULL_dbg_assertS
dbg_assert(this->checked != 0);
this->checked--;
#endif /* WITH_ASSERT */
#endif /* WITH_FULL_dbg_assertS */
if (index == NO_FREE_ITEM) {
error("%s: no more free items", this->name);
}
@ -189,8 +189,8 @@ DEFINE_POOL_METHOD(void *)::GetNew(size_t size, size_t index)
*/
DEFINE_POOL_METHOD(void)::FreeItem(size_t index)
{
assert(index < this->size);
assert(this->data[index] != nullptr);
dbg_assert(index < this->size);
dbg_assert(this->data[index] != nullptr);
if (Tcache) {
AllocCache *ac = (AllocCache *)this->data[index];
ac->next = this->alloc_cache;
@ -213,7 +213,7 @@ DEFINE_POOL_METHOD(void)::CleanPool()
for (size_t i = 0; i < this->first_unused; i++) {
delete this->Get(i); // 'delete nullptr;' is very valid
}
assert(this->items == 0);
dbg_assert(this->items == 0);
free(this->data);
free(this->free_bitmap);
this->first_unused = this->first_free = this->size = 0;

View File

@ -109,7 +109,7 @@ struct Pool : PoolBase {
*/
inline Titem *Get(size_t index)
{
assert_msg(index < this->first_unused, "index: " PRINTF_SIZE ", first_unused: " PRINTF_SIZE ", name: %s", index, this->first_unused, this->name);
dbg_assert_msg(index < this->first_unused, "index: " PRINTF_SIZE ", first_unused: " PRINTF_SIZE ", name: %s", index, this->first_unused, this->name);
return this->data[index];
}
@ -258,7 +258,7 @@ struct Pool : PoolBase {
{
if (p == nullptr) return;
Titem *pn = (Titem *)p;
assert_msg(pn == Tpool->Get(pn->index), "name: %s", Tpool->name);
dbg_assert_msg(pn == Tpool->Get(pn->index), "name: %s", Tpool->name);
Tpool->FreeItem(pn->index);
}
@ -292,7 +292,7 @@ struct Pool : PoolBase {
* memory are the same (because of possible inheritance).
* Use { size_t index = item->index; delete item; new (index) item; }
* instead to make sure destructor is called and no memory leaks. */
assert_msg(ptr != Tpool->data[i], "name: %s", Tpool->name);
dbg_assert_msg(ptr != Tpool->data[i], "name: %s", Tpool->name);
}
return ptr;
}

View File

@ -52,7 +52,7 @@ static inline bool IsDepotTile(TileIndex tile)
static inline DepotID GetDepotIndex(TileIndex t)
{
/* Hangars don't have a Depot class, thus store no DepotID. */
assert_tile(IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t), t);
dbg_assert_tile(IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t), t);
return _m[t].m2;
}

View File

@ -53,7 +53,7 @@ static inline bool IsValidAxis(Axis d)
*/
static inline Direction ReverseDir(Direction d)
{
assert(IsValidDirection(d));
dbg_assert(IsValidDirection(d));
return (Direction)(4 ^ d);
}
@ -67,8 +67,8 @@ static inline Direction ReverseDir(Direction d)
*/
static inline DirDiff DirDifference(Direction d0, Direction d1)
{
assert(IsValidDirection(d0));
assert(IsValidDirection(d1));
dbg_assert(IsValidDirection(d0));
dbg_assert(IsValidDirection(d1));
/* Cast to uint so compiler can use bitmask. If the difference is negative
* and we used int instead of uint, further "+ 8" would have to be added. */
return (DirDiff)((uint)(d0 - d1) % 8);
@ -103,7 +103,7 @@ static inline DirDiff ChangeDirDiff(DirDiff d, DirDiff delta)
*/
static inline Direction ChangeDir(Direction d, DirDiff delta)
{
assert(IsValidDirection(d));
dbg_assert(IsValidDirection(d));
/* Cast to uint so compiler can use bitmask. Result can never be negative. */
return (Direction)((uint)(d + delta) % 8);
}
@ -117,7 +117,7 @@ static inline Direction ChangeDir(Direction d, DirDiff delta)
*/
static inline DiagDirection ReverseDiagDir(DiagDirection d)
{
assert(IsValidDiagDirection(d));
dbg_assert(IsValidDiagDirection(d));
return (DiagDirection)(2 ^ d);
}
@ -130,8 +130,8 @@ static inline DiagDirection ReverseDiagDir(DiagDirection d)
*/
static inline DiagDirDiff DiagDirDifference(DiagDirection d0, DiagDirection d1)
{
assert(IsValidDiagDirection(d0));
assert(IsValidDiagDirection(d1));
dbg_assert(IsValidDiagDirection(d0));
dbg_assert(IsValidDiagDirection(d1));
/* Cast to uint so compiler can use bitmask. Result can never be negative. */
return (DiagDirDiff)((uint)(d0 - d1) % 4);
}
@ -148,7 +148,7 @@ static inline DiagDirDiff DiagDirDifference(DiagDirection d0, DiagDirection d1)
*/
static inline DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta)
{
assert(IsValidDiagDirection(d));
dbg_assert(IsValidDiagDirection(d));
/* Cast to uint so compiler can use bitmask. Result can never be negative. */
return (DiagDirection)((uint)(d + delta) % 4);
}
@ -165,7 +165,7 @@ static inline DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta)
*/
static inline DiagDirection DirToDiagDir(Direction dir)
{
assert(IsValidDirection(dir));
dbg_assert(IsValidDirection(dir));
return (DiagDirection)(dir >> 1);
}
@ -181,7 +181,7 @@ static inline DiagDirection DirToDiagDir(Direction dir)
*/
static inline Direction DiagDirToDir(DiagDirection dir)
{
assert(IsValidDiagDirection(dir));
dbg_assert(IsValidDiagDirection(dir));
return (Direction)(dir * 2 + 1);
}
@ -196,7 +196,7 @@ static inline Direction DiagDirToDir(DiagDirection dir)
*/
static inline Axis OtherAxis(Axis a)
{
assert(IsValidAxis(a));
dbg_assert(IsValidAxis(a));
return (Axis)(a ^ 1);
}
@ -213,7 +213,7 @@ static inline Axis OtherAxis(Axis a)
*/
static inline Axis DiagDirToAxis(DiagDirection d)
{
assert(IsValidDiagDirection(d));
dbg_assert(IsValidDiagDirection(d));
return (Axis)(d & 1);
}
@ -231,7 +231,7 @@ static inline Axis DiagDirToAxis(DiagDirection d)
*/
static inline DiagDirection AxisToDiagDir(Axis a)
{
assert(IsValidAxis(a));
dbg_assert(IsValidAxis(a));
return (DiagDirection)(2 - a);
}
@ -248,7 +248,7 @@ static inline DiagDirection AxisToDiagDir(Axis a)
*/
static inline Direction AxisToDirection(Axis a)
{
assert(IsValidAxis(a));
dbg_assert(IsValidAxis(a));
return (Direction)(5 - 2 * a);
}
@ -260,7 +260,7 @@ static inline Direction AxisToDirection(Axis a)
*/
static inline DiagDirection XYNSToDiagDir(Axis xy, uint ns)
{
assert(IsValidAxis(xy));
dbg_assert(IsValidAxis(xy));
return (DiagDirection)(xy * 3 ^ ns * 2);
}
@ -272,7 +272,7 @@ static inline DiagDirection XYNSToDiagDir(Axis xy, uint ns)
*/
static inline bool IsDiagonalDirection(Direction dir)
{
assert(IsValidDirection(dir));
dbg_assert(IsValidDirection(dir));
return (dir & 1) != 0;
}
@ -289,8 +289,8 @@ static inline bool IsDiagonalDirection(Direction dir)
*/
static inline DiagDirection DirToDiagDirAlongAxis(Direction dir, Axis axis)
{
assert(IsValidDirection(dir));
assert(IsValidAxis(axis));
dbg_assert(IsValidDirection(dir));
dbg_assert(IsValidAxis(axis));
if ((dir & 3) == (3 ^ (axis << 1))) return INVALID_DIAGDIR;
/* Mapping:
* X 4, 5, 6 -> 2 0, 1, 2 -> 0

View File

@ -126,7 +126,7 @@ struct HouseSpec {
static inline HouseSpec *Get(size_t house_id)
{
assert(house_id < NUM_HOUSES);
dbg_assert(house_id < NUM_HOUSES);
extern HouseSpec _house_specs[];
return &_house_specs[house_id];
}

View File

@ -62,7 +62,7 @@ enum IndustryGraphics {
*/
static inline IndustryID GetIndustryIndex(TileIndex t)
{
assert_tile(IsTileType(t, MP_INDUSTRY), t);
dbg_assert_tile(IsTileType(t, MP_INDUSTRY), t);
return _m[t].m2;
}
@ -74,7 +74,7 @@ static inline IndustryID GetIndustryIndex(TileIndex t)
*/
static inline bool IsIndustryCompleted(TileIndex t)
{
assert_tile(IsTileType(t, MP_INDUSTRY), t);
dbg_assert_tile(IsTileType(t, MP_INDUSTRY), t);
return HasBit(_m[t].m1, 7);
}
@ -87,7 +87,7 @@ IndustryType GetIndustryType(TileIndex tile);
*/
static inline void SetIndustryCompleted(TileIndex tile)
{
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
SB(_m[tile].m1, 7, 1, 1);
}
@ -99,7 +99,7 @@ static inline void SetIndustryCompleted(TileIndex tile)
*/
static inline byte GetIndustryConstructionStage(TileIndex tile)
{
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
return IsIndustryCompleted(tile) ? (byte)INDUSTRY_COMPLETED : GB(_m[tile].m1, 0, 2);
}
@ -111,7 +111,7 @@ static inline byte GetIndustryConstructionStage(TileIndex tile)
*/
static inline void SetIndustryConstructionStage(TileIndex tile, byte value)
{
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
SB(_m[tile].m1, 0, 2, value);
}
@ -124,7 +124,7 @@ static inline void SetIndustryConstructionStage(TileIndex tile, byte value)
*/
static inline IndustryGfx GetCleanIndustryGfx(TileIndex t)
{
assert_tile(IsTileType(t, MP_INDUSTRY), t);
dbg_assert_tile(IsTileType(t, MP_INDUSTRY), t);
return _m[t].m5 | (GB(_me[t].m6, 2, 1) << 8);
}
@ -136,7 +136,7 @@ static inline IndustryGfx GetCleanIndustryGfx(TileIndex t)
*/
static inline IndustryGfx GetIndustryGfx(TileIndex t)
{
assert_tile(IsTileType(t, MP_INDUSTRY), t);
dbg_assert_tile(IsTileType(t, MP_INDUSTRY), t);
return GetTranslatedIndustryTileID(GetCleanIndustryGfx(t));
}
@ -148,7 +148,7 @@ static inline IndustryGfx GetIndustryGfx(TileIndex t)
*/
static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
{
assert_tile(IsTileType(t, MP_INDUSTRY), t);
dbg_assert_tile(IsTileType(t, MP_INDUSTRY), t);
_m[t].m5 = GB(gfx, 0, 8);
SB(_me[t].m6, 2, 1, GB(gfx, 8, 1));
}
@ -161,7 +161,7 @@ static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
*/
static inline byte GetIndustryConstructionCounter(TileIndex tile)
{
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
return GB(_m[tile].m1, 2, 2);
}
@ -173,7 +173,7 @@ static inline byte GetIndustryConstructionCounter(TileIndex tile)
*/
static inline void SetIndustryConstructionCounter(TileIndex tile, byte value)
{
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
SB(_m[tile].m1, 2, 2, value);
}
@ -186,7 +186,7 @@ static inline void SetIndustryConstructionCounter(TileIndex tile, byte value)
*/
static inline void ResetIndustryConstructionStage(TileIndex tile)
{
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
SB(_m[tile].m1, 0, 4, 0);
SB(_m[tile].m1, 7, 1, 0);
}
@ -198,7 +198,7 @@ static inline void ResetIndustryConstructionStage(TileIndex tile)
*/
static inline byte GetIndustryAnimationLoop(TileIndex tile)
{
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
return _m[tile].m4;
}
@ -210,7 +210,7 @@ static inline byte GetIndustryAnimationLoop(TileIndex tile)
*/
static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
{
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
_m[tile].m4 = count;
}
@ -223,7 +223,7 @@ static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
*/
static inline byte GetIndustryRandomBits(TileIndex tile)
{
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
return _m[tile].m3;
}
@ -236,7 +236,7 @@ static inline byte GetIndustryRandomBits(TileIndex tile)
*/
static inline void SetIndustryRandomBits(TileIndex tile, byte bits)
{
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
_m[tile].m3 = bits;
}
@ -249,7 +249,7 @@ static inline void SetIndustryRandomBits(TileIndex tile, byte bits)
*/
static inline byte GetIndustryTriggers(TileIndex tile)
{
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
return GB(_me[tile].m6, 3, 3);
}
@ -263,7 +263,7 @@ static inline byte GetIndustryTriggers(TileIndex tile)
*/
static inline void SetIndustryTriggers(TileIndex tile, byte triggers)
{
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
SB(_me[tile].m6, 3, 3, triggers);
}

View File

@ -200,7 +200,7 @@ static inline IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx)
* will never be assigned as a tile index and is only required in order to do some
* tests while building the industry (as in WATER REQUIRED */
if (gfx != 0xFF) {
assert(gfx < INVALID_INDUSTRYTILE);
dbg_assert(gfx < INVALID_INDUSTRYTILE);
const IndustryTileSpec *it = &_industry_tile_specs[gfx];
return it->grf_prop.override == INVALID_INDUSTRYTILE ? gfx : it->grf_prop.override;
} else {

View File

@ -849,7 +849,7 @@ void RunTileLoop()
TileIndex tile = _cur_tileloop_tile;
/* The LFSR cannot have a zeroed state. */
assert(tile != 0);
dbg_assert(tile != 0);
SCOPE_INFO_FMT([&], "RunTileLoop: tile: %dx%d", TileX(tile), TileY(tile));
@ -1170,7 +1170,7 @@ static bool MakeLake(TileIndex tile, void *user_data)
*/
static bool FlowsDown(TileIndex begin, TileIndex end)
{
assert(DistanceManhattan(begin, end) == 1);
dbg_assert(DistanceManhattan(begin, end) == 1);
int heightBegin;
int heightEnd;

View File

@ -94,7 +94,7 @@ static inline int GetSlopePixelZInCorner(Slope tileh, Corner corner)
*/
static inline Slope GetFoundationPixelSlope(TileIndex tile, int *z)
{
assert(z != nullptr);
dbg_assert(z != nullptr);
Slope s = GetFoundationSlope(tile, z);
*z *= TILE_HEIGHT;
return s;

View File

@ -112,7 +112,7 @@ TileIndex TileAdd(TileIndex tile, TileIndexDiff add,
#endif
}
assert(TileXY(x, y) == TILE_MASK(tile + add));
dbg_assert(TileXY(x, y) == TILE_MASK(tile + add));
return TileXY(x, y);
}
@ -297,8 +297,8 @@ uint DistanceFromEdgeDir(TileIndex tile, DiagDirection dir)
*/
bool CircularTileSearch(TileIndex *tile, uint size, TestTileOnSearchProc proc, void *user_data)
{
assert(proc != nullptr);
assert(size > 0);
dbg_assert(proc != nullptr);
dbg_assert(size > 0);
if (size % 2 == 1) {
/* If the length of the side is uneven, the center has to be checked
@ -335,8 +335,8 @@ bool CircularTileSearch(TileIndex *tile, uint size, TestTileOnSearchProc proc, v
*/
bool CircularTileSearch(TileIndex *tile, uint radius, uint w, uint h, TestTileOnSearchProc proc, void *user_data)
{
assert(proc != nullptr);
assert(radius > 0);
dbg_assert(proc != nullptr);
dbg_assert(radius > 0);
uint x = TileX(*tile) + w + 1;
uint y = TileY(*tile);
@ -384,7 +384,7 @@ bool CircularTileSearch(TileIndex *tile, uint radius, uint w, uint h, TestTileOn
*/
bool EnoughContiguousTilesMatchingCondition(TileIndex tile, uint threshold, TestTileOnSearchProc proc, void *user_data)
{
assert(proc != nullptr);
dbg_assert(proc != nullptr);
if (threshold == 0) return true;
static_assert(MAX_MAP_TILES_BITS <= 30);

View File

@ -42,7 +42,7 @@ struct Object : ObjectPool::PoolItem<&_object_pool> {
*/
static inline void IncTypeCount(ObjectType type)
{
assert(type < NUM_OBJECTS);
dbg_assert(type < NUM_OBJECTS);
counts[type]++;
}
@ -53,7 +53,7 @@ struct Object : ObjectPool::PoolItem<&_object_pool> {
*/
static inline void DecTypeCount(ObjectType type)
{
assert(type < NUM_OBJECTS);
dbg_assert(type < NUM_OBJECTS);
counts[type]--;
}
@ -64,7 +64,7 @@ struct Object : ObjectPool::PoolItem<&_object_pool> {
*/
static inline uint16 GetTypeCount(ObjectType type)
{
assert(type < NUM_OBJECTS);
dbg_assert(type < NUM_OBJECTS);
return counts[type];
}

View File

@ -52,7 +52,7 @@ static inline bool IsObjectTypeTile(TileIndex t, ObjectType type)
*/
static inline ObjectID GetObjectIndex(TileIndex t)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
return _m[t].m2 | _m[t].m5 << 16;
}
@ -64,7 +64,7 @@ static inline ObjectID GetObjectIndex(TileIndex t)
*/
static inline byte GetObjectRandomBits(TileIndex t)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
return _m[t].m3;
}
@ -76,7 +76,7 @@ static inline byte GetObjectRandomBits(TileIndex t)
*/
static inline ObjectGround GetObjectGroundType(TileIndex t)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
return (ObjectGround)GB(_m[t].m4, 2, 2);
}
@ -89,7 +89,7 @@ static inline ObjectGround GetObjectGroundType(TileIndex t)
*/
static inline uint GetObjectGroundDensity(TileIndex t)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
return GB(_m[t].m4, 0, 2);
}
@ -102,7 +102,7 @@ static inline uint GetObjectGroundDensity(TileIndex t)
*/
static inline void SetObjectGroundDensity(TileIndex t, uint d)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
SB(_m[t].m4, 0, 2, d);
}
@ -114,7 +114,7 @@ static inline void SetObjectGroundDensity(TileIndex t, uint d)
*/
static inline uint GetObjectGroundCounter(TileIndex t)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
return GB(_m[t].m4, 5, 3);
}
@ -126,7 +126,7 @@ static inline uint GetObjectGroundCounter(TileIndex t)
*/
static inline void AddObjectGroundCounter(TileIndex t, int c)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
_m[t].m4 += c << 5;
}
@ -138,7 +138,7 @@ static inline void AddObjectGroundCounter(TileIndex t, int c)
*/
static inline void SetObjectGroundCounter(TileIndex t, uint c)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
SB(_m[t].m4, 5, 3, c);
}
@ -152,31 +152,31 @@ static inline void SetObjectGroundCounter(TileIndex t, uint c)
*/
static inline void SetObjectGroundTypeDensity(TileIndex t, ObjectGround type, uint density)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
_m[t].m4 = 0 << 5 | type << 2 | density;
}
static inline ObjectEffectiveFoundationType GetObjectEffectiveFoundationType(TileIndex t)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
return (ObjectEffectiveFoundationType)GB(_me[t].m6, 0, 2);
}
static inline void SetObjectEffectiveFoundationType(TileIndex t, ObjectEffectiveFoundationType foundation_type)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
SB(_me[t].m6, 0, 2, foundation_type);
}
static inline bool GetObjectHasViewportMapViewOverride(TileIndex t)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
return HasBit(_m[t].m4, 4);
}
static inline void SetObjectHasViewportMapViewOverride(TileIndex t, bool map_view_override)
{
assert_tile(IsTileType(t, MP_OBJECT), t);
dbg_assert_tile(IsTileType(t, MP_OBJECT), t);
SB(_m[t].m4, 4, 1, map_view_override ? 1 : 0);
}

View File

@ -1991,7 +1991,7 @@ void StateGameLoop()
SetWindowDirty(WC_MAIN_TOOLBAR, 0);
}
assert(IsLocalCompany());
dbg_assert(IsLocalCompany());
}
FiosNumberedSaveName &GetAutoSaveFiosNumberedSaveName()

View File

@ -58,22 +58,22 @@ struct CFollowTrackT
inline CFollowTrackT(Owner o, RailTypes railtype_override = INVALID_RAILTYPES)
{
assert(IsRailTT());
dbg_assert(IsRailTT());
m_veh = nullptr;
Init(o, railtype_override);
}
inline void Init(const VehicleType *v, RailTypes railtype_override)
{
assert(!IsRailTT() || (v != nullptr && v->type == VEH_TRAIN));
dbg_assert(!IsRailTT() || (v != nullptr && v->type == VEH_TRAIN));
m_veh = v;
Init(v != nullptr ? v->owner : INVALID_OWNER, IsRailTT() && railtype_override == INVALID_RAILTYPES ? Train::From(v)->compatible_railtypes : railtype_override);
}
inline void Init(Owner o, RailTypes railtype_override)
{
assert(!IsRoadTT() || m_veh != nullptr);
assert(!IsRailTT() || railtype_override != INVALID_RAILTYPES);
dbg_assert(!IsRoadTT() || m_veh != nullptr);
dbg_assert(!IsRailTT() || railtype_override != INVALID_RAILTYPES);
m_veh_owner = o;
/* don't worry, all is inlined so compiler should remove unnecessary initializations */
m_old_tile = INVALID_TILE;
@ -98,7 +98,7 @@ struct CFollowTrackT
/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */
inline DiagDirection GetSingleTramBit(TileIndex tile)
{
assert(IsTram()); // this function shouldn't be called in other cases
dbg_assert(IsTram()); // this function shouldn't be called in other cases
const bool is_bridge = IsRoadCustomBridgeHeadTile(tile);
if (is_bridge || IsNormalRoadTile(tile)) {
@ -123,7 +123,7 @@ struct CFollowTrackT
m_old_tile = old_tile;
m_old_td = old_td;
m_err = EC_NONE;
assert_tile(
dbg_assert_tile(
((TrackStatusToTrackdirBits(
GetTileTrackStatus(m_old_tile, TT(), (IsRoadTT() && m_veh != nullptr) ? (this->IsTram() ? RTT_TRAM : RTT_ROAD) : 0)
) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
@ -219,7 +219,9 @@ protected:
m_tiles_skipped = GetTunnelBridgeLength(m_new_tile, m_old_tile);
return;
}
if (!IsRoadCustomBridgeHeadTile(m_old_tile) && !IsRailCustomBridgeHeadTile(m_old_tile)) assert(ReverseDiagDir(enterdir) == m_exitdir);
if (!IsRoadCustomBridgeHeadTile(m_old_tile) && !IsRailCustomBridgeHeadTile(m_old_tile)) {
dbg_assert(ReverseDiagDir(enterdir) == m_exitdir);
}
}
/* normal or station tile, do one step */

View File

@ -80,7 +80,7 @@ public:
/** insert given item as open node (into m_open and m_open_queue) */
inline void InsertOpenNode(Titem_ &item)
{
assert(m_closed.Find(item.GetKey()) == nullptr);
dbg_assert(m_closed.Find(item.GetKey()) == nullptr);
m_open.Push(item);
m_open_queue.Include(&item);
if (&item == m_new_node) {
@ -110,7 +110,7 @@ public:
inline void DequeueBestOpenNode()
{
assert(!m_open_queue.IsEmpty());
dbg_assert(!m_open_queue.IsEmpty());
m_open_queue.Shift();
}
@ -143,7 +143,7 @@ public:
/** close node */
inline void InsertClosedNode(Titem_ &item)
{
assert(m_open.Find(item.GetKey()) == nullptr);
dbg_assert(m_open.Find(item.GetKey()) == nullptr);
m_closed.Push(item);
}

View File

@ -93,8 +93,8 @@ public:
inline int CurveCost(Trackdir td1, Trackdir td2)
{
assert(IsValidTrackdir(td1));
assert(IsValidTrackdir(td2));
dbg_assert(IsValidTrackdir(td1));
dbg_assert(IsValidTrackdir(td2));
int cost = 0;
if (TrackFollower::Allow90degTurns()
&& HasTrackdir(TrackdirCrossesTrackdirs(td1), td2)) {
@ -484,9 +484,9 @@ public:
{
int cost = 0;
const Train *v = Yapf().GetVehicle();
assert(v != nullptr);
assert(v->type == VEH_TRAIN);
assert(v->gcache.cached_total_length != 0);
dbg_assert(v != nullptr);
dbg_assert(v->type == VEH_TRAIN);
dbg_assert(v->gcache.cached_total_length != 0);
int missing_platform_length = CeilDiv(v->gcache.cached_total_length, TILE_SIZE) - platform_length;
if (missing_platform_length < 0) {
/* apply penalty for longer platform than needed */
@ -511,9 +511,9 @@ public:
*/
inline bool PfCalcCost(Node &n, const TrackFollower *tf)
{
assert(!n.flags_u.flags_s.m_targed_seen);
assert(tf->m_new_tile == n.m_key.m_tile);
assert((HasTrackdir(tf->m_new_td_bits, n.m_key.m_td)));
dbg_assert(!n.flags_u.flags_s.m_targed_seen);
dbg_assert(tf->m_new_tile == n.m_key.m_tile);
dbg_assert((HasTrackdir(tf->m_new_td_bits, n.m_key.m_td)));
/* Does the node have some parent node? */
bool has_parent = (n.m_parent != nullptr);
@ -568,7 +568,7 @@ public:
if (!has_parent) {
/* We will jump to the middle of the cost calculator assuming that segment cache is not used. */
assert(!is_cached_segment);
dbg_assert(!is_cached_segment);
/* Skip the first transition cost calculation. */
goto no_entry_cost;
} else if (n.flags_u.flags_s.m_teleport) {
@ -595,7 +595,7 @@ public:
end_segment_reason = segment.m_end_segment_reason;
/* We will need also some information about the last signal (if it was red). */
if (segment.m_last_signal_tile != INVALID_TILE) {
assert_tile(HasSignalOnTrackdir(segment.m_last_signal_tile, segment.m_last_signal_td), segment.m_last_signal_tile);
dbg_assert_tile(HasSignalOnTrackdir(segment.m_last_signal_tile, segment.m_last_signal_td), segment.m_last_signal_tile);
SignalState sig_state = GetSignalStateByTrackdir(segment.m_last_signal_tile, segment.m_last_signal_td);
bool is_red = (sig_state == SIGNAL_STATE_RED);
n.flags_u.flags_s.m_last_signal_was_red = is_red;
@ -634,7 +634,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
/* Tests for 'potential target' reasons to close the segment. */
if (cur.tile == prev.tile) {
/* Penalty for reversing in a depot. */
assert_tile(IsRailDepot(cur.tile), cur.tile);
dbg_assert_tile(IsRailDepot(cur.tile), cur.tile);
segment_cost += Yapf().PfGetSettings().rail_depot_reverse_penalty;
} else if (IsRailDepotTile(cur.tile)) {
@ -654,7 +654,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
/* Arbitrary maximum tiles to follow to avoid infinite loops. */
uint max_tiles = 20;
while (ft.Follow(t, td)) {
assert(t != ft.m_new_tile);
dbg_assert(t != ft.m_new_tile);
t = ft.m_new_tile;
if (t == cur.tile || --max_tiles == 0) {
/* We looped back on ourself or found another loop, bail out. */
@ -731,7 +731,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
tf_local.Init(v, Yapf().GetCompatibleRailTypes());
if (!tf_local.Follow(cur.tile, cur.td)) {
assert(tf_local.m_err != TrackFollower::EC_NONE);
dbg_assert(tf_local.m_err != TrackFollower::EC_NONE);
/* Can't move to the next tile (EOL?). */
if (!(end_segment_reason & (ESRB_RAIL_TYPE | ESRB_DEAD_END))) end_segment_reason |= ESRB_DEAD_END_EOL;
if (tf_local.m_err == TrackFollower::EC_RAIL_ROAD_TYPE) {
@ -855,7 +855,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
/* Station platform-length penalty. */
if ((end_segment_reason & ESRB_STATION) != ESRB_NONE) {
const BaseStation *st = BaseStation::GetByTile(n.GetLastTile());
assert(st != nullptr);
dbg_assert(st != nullptr);
uint platform_length = st->GetPlatformLength(n.GetLastTile(), ReverseDiagDir(TrackdirToExitdir(n.GetLastTrackdir())));
/* Reduce the extra cost caused by passing-station penalty (each station receives it in the segment cost). */
extra_cost -= Yapf().PfGetSettings().rail_station_penalty * platform_length;

View File

@ -177,19 +177,19 @@ struct CYapfRailNodeT
inline TileIndex GetLastTile() const
{
assert(m_segment != nullptr);
dbg_assert(m_segment != nullptr);
return m_segment->m_last_tile;
}
inline Trackdir GetLastTrackdir() const
{
assert(m_segment != nullptr);
dbg_assert(m_segment != nullptr);
return m_segment->m_last_td;
}
inline void SetLastTileTrackdir(TileIndex tile, Trackdir td)
{
assert(m_segment != nullptr);
dbg_assert(m_segment != nullptr);
m_segment->m_last_tile = tile;
m_segment->m_last_td = td;
}
@ -206,7 +206,7 @@ struct CYapfRailNodeT
if (!ft.Follow(cur, cur_td)) break;
cur = ft.m_new_tile;
assert(KillFirstBit(ft.m_new_td_bits) == TRACKDIR_BIT_NONE);
dbg_assert(KillFirstBit(ft.m_new_td_bits) == TRACKDIR_BIT_NONE);
cur_td = FindFirstTrackdir(ft.m_new_td_bits);
}
@ -227,7 +227,7 @@ struct CYapfRailNodeT
if (!ft.Follow(cur, cur_td)) break;
length += TILE_SIZE * ft.m_tiles_skipped;
cur = ft.m_new_tile;
assert(KillFirstBit(ft.m_new_td_bits) == TRACKDIR_BIT_NONE);
dbg_assert(KillFirstBit(ft.m_new_td_bits) == TRACKDIR_BIT_NONE);
cur_td = FindFirstTrackdir(ft.m_new_td_bits);
}

View File

@ -166,7 +166,7 @@ public:
/** Check the node for a possible reservation target. */
inline void FindSafePositionOnNode(Node *node)
{
assert(node->m_parent != nullptr);
dbg_assert(node->m_parent != nullptr);
/* We will never pass more than two non-reserve-through signals, no need to check for a safe tile. */
if (node->m_parent->m_num_signals_passed - node->m_parent->m_num_signals_res_through_passed >= 2) return;

View File

@ -153,7 +153,7 @@ public:
/* move back to the old tile/trackdir (where ship is coming from) */
TileIndex src_tile = TileAddByDiagDir(tile, ReverseDiagDir(enterdir));
Trackdir trackdir = v->GetVehicleTrackdir();
assert(IsValidTrackdir(trackdir));
dbg_assert(IsValidTrackdir(trackdir));
/* convert origin trackdir to TrackdirBits */
TrackdirBits trackdirs = TrackdirToTrackdirBits(trackdir);
@ -262,8 +262,8 @@ protected:
public:
inline int CurveCost(Trackdir td1, Trackdir td2)
{
assert(IsValidTrackdir(td1));
assert(IsValidTrackdir(td2));
dbg_assert(IsValidTrackdir(td1));
dbg_assert(IsValidTrackdir(td2));
if (HasTrackdir(TrackdirCrossesTrackdirs(td1), td2)) {
/* 90-deg curve penalty */

View File

@ -327,7 +327,7 @@ public:
static inline const RailtypeInfo *GetRailTypeInfo(RailType railtype)
{
extern RailtypeInfo _railtypes[RAILTYPE_END];
assert_msg(railtype < RAILTYPE_END, "%u", railtype);
dbg_assert_msg(railtype < RAILTYPE_END, "%u", railtype);
return &_railtypes[railtype];
}
@ -409,7 +409,7 @@ static inline bool Rail90DegTurnDisallowedTilesFromTrackdir(TileIndex t1, TileIn
*/
static inline Money RailBuildCost(RailType railtype)
{
assert(railtype < RAILTYPE_END);
dbg_assert(railtype < RAILTYPE_END);
return (_price[PR_BUILD_RAIL] * GetRailTypeInfo(railtype)->cost_multiplier) >> 3;
}
@ -425,7 +425,7 @@ static inline Money RailClearCost(RailType railtype)
* In this case we limit the removal earnings to 3/4s of the build
* cost.
*/
assert(railtype < RAILTYPE_END);
dbg_assert(railtype < RAILTYPE_END);
return std::max(_price[PR_CLEAR_RAIL], -RailBuildCost(railtype) * 3 / 4);
}
@ -464,7 +464,7 @@ static inline Money RailConvertCost(RailType from, RailType to)
*/
static inline Money RailMaintenanceCost(RailType railtype, uint32 num, uint32 total_num)
{
assert(railtype < RAILTYPE_END);
dbg_assert(railtype < RAILTYPE_END);
return (_price[PR_INFRASTRUCTURE_RAIL] * GetRailTypeInfo(railtype)->maintenance_multiplier * num * (1 + IntSqrt(total_num))) >> 11; // 4 bits fraction for the multiplier and 7 bits scaling.
}

View File

@ -36,7 +36,7 @@ enum RailTileType {
*/
static inline RailTileType GetRailTileType(TileIndex t)
{
assert_tile(IsTileType(t, MP_RAILWAY), t);
dbg_assert_tile(IsTileType(t, MP_RAILWAY), t);
return (RailTileType)GB(_m[t].m5, 6, 2);
}
@ -83,7 +83,7 @@ static inline bool HasSignals(TileIndex t)
*/
static inline void SetHasSignals(TileIndex tile, bool signals)
{
assert_tile(IsPlainRailTile(tile), tile);
dbg_assert_tile(IsPlainRailTile(tile), tile);
SB(_m[tile].m5, 6, 1, signals);
}
@ -165,7 +165,7 @@ static inline RailType GetPlainRailParallelTrackRailTypeByTrackBit(TileIndex t,
*/
static inline TrackBits GetTrackBits(TileIndex tile)
{
assert_tile(IsPlainRailTile(tile), tile);
dbg_assert_tile(IsPlainRailTile(tile), tile);
return (TrackBits)GB(_m[tile].m5, 0, 6);
}
@ -176,7 +176,7 @@ static inline TrackBits GetTrackBits(TileIndex tile)
*/
static inline void SetTrackBits(TileIndex t, TrackBits b)
{
assert_tile(IsPlainRailTile(t), t);
dbg_assert_tile(IsPlainRailTile(t), t);
SB(_m[t].m5, 0, 6, b);
}
@ -223,7 +223,7 @@ static inline Track GetRailDepotTrack(TileIndex t)
*/
static inline TrackBits GetRailReservationTrackBits(TileIndex t)
{
assert_tile(IsPlainRailTile(t), t);
dbg_assert_tile(IsPlainRailTile(t), t);
byte track_b = GB(_m[t].m2, 8, 3);
Track track = (Track)(track_b - 1); // map array saves Track+1
if (track_b == 0) return TRACK_BIT_NONE;
@ -238,9 +238,9 @@ static inline TrackBits GetRailReservationTrackBits(TileIndex t)
*/
static inline void SetTrackReservation(TileIndex t, TrackBits b)
{
assert_tile(IsPlainRailTile(t), t);
assert(b != INVALID_TRACK_BIT);
assert(!TracksOverlap(b));
dbg_assert_tile(IsPlainRailTile(t), t);
dbg_assert(b != INVALID_TRACK_BIT);
dbg_assert(!TracksOverlap(b));
Track track = RemoveFirstTrack(&b);
SB(_m[t].m2, 8, 3, track == INVALID_TRACK ? 0 : track + 1);
SB(_m[t].m2, 11, 1, (byte)(b != TRACK_BIT_NONE));
@ -255,7 +255,7 @@ static inline void SetTrackReservation(TileIndex t, TrackBits b)
*/
static inline bool TryReserveTrack(TileIndex tile, Track t)
{
assert_tile(HasTrack(tile, t), tile);
dbg_assert_tile(HasTrack(tile, t), tile);
TrackBits bits = TrackToTrackBits(t);
TrackBits res = GetRailReservationTrackBits(tile);
if ((res & bits) != TRACK_BIT_NONE) return false; // already reserved
@ -273,7 +273,7 @@ static inline bool TryReserveTrack(TileIndex tile, Track t)
*/
static inline void UnreserveTrack(TileIndex tile, Track t)
{
assert_tile(HasTrack(tile, t), tile);
dbg_assert_tile(HasTrack(tile, t), tile);
TrackBits res = GetRailReservationTrackBits(tile);
res &= ~TrackToTrackBits(t);
SetTrackReservation(tile, res);
@ -287,7 +287,7 @@ static inline void UnreserveTrack(TileIndex tile, Track t)
*/
static inline bool HasDepotReservation(TileIndex t)
{
assert_tile(IsRailDepot(t), t);
dbg_assert_tile(IsRailDepot(t), t);
return HasBit(_m[t].m5, 4);
}
@ -299,7 +299,7 @@ static inline bool HasDepotReservation(TileIndex t)
*/
static inline void SetDepotReservation(TileIndex t, bool b)
{
assert_tile(IsRailDepot(t), t);
dbg_assert_tile(IsRailDepot(t), t);
SB(_m[t].m5, 4, 1, (byte)b);
}
@ -316,14 +316,14 @@ static inline TrackBits GetDepotReservationTrackBits(TileIndex t)
static inline SignalType GetSignalType(TileIndex t, Track track)
{
assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
dbg_assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
return (SignalType)GB(_m[t].m2, pos, 3);
}
static inline void SetSignalType(TileIndex t, Track track, SignalType s)
{
assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
dbg_assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
SB(_m[t].m2, pos, 3, s);
if (track == INVALID_TRACK) SB(_m[t].m2, 4, 3, s);
@ -385,14 +385,14 @@ static inline void SetSignalVariant(TileIndex t, Track track, SignalVariant v)
static inline uint8 GetSignalAspect(TileIndex t, Track track)
{
assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
dbg_assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 3 : 0;
return GB(_me[t].m7, pos, 3);
}
static inline void SetSignalAspect(TileIndex t, Track track, uint8 aspect)
{
assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
dbg_assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 3 : 0;
SB(_me[t].m7, pos, 3, aspect);
}
@ -404,7 +404,7 @@ static inline bool NonZeroSignalStylePossiblyOnTile(TileIndex t)
static inline uint8 GetSignalStyle(TileIndex t, Track track)
{
assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
dbg_assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
return GB(_me[t].m6, pos, 4);
}
@ -423,21 +423,21 @@ static inline uint8 GetSignalStyleGeneric(TileIndex t, Track track)
static inline void SetSignalStyle(TileIndex t, Track track, uint8 style)
{
assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
dbg_assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
SB(_me[t].m6, pos, 4, style);
}
static inline bool GetSignalAlwaysReserveThrough(TileIndex t, Track track)
{
assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
dbg_assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 7 : 6;
return HasBit(_me[t].m7, pos);
}
static inline void SetSignalAlwaysReserveThrough(TileIndex t, Track track, bool reserve_through)
{
assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
dbg_assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t);
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 7 : 6;
SB(_me[t].m7, pos, 1, reserve_through ? 1 : 0);
}
@ -510,7 +510,7 @@ static inline bool IsSignalPresent(TileIndex t, byte signalbit)
*/
static inline bool HasSignalOnTrack(TileIndex tile, Track track)
{
assert(IsValidTrack(track));
dbg_assert(IsValidTrack(track));
return GetRailTileType(tile) == RAIL_TILE_SIGNALS && (GetPresentSignals(tile) & SignalOnTrack(track)) != 0;
}
@ -523,7 +523,7 @@ static inline bool HasSignalOnTrack(TileIndex tile, Track track)
*/
static inline bool HasSignalOnTrackdir(TileIndex tile, Trackdir trackdir)
{
assert (IsValidTrackdir(trackdir));
dbg_assert (IsValidTrackdir(trackdir));
return GetRailTileType(tile) == RAIL_TILE_SIGNALS && GetPresentSignals(tile) & SignalAlongTrackdir(trackdir);
}
@ -535,8 +535,8 @@ static inline bool HasSignalOnTrackdir(TileIndex tile, Trackdir trackdir)
*/
static inline SignalState GetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir)
{
assert(IsValidTrackdir(trackdir));
assert_tile(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)), tile);
dbg_assert(IsValidTrackdir(trackdir));
dbg_assert_tile(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)), tile);
return GetSignalStates(tile) & SignalAlongTrackdir(trackdir) ?
SIGNAL_STATE_GREEN : SIGNAL_STATE_RED;
}
@ -593,7 +593,7 @@ static inline bool HasOnewaySignalBlockingTrackdir(TileIndex tile, Trackdir td)
*/
static inline bool IsRestrictedSignal(TileIndex tile)
{
assert_tile(GetRailTileType(tile) == RAIL_TILE_SIGNALS, tile);
dbg_assert_tile(GetRailTileType(tile) == RAIL_TILE_SIGNALS, tile);
return (bool) GB(_m[tile].m2, 12, 1);
}
@ -603,7 +603,7 @@ static inline bool IsRestrictedSignal(TileIndex tile)
*/
static inline void SetRestrictedSignal(TileIndex tile, bool is_restricted)
{
assert_tile(GetRailTileType(tile) == RAIL_TILE_SIGNALS, tile);
dbg_assert_tile(GetRailTileType(tile) == RAIL_TILE_SIGNALS, tile);
SB(_m[tile].m2, 12, 1, is_restricted);
}

View File

@ -37,7 +37,7 @@ static inline bool IsValidRoadBits(RoadBits r)
*/
static inline RoadBits ComplementRoadBits(RoadBits r)
{
assert(IsValidRoadBits(r));
dbg_assert(IsValidRoadBits(r));
return (RoadBits)(ROAD_ALL ^ r);
}
@ -51,7 +51,7 @@ static inline RoadBits ComplementRoadBits(RoadBits r)
*/
static inline RoadBits MirrorRoadBits(RoadBits r)
{
assert(IsValidRoadBits(r));
dbg_assert(IsValidRoadBits(r));
return (RoadBits)(GB(r, 0, 2) << 2 | GB(r, 2, 2));
}
@ -66,7 +66,7 @@ static inline RoadBits MirrorRoadBits(RoadBits r)
*/
static inline RoadBits RotateRoadBits(RoadBits r, DiagDirDiff rot)
{
assert(IsValidRoadBits(r));
dbg_assert(IsValidRoadBits(r));
for (; rot > (DiagDirDiff)0; rot--) {
r = (RoadBits)(GB(r, 0, 1) << 3 | GB(r, 1, 3));
}
@ -81,7 +81,7 @@ static inline RoadBits RotateRoadBits(RoadBits r, DiagDirDiff rot)
*/
static inline bool IsStraightRoad(RoadBits r)
{
assert(IsValidRoadBits(r));
dbg_assert(IsValidRoadBits(r));
return (r == ROAD_X || r == ROAD_Y);
}
@ -96,7 +96,7 @@ static inline bool IsStraightRoad(RoadBits r)
*/
static inline RoadBits DiagDirToRoadBits(DiagDirection d)
{
assert(IsValidDiagDirection(d));
dbg_assert(IsValidDiagDirection(d));
return (RoadBits)(ROAD_NW << (3 ^ d));
}
@ -111,7 +111,7 @@ static inline RoadBits DiagDirToRoadBits(DiagDirection d)
*/
static inline RoadBits AxisToRoadBits(Axis a)
{
assert(IsValidAxis(a));
dbg_assert(IsValidAxis(a));
return a == AXIS_X ? ROAD_X : ROAD_Y;
}
@ -125,7 +125,7 @@ static inline RoadBits AxisToRoadBits(Axis a)
*/
static inline Money RoadMaintenanceCost(RoadType roadtype, uint32 num, uint32 total_num)
{
assert(roadtype < ROADTYPE_END);
dbg_assert(roadtype < ROADTYPE_END);
return (_price[PR_INFRASTRUCTURE_ROAD] * GetRoadTypeInfo(roadtype)->maintenance_multiplier * num * (1 + IntSqrt(total_num))) >> 12;
}
@ -135,7 +135,7 @@ static inline Money RoadMaintenanceCost(RoadType roadtype, uint32 num, uint32 to
*/
static inline bool HasRoadCatenary(RoadType roadtype)
{
assert(roadtype < ROADTYPE_END);
dbg_assert(roadtype < ROADTYPE_END);
return HasBit(GetRoadTypeInfo(roadtype)->flags, ROTF_CATENARY);
}

View File

@ -54,7 +54,7 @@ static inline bool MayHaveRoad(TileIndex t)
*/
static inline RoadTileType GetRoadTileType(TileIndex t)
{
assert_tile(IsTileType(t, MP_ROAD), t);
dbg_assert_tile(IsTileType(t, MP_ROAD), t);
return (RoadTileType)GB(_m[t].m5, 6, 2);
}
@ -130,7 +130,7 @@ static inline bool IsRoadDepotTile(TileIndex t)
*/
static inline RoadBits GetRoadBits(TileIndex t, RoadTramType rtt)
{
assert_tile(IsNormalRoad(t), t);
dbg_assert_tile(IsNormalRoad(t), t);
if (rtt == RTT_TRAM) return (RoadBits)GB(_m[t].m3, 0, 4);
return (RoadBits)GB(_m[t].m5, 0, 4);
}
@ -165,13 +165,13 @@ static inline void SetRoadBits(TileIndex t, RoadBits r, RoadTramType rtt)
static inline RoadType GetRoadTypeRoad(TileIndex t)
{
assert(MayHaveRoad(t));
dbg_assert(MayHaveRoad(t));
return (RoadType)GB(_m[t].m4, 0, 6);
}
static inline RoadType GetRoadTypeTram(TileIndex t)
{
assert(MayHaveRoad(t));
dbg_assert(MayHaveRoad(t));
return (RoadType)GB(_me[t].m8, 6, 6);
}
@ -251,7 +251,7 @@ static inline bool HasTileAnyRoadType(TileIndex t, RoadTypes rts)
*/
static inline Owner GetRoadOwner(TileIndex t, RoadTramType rtt)
{
assert(MayHaveRoad(t));
dbg_assert(MayHaveRoad(t));
if (rtt == RTT_ROAD) return (Owner)GB(IsNormalRoadTile(t) ? _m[t].m1 : _me[t].m7, 0, 5);
/* Trams don't need OWNER_TOWN, and remapping OWNER_NONE
@ -285,7 +285,7 @@ static inline void SetRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
*/
static inline bool IsRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
{
assert_tile(HasTileRoadType(t, rtt), t);
dbg_assert_tile(HasTileRoadType(t, rtt), t);
return (GetRoadOwner(t, rtt) == o);
}
@ -319,7 +319,7 @@ template <> struct EnumPropsT<DisallowedRoadDirections> : MakeEnumPropsT<Disallo
*/
static inline DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
{
assert_tile(IsNormalRoad(t), t);
dbg_assert_tile(IsNormalRoad(t), t);
return (DisallowedRoadDirections)GB(_m[t].m5, 4, 2);
}
@ -352,7 +352,7 @@ enum RoadCachedOneWayState {
*/
static inline RoadCachedOneWayState GetRoadCachedOneWayState(TileIndex t)
{
assert(MayHaveRoad(t));
dbg_assert(MayHaveRoad(t));
return (RoadCachedOneWayState)GB(_me[t].m8, 12, 3);
}
@ -376,7 +376,7 @@ static inline void SetRoadCachedOneWayState(TileIndex t, RoadCachedOneWayState r
*/
static inline Axis GetCrossingRoadAxis(TileIndex t)
{
assert_tile(IsLevelCrossing(t), t);
dbg_assert_tile(IsLevelCrossing(t), t);
return (Axis)GB(_m[t].m5, 0, 1);
}
@ -388,7 +388,7 @@ static inline Axis GetCrossingRoadAxis(TileIndex t)
*/
static inline Axis GetCrossingRailAxis(TileIndex t)
{
assert_tile(IsLevelCrossing(t), t);
dbg_assert_tile(IsLevelCrossing(t), t);
return OtherAxis((Axis)GetCrossingRoadAxis(t));
}
@ -431,7 +431,7 @@ static inline TrackBits GetCrossingRailBits(TileIndex tile)
*/
static inline bool HasCrossingReservation(TileIndex t)
{
assert_tile(IsLevelCrossingTile(t), t);
dbg_assert_tile(IsLevelCrossingTile(t), t);
return HasBit(_m[t].m5, 4);
}
@ -467,7 +467,7 @@ static inline TrackBits GetCrossingReservationTrackBits(TileIndex t)
*/
static inline bool IsCrossingBarred(TileIndex t)
{
assert_tile(IsLevelCrossing(t), t);
dbg_assert_tile(IsLevelCrossing(t), t);
return HasBit(_m[t].m5, 5);
}
@ -491,7 +491,7 @@ static inline void SetCrossingBarred(TileIndex t, bool barred)
*/
static inline bool IsCrossingPossiblyOccupiedByRoadVehicle(TileIndex t)
{
assert_tile(IsLevelCrossing(t), t);
dbg_assert_tile(IsLevelCrossing(t), t);
return HasBit(_m[t].m5, 1);
}
@ -622,7 +622,7 @@ static inline void TerminateRoadWorks(TileIndex t)
*/
static inline DiagDirection GetRoadDepotDirection(TileIndex t)
{
assert_tile(IsRoadDepot(t), t);
dbg_assert_tile(IsRoadDepot(t), t);
return (DiagDirection)GB(_m[t].m5, 0, 2);
}

View File

@ -91,7 +91,7 @@ struct RoadVehPathCache {
inline size_t size() const
{
assert(this->td.size() == this->tile.size());
dbg_assert(this->td.size() == this->tile.size());
return this->td.size();
}

View File

@ -61,11 +61,11 @@ WaterClass GetEffectiveWaterClass(TileIndex tile)
{
if (HasTileWaterClass(tile)) return GetWaterClass(tile);
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
assert_tile(GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER, tile);
dbg_assert_tile(GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER, tile);
return WATER_CLASS_CANAL;
}
if (IsTileType(tile, MP_RAILWAY)) {
assert_tile(GetRailGroundType(tile) == RAIL_GROUND_WATER, tile);
dbg_assert_tile(GetRailGroundType(tile) == RAIL_GROUND_WATER, tile);
return WATER_CLASS_SEA;
}
NOT_REACHED();
@ -96,7 +96,7 @@ static void GetShipIcon(EngineID engine, EngineImageType image_type, VehicleSpri
spritenum = e->original_image_index;
}
assert(IsValidImageIndex<VEH_SHIP>(spritenum));
dbg_assert(IsValidImageIndex<VEH_SHIP>(spritenum));
result->Set(DIR_W + _ship_sprites[spritenum]);
}
@ -148,7 +148,7 @@ void Ship::GetImage(Direction direction, EngineImageType image_type, VehicleSpri
spritenum = this->GetEngine()->original_image_index;
}
assert(IsValidImageIndex<VEH_SHIP>(spritenum));
dbg_assert(IsValidImageIndex<VEH_SHIP>(spritenum));
result->Set(_ship_sprites[spritenum] + direction);
}
@ -550,7 +550,7 @@ static void ShipArrivesAt(const Vehicle *v, Station *st)
*/
static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
{
assert(IsValidDiagDirection(enterdir));
dbg_assert(IsValidDiagDirection(enterdir));
bool path_found = true;
Track track;
@ -807,7 +807,7 @@ static int ShipTestUpDownOnLock(const Ship *v)
if ((v->x_pos & 0xF) != 8 || (v->y_pos & 0xF) != 8) return 0;
DiagDirection diagdir = GetInclinedSlopeDirection(GetTileSlope(v->tile));
assert(IsValidDiagDirection(diagdir));
dbg_assert(IsValidDiagDirection(diagdir));
if (DirToDiagDir(v->direction) == diagdir) {
/* Move up */
@ -848,7 +848,7 @@ static bool ShipMoveUpDownOnLock(Ship *v)
*/
bool IsShipDestinationTile(TileIndex tile, StationID station)
{
assert(IsDockingTile(tile));
dbg_assert(IsDockingTile(tile));
/* Check each tile adjacent to docking tile. */
for (DiagDirection d = DIAGDIR_BEGIN; d != DIAGDIR_END; d++) {
TileIndex t = tile + TileOffsByDiagDir(d);
@ -977,7 +977,7 @@ static void ShipController(Ship *v)
if (!IsValidTile(gp.new_tile)) goto reverse_direction;
DiagDirection diagdir = DiagdirBetweenTiles(gp.old_tile, gp.new_tile);
assert(diagdir != INVALID_DIAGDIR);
dbg_assert(diagdir != INVALID_DIAGDIR);
tracks = GetAvailShipTracks(gp.new_tile, diagdir);
if (tracks == TRACK_BIT_NONE) {
Trackdir trackdir = INVALID_TRACKDIR;
@ -988,7 +988,7 @@ static void ShipController(Ship *v)
DIR_SW, DIR_NW, DIR_W, DIR_W, DIR_N, DIR_N, INVALID_DIR, INVALID_DIR,
};
v->direction = _trackdir_to_direction[trackdir];
assert(v->direction != INVALID_DIR);
dbg_assert(v->direction != INVALID_DIR);
v->state = TrackdirBitsToTrackBits(TrackdirToTrackdirBits(trackdir));
goto direction_changed;
}

View File

@ -75,7 +75,7 @@ static inline Slope RemoveHalftileSlope(Slope s)
*/
static inline Slope ComplementSlope(Slope s)
{
assert(!IsSteepSlope(s) && !IsHalftileSlope(s));
dbg_assert(!IsSteepSlope(s) && !IsHalftileSlope(s));
return s ^ SLOPE_ELEVATED;
}
@ -98,7 +98,7 @@ static inline bool IsSlopeWithOneCornerRaised(Slope s)
*/
static inline Slope SlopeWithOneCornerRaised(Corner corner)
{
assert(IsValidCorner(corner));
dbg_assert(IsValidCorner(corner));
return (Slope)(1 << corner);
}
@ -147,7 +147,7 @@ static inline Corner GetHighestSlopeCorner(Slope s)
*/
static inline Corner GetHalftileSlopeCorner(Slope s)
{
assert(IsHalftileSlope(s));
dbg_assert(IsHalftileSlope(s));
return (Corner)((s >> 6) & 3);
}
@ -273,7 +273,7 @@ static inline Slope InclinedSlope(DiagDirection dir)
*/
static inline Slope HalftileSlope(Slope s, Corner corner)
{
assert(IsValidCorner(corner));
dbg_assert(IsValidCorner(corner));
return (Slope)(s | SLOPE_HALFTILE | (corner << 6));
}
@ -332,7 +332,7 @@ static inline bool IsNonContinuousFoundation(Foundation f)
*/
static inline Corner GetHalftileFoundationCorner(Foundation f)
{
assert(IsInsideMM(f, FOUNDATION_HALFTILE_W, FOUNDATION_HALFTILE_N + 1));
dbg_assert(IsInsideMM(f, FOUNDATION_HALFTILE_W, FOUNDATION_HALFTILE_N + 1));
return (Corner)(f - FOUNDATION_HALFTILE_W);
}
@ -355,7 +355,7 @@ static inline bool IsSpecialRailFoundation(Foundation f)
*/
static inline Corner GetRailFoundationCorner(Foundation f)
{
assert(IsSpecialRailFoundation(f));
dbg_assert(IsSpecialRailFoundation(f));
return (Corner)(f - FOUNDATION_RAIL_W);
}
@ -390,7 +390,7 @@ static inline Foundation InclinedFoundation(Axis axis)
*/
static inline Foundation HalftileFoundation(Corner corner)
{
assert(IsValidCorner(corner));
dbg_assert(IsValidCorner(corner));
return (Foundation)(FOUNDATION_HALFTILE_W + corner);
}
@ -402,7 +402,7 @@ static inline Foundation HalftileFoundation(Corner corner)
*/
static inline Foundation SpecialRailFoundation(Corner corner)
{
assert(IsValidCorner(corner));
dbg_assert(IsValidCorner(corner));
return (Foundation)(FOUNDATION_RAIL_W + corner);
}

View File

@ -297,7 +297,7 @@ public:
*/
bool Sort()
{
assert(this->sort_func_list != nullptr);
dbg_assert(this->sort_func_list != nullptr);
return this->Sort(this->sort_func_list[this->sort_type]);
}

View File

@ -48,13 +48,13 @@ uint GetMaxSpriteID();
static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
{
assert(type != ST_RECOLOUR);
dbg_assert(type != ST_RECOLOUR);
return (Sprite*)GetRawSprite(sprite, type);
}
static inline const byte *GetNonSprite(SpriteID sprite, SpriteType type)
{
assert(type == ST_RECOLOUR);
dbg_assert(type == ST_RECOLOUR);
return (byte*)GetRawSprite(sprite, type);
}

View File

@ -306,8 +306,8 @@ void Station::MarkTilesDirty(bool cargo_change) const
{
TileIndex start_tile = tile;
uint length = 0;
assert_tile(IsRailStationTile(tile), tile);
assert(dir < DIAGDIR_END);
dbg_assert_tile(IsRailStationTile(tile), tile);
dbg_assert(dir < DIAGDIR_END);
do {
length++;
@ -326,7 +326,7 @@ void Station::MarkTilesDirty(bool cargo_change) const
*/
static uint GetTileCatchmentRadius(TileIndex tile, const Station *st)
{
assert(IsTileType(tile, MP_STATION));
dbg_assert(IsTileType(tile, MP_STATION));
const int32 inc = _settings_game.station.catchment_increase;
@ -385,7 +385,7 @@ uint Station::GetCatchmentRadius() const
*/
Rect Station::GetCatchmentRectUsingRadius(uint catchment_radius) const
{
assert(!this->rect.IsEmpty());
dbg_assert(!this->rect.IsEmpty());
/* Compute acceptance rectangle */
Rect ret = {
@ -618,7 +618,7 @@ CommandCost StationRect::BeforeAddTile(TileIndex tile, StationRectMode mode)
int w = new_rect.right - new_rect.left + 1;
int h = new_rect.bottom - new_rect.top + 1;
if (mode != ADD_FORCE && (w > _settings_game.station.station_spread || h > _settings_game.station.station_spread)) {
assert(mode != ADD_TRY);
dbg_assert(mode != ADD_TRY);
return_cmd_error(STR_ERROR_STATION_TOO_SPREAD_OUT);
}
@ -715,8 +715,8 @@ bool StationRect::AfterRemoveTile(BaseStation *st, TileIndex tile)
bool StationRect::AfterRemoveRect(BaseStation *st, TileArea ta)
{
assert(this->PtInExtendedRect(TileX(ta.tile), TileY(ta.tile)));
assert(this->PtInExtendedRect(TileX(ta.tile) + ta.w - 1, TileY(ta.tile) + ta.h - 1));
dbg_assert(this->PtInExtendedRect(TileX(ta.tile), TileY(ta.tile)));
dbg_assert(this->PtInExtendedRect(TileX(ta.tile) + ta.w - 1, TileY(ta.tile) + ta.h - 1));
bool empty = this->AfterRemoveTile(st, ta.tile);
if (ta.w != 1 || ta.h != 1) empty = empty || this->AfterRemoveTile(st, TILE_ADDXY(ta.tile, ta.w - 1, ta.h - 1));

View File

@ -27,7 +27,7 @@ typedef byte StationGfx; ///< Index of station graphics. @see _station_display_d
*/
static inline StationID GetStationIndex(TileIndex t)
{
assert_tile(IsTileType(t, MP_STATION), t);
dbg_assert_tile(IsTileType(t, MP_STATION), t);
return (StationID)_m[t].m2;
}
@ -43,7 +43,7 @@ static const int GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET = 4; ///< The offset for the
*/
static inline StationType GetStationType(TileIndex t)
{
assert_tile(IsTileType(t, MP_STATION), t);
dbg_assert_tile(IsTileType(t, MP_STATION), t);
return (StationType)GB(_me[t].m6, 3, 4);
}
@ -55,7 +55,7 @@ static inline StationType GetStationType(TileIndex t)
*/
static inline RoadStopType GetRoadStopType(TileIndex t)
{
assert_tile(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS, t);
dbg_assert_tile(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS, t);
return GetStationType(t) == STATION_TRUCK ? ROADSTOP_TRUCK : ROADSTOP_BUS;
}
@ -67,7 +67,7 @@ static inline RoadStopType GetRoadStopType(TileIndex t)
*/
static inline StationGfx GetStationGfx(TileIndex t)
{
assert_tile(IsTileType(t, MP_STATION), t);
dbg_assert_tile(IsTileType(t, MP_STATION), t);
return _m[t].m5;
}
@ -79,7 +79,7 @@ static inline StationGfx GetStationGfx(TileIndex t)
*/
static inline void SetStationGfx(TileIndex t, StationGfx gfx)
{
assert_tile(IsTileType(t, MP_STATION), t);
dbg_assert_tile(IsTileType(t, MP_STATION), t);
_m[t].m5 = gfx;
}
@ -222,7 +222,7 @@ static inline bool IsRoadWaypointTile(TileIndex t)
*/
static inline bool IsStationRoadStop(TileIndex t)
{
assert_tile(IsTileType(t, MP_STATION), t);
dbg_assert_tile(IsTileType(t, MP_STATION), t);
return IsTruckStop(t) || IsBusStop(t);
}
@ -244,7 +244,7 @@ static inline bool IsStationRoadStopTile(TileIndex t)
*/
static inline bool IsAnyRoadStop(TileIndex t)
{
assert_tile(IsTileType(t, MP_STATION), t);
dbg_assert_tile(IsTileType(t, MP_STATION), t);
return IsTruckStop(t) || IsBusStop(t) || IsRoadWaypoint(t);
}
@ -285,7 +285,7 @@ static inline bool IsDriveThroughStopTile(TileIndex t)
*/
static inline DisallowedRoadDirections GetDriveThroughStopDisallowedRoadDirections(TileIndex t)
{
assert_tile(IsDriveThroughStopTile(t), t);
dbg_assert_tile(IsDriveThroughStopTile(t), t);
return (DisallowedRoadDirections)GB(_m[t].m3, 0, 2);
}
@ -296,8 +296,8 @@ static inline DisallowedRoadDirections GetDriveThroughStopDisallowedRoadDirectio
*/
static inline void SetDriveThroughStopDisallowedRoadDirections(TileIndex t, DisallowedRoadDirections drd)
{
assert_tile(IsDriveThroughStopTile(t), t);
assert(drd < DRD_END);
dbg_assert_tile(IsDriveThroughStopTile(t), t);
dbg_assert(drd < DRD_END);
SB(_m[t].m3, 0, 2, drd);
}
@ -308,7 +308,7 @@ static inline void SetDriveThroughStopDisallowedRoadDirections(TileIndex t, Disa
*/
static inline Roadside GetRoadWaypointRoadside(TileIndex tile)
{
assert_tile(IsRoadWaypointTile(tile), tile);
dbg_assert_tile(IsRoadWaypointTile(tile), tile);
return (Roadside)GB(_m[tile].m3, 2, 2);
}
@ -319,7 +319,7 @@ static inline Roadside GetRoadWaypointRoadside(TileIndex tile)
*/
static inline void SetRoadWaypointRoadside(TileIndex tile, Roadside s)
{
assert_tile(IsRoadWaypointTile(tile), tile);
dbg_assert_tile(IsRoadWaypointTile(tile), tile);
SB(_m[tile].m3, 2, 2, s);
}
@ -330,7 +330,7 @@ static inline void SetRoadWaypointRoadside(TileIndex tile, Roadside s)
*/
static inline bool IsRoadWaypointOnSnowOrDesert(TileIndex t)
{
assert_tile(IsRoadWaypointTile(t), t);
dbg_assert_tile(IsRoadWaypointTile(t), t);
return HasBit(_me[t].m8, 15);
}
@ -340,7 +340,7 @@ static inline bool IsRoadWaypointOnSnowOrDesert(TileIndex t)
*/
static inline void ToggleRoadWaypointOnSnowOrDesert(TileIndex t)
{
assert_tile(IsRoadWaypointTile(t), t);
dbg_assert_tile(IsRoadWaypointTile(t), t);
ToggleBit(_me[t].m8, 15);
}
@ -352,7 +352,7 @@ static inline void ToggleRoadWaypointOnSnowOrDesert(TileIndex t)
*/
static inline StationGfx GetAirportGfx(TileIndex t)
{
assert_tile(IsAirport(t), t);
dbg_assert_tile(IsAirport(t), t);
extern StationGfx GetTranslatedAirportTileID(StationGfx gfx);
return GetTranslatedAirportTileID(GetStationGfx(t));
}
@ -366,7 +366,7 @@ static inline StationGfx GetAirportGfx(TileIndex t)
static inline DiagDirection GetRoadStopDir(TileIndex t)
{
StationGfx gfx = GetStationGfx(t);
assert_tile(IsAnyRoadStopTile(t), t);
dbg_assert_tile(IsAnyRoadStopTile(t), t);
if (gfx < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET) {
return (DiagDirection)(gfx);
} else {
@ -445,7 +445,7 @@ static inline bool IsHangarTile(TileIndex t)
*/
static inline Axis GetRailStationAxis(TileIndex t)
{
assert_tile(HasStationRail(t), t);
dbg_assert_tile(HasStationRail(t), t);
return HasBit(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X;
}
@ -486,7 +486,7 @@ static inline TrackBits GetRailStationTrackBits(TileIndex t)
*/
static inline bool IsCompatibleTrainStationTile(TileIndex test_tile, TileIndex station_tile)
{
assert_tile(IsRailStationTile(station_tile), station_tile);
dbg_assert_tile(IsRailStationTile(station_tile), station_tile);
return IsRailStationTile(test_tile) && IsCompatibleRail(GetRailType(test_tile), GetRailType(station_tile)) &&
GetRailStationAxis(test_tile) == GetRailStationAxis(station_tile) &&
GetStationIndex(test_tile) == GetStationIndex(station_tile) &&
@ -501,7 +501,7 @@ static inline bool IsCompatibleTrainStationTile(TileIndex test_tile, TileIndex s
*/
static inline bool HasStationReservation(TileIndex t)
{
assert_tile(HasStationRail(t), t);
dbg_assert_tile(HasStationRail(t), t);
return HasBit(_me[t].m6, 2);
}
@ -513,7 +513,7 @@ static inline bool HasStationReservation(TileIndex t)
*/
static inline void SetRailStationReservation(TileIndex t, bool b)
{
assert_tile(HasStationRail(t), t);
dbg_assert_tile(HasStationRail(t), t);
SB(_me[t].m6, 2, 1, b ? 1 : 0);
}
@ -538,7 +538,7 @@ static inline TrackBits GetStationReservationTrackBits(TileIndex t)
static inline DiagDirection GetDockDirection(TileIndex t)
{
StationGfx gfx = GetStationGfx(t);
assert_tile(IsDock(t) && gfx < GFX_DOCK_BASE_WATER_PART, t);
dbg_assert_tile(IsDock(t) && gfx < GFX_DOCK_BASE_WATER_PART, t);
return (DiagDirection)(gfx);
}
@ -559,12 +559,12 @@ static inline TileIndexDiffC GetDockOffset(TileIndex t)
{ 2, 0},
{ 0, -2},
};
assert_tile(IsTileType(t, MP_STATION), t);
dbg_assert_tile(IsTileType(t, MP_STATION), t);
if (IsBuoy(t)) return buoy_offset;
if (IsOilRig(t)) return oilrig_offset;
assert_tile(IsDock(t), t);
dbg_assert_tile(IsDock(t), t);
return dock_offset[GetDockDirection(t)];
}
@ -577,7 +577,7 @@ static inline TileIndexDiffC GetDockOffset(TileIndex t)
*/
static inline bool IsCustomStationSpecIndex(TileIndex t)
{
assert_tile(HasStationTileRail(t), t);
dbg_assert_tile(HasStationTileRail(t), t);
return _m[t].m4 != 0;
}
@ -589,7 +589,7 @@ static inline bool IsCustomStationSpecIndex(TileIndex t)
*/
static inline void SetCustomStationSpecIndex(TileIndex t, byte specindex)
{
assert_tile(HasStationTileRail(t), t);
dbg_assert_tile(HasStationTileRail(t), t);
_m[t].m4 = specindex;
}
@ -601,7 +601,7 @@ static inline void SetCustomStationSpecIndex(TileIndex t, byte specindex)
*/
static inline uint GetCustomStationSpecIndex(TileIndex t)
{
assert_tile(HasStationTileRail(t), t);
dbg_assert_tile(HasStationTileRail(t), t);
return _m[t].m4;
}
@ -613,7 +613,7 @@ static inline uint GetCustomStationSpecIndex(TileIndex t)
*/
static inline bool IsCustomRoadStopSpecIndex(TileIndex t)
{
assert_tile(IsAnyRoadStopTile(t), t);
dbg_assert_tile(IsAnyRoadStopTile(t), t);
return GB(_me[t].m8, 0, 6) != 0;
}
@ -625,7 +625,7 @@ static inline bool IsCustomRoadStopSpecIndex(TileIndex t)
*/
static inline void SetCustomRoadStopSpecIndex(TileIndex t, byte specindex)
{
assert_tile(IsAnyRoadStopTile(t), t);
dbg_assert_tile(IsAnyRoadStopTile(t), t);
SB(_me[t].m8, 0, 6, specindex);
}
@ -637,7 +637,7 @@ static inline void SetCustomRoadStopSpecIndex(TileIndex t, byte specindex)
*/
static inline uint GetCustomRoadStopSpecIndex(TileIndex t)
{
assert_tile(IsAnyRoadStopTile(t), t);
dbg_assert_tile(IsAnyRoadStopTile(t), t);
return GB(_me[t].m8, 0, 6);
}
@ -649,7 +649,7 @@ static inline uint GetCustomRoadStopSpecIndex(TileIndex t)
*/
static inline void SetStationTileRandomBits(TileIndex t, byte random_bits)
{
assert_tile(IsTileType(t, MP_STATION), t);
dbg_assert_tile(IsTileType(t, MP_STATION), t);
SB(_m[t].m3, 4, 4, random_bits);
}
@ -661,7 +661,7 @@ static inline void SetStationTileRandomBits(TileIndex t, byte random_bits)
*/
static inline byte GetStationTileRandomBits(TileIndex t)
{
assert_tile(IsTileType(t, MP_STATION), t);
dbg_assert_tile(IsTileType(t, MP_STATION), t);
return GB(_m[t].m3, 4, 4);
}

View File

@ -83,7 +83,7 @@ int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap)
*/
char *strecat(char *dst, const char *src, const char *last)
{
assert(dst <= last);
dbg_assert(dst <= last);
while (*dst != '\0') {
if (dst == last) return dst;
dst++;
@ -111,7 +111,7 @@ char *strecat(char *dst, const char *src, const char *last)
*/
char *strecpy(char *dst, const char *src, const char *last, bool quiet_mode)
{
assert(dst <= last);
dbg_assert(dst <= last);
while (dst != last && *src != '\0') {
*dst++ = *src++;
}
@ -684,7 +684,7 @@ char *md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
*/
size_t Utf8Decode(WChar *c, const char *s)
{
assert(c != nullptr);
dbg_assert(c != nullptr);
if (!HasBit(s[0], 7)) {
/* Single byte character: 0xxxxxxx */
@ -1072,7 +1072,7 @@ public:
virtual size_t SetCurPosition(size_t pos)
{
assert(this->string != nullptr && pos <= this->len);
dbg_assert(this->string != nullptr && pos <= this->len);
/* Sanitize in case we get a position inside an UTF-8 sequence. */
while (pos > 0 && IsUtf8Part(this->string[pos])) pos--;
return this->cur_pos = pos;
@ -1080,7 +1080,7 @@ public:
virtual size_t Next(IterType what)
{
assert(this->string != nullptr);
dbg_assert(this->string != nullptr);
/* Already at the end? */
if (this->cur_pos >= this->len) return END;
@ -1118,7 +1118,7 @@ public:
virtual size_t Prev(IterType what)
{
assert(this->string != nullptr);
dbg_assert(this->string != nullptr);
/* Already at the beginning? */
if (this->cur_pos == 0) return END;

View File

@ -655,13 +655,13 @@ static void HeightMapCurves(uint level)
if (*h >= p1.x && *h < p2.x) {
ht[t] = p1.y + (*h - p1.x) * (p2.y - p1.y) / (p2.x - p1.x);
#ifdef WITH_ASSERT
#ifdef WITH_FULL_ASSERTS
found = true;
#endif
break;
}
}
assert(found);
dbg_assert(found);
}
/* Apply interpolation of curve map results. */

View File

@ -30,7 +30,7 @@ static inline uint TileHeight(TileIndex tile)
{
/* this method is inlined in many places and is performance-critical, drop assertion in non-debug builds */
#ifdef _DEBUG
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
#endif
return _m[tile].height;
}
@ -59,8 +59,8 @@ static inline uint TileHeightOutsideMap(int x, int y)
*/
static inline void SetTileHeight(TileIndex tile, uint height)
{
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
assert(height <= MAX_TILE_HEIGHT);
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
dbg_assert(height <= MAX_TILE_HEIGHT);
_m[tile].height = height;
}
@ -100,7 +100,7 @@ static inline TileType GetTileType(TileIndex tile)
{
/* this method is inlined in many places and is performance-critical, drop assertion in non-debug builds */
#ifdef _DEBUG
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
#endif
return (TileType)GB(_m[tile].type, 4, 4);
}
@ -114,7 +114,7 @@ static inline TileType GetTileType(TileIndex tile)
*/
static inline bool IsInnerTile(TileIndex tile)
{
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
uint x = TileX(tile);
uint y = TileY(tile);
@ -136,11 +136,11 @@ static inline bool IsInnerTile(TileIndex tile)
*/
static inline void SetTileType(TileIndex tile, TileType type)
{
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X, type: %d", tile, MapSize(), type);
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X, type: %d", tile, MapSize(), type);
/* VOID tiles (and no others) are exactly allowed at the lower left and right
* edges of the map. If _settings_game.construction.freeform_edges is true,
* the upper edges of the map are also VOID tiles. */
assert_msg(IsInnerTile(tile) == (type != MP_VOID), "tile: 0x%X (%d), type: %d", tile, IsInnerTile(tile), type);
dbg_assert_msg(IsInnerTile(tile) == (type != MP_VOID), "tile: 0x%X (%d), type: %d", tile, IsInnerTile(tile), type);
SB(_m[tile].type, 4, 4, type);
}
@ -183,8 +183,8 @@ static inline bool IsValidTile(TileIndex tile)
*/
static inline Owner GetTileOwner(TileIndex tile)
{
assert_msg(IsValidTile(tile), "tile: 0x%X, size: 0x%X", tile, MapSize());
assert_msg(!IsTileType(tile, MP_HOUSE) && !IsTileType(tile, MP_INDUSTRY), "tile: 0x%X (%d)", tile, GetTileType(tile));
dbg_assert_msg(IsValidTile(tile), "tile: 0x%X, size: 0x%X", tile, MapSize());
dbg_assert_msg(!IsTileType(tile, MP_HOUSE) && !IsTileType(tile, MP_INDUSTRY), "tile: 0x%X (%d)", tile, GetTileType(tile));
return (Owner)GB(_m[tile].m1, 0, 5);
}
@ -202,8 +202,8 @@ static inline Owner GetTileOwner(TileIndex tile)
*/
static inline void SetTileOwner(TileIndex tile, Owner owner)
{
assert_msg(IsValidTile(tile), "tile: 0x%X, size: 0x%X, owner: %d", tile, MapSize(), owner);
assert_msg(!IsTileType(tile, MP_HOUSE) && !IsTileType(tile, MP_INDUSTRY), "tile: 0x%X (%d), owner: %d", tile, GetTileType(tile), owner);
dbg_assert_msg(IsValidTile(tile), "tile: 0x%X, size: 0x%X, owner: %d", tile, MapSize(), owner);
dbg_assert_msg(!IsTileType(tile, MP_HOUSE) && !IsTileType(tile, MP_INDUSTRY), "tile: 0x%X (%d), owner: %d", tile, GetTileType(tile), owner);
SB(_m[tile].m1, 0, 5, owner);
}
@ -228,8 +228,8 @@ static inline bool IsTileOwner(TileIndex tile, Owner owner)
*/
static inline void SetTropicZone(TileIndex tile, TropicZone type)
{
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X, type: %d", tile, MapSize(), type);
assert_msg(!IsTileType(tile, MP_VOID) || type == TROPICZONE_NORMAL, "tile: 0x%X (%d), type: %d", tile, GetTileType(tile), type);
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X, type: %d", tile, MapSize(), type);
dbg_assert_msg(!IsTileType(tile, MP_VOID) || type == TROPICZONE_NORMAL, "tile: 0x%X (%d), type: %d", tile, GetTileType(tile), type);
SB(_m[tile].type, 0, 2, type);
}
@ -241,7 +241,7 @@ static inline void SetTropicZone(TileIndex tile, TropicZone type)
*/
static inline TropicZone GetTropicZone(TileIndex tile)
{
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
return (TropicZone)GB(_m[tile].type, 0, 2);
}
@ -253,7 +253,7 @@ static inline TropicZone GetTropicZone(TileIndex tile)
*/
static inline byte GetAnimationFrame(TileIndex t)
{
assert_msg(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_STATION), "tile: 0x%X (%d)", t, GetTileType(t));
dbg_assert_msg(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_STATION), "tile: 0x%X (%d)", t, GetTileType(t));
return _me[t].m7;
}
@ -265,7 +265,7 @@ static inline byte GetAnimationFrame(TileIndex t)
*/
static inline void SetAnimationFrame(TileIndex t, byte frame)
{
assert_msg(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_STATION), "tile: 0x%X (%d)", t, GetTileType(t));
dbg_assert_msg(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_STATION), "tile: 0x%X (%d)", t, GetTileType(t));
_me[t].m7 = frame;
}

View File

@ -20,8 +20,8 @@
*/
OrthogonalTileArea::OrthogonalTileArea(TileIndex start, TileIndex end)
{
assert(start < MapSize());
assert(end < MapSize());
dbg_assert(start < MapSize());
dbg_assert(end < MapSize());
uint sx = TileX(start);
uint sy = TileY(start);
@ -76,7 +76,7 @@ bool OrthogonalTileArea::Intersects(const OrthogonalTileArea &ta) const
{
if (ta.w == 0 || this->w == 0) return false;
assert(ta.w != 0 && ta.h != 0 && this->w != 0 && this->h != 0);
dbg_assert(ta.w != 0 && ta.h != 0 && this->w != 0 && this->h != 0);
uint left1 = TileX(this->tile);
uint top1 = TileY(this->tile);
@ -105,7 +105,7 @@ bool OrthogonalTileArea::Contains(TileIndex tile) const
{
if (this->w == 0) return false;
assert(this->w != 0 && this->h != 0);
dbg_assert(this->w != 0 && this->h != 0);
uint left = TileX(this->tile);
uint top = TileY(this->tile);
@ -141,7 +141,7 @@ OrthogonalTileArea &OrthogonalTileArea::Expand(int rad)
*/
void OrthogonalTileArea::ClampToMap()
{
assert(this->tile < MapSize());
dbg_assert(this->tile < MapSize());
this->w = std::min<int>(this->w, MapSizeX() - TileX(this->tile));
this->h = std::min<int>(this->h, MapSizeY() - TileY(this->tile));
}
@ -171,8 +171,8 @@ OrthogonalTileIterator OrthogonalTileArea::end() const
*/
DiagonalTileArea::DiagonalTileArea(TileIndex start, TileIndex end) : tile(start)
{
assert(start < MapSize());
assert(end < MapSize());
dbg_assert(start < MapSize());
dbg_assert(end < MapSize());
/* Unfortunately we can't find a new base and make all a and b positive because
* the new base might be a "flattened" corner where there actually is no single
@ -233,7 +233,7 @@ bool DiagonalTileArea::Contains(TileIndex tile) const
*/
TileIterator &DiagonalTileIterator::operator++()
{
assert(this->tile != INVALID_TILE);
dbg_assert(this->tile != INVALID_TILE);
/* Determine the next tile, while clipping at map borders */
bool new_line = false;

View File

@ -21,7 +21,7 @@
*/
static inline TownID GetTownIndex(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)), t);
return _m[t].m2;
}
@ -33,7 +33,7 @@ static inline TownID GetTownIndex(TileIndex t)
*/
static inline void SetTownIndex(TileIndex t, TownID index)
{
assert_tile(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)), t);
_m[t].m2 = index;
}
@ -46,7 +46,7 @@ static inline void SetTownIndex(TileIndex t, TownID index)
*/
static inline HouseID GetCleanHouseType(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
return _m[t].m4 | (GB(_m[t].m3, 5, 2) << 8);
}
@ -69,7 +69,7 @@ static inline HouseID GetHouseType(TileIndex t)
*/
static inline void SetHouseType(TileIndex t, HouseID house_id)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
_m[t].m4 = GB(house_id, 0, 8);
SB(_m[t].m3, 5, 2, GB(house_id, 8, 2));
}
@ -144,7 +144,7 @@ static inline void SetLiftPosition(TileIndex t, byte pos)
*/
static inline bool IsHouseCompleted(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
return HasBit(_m[t].m3, 7);
}
@ -155,7 +155,7 @@ static inline bool IsHouseCompleted(TileIndex t)
*/
static inline void SetHouseCompleted(TileIndex t, bool status)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
SB(_m[t].m3, 7, 1, !!status);
}
@ -182,7 +182,7 @@ static inline void SetHouseCompleted(TileIndex t, bool status)
*/
static inline byte GetHouseBuildingStage(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
return IsHouseCompleted(t) ? (byte)TOWN_HOUSE_COMPLETED : GB(_m[t].m5, 3, 2);
}
@ -194,7 +194,7 @@ static inline byte GetHouseBuildingStage(TileIndex t)
*/
static inline byte GetHouseConstructionTick(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
return IsHouseCompleted(t) ? 0 : GB(_m[t].m5, 0, 3);
}
@ -207,7 +207,7 @@ static inline byte GetHouseConstructionTick(TileIndex t)
*/
static inline void IncHouseConstructionTick(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
AB(_m[t].m5, 0, 5, 1);
if (GB(_m[t].m5, 3, 2) == TOWN_HOUSE_COMPLETED) {
@ -225,7 +225,7 @@ static inline void IncHouseConstructionTick(TileIndex t)
*/
static inline void ResetHouseAge(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE) && IsHouseCompleted(t), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE) && IsHouseCompleted(t), t);
_m[t].m5 = 0;
}
@ -236,7 +236,7 @@ static inline void ResetHouseAge(TileIndex t)
*/
static inline void IncrementHouseAge(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
if (IsHouseCompleted(t) && _m[t].m5 < 0xFF) _m[t].m5++;
}
@ -248,7 +248,7 @@ static inline void IncrementHouseAge(TileIndex t)
*/
static inline Year GetHouseAge(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
return IsHouseCompleted(t) ? _m[t].m5 : 0;
}
@ -261,7 +261,7 @@ static inline Year GetHouseAge(TileIndex t)
*/
static inline void SetHouseRandomBits(TileIndex t, byte random)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
_m[t].m1 = random;
}
@ -274,7 +274,7 @@ static inline void SetHouseRandomBits(TileIndex t, byte random)
*/
static inline byte GetHouseRandomBits(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
return _m[t].m1;
}
@ -287,7 +287,7 @@ static inline byte GetHouseRandomBits(TileIndex t)
*/
static inline void SetHouseTriggers(TileIndex t, byte triggers)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
SB(_m[t].m3, 0, 5, triggers);
}
@ -300,7 +300,7 @@ static inline void SetHouseTriggers(TileIndex t, byte triggers)
*/
static inline byte GetHouseTriggers(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
return GB(_m[t].m3, 0, 5);
}
@ -312,7 +312,7 @@ static inline byte GetHouseTriggers(TileIndex t)
*/
static inline byte GetHouseProcessingTime(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
return GB(_me[t].m6, 2, 6);
}
@ -324,7 +324,7 @@ static inline byte GetHouseProcessingTime(TileIndex t)
*/
static inline void SetHouseProcessingTime(TileIndex t, byte time)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
SB(_me[t].m6, 2, 6, time);
}
@ -335,7 +335,7 @@ static inline void SetHouseProcessingTime(TileIndex t, byte time)
*/
static inline void DecHouseProcessingTime(TileIndex t)
{
assert_tile(IsTileType(t, MP_HOUSE), t);
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
_me[t].m6 -= 1 << 2;
}
@ -351,7 +351,7 @@ static inline void DecHouseProcessingTime(TileIndex t)
*/
static inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
{
assert_tile(IsTileType(t, MP_CLEAR), t);
dbg_assert_tile(IsTileType(t, MP_CLEAR), t);
SetTileType(t, MP_HOUSE);
_m[t].m1 = random_bits;

View File

@ -22,7 +22,7 @@ using SetTrackBitIterator = SetBitIterator<Track, TrackBits>;
*
* @param track The value to check
* @return true if the given value is a valid track.
* @note Use this in an assert()
* @note Use this in an dbg_assert()
*/
static inline bool IsValidTrack(Track track)
{
@ -34,7 +34,7 @@ static inline bool IsValidTrack(Track track)
*
* @param trackdir The value to check
* @return true if the given value is a valid Trackdir
* @note Use this in an assert()
* @note Use this in an dbg_assert()
*/
static inline bool IsValidTrackdirForRoadVehicle(Trackdir trackdir)
{
@ -46,7 +46,7 @@ static inline bool IsValidTrackdirForRoadVehicle(Trackdir trackdir)
*
* @param trackdir The value to check
* @return true if the given value is a valid Trackdir
* @note Use this in an assert()
* @note Use this in an dbg_assert()
*/
static inline bool IsValidTrackdir(Trackdir trackdir)
{
@ -64,7 +64,7 @@ static inline bool IsValidTrackdir(Trackdir trackdir)
*/
static inline Track AxisToTrack(Axis a)
{
assert(IsValidAxis(a));
dbg_assert(IsValidAxis(a));
return (Track)a;
}
@ -75,7 +75,7 @@ static inline Track AxisToTrack(Axis a)
*/
static inline TrackBits TrackToTrackBits(Track track)
{
assert(IsValidTrack(track));
dbg_assert(IsValidTrack(track));
return (TrackBits)(1 << track);
}
@ -98,7 +98,7 @@ static inline TrackBits AxisToTrackBits(Axis a)
static inline TrackBits CornerToTrackBits(Corner corner)
{
extern const TrackBits _corner_to_trackbits[];
assert(IsValidCorner(corner));
dbg_assert(IsValidCorner(corner));
return _corner_to_trackbits[corner];
}
@ -109,7 +109,7 @@ static inline TrackBits CornerToTrackBits(Corner corner)
*/
static inline TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir)
{
assert(IsValidTrackdir(trackdir));
dbg_assert(IsValidTrackdir(trackdir));
return (TrackdirBits)(1 << trackdir);
}
@ -130,7 +130,7 @@ static inline TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir)
static inline Track RemoveFirstTrack(TrackBits *tracks)
{
if (*tracks != TRACK_BIT_NONE && *tracks != INVALID_TRACK_BIT) {
assert((*tracks & ~TRACK_BIT_MASK) == TRACK_BIT_NONE);
dbg_assert((*tracks & ~TRACK_BIT_MASK) == TRACK_BIT_NONE);
Track first = (Track)FIND_FIRST_BIT(*tracks);
ClrBit(*tracks, first);
return first;
@ -155,7 +155,7 @@ static inline Track RemoveFirstTrack(TrackBits *tracks)
static inline Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs)
{
if (*trackdirs != TRACKDIR_BIT_NONE && *trackdirs != INVALID_TRACKDIR_BIT) {
assert((*trackdirs & ~TRACKDIR_BIT_MASK) == TRACKDIR_BIT_NONE);
dbg_assert((*trackdirs & ~TRACKDIR_BIT_MASK) == TRACKDIR_BIT_NONE);
Trackdir first = (Trackdir)FindFirstBit2x64(*trackdirs);
ClrBit(*trackdirs, first);
return first;
@ -191,7 +191,7 @@ static inline Track FindFirstTrack(TrackBits tracks)
*/
static inline Track TrackBitsToTrack(TrackBits tracks)
{
assert(tracks == INVALID_TRACK_BIT || (tracks != TRACK_BIT_NONE && KillFirstBit(tracks & TRACK_BIT_MASK) == TRACK_BIT_NONE));
dbg_assert(tracks == INVALID_TRACK_BIT || (tracks != TRACK_BIT_NONE && KillFirstBit(tracks & TRACK_BIT_MASK) == TRACK_BIT_NONE));
return tracks != INVALID_TRACK_BIT ? (Track)FIND_FIRST_BIT(tracks & TRACK_BIT_MASK) : INVALID_TRACK;
}
@ -209,7 +209,7 @@ static inline Track TrackBitsToTrack(TrackBits tracks)
*/
static inline Trackdir FindFirstTrackdir(TrackdirBits trackdirs)
{
assert((trackdirs & ~TRACKDIR_BIT_MASK) == TRACKDIR_BIT_NONE);
dbg_assert((trackdirs & ~TRACKDIR_BIT_MASK) == TRACKDIR_BIT_NONE);
return (trackdirs != TRACKDIR_BIT_NONE) ? (Trackdir)FindFirstBit2x64(trackdirs) : INVALID_TRACKDIR;
}
@ -229,7 +229,7 @@ static inline Trackdir FindFirstTrackdir(TrackdirBits trackdirs)
*/
static inline Track TrackToOppositeTrack(Track t)
{
assert(IsValidTrack(t));
dbg_assert(IsValidTrack(t));
return (Track)(t ^ 1);
}
@ -245,7 +245,7 @@ static inline Track TrackToOppositeTrack(Track t)
*/
static inline Trackdir ReverseTrackdir(Trackdir trackdir)
{
assert(IsValidTrackdirForRoadVehicle(trackdir));
dbg_assert(IsValidTrackdirForRoadVehicle(trackdir));
return (Trackdir)(trackdir ^ 8);
}
@ -260,7 +260,7 @@ static inline Trackdir ReverseTrackdir(Trackdir trackdir)
*/
static inline Track TrackdirToTrack(Trackdir trackdir)
{
assert(IsValidTrackdir(trackdir));
dbg_assert(IsValidTrackdir(trackdir));
return (Track)(trackdir & 0x7);
}
@ -277,7 +277,7 @@ static inline Track TrackdirToTrack(Trackdir trackdir)
*/
static inline Trackdir TrackToTrackdir(Track track)
{
assert(IsValidTrack(track));
dbg_assert(IsValidTrack(track));
return (Trackdir)track;
}
@ -327,7 +327,7 @@ static inline TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
*/
static inline bool HasTrack(TrackBits tracks, Track track)
{
assert(IsValidTrack(track));
dbg_assert(IsValidTrack(track));
return HasBit(tracks, track);
}
@ -338,7 +338,7 @@ static inline bool HasTrack(TrackBits tracks, Track track)
*/
static inline bool HasTrackdir(TrackdirBits trackdirs, Trackdir trackdir)
{
assert(IsValidTrackdir(trackdir));
dbg_assert(IsValidTrackdir(trackdir));
return HasBit(trackdirs, trackdir);
}
@ -401,7 +401,7 @@ static inline TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, Trackdir
*/
static inline Trackdir NextTrackdir(Trackdir trackdir)
{
assert(IsValidTrackdir(trackdir));
dbg_assert(IsValidTrackdir(trackdir));
extern const Trackdir _next_trackdir[TRACKDIR_END];
return _next_trackdir[trackdir];
}
@ -418,7 +418,7 @@ static inline Trackdir NextTrackdir(Trackdir trackdir)
*/
static inline TrackBits TrackCrossesTracks(Track track)
{
assert(IsValidTrack(track));
dbg_assert(IsValidTrack(track));
extern const TrackBits _track_crosses_tracks[TRACK_END];
return _track_crosses_tracks[track];
}
@ -437,7 +437,7 @@ static inline TrackBits TrackCrossesTracks(Track track)
*/
static inline DiagDirection TrackdirToExitdir(Trackdir trackdir)
{
assert(IsValidTrackdirForRoadVehicle(trackdir));
dbg_assert(IsValidTrackdirForRoadVehicle(trackdir));
extern const DiagDirection _trackdir_to_exitdir[TRACKDIR_END];
return _trackdir_to_exitdir[trackdir];
}
@ -459,8 +459,8 @@ static inline DiagDirection TrackdirToExitdir(Trackdir trackdir)
*/
static inline Trackdir TrackExitdirToTrackdir(Track track, DiagDirection diagdir)
{
assert(IsValidTrack(track));
assert(IsValidDiagDirection(diagdir));
dbg_assert(IsValidTrack(track));
dbg_assert(IsValidDiagDirection(diagdir));
extern const Trackdir _track_exitdir_to_trackdir[TRACK_END][DIAGDIR_END];
return _track_exitdir_to_trackdir[track][diagdir];
}
@ -484,8 +484,8 @@ static inline Trackdir TrackExitdirToTrackdir(Track track, DiagDirection diagdir
*/
static inline Trackdir TrackEnterdirToTrackdir(Track track, DiagDirection diagdir)
{
assert(IsValidTrack(track));
assert(IsValidDiagDirection(diagdir));
dbg_assert(IsValidTrack(track));
dbg_assert(IsValidDiagDirection(diagdir));
extern const Trackdir _track_enterdir_to_trackdir[TRACK_END][DIAGDIR_END];
return _track_enterdir_to_trackdir[track][diagdir];
}
@ -496,8 +496,8 @@ static inline Trackdir TrackEnterdirToTrackdir(Track track, DiagDirection diagdi
*/
static inline Trackdir TrackDirectionToTrackdir(Track track, Direction dir)
{
assert(IsValidTrack(track));
assert(IsValidDirection(dir));
dbg_assert(IsValidTrack(track));
dbg_assert(IsValidDirection(dir));
extern const Trackdir _track_direction_to_trackdir[TRACK_END][DIR_END];
return _track_direction_to_trackdir[track][dir];
}
@ -510,7 +510,7 @@ static inline Trackdir TrackDirectionToTrackdir(Track track, Direction dir)
*/
static inline Track DiagDirToDiagTrack(DiagDirection diagdir)
{
assert(IsValidDiagDirection(diagdir));
dbg_assert(IsValidDiagDirection(diagdir));
return (Track)(diagdir & 1);
}
@ -522,7 +522,7 @@ static inline Track DiagDirToDiagTrack(DiagDirection diagdir)
*/
static inline TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
{
assert(IsValidDiagDirection(diagdir));
dbg_assert(IsValidDiagDirection(diagdir));
return TrackToTrackBits(DiagDirToDiagTrack(diagdir));
}
@ -535,7 +535,7 @@ static inline TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
*/
static inline Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
{
assert(IsValidDiagDirection(diagdir));
dbg_assert(IsValidDiagDirection(diagdir));
extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END];
return _dir_to_diag_trackdir[diagdir];
}
@ -553,7 +553,7 @@ static inline Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
*/
static inline TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir)
{
assert(IsValidDiagDirection(diagdir));
dbg_assert(IsValidDiagDirection(diagdir));
extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END];
return _exitdir_reaches_trackdirs[diagdir];
}
@ -582,7 +582,7 @@ static inline TrackBits DiagdirReachesTracks(DiagDirection diagdir) { return Tra
*/
static inline TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir)
{
assert(IsValidTrackdir(trackdir));
dbg_assert(IsValidTrackdir(trackdir));
extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END];
return _exitdir_reaches_trackdirs[TrackdirToExitdir(trackdir)];
}
@ -604,7 +604,7 @@ static inline TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir)
*/
static inline TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
{
assert(IsValidTrackdirForRoadVehicle(trackdir));
dbg_assert(IsValidTrackdirForRoadVehicle(trackdir));
extern const TrackdirBits _track_crosses_trackdirs[TRACK_END];
return _track_crosses_trackdirs[TrackdirToTrack(trackdir)];
}
@ -617,7 +617,7 @@ static inline TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
*/
static inline bool IsDiagonalTrack(Track track)
{
assert(IsValidTrack(track));
dbg_assert(IsValidTrack(track));
return (track == TRACK_X) || (track == TRACK_Y);
}
@ -629,7 +629,7 @@ static inline bool IsDiagonalTrack(Track track)
*/
static inline bool IsDiagonalTrackdir(Trackdir trackdir)
{
assert(IsValidTrackdir(trackdir));
dbg_assert(IsValidTrackdir(trackdir));
return IsDiagonalTrack(TrackdirToTrack(trackdir));
}
@ -671,7 +671,7 @@ static inline bool TrackOverlapsTracks(TrackBits tracks, Track track)
*/
static inline bool IsReversingRoadTrackdir(Trackdir dir)
{
assert(IsValidTrackdirForRoadVehicle(dir));
dbg_assert(IsValidTrackdirForRoadVehicle(dir));
return (dir & 0x07) >= 6;
}
@ -682,7 +682,7 @@ static inline bool IsReversingRoadTrackdir(Trackdir dir)
*/
static inline bool IsStraightRoadTrackdir(Trackdir dir)
{
assert(IsValidTrackdirForRoadVehicle(dir));
dbg_assert(IsValidTrackdirForRoadVehicle(dir));
return (dir & 0x06) == 0;
}
@ -698,7 +698,7 @@ static inline bool IsStraightRoadTrackdir(Trackdir dir)
*/
static inline bool IsUphillTrackdir(Slope slope, Trackdir dir)
{
assert(IsValidTrackdirForRoadVehicle(dir));
dbg_assert(IsValidTrackdirForRoadVehicle(dir));
extern const TrackdirBits _uphill_trackdirs[];
return HasBit(_uphill_trackdirs[RemoveHalftileSlope(slope)], dir);
}

View File

@ -205,7 +205,7 @@ void CheckTrainsLengths()
*/
void CheckBreakdownFlags(Train *v)
{
assert(v->IsFrontEngine());
dbg_assert(v->IsFrontEngine());
/* clear the flags we're gonna check first, we'll set them again later (if applicable) */
CLRBITS(v->flags, (1 << VRF_BREAKDOWN_BRAKING) | VRF_IS_BROKEN);
@ -255,7 +255,7 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes)
{
uint16 max_speed = UINT16_MAX;
assert(this->IsFrontEngine() || this->IsFreeWagon());
dbg_assert(this->IsFrontEngine() || this->IsFreeWagon());
const RailVehicleInfo *rvi_v = RailVehInfo(this->engine_type);
EngineID first_engine = this->IsFrontEngine() ? this->engine_type : INVALID_ENGINE;
@ -271,7 +271,7 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes)
const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type);
/* Check the this->first cache. */
assert_msg(u->First() == this, "u: %s, this: %s",
dbg_assert_msg(u->First() == this, "u: %s, this: %s",
scope_dumper().VehicleInfo(u), scope_dumper().VehicleInfo(this));
/* update the 'first engine' */
@ -613,7 +613,7 @@ int GetTrainStopLocation(StationID station_id, TileIndex tile, Train *v, bool up
*/
int Train::GetCurveSpeedLimit() const
{
assert(this->First() == this);
dbg_assert(this->First() == this);
static const int absolute_max_speed = UINT16_MAX;
int max_speed = absolute_max_speed;
@ -690,7 +690,7 @@ void AdvanceOrderIndex(const Vehicle *v, VehicleOrderID &index)
if (index >= v->GetNumOrders()) index = 0;
Order *order = v->GetOrder(index);
assert(order != nullptr);
dbg_assert(order != nullptr);
switch (order->GetType()) {
case OT_GOTO_DEPOT:
@ -1157,7 +1157,7 @@ uint32 Train::CalculateOverallZPos() const
/** Update acceleration of the train from the cached power and weight. */
void Train::UpdateAcceleration()
{
assert(this->IsFrontEngine() || this->IsFreeWagon());
dbg_assert(this->IsFrontEngine() || this->IsFreeWagon());
uint power = this->gcache.cached_power;
uint weight = this->gcache.cached_weight;
@ -1285,7 +1285,7 @@ int Train::GetDisplayImageWidth(Point *offset) const
static SpriteID GetDefaultTrainSprite(uint8 spritenum, Direction direction)
{
assert(IsValidImageIndex<VEH_TRAIN>(spritenum));
dbg_assert(IsValidImageIndex<VEH_TRAIN>(spritenum));
return ((direction + _engine_sprite_add[spritenum]) & _engine_sprite_and[spritenum]) + _engine_sprite_base[spritenum];
}
@ -1308,7 +1308,7 @@ void Train::GetImage(Direction direction, EngineImageType image_type, VehicleSpr
spritenum = this->GetEngine()->original_image_index;
}
assert(IsValidImageIndex<VEH_TRAIN>(spritenum));
dbg_assert(IsValidImageIndex<VEH_TRAIN>(spritenum));
SpriteID sprite = GetDefaultTrainSprite(spritenum, direction);
if (this->cargo.StoredCount() >= this->cargo_cap / 2U) sprite += _wagon_full_adder[spritenum];
@ -2595,7 +2595,7 @@ static Vehicle *TrainApproachingCrossingEnum(Vehicle *v, void *data)
*/
static bool TrainApproachingCrossing(TileIndex tile)
{
assert_tile(IsLevelCrossingTile(tile), tile);
dbg_assert_tile(IsLevelCrossingTile(tile), tile);
DiagDirection dir = AxisToDiagDir(GetCrossingRailAxis(tile));
TileIndex tile_from = tile + TileOffsByDiagDir(dir);
@ -2627,7 +2627,7 @@ static inline bool CheckLevelCrossing(TileIndex tile)
*/
static void UpdateLevelCrossingTile(TileIndex tile, bool sound, bool is_forced, bool forced_state)
{
assert_tile(IsLevelCrossingTile(tile), tile);
dbg_assert_tile(IsLevelCrossingTile(tile), tile);
bool new_state;
if (is_forced) {
@ -3656,7 +3656,7 @@ void FreeTrainTrackReservation(Train *v, TileIndex origin, Trackdir orig_td)
tile = ft.m_new_tile;
TrackdirBits bits = ft.m_new_td_bits & TrackBitsToTrackdirBits(GetReservedTrackbits(tile));
td = RemoveFirstTrackdir(&bits);
assert(bits == TRACKDIR_BIT_NONE);
dbg_assert(bits == TRACKDIR_BIT_NONE);
if (!IsValidTrackdir(td)) break;
@ -3817,9 +3817,9 @@ static PBSTileInfo ExtendTrainReservation(const Train *v, const PBSTileInfo &ori
if (ft.m_tiles_skipped == 0 && Rail90DegTurnDisallowedTilesFromTrackdir(ft.m_old_tile, ft.m_new_tile, ft.m_old_td)) {
ft.m_new_td_bits &= ~TrackdirCrossesTrackdirs(ft.m_old_td);
assert(ft.m_new_td_bits != TRACKDIR_BIT_NONE);
dbg_assert(ft.m_new_td_bits != TRACKDIR_BIT_NONE);
}
assert(KillFirstBit(ft.m_new_td_bits) == TRACKDIR_BIT_NONE);
dbg_assert(KillFirstBit(ft.m_new_td_bits) == TRACKDIR_BIT_NONE);
tile = ft.m_new_tile;
cur_td = FindFirstTrackdir(ft.m_new_td_bits);
@ -3915,7 +3915,7 @@ public:
if (this->v->cur_real_order_index >= this->v->GetNumOrders()) this->v->cur_real_order_index = 0;
Order *order = this->v->GetOrder(this->v->cur_real_order_index);
assert(order != nullptr);
dbg_assert(order != nullptr);
switch (order->GetType()) {
case OT_GOTO_DEPOT:
@ -4228,7 +4228,7 @@ static Track ChooseTrainTrack(Train *v, TileIndex tile, DiagDirection enterdir,
bool do_track_reservation = _settings_game.pf.reserve_paths || (flags & CTTF_FORCE_RES);
Trackdir changed_signal = INVALID_TRACKDIR;
assert((tracks & ~TRACK_BIT_MASK) == 0);
dbg_assert((tracks & ~TRACK_BIT_MASK) == 0);
bool got_reservation = false;
if (p_got_reservation != nullptr) *p_got_reservation = got_reservation;
@ -4464,7 +4464,7 @@ static Track ChooseTrainTrack(Train *v, TileIndex tile, DiagDirection enterdir,
*/
bool TryPathReserve(Train *v, bool mark_as_stuck, bool first_tile_okay)
{
assert(v->IsFrontEngine());
dbg_assert(v->IsFrontEngine());
ClearLookAheadIfInvalid(v);
@ -4585,7 +4585,7 @@ static bool CheckReverseTrain(const Train *v)
return false;
}
assert(v->track != TRACK_BIT_NONE);
dbg_assert(v->track != TRACK_BIT_NONE);
switch (_settings_game.pf.pathfinder_for_trains) {
case VPF_NPF: return NPFTrainCheckReverse(v);
@ -4659,7 +4659,7 @@ int Train::UpdateSpeed(MaxSpeedInfo max_speed_info)
*/
static bool HandlePossibleBreakdowns(Train *v)
{
assert(v->IsFrontEngine());
dbg_assert(v->IsFrontEngine());
for (Train *u = v; u != nullptr; u = u->Next()) {
if (u->breakdown_ctr != 0 && (u->IsEngine() || u->IsMultiheaded())) {
if (u->breakdown_ctr <= 2) {
@ -4806,7 +4806,7 @@ void Train::ReserveTrackUnderConsist() const
/* reserve the first available track */
TrackBits bits = GetAcrossTunnelBridgeTrackBits(u->tile);
Track first_track = RemoveFirstTrack(&bits);
assert(IsValidTrack(first_track));
dbg_assert(IsValidTrack(first_track));
TryReserveRailTrack(u->tile, first_track);
} else {
TryReserveRailTrack(u->tile, DiagDirToDiagTrack(GetTunnelBridgeDirection(u->tile)));
@ -4943,7 +4943,7 @@ static bool CheckTrainCollision(Train *v)
/* can't collide in depot */
if (v->track == TRACK_BIT_DEPOT) return false;
assert(v->track & TRACK_BIT_WORMHOLE || TileVirtXY(v->x_pos, v->y_pos) == v->tile);
dbg_assert(v->track & TRACK_BIT_WORMHOLE || TileVirtXY(v->x_pos, v->y_pos) == v->tile);
TrainCollideChecker tcc;
tcc.v = v;
@ -5420,7 +5420,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
/* Determine what direction we're entering the new tile from */
enterdir = DiagdirBetweenTiles(gp.old_tile, gp.new_tile);
assert(IsValidDiagDirection(enterdir));
dbg_assert(IsValidDiagDirection(enterdir));
enter_new_tile:
@ -5454,7 +5454,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
/* Currently the locomotive is active. Determine which one of the
* available tracks to choose */
chosen_track = TrackToTrackBits(ChooseTrainTrack(v, gp.new_tile, enterdir, bits, CTTF_MARK_STUCK | CTTF_NON_LOOKAHEAD, nullptr));
assert_msg_tile(chosen_track & (bits | GetReservedTrackbits(gp.new_tile)), gp.new_tile, "0x%X, 0x%X, 0x%X", chosen_track, bits, GetReservedTrackbits(gp.new_tile));
dbg_assert_msg_tile(chosen_track & (bits | GetReservedTrackbits(gp.new_tile)), gp.new_tile, "0x%X, 0x%X, 0x%X", chosen_track, bits, GetReservedTrackbits(gp.new_tile));
if (v->force_proceed != TFP_NONE && IsPlainRailTile(gp.new_tile) && HasSignals(gp.new_tile)) {
/* For each signal we find decrease the counter by one.
@ -5543,7 +5543,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
if (prev->track & TRACK_BIT_WORMHOLE) {
/* Vehicles entering tunnels enter the wormhole earlier than for bridges.
* However, just choose the track into the wormhole. */
assert_tile(IsTunnel(prev->tile), prev->tile);
dbg_assert_tile(IsTunnel(prev->tile), prev->tile);
chosen_track = bits;
} else {
chosen_track = prev->track;
@ -5563,14 +5563,14 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
{TRACK_BIT_RIGHT, TRACK_BIT_NONE, TRACK_BIT_LOWER, TRACK_BIT_Y }
};
DiagDirection exitdir = DiagdirBetweenTiles(gp.new_tile, TileVirtXY(prev->x_pos, prev->y_pos));
assert(IsValidDiagDirection(exitdir));
dbg_assert(IsValidDiagDirection(exitdir));
chosen_track = _connecting_track[enterdir][exitdir];
}
chosen_track &= bits;
}
/* Make sure chosen track is a valid track */
assert(
dbg_assert(
chosen_track == TRACK_BIT_X || chosen_track == TRACK_BIT_Y ||
chosen_track == TRACK_BIT_UPPER || chosen_track == TRACK_BIT_LOWER ||
chosen_track == TRACK_BIT_LEFT || chosen_track == TRACK_BIT_RIGHT);
@ -5631,7 +5631,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
v->tile = gp.new_tile;
v->track = chosen_track;
assert(v->track);
dbg_assert(v->track);
if (GetTileRailTypeByTrackBit(gp.new_tile, chosen_track) != GetTileRailTypeByTrackBit(gp.old_tile, old_trackbits)) {
/* v->track and v->tile must both be valid and consistent before this is called */
@ -6108,7 +6108,7 @@ static void DeleteLastWagon(Train *v)
FindVehicleOnPos(tile, VEH_TRAIN, &remaining_trackbits, CollectTrackbitsFromCrashedVehiclesEnum);
/* It is important that these two are the first in the loop, as reservation cannot deal with every trackbit combination */
assert(TRACK_BEGIN == TRACK_X && TRACK_Y == TRACK_BEGIN + 1);
dbg_assert(TRACK_BEGIN == TRACK_X && TRACK_Y == TRACK_BEGIN + 1);
for (Track t : SetTrackBitIterator(remaining_trackbits)) TryReserveRailTrack(tile, t);
}
@ -6296,8 +6296,8 @@ static bool TrainCanLeaveTile(const Train *v)
*/
static TileIndex TrainApproachingCrossingTile(const Train *v)
{
assert(v->IsFrontEngine());
assert(!(v->vehstatus & VS_CRASHED));
dbg_assert(v->IsFrontEngine());
dbg_assert(!(v->vehstatus & VS_CRASHED));
if (!TrainCanLeaveTile(v)) return INVALID_TILE;

View File

@ -98,8 +98,8 @@ static bool CanPlantTreesOnTile(TileIndex tile, bool allow_desert)
*/
static void PlantTreesOnTile(TileIndex tile, TreeType treetype, uint count, uint growth)
{
assert(treetype != TREE_INVALID);
assert_tile(CanPlantTreesOnTile(tile, true), tile);
dbg_assert(treetype != TREE_INVALID);
dbg_assert_tile(CanPlantTreesOnTile(tile, true), tile);
TreeGround ground;
uint density = 3;
@ -457,7 +457,7 @@ void RemoveAllTrees()
*/
uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, uint count, bool set_zone)
{
assert(treetype < TREE_TOYLAND + TREE_COUNT_TOYLAND);
dbg_assert(treetype < TREE_TOYLAND + TREE_COUNT_TOYLAND);
const bool allow_desert = treetype == TREE_CACTUS;
uint planted = 0;
@ -725,7 +725,7 @@ static void DrawTile_Trees(TileInfo *ti, DrawTileProcParams params)
index += 164 - (TREE_SUB_ARCTIC << 2);
}
assert(index < lengthof(_tree_layout_sprite));
dbg_assert(index < lengthof(_tree_layout_sprite));
const PalSpriteID *s = _tree_layout_sprite[index];
const TreePos *d = _tree_layout_xy[GB(tmp, 2, 2)];

View File

@ -72,7 +72,7 @@ enum TreeGround {
*/
static inline TreeType GetTreeType(TileIndex t)
{
assert_tile(IsTileType(t, MP_TREES), t);
dbg_assert_tile(IsTileType(t, MP_TREES), t);
return (TreeType)_m[t].m3;
}
@ -87,7 +87,7 @@ static inline TreeType GetTreeType(TileIndex t)
*/
static inline TreeGround GetTreeGround(TileIndex t)
{
assert_tile(IsTileType(t, MP_TREES), t);
dbg_assert_tile(IsTileType(t, MP_TREES), t);
return (TreeGround)GB(_m[t].m2, 6, 3);
}
@ -112,7 +112,7 @@ static inline TreeGround GetTreeGround(TileIndex t)
*/
static inline uint GetTreeDensity(TileIndex t)
{
assert_tile(IsTileType(t, MP_TREES), t);
dbg_assert_tile(IsTileType(t, MP_TREES), t);
return GB(_m[t].m2, 4, 2);
}
@ -129,7 +129,7 @@ static inline uint GetTreeDensity(TileIndex t)
*/
static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
{
assert_tile(IsTileType(t, MP_TREES), t); // XXX incomplete
dbg_assert_tile(IsTileType(t, MP_TREES), t); // XXX incomplete
SB(_m[t].m2, 4, 2, d);
SB(_m[t].m2, 6, 3, g);
SetWaterClass(t, g == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID);
@ -148,7 +148,7 @@ static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
*/
static inline uint GetTreeCount(TileIndex t)
{
assert_tile(IsTileType(t, MP_TREES), t);
dbg_assert_tile(IsTileType(t, MP_TREES), t);
return GB(_m[t].m5, 6, 2) + 1;
}
@ -165,7 +165,7 @@ static inline uint GetTreeCount(TileIndex t)
*/
static inline void AddTreeCount(TileIndex t, int c)
{
assert_tile(IsTileType(t, MP_TREES), t); // XXX incomplete
dbg_assert_tile(IsTileType(t, MP_TREES), t); // XXX incomplete
_m[t].m5 += ((uint) c) << 6;
}
@ -180,7 +180,7 @@ static inline void AddTreeCount(TileIndex t, int c)
*/
static inline uint GetTreeGrowth(TileIndex t)
{
assert_tile(IsTileType(t, MP_TREES), t);
dbg_assert_tile(IsTileType(t, MP_TREES), t);
return GB(_m[t].m5, 0, 3);
}
@ -195,7 +195,7 @@ static inline uint GetTreeGrowth(TileIndex t)
*/
static inline void AddTreeGrowth(TileIndex t, int a)
{
assert_tile(IsTileType(t, MP_TREES), t); // XXX incomplete
dbg_assert_tile(IsTileType(t, MP_TREES), t); // XXX incomplete
_m[t].m5 += a;
}
@ -211,7 +211,7 @@ static inline void AddTreeGrowth(TileIndex t, int a)
*/
static inline void SetTreeGrowth(TileIndex t, uint g)
{
assert_tile(IsTileType(t, MP_TREES), t); // XXX incomplete
dbg_assert_tile(IsTileType(t, MP_TREES), t); // XXX incomplete
SB(_m[t].m5, 0, 3, g);
}
@ -223,7 +223,7 @@ static inline void SetTreeGrowth(TileIndex t, uint g)
*/
static inline void ClearOldTreeCounter(TileIndex t)
{
assert_tile(IsTileType(t, MP_TREES), t);
dbg_assert_tile(IsTileType(t, MP_TREES), t);
SB(_m[t].m2, 0, 4, 0);
}

View File

@ -24,7 +24,7 @@ static const TunnelID TUNNEL_ID_MAP_LOOKUP = 0xFFFF; ///< Sentinel ID value to s
*/
static inline bool IsTunnel(TileIndex t)
{
assert_tile(IsTileType(t, MP_TUNNELBRIDGE), t);
dbg_assert_tile(IsTileType(t, MP_TUNNELBRIDGE), t);
return !HasBit(_m[t].m5, 7);
}
@ -48,7 +48,7 @@ static inline TunnelID GetTunnelIndex(TileIndex t)
{
extern TunnelID GetTunnelIndexByLookup(TileIndex t);
assert_tile(IsTunnelTile(t), t);
dbg_assert_tile(IsTunnelTile(t), t);
TunnelID map_id = _m[t].m2;
return map_id == TUNNEL_ID_MAP_LOOKUP ? GetTunnelIndexByLookup(t) : map_id;
}
@ -71,7 +71,7 @@ static inline bool IsRailTunnelTile(TileIndex t)
*/
static inline bool HasTunnelReservation(TileIndex t)
{
assert_tile(IsRailTunnelTile(t), t);
dbg_assert_tile(IsRailTunnelTile(t), t);
return HasBit(_m[t].m5, 4);
}
@ -83,7 +83,7 @@ static inline bool HasTunnelReservation(TileIndex t)
*/
static inline void SetTunnelReservation(TileIndex t, bool b)
{
assert_tile(IsRailTunnelTile(t), t);
dbg_assert_tile(IsRailTunnelTile(t), t);
SB(_m[t].m5, 4, 1, b ? 1 : 0);
}
@ -107,7 +107,7 @@ bool IsTunnelInWay(TileIndex, int z, IsTunnelInWayFlags flags = ITIWF_NONE);
*/
static inline void SetTunnelIndex(TileIndex t, TunnelID id)
{
assert_tile(IsTunnelTile(t), t);
dbg_assert_tile(IsTunnelTile(t), t);
_m[t].m2 = (id >= TUNNEL_ID_MAP_LOOKUP) ? TUNNEL_ID_MAP_LOOKUP : id;
}

View File

@ -161,7 +161,7 @@ bool Vehicle::NeedsAutorenewing(const Company *c, bool use_renew_setting) const
* However this takes time and since the Company pointer is often present
* when this function is called then it's faster to pass the pointer as an
* argument rather than finding it again. */
assert(c == Company::Get(this->owner));
dbg_assert(c == Company::Get(this->owner));
if (use_renew_setting && !c->settings.engine_renew) return false;
if (this->age - this->max_age < (c->settings.engine_renew_months * 30)) return false;
@ -179,7 +179,7 @@ bool Vehicle::NeedsAutorenewing(const Company *c, bool use_renew_setting) const
*/
void VehicleServiceInDepot(Vehicle *v)
{
assert(v != nullptr);
dbg_assert(v != nullptr);
const Engine *e = Engine::Get(v->engine_type);
if (v->type == VEH_TRAIN) {
if (v->Next() != nullptr) VehicleServiceInDepot(v->Next());
@ -1104,7 +1104,7 @@ void Vehicle::PreDestructor()
HideFillingPercent(&this->fill_percent_te_id);
this->CancelReservation(INVALID_STATION, st);
delete this->cargo_payment;
assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
dbg_assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
}
if (this->IsEngineCountable()) {
@ -1723,7 +1723,7 @@ void CallVehicleTicks()
default:
NOT_REACHED();
}
assert(type != INVALID_EXPENSES);
dbg_assert(type != INVALID_EXPENSES);
Money vehicle_new_value = v->GetEngine()->GetCost();
@ -2475,7 +2475,7 @@ uint8 CalcPercentVehicleFilledOfCargo(const Vehicle *front, CargoID cargo)
void VehicleEnterDepot(Vehicle *v)
{
/* Always work with the front of the vehicle */
assert(v == v->First());
dbg_assert(v == v->First());
switch (v->type) {
case VEH_TRAIN: {
@ -3337,7 +3337,7 @@ void Vehicle::LeaveStation()
assert(this->current_order.IsAnyLoadingType());
delete this->cargo_payment;
assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
dbg_assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
ClrBit(this->vehicle_flags, VF_COND_ORDER_WAIT);
@ -3467,7 +3467,7 @@ void Vehicle::LeaveStation()
void Vehicle::AdvanceLoadingInStation()
{
assert(this->current_order.IsType(OT_LOADING));
assert(this->type == VEH_TRAIN);
dbg_assert(this->type == VEH_TRAIN);
ClrBit(Train::From(this)->flags, VRF_ADVANCE_IN_PLATFORM);
@ -3901,7 +3901,7 @@ int ReversingDistanceTargetSpeed(const Train *v);
*/
void Vehicle::ShowVisualEffect(uint max_speed) const
{
assert(this->IsPrimaryVehicle());
dbg_assert(this->IsPrimaryVehicle());
bool sound = false;
/* Do not show any smoke when:
@ -4057,7 +4057,7 @@ void Vehicle::ShowVisualEffect(uint max_speed) const
*/
void Vehicle::SetNext(Vehicle *next)
{
assert(this != next);
dbg_assert(this != next);
if (this->next != nullptr) {
/* We had an old next vehicle. Update the first and previous pointers */
@ -4086,11 +4086,11 @@ void Vehicle::SetNext(Vehicle *next)
*/
void Vehicle::AddToShared(Vehicle *shared_chain)
{
assert(this->previous_shared == nullptr && this->next_shared == nullptr);
dbg_assert(this->previous_shared == nullptr && this->next_shared == nullptr);
if (shared_chain->orders == nullptr) {
assert(shared_chain->previous_shared == nullptr);
assert(shared_chain->next_shared == nullptr);
dbg_assert(shared_chain->previous_shared == nullptr);
dbg_assert(shared_chain->next_shared == nullptr);
this->orders = shared_chain->orders = new OrderList(nullptr, shared_chain);
}
@ -4332,7 +4332,7 @@ void VehiclesYearlyLoop()
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
{
const Engine *e = Engine::GetIfValid(engine_type);
assert(e != nullptr);
dbg_assert(e != nullptr);
switch (e->type) {
case VEH_TRAIN:
@ -4425,7 +4425,7 @@ StringID GetVehicleCannotUseStationReason(const Vehicle *v, const Station *st)
*/
GroundVehicleCache *Vehicle::GetGroundVehicleCache()
{
assert(this->IsGroundVehicle());
dbg_assert(this->IsGroundVehicle());
if (this->type == VEH_TRAIN) {
return &Train::From(this)->gcache;
} else {
@ -4440,7 +4440,7 @@ GroundVehicleCache *Vehicle::GetGroundVehicleCache()
*/
const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const
{
assert(this->IsGroundVehicle());
dbg_assert(this->IsGroundVehicle());
if (this->type == VEH_TRAIN) {
return &Train::From(this)->gcache;
} else {
@ -4455,7 +4455,7 @@ const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const
*/
uint16 &Vehicle::GetGroundVehicleFlags()
{
assert(this->IsGroundVehicle());
dbg_assert(this->IsGroundVehicle());
if (this->type == VEH_TRAIN) {
return Train::From(this)->gv_flags;
} else {
@ -4470,7 +4470,7 @@ uint16 &Vehicle::GetGroundVehicleFlags()
*/
const uint16 &Vehicle::GetGroundVehicleFlags() const
{
assert(this->IsGroundVehicle());
dbg_assert(this->IsGroundVehicle());
if (this->type == VEH_TRAIN) {
return Train::From(this)->gv_flags;
} else {

View File

@ -38,7 +38,7 @@ struct GUIVehicleGroup {
const Vehicle *GetSingleVehicle() const
{
assert(this->NumVehicles() == 1);
dbg_assert(this->NumVehicles() == 1);
return this->vehicles_begin[0];
}

View File

@ -855,7 +855,7 @@ void HandleZoomMessage(Window *w, const Viewport *vp, byte widget_zoom_in, byte
*/
static void AddTileSpriteToDraw(SpriteID image, PaletteID pal, int32 x, int32 y, int z, const SubSprite *sub = nullptr, int extra_offs_x = 0, int extra_offs_y = 0)
{
assert((image & SPRITE_MASK) < MAX_SPRITES);
dbg_assert((image & SPRITE_MASK) < MAX_SPRITES);
TileSpriteToDraw &ts = _vd.tile_sprites_to_draw.emplace_back();
ts.image = image;
@ -880,8 +880,8 @@ static void AddTileSpriteToDraw(SpriteID image, PaletteID pal, int32 x, int32 y,
*/
static void AddChildSpriteToFoundation(SpriteID image, PaletteID pal, const SubSprite *sub, FoundationPart foundation_part, int extra_offs_x, int extra_offs_y)
{
assert(IsInsideMM(foundation_part, 0, FOUNDATION_PART_END));
assert(_vd.foundation[foundation_part] != -1);
dbg_assert(IsInsideMM(foundation_part, 0, FOUNDATION_PART_END));
dbg_assert(_vd.foundation[foundation_part] != -1);
Point offs = _vd.foundation_offset[foundation_part];
/* Change the active ChildSprite list to the one of the foundation */
@ -1025,7 +1025,7 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w,
{
int32 left, right, top, bottom;
assert((image & SPRITE_MASK) < MAX_SPRITES);
dbg_assert((image & SPRITE_MASK) < MAX_SPRITES);
/* make the sprites transparent with the right palette */
if (transparent) {
@ -1136,7 +1136,7 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w,
*/
void StartSpriteCombine()
{
assert(_vd.combine_sprites == SPRITE_COMBINE_NONE);
dbg_assert(_vd.combine_sprites == SPRITE_COMBINE_NONE);
_vd.combine_sprites = SPRITE_COMBINE_PENDING;
}
@ -1146,7 +1146,7 @@ void StartSpriteCombine()
*/
void EndSpriteCombine()
{
assert(_vd.combine_sprites != SPRITE_COMBINE_NONE);
dbg_assert(_vd.combine_sprites != SPRITE_COMBINE_NONE);
if (_vd.combine_sprites == SPRITE_COMBINE_ACTIVE) {
ParentSpriteToDraw &ps = _vd.parent_sprites_to_draw[_vd.combine_psd_index];
ps.left = _vd.combine_left;
@ -1206,7 +1206,7 @@ static bool IsInsideSelectedRectangle(int x, int y)
*/
void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool transparent, const SubSprite *sub, bool scale, bool relative)
{
assert((image & SPRITE_MASK) < MAX_SPRITES);
dbg_assert((image & SPRITE_MASK) < MAX_SPRITES);
/* If the ParentSprite was clipped by the viewport bounds, do not draw the ChildSprites either */
if (_vd.last_child == nullptr) return;
@ -1238,7 +1238,7 @@ void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool tran
static void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2, Colours colour, uint16 width)
{
assert(width != 0);
dbg_assert(width != 0);
StringSpriteToDraw &ss = _vd.string_sprites_to_draw.emplace_back();
ss.string = string;
ss.x = x;
@ -1576,8 +1576,8 @@ static int GetViewportY(Point tile)
*/
static void ViewportAddLandscape()
{
assert(_vd.dpi.top <= _vd.dpi.top + _vd.dpi.height);
assert(_vd.dpi.left <= _vd.dpi.left + _vd.dpi.width);
dbg_assert(_vd.dpi.top <= _vd.dpi.top + _vd.dpi.height);
dbg_assert(_vd.dpi.left <= _vd.dpi.left + _vd.dpi.width);
Point upper_left = InverseRemapCoords(_vd.dpi.left, _vd.dpi.top);
Point upper_right = InverseRemapCoords(_vd.dpi.left + _vd.dpi.width, _vd.dpi.top);
@ -1615,8 +1615,8 @@ static void ViewportAddLandscape()
Point tilecoord;
tilecoord.x = (row - column) / 2;
tilecoord.y = (row + column) / 2;
assert(column == tilecoord.y - tilecoord.x);
assert(row == tilecoord.y + tilecoord.x);
dbg_assert(column == tilecoord.y - tilecoord.x);
dbg_assert(row == tilecoord.y + tilecoord.x);
TileType tile_type;
TileInfo tile_info;
@ -3325,7 +3325,7 @@ static void ViewportMapDrawBridgeTunnel(Viewport * const vp, const TunnelBridgeT
template <bool is_32bpp, bool show_slope>
void ViewportMapDraw(Viewport * const vp)
{
assert(vp != nullptr);
dbg_assert(vp != nullptr);
Blitter * const blitter = BlitterFactory::GetCurrentBlitter();
SmallMapWindow::RebuildColourIndexIfNecessary();
@ -3933,7 +3933,7 @@ static void MarkRouteStepDirty(RouteStepsMap::const_iterator cit)
static void MarkRouteStepDirty(const TileIndex tile, uint order_nr)
{
assert(tile != INVALID_TILE);
dbg_assert(tile != INVALID_TILE);
const Point pt = RemapCoords2(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2);
const int char_height = GetCharacterHeight(FS_SMALL) + 1;
const int max_width = _vp_route_step_base_width + _vp_route_step_string_width[3];
@ -4088,8 +4088,8 @@ void MarkViewportLineDirty(Viewport * const vp, const Point from_pt, const Point
void MarkTileLineDirty(const TileIndex from_tile, const TileIndex to_tile, ViewportMarkDirtyFlags flags)
{
assert(from_tile != INVALID_TILE);
assert(to_tile != INVALID_TILE);
dbg_assert(from_tile != INVALID_TILE);
dbg_assert(to_tile != INVALID_TILE);
const Point from_pt = RemapCoords2(TileX(from_tile) * TILE_SIZE + TILE_SIZE / 2, TileY(from_tile) * TILE_SIZE + TILE_SIZE / 2);
const Point to_pt = RemapCoords2(TileX(to_tile) * TILE_SIZE + TILE_SIZE / 2, TileY(to_tile) * TILE_SIZE + TILE_SIZE / 2);
@ -4192,8 +4192,8 @@ static void SetSelectionTilesDirty()
x_size -= TILE_SIZE;
y_size -= TILE_SIZE;
assert(x_size >= 0);
assert(y_size >= 0);
dbg_assert(x_size >= 0);
dbg_assert(y_size >= 0);
int x_end = Clamp(x_start + x_size, 0, MapSizeX() * TILE_SIZE - TILE_SIZE);
int y_end = Clamp(y_start + y_size, 0, MapSizeY() * TILE_SIZE - TILE_SIZE);
@ -4202,7 +4202,7 @@ static void SetSelectionTilesDirty()
y_start = Clamp(y_start, 0, MapSizeY() * TILE_SIZE - TILE_SIZE);
/* make sure everything is multiple of TILE_SIZE */
assert((x_end | y_end | x_start | y_start) % TILE_SIZE == 0);
dbg_assert((x_end | y_end | x_start | y_start) % TILE_SIZE == 0);
/* How it works:
* Suppose we have to mark dirty rectangle of 3x4 tiles:
@ -5173,7 +5173,7 @@ static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_t
/* Use lookup table for start-tile based on HighLightStyle direction */
byte style_t = style * 2;
assert(style_t < lengthof(heightdiff_line_by_dir) - 13);
dbg_assert(style_t < lengthof(heightdiff_line_by_dir) - 13);
h0 = TileHeight(TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_line_by_dir[style_t])));
uint ht = TileHeight(TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_line_by_dir[style_t + 1])));
h0 = std::max(h0, ht);
@ -5181,7 +5181,7 @@ static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_t
/* Use lookup table for end-tile based on HighLightStyle direction
* flip around side (lower/upper, left/right) based on distance */
if (distance == 0) style_t = flip_style_direction[style] * 2;
assert(style_t < lengthof(heightdiff_line_by_dir) - 13);
dbg_assert(style_t < lengthof(heightdiff_line_by_dir) - 13);
h1 = TileHeight(TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_line_by_dir[12 + style_t])));
ht = TileHeight(TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_line_by_dir[12 + style_t + 1])));
h1 = std::max(h1, ht);
@ -6061,7 +6061,7 @@ void InitializeSpriteSorter()
break;
}
}
assert(_vp_sprite_sorter != nullptr);
dbg_assert(_vp_sprite_sorter != nullptr);
}
/**

View File

@ -76,7 +76,7 @@ bool IsPossibleDockingTile(TileIndex t);
*/
static inline WaterTileType GetWaterTileType(TileIndex t)
{
assert_tile(IsTileType(t, MP_WATER), t);
dbg_assert_tile(IsTileType(t, MP_WATER), t);
switch (GB(_m[t].m5, WBL_TYPE_BEGIN, WBL_TYPE_COUNT)) {
case WBL_TYPE_NORMAL: return HasBit(_m[t].m5, WBL_COAST_FLAG) ? WATER_TILE_COAST : WATER_TILE_CLEAR;
@ -105,7 +105,7 @@ static inline bool HasTileWaterClass(TileIndex t)
*/
static inline WaterClass GetWaterClass(TileIndex t)
{
assert_tile(HasTileWaterClass(t), t);
dbg_assert_tile(HasTileWaterClass(t), t);
return (WaterClass)GB(_m[t].m1, 5, 2);
}
@ -117,7 +117,7 @@ static inline WaterClass GetWaterClass(TileIndex t)
*/
static inline void SetWaterClass(TileIndex t, WaterClass wc)
{
assert_tile(HasTileWaterClass(t), t);
dbg_assert_tile(HasTileWaterClass(t), t);
SB(_m[t].m1, 5, 2, wc);
}
@ -236,7 +236,7 @@ static inline bool IsShipDepotTile(TileIndex t)
*/
static inline Axis GetShipDepotAxis(TileIndex t)
{
assert_tile(IsShipDepotTile(t), t);
dbg_assert_tile(IsShipDepotTile(t), t);
return (Axis)GB(_m[t].m5, WBL_DEPOT_AXIS, 1);
}
@ -248,7 +248,7 @@ static inline Axis GetShipDepotAxis(TileIndex t)
*/
static inline DepotPart GetShipDepotPart(TileIndex t)
{
assert_tile(IsShipDepotTile(t), t);
dbg_assert_tile(IsShipDepotTile(t), t);
return (DepotPart)GB(_m[t].m5, WBL_DEPOT_PART, 1);
}
@ -282,7 +282,7 @@ static inline TileIndex GetOtherShipDepotTile(TileIndex t)
*/
static inline TileIndex GetShipDepotNorthTile(TileIndex t)
{
assert_tile(IsShipDepot(t), t);
dbg_assert_tile(IsShipDepot(t), t);
TileIndex tile2 = GetOtherShipDepotTile(t);
return t < tile2 ? t : tile2;
@ -307,7 +307,7 @@ static inline bool IsLock(TileIndex t)
*/
static inline DiagDirection GetLockDirection(TileIndex t)
{
assert_tile(IsLock(t), t);
dbg_assert_tile(IsLock(t), t);
return (DiagDirection)GB(_m[t].m5, WBL_LOCK_ORIENT_BEGIN, WBL_LOCK_ORIENT_COUNT);
}
@ -319,7 +319,7 @@ static inline DiagDirection GetLockDirection(TileIndex t)
*/
static inline byte GetLockPart(TileIndex t)
{
assert_tile(IsLock(t), t);
dbg_assert_tile(IsLock(t), t);
return GB(_m[t].m5, WBL_LOCK_PART_BEGIN, WBL_LOCK_PART_COUNT);
}
@ -331,7 +331,7 @@ static inline byte GetLockPart(TileIndex t)
*/
static inline byte GetWaterTileRandomBits(TileIndex t)
{
assert_tile(IsTileType(t, MP_WATER), t);
dbg_assert_tile(IsTileType(t, MP_WATER), t);
return _m[t].m4;
}
@ -354,7 +354,7 @@ static inline bool HasTileWaterGround(TileIndex t)
*/
static inline void SetDockingTile(TileIndex t, bool b)
{
assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE));
dbg_assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE));
SB(_m[t].m1, 7, 1, b ? 1 : 0);
}
@ -434,7 +434,7 @@ static inline void MakeRiver(TileIndex t, uint8 random_bits)
*/
static inline void MakeCanal(TileIndex t, Owner o, uint8 random_bits)
{
assert(o != OWNER_WATER);
dbg_assert(o != OWNER_WATER);
MakeWater(t, o, WATER_CLASS_CANAL, random_bits);
}
@ -512,7 +512,7 @@ static inline void MakeLock(TileIndex t, Owner o, DiagDirection d, WaterClass wc
*/
static inline void SetNonFloodingWaterTile(TileIndex t, bool b)
{
assert(IsTileType(t, MP_WATER));
dbg_assert(IsTileType(t, MP_WATER));
SB(_m[t].m3, 0, 1, b ? 1 : 0);
}
/**

View File

@ -240,7 +240,7 @@ void Window::DisableAllWidgetHighlight()
*/
void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour)
{
assert(widget_index < this->nested_array_size);
dbg_assert(widget_index < this->nested_array_size);
NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget_index);
if (nwid == nullptr) return;
@ -273,7 +273,7 @@ void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour
*/
bool Window::IsWidgetHighlighted(byte widget_index) const
{
assert(widget_index < this->nested_array_size);
dbg_assert(widget_index < this->nested_array_size);
const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget_index);
if (nwid == nullptr) return false;
@ -521,7 +521,7 @@ bool Window::SetFocusedWidget(int widget_index)
/* Do nothing if widget_index is already focused, or if it wasn't a valid widget. */
if ((uint)widget_index >= this->nested_array_size) return false;
assert(this->nested_array[widget_index] != nullptr); // Setting focus to a non-existing widget is a bad idea.
dbg_assert(this->nested_array[widget_index] != nullptr); // Setting focus to a non-existing widget is a bad idea.
if (this->nested_focus != nullptr) {
if (this->GetWidget<NWidgetCore>(widget_index) == this->nested_focus) return false;
@ -1403,7 +1403,7 @@ static uint GetWindowZPriority(WindowClass wc)
*/
static void AddWindowToZOrdering(Window *w)
{
assert(w->z_front == nullptr && w->z_back == nullptr);
dbg_assert(w->z_front == nullptr && w->z_back == nullptr);
if (_z_front_window == nullptr) {
/* It's the only window. */
@ -1417,7 +1417,7 @@ static void AddWindowToZOrdering(Window *w)
while (v != nullptr && (v->window_class == WC_INVALID || GetWindowZPriority(v->window_class) > GetWindowZPriority(w->window_class))) {
if (v->window_class != WC_INVALID) {
/* Sanity check z-ordering, while we're at it. */
assert(last_z_priority >= GetWindowZPriority(v->window_class));
dbg_assert(last_z_priority >= GetWindowZPriority(v->window_class));
last_z_priority = GetWindowZPriority(v->window_class);
}
@ -1454,14 +1454,14 @@ static void AddWindowToZOrdering(Window *w)
static void RemoveWindowFromZOrdering(WindowBase *w)
{
if (w->z_front == nullptr) {
assert(_z_front_window == w);
dbg_assert(_z_front_window == w);
_z_front_window = w->z_back;
} else {
w->z_front->z_back = w->z_back;
}
if (w->z_back == nullptr) {
assert(_z_back_window == w);
dbg_assert(_z_back_window == w);
_z_back_window = w->z_front;
} else {
w->z_back->z_front = w->z_front;
@ -1764,7 +1764,7 @@ restart:
Point GetToolbarAlignedWindowPosition(int window_width)
{
const Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0);
assert(w != nullptr);
dbg_assert(w != nullptr);
Point pt = { _current_text_dir == TD_RTL ? w->left : (w->left + w->width) - window_width, w->top + w->height };
return pt;
}