Mercurial > hg > openttd
changeset 12563:bad474e5cd7e draft
(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.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Fri, 31 Jul 2009 13:25:20 +0000 |
parents | e6b8a343eb13 |
children | 5add58f1ce2a |
files | src/aircraft_cmd.cpp src/openttd.cpp src/strings.cpp src/water_cmd.cpp src/yapf/yapf_base.hpp |
diffstat | 5 files changed, 7 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1799,8 +1799,7 @@ } 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 */
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -116,6 +116,8 @@ 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); }
--- a/src/strings.cpp +++ b/src/strings.cpp @@ -1248,8 +1248,7 @@ return strecpy(buff, GetScreenshotFormatDesc(i), last); } - assert(0); - return NULL; + NOT_REACHED(); } #ifdef ENABLE_NETWORK
--- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -690,13 +690,13 @@ 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);