summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-07-31 13:25:20 +0000
committerrubidium <rubidium@openttd.org>2009-07-31 13:25:20 +0000
commit097e79a86de967c416d71d934a325d883d917fd5 (patch)
tree5a6a23be557b11e2963262c88946b7791343920b
parentc2fdb85c0dce9cfa61045ccee16052f0e31d7078 (diff)
downloadopenttd-097e79a86de967c416d71d934a325d883d917fd5.tar.xz
(svn r17001) -Codechange: replace some more assert(0)s to NOT_REACHED() and document why they (assert(0)) have to stay for the remaining cases.
-rw-r--r--src/aircraft_cmd.cpp3
-rw-r--r--src/openttd.cpp2
-rw-r--r--src/strings.cpp3
-rw-r--r--src/water_cmd.cpp4
-rw-r--r--src/yapf/yapf_base.hpp4
5 files changed, 7 insertions, 9 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 8d0a3dda0..11cea23d7 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -1799,8 +1799,7 @@ static bool AirportMove(Aircraft *v, const AirportFTAClass *apc)
} while (current != NULL);
DEBUG(misc, 0, "[Ap] cannot move further on Airport! (pos %d state %d) for vehicle %d", v->pos, v->state, v->index);
- assert(0);
- return false;
+ NOT_REACHED();
}
/* returns true if the road ahead is busy, eg. you must wait before proceeding */
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 962a05143..df2996b1a 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -116,6 +116,8 @@ void CDECL error(const char *s, ...)
ShowOSErrorBox(buf, true);
if (_video_driver != NULL) _video_driver->Stop();
+ /* Don't go into NOT_REACHED here; NOT_REACHED is using error, so
+ * using it would result in an infinite loop instead of errors. */
assert(0);
exit(1);
}
diff --git a/src/strings.cpp b/src/strings.cpp
index 4cbe06df3..add90ae26 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -1248,8 +1248,7 @@ static char *GetSpecialNameString(char *buff, int ind, int64 *argv, const char *
return strecpy(buff, GetScreenshotFormatDesc(i), last);
}
- assert(0);
- return NULL;
+ NOT_REACHED();
}
#ifdef ENABLE_NETWORK
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 33c53fff3..52247e8c0 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -690,13 +690,13 @@ static void GetTileDesc_Water(TileIndex tile, TileDesc *td)
case WATER_CLASS_SEA: td->str = STR_WATER_DESCRIPTION_WATER; break;
case WATER_CLASS_CANAL: td->str = STR_LANDINFO_CANAL; break;
case WATER_CLASS_RIVER: td->str = STR_LANDINFO_RIVER; break;
- default: assert(0); break;
+ default: NOT_REACHED(); break;
}
break;
case WATER_TILE_COAST: td->str = STR_WATER_DESCRIPTION_COAST_OR_RIVERBANK; break;
case WATER_TILE_LOCK : td->str = STR_LANDINFO_LOCK; break;
case WATER_TILE_DEPOT: td->str = STR_WATER_DESCRIPTION_SHIP_DEPOT; break;
- default: assert(0); break;
+ default: NOT_REACHED(); break;
}
td->owner[0] = GetTileOwner(tile);
diff --git a/src/yapf/yapf_base.hpp b/src/yapf/yapf_base.hpp
index b29e886e4..c33c08777 100644
--- a/src/yapf/yapf_base.hpp
+++ b/src/yapf/yapf_base.hpp
@@ -275,9 +275,7 @@ public:
* - PfCalcEstimate() gives too large numbers
* - PfCalcCost() gives too small numbers
* - You have used negative cost penalty in some cases (cost bonus) */
- assert(0);
-
- return;
+ NOT_REACHED();
}
return;
}