summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2011-02-25 22:04:38 +0000
committeralberth <alberth@openttd.org>2011-02-25 22:04:38 +0000
commit31386c42a7aa51b5b6a7abfc728b9ed4e34df0ea (patch)
tree793449a253b91916b65c373f54b4544a8c6c86b8
parent1dbc0a20bed5cd85035b4f84a649c4f7386b07ab (diff)
downloadopenttd-31386c42a7aa51b5b6a7abfc728b9ed4e34df0ea.tar.xz
(svn r22145) -Codechange: Do explicit test for non-bool values.
-rw-r--r--src/ai/api/ai_rail.cpp8
-rw-r--r--src/autoreplace.cpp4
-rw-r--r--src/gfx.cpp2
-rw-r--r--src/ini.cpp6
-rw-r--r--src/misc/countedptr.hpp8
-rw-r--r--src/openttd.cpp4
-rw-r--r--src/os/windows/crashlog_win.cpp4
-rw-r--r--src/pathfinder/follow_track.hpp2
-rw-r--r--src/pathfinder/npf/npf.cpp2
-rw-r--r--src/settings.cpp2
-rw-r--r--src/strgen/strgen.cpp8
-rw-r--r--src/train_cmd.cpp4
-rw-r--r--src/video/win32_v.cpp2
-rw-r--r--src/widget.cpp6
14 files changed, 31 insertions, 31 deletions
diff --git a/src/ai/api/ai_rail.cpp b/src/ai/api/ai_rail.cpp
index 0d734f01c..c6aefe714 100644
--- a/src/ai/api/ai_rail.cpp
+++ b/src/ai/api/ai_rail.cpp
@@ -291,7 +291,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
} else {
p2 |= (TRACK_LEFT << 4);
}
- if (diag_offset) {
+ if (diag_offset != 0) {
*to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1);
} else {
*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 {
p2 |= (TRACK_LOWER << 4);
}
- if (diag_offset) {
+ if (diag_offset != 0) {
*to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1);
} else {
*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 {
p2 |= (TRACK_RIGHT << 4);
}
- if (!diag_offset) {
+ if (diag_offset == 0) {
*to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1);
} else {
*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 {
p2 |= (TRACK_LOWER << 4);
}
- if (!diag_offset) {
+ if (diag_offset == 0) {
*to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1);
} else {
*to -= ::MapSizeX() * Clamp((int)::TileY(*to) - (int)::TileY(tile), -1, 1);
diff --git a/src/autoreplace.cpp b/src/autoreplace.cpp
index 464aa354a..4a7dfcd01 100644
--- a/src/autoreplace.cpp
+++ b/src/autoreplace.cpp
@@ -26,7 +26,7 @@ static EngineRenew *GetEngineReplacement(EngineRenewList erl, EngineID engine, G
{
EngineRenew *er = (EngineRenew *)erl;
- while (er) {
+ while (er != NULL) {
if (er->from == engine && er->group_id == group) return er;
er = er->next;
}
@@ -114,7 +114,7 @@ CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, Group
EngineRenew *er = (EngineRenew *)(*erl);
EngineRenew *prev = NULL;
- while (er) {
+ while (er != NULL) {
if (er->from == engine && er->group_id == group) {
if (flags & DC_EXEC) {
if (prev == NULL) { // First element
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 7fad4f15b..6253238a3 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -1699,7 +1699,7 @@ void SetDirtyBlocks(int left, int top, int right, int bottom)
do {
int i = width;
- do b[--i] = 0xFF; while (i);
+ do b[--i] = 0xFF; while (i != 0);
b += _dirty_bytes_per_line;
} while (--height != 0);
diff --git a/src/ini.cpp b/src/ini.cpp
index dc658296e..35d8910c8 100644
--- a/src/ini.cpp
+++ b/src/ini.cpp
@@ -268,11 +268,11 @@ void IniFile::LoadFromDisk(const char *filename)
}
s++; // skip [
group = new IniGroup(this, s, e - s);
- if (comment_size) {
+ if (comment_size != 0) {
group->comment = strndup(comment, comment_size);
comment_size = 0;
}
- } else if (group) {
+ } else if (group != NULL) {
char *t;
/* find end of keyname */
if (*s == '\"') {
@@ -285,7 +285,7 @@ void IniFile::LoadFromDisk(const char *filename)
/* it's an item in an existing group */
IniItem *item = new IniItem(group, s, t - s);
- if (comment_size) {
+ if (comment_size != 0) {
item->comment = strndup(comment, comment_size);
comment_size = 0;
}
diff --git a/src/misc/countedptr.hpp b/src/misc/countedptr.hpp
index 78115c091..fbf2a40df 100644
--- a/src/misc/countedptr.hpp
+++ b/src/misc/countedptr.hpp
@@ -96,10 +96,10 @@ FORCEINLINE void CCountedPtr<Tcls_>::Assign(Tcls *pT)
{
/* if they are the same, we do nothing */
if (pT != m_pT) {
- if (pT) pT->AddRef(); // AddRef new pointer if any
- Tcls *pTold = m_pT; // save original ptr
- m_pT = pT; // update m_pT to new value
- if (pTold) pTold->Release(); // release old ptr if any
+ if (pT != NULL) pT->AddRef(); // AddRef new pointer if any
+ Tcls *pTold = m_pT; // save original ptr
+ m_pT = pT; // update m_pT to new value
+ if (pTold != NULL) pTold->Release(); // release old ptr if any
}
}
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 415f822cc..997899513 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -547,11 +547,11 @@ int ttd_main(int argc, char *argv[])
#if defined(ENABLE_NETWORK)
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.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;
#endif /* ENABLE_NETWORK */
diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp
index a975603dd..2fd930d19 100644
--- a/src/os/windows/crashlog_win.cpp
+++ b/src/os/windows/crashlog_win.cpp
@@ -526,7 +526,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
/* Close any possible log files */
CloseConsoleLogIfActive();
- if (_safe_esp) {
+ if (_safe_esp != NULL) {
#ifdef _M_AMD64
ep->ContextRecord->Rip = (DWORD64)ShowCrashlogWindow;
ep->ContextRecord->Rsp = (DWORD64)_safe_esp;
@@ -605,7 +605,7 @@ static void SetWndSize(HWND wnd, int mode)
if (mode >= 0) {
GetWindowRect(GetDlgItem(wnd, 11), &r2);
int offs = r2.bottom - r2.top + 10;
- if (!mode) offs = -offs;
+ if (mode == 0) offs = -offs;
SetWindowPos(wnd, HWND_TOPMOST, 0, 0,
r.right - r.left, r.bottom - r.top + offs, SWP_NOMOVE | SWP_NOZORDER);
} else {
diff --git a/src/pathfinder/follow_track.hpp b/src/pathfinder/follow_track.hpp
index 8656a4f05..c32b7b704 100644
--- a/src/pathfinder/follow_track.hpp
+++ b/src/pathfinder/follow_track.hpp
@@ -456,7 +456,7 @@ public:
}
/* 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;
}
};
diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp
index f8ab9c2f0..9eca606f0 100644
--- a/src/pathfinder/npf/npf.cpp
+++ b/src/pathfinder/npf/npf.cpp
@@ -981,7 +981,7 @@ static NPFFoundTargetData NPFRouteInternal(AyStarNode *start1, bool ignore_start
start1->user_data[NPF_NODE_FLAGS] = 0;
NPFSetFlag(start1, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile1);
_npf_aystar.AddStartNode(start1, 0);
- if (start2) {
+ if (start2 != NULL) {
start2->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR;
start2->user_data[NPF_NODE_FLAGS] = 0;
NPFSetFlag(start2, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile2);
diff --git a/src/settings.cpp b/src/settings.cpp
index 68e52fec6..6d36f623b 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -781,7 +781,7 @@ static bool CheckInterval(int32 p1)
vds = &Company::Get(_current_company)->settings.vehicle;
}
- if (p1) {
+ if (p1 != 0) {
vds->servint_trains = 50;
vds->servint_roadveh = 50;
vds->servint_aircraft = 50;
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index a299eeea5..d3b86c4ec 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -724,7 +724,7 @@ static void HandleString(char *str, bool master)
/* Check if the string has a case..
* The syntax for cases is IDENTNAME.case */
char *casep = strchr(str, '.');
- if (casep) *casep++ = '\0';
+ if (casep != NULL) *casep++ = '\0';
/* Check if this string already exists.. */
LangString *ent = HashFind(str);
@@ -901,7 +901,7 @@ bool CompareFiles(const char *n1, const char *n2)
fclose(f1);
return false;
}
- } while (l1);
+ } while (l1 != 0);
fclose(f2);
fclose(f1);
@@ -1320,7 +1320,7 @@ int CDECL main(int argc, char *argv[])
_masterlang = true;
ParseFile(pathbuf, true);
MakeHashOfStrings();
- if (_errors) return 1;
+ if (_errors != 0) return 1;
/* write strings.h */
ottd_mkdir(dest_dir);
@@ -1336,7 +1336,7 @@ int CDECL main(int argc, char *argv[])
ParseFile(pathbuf, true);
MakeHashOfStrings();
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 */
r = strrchr(mgo.argv[0], PATHSEPCHAR);
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index e234c9d28..05ce1aaad 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -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;
/* 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 (enterdir) *enterdir = ft.m_exitdir;
+ if (new_tracks != NULL) *new_tracks = TrackdirBitsToTrackBits(ft.m_new_td_bits);
+ if (enterdir != NULL) *enterdir = ft.m_exitdir;
return PBSTileInfo(ft.m_new_tile, ft.m_old_td, false);
}
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index dc230456d..62e8751d6 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -379,7 +379,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
SelectPalette(hDC, hOldPalette, TRUE);
ReleaseDC(hwnd, hDC);
- if (nChanged) InvalidateRect(hwnd, NULL, FALSE);
+ if (nChanged != 0) InvalidateRect(hwnd, NULL, FALSE);
return 0;
}
diff --git a/src/widget.cpp b/src/widget.cpp
index 364403e30..210ca6c8c 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -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. */
- if (nwid_cont) nwid_cont->Add(sub_widget);
- if (nwid_parent) nwid_parent->Add(sub_widget);
- if (!nwid_cont && !nwid_parent) {
+ if (nwid_cont != NULL) nwid_cont->Add(sub_widget);
+ if (nwid_parent != NULL) nwid_parent->Add(sub_widget);
+ if (nwid_cont == NULL && nwid_parent == NULL) {
*parent = sub_widget;
return total_used;
}