Cleanup: simplify some boolean expressions

pull/332/head
Rubidium 3 years ago committed by rubidium42
parent 357af686dc
commit 281a65b3e1

@ -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
}

@ -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));

@ -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);

@ -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();
}
/**

@ -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);
}
/**

@ -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;
}
/**

@ -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;
}

@ -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;
}
/**

@ -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);
}

Loading…
Cancel
Save