TBTR: Add sanity check assertions
This commit is contained in:
@@ -188,6 +188,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual_train = train;
|
virtual_train = train;
|
||||||
|
if (virtual_train != NULL) {
|
||||||
|
assert(HasBit(virtual_train->subtype, GVSF_VIRTUAL));
|
||||||
|
}
|
||||||
UpdateButtonState();
|
UpdateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,6 +545,7 @@ public:
|
|||||||
void RearrangeVirtualTrain()
|
void RearrangeVirtualTrain()
|
||||||
{
|
{
|
||||||
virtual_train = virtual_train->First();
|
virtual_train = virtual_train->First();
|
||||||
|
assert(HasBit(virtual_train->subtype, GVSF_VIRTUAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1211,6 +1211,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
|||||||
src = src->GetFirstEnginePart();
|
src = src->GetFirstEnginePart();
|
||||||
if (dst != NULL) {
|
if (dst != NULL) {
|
||||||
dst = dst->GetFirstEnginePart();
|
dst = dst->GetFirstEnginePart();
|
||||||
|
assert(HasBit(dst->subtype, GVSF_VIRTUAL) == HasBit(src->subtype, GVSF_VIRTUAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't move the same vehicle.. */
|
/* don't move the same vehicle.. */
|
||||||
@@ -1218,9 +1219,11 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
|||||||
|
|
||||||
/* locate the head of the two chains */
|
/* locate the head of the two chains */
|
||||||
Train *src_head = src->First();
|
Train *src_head = src->First();
|
||||||
|
assert(HasBit(src_head->subtype, GVSF_VIRTUAL) == HasBit(src->subtype, GVSF_VIRTUAL));
|
||||||
Train *dst_head;
|
Train *dst_head;
|
||||||
if (dst != NULL) {
|
if (dst != NULL) {
|
||||||
dst_head = dst->First();
|
dst_head = dst->First();
|
||||||
|
assert(HasBit(dst_head->subtype, GVSF_VIRTUAL) == HasBit(dst->subtype, GVSF_VIRTUAL));
|
||||||
if (dst_head->tile != src_head->tile) return CMD_ERROR;
|
if (dst_head->tile != src_head->tile) return CMD_ERROR;
|
||||||
/* Now deal with articulated part of destination wagon */
|
/* Now deal with articulated part of destination wagon */
|
||||||
dst = dst->GetLastEnginePart();
|
dst = dst->GetLastEnginePart();
|
||||||
|
@@ -1072,6 +1072,8 @@ void CallVehicleTicks()
|
|||||||
for (TemplateReplacementMap::iterator it = _vehicles_to_templatereplace.Begin(); it != _vehicles_to_templatereplace.End(); it++) {
|
for (TemplateReplacementMap::iterator it = _vehicles_to_templatereplace.Begin(); it != _vehicles_to_templatereplace.End(); it++) {
|
||||||
Train *t = it->first;
|
Train *t = it->first;
|
||||||
|
|
||||||
|
assert(!_vehicles_to_autoreplace.Contains(t));
|
||||||
|
|
||||||
/* Store the position of the effect as the vehicle pointer will become invalid later */
|
/* Store the position of the effect as the vehicle pointer will become invalid later */
|
||||||
int x = t->x_pos;
|
int x = t->x_pos;
|
||||||
int y = t->y_pos;
|
int y = t->y_pos;
|
||||||
|
Reference in New Issue
Block a user