(svn r22145) -Codechange: Do explicit test for non-bool values.

This commit is contained in:
alberth 2011-02-25 22:04:38 +00:00
parent 1dbc0a20be
commit 31386c42a7
14 changed files with 31 additions and 31 deletions

View File

@ -291,7 +291,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
} else { } else {
p2 |= (TRACK_LEFT << 4); p2 |= (TRACK_LEFT << 4);
} }
if (diag_offset) { if (diag_offset != 0) {
*to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1); *to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1);
} else { } else {
*to -= ::MapSizeX() * Clamp((int)::TileY(*to) - (int)::TileY(tile), -1, 1); *to -= ::MapSizeX() * Clamp((int)::TileY(*to) - (int)::TileY(tile), -1, 1);
@ -302,7 +302,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
} else { } else {
p2 |= (TRACK_LOWER << 4); p2 |= (TRACK_LOWER << 4);
} }
if (diag_offset) { if (diag_offset != 0) {
*to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1); *to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1);
} else { } else {
*to -= ::MapSizeX() * Clamp((int)::TileY(*to) - (int)::TileY(tile), -1, 1); *to -= ::MapSizeX() * Clamp((int)::TileY(*to) - (int)::TileY(tile), -1, 1);
@ -313,7 +313,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
} else { } else {
p2 |= (TRACK_RIGHT << 4); p2 |= (TRACK_RIGHT << 4);
} }
if (!diag_offset) { if (diag_offset == 0) {
*to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1); *to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1);
} else { } else {
*to -= ::MapSizeX() * Clamp((int)::TileY(*to) - (int)::TileY(tile), -1, 1); *to -= ::MapSizeX() * Clamp((int)::TileY(*to) - (int)::TileY(tile), -1, 1);
@ -324,7 +324,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
} else { } else {
p2 |= (TRACK_LOWER << 4); p2 |= (TRACK_LOWER << 4);
} }
if (!diag_offset) { if (diag_offset == 0) {
*to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1); *to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1);
} else { } else {
*to -= ::MapSizeX() * Clamp((int)::TileY(*to) - (int)::TileY(tile), -1, 1); *to -= ::MapSizeX() * Clamp((int)::TileY(*to) - (int)::TileY(tile), -1, 1);

View File

@ -26,7 +26,7 @@ static EngineRenew *GetEngineReplacement(EngineRenewList erl, EngineID engine, G
{ {
EngineRenew *er = (EngineRenew *)erl; EngineRenew *er = (EngineRenew *)erl;
while (er) { while (er != NULL) {
if (er->from == engine && er->group_id == group) return er; if (er->from == engine && er->group_id == group) return er;
er = er->next; er = er->next;
} }
@ -114,7 +114,7 @@ CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, Group
EngineRenew *er = (EngineRenew *)(*erl); EngineRenew *er = (EngineRenew *)(*erl);
EngineRenew *prev = NULL; EngineRenew *prev = NULL;
while (er) { while (er != NULL) {
if (er->from == engine && er->group_id == group) { if (er->from == engine && er->group_id == group) {
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
if (prev == NULL) { // First element if (prev == NULL) { // First element

View File

@ -1699,7 +1699,7 @@ void SetDirtyBlocks(int left, int top, int right, int bottom)
do { do {
int i = width; int i = width;
do b[--i] = 0xFF; while (i); do b[--i] = 0xFF; while (i != 0);
b += _dirty_bytes_per_line; b += _dirty_bytes_per_line;
} while (--height != 0); } while (--height != 0);

View File

@ -268,11 +268,11 @@ void IniFile::LoadFromDisk(const char *filename)
} }
s++; // skip [ s++; // skip [
group = new IniGroup(this, s, e - s); group = new IniGroup(this, s, e - s);
if (comment_size) { if (comment_size != 0) {
group->comment = strndup(comment, comment_size); group->comment = strndup(comment, comment_size);
comment_size = 0; comment_size = 0;
} }
} else if (group) { } else if (group != NULL) {
char *t; char *t;
/* find end of keyname */ /* find end of keyname */
if (*s == '\"') { if (*s == '\"') {
@ -285,7 +285,7 @@ void IniFile::LoadFromDisk(const char *filename)
/* it's an item in an existing group */ /* it's an item in an existing group */
IniItem *item = new IniItem(group, s, t - s); IniItem *item = new IniItem(group, s, t - s);
if (comment_size) { if (comment_size != 0) {
item->comment = strndup(comment, comment_size); item->comment = strndup(comment, comment_size);
comment_size = 0; comment_size = 0;
} }

View File

@ -96,10 +96,10 @@ FORCEINLINE void CCountedPtr<Tcls_>::Assign(Tcls *pT)
{ {
/* if they are the same, we do nothing */ /* if they are the same, we do nothing */
if (pT != m_pT) { if (pT != m_pT) {
if (pT) pT->AddRef(); // AddRef new pointer if any if (pT != NULL) pT->AddRef(); // AddRef new pointer if any
Tcls *pTold = m_pT; // save original ptr Tcls *pTold = m_pT; // save original ptr
m_pT = pT; // update m_pT to new value m_pT = pT; // update m_pT to new value
if (pTold) pTold->Release(); // release old ptr if any if (pTold != NULL) pTold->Release(); // release old ptr if any
} }
} }

View File

@ -547,11 +547,11 @@ int ttd_main(int argc, char *argv[])
#if defined(ENABLE_NETWORK) #if defined(ENABLE_NETWORK)
if (dedicated) DEBUG(net, 0, "Starting dedicated version %s", _openttd_revision); if (dedicated) DEBUG(net, 0, "Starting dedicated version %s", _openttd_revision);
if (dedicated_host) { if (dedicated_host != NULL) {
_network_bind_list.Clear(); _network_bind_list.Clear();
*_network_bind_list.Append() = strdup(dedicated_host); *_network_bind_list.Append() = strdup(dedicated_host);
} }
if (dedicated_port) _settings_client.network.server_port = dedicated_port; if (dedicated_port != 0) _settings_client.network.server_port = dedicated_port;
if (_dedicated_forks && !dedicated) _dedicated_forks = false; if (_dedicated_forks && !dedicated) _dedicated_forks = false;
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */

View File

@ -526,7 +526,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
/* Close any possible log files */ /* Close any possible log files */
CloseConsoleLogIfActive(); CloseConsoleLogIfActive();
if (_safe_esp) { if (_safe_esp != NULL) {
#ifdef _M_AMD64 #ifdef _M_AMD64
ep->ContextRecord->Rip = (DWORD64)ShowCrashlogWindow; ep->ContextRecord->Rip = (DWORD64)ShowCrashlogWindow;
ep->ContextRecord->Rsp = (DWORD64)_safe_esp; ep->ContextRecord->Rsp = (DWORD64)_safe_esp;
@ -605,7 +605,7 @@ static void SetWndSize(HWND wnd, int mode)
if (mode >= 0) { if (mode >= 0) {
GetWindowRect(GetDlgItem(wnd, 11), &r2); GetWindowRect(GetDlgItem(wnd, 11), &r2);
int offs = r2.bottom - r2.top + 10; int offs = r2.bottom - r2.top + 10;
if (!mode) offs = -offs; if (mode == 0) offs = -offs;
SetWindowPos(wnd, HWND_TOPMOST, 0, 0, SetWindowPos(wnd, HWND_TOPMOST, 0, 0,
r.right - r.left, r.bottom - r.top + offs, SWP_NOMOVE | SWP_NOZORDER); r.right - r.left, r.bottom - r.top + offs, SWP_NOMOVE | SWP_NOZORDER);
} else { } else {

View File

@ -456,7 +456,7 @@ public:
} }
/* if min speed was requested, return it */ /* if min speed was requested, return it */
if (pmin_speed) *pmin_speed = min_speed; if (pmin_speed != NULL) *pmin_speed = min_speed;
return max_speed; return max_speed;
} }
}; };

View File

@ -981,7 +981,7 @@ static NPFFoundTargetData NPFRouteInternal(AyStarNode *start1, bool ignore_start
start1->user_data[NPF_NODE_FLAGS] = 0; start1->user_data[NPF_NODE_FLAGS] = 0;
NPFSetFlag(start1, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile1); NPFSetFlag(start1, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile1);
_npf_aystar.AddStartNode(start1, 0); _npf_aystar.AddStartNode(start1, 0);
if (start2) { if (start2 != NULL) {
start2->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR; start2->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR;
start2->user_data[NPF_NODE_FLAGS] = 0; start2->user_data[NPF_NODE_FLAGS] = 0;
NPFSetFlag(start2, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile2); NPFSetFlag(start2, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile2);

View File

@ -781,7 +781,7 @@ static bool CheckInterval(int32 p1)
vds = &Company::Get(_current_company)->settings.vehicle; vds = &Company::Get(_current_company)->settings.vehicle;
} }
if (p1) { if (p1 != 0) {
vds->servint_trains = 50; vds->servint_trains = 50;
vds->servint_roadveh = 50; vds->servint_roadveh = 50;
vds->servint_aircraft = 50; vds->servint_aircraft = 50;

View File

@ -724,7 +724,7 @@ static void HandleString(char *str, bool master)
/* Check if the string has a case.. /* Check if the string has a case..
* The syntax for cases is IDENTNAME.case */ * The syntax for cases is IDENTNAME.case */
char *casep = strchr(str, '.'); char *casep = strchr(str, '.');
if (casep) *casep++ = '\0'; if (casep != NULL) *casep++ = '\0';
/* Check if this string already exists.. */ /* Check if this string already exists.. */
LangString *ent = HashFind(str); LangString *ent = HashFind(str);
@ -901,7 +901,7 @@ bool CompareFiles(const char *n1, const char *n2)
fclose(f1); fclose(f1);
return false; return false;
} }
} while (l1); } while (l1 != 0);
fclose(f2); fclose(f2);
fclose(f1); fclose(f1);
@ -1320,7 +1320,7 @@ int CDECL main(int argc, char *argv[])
_masterlang = true; _masterlang = true;
ParseFile(pathbuf, true); ParseFile(pathbuf, true);
MakeHashOfStrings(); MakeHashOfStrings();
if (_errors) return 1; if (_errors != 0) return 1;
/* write strings.h */ /* write strings.h */
ottd_mkdir(dest_dir); ottd_mkdir(dest_dir);
@ -1336,7 +1336,7 @@ int CDECL main(int argc, char *argv[])
ParseFile(pathbuf, true); ParseFile(pathbuf, true);
MakeHashOfStrings(); MakeHashOfStrings();
ParseFile(replace_pathsep(mgo.argv[0]), false); // target file ParseFile(replace_pathsep(mgo.argv[0]), false); // target file
if (_errors) return 1; if (_errors != 0) return 1;
/* get the targetfile, strip any directories and append to destination path */ /* get the targetfile, strip any directories and append to destination path */
r = strrchr(mgo.argv[0], PATHSEPCHAR); r = strrchr(mgo.argv[0], PATHSEPCHAR);

View File

@ -2213,8 +2213,8 @@ static PBSTileInfo ExtendTrainReservation(const Train *v, TrackBits *new_tracks,
if (ft.m_tiles_skipped != 0) ft.m_new_tile -= TileOffsByDiagDir(ft.m_exitdir) * ft.m_tiles_skipped; if (ft.m_tiles_skipped != 0) ft.m_new_tile -= TileOffsByDiagDir(ft.m_exitdir) * ft.m_tiles_skipped;
/* Choice found, path valid but not okay. Save info about the choice tile as well. */ /* Choice found, path valid but not okay. Save info about the choice tile as well. */
if (new_tracks) *new_tracks = TrackdirBitsToTrackBits(ft.m_new_td_bits); if (new_tracks != NULL) *new_tracks = TrackdirBitsToTrackBits(ft.m_new_td_bits);
if (enterdir) *enterdir = ft.m_exitdir; if (enterdir != NULL) *enterdir = ft.m_exitdir;
return PBSTileInfo(ft.m_new_tile, ft.m_old_td, false); return PBSTileInfo(ft.m_new_tile, ft.m_old_td, false);
} }

View File

@ -379,7 +379,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
SelectPalette(hDC, hOldPalette, TRUE); SelectPalette(hDC, hOldPalette, TRUE);
ReleaseDC(hwnd, hDC); ReleaseDC(hwnd, hDC);
if (nChanged) InvalidateRect(hwnd, NULL, FALSE); if (nChanged != 0) InvalidateRect(hwnd, NULL, FALSE);
return 0; return 0;
} }

View File

@ -2559,9 +2559,9 @@ static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase **par
} }
/* Add sub_widget to parent container if available, otherwise return the widget to the caller. */ /* Add sub_widget to parent container if available, otherwise return the widget to the caller. */
if (nwid_cont) nwid_cont->Add(sub_widget); if (nwid_cont != NULL) nwid_cont->Add(sub_widget);
if (nwid_parent) nwid_parent->Add(sub_widget); if (nwid_parent != NULL) nwid_parent->Add(sub_widget);
if (!nwid_cont && !nwid_parent) { if (nwid_cont == NULL && nwid_parent == NULL) {
*parent = sub_widget; *parent = sub_widget;
return total_used; return total_used;
} }