void CSoundEmitterSystemBase::RenameSound( const char *soundname, const char *newname ) { // Same name? if ( !Q_stricmp( soundname, newname ) ) { return; } int oldindex = GetSoundIndex( soundname ); if ( !IsValidIndex( oldindex ) ) { Msg( "Can't rename %s, no such sound\n", soundname ); return; } int check = GetSoundIndex( newname ); if ( IsValidIndex( check ) ) { Msg( "Can't rename %s to %s, new name already in list\n", soundname, newname ); return; } // Copy out old entry CSoundEntry entry = m_Sounds[ oldindex ]; // Remove it m_Sounds.Remove( soundname ); // Re-insert in new spot m_Sounds.Insert( newname, entry ); // Mark associated script as dirty m_SoundKeyValues[ entry.m_nScriptFileIndex ].dirty = true; }
TPolicy CPolicyHandler::GetPolicy(TUid aUid, TUint aAction) { TInt cpIdx = FindControlPolicy(aUid); if(IsValidIndex(cpIdx)) { TInt apIdx = FindActionPolicy(iPolicies[cpIdx], aAction); if(IsValidIndex(apIdx)) { return iPolicies[cpIdx]->iActions[apIdx].iPolicy; } } return ENotSupported; }
wxString SCH_FIND_COLLECTOR::GetText() { wxCHECK_MSG( (GetCount() != 0) && IsValidIndex( m_foundIndex ), wxEmptyString, wxT( "Cannot get found item at invalid index." ) ); SCH_FIND_COLLECTOR_DATA data = m_data[ m_foundIndex ]; EDA_ITEM* foundItem = m_List[ m_foundIndex ]; wxCHECK_MSG( foundItem != NULL, wxEmptyString, wxT( "Invalid found item pointer." ) ); wxString msg; if( data.GetParent() ) { msg.Printf( _( "Child item %s of parent item %s found in sheet %s" ), GetChars( foundItem->GetSelectMenuText() ), GetChars( data.GetParent()->GetSelectMenuText() ), GetChars( data.GetSheetPath() ) ); } else { msg.Printf( _( "Item %s found in sheet %s" ), GetChars( foundItem->GetSelectMenuText() ), GetChars( data.GetSheetPath() ) ); } return msg; }
BOOL CTeleportPath::MakeDistanceTable() { if (m_ppTable == NULL) return FALSE; // convert the graph into a distance table for (int x = 0; x < m_nCX; x++) { for (int y = 0; y < m_nCY; y++) { if ((m_ppTable[x][y] % 2) == 0) m_ppTable[x][y] = (short)CalculateDistance(x, y, m_ptEnd.x, m_ptEnd.y); else m_ppTable[x][y] = RANGE_INVALID; } } if(m_ptEnd.y >= m_nCY) m_ptEnd.y = m_nCY - 1; if(!IsValidIndex(m_ptEnd.x, m_ptEnd.y)) return false; m_ppTable[m_ptEnd.x][m_ptEnd.y] = 1; return TRUE; }
void nsMsgThreadedDBView::OnExtraFlagChanged(nsMsgViewIndex index, PRUint32 extraFlag) { if (IsValidIndex(index)) { if (m_havePrevView) { nsMsgKey keyChanged = m_keys[index]; nsMsgViewIndex prevViewIndex = m_prevKeys.IndexOf(keyChanged); if (prevViewIndex != nsMsgViewIndex_None) { PRUint32 prevFlag = m_prevFlags[prevViewIndex]; // don't want to change the elided bit, or has children or is thread if (prevFlag & nsMsgMessageFlags::Elided) extraFlag |= nsMsgMessageFlags::Elided; else extraFlag &= ~nsMsgMessageFlags::Elided; if (prevFlag & MSG_VIEW_FLAG_ISTHREAD) extraFlag |= MSG_VIEW_FLAG_ISTHREAD; else extraFlag &= ~MSG_VIEW_FLAG_ISTHREAD; if (prevFlag & MSG_VIEW_FLAG_HASCHILDREN) extraFlag |= MSG_VIEW_FLAG_HASCHILDREN; else extraFlag &= ~MSG_VIEW_FLAG_HASCHILDREN; m_prevFlags[prevViewIndex] = extraFlag; // will this be right? } } } // we don't really know what's changed, but to be on the safe side, set the sort invalid // so that reverse sort will pick it up. if (m_sortType == nsMsgViewSortType::byStatus || m_sortType == nsMsgViewSortType::byFlagged || m_sortType == nsMsgViewSortType::byUnread || m_sortType == nsMsgViewSortType::byPriority) m_sortValid = false; }
CBoundaryTreeNode* CBoundaryTree::pNode( int nodeIdx ) { //return a pointer to the node at nodeIdx if(IsValidIndex(nodeIdx)) return( &(data[nodeIdx]) ); return NULL; }
CBoundaryTreeNode* CBoundaryTree::pRoot() { //return a pointer to the root node if(IsValidIndex(rootIdx)) return( &(data[rootIdx]) ); return NULL; }
// add new header using the argument as a template CZipFileHeader* CZipCentralDir::AddNewFile(const CZipFileHeader & header, int iReplaceIndex) { CZipFileHeader* pHeader = new CZipFileHeader(header); m_pOpenedFile = pHeader; WORD uIndex; DWORD uOffset = 0; bool bReplace = IsValidIndex(iReplaceIndex); if (bReplace) { CZipFileHeader* pfh = m_headers[iReplaceIndex]; uOffset = pfh->m_uOffset + m_info.m_uBytesBeforeZip; RemoveFile(pfh, iReplaceIndex, false); m_headers.InsertAt(iReplaceIndex, pHeader); uIndex = (WORD)iReplaceIndex; } else uIndex = m_headers.Add(pHeader); if (m_bFindFastEnabled) InsertFindFastElement(pHeader, uIndex); // GetCount > 0, 'cos we've just added a header RemoveFromDisk(); if (bReplace) m_pStorage->m_pFile->Seek(uOffset, CZipAbstractFile::begin); else m_pStorage->m_pFile->SeekToEnd(); return pHeader; }
bool CParseChannelSettingConfig::GetChannelSettingInfo( unsigned int nChannelNum, CHANNEL_SETTING_INFO* pChannelSettingInfo, bool bNew ) { if( !IsValidIndex(nChannelNum) ) return false; if( NULL == pChannelSettingInfo ) return false; for( int i=0; i< m_vecChannelSettingInfo.count(); i++ ) { if( nChannelNum == m_vecChannelSettingInfo[i].nChannelNum ) { pChannelSettingInfo->nChannelNum = bNew?m_vecNewChannelSettingInfo[i].nChannelNum:m_vecChannelSettingInfo[i].nChannelNum; pChannelSettingInfo->enuQuality = bNew?m_vecNewChannelSettingInfo[i].enuQuality:m_vecChannelSettingInfo[i].enuQuality; pChannelSettingInfo->bRtmpEnable1 = bNew?m_vecNewChannelSettingInfo[i].bRtmpEnable1:m_vecChannelSettingInfo[i].bRtmpEnable1; pChannelSettingInfo->strRtmpAddr1 = bNew?m_vecNewChannelSettingInfo[i].strRtmpAddr1:m_vecChannelSettingInfo[i].strRtmpAddr1; pChannelSettingInfo->nRtmpAudioDelay1 = bNew?m_vecNewChannelSettingInfo[i].nRtmpAudioDelay1:m_vecChannelSettingInfo[i].nRtmpAudioDelay1; pChannelSettingInfo->bRtmpEnable2 = bNew?m_vecNewChannelSettingInfo[i].bRtmpEnable2:m_vecChannelSettingInfo[i].bRtmpEnable2; pChannelSettingInfo->strRtmpAddr2 = bNew?m_vecNewChannelSettingInfo[i].strRtmpAddr2:m_vecChannelSettingInfo[i].strRtmpAddr2; pChannelSettingInfo->nRtmpAudioDelay2 = bNew?m_vecNewChannelSettingInfo[i].nRtmpAudioDelay2:m_vecChannelSettingInfo[i].nRtmpAudioDelay2; pChannelSettingInfo->bUdpOrRtpEnable = bNew?m_vecNewChannelSettingInfo[i].bUdpOrRtpEnable:m_vecChannelSettingInfo[i].bUdpOrRtpEnable; pChannelSettingInfo->bUdpOrRtpAddr = bNew?m_vecNewChannelSettingInfo[i].bUdpOrRtpAddr:m_vecChannelSettingInfo[i].bUdpOrRtpAddr; pChannelSettingInfo->strUdpOrRtpIp = bNew?m_vecNewChannelSettingInfo[i].strUdpOrRtpIp:m_vecChannelSettingInfo[i].strUdpOrRtpIp; pChannelSettingInfo->nUdpOrRtpPort = bNew?m_vecNewChannelSettingInfo[i].nUdpOrRtpPort:m_vecChannelSettingInfo[i].nUdpOrRtpPort; pChannelSettingInfo->nUdpOrRtpAudioDelay = bNew?m_vecNewChannelSettingInfo[i].nUdpOrRtpAudioDelay:m_vecChannelSettingInfo[i].nUdpOrRtpAudioDelay; pChannelSettingInfo->nInputVideoFormat = bNew?m_vecNewChannelSettingInfo[i].nInputVideoFormat:m_vecChannelSettingInfo[i].nInputVideoFormat; pChannelSettingInfo->nOutputVideoFormat = bNew?m_vecNewChannelSettingInfo[i].nOutputVideoFormat:m_vecChannelSettingInfo[i].nOutputVideoFormat; break; } } return true; }
//----------------------------------------------------------------------------- // Purpose: // Input : index - // Output : char const //----------------------------------------------------------------------------- const char *CSoundEmitterSystemBase::GetSoundName( int index ) { if ( !IsValidIndex( index ) ) return ""; return m_Sounds.GetElementName( index ); }
void CUtlVector<T, A>::ShiftElementsRight(int elem, int num) { assert(IsValidIndex(elem) || (m_Size == 0) || (num == 0)); int numToMove = m_Size - elem - num; if((numToMove > 0) && (num > 0)) memmove(&Element(elem + num), &Element(elem), numToMove * sizeof(T)); }
// Set the light level on the specified palette (with special cockpit reflection alpha) void PaletteBankClass::LightReflectionPalette( int id, Tcolor *light ) { if ( !IsValidIndex(id) ) { return; } PalettePool[id].LightTexturePaletteReflection( light ); }
// Set the light level on the specified palette (with special building lights) void PaletteBankClass::LightBuildingPalette( int id, Tcolor *light ) { if ( !IsValidIndex(id) ) { return; } PalettePool[id].LightTexturePaletteBuilding( light ); }
// ============================================================================ // ============================================================================ IVistaNode* VistaGroupNode::GetChild(unsigned int nChildindex) const { //index-check if(IsValidIndex(nChildindex)) return m_vecChildren[nChildindex]; else return NULL; }
//----------------------------------------------------------------------------- // Purpose: // Input : index - // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CSoundEmitterSystemBase::GetShouldAlwaysPrecacheSound( int index ) { if ( !IsValidIndex( index ) ) return false; CSoundEntry const *entry = &m_Sounds[ index ]; return entry->m_bPrecacheAlways; }
int Field::Value(int x, int y) { if (IsValidIndex(x, y)) { return GetCell(x, y).GetValue(); } return -1; }
///////////////////////////////////////////////////////////////////// // The "Get Best Move" Algorithm // // Originally developed by Niren7, Modified by Abin ///////////////////////////////////////////////////////////////////// BOOL CTeleportPath::GetBestMove(POINT& pos, int nAdjust) { if(CalculateDistance(m_ptEnd, pos) <= TP_RANGE) { pos = m_ptEnd; return PATH_REACHED; // we reached the destination } if (!IsValidIndex(pos.x, pos.y)) return PATH_FAIL; // fail Block(pos, nAdjust); POINT p, best; int value = RANGE_INVALID; DWORD LeftX = pos.x, LeftY = pos.y; if( pos.x < TP_RANGE ) LeftX += ( TP_RANGE - pos.x); if( pos.y < TP_RANGE) LeftY += ( TP_RANGE - pos.y); for (p.x = LeftX - TP_RANGE; p.x <= LeftX + TP_RANGE; p.x++) { for (p.y = LeftY - TP_RANGE; p.y <= LeftY + TP_RANGE; p.y++) { if (!IsValidIndex(p.x, p.y)) continue; if (m_ppTable[p.x][p.y] < value && CalculateDistance(p, pos) <= TP_RANGE) { value = m_ppTable[p.x][p.y]; best = p; } } } if (value >= RANGE_INVALID) return PATH_FAIL; // no path at all pos = best; Block(pos, nAdjust); return PATH_CONTINUE; // ok but not reached yet }
bool Reader::GetInt64(int index, int64_t & val) { if(! IsValidIndex(index)) { return false; } val = sqlite3_column_int64(m_cmd->m_st, index); return true; }
bool Reader::GetDouble(int index, double & val) { if(! IsValidIndex(index)) { return false; } val = sqlite3_column_double(m_cmd->m_st, index); return true; }
bool Reader::GetString(int index, CString & val) { if(! IsValidIndex(index)) { return false; } val = (LPCTSTR) sqlite3_column_text16(m_cmd->m_st, index); return true; }
void const * Reader::GetBlob(int index, int & size) { if(! IsValidIndex(index)) { size = -1; return 0; } size = sqlite3_column_bytes(m_cmd->m_st, index); return sqlite3_column_blob(m_cmd->m_st, index); }
int CUtlVector<T, A>::InsertBefore(int elem) { // Can insert at the end assert((elem == Count()) || IsValidIndex(elem)); GrowVector(); ShiftElementsRight(elem); Construct(&Element(elem)); return elem; }
CBoundaryTreeNode* CBoundaryTree::pRSibling(CBoundaryTreeNode* pNode) { //return a reference to the right sibling node of this node //if the node has not right sibling, return NULL ASSERT( pNode->IsValid() ); if( IsValidIndex(pNode->rSiblingIdx) ) { return( &(data[pNode->rSiblingIdx]) ); } return(NULL); }
CBoundaryTreeNode* CBoundaryTree::pLChild(CBoundaryTreeNode* pNode) { //return a reference to the left child node of this node //if the node has no left child, return NULL ASSERT( pNode->IsValid() ); if( IsValidIndex(pNode->lChildIdx) ) { return( &(data[pNode->lChildIdx]) ); } return(NULL); }
CBoundaryTreeNode* CBoundaryTree::pParent(CBoundaryTreeNode* pNode) { //return a pointer to the parent node of this node //if the node has no parent (e.g. is a root), return NULL ASSERT( pNode->IsValid() ); if( IsValidIndex(pNode->parentIdx) ) { return( &(data[pNode->parentIdx]) ); } return(NULL); }
void CUtlVector<T, A>::FastRemove(int elem) { assert(IsValidIndex(elem)); Destruct(&Element(elem)); if(m_Size > 0) { if(elem != m_Size - 1) memcpy(&Element(elem), &Element(m_Size - 1), sizeof(T)); --m_Size; } }
void CUtlVector<T, A>::ShiftElementsLeft(int elem, int num) { assert(IsValidIndex(elem) || (m_Size == 0) || (num == 0)); int numToMove = m_Size - elem - num; if((numToMove > 0) && (num > 0)) { memmove(&Element(elem), &Element(elem + num), numToMove * sizeof(T)); #ifdef _DEBUG memset(&Element(m_Size - num), 0xDD, num * sizeof(T)); #endif } }
void* List::GetAt(int32_t nIndex) { if ( !IsValidIndex(nIndex) ) return NULL; AutoLock autoLock(&mLock); Node* p = m_pHead; for (int32_t i = 0; i < nIndex; i++) p = p->m_pNext; return p->m_data; }
int CUtlVector<T, A>::InsertBefore(int elem, const T& src) { // Can't insert something that's in the list... reallocation may hose us assert((Base() == NULL) || (&src < Base()) || (&src >= (Base() + Count()))); // Can insert at the end assert((elem == Count()) || IsValidIndex(elem)); GrowVector(); ShiftElementsRight(elem); CopyConstruct(&Element(elem), src); return elem; }
NS_IMETHODIMP nsMsgGroupView::GetCellProperties(int32_t aRow, nsITreeColumn *aCol, nsAString& aProperties) { if (!IsValidIndex(aRow)) return NS_MSG_INVALID_DBVIEW_INDEX; if (m_flags[aRow] & MSG_VIEW_FLAG_DUMMY) { aProperties.AssignLiteral("dummy"); return NS_OK; } return nsMsgDBView::GetCellProperties(aRow, aCol, aProperties); }