mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r22145) -Codechange: Do explicit test for non-bool values.
This commit is contained in:
parent
1dbc0a20be
commit
31386c42a7
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue