Change various asserts to not be included in release builds
This commit is contained in:
104
src/3rdparty/cpp-btree/btree.h
vendored
104
src/3rdparty/cpp-btree/btree.h
vendored
@@ -527,7 +527,7 @@ class btree_node {
|
|||||||
// be a leaf.
|
// be a leaf.
|
||||||
bool is_root() const { return parent()->leaf(); }
|
bool is_root() const { return parent()->leaf(); }
|
||||||
void make_root() {
|
void make_root() {
|
||||||
assert(parent()->is_root());
|
dbg_assert(parent()->is_root());
|
||||||
fields_.parent = fields_.parent->parent();
|
fields_.parent = fields_.parent->parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1266,7 +1266,7 @@ class btree : public Params::key_compare {
|
|||||||
}
|
}
|
||||||
void delete_internal_node(node_type *node) {
|
void delete_internal_node(node_type *node) {
|
||||||
node->destroy();
|
node->destroy();
|
||||||
assert(node != root());
|
dbg_assert(node != root());
|
||||||
mutable_internal_allocator()->deallocate(
|
mutable_internal_allocator()->deallocate(
|
||||||
reinterpret_cast<char*>(node), sizeof(internal_fields));
|
reinterpret_cast<char*>(node), sizeof(internal_fields));
|
||||||
}
|
}
|
||||||
@@ -1422,7 +1422,7 @@ class btree : public Params::key_compare {
|
|||||||
// btree_node methods
|
// btree_node methods
|
||||||
template <typename P>
|
template <typename P>
|
||||||
inline void btree_node<P>::insert_value(int i, const value_type &x) {
|
inline void btree_node<P>::insert_value(int i, const value_type &x) {
|
||||||
assert(i <= count());
|
dbg_assert(i <= count());
|
||||||
value_init(count(), x);
|
value_init(count(), x);
|
||||||
for (int j = count(); j > i; --j) {
|
for (int j = count(); j > i; --j) {
|
||||||
value_swap(j, this, j - 1);
|
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>
|
template <typename P>
|
||||||
inline void btree_node<P>::remove_value(int i) {
|
inline void btree_node<P>::remove_value(int i) {
|
||||||
if (!leaf()) {
|
if (!leaf()) {
|
||||||
assert(child(i + 1)->count() == 0);
|
dbg_assert(child(i + 1)->count() == 0);
|
||||||
for (int j = i + 1; j < count(); ++j) {
|
for (int j = i + 1; j < count(); ++j) {
|
||||||
*mutable_child(j) = child(j + 1);
|
*mutable_child(j) = child(j + 1);
|
||||||
child(j)->set_position(j);
|
child(j)->set_position(j);
|
||||||
@@ -1459,11 +1459,11 @@ inline void btree_node<P>::remove_value(int i) {
|
|||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
void btree_node<P>::rebalance_right_to_left(btree_node *src, int to_move) {
|
void btree_node<P>::rebalance_right_to_left(btree_node *src, int to_move) {
|
||||||
assert(parent() == src->parent());
|
dbg_assert(parent() == src->parent());
|
||||||
assert(position() + 1 == src->position());
|
dbg_assert(position() + 1 == src->position());
|
||||||
assert(src->count() >= count());
|
dbg_assert(src->count() >= count());
|
||||||
assert(to_move >= 1);
|
dbg_assert(to_move >= 1);
|
||||||
assert(to_move <= src->count());
|
dbg_assert(to_move <= src->count());
|
||||||
|
|
||||||
// Make room in the left node for the new values.
|
// Make room in the left node for the new values.
|
||||||
for (int i = 0; i < to_move; ++i) {
|
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));
|
set_child(1 + count() + i, src->child(i));
|
||||||
}
|
}
|
||||||
for (int i = 0; i <= src->count() - to_move; ++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->set_child(i, src->child(i + to_move));
|
||||||
*src->mutable_child(i + to_move) = NULL;
|
*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>
|
template <typename P>
|
||||||
void btree_node<P>::rebalance_left_to_right(btree_node *dest, int to_move) {
|
void btree_node<P>::rebalance_left_to_right(btree_node *dest, int to_move) {
|
||||||
assert(parent() == dest->parent());
|
dbg_assert(parent() == dest->parent());
|
||||||
assert(position() + 1 == dest->position());
|
dbg_assert(position() + 1 == dest->position());
|
||||||
assert(count() >= dest->count());
|
dbg_assert(count() >= dest->count());
|
||||||
assert(to_move >= 1);
|
dbg_assert(to_move >= 1);
|
||||||
assert(to_move <= count());
|
dbg_assert(to_move <= count());
|
||||||
|
|
||||||
// Make room in the right node for the new values.
|
// Make room in the right node for the new values.
|
||||||
for (int i = 0; i < to_move; ++i) {
|
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>
|
template <typename P>
|
||||||
void btree_node<P>::split(btree_node *dest, int insert_position) {
|
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
|
// 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
|
// 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);
|
dest->set_count(count() / 2);
|
||||||
}
|
}
|
||||||
set_count(count() - dest->count());
|
set_count(count() - dest->count());
|
||||||
assert(count() >= 1);
|
dbg_assert(count() >= 1);
|
||||||
|
|
||||||
// Move values from the left sibling to the right sibling.
|
// Move values from the left sibling to the right sibling.
|
||||||
for (int i = 0; i < dest->count(); ++i) {
|
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()) {
|
if (!leaf()) {
|
||||||
for (int i = 0; i <= dest->count(); ++i) {
|
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));
|
dest->set_child(i, child(count() + i + 1));
|
||||||
*mutable_child(count() + i + 1) = NULL;
|
*mutable_child(count() + i + 1) = NULL;
|
||||||
}
|
}
|
||||||
@@ -1592,8 +1592,8 @@ void btree_node<P>::split(btree_node *dest, int insert_position) {
|
|||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
void btree_node<P>::merge(btree_node *src) {
|
void btree_node<P>::merge(btree_node *src) {
|
||||||
assert(parent() == src->parent());
|
dbg_assert(parent() == src->parent());
|
||||||
assert(position() + 1 == src->position());
|
dbg_assert(position() + 1 == src->position());
|
||||||
|
|
||||||
// Move the delimiting value to the left node.
|
// Move the delimiting value to the left node.
|
||||||
value_init(count());
|
value_init(count());
|
||||||
@@ -1624,7 +1624,7 @@ void btree_node<P>::merge(btree_node *src) {
|
|||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
void btree_node<P>::swap(btree_node *x) {
|
void btree_node<P>::swap(btree_node *x) {
|
||||||
assert(leaf() == x->leaf());
|
dbg_assert(leaf() == x->leaf());
|
||||||
|
|
||||||
// Swap the values.
|
// Swap the values.
|
||||||
for (int i = count(); i < x->count(); ++i) {
|
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>
|
template <typename N, typename R, typename P>
|
||||||
void btree_iterator<N, R, P>::increment_slow() {
|
void btree_iterator<N, R, P>::increment_slow() {
|
||||||
if (node->leaf()) {
|
if (node->leaf()) {
|
||||||
assert(position >= node->count());
|
dbg_assert(position >= node->count());
|
||||||
self_type save(*this);
|
self_type save(*this);
|
||||||
while (position == node->count() && !node->is_root()) {
|
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();
|
position = node->position();
|
||||||
node = node->parent();
|
node = node->parent();
|
||||||
}
|
}
|
||||||
@@ -1677,7 +1677,7 @@ void btree_iterator<N, R, P>::increment_slow() {
|
|||||||
*this = save;
|
*this = save;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(position < node->count());
|
dbg_assert(position < node->count());
|
||||||
node = node->child(position + 1);
|
node = node->child(position + 1);
|
||||||
while (!node->leaf()) {
|
while (!node->leaf()) {
|
||||||
node = node->child(0);
|
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>
|
template <typename N, typename R, typename P>
|
||||||
void btree_iterator<N, R, P>::decrement_slow() {
|
void btree_iterator<N, R, P>::decrement_slow() {
|
||||||
if (node->leaf()) {
|
if (node->leaf()) {
|
||||||
assert(position <= -1);
|
dbg_assert(position <= -1);
|
||||||
self_type save(*this);
|
self_type save(*this);
|
||||||
while (position < 0 && !node->is_root()) {
|
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;
|
position = node->position() - 1;
|
||||||
node = node->parent();
|
node = node->parent();
|
||||||
}
|
}
|
||||||
@@ -1717,7 +1717,7 @@ void btree_iterator<N, R, P>::decrement_slow() {
|
|||||||
*this = save;
|
*this = save;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(position >= 0);
|
dbg_assert(position >= 0);
|
||||||
node = node->child(position);
|
node = node->child(position);
|
||||||
while (!node->leaf()) {
|
while (!node->leaf()) {
|
||||||
node = node->child(node->count());
|
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
|
// 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.
|
// value of our left child. This is easy, we just decrement iter.
|
||||||
iterator tmp_iter(iter--);
|
iterator tmp_iter(iter--);
|
||||||
assert(iter.node->leaf());
|
dbg_assert(iter.node->leaf());
|
||||||
assert(!compare_keys(tmp_iter.key(), iter.key()));
|
dbg_assert(!compare_keys(tmp_iter.key(), iter.key()));
|
||||||
iter.node->value_swap(iter.position, tmp_iter.node, tmp_iter.position);
|
iter.node->value_swap(iter.position, tmp_iter.node, tmp_iter.position);
|
||||||
internal_delete = true;
|
internal_delete = true;
|
||||||
--*mutable_size();
|
--*mutable_size();
|
||||||
@@ -1975,15 +1975,15 @@ void btree<P>::swap(self_type &x) {
|
|||||||
template <typename P>
|
template <typename P>
|
||||||
void btree<P>::verify() const {
|
void btree<P>::verify() const {
|
||||||
if (root() != NULL) {
|
if (root() != NULL) {
|
||||||
assert(size() == internal_verify(root(), NULL, NULL));
|
dbg_assert(size() == internal_verify(root(), NULL, NULL));
|
||||||
assert(leftmost() == (++const_iterator(root(), -1)).node);
|
dbg_assert(leftmost() == (++const_iterator(root(), -1)).node);
|
||||||
assert(rightmost() == (--const_iterator(root(), root()->count())).node);
|
dbg_assert(rightmost() == (--const_iterator(root(), root()->count())).node);
|
||||||
assert(leftmost()->leaf());
|
dbg_assert(leftmost()->leaf());
|
||||||
assert(rightmost()->leaf());
|
dbg_assert(rightmost()->leaf());
|
||||||
} else {
|
} else {
|
||||||
assert(size() == 0);
|
dbg_assert(size() == 0);
|
||||||
assert(leftmost() == NULL);
|
dbg_assert(leftmost() == NULL);
|
||||||
assert(rightmost() == NULL);
|
dbg_assert(rightmost() == NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1991,7 +1991,7 @@ template <typename P>
|
|||||||
void btree<P>::rebalance_or_split(iterator *iter) {
|
void btree<P>::rebalance_or_split(iterator *iter) {
|
||||||
node_type *&node = iter->node;
|
node_type *&node = iter->node;
|
||||||
int &insert_position = iter->position;
|
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.
|
// First try to make room on the node by rebalancing.
|
||||||
node_type *parent = node->parent();
|
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->count() + to_move) < left->max_count())) {
|
||||||
left->rebalance_right_to_left(node, to_move);
|
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;
|
insert_position = insert_position - to_move;
|
||||||
if (insert_position < 0) {
|
if (insert_position < 0) {
|
||||||
insert_position = insert_position + left->count() + 1;
|
insert_position = insert_position + left->count() + 1;
|
||||||
node = left;
|
node = left;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(node->count() < node->max_count());
|
dbg_assert(node->count() < node->max_count());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2044,7 +2044,7 @@ void btree<P>::rebalance_or_split(iterator *iter) {
|
|||||||
node = right;
|
node = right;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(node->count() < node->max_count());
|
dbg_assert(node->count() < node->max_count());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2064,7 +2064,7 @@ void btree<P>::rebalance_or_split(iterator *iter) {
|
|||||||
parent = new_internal_root_node();
|
parent = new_internal_root_node();
|
||||||
parent->set_child(0, root());
|
parent->set_child(0, root());
|
||||||
*mutable_root() = parent;
|
*mutable_root() = parent;
|
||||||
assert(*mutable_rightmost() == parent->child(0));
|
dbg_assert(*mutable_rightmost() == parent->child(0));
|
||||||
} else {
|
} else {
|
||||||
// The root node is an internal node. We do not want to create a new root
|
// 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
|
// 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.
|
// Deleted the last item on the root node, shrink the height of the tree.
|
||||||
if (root()->leaf()) {
|
if (root()->leaf()) {
|
||||||
assert(size() == 0);
|
dbg_assert(size() == 0);
|
||||||
delete_leaf_node(root());
|
delete_leaf_node(root());
|
||||||
*mutable_root() = NULL;
|
*mutable_root() = NULL;
|
||||||
} else {
|
} else {
|
||||||
@@ -2214,7 +2214,7 @@ btree<P>::internal_insert(iterator iter, const value_type &v) {
|
|||||||
if (iter.node->max_count() < kNodeValues) {
|
if (iter.node->max_count() < kNodeValues) {
|
||||||
// Insertion into the root where the root is smaller that the full node
|
// Insertion into the root where the root is smaller that the full node
|
||||||
// size. Simply grow the size of the root 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(
|
iter.node = new_leaf_root_node(
|
||||||
std::min<int>(kNodeValues, 2 * iter.node->max_count()));
|
std::min<int>(kNodeValues, 2 * iter.node->max_count()));
|
||||||
iter.node->swap(root());
|
iter.node->swap(root());
|
||||||
@@ -2369,23 +2369,23 @@ void btree<P>::internal_dump(
|
|||||||
template <typename P>
|
template <typename P>
|
||||||
int btree<P>::internal_verify(
|
int btree<P>::internal_verify(
|
||||||
const node_type *node, const key_type *lo, const key_type *hi) const {
|
const node_type *node, const key_type *lo, const key_type *hi) const {
|
||||||
assert(node->count() > 0);
|
dbg_assert(node->count() > 0);
|
||||||
assert(node->count() <= node->max_count());
|
dbg_assert(node->count() <= node->max_count());
|
||||||
if (lo) {
|
if (lo) {
|
||||||
assert(!compare_keys(node->key(0), *lo));
|
dbg_assert(!compare_keys(node->key(0), *lo));
|
||||||
}
|
}
|
||||||
if (hi) {
|
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) {
|
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();
|
int count = node->count();
|
||||||
if (!node->leaf()) {
|
if (!node->leaf()) {
|
||||||
for (int i = 0; i <= node->count(); ++i) {
|
for (int i = 0; i <= node->count(); ++i) {
|
||||||
assert(node->child(i) != NULL);
|
dbg_assert(node->child(i) != NULL);
|
||||||
assert(node->child(i)->parent() == node);
|
dbg_assert(node->child(i)->parent() == node);
|
||||||
assert(node->child(i)->position() == i);
|
dbg_assert(node->child(i)->position() == i);
|
||||||
count += internal_verify(
|
count += internal_verify(
|
||||||
node->child(i),
|
node->child(i),
|
||||||
(i == 0) ? lo : &node->key(i - 1),
|
(i == 0) ? lo : &node->key(i - 1),
|
||||||
|
4
src/3rdparty/cpp-btree/safe_btree.h
vendored
4
src/3rdparty/cpp-btree/safe_btree.h
vendored
@@ -122,13 +122,13 @@ class safe_btree_iterator {
|
|||||||
// This reference value is potentially invalidated by any non-const
|
// This reference value is potentially invalidated by any non-const
|
||||||
// method on the tree; it is NOT safe.
|
// method on the tree; it is NOT safe.
|
||||||
reference operator*() const {
|
reference operator*() const {
|
||||||
assert(generation_ > 0);
|
dbg_assert(generation_ > 0);
|
||||||
return iter().operator*();
|
return iter().operator*();
|
||||||
}
|
}
|
||||||
// This pointer value is potentially invalidated by any non-const
|
// This pointer value is potentially invalidated by any non-const
|
||||||
// method on the tree; it is NOT safe.
|
// method on the tree; it is NOT safe.
|
||||||
pointer operator->() const {
|
pointer operator->() const {
|
||||||
assert(generation_ > 0);
|
dbg_assert(generation_ > 0);
|
||||||
return iter().operator->();
|
return iter().operator->();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
src/3rdparty/squirrel/squirrel/sqstate.cpp
vendored
4
src/3rdparty/squirrel/squirrel/sqstate.cpp
vendored
@@ -281,7 +281,7 @@ SQInteger SQSharedState::CollectGarbage(SQVM *vm)
|
|||||||
|
|
||||||
SQGCMarkerQueue queue;
|
SQGCMarkerQueue queue;
|
||||||
queue.Enqueue(vms);
|
queue.Enqueue(vms);
|
||||||
#ifdef WITH_ASSERT
|
#ifdef WITH_FULL_ASSERTS
|
||||||
SQInteger x = _table(_thread(_root_vm)->_roottable)->CountUsed();
|
SQInteger x = _table(_thread(_root_vm)->_roottable)->CountUsed();
|
||||||
#endif
|
#endif
|
||||||
_refs_table.EnqueueMarkObject(queue);
|
_refs_table.EnqueueMarkObject(queue);
|
||||||
@@ -329,7 +329,7 @@ SQInteger SQSharedState::CollectGarbage(SQVM *vm)
|
|||||||
t = t->_next;
|
t = t->_next;
|
||||||
}
|
}
|
||||||
_gc_chain = tchain;
|
_gc_chain = tchain;
|
||||||
#ifdef WITH_ASSERT
|
#ifdef WITH_FULL_ASSERTS
|
||||||
SQInteger z = _table(_thread(_root_vm)->_roottable)->CountUsed();
|
SQInteger z = _table(_thread(_root_vm)->_roottable)->CountUsed();
|
||||||
assert(z == x);
|
assert(z == x);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -299,7 +299,7 @@ struct SpecializedStation : public BaseStation {
|
|||||||
*/
|
*/
|
||||||
static inline T *From(BaseStation *st)
|
static inline T *From(BaseStation *st)
|
||||||
{
|
{
|
||||||
assert(IsExpected(st));
|
dbg_assert(IsExpected(st));
|
||||||
return (T *)st;
|
return (T *)st;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +310,7 @@ struct SpecializedStation : public BaseStation {
|
|||||||
*/
|
*/
|
||||||
static inline const T *From(const BaseStation *st)
|
static inline const T *From(const BaseStation *st)
|
||||||
{
|
{
|
||||||
assert(IsExpected(st));
|
dbg_assert(IsExpected(st));
|
||||||
return (const T *)st;
|
return (const T *)st;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -89,7 +89,7 @@ bool HasBridgeFlatRamp(Slope tileh, Axis axis);
|
|||||||
*/
|
*/
|
||||||
static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
|
static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
|
||||||
{
|
{
|
||||||
assert(i < lengthof(_bridge));
|
dbg_assert(i < lengthof(_bridge));
|
||||||
return &_bridge[i];
|
return &_bridge[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -125,7 +125,7 @@ CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16 count, So
|
|||||||
source_xy(source_xy),
|
source_xy(source_xy),
|
||||||
loaded_at_xy(0)
|
loaded_at_xy(0)
|
||||||
{
|
{
|
||||||
assert(count != 0);
|
dbg_assert(count != 0);
|
||||||
this->source_type = source_type;
|
this->source_type = source_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ CargoPacket::CargoPacket(uint16 count, byte days_in_transit, StationID source, T
|
|||||||
source_xy(source_xy),
|
source_xy(source_xy),
|
||||||
loaded_at_xy(loaded_at_xy)
|
loaded_at_xy(loaded_at_xy)
|
||||||
{
|
{
|
||||||
assert(count != 0);
|
dbg_assert(count != 0);
|
||||||
this->source_type = source_type;
|
this->source_type = source_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ void CargoPacket::Merge(CargoPacket *cp)
|
|||||||
*/
|
*/
|
||||||
void CargoPacket::Reduce(uint count)
|
void CargoPacket::Reduce(uint count)
|
||||||
{
|
{
|
||||||
assert(count < this->count);
|
dbg_assert(count < this->count);
|
||||||
this->feeder_share -= this->FeederShare(count);
|
this->feeder_share -= this->FeederShare(count);
|
||||||
if (this->flags & CPF_HAS_DEFERRED_PAYMENT) {
|
if (this->flags & CPF_HAS_DEFERRED_PAYMENT) {
|
||||||
IterateCargoPacketDeferredPayments(this->index, false, [&](Money &payment, CompanyID cid, VehicleType type) {
|
IterateCargoPacketDeferredPayments(this->index, false, [&](Money &payment, CompanyID cid, VehicleType type) {
|
||||||
@@ -335,7 +335,7 @@ void CargoList<Tinst, Tcont>::OnCleanPool()
|
|||||||
template <class Tinst, class Tcont>
|
template <class Tinst, class Tcont>
|
||||||
void CargoList<Tinst, Tcont>::RemoveFromCache(const CargoPacket *cp, uint count)
|
void CargoList<Tinst, Tcont>::RemoveFromCache(const CargoPacket *cp, uint count)
|
||||||
{
|
{
|
||||||
assert(count <= cp->count);
|
dbg_assert(count <= cp->count);
|
||||||
this->count -= count;
|
this->count -= count;
|
||||||
this->cargo_days_in_transit -= cp->days_in_transit * 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)
|
void VehicleCargoList::Append(CargoPacket *cp, MoveToAction action)
|
||||||
{
|
{
|
||||||
assert(cp != nullptr);
|
dbg_assert(cp != nullptr);
|
||||||
assert(action == MTA_LOAD ||
|
dbg_assert(action == MTA_LOAD ||
|
||||||
(action == MTA_KEEP && this->action_counts[MTA_LOAD] == 0));
|
(action == MTA_KEEP && this->action_counts[MTA_LOAD] == 0));
|
||||||
this->AddToMeta(cp, action);
|
this->AddToMeta(cp, action);
|
||||||
|
|
||||||
@@ -541,7 +541,7 @@ void VehicleCargoList::AddToCache(const CargoPacket *cp)
|
|||||||
*/
|
*/
|
||||||
void VehicleCargoList::RemoveFromMeta(const CargoPacket *cp, MoveToAction action, uint count)
|
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->AssertCountConsistency();
|
||||||
this->RemoveFromCache(cp, count);
|
this->RemoveFromCache(cp, count);
|
||||||
this->action_counts[action] -= 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)
|
bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8 order_flags, const GoodsEntry *ge, CargoPayment *payment)
|
||||||
{
|
{
|
||||||
this->AssertCountConsistency();
|
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;
|
this->action_counts[MTA_TRANSFER] = this->action_counts[MTA_DELIVER] = this->action_counts[MTA_KEEP] = 0;
|
||||||
Iterator it = this->packets.begin();
|
Iterator it = this->packets.begin();
|
||||||
uint sum = 0;
|
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_keep = (order_flags & OUFB_NO_UNLOAD) != 0;
|
||||||
bool force_unload = (order_flags & OUFB_UNLOAD) != 0;
|
bool force_unload = (order_flags & OUFB_UNLOAD) != 0;
|
||||||
bool force_transfer = (order_flags & (OUFB_TRANSFER | 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) {
|
while (sum < this->count) {
|
||||||
CargoPacket *cp = *it;
|
CargoPacket *cp = *it;
|
||||||
|
|
||||||
@@ -716,7 +716,7 @@ bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationID
|
|||||||
this->action_counts[action] += cp->count;
|
this->action_counts[action] += cp->count;
|
||||||
sum += cp->count;
|
sum += cp->count;
|
||||||
}
|
}
|
||||||
assert(this->packets.empty());
|
dbg_assert(this->packets.empty());
|
||||||
this->packets = std::move(transfer_deliver);
|
this->packets = std::move(transfer_deliver);
|
||||||
this->packets.insert(this->packets.end(), keep.begin(), keep.end());
|
this->packets.insert(this->packets.end(), keep.begin(), keep.end());
|
||||||
this->AssertCountConsistency();
|
this->AssertCountConsistency();
|
||||||
@@ -899,7 +899,7 @@ uint VehicleCargoList::RerouteFromSource(uint max_move, VehicleCargoList *dest,
|
|||||||
*/
|
*/
|
||||||
void StationCargoList::Append(CargoPacket *cp, StationID next)
|
void StationCargoList::Append(CargoPacket *cp, StationID next)
|
||||||
{
|
{
|
||||||
assert(cp != nullptr);
|
dbg_assert(cp != nullptr);
|
||||||
this->AddToCache(cp);
|
this->AddToCache(cp);
|
||||||
|
|
||||||
StationCargoPacketMap::List &list = this->packets[next];
|
StationCargoPacketMap::List &list = this->packets[next];
|
||||||
|
@@ -34,7 +34,7 @@ enum ClearGround {
|
|||||||
*/
|
*/
|
||||||
static inline bool IsSnowTile(TileIndex t)
|
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);
|
return HasBit(_m[t].m3, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ static inline bool IsSnowTile(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline ClearGround GetRawClearGround(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);
|
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)
|
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);
|
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)
|
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;
|
_m[t].m5 += d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ static inline void AddClearDensity(TileIndex t, int d)
|
|||||||
*/
|
*/
|
||||||
static inline void SetClearDensity(TileIndex t, uint 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);
|
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)
|
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);
|
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)
|
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;
|
_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)
|
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);
|
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)
|
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;
|
_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)
|
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);
|
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)
|
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);
|
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)
|
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;
|
return(IndustryID) _m[t].m2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ static inline IndustryID GetIndustryIndexOfField(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void SetIndustryIndexOfField(TileIndex t, IndustryID i)
|
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;
|
_m[t].m2 = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ static inline void SetIndustryIndexOfField(TileIndex t, IndustryID i)
|
|||||||
*/
|
*/
|
||||||
static inline uint GetFence(TileIndex t, DiagDirection side)
|
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) {
|
switch (side) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
case DIAGDIR_SE: return GB(_m[t].m4, 2, 3);
|
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)
|
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) {
|
switch (side) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
case DIAGDIR_SE: SB(_m[t].m4, 2, 3, h); break;
|
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)
|
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);
|
SetBit(_m[t].m3, 4);
|
||||||
if (GetRawClearGround(t) == CLEAR_FIELDS) {
|
if (GetRawClearGround(t) == CLEAR_FIELDS) {
|
||||||
SetClearGroundDensity(t, CLEAR_GRASS, density);
|
SetClearGroundDensity(t, CLEAR_GRASS, density);
|
||||||
@@ -315,7 +315,7 @@ static inline void MakeSnow(TileIndex t, uint density = 0)
|
|||||||
*/
|
*/
|
||||||
static inline void ClearSnow(TileIndex t)
|
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);
|
ClrBit(_m[t].m3, 4);
|
||||||
SetClearDensity(t, 3);
|
SetClearDensity(t, 3);
|
||||||
}
|
}
|
||||||
|
@@ -118,7 +118,7 @@ class Kdtree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->Build(elements.begin(), elements.end());
|
this->Build(elements.begin(), elements.end());
|
||||||
assert(initial_count == this->Count());
|
dbg_assert(initial_count == this->Count());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ class Kdtree {
|
|||||||
CoordT ec = this->xyfunc(element, dim);
|
CoordT ec = this->xyfunc(element, dim);
|
||||||
/* Which side to remove from */
|
/* Which side to remove from */
|
||||||
size_t next = (ec < nc) ? n.left : n.right;
|
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 */
|
/* Descend */
|
||||||
size_t new_branch = this->RemoveRecursive(element, next, level + 1);
|
size_t new_branch = this->RemoveRecursive(element, next, level + 1);
|
||||||
if (new_branch != next) {
|
if (new_branch != next) {
|
||||||
@@ -317,7 +317,7 @@ class Kdtree {
|
|||||||
return this->unbalanced > this->Count() / 4;
|
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)
|
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;
|
if (node_idx == INVALID_NODE) return;
|
||||||
@@ -326,10 +326,10 @@ class Kdtree {
|
|||||||
CoordT cx = this->xyfunc(n.element, 0);
|
CoordT cx = this->xyfunc(n.element, 0);
|
||||||
CoordT cy = this->xyfunc(n.element, 1);
|
CoordT cy = this->xyfunc(n.element, 1);
|
||||||
|
|
||||||
assert(cx >= min_x);
|
dbg_assert(cx >= min_x);
|
||||||
assert(cx < max_x);
|
dbg_assert(cx < max_x);
|
||||||
assert(cy >= min_y);
|
dbg_assert(cy >= min_y);
|
||||||
assert(cy < max_y);
|
dbg_assert(cy < max_y);
|
||||||
|
|
||||||
if (level % 2 == 0) {
|
if (level % 2 == 0) {
|
||||||
// split in dimension 0 = x
|
// split in dimension 0 = x
|
||||||
@@ -431,7 +431,7 @@ public:
|
|||||||
/** Get number of elements stored in tree */
|
/** Get number of elements stored in tree */
|
||||||
size_t Count() const
|
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();
|
return this->nodes.size() - this->free_list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,7 +442,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
T FindNearest(CoordT x, CoordT y) const
|
T FindNearest(CoordT x, CoordT y) const
|
||||||
{
|
{
|
||||||
assert(this->Count() > 0);
|
dbg_assert(this->Count() > 0);
|
||||||
|
|
||||||
CoordT xy[2] = { x, y };
|
CoordT xy[2] = { x, y };
|
||||||
return this->FindNearestRecursive(xy, this->root, 0).first;
|
return this->FindNearestRecursive(xy, this->root, 0).first;
|
||||||
@@ -460,8 +460,8 @@ public:
|
|||||||
template <typename Outputter>
|
template <typename Outputter>
|
||||||
void FindContained(CoordT x1, CoordT y1, CoordT x2, CoordT y2, const Outputter &outputter) const
|
void FindContained(CoordT x1, CoordT y1, CoordT x2, CoordT y2, const Outputter &outputter) const
|
||||||
{
|
{
|
||||||
assert(x1 < x2);
|
dbg_assert(x1 < x2);
|
||||||
assert(y1 < y2);
|
dbg_assert(y1 < y2);
|
||||||
|
|
||||||
if (this->Count() == 0) return;
|
if (this->Count() == 0) return;
|
||||||
|
|
||||||
|
@@ -35,9 +35,9 @@ DEFINE_POOL_METHOD(inline)::Pool(const char *name) :
|
|||||||
first_free(0),
|
first_free(0),
|
||||||
first_unused(0),
|
first_unused(0),
|
||||||
items(0),
|
items(0),
|
||||||
#ifdef WITH_ASSERT
|
#ifdef WITH_FULL_dbg_assertS
|
||||||
checked(0),
|
checked(0),
|
||||||
#endif /* WITH_ASSERT */
|
#endif /* WITH_FULL_dbg_assertS */
|
||||||
cleaning(false),
|
cleaning(false),
|
||||||
data(nullptr),
|
data(nullptr),
|
||||||
free_bitmap(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)
|
DEFINE_POOL_METHOD(inline void)::ResizeFor(size_t index)
|
||||||
{
|
{
|
||||||
assert(index >= this->size);
|
dbg_assert(index >= this->size);
|
||||||
assert(index < Tmax_size);
|
dbg_assert(index < Tmax_size);
|
||||||
|
|
||||||
size_t new_size = std::min(Tmax_size, Align(index + 1, std::max<uint>(64, Tgrowth_step)));
|
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;
|
return this->first_unused;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(this->first_unused == this->size);
|
dbg_assert(this->first_unused == this->size);
|
||||||
|
|
||||||
if (this->first_unused < Tmax_size) {
|
if (this->first_unused < Tmax_size) {
|
||||||
this->ResizeFor(this->first_unused);
|
this->ResizeFor(this->first_unused);
|
||||||
return this->first_unused;
|
return this->first_unused;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(this->first_unused == Tmax_size);
|
dbg_assert(this->first_unused == Tmax_size);
|
||||||
|
|
||||||
return NO_FREE_ITEM;
|
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)
|
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->first_unused = std::max(this->first_unused, index + 1);
|
||||||
this->items++;
|
this->items++;
|
||||||
|
|
||||||
Titem *item;
|
Titem *item;
|
||||||
if (Tcache && this->alloc_cache != nullptr) {
|
if (Tcache && this->alloc_cache != nullptr) {
|
||||||
assert(sizeof(Titem) == size);
|
dbg_assert(sizeof(Titem) == size);
|
||||||
item = (Titem *)this->alloc_cache;
|
item = (Titem *)this->alloc_cache;
|
||||||
this->alloc_cache = this->alloc_cache->next;
|
this->alloc_cache = this->alloc_cache->next;
|
||||||
if (Tzero) {
|
if (Tzero) {
|
||||||
@@ -145,10 +145,10 @@ DEFINE_POOL_METHOD(void *)::GetNew(size_t size)
|
|||||||
{
|
{
|
||||||
size_t index = this->FindFirstFree();
|
size_t index = this->FindFirstFree();
|
||||||
|
|
||||||
#ifdef WITH_ASSERT
|
#ifdef WITH_FULL_dbg_assertS
|
||||||
assert(this->checked != 0);
|
dbg_assert(this->checked != 0);
|
||||||
this->checked--;
|
this->checked--;
|
||||||
#endif /* WITH_ASSERT */
|
#endif /* WITH_FULL_dbg_assertS */
|
||||||
if (index == NO_FREE_ITEM) {
|
if (index == NO_FREE_ITEM) {
|
||||||
error("%s: no more free items", this->name);
|
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)
|
DEFINE_POOL_METHOD(void)::FreeItem(size_t index)
|
||||||
{
|
{
|
||||||
assert(index < this->size);
|
dbg_assert(index < this->size);
|
||||||
assert(this->data[index] != nullptr);
|
dbg_assert(this->data[index] != nullptr);
|
||||||
if (Tcache) {
|
if (Tcache) {
|
||||||
AllocCache *ac = (AllocCache *)this->data[index];
|
AllocCache *ac = (AllocCache *)this->data[index];
|
||||||
ac->next = this->alloc_cache;
|
ac->next = this->alloc_cache;
|
||||||
@@ -213,7 +213,7 @@ DEFINE_POOL_METHOD(void)::CleanPool()
|
|||||||
for (size_t i = 0; i < this->first_unused; i++) {
|
for (size_t i = 0; i < this->first_unused; i++) {
|
||||||
delete this->Get(i); // 'delete nullptr;' is very valid
|
delete this->Get(i); // 'delete nullptr;' is very valid
|
||||||
}
|
}
|
||||||
assert(this->items == 0);
|
dbg_assert(this->items == 0);
|
||||||
free(this->data);
|
free(this->data);
|
||||||
free(this->free_bitmap);
|
free(this->free_bitmap);
|
||||||
this->first_unused = this->first_free = this->size = 0;
|
this->first_unused = this->first_free = this->size = 0;
|
||||||
|
@@ -109,7 +109,7 @@ struct Pool : PoolBase {
|
|||||||
*/
|
*/
|
||||||
inline Titem *Get(size_t index)
|
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];
|
return this->data[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ struct Pool : PoolBase {
|
|||||||
{
|
{
|
||||||
if (p == nullptr) return;
|
if (p == nullptr) return;
|
||||||
Titem *pn = (Titem *)p;
|
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);
|
Tpool->FreeItem(pn->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ struct Pool : PoolBase {
|
|||||||
* memory are the same (because of possible inheritance).
|
* memory are the same (because of possible inheritance).
|
||||||
* Use { size_t index = item->index; delete item; new (index) item; }
|
* Use { size_t index = item->index; delete item; new (index) item; }
|
||||||
* instead to make sure destructor is called and no memory leaks. */
|
* 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;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
@@ -52,7 +52,7 @@ static inline bool IsDepotTile(TileIndex tile)
|
|||||||
static inline DepotID GetDepotIndex(TileIndex t)
|
static inline DepotID GetDepotIndex(TileIndex t)
|
||||||
{
|
{
|
||||||
/* Hangars don't have a Depot class, thus store no DepotID. */
|
/* 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;
|
return _m[t].m2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ static inline bool IsValidAxis(Axis d)
|
|||||||
*/
|
*/
|
||||||
static inline Direction ReverseDir(Direction d)
|
static inline Direction ReverseDir(Direction d)
|
||||||
{
|
{
|
||||||
assert(IsValidDirection(d));
|
dbg_assert(IsValidDirection(d));
|
||||||
return (Direction)(4 ^ d);
|
return (Direction)(4 ^ d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +67,8 @@ static inline Direction ReverseDir(Direction d)
|
|||||||
*/
|
*/
|
||||||
static inline DirDiff DirDifference(Direction d0, Direction d1)
|
static inline DirDiff DirDifference(Direction d0, Direction d1)
|
||||||
{
|
{
|
||||||
assert(IsValidDirection(d0));
|
dbg_assert(IsValidDirection(d0));
|
||||||
assert(IsValidDirection(d1));
|
dbg_assert(IsValidDirection(d1));
|
||||||
/* Cast to uint so compiler can use bitmask. If the difference is negative
|
/* 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. */
|
* and we used int instead of uint, further "+ 8" would have to be added. */
|
||||||
return (DirDiff)((uint)(d0 - d1) % 8);
|
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)
|
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. */
|
/* Cast to uint so compiler can use bitmask. Result can never be negative. */
|
||||||
return (Direction)((uint)(d + delta) % 8);
|
return (Direction)((uint)(d + delta) % 8);
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ static inline Direction ChangeDir(Direction d, DirDiff delta)
|
|||||||
*/
|
*/
|
||||||
static inline DiagDirection ReverseDiagDir(DiagDirection d)
|
static inline DiagDirection ReverseDiagDir(DiagDirection d)
|
||||||
{
|
{
|
||||||
assert(IsValidDiagDirection(d));
|
dbg_assert(IsValidDiagDirection(d));
|
||||||
return (DiagDirection)(2 ^ d);
|
return (DiagDirection)(2 ^ d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,8 +130,8 @@ static inline DiagDirection ReverseDiagDir(DiagDirection d)
|
|||||||
*/
|
*/
|
||||||
static inline DiagDirDiff DiagDirDifference(DiagDirection d0, DiagDirection d1)
|
static inline DiagDirDiff DiagDirDifference(DiagDirection d0, DiagDirection d1)
|
||||||
{
|
{
|
||||||
assert(IsValidDiagDirection(d0));
|
dbg_assert(IsValidDiagDirection(d0));
|
||||||
assert(IsValidDiagDirection(d1));
|
dbg_assert(IsValidDiagDirection(d1));
|
||||||
/* Cast to uint so compiler can use bitmask. Result can never be negative. */
|
/* Cast to uint so compiler can use bitmask. Result can never be negative. */
|
||||||
return (DiagDirDiff)((uint)(d0 - d1) % 4);
|
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)
|
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. */
|
/* Cast to uint so compiler can use bitmask. Result can never be negative. */
|
||||||
return (DiagDirection)((uint)(d + delta) % 4);
|
return (DiagDirection)((uint)(d + delta) % 4);
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ static inline DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta)
|
|||||||
*/
|
*/
|
||||||
static inline DiagDirection DirToDiagDir(Direction dir)
|
static inline DiagDirection DirToDiagDir(Direction dir)
|
||||||
{
|
{
|
||||||
assert(IsValidDirection(dir));
|
dbg_assert(IsValidDirection(dir));
|
||||||
return (DiagDirection)(dir >> 1);
|
return (DiagDirection)(dir >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ static inline DiagDirection DirToDiagDir(Direction dir)
|
|||||||
*/
|
*/
|
||||||
static inline Direction DiagDirToDir(DiagDirection dir)
|
static inline Direction DiagDirToDir(DiagDirection dir)
|
||||||
{
|
{
|
||||||
assert(IsValidDiagDirection(dir));
|
dbg_assert(IsValidDiagDirection(dir));
|
||||||
return (Direction)(dir * 2 + 1);
|
return (Direction)(dir * 2 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ static inline Direction DiagDirToDir(DiagDirection dir)
|
|||||||
*/
|
*/
|
||||||
static inline Axis OtherAxis(Axis a)
|
static inline Axis OtherAxis(Axis a)
|
||||||
{
|
{
|
||||||
assert(IsValidAxis(a));
|
dbg_assert(IsValidAxis(a));
|
||||||
return (Axis)(a ^ 1);
|
return (Axis)(a ^ 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ static inline Axis OtherAxis(Axis a)
|
|||||||
*/
|
*/
|
||||||
static inline Axis DiagDirToAxis(DiagDirection d)
|
static inline Axis DiagDirToAxis(DiagDirection d)
|
||||||
{
|
{
|
||||||
assert(IsValidDiagDirection(d));
|
dbg_assert(IsValidDiagDirection(d));
|
||||||
return (Axis)(d & 1);
|
return (Axis)(d & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +231,7 @@ static inline Axis DiagDirToAxis(DiagDirection d)
|
|||||||
*/
|
*/
|
||||||
static inline DiagDirection AxisToDiagDir(Axis a)
|
static inline DiagDirection AxisToDiagDir(Axis a)
|
||||||
{
|
{
|
||||||
assert(IsValidAxis(a));
|
dbg_assert(IsValidAxis(a));
|
||||||
return (DiagDirection)(2 - a);
|
return (DiagDirection)(2 - a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ static inline DiagDirection AxisToDiagDir(Axis a)
|
|||||||
*/
|
*/
|
||||||
static inline Direction AxisToDirection(Axis a)
|
static inline Direction AxisToDirection(Axis a)
|
||||||
{
|
{
|
||||||
assert(IsValidAxis(a));
|
dbg_assert(IsValidAxis(a));
|
||||||
return (Direction)(5 - 2 * a);
|
return (Direction)(5 - 2 * a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ static inline Direction AxisToDirection(Axis a)
|
|||||||
*/
|
*/
|
||||||
static inline DiagDirection XYNSToDiagDir(Axis xy, uint ns)
|
static inline DiagDirection XYNSToDiagDir(Axis xy, uint ns)
|
||||||
{
|
{
|
||||||
assert(IsValidAxis(xy));
|
dbg_assert(IsValidAxis(xy));
|
||||||
return (DiagDirection)(xy * 3 ^ ns * 2);
|
return (DiagDirection)(xy * 3 ^ ns * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ static inline DiagDirection XYNSToDiagDir(Axis xy, uint ns)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsDiagonalDirection(Direction dir)
|
static inline bool IsDiagonalDirection(Direction dir)
|
||||||
{
|
{
|
||||||
assert(IsValidDirection(dir));
|
dbg_assert(IsValidDirection(dir));
|
||||||
return (dir & 1) != 0;
|
return (dir & 1) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,8 +289,8 @@ static inline bool IsDiagonalDirection(Direction dir)
|
|||||||
*/
|
*/
|
||||||
static inline DiagDirection DirToDiagDirAlongAxis(Direction dir, Axis axis)
|
static inline DiagDirection DirToDiagDirAlongAxis(Direction dir, Axis axis)
|
||||||
{
|
{
|
||||||
assert(IsValidDirection(dir));
|
dbg_assert(IsValidDirection(dir));
|
||||||
assert(IsValidAxis(axis));
|
dbg_assert(IsValidAxis(axis));
|
||||||
if ((dir & 3) == (3 ^ (axis << 1))) return INVALID_DIAGDIR;
|
if ((dir & 3) == (3 ^ (axis << 1))) return INVALID_DIAGDIR;
|
||||||
/* Mapping:
|
/* Mapping:
|
||||||
* X 4, 5, 6 -> 2 0, 1, 2 -> 0
|
* X 4, 5, 6 -> 2 0, 1, 2 -> 0
|
||||||
|
@@ -126,7 +126,7 @@ struct HouseSpec {
|
|||||||
|
|
||||||
static inline HouseSpec *Get(size_t house_id)
|
static inline HouseSpec *Get(size_t house_id)
|
||||||
{
|
{
|
||||||
assert(house_id < NUM_HOUSES);
|
dbg_assert(house_id < NUM_HOUSES);
|
||||||
extern HouseSpec _house_specs[];
|
extern HouseSpec _house_specs[];
|
||||||
return &_house_specs[house_id];
|
return &_house_specs[house_id];
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,7 @@ enum IndustryGraphics {
|
|||||||
*/
|
*/
|
||||||
static inline IndustryID GetIndustryIndex(TileIndex t)
|
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;
|
return _m[t].m2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ static inline IndustryID GetIndustryIndex(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsIndustryCompleted(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);
|
return HasBit(_m[t].m1, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ IndustryType GetIndustryType(TileIndex tile);
|
|||||||
*/
|
*/
|
||||||
static inline void SetIndustryCompleted(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);
|
SB(_m[tile].m1, 7, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ static inline void SetIndustryCompleted(TileIndex tile)
|
|||||||
*/
|
*/
|
||||||
static inline byte GetIndustryConstructionStage(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);
|
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)
|
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);
|
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)
|
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);
|
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)
|
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));
|
return GetTranslatedIndustryTileID(GetCleanIndustryGfx(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ static inline IndustryGfx GetIndustryGfx(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
|
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);
|
_m[t].m5 = GB(gfx, 0, 8);
|
||||||
SB(_me[t].m6, 2, 1, GB(gfx, 8, 1));
|
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)
|
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);
|
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)
|
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);
|
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)
|
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, 0, 4, 0);
|
||||||
SB(_m[tile].m1, 7, 1, 0);
|
SB(_m[tile].m1, 7, 1, 0);
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ static inline void ResetIndustryConstructionStage(TileIndex tile)
|
|||||||
*/
|
*/
|
||||||
static inline byte GetIndustryAnimationLoop(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;
|
return _m[tile].m4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ static inline byte GetIndustryAnimationLoop(TileIndex tile)
|
|||||||
*/
|
*/
|
||||||
static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
|
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;
|
_m[tile].m4 = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +223,7 @@ static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
|
|||||||
*/
|
*/
|
||||||
static inline byte GetIndustryRandomBits(TileIndex tile)
|
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;
|
return _m[tile].m3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ static inline byte GetIndustryRandomBits(TileIndex tile)
|
|||||||
*/
|
*/
|
||||||
static inline void SetIndustryRandomBits(TileIndex tile, byte bits)
|
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;
|
_m[tile].m3 = bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ static inline void SetIndustryRandomBits(TileIndex tile, byte bits)
|
|||||||
*/
|
*/
|
||||||
static inline byte GetIndustryTriggers(TileIndex tile)
|
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);
|
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)
|
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);
|
SB(_me[tile].m6, 3, 3, triggers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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
|
* 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 */
|
* tests while building the industry (as in WATER REQUIRED */
|
||||||
if (gfx != 0xFF) {
|
if (gfx != 0xFF) {
|
||||||
assert(gfx < INVALID_INDUSTRYTILE);
|
dbg_assert(gfx < INVALID_INDUSTRYTILE);
|
||||||
const IndustryTileSpec *it = &_industry_tile_specs[gfx];
|
const IndustryTileSpec *it = &_industry_tile_specs[gfx];
|
||||||
return it->grf_prop.override == INVALID_INDUSTRYTILE ? gfx : it->grf_prop.override;
|
return it->grf_prop.override == INVALID_INDUSTRYTILE ? gfx : it->grf_prop.override;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -849,7 +849,7 @@ void RunTileLoop()
|
|||||||
|
|
||||||
TileIndex tile = _cur_tileloop_tile;
|
TileIndex tile = _cur_tileloop_tile;
|
||||||
/* The LFSR cannot have a zeroed state. */
|
/* 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));
|
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)
|
static bool FlowsDown(TileIndex begin, TileIndex end)
|
||||||
{
|
{
|
||||||
assert(DistanceManhattan(begin, end) == 1);
|
dbg_assert(DistanceManhattan(begin, end) == 1);
|
||||||
|
|
||||||
int heightBegin;
|
int heightBegin;
|
||||||
int heightEnd;
|
int heightEnd;
|
||||||
|
@@ -94,7 +94,7 @@ static inline int GetSlopePixelZInCorner(Slope tileh, Corner corner)
|
|||||||
*/
|
*/
|
||||||
static inline Slope GetFoundationPixelSlope(TileIndex tile, int *z)
|
static inline Slope GetFoundationPixelSlope(TileIndex tile, int *z)
|
||||||
{
|
{
|
||||||
assert(z != nullptr);
|
dbg_assert(z != nullptr);
|
||||||
Slope s = GetFoundationSlope(tile, z);
|
Slope s = GetFoundationSlope(tile, z);
|
||||||
*z *= TILE_HEIGHT;
|
*z *= TILE_HEIGHT;
|
||||||
return s;
|
return s;
|
||||||
|
12
src/map.cpp
12
src/map.cpp
@@ -112,7 +112,7 @@ TileIndex TileAdd(TileIndex tile, TileIndexDiff add,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(TileXY(x, y) == TILE_MASK(tile + add));
|
dbg_assert(TileXY(x, y) == TILE_MASK(tile + add));
|
||||||
|
|
||||||
return TileXY(x, y);
|
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)
|
bool CircularTileSearch(TileIndex *tile, uint size, TestTileOnSearchProc proc, void *user_data)
|
||||||
{
|
{
|
||||||
assert(proc != nullptr);
|
dbg_assert(proc != nullptr);
|
||||||
assert(size > 0);
|
dbg_assert(size > 0);
|
||||||
|
|
||||||
if (size % 2 == 1) {
|
if (size % 2 == 1) {
|
||||||
/* If the length of the side is uneven, the center has to be checked
|
/* 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)
|
bool CircularTileSearch(TileIndex *tile, uint radius, uint w, uint h, TestTileOnSearchProc proc, void *user_data)
|
||||||
{
|
{
|
||||||
assert(proc != nullptr);
|
dbg_assert(proc != nullptr);
|
||||||
assert(radius > 0);
|
dbg_assert(radius > 0);
|
||||||
|
|
||||||
uint x = TileX(*tile) + w + 1;
|
uint x = TileX(*tile) + w + 1;
|
||||||
uint y = TileY(*tile);
|
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)
|
bool EnoughContiguousTilesMatchingCondition(TileIndex tile, uint threshold, TestTileOnSearchProc proc, void *user_data)
|
||||||
{
|
{
|
||||||
assert(proc != nullptr);
|
dbg_assert(proc != nullptr);
|
||||||
if (threshold == 0) return true;
|
if (threshold == 0) return true;
|
||||||
|
|
||||||
static_assert(MAX_MAP_TILES_BITS <= 30);
|
static_assert(MAX_MAP_TILES_BITS <= 30);
|
||||||
|
@@ -42,7 +42,7 @@ struct Object : ObjectPool::PoolItem<&_object_pool> {
|
|||||||
*/
|
*/
|
||||||
static inline void IncTypeCount(ObjectType type)
|
static inline void IncTypeCount(ObjectType type)
|
||||||
{
|
{
|
||||||
assert(type < NUM_OBJECTS);
|
dbg_assert(type < NUM_OBJECTS);
|
||||||
counts[type]++;
|
counts[type]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ struct Object : ObjectPool::PoolItem<&_object_pool> {
|
|||||||
*/
|
*/
|
||||||
static inline void DecTypeCount(ObjectType type)
|
static inline void DecTypeCount(ObjectType type)
|
||||||
{
|
{
|
||||||
assert(type < NUM_OBJECTS);
|
dbg_assert(type < NUM_OBJECTS);
|
||||||
counts[type]--;
|
counts[type]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ struct Object : ObjectPool::PoolItem<&_object_pool> {
|
|||||||
*/
|
*/
|
||||||
static inline uint16 GetTypeCount(ObjectType type)
|
static inline uint16 GetTypeCount(ObjectType type)
|
||||||
{
|
{
|
||||||
assert(type < NUM_OBJECTS);
|
dbg_assert(type < NUM_OBJECTS);
|
||||||
return counts[type];
|
return counts[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,7 +52,7 @@ static inline bool IsObjectTypeTile(TileIndex t, ObjectType type)
|
|||||||
*/
|
*/
|
||||||
static inline ObjectID GetObjectIndex(TileIndex t)
|
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;
|
return _m[t].m2 | _m[t].m5 << 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ static inline ObjectID GetObjectIndex(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline byte GetObjectRandomBits(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;
|
return _m[t].m3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ static inline byte GetObjectRandomBits(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline ObjectGround GetObjectGroundType(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);
|
return (ObjectGround)GB(_m[t].m4, 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ static inline ObjectGround GetObjectGroundType(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline uint GetObjectGroundDensity(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);
|
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)
|
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);
|
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)
|
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);
|
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)
|
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;
|
_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)
|
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);
|
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)
|
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;
|
_m[t].m4 = 0 << 5 | type << 2 | density;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ObjectEffectiveFoundationType GetObjectEffectiveFoundationType(TileIndex t)
|
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);
|
return (ObjectEffectiveFoundationType)GB(_me[t].m6, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void SetObjectEffectiveFoundationType(TileIndex t, ObjectEffectiveFoundationType foundation_type)
|
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);
|
SB(_me[t].m6, 0, 2, foundation_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool GetObjectHasViewportMapViewOverride(TileIndex t)
|
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);
|
return HasBit(_m[t].m4, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void SetObjectHasViewportMapViewOverride(TileIndex t, bool map_view_override)
|
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);
|
SB(_m[t].m4, 4, 1, map_view_override ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1991,7 +1991,7 @@ void StateGameLoop()
|
|||||||
SetWindowDirty(WC_MAIN_TOOLBAR, 0);
|
SetWindowDirty(WC_MAIN_TOOLBAR, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(IsLocalCompany());
|
dbg_assert(IsLocalCompany());
|
||||||
}
|
}
|
||||||
|
|
||||||
FiosNumberedSaveName &GetAutoSaveFiosNumberedSaveName()
|
FiosNumberedSaveName &GetAutoSaveFiosNumberedSaveName()
|
||||||
|
@@ -58,22 +58,22 @@ struct CFollowTrackT
|
|||||||
|
|
||||||
inline CFollowTrackT(Owner o, RailTypes railtype_override = INVALID_RAILTYPES)
|
inline CFollowTrackT(Owner o, RailTypes railtype_override = INVALID_RAILTYPES)
|
||||||
{
|
{
|
||||||
assert(IsRailTT());
|
dbg_assert(IsRailTT());
|
||||||
m_veh = nullptr;
|
m_veh = nullptr;
|
||||||
Init(o, railtype_override);
|
Init(o, railtype_override);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Init(const VehicleType *v, RailTypes 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;
|
m_veh = v;
|
||||||
Init(v != nullptr ? v->owner : INVALID_OWNER, IsRailTT() && railtype_override == INVALID_RAILTYPES ? Train::From(v)->compatible_railtypes : railtype_override);
|
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)
|
inline void Init(Owner o, RailTypes railtype_override)
|
||||||
{
|
{
|
||||||
assert(!IsRoadTT() || m_veh != nullptr);
|
dbg_assert(!IsRoadTT() || m_veh != nullptr);
|
||||||
assert(!IsRailTT() || railtype_override != INVALID_RAILTYPES);
|
dbg_assert(!IsRailTT() || railtype_override != INVALID_RAILTYPES);
|
||||||
m_veh_owner = o;
|
m_veh_owner = o;
|
||||||
/* don't worry, all is inlined so compiler should remove unnecessary initializations */
|
/* don't worry, all is inlined so compiler should remove unnecessary initializations */
|
||||||
m_old_tile = INVALID_TILE;
|
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) */
|
/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */
|
||||||
inline DiagDirection GetSingleTramBit(TileIndex tile)
|
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);
|
const bool is_bridge = IsRoadCustomBridgeHeadTile(tile);
|
||||||
if (is_bridge || IsNormalRoadTile(tile)) {
|
if (is_bridge || IsNormalRoadTile(tile)) {
|
||||||
@@ -123,7 +123,7 @@ struct CFollowTrackT
|
|||||||
m_old_tile = old_tile;
|
m_old_tile = old_tile;
|
||||||
m_old_td = old_td;
|
m_old_td = old_td;
|
||||||
m_err = EC_NONE;
|
m_err = EC_NONE;
|
||||||
assert_tile(
|
dbg_assert_tile(
|
||||||
((TrackStatusToTrackdirBits(
|
((TrackStatusToTrackdirBits(
|
||||||
GetTileTrackStatus(m_old_tile, TT(), (IsRoadTT() && m_veh != nullptr) ? (this->IsTram() ? RTT_TRAM : RTT_ROAD) : 0)
|
GetTileTrackStatus(m_old_tile, TT(), (IsRoadTT() && m_veh != nullptr) ? (this->IsTram() ? RTT_TRAM : RTT_ROAD) : 0)
|
||||||
) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
|
) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
|
||||||
@@ -219,7 +219,9 @@ protected:
|
|||||||
m_tiles_skipped = GetTunnelBridgeLength(m_new_tile, m_old_tile);
|
m_tiles_skipped = GetTunnelBridgeLength(m_new_tile, m_old_tile);
|
||||||
return;
|
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 */
|
/* normal or station tile, do one step */
|
||||||
|
@@ -80,7 +80,7 @@ public:
|
|||||||
/** insert given item as open node (into m_open and m_open_queue) */
|
/** insert given item as open node (into m_open and m_open_queue) */
|
||||||
inline void InsertOpenNode(Titem_ &item)
|
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.Push(item);
|
||||||
m_open_queue.Include(&item);
|
m_open_queue.Include(&item);
|
||||||
if (&item == m_new_node) {
|
if (&item == m_new_node) {
|
||||||
@@ -110,7 +110,7 @@ public:
|
|||||||
|
|
||||||
inline void DequeueBestOpenNode()
|
inline void DequeueBestOpenNode()
|
||||||
{
|
{
|
||||||
assert(!m_open_queue.IsEmpty());
|
dbg_assert(!m_open_queue.IsEmpty());
|
||||||
m_open_queue.Shift();
|
m_open_queue.Shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ public:
|
|||||||
/** close node */
|
/** close node */
|
||||||
inline void InsertClosedNode(Titem_ &item)
|
inline void InsertClosedNode(Titem_ &item)
|
||||||
{
|
{
|
||||||
assert(m_open.Find(item.GetKey()) == nullptr);
|
dbg_assert(m_open.Find(item.GetKey()) == nullptr);
|
||||||
m_closed.Push(item);
|
m_closed.Push(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -93,8 +93,8 @@ public:
|
|||||||
|
|
||||||
inline int CurveCost(Trackdir td1, Trackdir td2)
|
inline int CurveCost(Trackdir td1, Trackdir td2)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdir(td1));
|
dbg_assert(IsValidTrackdir(td1));
|
||||||
assert(IsValidTrackdir(td2));
|
dbg_assert(IsValidTrackdir(td2));
|
||||||
int cost = 0;
|
int cost = 0;
|
||||||
if (TrackFollower::Allow90degTurns()
|
if (TrackFollower::Allow90degTurns()
|
||||||
&& HasTrackdir(TrackdirCrossesTrackdirs(td1), td2)) {
|
&& HasTrackdir(TrackdirCrossesTrackdirs(td1), td2)) {
|
||||||
@@ -484,9 +484,9 @@ public:
|
|||||||
{
|
{
|
||||||
int cost = 0;
|
int cost = 0;
|
||||||
const Train *v = Yapf().GetVehicle();
|
const Train *v = Yapf().GetVehicle();
|
||||||
assert(v != nullptr);
|
dbg_assert(v != nullptr);
|
||||||
assert(v->type == VEH_TRAIN);
|
dbg_assert(v->type == VEH_TRAIN);
|
||||||
assert(v->gcache.cached_total_length != 0);
|
dbg_assert(v->gcache.cached_total_length != 0);
|
||||||
int missing_platform_length = CeilDiv(v->gcache.cached_total_length, TILE_SIZE) - platform_length;
|
int missing_platform_length = CeilDiv(v->gcache.cached_total_length, TILE_SIZE) - platform_length;
|
||||||
if (missing_platform_length < 0) {
|
if (missing_platform_length < 0) {
|
||||||
/* apply penalty for longer platform than needed */
|
/* apply penalty for longer platform than needed */
|
||||||
@@ -511,9 +511,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
inline bool PfCalcCost(Node &n, const TrackFollower *tf)
|
inline bool PfCalcCost(Node &n, const TrackFollower *tf)
|
||||||
{
|
{
|
||||||
assert(!n.flags_u.flags_s.m_targed_seen);
|
dbg_assert(!n.flags_u.flags_s.m_targed_seen);
|
||||||
assert(tf->m_new_tile == n.m_key.m_tile);
|
dbg_assert(tf->m_new_tile == n.m_key.m_tile);
|
||||||
assert((HasTrackdir(tf->m_new_td_bits, n.m_key.m_td)));
|
dbg_assert((HasTrackdir(tf->m_new_td_bits, n.m_key.m_td)));
|
||||||
|
|
||||||
/* Does the node have some parent node? */
|
/* Does the node have some parent node? */
|
||||||
bool has_parent = (n.m_parent != nullptr);
|
bool has_parent = (n.m_parent != nullptr);
|
||||||
@@ -568,7 +568,7 @@ public:
|
|||||||
|
|
||||||
if (!has_parent) {
|
if (!has_parent) {
|
||||||
/* We will jump to the middle of the cost calculator assuming that segment cache is not used. */
|
/* 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. */
|
/* Skip the first transition cost calculation. */
|
||||||
goto no_entry_cost;
|
goto no_entry_cost;
|
||||||
} else if (n.flags_u.flags_s.m_teleport) {
|
} else if (n.flags_u.flags_s.m_teleport) {
|
||||||
@@ -595,7 +595,7 @@ public:
|
|||||||
end_segment_reason = segment.m_end_segment_reason;
|
end_segment_reason = segment.m_end_segment_reason;
|
||||||
/* We will need also some information about the last signal (if it was red). */
|
/* We will need also some information about the last signal (if it was red). */
|
||||||
if (segment.m_last_signal_tile != INVALID_TILE) {
|
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);
|
SignalState sig_state = GetSignalStateByTrackdir(segment.m_last_signal_tile, segment.m_last_signal_td);
|
||||||
bool is_red = (sig_state == SIGNAL_STATE_RED);
|
bool is_red = (sig_state == SIGNAL_STATE_RED);
|
||||||
n.flags_u.flags_s.m_last_signal_was_red = is_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. */
|
/* Tests for 'potential target' reasons to close the segment. */
|
||||||
if (cur.tile == prev.tile) {
|
if (cur.tile == prev.tile) {
|
||||||
/* Penalty for reversing in a depot. */
|
/* 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;
|
segment_cost += Yapf().PfGetSettings().rail_depot_reverse_penalty;
|
||||||
|
|
||||||
} else if (IsRailDepotTile(cur.tile)) {
|
} 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. */
|
/* Arbitrary maximum tiles to follow to avoid infinite loops. */
|
||||||
uint max_tiles = 20;
|
uint max_tiles = 20;
|
||||||
while (ft.Follow(t, td)) {
|
while (ft.Follow(t, td)) {
|
||||||
assert(t != ft.m_new_tile);
|
dbg_assert(t != ft.m_new_tile);
|
||||||
t = ft.m_new_tile;
|
t = ft.m_new_tile;
|
||||||
if (t == cur.tile || --max_tiles == 0) {
|
if (t == cur.tile || --max_tiles == 0) {
|
||||||
/* We looped back on ourself or found another loop, bail out. */
|
/* 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());
|
tf_local.Init(v, Yapf().GetCompatibleRailTypes());
|
||||||
|
|
||||||
if (!tf_local.Follow(cur.tile, cur.td)) {
|
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?). */
|
/* 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 (!(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) {
|
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. */
|
/* Station platform-length penalty. */
|
||||||
if ((end_segment_reason & ESRB_STATION) != ESRB_NONE) {
|
if ((end_segment_reason & ESRB_STATION) != ESRB_NONE) {
|
||||||
const BaseStation *st = BaseStation::GetByTile(n.GetLastTile());
|
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())));
|
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). */
|
/* 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;
|
extra_cost -= Yapf().PfGetSettings().rail_station_penalty * platform_length;
|
||||||
|
@@ -177,19 +177,19 @@ struct CYapfRailNodeT
|
|||||||
|
|
||||||
inline TileIndex GetLastTile() const
|
inline TileIndex GetLastTile() const
|
||||||
{
|
{
|
||||||
assert(m_segment != nullptr);
|
dbg_assert(m_segment != nullptr);
|
||||||
return m_segment->m_last_tile;
|
return m_segment->m_last_tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Trackdir GetLastTrackdir() const
|
inline Trackdir GetLastTrackdir() const
|
||||||
{
|
{
|
||||||
assert(m_segment != nullptr);
|
dbg_assert(m_segment != nullptr);
|
||||||
return m_segment->m_last_td;
|
return m_segment->m_last_td;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SetLastTileTrackdir(TileIndex tile, Trackdir 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_tile = tile;
|
||||||
m_segment->m_last_td = td;
|
m_segment->m_last_td = td;
|
||||||
}
|
}
|
||||||
@@ -206,7 +206,7 @@ struct CYapfRailNodeT
|
|||||||
|
|
||||||
if (!ft.Follow(cur, cur_td)) break;
|
if (!ft.Follow(cur, cur_td)) break;
|
||||||
cur = ft.m_new_tile;
|
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);
|
cur_td = FindFirstTrackdir(ft.m_new_td_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ struct CYapfRailNodeT
|
|||||||
if (!ft.Follow(cur, cur_td)) break;
|
if (!ft.Follow(cur, cur_td)) break;
|
||||||
length += TILE_SIZE * ft.m_tiles_skipped;
|
length += TILE_SIZE * ft.m_tiles_skipped;
|
||||||
cur = ft.m_new_tile;
|
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);
|
cur_td = FindFirstTrackdir(ft.m_new_td_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -166,7 +166,7 @@ public:
|
|||||||
/** Check the node for a possible reservation target. */
|
/** Check the node for a possible reservation target. */
|
||||||
inline void FindSafePositionOnNode(Node *node)
|
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. */
|
/* 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;
|
if (node->m_parent->m_num_signals_passed - node->m_parent->m_num_signals_res_through_passed >= 2) return;
|
||||||
|
@@ -153,7 +153,7 @@ public:
|
|||||||
/* move back to the old tile/trackdir (where ship is coming from) */
|
/* move back to the old tile/trackdir (where ship is coming from) */
|
||||||
TileIndex src_tile = TileAddByDiagDir(tile, ReverseDiagDir(enterdir));
|
TileIndex src_tile = TileAddByDiagDir(tile, ReverseDiagDir(enterdir));
|
||||||
Trackdir trackdir = v->GetVehicleTrackdir();
|
Trackdir trackdir = v->GetVehicleTrackdir();
|
||||||
assert(IsValidTrackdir(trackdir));
|
dbg_assert(IsValidTrackdir(trackdir));
|
||||||
|
|
||||||
/* convert origin trackdir to TrackdirBits */
|
/* convert origin trackdir to TrackdirBits */
|
||||||
TrackdirBits trackdirs = TrackdirToTrackdirBits(trackdir);
|
TrackdirBits trackdirs = TrackdirToTrackdirBits(trackdir);
|
||||||
@@ -262,8 +262,8 @@ protected:
|
|||||||
public:
|
public:
|
||||||
inline int CurveCost(Trackdir td1, Trackdir td2)
|
inline int CurveCost(Trackdir td1, Trackdir td2)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdir(td1));
|
dbg_assert(IsValidTrackdir(td1));
|
||||||
assert(IsValidTrackdir(td2));
|
dbg_assert(IsValidTrackdir(td2));
|
||||||
|
|
||||||
if (HasTrackdir(TrackdirCrossesTrackdirs(td1), td2)) {
|
if (HasTrackdir(TrackdirCrossesTrackdirs(td1), td2)) {
|
||||||
/* 90-deg curve penalty */
|
/* 90-deg curve penalty */
|
||||||
|
@@ -327,7 +327,7 @@ public:
|
|||||||
static inline const RailtypeInfo *GetRailTypeInfo(RailType railtype)
|
static inline const RailtypeInfo *GetRailTypeInfo(RailType railtype)
|
||||||
{
|
{
|
||||||
extern RailtypeInfo _railtypes[RAILTYPE_END];
|
extern RailtypeInfo _railtypes[RAILTYPE_END];
|
||||||
assert_msg(railtype < RAILTYPE_END, "%u", railtype);
|
dbg_assert_msg(railtype < RAILTYPE_END, "%u", railtype);
|
||||||
return &_railtypes[railtype];
|
return &_railtypes[railtype];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,7 +409,7 @@ static inline bool Rail90DegTurnDisallowedTilesFromTrackdir(TileIndex t1, TileIn
|
|||||||
*/
|
*/
|
||||||
static inline Money RailBuildCost(RailType railtype)
|
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;
|
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
|
* In this case we limit the removal earnings to 3/4s of the build
|
||||||
* cost.
|
* cost.
|
||||||
*/
|
*/
|
||||||
assert(railtype < RAILTYPE_END);
|
dbg_assert(railtype < RAILTYPE_END);
|
||||||
return std::max(_price[PR_CLEAR_RAIL], -RailBuildCost(railtype) * 3 / 4);
|
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)
|
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.
|
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.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ enum RailTileType {
|
|||||||
*/
|
*/
|
||||||
static inline RailTileType GetRailTileType(TileIndex t)
|
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);
|
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)
|
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);
|
SB(_m[tile].m5, 6, 1, signals);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ static inline RailType GetPlainRailParallelTrackRailTypeByTrackBit(TileIndex t,
|
|||||||
*/
|
*/
|
||||||
static inline TrackBits GetTrackBits(TileIndex tile)
|
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);
|
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)
|
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);
|
SB(_m[t].m5, 0, 6, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +223,7 @@ static inline Track GetRailDepotTrack(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline TrackBits GetRailReservationTrackBits(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);
|
byte track_b = GB(_m[t].m2, 8, 3);
|
||||||
Track track = (Track)(track_b - 1); // map array saves Track+1
|
Track track = (Track)(track_b - 1); // map array saves Track+1
|
||||||
if (track_b == 0) return TRACK_BIT_NONE;
|
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)
|
static inline void SetTrackReservation(TileIndex t, TrackBits b)
|
||||||
{
|
{
|
||||||
assert_tile(IsPlainRailTile(t), t);
|
dbg_assert_tile(IsPlainRailTile(t), t);
|
||||||
assert(b != INVALID_TRACK_BIT);
|
dbg_assert(b != INVALID_TRACK_BIT);
|
||||||
assert(!TracksOverlap(b));
|
dbg_assert(!TracksOverlap(b));
|
||||||
Track track = RemoveFirstTrack(&b);
|
Track track = RemoveFirstTrack(&b);
|
||||||
SB(_m[t].m2, 8, 3, track == INVALID_TRACK ? 0 : track + 1);
|
SB(_m[t].m2, 8, 3, track == INVALID_TRACK ? 0 : track + 1);
|
||||||
SB(_m[t].m2, 11, 1, (byte)(b != TRACK_BIT_NONE));
|
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)
|
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 bits = TrackToTrackBits(t);
|
||||||
TrackBits res = GetRailReservationTrackBits(tile);
|
TrackBits res = GetRailReservationTrackBits(tile);
|
||||||
if ((res & bits) != TRACK_BIT_NONE) return false; // already reserved
|
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)
|
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);
|
TrackBits res = GetRailReservationTrackBits(tile);
|
||||||
res &= ~TrackToTrackBits(t);
|
res &= ~TrackToTrackBits(t);
|
||||||
SetTrackReservation(tile, res);
|
SetTrackReservation(tile, res);
|
||||||
@@ -287,7 +287,7 @@ static inline void UnreserveTrack(TileIndex tile, Track t)
|
|||||||
*/
|
*/
|
||||||
static inline bool HasDepotReservation(TileIndex t)
|
static inline bool HasDepotReservation(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(IsRailDepot(t), t);
|
dbg_assert_tile(IsRailDepot(t), t);
|
||||||
return HasBit(_m[t].m5, 4);
|
return HasBit(_m[t].m5, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ static inline bool HasDepotReservation(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void SetDepotReservation(TileIndex t, bool b)
|
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);
|
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)
|
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;
|
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
|
||||||
return (SignalType)GB(_m[t].m2, pos, 3);
|
return (SignalType)GB(_m[t].m2, pos, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void SetSignalType(TileIndex t, Track track, SignalType s)
|
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;
|
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
|
||||||
SB(_m[t].m2, pos, 3, s);
|
SB(_m[t].m2, pos, 3, s);
|
||||||
if (track == INVALID_TRACK) SB(_m[t].m2, 4, 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)
|
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;
|
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 3 : 0;
|
||||||
return GB(_me[t].m7, pos, 3);
|
return GB(_me[t].m7, pos, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void SetSignalAspect(TileIndex t, Track track, uint8 aspect)
|
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;
|
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 3 : 0;
|
||||||
SB(_me[t].m7, pos, 3, aspect);
|
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)
|
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;
|
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
|
||||||
return GB(_me[t].m6, pos, 4);
|
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)
|
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;
|
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
|
||||||
SB(_me[t].m6, pos, 4, style);
|
SB(_me[t].m6, pos, 4, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool GetSignalAlwaysReserveThrough(TileIndex t, Track track)
|
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;
|
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 7 : 6;
|
||||||
return HasBit(_me[t].m7, pos);
|
return HasBit(_me[t].m7, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void SetSignalAlwaysReserveThrough(TileIndex t, Track track, bool reserve_through)
|
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;
|
byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 7 : 6;
|
||||||
SB(_me[t].m7, pos, 1, reserve_through ? 1 : 0);
|
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)
|
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;
|
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)
|
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);
|
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)
|
static inline SignalState GetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdir(trackdir));
|
dbg_assert(IsValidTrackdir(trackdir));
|
||||||
assert_tile(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)), tile);
|
dbg_assert_tile(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)), tile);
|
||||||
return GetSignalStates(tile) & SignalAlongTrackdir(trackdir) ?
|
return GetSignalStates(tile) & SignalAlongTrackdir(trackdir) ?
|
||||||
SIGNAL_STATE_GREEN : SIGNAL_STATE_RED;
|
SIGNAL_STATE_GREEN : SIGNAL_STATE_RED;
|
||||||
}
|
}
|
||||||
@@ -593,7 +593,7 @@ static inline bool HasOnewaySignalBlockingTrackdir(TileIndex tile, Trackdir td)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsRestrictedSignal(TileIndex tile)
|
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);
|
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)
|
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);
|
SB(_m[tile].m2, 12, 1, is_restricted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ static inline bool IsValidRoadBits(RoadBits r)
|
|||||||
*/
|
*/
|
||||||
static inline RoadBits ComplementRoadBits(RoadBits r)
|
static inline RoadBits ComplementRoadBits(RoadBits r)
|
||||||
{
|
{
|
||||||
assert(IsValidRoadBits(r));
|
dbg_assert(IsValidRoadBits(r));
|
||||||
return (RoadBits)(ROAD_ALL ^ r);
|
return (RoadBits)(ROAD_ALL ^ r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ static inline RoadBits ComplementRoadBits(RoadBits r)
|
|||||||
*/
|
*/
|
||||||
static inline RoadBits MirrorRoadBits(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));
|
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)
|
static inline RoadBits RotateRoadBits(RoadBits r, DiagDirDiff rot)
|
||||||
{
|
{
|
||||||
assert(IsValidRoadBits(r));
|
dbg_assert(IsValidRoadBits(r));
|
||||||
for (; rot > (DiagDirDiff)0; rot--) {
|
for (; rot > (DiagDirDiff)0; rot--) {
|
||||||
r = (RoadBits)(GB(r, 0, 1) << 3 | GB(r, 1, 3));
|
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)
|
static inline bool IsStraightRoad(RoadBits r)
|
||||||
{
|
{
|
||||||
assert(IsValidRoadBits(r));
|
dbg_assert(IsValidRoadBits(r));
|
||||||
return (r == ROAD_X || r == ROAD_Y);
|
return (r == ROAD_X || r == ROAD_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ static inline bool IsStraightRoad(RoadBits r)
|
|||||||
*/
|
*/
|
||||||
static inline RoadBits DiagDirToRoadBits(DiagDirection d)
|
static inline RoadBits DiagDirToRoadBits(DiagDirection d)
|
||||||
{
|
{
|
||||||
assert(IsValidDiagDirection(d));
|
dbg_assert(IsValidDiagDirection(d));
|
||||||
return (RoadBits)(ROAD_NW << (3 ^ d));
|
return (RoadBits)(ROAD_NW << (3 ^ d));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ static inline RoadBits DiagDirToRoadBits(DiagDirection d)
|
|||||||
*/
|
*/
|
||||||
static inline RoadBits AxisToRoadBits(Axis a)
|
static inline RoadBits AxisToRoadBits(Axis a)
|
||||||
{
|
{
|
||||||
assert(IsValidAxis(a));
|
dbg_assert(IsValidAxis(a));
|
||||||
return a == AXIS_X ? ROAD_X : ROAD_Y;
|
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)
|
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;
|
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)
|
static inline bool HasRoadCatenary(RoadType roadtype)
|
||||||
{
|
{
|
||||||
assert(roadtype < ROADTYPE_END);
|
dbg_assert(roadtype < ROADTYPE_END);
|
||||||
return HasBit(GetRoadTypeInfo(roadtype)->flags, ROTF_CATENARY);
|
return HasBit(GetRoadTypeInfo(roadtype)->flags, ROTF_CATENARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@ static inline bool MayHaveRoad(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline RoadTileType GetRoadTileType(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);
|
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)
|
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);
|
if (rtt == RTT_TRAM) return (RoadBits)GB(_m[t].m3, 0, 4);
|
||||||
return (RoadBits)GB(_m[t].m5, 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)
|
static inline RoadType GetRoadTypeRoad(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(MayHaveRoad(t));
|
dbg_assert(MayHaveRoad(t));
|
||||||
return (RoadType)GB(_m[t].m4, 0, 6);
|
return (RoadType)GB(_m[t].m4, 0, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline RoadType GetRoadTypeTram(TileIndex t)
|
static inline RoadType GetRoadTypeTram(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(MayHaveRoad(t));
|
dbg_assert(MayHaveRoad(t));
|
||||||
return (RoadType)GB(_me[t].m8, 6, 6);
|
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)
|
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);
|
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
|
/* 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)
|
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);
|
return (GetRoadOwner(t, rtt) == o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ template <> struct EnumPropsT<DisallowedRoadDirections> : MakeEnumPropsT<Disallo
|
|||||||
*/
|
*/
|
||||||
static inline DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
|
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);
|
return (DisallowedRoadDirections)GB(_m[t].m5, 4, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ enum RoadCachedOneWayState {
|
|||||||
*/
|
*/
|
||||||
static inline RoadCachedOneWayState GetRoadCachedOneWayState(TileIndex t)
|
static inline RoadCachedOneWayState GetRoadCachedOneWayState(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(MayHaveRoad(t));
|
dbg_assert(MayHaveRoad(t));
|
||||||
return (RoadCachedOneWayState)GB(_me[t].m8, 12, 3);
|
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)
|
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);
|
return (Axis)GB(_m[t].m5, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,7 +388,7 @@ static inline Axis GetCrossingRoadAxis(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline Axis GetCrossingRailAxis(TileIndex t)
|
static inline Axis GetCrossingRailAxis(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(IsLevelCrossing(t), t);
|
dbg_assert_tile(IsLevelCrossing(t), t);
|
||||||
return OtherAxis((Axis)GetCrossingRoadAxis(t));
|
return OtherAxis((Axis)GetCrossingRoadAxis(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,7 +431,7 @@ static inline TrackBits GetCrossingRailBits(TileIndex tile)
|
|||||||
*/
|
*/
|
||||||
static inline bool HasCrossingReservation(TileIndex t)
|
static inline bool HasCrossingReservation(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(IsLevelCrossingTile(t), t);
|
dbg_assert_tile(IsLevelCrossingTile(t), t);
|
||||||
return HasBit(_m[t].m5, 4);
|
return HasBit(_m[t].m5, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,7 +467,7 @@ static inline TrackBits GetCrossingReservationTrackBits(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsCrossingBarred(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);
|
return HasBit(_m[t].m5, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,7 +491,7 @@ static inline void SetCrossingBarred(TileIndex t, bool barred)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsCrossingPossiblyOccupiedByRoadVehicle(TileIndex t)
|
static inline bool IsCrossingPossiblyOccupiedByRoadVehicle(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(IsLevelCrossing(t), t);
|
dbg_assert_tile(IsLevelCrossing(t), t);
|
||||||
return HasBit(_m[t].m5, 1);
|
return HasBit(_m[t].m5, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,7 +622,7 @@ static inline void TerminateRoadWorks(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline DiagDirection GetRoadDepotDirection(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);
|
return (DiagDirection)GB(_m[t].m5, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -91,7 +91,7 @@ struct RoadVehPathCache {
|
|||||||
|
|
||||||
inline size_t size() const
|
inline size_t size() const
|
||||||
{
|
{
|
||||||
assert(this->td.size() == this->tile.size());
|
dbg_assert(this->td.size() == this->tile.size());
|
||||||
return this->td.size();
|
return this->td.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,11 +61,11 @@ WaterClass GetEffectiveWaterClass(TileIndex tile)
|
|||||||
{
|
{
|
||||||
if (HasTileWaterClass(tile)) return GetWaterClass(tile);
|
if (HasTileWaterClass(tile)) return GetWaterClass(tile);
|
||||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||||
assert_tile(GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER, tile);
|
dbg_assert_tile(GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER, tile);
|
||||||
return WATER_CLASS_CANAL;
|
return WATER_CLASS_CANAL;
|
||||||
}
|
}
|
||||||
if (IsTileType(tile, MP_RAILWAY)) {
|
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;
|
return WATER_CLASS_SEA;
|
||||||
}
|
}
|
||||||
NOT_REACHED();
|
NOT_REACHED();
|
||||||
@@ -96,7 +96,7 @@ static void GetShipIcon(EngineID engine, EngineImageType image_type, VehicleSpri
|
|||||||
spritenum = e->original_image_index;
|
spritenum = e->original_image_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(IsValidImageIndex<VEH_SHIP>(spritenum));
|
dbg_assert(IsValidImageIndex<VEH_SHIP>(spritenum));
|
||||||
result->Set(DIR_W + _ship_sprites[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;
|
spritenum = this->GetEngine()->original_image_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(IsValidImageIndex<VEH_SHIP>(spritenum));
|
dbg_assert(IsValidImageIndex<VEH_SHIP>(spritenum));
|
||||||
result->Set(_ship_sprites[spritenum] + direction);
|
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)
|
static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
|
||||||
{
|
{
|
||||||
assert(IsValidDiagDirection(enterdir));
|
dbg_assert(IsValidDiagDirection(enterdir));
|
||||||
|
|
||||||
bool path_found = true;
|
bool path_found = true;
|
||||||
Track track;
|
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;
|
if ((v->x_pos & 0xF) != 8 || (v->y_pos & 0xF) != 8) return 0;
|
||||||
|
|
||||||
DiagDirection diagdir = GetInclinedSlopeDirection(GetTileSlope(v->tile));
|
DiagDirection diagdir = GetInclinedSlopeDirection(GetTileSlope(v->tile));
|
||||||
assert(IsValidDiagDirection(diagdir));
|
dbg_assert(IsValidDiagDirection(diagdir));
|
||||||
|
|
||||||
if (DirToDiagDir(v->direction) == diagdir) {
|
if (DirToDiagDir(v->direction) == diagdir) {
|
||||||
/* Move up */
|
/* Move up */
|
||||||
@@ -848,7 +848,7 @@ static bool ShipMoveUpDownOnLock(Ship *v)
|
|||||||
*/
|
*/
|
||||||
bool IsShipDestinationTile(TileIndex tile, StationID station)
|
bool IsShipDestinationTile(TileIndex tile, StationID station)
|
||||||
{
|
{
|
||||||
assert(IsDockingTile(tile));
|
dbg_assert(IsDockingTile(tile));
|
||||||
/* Check each tile adjacent to docking tile. */
|
/* Check each tile adjacent to docking tile. */
|
||||||
for (DiagDirection d = DIAGDIR_BEGIN; d != DIAGDIR_END; d++) {
|
for (DiagDirection d = DIAGDIR_BEGIN; d != DIAGDIR_END; d++) {
|
||||||
TileIndex t = tile + TileOffsByDiagDir(d);
|
TileIndex t = tile + TileOffsByDiagDir(d);
|
||||||
@@ -977,7 +977,7 @@ static void ShipController(Ship *v)
|
|||||||
if (!IsValidTile(gp.new_tile)) goto reverse_direction;
|
if (!IsValidTile(gp.new_tile)) goto reverse_direction;
|
||||||
|
|
||||||
DiagDirection diagdir = DiagdirBetweenTiles(gp.old_tile, gp.new_tile);
|
DiagDirection diagdir = DiagdirBetweenTiles(gp.old_tile, gp.new_tile);
|
||||||
assert(diagdir != INVALID_DIAGDIR);
|
dbg_assert(diagdir != INVALID_DIAGDIR);
|
||||||
tracks = GetAvailShipTracks(gp.new_tile, diagdir);
|
tracks = GetAvailShipTracks(gp.new_tile, diagdir);
|
||||||
if (tracks == TRACK_BIT_NONE) {
|
if (tracks == TRACK_BIT_NONE) {
|
||||||
Trackdir trackdir = INVALID_TRACKDIR;
|
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,
|
DIR_SW, DIR_NW, DIR_W, DIR_W, DIR_N, DIR_N, INVALID_DIR, INVALID_DIR,
|
||||||
};
|
};
|
||||||
v->direction = _trackdir_to_direction[trackdir];
|
v->direction = _trackdir_to_direction[trackdir];
|
||||||
assert(v->direction != INVALID_DIR);
|
dbg_assert(v->direction != INVALID_DIR);
|
||||||
v->state = TrackdirBitsToTrackBits(TrackdirToTrackdirBits(trackdir));
|
v->state = TrackdirBitsToTrackBits(TrackdirToTrackdirBits(trackdir));
|
||||||
goto direction_changed;
|
goto direction_changed;
|
||||||
}
|
}
|
||||||
|
@@ -75,7 +75,7 @@ static inline Slope RemoveHalftileSlope(Slope s)
|
|||||||
*/
|
*/
|
||||||
static inline Slope ComplementSlope(Slope s)
|
static inline Slope ComplementSlope(Slope s)
|
||||||
{
|
{
|
||||||
assert(!IsSteepSlope(s) && !IsHalftileSlope(s));
|
dbg_assert(!IsSteepSlope(s) && !IsHalftileSlope(s));
|
||||||
return s ^ SLOPE_ELEVATED;
|
return s ^ SLOPE_ELEVATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ static inline bool IsSlopeWithOneCornerRaised(Slope s)
|
|||||||
*/
|
*/
|
||||||
static inline Slope SlopeWithOneCornerRaised(Corner corner)
|
static inline Slope SlopeWithOneCornerRaised(Corner corner)
|
||||||
{
|
{
|
||||||
assert(IsValidCorner(corner));
|
dbg_assert(IsValidCorner(corner));
|
||||||
return (Slope)(1 << corner);
|
return (Slope)(1 << corner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ static inline Corner GetHighestSlopeCorner(Slope s)
|
|||||||
*/
|
*/
|
||||||
static inline Corner GetHalftileSlopeCorner(Slope s)
|
static inline Corner GetHalftileSlopeCorner(Slope s)
|
||||||
{
|
{
|
||||||
assert(IsHalftileSlope(s));
|
dbg_assert(IsHalftileSlope(s));
|
||||||
return (Corner)((s >> 6) & 3);
|
return (Corner)((s >> 6) & 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ static inline Slope InclinedSlope(DiagDirection dir)
|
|||||||
*/
|
*/
|
||||||
static inline Slope HalftileSlope(Slope s, Corner corner)
|
static inline Slope HalftileSlope(Slope s, Corner corner)
|
||||||
{
|
{
|
||||||
assert(IsValidCorner(corner));
|
dbg_assert(IsValidCorner(corner));
|
||||||
return (Slope)(s | SLOPE_HALFTILE | (corner << 6));
|
return (Slope)(s | SLOPE_HALFTILE | (corner << 6));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,7 +332,7 @@ static inline bool IsNonContinuousFoundation(Foundation f)
|
|||||||
*/
|
*/
|
||||||
static inline Corner GetHalftileFoundationCorner(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);
|
return (Corner)(f - FOUNDATION_HALFTILE_W);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +355,7 @@ static inline bool IsSpecialRailFoundation(Foundation f)
|
|||||||
*/
|
*/
|
||||||
static inline Corner GetRailFoundationCorner(Foundation f)
|
static inline Corner GetRailFoundationCorner(Foundation f)
|
||||||
{
|
{
|
||||||
assert(IsSpecialRailFoundation(f));
|
dbg_assert(IsSpecialRailFoundation(f));
|
||||||
return (Corner)(f - FOUNDATION_RAIL_W);
|
return (Corner)(f - FOUNDATION_RAIL_W);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,7 +390,7 @@ static inline Foundation InclinedFoundation(Axis axis)
|
|||||||
*/
|
*/
|
||||||
static inline Foundation HalftileFoundation(Corner corner)
|
static inline Foundation HalftileFoundation(Corner corner)
|
||||||
{
|
{
|
||||||
assert(IsValidCorner(corner));
|
dbg_assert(IsValidCorner(corner));
|
||||||
return (Foundation)(FOUNDATION_HALFTILE_W + corner);
|
return (Foundation)(FOUNDATION_HALFTILE_W + corner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +402,7 @@ static inline Foundation HalftileFoundation(Corner corner)
|
|||||||
*/
|
*/
|
||||||
static inline Foundation SpecialRailFoundation(Corner corner)
|
static inline Foundation SpecialRailFoundation(Corner corner)
|
||||||
{
|
{
|
||||||
assert(IsValidCorner(corner));
|
dbg_assert(IsValidCorner(corner));
|
||||||
return (Foundation)(FOUNDATION_RAIL_W + corner);
|
return (Foundation)(FOUNDATION_RAIL_W + corner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -297,7 +297,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool Sort()
|
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]);
|
return this->Sort(this->sort_func_list[this->sort_type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,13 +48,13 @@ uint GetMaxSpriteID();
|
|||||||
|
|
||||||
static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
|
static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
|
||||||
{
|
{
|
||||||
assert(type != ST_RECOLOUR);
|
dbg_assert(type != ST_RECOLOUR);
|
||||||
return (Sprite*)GetRawSprite(sprite, type);
|
return (Sprite*)GetRawSprite(sprite, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const byte *GetNonSprite(SpriteID sprite, SpriteType type)
|
static inline const byte *GetNonSprite(SpriteID sprite, SpriteType type)
|
||||||
{
|
{
|
||||||
assert(type == ST_RECOLOUR);
|
dbg_assert(type == ST_RECOLOUR);
|
||||||
return (byte*)GetRawSprite(sprite, type);
|
return (byte*)GetRawSprite(sprite, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -306,8 +306,8 @@ void Station::MarkTilesDirty(bool cargo_change) const
|
|||||||
{
|
{
|
||||||
TileIndex start_tile = tile;
|
TileIndex start_tile = tile;
|
||||||
uint length = 0;
|
uint length = 0;
|
||||||
assert_tile(IsRailStationTile(tile), tile);
|
dbg_assert_tile(IsRailStationTile(tile), tile);
|
||||||
assert(dir < DIAGDIR_END);
|
dbg_assert(dir < DIAGDIR_END);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
length++;
|
length++;
|
||||||
@@ -326,7 +326,7 @@ void Station::MarkTilesDirty(bool cargo_change) const
|
|||||||
*/
|
*/
|
||||||
static uint GetTileCatchmentRadius(TileIndex tile, const Station *st)
|
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;
|
const int32 inc = _settings_game.station.catchment_increase;
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@ uint Station::GetCatchmentRadius() const
|
|||||||
*/
|
*/
|
||||||
Rect Station::GetCatchmentRectUsingRadius(uint catchment_radius) const
|
Rect Station::GetCatchmentRectUsingRadius(uint catchment_radius) const
|
||||||
{
|
{
|
||||||
assert(!this->rect.IsEmpty());
|
dbg_assert(!this->rect.IsEmpty());
|
||||||
|
|
||||||
/* Compute acceptance rectangle */
|
/* Compute acceptance rectangle */
|
||||||
Rect ret = {
|
Rect ret = {
|
||||||
@@ -618,7 +618,7 @@ CommandCost StationRect::BeforeAddTile(TileIndex tile, StationRectMode mode)
|
|||||||
int w = new_rect.right - new_rect.left + 1;
|
int w = new_rect.right - new_rect.left + 1;
|
||||||
int h = new_rect.bottom - new_rect.top + 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)) {
|
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);
|
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)
|
bool StationRect::AfterRemoveRect(BaseStation *st, TileArea ta)
|
||||||
{
|
{
|
||||||
assert(this->PtInExtendedRect(TileX(ta.tile), TileY(ta.tile)));
|
dbg_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) + ta.w - 1, TileY(ta.tile) + ta.h - 1));
|
||||||
|
|
||||||
bool empty = this->AfterRemoveTile(st, ta.tile);
|
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));
|
if (ta.w != 1 || ta.h != 1) empty = empty || this->AfterRemoveTile(st, TILE_ADDXY(ta.tile, ta.w - 1, ta.h - 1));
|
||||||
|
@@ -27,7 +27,7 @@ typedef byte StationGfx; ///< Index of station graphics. @see _station_display_d
|
|||||||
*/
|
*/
|
||||||
static inline StationID GetStationIndex(TileIndex t)
|
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;
|
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)
|
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);
|
return (StationType)GB(_me[t].m6, 3, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ static inline StationType GetStationType(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline RoadStopType GetRoadStopType(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;
|
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)
|
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;
|
return _m[t].m5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ static inline StationGfx GetStationGfx(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void SetStationGfx(TileIndex t, StationGfx gfx)
|
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;
|
_m[t].m5 = gfx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ static inline bool IsRoadWaypointTile(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsStationRoadStop(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);
|
return IsTruckStop(t) || IsBusStop(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ static inline bool IsStationRoadStopTile(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsAnyRoadStop(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);
|
return IsTruckStop(t) || IsBusStop(t) || IsRoadWaypoint(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,7 +285,7 @@ static inline bool IsDriveThroughStopTile(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline DisallowedRoadDirections GetDriveThroughStopDisallowedRoadDirections(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);
|
return (DisallowedRoadDirections)GB(_m[t].m3, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,8 +296,8 @@ static inline DisallowedRoadDirections GetDriveThroughStopDisallowedRoadDirectio
|
|||||||
*/
|
*/
|
||||||
static inline void SetDriveThroughStopDisallowedRoadDirections(TileIndex t, DisallowedRoadDirections drd)
|
static inline void SetDriveThroughStopDisallowedRoadDirections(TileIndex t, DisallowedRoadDirections drd)
|
||||||
{
|
{
|
||||||
assert_tile(IsDriveThroughStopTile(t), t);
|
dbg_assert_tile(IsDriveThroughStopTile(t), t);
|
||||||
assert(drd < DRD_END);
|
dbg_assert(drd < DRD_END);
|
||||||
SB(_m[t].m3, 0, 2, drd);
|
SB(_m[t].m3, 0, 2, drd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ static inline void SetDriveThroughStopDisallowedRoadDirections(TileIndex t, Disa
|
|||||||
*/
|
*/
|
||||||
static inline Roadside GetRoadWaypointRoadside(TileIndex tile)
|
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);
|
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)
|
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);
|
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)
|
static inline bool IsRoadWaypointOnSnowOrDesert(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(IsRoadWaypointTile(t), t);
|
dbg_assert_tile(IsRoadWaypointTile(t), t);
|
||||||
return HasBit(_me[t].m8, 15);
|
return HasBit(_me[t].m8, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,7 +340,7 @@ static inline bool IsRoadWaypointOnSnowOrDesert(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void ToggleRoadWaypointOnSnowOrDesert(TileIndex t)
|
static inline void ToggleRoadWaypointOnSnowOrDesert(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(IsRoadWaypointTile(t), t);
|
dbg_assert_tile(IsRoadWaypointTile(t), t);
|
||||||
ToggleBit(_me[t].m8, 15);
|
ToggleBit(_me[t].m8, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ static inline void ToggleRoadWaypointOnSnowOrDesert(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline StationGfx GetAirportGfx(TileIndex t)
|
static inline StationGfx GetAirportGfx(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(IsAirport(t), t);
|
dbg_assert_tile(IsAirport(t), t);
|
||||||
extern StationGfx GetTranslatedAirportTileID(StationGfx gfx);
|
extern StationGfx GetTranslatedAirportTileID(StationGfx gfx);
|
||||||
return GetTranslatedAirportTileID(GetStationGfx(t));
|
return GetTranslatedAirportTileID(GetStationGfx(t));
|
||||||
}
|
}
|
||||||
@@ -366,7 +366,7 @@ static inline StationGfx GetAirportGfx(TileIndex t)
|
|||||||
static inline DiagDirection GetRoadStopDir(TileIndex t)
|
static inline DiagDirection GetRoadStopDir(TileIndex t)
|
||||||
{
|
{
|
||||||
StationGfx gfx = GetStationGfx(t);
|
StationGfx gfx = GetStationGfx(t);
|
||||||
assert_tile(IsAnyRoadStopTile(t), t);
|
dbg_assert_tile(IsAnyRoadStopTile(t), t);
|
||||||
if (gfx < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET) {
|
if (gfx < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET) {
|
||||||
return (DiagDirection)(gfx);
|
return (DiagDirection)(gfx);
|
||||||
} else {
|
} else {
|
||||||
@@ -445,7 +445,7 @@ static inline bool IsHangarTile(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline Axis GetRailStationAxis(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;
|
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)
|
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)) &&
|
return IsRailStationTile(test_tile) && IsCompatibleRail(GetRailType(test_tile), GetRailType(station_tile)) &&
|
||||||
GetRailStationAxis(test_tile) == GetRailStationAxis(station_tile) &&
|
GetRailStationAxis(test_tile) == GetRailStationAxis(station_tile) &&
|
||||||
GetStationIndex(test_tile) == GetStationIndex(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)
|
static inline bool HasStationReservation(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(HasStationRail(t), t);
|
dbg_assert_tile(HasStationRail(t), t);
|
||||||
return HasBit(_me[t].m6, 2);
|
return HasBit(_me[t].m6, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,7 +513,7 @@ static inline bool HasStationReservation(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void SetRailStationReservation(TileIndex t, bool b)
|
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);
|
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)
|
static inline DiagDirection GetDockDirection(TileIndex t)
|
||||||
{
|
{
|
||||||
StationGfx gfx = GetStationGfx(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);
|
return (DiagDirection)(gfx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,12 +559,12 @@ static inline TileIndexDiffC GetDockOffset(TileIndex t)
|
|||||||
{ 2, 0},
|
{ 2, 0},
|
||||||
{ 0, -2},
|
{ 0, -2},
|
||||||
};
|
};
|
||||||
assert_tile(IsTileType(t, MP_STATION), t);
|
dbg_assert_tile(IsTileType(t, MP_STATION), t);
|
||||||
|
|
||||||
if (IsBuoy(t)) return buoy_offset;
|
if (IsBuoy(t)) return buoy_offset;
|
||||||
if (IsOilRig(t)) return oilrig_offset;
|
if (IsOilRig(t)) return oilrig_offset;
|
||||||
|
|
||||||
assert_tile(IsDock(t), t);
|
dbg_assert_tile(IsDock(t), t);
|
||||||
|
|
||||||
return dock_offset[GetDockDirection(t)];
|
return dock_offset[GetDockDirection(t)];
|
||||||
}
|
}
|
||||||
@@ -577,7 +577,7 @@ static inline TileIndexDiffC GetDockOffset(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsCustomStationSpecIndex(TileIndex t)
|
static inline bool IsCustomStationSpecIndex(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(HasStationTileRail(t), t);
|
dbg_assert_tile(HasStationTileRail(t), t);
|
||||||
return _m[t].m4 != 0;
|
return _m[t].m4 != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,7 +589,7 @@ static inline bool IsCustomStationSpecIndex(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void SetCustomStationSpecIndex(TileIndex t, byte specindex)
|
static inline void SetCustomStationSpecIndex(TileIndex t, byte specindex)
|
||||||
{
|
{
|
||||||
assert_tile(HasStationTileRail(t), t);
|
dbg_assert_tile(HasStationTileRail(t), t);
|
||||||
_m[t].m4 = specindex;
|
_m[t].m4 = specindex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -601,7 +601,7 @@ static inline void SetCustomStationSpecIndex(TileIndex t, byte specindex)
|
|||||||
*/
|
*/
|
||||||
static inline uint GetCustomStationSpecIndex(TileIndex t)
|
static inline uint GetCustomStationSpecIndex(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(HasStationTileRail(t), t);
|
dbg_assert_tile(HasStationTileRail(t), t);
|
||||||
return _m[t].m4;
|
return _m[t].m4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -613,7 +613,7 @@ static inline uint GetCustomStationSpecIndex(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsCustomRoadStopSpecIndex(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;
|
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)
|
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);
|
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)
|
static inline uint GetCustomRoadStopSpecIndex(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(IsAnyRoadStopTile(t), t);
|
dbg_assert_tile(IsAnyRoadStopTile(t), t);
|
||||||
return GB(_me[t].m8, 0, 6);
|
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)
|
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);
|
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)
|
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);
|
return GB(_m[t].m3, 4, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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)
|
char *strecat(char *dst, const char *src, const char *last)
|
||||||
{
|
{
|
||||||
assert(dst <= last);
|
dbg_assert(dst <= last);
|
||||||
while (*dst != '\0') {
|
while (*dst != '\0') {
|
||||||
if (dst == last) return dst;
|
if (dst == last) return dst;
|
||||||
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)
|
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') {
|
while (dst != last && *src != '\0') {
|
||||||
*dst++ = *src++;
|
*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)
|
size_t Utf8Decode(WChar *c, const char *s)
|
||||||
{
|
{
|
||||||
assert(c != nullptr);
|
dbg_assert(c != nullptr);
|
||||||
|
|
||||||
if (!HasBit(s[0], 7)) {
|
if (!HasBit(s[0], 7)) {
|
||||||
/* Single byte character: 0xxxxxxx */
|
/* Single byte character: 0xxxxxxx */
|
||||||
@@ -1072,7 +1072,7 @@ public:
|
|||||||
|
|
||||||
virtual size_t SetCurPosition(size_t pos)
|
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. */
|
/* Sanitize in case we get a position inside an UTF-8 sequence. */
|
||||||
while (pos > 0 && IsUtf8Part(this->string[pos])) pos--;
|
while (pos > 0 && IsUtf8Part(this->string[pos])) pos--;
|
||||||
return this->cur_pos = pos;
|
return this->cur_pos = pos;
|
||||||
@@ -1080,7 +1080,7 @@ public:
|
|||||||
|
|
||||||
virtual size_t Next(IterType what)
|
virtual size_t Next(IterType what)
|
||||||
{
|
{
|
||||||
assert(this->string != nullptr);
|
dbg_assert(this->string != nullptr);
|
||||||
|
|
||||||
/* Already at the end? */
|
/* Already at the end? */
|
||||||
if (this->cur_pos >= this->len) return END;
|
if (this->cur_pos >= this->len) return END;
|
||||||
@@ -1118,7 +1118,7 @@ public:
|
|||||||
|
|
||||||
virtual size_t Prev(IterType what)
|
virtual size_t Prev(IterType what)
|
||||||
{
|
{
|
||||||
assert(this->string != nullptr);
|
dbg_assert(this->string != nullptr);
|
||||||
|
|
||||||
/* Already at the beginning? */
|
/* Already at the beginning? */
|
||||||
if (this->cur_pos == 0) return END;
|
if (this->cur_pos == 0) return END;
|
||||||
|
@@ -655,13 +655,13 @@ static void HeightMapCurves(uint level)
|
|||||||
|
|
||||||
if (*h >= p1.x && *h < p2.x) {
|
if (*h >= p1.x && *h < p2.x) {
|
||||||
ht[t] = p1.y + (*h - p1.x) * (p2.y - p1.y) / (p2.x - p1.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;
|
found = true;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(found);
|
dbg_assert(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Apply interpolation of curve map results. */
|
/* Apply interpolation of curve map results. */
|
||||||
|
@@ -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 */
|
/* this method is inlined in many places and is performance-critical, drop assertion in non-debug builds */
|
||||||
#ifdef _DEBUG
|
#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
|
#endif
|
||||||
return _m[tile].height;
|
return _m[tile].height;
|
||||||
}
|
}
|
||||||
@@ -59,8 +59,8 @@ static inline uint TileHeightOutsideMap(int x, int y)
|
|||||||
*/
|
*/
|
||||||
static inline void SetTileHeight(TileIndex tile, uint height)
|
static inline void SetTileHeight(TileIndex tile, uint height)
|
||||||
{
|
{
|
||||||
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());
|
||||||
assert(height <= MAX_TILE_HEIGHT);
|
dbg_assert(height <= MAX_TILE_HEIGHT);
|
||||||
_m[tile].height = 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 */
|
/* this method is inlined in many places and is performance-critical, drop assertion in non-debug builds */
|
||||||
#ifdef _DEBUG
|
#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
|
#endif
|
||||||
return (TileType)GB(_m[tile].type, 4, 4);
|
return (TileType)GB(_m[tile].type, 4, 4);
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ static inline TileType GetTileType(TileIndex tile)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsInnerTile(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 x = TileX(tile);
|
||||||
uint y = TileY(tile);
|
uint y = TileY(tile);
|
||||||
@@ -136,11 +136,11 @@ static inline bool IsInnerTile(TileIndex tile)
|
|||||||
*/
|
*/
|
||||||
static inline void SetTileType(TileIndex tile, TileType type)
|
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
|
/* 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,
|
* edges of the map. If _settings_game.construction.freeform_edges is true,
|
||||||
* the upper edges of the map are also VOID tiles. */
|
* 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);
|
SB(_m[tile].type, 4, 4, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,8 +183,8 @@ static inline bool IsValidTile(TileIndex tile)
|
|||||||
*/
|
*/
|
||||||
static inline Owner GetTileOwner(TileIndex tile)
|
static inline Owner GetTileOwner(TileIndex tile)
|
||||||
{
|
{
|
||||||
assert_msg(IsValidTile(tile), "tile: 0x%X, size: 0x%X", tile, MapSize());
|
dbg_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(!IsTileType(tile, MP_HOUSE) && !IsTileType(tile, MP_INDUSTRY), "tile: 0x%X (%d)", tile, GetTileType(tile));
|
||||||
|
|
||||||
return (Owner)GB(_m[tile].m1, 0, 5);
|
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)
|
static inline void SetTileOwner(TileIndex tile, Owner owner)
|
||||||
{
|
{
|
||||||
assert_msg(IsValidTile(tile), "tile: 0x%X, size: 0x%X, owner: %d", tile, MapSize(), owner);
|
dbg_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(!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);
|
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)
|
static inline void SetTropicZone(TileIndex tile, TropicZone 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);
|
||||||
assert_msg(!IsTileType(tile, MP_VOID) || type == TROPICZONE_NORMAL, "tile: 0x%X (%d), type: %d", tile, GetTileType(tile), 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);
|
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)
|
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);
|
return (TropicZone)GB(_m[tile].type, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ static inline TropicZone GetTropicZone(TileIndex tile)
|
|||||||
*/
|
*/
|
||||||
static inline byte GetAnimationFrame(TileIndex t)
|
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;
|
return _me[t].m7;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ static inline byte GetAnimationFrame(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void SetAnimationFrame(TileIndex t, byte frame)
|
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;
|
_me[t].m7 = frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,8 +20,8 @@
|
|||||||
*/
|
*/
|
||||||
OrthogonalTileArea::OrthogonalTileArea(TileIndex start, TileIndex end)
|
OrthogonalTileArea::OrthogonalTileArea(TileIndex start, TileIndex end)
|
||||||
{
|
{
|
||||||
assert(start < MapSize());
|
dbg_assert(start < MapSize());
|
||||||
assert(end < MapSize());
|
dbg_assert(end < MapSize());
|
||||||
|
|
||||||
uint sx = TileX(start);
|
uint sx = TileX(start);
|
||||||
uint sy = TileY(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;
|
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 left1 = TileX(this->tile);
|
||||||
uint top1 = TileY(this->tile);
|
uint top1 = TileY(this->tile);
|
||||||
@@ -105,7 +105,7 @@ bool OrthogonalTileArea::Contains(TileIndex tile) const
|
|||||||
{
|
{
|
||||||
if (this->w == 0) return false;
|
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 left = TileX(this->tile);
|
||||||
uint top = TileY(this->tile);
|
uint top = TileY(this->tile);
|
||||||
@@ -141,7 +141,7 @@ OrthogonalTileArea &OrthogonalTileArea::Expand(int rad)
|
|||||||
*/
|
*/
|
||||||
void OrthogonalTileArea::ClampToMap()
|
void OrthogonalTileArea::ClampToMap()
|
||||||
{
|
{
|
||||||
assert(this->tile < MapSize());
|
dbg_assert(this->tile < MapSize());
|
||||||
this->w = std::min<int>(this->w, MapSizeX() - TileX(this->tile));
|
this->w = std::min<int>(this->w, MapSizeX() - TileX(this->tile));
|
||||||
this->h = std::min<int>(this->h, MapSizeY() - TileY(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)
|
DiagonalTileArea::DiagonalTileArea(TileIndex start, TileIndex end) : tile(start)
|
||||||
{
|
{
|
||||||
assert(start < MapSize());
|
dbg_assert(start < MapSize());
|
||||||
assert(end < MapSize());
|
dbg_assert(end < MapSize());
|
||||||
|
|
||||||
/* Unfortunately we can't find a new base and make all a and b positive because
|
/* 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
|
* 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++()
|
TileIterator &DiagonalTileIterator::operator++()
|
||||||
{
|
{
|
||||||
assert(this->tile != INVALID_TILE);
|
dbg_assert(this->tile != INVALID_TILE);
|
||||||
|
|
||||||
/* Determine the next tile, while clipping at map borders */
|
/* Determine the next tile, while clipping at map borders */
|
||||||
bool new_line = false;
|
bool new_line = false;
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
static inline TownID GetTownIndex(TileIndex t)
|
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;
|
return _m[t].m2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ static inline TownID GetTownIndex(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void SetTownIndex(TileIndex t, TownID index)
|
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;
|
_m[t].m2 = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ static inline void SetTownIndex(TileIndex t, TownID index)
|
|||||||
*/
|
*/
|
||||||
static inline HouseID GetCleanHouseType(TileIndex t)
|
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);
|
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)
|
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);
|
_m[t].m4 = GB(house_id, 0, 8);
|
||||||
SB(_m[t].m3, 5, 2, GB(house_id, 8, 2));
|
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)
|
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);
|
return HasBit(_m[t].m3, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ static inline bool IsHouseCompleted(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void SetHouseCompleted(TileIndex t, bool status)
|
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);
|
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)
|
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);
|
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)
|
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);
|
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)
|
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);
|
AB(_m[t].m5, 0, 5, 1);
|
||||||
|
|
||||||
if (GB(_m[t].m5, 3, 2) == TOWN_HOUSE_COMPLETED) {
|
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)
|
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;
|
_m[t].m5 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ static inline void ResetHouseAge(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void IncrementHouseAge(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++;
|
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)
|
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;
|
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)
|
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;
|
_m[t].m1 = random;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +274,7 @@ static inline void SetHouseRandomBits(TileIndex t, byte random)
|
|||||||
*/
|
*/
|
||||||
static inline byte GetHouseRandomBits(TileIndex t)
|
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;
|
return _m[t].m1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +287,7 @@ static inline byte GetHouseRandomBits(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void SetHouseTriggers(TileIndex t, byte triggers)
|
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);
|
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)
|
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);
|
return GB(_m[t].m3, 0, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ static inline byte GetHouseTriggers(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline byte GetHouseProcessingTime(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);
|
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)
|
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);
|
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)
|
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;
|
_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)
|
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);
|
SetTileType(t, MP_HOUSE);
|
||||||
_m[t].m1 = random_bits;
|
_m[t].m1 = random_bits;
|
||||||
|
@@ -22,7 +22,7 @@ using SetTrackBitIterator = SetBitIterator<Track, TrackBits>;
|
|||||||
*
|
*
|
||||||
* @param track The value to check
|
* @param track The value to check
|
||||||
* @return true if the given value is a valid track.
|
* @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)
|
static inline bool IsValidTrack(Track track)
|
||||||
{
|
{
|
||||||
@@ -34,7 +34,7 @@ static inline bool IsValidTrack(Track track)
|
|||||||
*
|
*
|
||||||
* @param trackdir The value to check
|
* @param trackdir The value to check
|
||||||
* @return true if the given value is a valid Trackdir
|
* @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)
|
static inline bool IsValidTrackdirForRoadVehicle(Trackdir trackdir)
|
||||||
{
|
{
|
||||||
@@ -46,7 +46,7 @@ static inline bool IsValidTrackdirForRoadVehicle(Trackdir trackdir)
|
|||||||
*
|
*
|
||||||
* @param trackdir The value to check
|
* @param trackdir The value to check
|
||||||
* @return true if the given value is a valid Trackdir
|
* @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)
|
static inline bool IsValidTrackdir(Trackdir trackdir)
|
||||||
{
|
{
|
||||||
@@ -64,7 +64,7 @@ static inline bool IsValidTrackdir(Trackdir trackdir)
|
|||||||
*/
|
*/
|
||||||
static inline Track AxisToTrack(Axis a)
|
static inline Track AxisToTrack(Axis a)
|
||||||
{
|
{
|
||||||
assert(IsValidAxis(a));
|
dbg_assert(IsValidAxis(a));
|
||||||
return (Track)a;
|
return (Track)a;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ static inline Track AxisToTrack(Axis a)
|
|||||||
*/
|
*/
|
||||||
static inline TrackBits TrackToTrackBits(Track track)
|
static inline TrackBits TrackToTrackBits(Track track)
|
||||||
{
|
{
|
||||||
assert(IsValidTrack(track));
|
dbg_assert(IsValidTrack(track));
|
||||||
return (TrackBits)(1 << track);
|
return (TrackBits)(1 << track);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ static inline TrackBits AxisToTrackBits(Axis a)
|
|||||||
static inline TrackBits CornerToTrackBits(Corner corner)
|
static inline TrackBits CornerToTrackBits(Corner corner)
|
||||||
{
|
{
|
||||||
extern const TrackBits _corner_to_trackbits[];
|
extern const TrackBits _corner_to_trackbits[];
|
||||||
assert(IsValidCorner(corner));
|
dbg_assert(IsValidCorner(corner));
|
||||||
return _corner_to_trackbits[corner];
|
return _corner_to_trackbits[corner];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ static inline TrackBits CornerToTrackBits(Corner corner)
|
|||||||
*/
|
*/
|
||||||
static inline TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir)
|
static inline TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdir(trackdir));
|
dbg_assert(IsValidTrackdir(trackdir));
|
||||||
return (TrackdirBits)(1 << trackdir);
|
return (TrackdirBits)(1 << trackdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ static inline TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir)
|
|||||||
static inline Track RemoveFirstTrack(TrackBits *tracks)
|
static inline Track RemoveFirstTrack(TrackBits *tracks)
|
||||||
{
|
{
|
||||||
if (*tracks != TRACK_BIT_NONE && *tracks != INVALID_TRACK_BIT) {
|
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);
|
Track first = (Track)FIND_FIRST_BIT(*tracks);
|
||||||
ClrBit(*tracks, first);
|
ClrBit(*tracks, first);
|
||||||
return first;
|
return first;
|
||||||
@@ -155,7 +155,7 @@ static inline Track RemoveFirstTrack(TrackBits *tracks)
|
|||||||
static inline Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs)
|
static inline Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs)
|
||||||
{
|
{
|
||||||
if (*trackdirs != TRACKDIR_BIT_NONE && *trackdirs != INVALID_TRACKDIR_BIT) {
|
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);
|
Trackdir first = (Trackdir)FindFirstBit2x64(*trackdirs);
|
||||||
ClrBit(*trackdirs, first);
|
ClrBit(*trackdirs, first);
|
||||||
return first;
|
return first;
|
||||||
@@ -191,7 +191,7 @@ static inline Track FindFirstTrack(TrackBits tracks)
|
|||||||
*/
|
*/
|
||||||
static inline Track TrackBitsToTrack(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;
|
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)
|
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;
|
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)
|
static inline Track TrackToOppositeTrack(Track t)
|
||||||
{
|
{
|
||||||
assert(IsValidTrack(t));
|
dbg_assert(IsValidTrack(t));
|
||||||
return (Track)(t ^ 1);
|
return (Track)(t ^ 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +245,7 @@ static inline Track TrackToOppositeTrack(Track t)
|
|||||||
*/
|
*/
|
||||||
static inline Trackdir ReverseTrackdir(Trackdir trackdir)
|
static inline Trackdir ReverseTrackdir(Trackdir trackdir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdirForRoadVehicle(trackdir));
|
dbg_assert(IsValidTrackdirForRoadVehicle(trackdir));
|
||||||
return (Trackdir)(trackdir ^ 8);
|
return (Trackdir)(trackdir ^ 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ static inline Trackdir ReverseTrackdir(Trackdir trackdir)
|
|||||||
*/
|
*/
|
||||||
static inline Track TrackdirToTrack(Trackdir trackdir)
|
static inline Track TrackdirToTrack(Trackdir trackdir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdir(trackdir));
|
dbg_assert(IsValidTrackdir(trackdir));
|
||||||
return (Track)(trackdir & 0x7);
|
return (Track)(trackdir & 0x7);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ static inline Track TrackdirToTrack(Trackdir trackdir)
|
|||||||
*/
|
*/
|
||||||
static inline Trackdir TrackToTrackdir(Track track)
|
static inline Trackdir TrackToTrackdir(Track track)
|
||||||
{
|
{
|
||||||
assert(IsValidTrack(track));
|
dbg_assert(IsValidTrack(track));
|
||||||
return (Trackdir)track;
|
return (Trackdir)track;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ static inline TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
|
|||||||
*/
|
*/
|
||||||
static inline bool HasTrack(TrackBits tracks, Track track)
|
static inline bool HasTrack(TrackBits tracks, Track track)
|
||||||
{
|
{
|
||||||
assert(IsValidTrack(track));
|
dbg_assert(IsValidTrack(track));
|
||||||
return HasBit(tracks, 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)
|
static inline bool HasTrackdir(TrackdirBits trackdirs, Trackdir trackdir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdir(trackdir));
|
dbg_assert(IsValidTrackdir(trackdir));
|
||||||
return HasBit(trackdirs, trackdir);
|
return HasBit(trackdirs, trackdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,7 +401,7 @@ static inline TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, Trackdir
|
|||||||
*/
|
*/
|
||||||
static inline Trackdir NextTrackdir(Trackdir trackdir)
|
static inline Trackdir NextTrackdir(Trackdir trackdir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdir(trackdir));
|
dbg_assert(IsValidTrackdir(trackdir));
|
||||||
extern const Trackdir _next_trackdir[TRACKDIR_END];
|
extern const Trackdir _next_trackdir[TRACKDIR_END];
|
||||||
return _next_trackdir[trackdir];
|
return _next_trackdir[trackdir];
|
||||||
}
|
}
|
||||||
@@ -418,7 +418,7 @@ static inline Trackdir NextTrackdir(Trackdir trackdir)
|
|||||||
*/
|
*/
|
||||||
static inline TrackBits TrackCrossesTracks(Track track)
|
static inline TrackBits TrackCrossesTracks(Track track)
|
||||||
{
|
{
|
||||||
assert(IsValidTrack(track));
|
dbg_assert(IsValidTrack(track));
|
||||||
extern const TrackBits _track_crosses_tracks[TRACK_END];
|
extern const TrackBits _track_crosses_tracks[TRACK_END];
|
||||||
return _track_crosses_tracks[track];
|
return _track_crosses_tracks[track];
|
||||||
}
|
}
|
||||||
@@ -437,7 +437,7 @@ static inline TrackBits TrackCrossesTracks(Track track)
|
|||||||
*/
|
*/
|
||||||
static inline DiagDirection TrackdirToExitdir(Trackdir trackdir)
|
static inline DiagDirection TrackdirToExitdir(Trackdir trackdir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdirForRoadVehicle(trackdir));
|
dbg_assert(IsValidTrackdirForRoadVehicle(trackdir));
|
||||||
extern const DiagDirection _trackdir_to_exitdir[TRACKDIR_END];
|
extern const DiagDirection _trackdir_to_exitdir[TRACKDIR_END];
|
||||||
return _trackdir_to_exitdir[trackdir];
|
return _trackdir_to_exitdir[trackdir];
|
||||||
}
|
}
|
||||||
@@ -459,8 +459,8 @@ static inline DiagDirection TrackdirToExitdir(Trackdir trackdir)
|
|||||||
*/
|
*/
|
||||||
static inline Trackdir TrackExitdirToTrackdir(Track track, DiagDirection diagdir)
|
static inline Trackdir TrackExitdirToTrackdir(Track track, DiagDirection diagdir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrack(track));
|
dbg_assert(IsValidTrack(track));
|
||||||
assert(IsValidDiagDirection(diagdir));
|
dbg_assert(IsValidDiagDirection(diagdir));
|
||||||
extern const Trackdir _track_exitdir_to_trackdir[TRACK_END][DIAGDIR_END];
|
extern const Trackdir _track_exitdir_to_trackdir[TRACK_END][DIAGDIR_END];
|
||||||
return _track_exitdir_to_trackdir[track][diagdir];
|
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)
|
static inline Trackdir TrackEnterdirToTrackdir(Track track, DiagDirection diagdir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrack(track));
|
dbg_assert(IsValidTrack(track));
|
||||||
assert(IsValidDiagDirection(diagdir));
|
dbg_assert(IsValidDiagDirection(diagdir));
|
||||||
extern const Trackdir _track_enterdir_to_trackdir[TRACK_END][DIAGDIR_END];
|
extern const Trackdir _track_enterdir_to_trackdir[TRACK_END][DIAGDIR_END];
|
||||||
return _track_enterdir_to_trackdir[track][diagdir];
|
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)
|
static inline Trackdir TrackDirectionToTrackdir(Track track, Direction dir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrack(track));
|
dbg_assert(IsValidTrack(track));
|
||||||
assert(IsValidDirection(dir));
|
dbg_assert(IsValidDirection(dir));
|
||||||
extern const Trackdir _track_direction_to_trackdir[TRACK_END][DIR_END];
|
extern const Trackdir _track_direction_to_trackdir[TRACK_END][DIR_END];
|
||||||
return _track_direction_to_trackdir[track][dir];
|
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)
|
static inline Track DiagDirToDiagTrack(DiagDirection diagdir)
|
||||||
{
|
{
|
||||||
assert(IsValidDiagDirection(diagdir));
|
dbg_assert(IsValidDiagDirection(diagdir));
|
||||||
return (Track)(diagdir & 1);
|
return (Track)(diagdir & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,7 +522,7 @@ static inline Track DiagDirToDiagTrack(DiagDirection diagdir)
|
|||||||
*/
|
*/
|
||||||
static inline TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
|
static inline TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
|
||||||
{
|
{
|
||||||
assert(IsValidDiagDirection(diagdir));
|
dbg_assert(IsValidDiagDirection(diagdir));
|
||||||
return TrackToTrackBits(DiagDirToDiagTrack(diagdir));
|
return TrackToTrackBits(DiagDirToDiagTrack(diagdir));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,7 +535,7 @@ static inline TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
|
|||||||
*/
|
*/
|
||||||
static inline Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
|
static inline Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
|
||||||
{
|
{
|
||||||
assert(IsValidDiagDirection(diagdir));
|
dbg_assert(IsValidDiagDirection(diagdir));
|
||||||
extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END];
|
extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END];
|
||||||
return _dir_to_diag_trackdir[diagdir];
|
return _dir_to_diag_trackdir[diagdir];
|
||||||
}
|
}
|
||||||
@@ -553,7 +553,7 @@ static inline Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
|
|||||||
*/
|
*/
|
||||||
static inline TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir)
|
static inline TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir)
|
||||||
{
|
{
|
||||||
assert(IsValidDiagDirection(diagdir));
|
dbg_assert(IsValidDiagDirection(diagdir));
|
||||||
extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END];
|
extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END];
|
||||||
return _exitdir_reaches_trackdirs[diagdir];
|
return _exitdir_reaches_trackdirs[diagdir];
|
||||||
}
|
}
|
||||||
@@ -582,7 +582,7 @@ static inline TrackBits DiagdirReachesTracks(DiagDirection diagdir) { return Tra
|
|||||||
*/
|
*/
|
||||||
static inline TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir)
|
static inline TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdir(trackdir));
|
dbg_assert(IsValidTrackdir(trackdir));
|
||||||
extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END];
|
extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END];
|
||||||
return _exitdir_reaches_trackdirs[TrackdirToExitdir(trackdir)];
|
return _exitdir_reaches_trackdirs[TrackdirToExitdir(trackdir)];
|
||||||
}
|
}
|
||||||
@@ -604,7 +604,7 @@ static inline TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir)
|
|||||||
*/
|
*/
|
||||||
static inline TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
|
static inline TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdirForRoadVehicle(trackdir));
|
dbg_assert(IsValidTrackdirForRoadVehicle(trackdir));
|
||||||
extern const TrackdirBits _track_crosses_trackdirs[TRACK_END];
|
extern const TrackdirBits _track_crosses_trackdirs[TRACK_END];
|
||||||
return _track_crosses_trackdirs[TrackdirToTrack(trackdir)];
|
return _track_crosses_trackdirs[TrackdirToTrack(trackdir)];
|
||||||
}
|
}
|
||||||
@@ -617,7 +617,7 @@ static inline TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsDiagonalTrack(Track track)
|
static inline bool IsDiagonalTrack(Track track)
|
||||||
{
|
{
|
||||||
assert(IsValidTrack(track));
|
dbg_assert(IsValidTrack(track));
|
||||||
return (track == TRACK_X) || (track == TRACK_Y);
|
return (track == TRACK_X) || (track == TRACK_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,7 +629,7 @@ static inline bool IsDiagonalTrack(Track track)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsDiagonalTrackdir(Trackdir trackdir)
|
static inline bool IsDiagonalTrackdir(Trackdir trackdir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdir(trackdir));
|
dbg_assert(IsValidTrackdir(trackdir));
|
||||||
return IsDiagonalTrack(TrackdirToTrack(trackdir));
|
return IsDiagonalTrack(TrackdirToTrack(trackdir));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -671,7 +671,7 @@ static inline bool TrackOverlapsTracks(TrackBits tracks, Track track)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsReversingRoadTrackdir(Trackdir dir)
|
static inline bool IsReversingRoadTrackdir(Trackdir dir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdirForRoadVehicle(dir));
|
dbg_assert(IsValidTrackdirForRoadVehicle(dir));
|
||||||
return (dir & 0x07) >= 6;
|
return (dir & 0x07) >= 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -682,7 +682,7 @@ static inline bool IsReversingRoadTrackdir(Trackdir dir)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsStraightRoadTrackdir(Trackdir dir)
|
static inline bool IsStraightRoadTrackdir(Trackdir dir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdirForRoadVehicle(dir));
|
dbg_assert(IsValidTrackdirForRoadVehicle(dir));
|
||||||
return (dir & 0x06) == 0;
|
return (dir & 0x06) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -698,7 +698,7 @@ static inline bool IsStraightRoadTrackdir(Trackdir dir)
|
|||||||
*/
|
*/
|
||||||
static inline bool IsUphillTrackdir(Slope slope, Trackdir dir)
|
static inline bool IsUphillTrackdir(Slope slope, Trackdir dir)
|
||||||
{
|
{
|
||||||
assert(IsValidTrackdirForRoadVehicle(dir));
|
dbg_assert(IsValidTrackdirForRoadVehicle(dir));
|
||||||
extern const TrackdirBits _uphill_trackdirs[];
|
extern const TrackdirBits _uphill_trackdirs[];
|
||||||
return HasBit(_uphill_trackdirs[RemoveHalftileSlope(slope)], dir);
|
return HasBit(_uphill_trackdirs[RemoveHalftileSlope(slope)], dir);
|
||||||
}
|
}
|
||||||
|
@@ -205,7 +205,7 @@ void CheckTrainsLengths()
|
|||||||
*/
|
*/
|
||||||
void CheckBreakdownFlags(Train *v)
|
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) */
|
/* 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);
|
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;
|
uint16 max_speed = UINT16_MAX;
|
||||||
|
|
||||||
assert(this->IsFrontEngine() || this->IsFreeWagon());
|
dbg_assert(this->IsFrontEngine() || this->IsFreeWagon());
|
||||||
|
|
||||||
const RailVehicleInfo *rvi_v = RailVehInfo(this->engine_type);
|
const RailVehicleInfo *rvi_v = RailVehInfo(this->engine_type);
|
||||||
EngineID first_engine = this->IsFrontEngine() ? this->engine_type : INVALID_ENGINE;
|
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);
|
const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type);
|
||||||
|
|
||||||
/* Check the this->first cache. */
|
/* 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));
|
scope_dumper().VehicleInfo(u), scope_dumper().VehicleInfo(this));
|
||||||
|
|
||||||
/* update the 'first engine' */
|
/* update the 'first engine' */
|
||||||
@@ -613,7 +613,7 @@ int GetTrainStopLocation(StationID station_id, TileIndex tile, Train *v, bool up
|
|||||||
*/
|
*/
|
||||||
int Train::GetCurveSpeedLimit() const
|
int Train::GetCurveSpeedLimit() const
|
||||||
{
|
{
|
||||||
assert(this->First() == this);
|
dbg_assert(this->First() == this);
|
||||||
|
|
||||||
static const int absolute_max_speed = UINT16_MAX;
|
static const int absolute_max_speed = UINT16_MAX;
|
||||||
int max_speed = absolute_max_speed;
|
int max_speed = absolute_max_speed;
|
||||||
@@ -690,7 +690,7 @@ void AdvanceOrderIndex(const Vehicle *v, VehicleOrderID &index)
|
|||||||
if (index >= v->GetNumOrders()) index = 0;
|
if (index >= v->GetNumOrders()) index = 0;
|
||||||
|
|
||||||
Order *order = v->GetOrder(index);
|
Order *order = v->GetOrder(index);
|
||||||
assert(order != nullptr);
|
dbg_assert(order != nullptr);
|
||||||
|
|
||||||
switch (order->GetType()) {
|
switch (order->GetType()) {
|
||||||
case OT_GOTO_DEPOT:
|
case OT_GOTO_DEPOT:
|
||||||
@@ -1157,7 +1157,7 @@ uint32 Train::CalculateOverallZPos() const
|
|||||||
/** Update acceleration of the train from the cached power and weight. */
|
/** Update acceleration of the train from the cached power and weight. */
|
||||||
void Train::UpdateAcceleration()
|
void Train::UpdateAcceleration()
|
||||||
{
|
{
|
||||||
assert(this->IsFrontEngine() || this->IsFreeWagon());
|
dbg_assert(this->IsFrontEngine() || this->IsFreeWagon());
|
||||||
|
|
||||||
uint power = this->gcache.cached_power;
|
uint power = this->gcache.cached_power;
|
||||||
uint weight = this->gcache.cached_weight;
|
uint weight = this->gcache.cached_weight;
|
||||||
@@ -1285,7 +1285,7 @@ int Train::GetDisplayImageWidth(Point *offset) const
|
|||||||
|
|
||||||
static SpriteID GetDefaultTrainSprite(uint8 spritenum, Direction direction)
|
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];
|
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;
|
spritenum = this->GetEngine()->original_image_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(IsValidImageIndex<VEH_TRAIN>(spritenum));
|
dbg_assert(IsValidImageIndex<VEH_TRAIN>(spritenum));
|
||||||
SpriteID sprite = GetDefaultTrainSprite(spritenum, direction);
|
SpriteID sprite = GetDefaultTrainSprite(spritenum, direction);
|
||||||
|
|
||||||
if (this->cargo.StoredCount() >= this->cargo_cap / 2U) sprite += _wagon_full_adder[spritenum];
|
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)
|
static bool TrainApproachingCrossing(TileIndex tile)
|
||||||
{
|
{
|
||||||
assert_tile(IsLevelCrossingTile(tile), tile);
|
dbg_assert_tile(IsLevelCrossingTile(tile), tile);
|
||||||
|
|
||||||
DiagDirection dir = AxisToDiagDir(GetCrossingRailAxis(tile));
|
DiagDirection dir = AxisToDiagDir(GetCrossingRailAxis(tile));
|
||||||
TileIndex tile_from = tile + TileOffsByDiagDir(dir);
|
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)
|
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;
|
bool new_state;
|
||||||
|
|
||||||
if (is_forced) {
|
if (is_forced) {
|
||||||
@@ -3656,7 +3656,7 @@ void FreeTrainTrackReservation(Train *v, TileIndex origin, Trackdir orig_td)
|
|||||||
tile = ft.m_new_tile;
|
tile = ft.m_new_tile;
|
||||||
TrackdirBits bits = ft.m_new_td_bits & TrackBitsToTrackdirBits(GetReservedTrackbits(tile));
|
TrackdirBits bits = ft.m_new_td_bits & TrackBitsToTrackdirBits(GetReservedTrackbits(tile));
|
||||||
td = RemoveFirstTrackdir(&bits);
|
td = RemoveFirstTrackdir(&bits);
|
||||||
assert(bits == TRACKDIR_BIT_NONE);
|
dbg_assert(bits == TRACKDIR_BIT_NONE);
|
||||||
|
|
||||||
if (!IsValidTrackdir(td)) break;
|
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)) {
|
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);
|
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;
|
tile = ft.m_new_tile;
|
||||||
cur_td = FindFirstTrackdir(ft.m_new_td_bits);
|
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;
|
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);
|
Order *order = this->v->GetOrder(this->v->cur_real_order_index);
|
||||||
assert(order != nullptr);
|
dbg_assert(order != nullptr);
|
||||||
|
|
||||||
switch (order->GetType()) {
|
switch (order->GetType()) {
|
||||||
case OT_GOTO_DEPOT:
|
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);
|
bool do_track_reservation = _settings_game.pf.reserve_paths || (flags & CTTF_FORCE_RES);
|
||||||
Trackdir changed_signal = INVALID_TRACKDIR;
|
Trackdir changed_signal = INVALID_TRACKDIR;
|
||||||
|
|
||||||
assert((tracks & ~TRACK_BIT_MASK) == 0);
|
dbg_assert((tracks & ~TRACK_BIT_MASK) == 0);
|
||||||
|
|
||||||
bool got_reservation = false;
|
bool got_reservation = false;
|
||||||
if (p_got_reservation != nullptr) *p_got_reservation = got_reservation;
|
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)
|
bool TryPathReserve(Train *v, bool mark_as_stuck, bool first_tile_okay)
|
||||||
{
|
{
|
||||||
assert(v->IsFrontEngine());
|
dbg_assert(v->IsFrontEngine());
|
||||||
|
|
||||||
ClearLookAheadIfInvalid(v);
|
ClearLookAheadIfInvalid(v);
|
||||||
|
|
||||||
@@ -4585,7 +4585,7 @@ static bool CheckReverseTrain(const Train *v)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(v->track != TRACK_BIT_NONE);
|
dbg_assert(v->track != TRACK_BIT_NONE);
|
||||||
|
|
||||||
switch (_settings_game.pf.pathfinder_for_trains) {
|
switch (_settings_game.pf.pathfinder_for_trains) {
|
||||||
case VPF_NPF: return NPFTrainCheckReverse(v);
|
case VPF_NPF: return NPFTrainCheckReverse(v);
|
||||||
@@ -4659,7 +4659,7 @@ int Train::UpdateSpeed(MaxSpeedInfo max_speed_info)
|
|||||||
*/
|
*/
|
||||||
static bool HandlePossibleBreakdowns(Train *v)
|
static bool HandlePossibleBreakdowns(Train *v)
|
||||||
{
|
{
|
||||||
assert(v->IsFrontEngine());
|
dbg_assert(v->IsFrontEngine());
|
||||||
for (Train *u = v; u != nullptr; u = u->Next()) {
|
for (Train *u = v; u != nullptr; u = u->Next()) {
|
||||||
if (u->breakdown_ctr != 0 && (u->IsEngine() || u->IsMultiheaded())) {
|
if (u->breakdown_ctr != 0 && (u->IsEngine() || u->IsMultiheaded())) {
|
||||||
if (u->breakdown_ctr <= 2) {
|
if (u->breakdown_ctr <= 2) {
|
||||||
@@ -4806,7 +4806,7 @@ void Train::ReserveTrackUnderConsist() const
|
|||||||
/* reserve the first available track */
|
/* reserve the first available track */
|
||||||
TrackBits bits = GetAcrossTunnelBridgeTrackBits(u->tile);
|
TrackBits bits = GetAcrossTunnelBridgeTrackBits(u->tile);
|
||||||
Track first_track = RemoveFirstTrack(&bits);
|
Track first_track = RemoveFirstTrack(&bits);
|
||||||
assert(IsValidTrack(first_track));
|
dbg_assert(IsValidTrack(first_track));
|
||||||
TryReserveRailTrack(u->tile, first_track);
|
TryReserveRailTrack(u->tile, first_track);
|
||||||
} else {
|
} else {
|
||||||
TryReserveRailTrack(u->tile, DiagDirToDiagTrack(GetTunnelBridgeDirection(u->tile)));
|
TryReserveRailTrack(u->tile, DiagDirToDiagTrack(GetTunnelBridgeDirection(u->tile)));
|
||||||
@@ -4943,7 +4943,7 @@ static bool CheckTrainCollision(Train *v)
|
|||||||
/* can't collide in depot */
|
/* can't collide in depot */
|
||||||
if (v->track == TRACK_BIT_DEPOT) return false;
|
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;
|
TrainCollideChecker tcc;
|
||||||
tcc.v = v;
|
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 */
|
/* Determine what direction we're entering the new tile from */
|
||||||
enterdir = DiagdirBetweenTiles(gp.old_tile, gp.new_tile);
|
enterdir = DiagdirBetweenTiles(gp.old_tile, gp.new_tile);
|
||||||
assert(IsValidDiagDirection(enterdir));
|
dbg_assert(IsValidDiagDirection(enterdir));
|
||||||
|
|
||||||
enter_new_tile:
|
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
|
/* Currently the locomotive is active. Determine which one of the
|
||||||
* available tracks to choose */
|
* available tracks to choose */
|
||||||
chosen_track = TrackToTrackBits(ChooseTrainTrack(v, gp.new_tile, enterdir, bits, CTTF_MARK_STUCK | CTTF_NON_LOOKAHEAD, nullptr));
|
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)) {
|
if (v->force_proceed != TFP_NONE && IsPlainRailTile(gp.new_tile) && HasSignals(gp.new_tile)) {
|
||||||
/* For each signal we find decrease the counter by one.
|
/* 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) {
|
if (prev->track & TRACK_BIT_WORMHOLE) {
|
||||||
/* Vehicles entering tunnels enter the wormhole earlier than for bridges.
|
/* Vehicles entering tunnels enter the wormhole earlier than for bridges.
|
||||||
* However, just choose the track into the wormhole. */
|
* 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;
|
chosen_track = bits;
|
||||||
} else {
|
} else {
|
||||||
chosen_track = prev->track;
|
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 }
|
{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));
|
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 = _connecting_track[enterdir][exitdir];
|
||||||
}
|
}
|
||||||
chosen_track &= bits;
|
chosen_track &= bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure chosen track is a valid track */
|
/* 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_X || chosen_track == TRACK_BIT_Y ||
|
||||||
chosen_track == TRACK_BIT_UPPER || chosen_track == TRACK_BIT_LOWER ||
|
chosen_track == TRACK_BIT_UPPER || chosen_track == TRACK_BIT_LOWER ||
|
||||||
chosen_track == TRACK_BIT_LEFT || chosen_track == TRACK_BIT_RIGHT);
|
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->tile = gp.new_tile;
|
||||||
v->track = chosen_track;
|
v->track = chosen_track;
|
||||||
assert(v->track);
|
dbg_assert(v->track);
|
||||||
|
|
||||||
if (GetTileRailTypeByTrackBit(gp.new_tile, chosen_track) != GetTileRailTypeByTrackBit(gp.old_tile, old_trackbits)) {
|
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 */
|
/* 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);
|
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 */
|
/* 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);
|
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)
|
static TileIndex TrainApproachingCrossingTile(const Train *v)
|
||||||
{
|
{
|
||||||
assert(v->IsFrontEngine());
|
dbg_assert(v->IsFrontEngine());
|
||||||
assert(!(v->vehstatus & VS_CRASHED));
|
dbg_assert(!(v->vehstatus & VS_CRASHED));
|
||||||
|
|
||||||
if (!TrainCanLeaveTile(v)) return INVALID_TILE;
|
if (!TrainCanLeaveTile(v)) return INVALID_TILE;
|
||||||
|
|
||||||
|
@@ -98,8 +98,8 @@ static bool CanPlantTreesOnTile(TileIndex tile, bool allow_desert)
|
|||||||
*/
|
*/
|
||||||
static void PlantTreesOnTile(TileIndex tile, TreeType treetype, uint count, uint growth)
|
static void PlantTreesOnTile(TileIndex tile, TreeType treetype, uint count, uint growth)
|
||||||
{
|
{
|
||||||
assert(treetype != TREE_INVALID);
|
dbg_assert(treetype != TREE_INVALID);
|
||||||
assert_tile(CanPlantTreesOnTile(tile, true), tile);
|
dbg_assert_tile(CanPlantTreesOnTile(tile, true), tile);
|
||||||
|
|
||||||
TreeGround ground;
|
TreeGround ground;
|
||||||
uint density = 3;
|
uint density = 3;
|
||||||
@@ -457,7 +457,7 @@ void RemoveAllTrees()
|
|||||||
*/
|
*/
|
||||||
uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, uint count, bool set_zone)
|
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;
|
const bool allow_desert = treetype == TREE_CACTUS;
|
||||||
uint planted = 0;
|
uint planted = 0;
|
||||||
|
|
||||||
@@ -725,7 +725,7 @@ static void DrawTile_Trees(TileInfo *ti, DrawTileProcParams params)
|
|||||||
index += 164 - (TREE_SUB_ARCTIC << 2);
|
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 PalSpriteID *s = _tree_layout_sprite[index];
|
||||||
const TreePos *d = _tree_layout_xy[GB(tmp, 2, 2)];
|
const TreePos *d = _tree_layout_xy[GB(tmp, 2, 2)];
|
||||||
|
@@ -72,7 +72,7 @@ enum TreeGround {
|
|||||||
*/
|
*/
|
||||||
static inline TreeType GetTreeType(TileIndex t)
|
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;
|
return (TreeType)_m[t].m3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ static inline TreeType GetTreeType(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline TreeGround GetTreeGround(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);
|
return (TreeGround)GB(_m[t].m2, 6, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ static inline TreeGround GetTreeGround(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline uint GetTreeDensity(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);
|
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)
|
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, 4, 2, d);
|
||||||
SB(_m[t].m2, 6, 3, g);
|
SB(_m[t].m2, 6, 3, g);
|
||||||
SetWaterClass(t, g == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID);
|
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)
|
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;
|
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)
|
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;
|
_m[t].m5 += ((uint) c) << 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ static inline void AddTreeCount(TileIndex t, int c)
|
|||||||
*/
|
*/
|
||||||
static inline uint GetTreeGrowth(TileIndex t)
|
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);
|
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)
|
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;
|
_m[t].m5 += a;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ static inline void AddTreeGrowth(TileIndex t, int a)
|
|||||||
*/
|
*/
|
||||||
static inline void SetTreeGrowth(TileIndex t, uint g)
|
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);
|
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)
|
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);
|
SB(_m[t].m2, 0, 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ static const TunnelID TUNNEL_ID_MAP_LOOKUP = 0xFFFF; ///< Sentinel ID value to s
|
|||||||
*/
|
*/
|
||||||
static inline bool IsTunnel(TileIndex t)
|
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);
|
return !HasBit(_m[t].m5, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ static inline TunnelID GetTunnelIndex(TileIndex t)
|
|||||||
{
|
{
|
||||||
extern TunnelID GetTunnelIndexByLookup(TileIndex t);
|
extern TunnelID GetTunnelIndexByLookup(TileIndex t);
|
||||||
|
|
||||||
assert_tile(IsTunnelTile(t), t);
|
dbg_assert_tile(IsTunnelTile(t), t);
|
||||||
TunnelID map_id = _m[t].m2;
|
TunnelID map_id = _m[t].m2;
|
||||||
return map_id == TUNNEL_ID_MAP_LOOKUP ? GetTunnelIndexByLookup(t) : map_id;
|
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)
|
static inline bool HasTunnelReservation(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(IsRailTunnelTile(t), t);
|
dbg_assert_tile(IsRailTunnelTile(t), t);
|
||||||
return HasBit(_m[t].m5, 4);
|
return HasBit(_m[t].m5, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ static inline bool HasTunnelReservation(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void SetTunnelReservation(TileIndex t, bool b)
|
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);
|
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)
|
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;
|
_m[t].m2 = (id >= TUNNEL_ID_MAP_LOOKUP) ? TUNNEL_ID_MAP_LOOKUP : id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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
|
* 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
|
* when this function is called then it's faster to pass the pointer as an
|
||||||
* argument rather than finding it again. */
|
* 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 (use_renew_setting && !c->settings.engine_renew) return false;
|
||||||
if (this->age - this->max_age < (c->settings.engine_renew_months * 30)) 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)
|
void VehicleServiceInDepot(Vehicle *v)
|
||||||
{
|
{
|
||||||
assert(v != nullptr);
|
dbg_assert(v != nullptr);
|
||||||
const Engine *e = Engine::Get(v->engine_type);
|
const Engine *e = Engine::Get(v->engine_type);
|
||||||
if (v->type == VEH_TRAIN) {
|
if (v->type == VEH_TRAIN) {
|
||||||
if (v->Next() != nullptr) VehicleServiceInDepot(v->Next());
|
if (v->Next() != nullptr) VehicleServiceInDepot(v->Next());
|
||||||
@@ -1104,7 +1104,7 @@ void Vehicle::PreDestructor()
|
|||||||
HideFillingPercent(&this->fill_percent_te_id);
|
HideFillingPercent(&this->fill_percent_te_id);
|
||||||
this->CancelReservation(INVALID_STATION, st);
|
this->CancelReservation(INVALID_STATION, st);
|
||||||
delete this->cargo_payment;
|
delete this->cargo_payment;
|
||||||
assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
|
dbg_assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->IsEngineCountable()) {
|
if (this->IsEngineCountable()) {
|
||||||
@@ -1723,7 +1723,7 @@ void CallVehicleTicks()
|
|||||||
default:
|
default:
|
||||||
NOT_REACHED();
|
NOT_REACHED();
|
||||||
}
|
}
|
||||||
assert(type != INVALID_EXPENSES);
|
dbg_assert(type != INVALID_EXPENSES);
|
||||||
|
|
||||||
Money vehicle_new_value = v->GetEngine()->GetCost();
|
Money vehicle_new_value = v->GetEngine()->GetCost();
|
||||||
|
|
||||||
@@ -2475,7 +2475,7 @@ uint8 CalcPercentVehicleFilledOfCargo(const Vehicle *front, CargoID cargo)
|
|||||||
void VehicleEnterDepot(Vehicle *v)
|
void VehicleEnterDepot(Vehicle *v)
|
||||||
{
|
{
|
||||||
/* Always work with the front of the vehicle */
|
/* Always work with the front of the vehicle */
|
||||||
assert(v == v->First());
|
dbg_assert(v == v->First());
|
||||||
|
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
case VEH_TRAIN: {
|
case VEH_TRAIN: {
|
||||||
@@ -3337,7 +3337,7 @@ void Vehicle::LeaveStation()
|
|||||||
assert(this->current_order.IsAnyLoadingType());
|
assert(this->current_order.IsAnyLoadingType());
|
||||||
|
|
||||||
delete this->cargo_payment;
|
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);
|
ClrBit(this->vehicle_flags, VF_COND_ORDER_WAIT);
|
||||||
|
|
||||||
@@ -3467,7 +3467,7 @@ void Vehicle::LeaveStation()
|
|||||||
void Vehicle::AdvanceLoadingInStation()
|
void Vehicle::AdvanceLoadingInStation()
|
||||||
{
|
{
|
||||||
assert(this->current_order.IsType(OT_LOADING));
|
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);
|
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
|
void Vehicle::ShowVisualEffect(uint max_speed) const
|
||||||
{
|
{
|
||||||
assert(this->IsPrimaryVehicle());
|
dbg_assert(this->IsPrimaryVehicle());
|
||||||
bool sound = false;
|
bool sound = false;
|
||||||
|
|
||||||
/* Do not show any smoke when:
|
/* Do not show any smoke when:
|
||||||
@@ -4057,7 +4057,7 @@ void Vehicle::ShowVisualEffect(uint max_speed) const
|
|||||||
*/
|
*/
|
||||||
void Vehicle::SetNext(Vehicle *next)
|
void Vehicle::SetNext(Vehicle *next)
|
||||||
{
|
{
|
||||||
assert(this != next);
|
dbg_assert(this != next);
|
||||||
|
|
||||||
if (this->next != nullptr) {
|
if (this->next != nullptr) {
|
||||||
/* We had an old next vehicle. Update the first and previous pointers */
|
/* 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)
|
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) {
|
if (shared_chain->orders == nullptr) {
|
||||||
assert(shared_chain->previous_shared == nullptr);
|
dbg_assert(shared_chain->previous_shared == nullptr);
|
||||||
assert(shared_chain->next_shared == nullptr);
|
dbg_assert(shared_chain->next_shared == nullptr);
|
||||||
this->orders = shared_chain->orders = new OrderList(nullptr, shared_chain);
|
this->orders = shared_chain->orders = new OrderList(nullptr, shared_chain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4332,7 +4332,7 @@ void VehiclesYearlyLoop()
|
|||||||
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
|
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
|
||||||
{
|
{
|
||||||
const Engine *e = Engine::GetIfValid(engine_type);
|
const Engine *e = Engine::GetIfValid(engine_type);
|
||||||
assert(e != nullptr);
|
dbg_assert(e != nullptr);
|
||||||
|
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
case VEH_TRAIN:
|
case VEH_TRAIN:
|
||||||
@@ -4425,7 +4425,7 @@ StringID GetVehicleCannotUseStationReason(const Vehicle *v, const Station *st)
|
|||||||
*/
|
*/
|
||||||
GroundVehicleCache *Vehicle::GetGroundVehicleCache()
|
GroundVehicleCache *Vehicle::GetGroundVehicleCache()
|
||||||
{
|
{
|
||||||
assert(this->IsGroundVehicle());
|
dbg_assert(this->IsGroundVehicle());
|
||||||
if (this->type == VEH_TRAIN) {
|
if (this->type == VEH_TRAIN) {
|
||||||
return &Train::From(this)->gcache;
|
return &Train::From(this)->gcache;
|
||||||
} else {
|
} else {
|
||||||
@@ -4440,7 +4440,7 @@ GroundVehicleCache *Vehicle::GetGroundVehicleCache()
|
|||||||
*/
|
*/
|
||||||
const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const
|
const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const
|
||||||
{
|
{
|
||||||
assert(this->IsGroundVehicle());
|
dbg_assert(this->IsGroundVehicle());
|
||||||
if (this->type == VEH_TRAIN) {
|
if (this->type == VEH_TRAIN) {
|
||||||
return &Train::From(this)->gcache;
|
return &Train::From(this)->gcache;
|
||||||
} else {
|
} else {
|
||||||
@@ -4455,7 +4455,7 @@ const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const
|
|||||||
*/
|
*/
|
||||||
uint16 &Vehicle::GetGroundVehicleFlags()
|
uint16 &Vehicle::GetGroundVehicleFlags()
|
||||||
{
|
{
|
||||||
assert(this->IsGroundVehicle());
|
dbg_assert(this->IsGroundVehicle());
|
||||||
if (this->type == VEH_TRAIN) {
|
if (this->type == VEH_TRAIN) {
|
||||||
return Train::From(this)->gv_flags;
|
return Train::From(this)->gv_flags;
|
||||||
} else {
|
} else {
|
||||||
@@ -4470,7 +4470,7 @@ uint16 &Vehicle::GetGroundVehicleFlags()
|
|||||||
*/
|
*/
|
||||||
const uint16 &Vehicle::GetGroundVehicleFlags() const
|
const uint16 &Vehicle::GetGroundVehicleFlags() const
|
||||||
{
|
{
|
||||||
assert(this->IsGroundVehicle());
|
dbg_assert(this->IsGroundVehicle());
|
||||||
if (this->type == VEH_TRAIN) {
|
if (this->type == VEH_TRAIN) {
|
||||||
return Train::From(this)->gv_flags;
|
return Train::From(this)->gv_flags;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -38,7 +38,7 @@ struct GUIVehicleGroup {
|
|||||||
|
|
||||||
const Vehicle *GetSingleVehicle() const
|
const Vehicle *GetSingleVehicle() const
|
||||||
{
|
{
|
||||||
assert(this->NumVehicles() == 1);
|
dbg_assert(this->NumVehicles() == 1);
|
||||||
return this->vehicles_begin[0];
|
return this->vehicles_begin[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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)
|
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();
|
TileSpriteToDraw &ts = _vd.tile_sprites_to_draw.emplace_back();
|
||||||
ts.image = image;
|
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)
|
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));
|
dbg_assert(IsInsideMM(foundation_part, 0, FOUNDATION_PART_END));
|
||||||
assert(_vd.foundation[foundation_part] != -1);
|
dbg_assert(_vd.foundation[foundation_part] != -1);
|
||||||
Point offs = _vd.foundation_offset[foundation_part];
|
Point offs = _vd.foundation_offset[foundation_part];
|
||||||
|
|
||||||
/* Change the active ChildSprite list to the one of the foundation */
|
/* 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;
|
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 */
|
/* make the sprites transparent with the right palette */
|
||||||
if (transparent) {
|
if (transparent) {
|
||||||
@@ -1136,7 +1136,7 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w,
|
|||||||
*/
|
*/
|
||||||
void StartSpriteCombine()
|
void StartSpriteCombine()
|
||||||
{
|
{
|
||||||
assert(_vd.combine_sprites == SPRITE_COMBINE_NONE);
|
dbg_assert(_vd.combine_sprites == SPRITE_COMBINE_NONE);
|
||||||
_vd.combine_sprites = SPRITE_COMBINE_PENDING;
|
_vd.combine_sprites = SPRITE_COMBINE_PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1146,7 +1146,7 @@ void StartSpriteCombine()
|
|||||||
*/
|
*/
|
||||||
void EndSpriteCombine()
|
void EndSpriteCombine()
|
||||||
{
|
{
|
||||||
assert(_vd.combine_sprites != SPRITE_COMBINE_NONE);
|
dbg_assert(_vd.combine_sprites != SPRITE_COMBINE_NONE);
|
||||||
if (_vd.combine_sprites == SPRITE_COMBINE_ACTIVE) {
|
if (_vd.combine_sprites == SPRITE_COMBINE_ACTIVE) {
|
||||||
ParentSpriteToDraw &ps = _vd.parent_sprites_to_draw[_vd.combine_psd_index];
|
ParentSpriteToDraw &ps = _vd.parent_sprites_to_draw[_vd.combine_psd_index];
|
||||||
ps.left = _vd.combine_left;
|
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)
|
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 the ParentSprite was clipped by the viewport bounds, do not draw the ChildSprites either */
|
||||||
if (_vd.last_child == nullptr) return;
|
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)
|
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();
|
StringSpriteToDraw &ss = _vd.string_sprites_to_draw.emplace_back();
|
||||||
ss.string = string;
|
ss.string = string;
|
||||||
ss.x = x;
|
ss.x = x;
|
||||||
@@ -1576,8 +1576,8 @@ static int GetViewportY(Point tile)
|
|||||||
*/
|
*/
|
||||||
static void ViewportAddLandscape()
|
static void ViewportAddLandscape()
|
||||||
{
|
{
|
||||||
assert(_vd.dpi.top <= _vd.dpi.top + _vd.dpi.height);
|
dbg_assert(_vd.dpi.top <= _vd.dpi.top + _vd.dpi.height);
|
||||||
assert(_vd.dpi.left <= _vd.dpi.left + _vd.dpi.width);
|
dbg_assert(_vd.dpi.left <= _vd.dpi.left + _vd.dpi.width);
|
||||||
|
|
||||||
Point upper_left = InverseRemapCoords(_vd.dpi.left, _vd.dpi.top);
|
Point upper_left = InverseRemapCoords(_vd.dpi.left, _vd.dpi.top);
|
||||||
Point upper_right = InverseRemapCoords(_vd.dpi.left + _vd.dpi.width, _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;
|
Point tilecoord;
|
||||||
tilecoord.x = (row - column) / 2;
|
tilecoord.x = (row - column) / 2;
|
||||||
tilecoord.y = (row + column) / 2;
|
tilecoord.y = (row + column) / 2;
|
||||||
assert(column == tilecoord.y - tilecoord.x);
|
dbg_assert(column == tilecoord.y - tilecoord.x);
|
||||||
assert(row == tilecoord.y + tilecoord.x);
|
dbg_assert(row == tilecoord.y + tilecoord.x);
|
||||||
|
|
||||||
TileType tile_type;
|
TileType tile_type;
|
||||||
TileInfo tile_info;
|
TileInfo tile_info;
|
||||||
@@ -3325,7 +3325,7 @@ static void ViewportMapDrawBridgeTunnel(Viewport * const vp, const TunnelBridgeT
|
|||||||
template <bool is_32bpp, bool show_slope>
|
template <bool is_32bpp, bool show_slope>
|
||||||
void ViewportMapDraw(Viewport * const vp)
|
void ViewportMapDraw(Viewport * const vp)
|
||||||
{
|
{
|
||||||
assert(vp != nullptr);
|
dbg_assert(vp != nullptr);
|
||||||
Blitter * const blitter = BlitterFactory::GetCurrentBlitter();
|
Blitter * const blitter = BlitterFactory::GetCurrentBlitter();
|
||||||
|
|
||||||
SmallMapWindow::RebuildColourIndexIfNecessary();
|
SmallMapWindow::RebuildColourIndexIfNecessary();
|
||||||
@@ -3933,7 +3933,7 @@ static void MarkRouteStepDirty(RouteStepsMap::const_iterator cit)
|
|||||||
|
|
||||||
static void MarkRouteStepDirty(const TileIndex tile, uint order_nr)
|
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 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 char_height = GetCharacterHeight(FS_SMALL) + 1;
|
||||||
const int max_width = _vp_route_step_base_width + _vp_route_step_string_width[3];
|
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)
|
void MarkTileLineDirty(const TileIndex from_tile, const TileIndex to_tile, ViewportMarkDirtyFlags flags)
|
||||||
{
|
{
|
||||||
assert(from_tile != INVALID_TILE);
|
dbg_assert(from_tile != INVALID_TILE);
|
||||||
assert(to_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 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);
|
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;
|
x_size -= TILE_SIZE;
|
||||||
y_size -= TILE_SIZE;
|
y_size -= TILE_SIZE;
|
||||||
|
|
||||||
assert(x_size >= 0);
|
dbg_assert(x_size >= 0);
|
||||||
assert(y_size >= 0);
|
dbg_assert(y_size >= 0);
|
||||||
|
|
||||||
int x_end = Clamp(x_start + x_size, 0, MapSizeX() * TILE_SIZE - TILE_SIZE);
|
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);
|
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);
|
y_start = Clamp(y_start, 0, MapSizeY() * TILE_SIZE - TILE_SIZE);
|
||||||
|
|
||||||
/* make sure everything is multiple of 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:
|
/* How it works:
|
||||||
* Suppose we have to mark dirty rectangle of 3x4 tiles:
|
* 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 */
|
/* Use lookup table for start-tile based on HighLightStyle direction */
|
||||||
byte style_t = style * 2;
|
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])));
|
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])));
|
uint ht = TileHeight(TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_line_by_dir[style_t + 1])));
|
||||||
h0 = std::max(h0, ht);
|
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
|
/* Use lookup table for end-tile based on HighLightStyle direction
|
||||||
* flip around side (lower/upper, left/right) based on distance */
|
* flip around side (lower/upper, left/right) based on distance */
|
||||||
if (distance == 0) style_t = flip_style_direction[style] * 2;
|
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])));
|
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])));
|
ht = TileHeight(TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_line_by_dir[12 + style_t + 1])));
|
||||||
h1 = std::max(h1, ht);
|
h1 = std::max(h1, ht);
|
||||||
@@ -6061,7 +6061,7 @@ void InitializeSpriteSorter()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(_vp_sprite_sorter != nullptr);
|
dbg_assert(_vp_sprite_sorter != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -76,7 +76,7 @@ bool IsPossibleDockingTile(TileIndex t);
|
|||||||
*/
|
*/
|
||||||
static inline WaterTileType GetWaterTileType(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)) {
|
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;
|
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)
|
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);
|
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)
|
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);
|
SB(_m[t].m1, 5, 2, wc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ static inline bool IsShipDepotTile(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline Axis GetShipDepotAxis(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);
|
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)
|
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);
|
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)
|
static inline TileIndex GetShipDepotNorthTile(TileIndex t)
|
||||||
{
|
{
|
||||||
assert_tile(IsShipDepot(t), t);
|
dbg_assert_tile(IsShipDepot(t), t);
|
||||||
TileIndex tile2 = GetOtherShipDepotTile(t);
|
TileIndex tile2 = GetOtherShipDepotTile(t);
|
||||||
|
|
||||||
return t < tile2 ? t : tile2;
|
return t < tile2 ? t : tile2;
|
||||||
@@ -307,7 +307,7 @@ static inline bool IsLock(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline DiagDirection GetLockDirection(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);
|
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)
|
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);
|
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)
|
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;
|
return _m[t].m4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +354,7 @@ static inline bool HasTileWaterGround(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline void SetDockingTile(TileIndex t, bool b)
|
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);
|
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)
|
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);
|
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)
|
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);
|
SB(_m[t].m3, 0, 1, b ? 1 : 0);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@@ -240,7 +240,7 @@ void Window::DisableAllWidgetHighlight()
|
|||||||
*/
|
*/
|
||||||
void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour)
|
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);
|
NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget_index);
|
||||||
if (nwid == nullptr) return;
|
if (nwid == nullptr) return;
|
||||||
@@ -273,7 +273,7 @@ void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour
|
|||||||
*/
|
*/
|
||||||
bool Window::IsWidgetHighlighted(byte widget_index) const
|
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);
|
const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget_index);
|
||||||
if (nwid == nullptr) return false;
|
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. */
|
/* 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;
|
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->nested_focus != nullptr) {
|
||||||
if (this->GetWidget<NWidgetCore>(widget_index) == this->nested_focus) return false;
|
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)
|
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) {
|
if (_z_front_window == nullptr) {
|
||||||
/* It's the only window. */
|
/* 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))) {
|
while (v != nullptr && (v->window_class == WC_INVALID || GetWindowZPriority(v->window_class) > GetWindowZPriority(w->window_class))) {
|
||||||
if (v->window_class != WC_INVALID) {
|
if (v->window_class != WC_INVALID) {
|
||||||
/* Sanity check z-ordering, while we're at it. */
|
/* 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);
|
last_z_priority = GetWindowZPriority(v->window_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1454,14 +1454,14 @@ static void AddWindowToZOrdering(Window *w)
|
|||||||
static void RemoveWindowFromZOrdering(WindowBase *w)
|
static void RemoveWindowFromZOrdering(WindowBase *w)
|
||||||
{
|
{
|
||||||
if (w->z_front == nullptr) {
|
if (w->z_front == nullptr) {
|
||||||
assert(_z_front_window == w);
|
dbg_assert(_z_front_window == w);
|
||||||
_z_front_window = w->z_back;
|
_z_front_window = w->z_back;
|
||||||
} else {
|
} else {
|
||||||
w->z_front->z_back = w->z_back;
|
w->z_front->z_back = w->z_back;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w->z_back == nullptr) {
|
if (w->z_back == nullptr) {
|
||||||
assert(_z_back_window == w);
|
dbg_assert(_z_back_window == w);
|
||||||
_z_back_window = w->z_front;
|
_z_back_window = w->z_front;
|
||||||
} else {
|
} else {
|
||||||
w->z_back->z_front = w->z_front;
|
w->z_back->z_front = w->z_front;
|
||||||
@@ -1764,7 +1764,7 @@ restart:
|
|||||||
Point GetToolbarAlignedWindowPosition(int window_width)
|
Point GetToolbarAlignedWindowPosition(int window_width)
|
||||||
{
|
{
|
||||||
const Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0);
|
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 };
|
Point pt = { _current_text_dir == TD_RTL ? w->left : (w->left + w->width) - window_width, w->top + w->height };
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user