summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRubidium <rubidium@openttd.org>2021-06-16 23:21:21 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-06-17 16:18:30 +0200
commit281a65b3e17310d07458652a3f6cba55aff59dc0 (patch)
treee3f06df00a9f8fc074f863b230980f2a11b066e4 /src
parent357af686dc5e0a0085da5c42639abe83caebe6c3 (diff)
downloadopenttd-281a65b3e17310d07458652a3f6cba55aff59dc0.tar.xz
Cleanup: simplify some boolean expressions
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/squirrel/squirrel/sqapi.cpp12
-rw-r--r--src/3rdparty/squirrel/squirrel/sqvm.cpp6
-rw-r--r--src/fios_gui.cpp2
-rw-r--r--src/news_gui.cpp3
-rw-r--r--src/pathfinder/npf/npf.cpp4
-rw-r--r--src/saveload/saveload.h4
-rw-r--r--src/script/api/script_list.cpp4
-rw-r--r--src/settings_gui.cpp3
-rw-r--r--src/signal.cpp4
9 files changed, 17 insertions, 25 deletions
diff --git a/src/3rdparty/squirrel/squirrel/sqapi.cpp b/src/3rdparty/squirrel/squirrel/sqapi.cpp
index aeef3779b..80c5d816e 100644
--- a/src/3rdparty/squirrel/squirrel/sqapi.cpp
+++ b/src/3rdparty/squirrel/squirrel/sqapi.cpp
@@ -135,7 +135,7 @@ void sq_close(HSQUIRRELVM v)
SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror)
{
SQObjectPtr o;
- if(Compile(v, read, p, sourcename, o, raiseerror?true:false, _ss(v)->_debuginfo)) {
+ if(Compile(v, read, p, sourcename, o, raiseerror != 0, _ss(v)->_debuginfo)) {
v->Push(SQClosure::Create(_ss(v), _funcproto(o)));
return SQ_OK;
}
@@ -144,12 +144,12 @@ SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQCha
void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable)
{
- _ss(v)->_debuginfo = enable?true:false;
+ _ss(v)->_debuginfo = enable != 0;
}
void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable)
{
- _ss(v)->_notifyallexceptions = enable?true:false;
+ _ss(v)->_notifyallexceptions = enable != 0;
}
void sq_addref(HSQUIRRELVM v,HSQOBJECT *po)
@@ -224,7 +224,7 @@ void sq_pushinteger(HSQUIRRELVM v,SQInteger n)
void sq_pushbool(HSQUIRRELVM v,SQBool b)
{
- v->Push(b?true:false);
+ v->Push(b != 0);
}
void sq_pushfloat(HSQUIRRELVM v,SQFloat n)
@@ -724,7 +724,7 @@ SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic)
if(type(self) == OT_TABLE || type(self) == OT_CLASS) {
SQObjectPtr &key = v->GetUp(-2);
if(type(key) == OT_NULL) return sq_throwerror(v, "null is not a valid key");
- v->NewSlot(self, key, v->GetUp(-1),bstatic?true:false);
+ v->NewSlot(self, key, v->GetUp(-1),bstatic != 0);
v->Pop(2);
}
return SQ_OK;
@@ -975,7 +975,7 @@ SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror,
v->_can_suspend = suspend >= 0;
if (v->_can_suspend) v->_ops_till_suspend = suspend;
- if(v->Call(v->GetUp(-(params+1)),params,v->_top-params,res,raiseerror?true:false,v->_can_suspend)){
+ if(v->Call(v->GetUp(-(params+1)),params,v->_top-params,res,raiseerror != 0,v->_can_suspend)){
if(!v->_suspended) {
v->Pop(params);//pop closure and args
}
diff --git a/src/3rdparty/squirrel/squirrel/sqvm.cpp b/src/3rdparty/squirrel/squirrel/sqvm.cpp
index b6f2c526d..1f81a2e9a 100644
--- a/src/3rdparty/squirrel/squirrel/sqvm.cpp
+++ b/src/3rdparty/squirrel/squirrel/sqvm.cpp
@@ -437,7 +437,7 @@ bool SQVM::Return(SQInteger _arg0, SQInteger _arg1, SQObjectPtr &retval)
while (last_top > oldstackbase) _stack._vals[last_top--].Null();
assert(oldstackbase >= _stackbase);
- return broot?true:false;
+ return broot != 0;
}
#define _RET_ON_FAIL(exp) { if(!exp) return false; }
@@ -653,7 +653,7 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,SQInteger baseclass,SQInteger attributes
bool SQVM::IsEqual(SQObjectPtr &o1,SQObjectPtr &o2,bool &res)
{
if(type(o1) == type(o2)) {
- res = ((_rawval(o1) == _rawval(o2)?true:false));
+ res = ((_rawval(o1) == _rawval(o2)));
}
else {
if(sq_isnumeric(o1) && sq_isnumeric(o2)) {
@@ -1028,7 +1028,7 @@ common_call:
case _OP_THROW: Raise_Error(TARGET); SQ_THROW();
case _OP_CLASS: _GUARD(CLASS_OP(TARGET,arg1,arg2)); continue;
case _OP_NEWSLOTA:
- bool bstatic = (arg0&NEW_SLOT_STATIC_FLAG)?true:false;
+ bool bstatic = (arg0&NEW_SLOT_STATIC_FLAG) != 0;
if(type(STK(arg1)) == OT_CLASS) {
if(type(_class(STK(arg1))->_metamethods[MT_NEWMEMBER]) != OT_NULL ) {
Push(STK(arg1)); Push(STK(arg2)); Push(STK(arg3));
diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp
index 2d33875f6..c0551701e 100644
--- a/src/fios_gui.cpp
+++ b/src/fios_gui.cpp
@@ -868,7 +868,7 @@ public:
this->fios_items_shown[i] = this->string_filter.GetState();
if (this->fios_items_shown[i]) items_shown_count++;
- if (&(this->fios_items[i]) == this->selected && this->fios_items_shown[i] == false) {
+ if (&(this->fios_items[i]) == this->selected && !this->fios_items_shown[i]) {
/* The selected element has been filtered out */
this->selected = nullptr;
this->OnInvalidateData(SLIWD_SELECTION_CHANGES);
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 731eb95c2..5c72f8741 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -639,8 +639,7 @@ static bool ReadyForNextTickerItem()
/* Ticker message
* Check if the status bar message is still being displayed? */
- if (IsNewsTickerShown()) return false;
- return true;
+ return !IsNewsTickerShown();
}
/**
diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp
index 733b2eba9..588718185 100644
--- a/src/pathfinder/npf/npf.cpp
+++ b/src/pathfinder/npf/npf.cpp
@@ -826,9 +826,7 @@ static bool CanEnterTile(TileIndex tile, DiagDirection dir, AyStarUserData *user
/* Depots, standard roadstops and single tram bits can only be entered from one direction */
DiagDirection single_entry = GetTileSingleEntry(tile, user->type, user->subtype);
- if (single_entry != INVALID_DIAGDIR && single_entry != ReverseDiagDir(dir)) return false;
-
- return true;
+ return single_entry == INVALID_DIAGDIR || single_entry == ReverseDiagDir(dir);
}
/**
diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h
index dfd687f35..8456da415 100644
--- a/src/saveload/saveload.h
+++ b/src/saveload/saveload.h
@@ -956,9 +956,7 @@ static inline bool IsSavegameVersionUntil(SaveLoadVersion major)
static inline bool SlIsObjectCurrentlyValid(SaveLoadVersion version_from, SaveLoadVersion version_to)
{
extern const SaveLoadVersion SAVEGAME_VERSION;
- if (SAVEGAME_VERSION < version_from || SAVEGAME_VERSION >= version_to) return false;
-
- return true;
+ return version_from <= SAVEGAME_VERSION && SAVEGAME_VERSION < version_to;
}
/**
diff --git a/src/script/api/script_list.cpp b/src/script/api/script_list.cpp
index 1985cdbfb..623128bdd 100644
--- a/src/script/api/script_list.cpp
+++ b/src/script/api/script_list.cpp
@@ -468,7 +468,7 @@ int64 ScriptList::Begin()
int64 ScriptList::Next()
{
- if (this->initialized == false) {
+ if (!this->initialized) {
Debug(script, 0, "Next() is invalid as Begin() is never called");
return 0;
}
@@ -482,7 +482,7 @@ bool ScriptList::IsEmpty()
bool ScriptList::IsEnd()
{
- if (this->initialized == false) {
+ if (!this->initialized) {
Debug(script, 0, "IsEnd() is invalid as Begin() is never called");
return true;
}
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index b17b343c7..a63448aef 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -930,8 +930,7 @@ void BaseSettingEntry::Init(byte level)
bool BaseSettingEntry::IsVisible(const BaseSettingEntry *item) const
{
if (this->IsFiltered()) return false;
- if (this == item) return true;
- return false;
+ return this == item;
}
/**
diff --git a/src/signal.cpp b/src/signal.cpp
index 4a7e7913e..329b1b05d 100644
--- a/src/signal.cpp
+++ b/src/signal.cpp
@@ -216,9 +216,7 @@ static inline bool CheckAddToTodoSet(TileIndex t1, DiagDirection d1, TileIndex t
assert(!_tbdset.IsIn(t1, d1)); // it really shouldn't be there already
- if (_tbdset.Remove(t2, d2)) return false;
-
- return true;
+ return !_tbdset.Remove(t2, d2);
}