Changeset - r25709:feac296d221b
[Not reviewed]
master
0 9 0
Rubidium - 3 years ago 2021-06-16 21:21:21
rubidium@openttd.org
Cleanup: simplify some boolean expressions
9 files changed with 17 insertions and 25 deletions:
0 comments (0 inline, 0 general)
src/3rdparty/squirrel/squirrel/sqapi.cpp
Show inline comments
 
@@ -132,27 +132,27 @@ void sq_close(HSQUIRRELVM v)
 
	sq_delete(ss, SQSharedState);
 
}
 

	
 
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;
 
	}
 
	return SQ_ERROR;
 
}
 

	
 
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)
 
{
 
	if(!ISREFCOUNTED(type(*po))) return;
 
#ifdef NO_GARBAGE_COLLECTOR
 
@@ -221,13 +221,13 @@ void sq_pushinteger(HSQUIRRELVM v,SQInte
 
{
 
	v->Push(n);
 
}
 

	
 
void sq_pushbool(HSQUIRRELVM v,SQBool b)
 
{
 
	v->Push(b?true:false);
 
	v->Push(b != 0);
 
}
 

	
 
void sq_pushfloat(HSQUIRRELVM v,SQFloat n)
 
{
 
	v->Push(n);
 
}
 
@@ -721,13 +721,13 @@ SQRESULT sq_newslot(HSQUIRRELVM v, SQInt
 
{
 
	sq_aux_paramscheck(v, 3);
 
	SQObjectPtr &self = stack_get(v, idx);
 
	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;
 
}
 

	
 
SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval)
 
@@ -972,13 +972,13 @@ SQRESULT sq_resume(HSQUIRRELVM v,SQBool 
 
SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror, int suspend)
 
{
 
	SQObjectPtr res;
 
	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
 
		}
 
		if(retval){
 
			v->Push(res); return SQ_OK;
 
		}
src/3rdparty/squirrel/squirrel/sqvm.cpp
Show inline comments
 
@@ -434,13 +434,13 @@ bool SQVM::Return(SQInteger _arg0, SQInt
 
				STK(target) = _null_;
 
		}
 
	}
 

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

	
 
bool SQVM::LOCAL_INC(SQInteger op,SQObjectPtr &target, SQObjectPtr &a, SQObjectPtr &incr)
 
{
 
@@ -650,13 +650,13 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,
 

	
 

	
 

	
 
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)) {
 
			SQInteger cmpres;
 
			if(!ObjCmp(o1, o2,cmpres)) return false;
 
			res = (cmpres == 0);
 
@@ -1025,13 +1025,13 @@ common_call:
 
				}
 
							  }
 
				continue;
 
			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));
 
						Push((arg0&NEW_SLOT_ATTRIBUTES_FLAG) ? STK(arg2-1) : _null_);
 
						Push(bstatic);
 
						int nparams = 5;
src/fios_gui.cpp
Show inline comments
 
@@ -865,13 +865,13 @@ public:
 
						this->string_filter.ResetState();
 
						this->string_filter.AddLine(this->fios_items[i].title);
 
						/* We set the vector to show this fios element as filtered depending on the result of the filter */
 
						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);
 
						}
 
					}
 
				}
src/news_gui.cpp
Show inline comments
 
@@ -636,14 +636,13 @@ static bool ReadyForNextTickerItem()
 
{
 
	const NewsItem *ni = _statusbar_news_item;
 
	if (ni == nullptr) return true;
 

	
 
	/* Ticker message
 
	 * Check if the status bar message is still being displayed? */
 
	if (IsNewsTickerShown()) return false;
 
	return true;
 
	return !IsNewsTickerShown();
 
}
 

	
 
/**
 
 * Are we ready to show another news item?
 
 * Only if no newspaper is displayed
 
 */
src/pathfinder/npf/npf.cpp
Show inline comments
 
@@ -823,15 +823,13 @@ static bool CanEnterTile(TileIndex tile,
 

	
 
		default: break;
 
	}
 

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

	
 
/**
 
 * Returns the driveable Trackdirs on a tile.
 
 *
 
 * One-way-roads are taken into account. Signals are not tested.
src/saveload/saveload.h
Show inline comments
 
@@ -953,15 +953,13 @@ static inline bool IsSavegameVersionUnti
 
 * @param version_to   Exclusive savegame version upper bound. SL_MAX_VERSION if no upper bound.
 
 * @return Active savegame version falls within the given range.
 
 */
 
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;
 
}
 

	
 
/**
 
 * Get the NumberType of a setting. This describes the integer type
 
 * as it is represented in memory
 
 * @param type VarType holding information about the variable-type
src/script/api/script_list.cpp
Show inline comments
 
@@ -465,13 +465,13 @@ int64 ScriptList::Begin()
 
	this->initialized = true;
 
	return this->sorter->Begin();
 
}
 

	
 
int64 ScriptList::Next()
 
{
 
	if (this->initialized == false) {
 
	if (!this->initialized) {
 
		Debug(script, 0, "Next() is invalid as Begin() is never called");
 
		return 0;
 
	}
 
	return this->sorter->Next();
 
}
 

	
 
@@ -479,13 +479,13 @@ bool ScriptList::IsEmpty()
 
{
 
	return this->items.empty();
 
}
 

	
 
bool ScriptList::IsEnd()
 
{
 
	if (this->initialized == false) {
 
	if (!this->initialized) {
 
		Debug(script, 0, "IsEnd() is invalid as Begin() is never called");
 
		return true;
 
	}
 
	return this->sorter->IsEnd();
 
}
 

	
src/settings_gui.cpp
Show inline comments
 
@@ -927,14 +927,13 @@ void BaseSettingEntry::Init(byte level)
 
 * @param item Entry to search for.
 
 * @return true if entry is visible.
 
 */
 
bool BaseSettingEntry::IsVisible(const BaseSettingEntry *item) const
 
{
 
	if (this->IsFiltered()) return false;
 
	if (this == item) return true;
 
	return false;
 
	return this == item;
 
}
 

	
 
/**
 
 * Find setting entry at row \a row_num
 
 * @param row_num Index of entry to return
 
 * @param cur_row Current row number
src/signal.cpp
Show inline comments
 
@@ -213,15 +213,13 @@ static inline bool CheckAddToTodoSet(Til
 
{
 
	_globset.Remove(t1, d1); // it can be in Global but not in Todo
 
	_globset.Remove(t2, d2); // remove in all cases
 

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

	
 

	
 
/**
 
 * Perform some operations before adding data into Todo set
 
 * The new and reverse direction is removed from Global set, because we are sure
0 comments (0 inline, 0 general)