Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,8 @@ void CServer::SendChatTextToAllConChannels ( const int iSendingChanID, const QSt

bool CServer::SendChatTextToConChannel ( const int iCurChanID, const QString& strChatText )
{
if ( !MathUtils::InRange<int> ( iCurChanID, 0, iMaxNumChannels - 1 ) || !vecChannels[iCurChanID].IsConnected() )
// Check if iCurChanID is in range [0, iMaxNumChannels)
if ( !MathUtils::InRange<int> ( iCurChanID, 0, iMaxNumChannels ) || !vecChannels[iCurChanID].IsConnected() )
{
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -1243,11 +1243,11 @@ class MathUtils
}
}

// return true if a value is within the lower and upper bounds (inclusively), otherwise false
// Returns true if value is in [lower, upper) (inclusive lower, exclusive upper).
template<typename T>
static inline bool InRange ( T value, T lower, T upper )
static inline bool InRange ( T value, T lower /* inclusive */, T upper /* exclusive */ )
{
return !( value < lower || value > upper );
return value >= lower && value < upper;
}
};

Expand Down
Loading