Obj_T & BTreeIterator<Key_T,Obj_T>:: current() //----------------------------------- { InternalAssert( _currObj != NULL ); return *_currObj; // might be NULL, but c'est la vie }
int MergeInfoSection::getFileLenDelta( MergeFile * file, MergeOffset& moff, uint_32 form ) //------------------------------------------------------------- { uint_32 oldIdx; uint_32 newIdx; int delta; switch( form ) { case DW_FORM_udata: oldIdx = file->readULEB128( DR_DEBUG_INFO, moff.offset ); break; case DW_FORM_sdata: oldIdx = file->readSLEB128( DR_DEBUG_INFO, moff.offset ); break; default: InternalAssert( 0 /* unknown form for fileLenDelta */ ); file->skipForm( DR_DEBUG_INFO, moff.offset, form, getAddrSize() ); return 0; } newIdx = _line.getNewFileIdx( moff.fileIdx, (uint_16) oldIdx ); delta = MergeFile::ULEB128Len( newIdx ); delta -= MergeFile::ULEB128Len( oldIdx ); #if ( INSTRUMENTS == INSTRUMENTS_FULL_LOGGING ) Log.printf( "FileLenDelta from %x to %x -- %d\n", oldIdx, newIdx, delta ); #endif return (DIELen_T) delta; }
bool BTreeIterator<Key_T,Obj_T>:: operator++ () //----------------------------------- { SearchEntry<Key_T,Obj_T> entry; BTreeNodeBase<Key_T,Obj_T> * next; if( _stack == NULL ) { _stack = new WCValOrderedVector< SearchEntry<Key_T,Obj_T> >( 200, 100 ); next = _tree->getRoot(); if( next == NULL ) return FALSE; //<----- early return for empty tree do { entry._entry = -1; entry._node = next; next = entry.nextNode(); _stack->append( entry ); } while( next != NULL ); } InternalAssert( _stack->entries() != 0 ); _tree->unlock( _currObj ); // might be NULL, but that's ok to unlock while( 1 ) { entry = (*_stack)[ _stack->entries() - 1 ]; _stack->removeLast(); _currObj = entry.nextObj(); _stack->append( entry ); if( _currObj != NULL ) { _tree->lock( _currObj ); return TRUE; // <------- next object found } do { _stack->removeLast(); // discard empty node if( _stack->entries() == 0 ) { _currObj = NULL; _stack->clear(); // redundant, but what the hey delete _stack; _stack = NULL; return FALSE; // <------- end of objects } next = (*_stack)[ _stack->entries() - 1 ].nextNode(); } while( next == NULL ); do { entry._node = next; entry._entry = -1; next = entry.nextNode(); _stack->append( entry ); } while( next != NULL ); } }
// VC1 or Chicago pre-Beta VC2 void AFXAPI AfxAssertFailedLine(LPCSTR lpszFileName, INT32 nLine) #endif { #ifdef _MAC // ignore an incredibly annoying Mac assert which is something to do with rendering // the icons on our scroll bars if ( (nLine==119) && (camStrcmp(lpszFileName, "winbtn.cpp")==0) ) return FALSE; #endif // must NOT use MFC for reporting this InternalAssert( _T("MFC Ensure"), lpszFileName, nLine, FALSE ); #if COMPILER_REVISION >= 3 return FALSE; #endif }
const char * MergeFile::readString( dr_section sect, uint_32& off ) //----------------------------------------------------------------- { int i; uint_8 b; for( i = 0; ; i += 1 ) { b = readByte( sect, off ); _buffer[ i ] = b; if( b == '\0' || i >= MERGEFILESTRBUF ) break; } InternalAssert( i < MERGEFILESTRBUF ); // NYI -- throw or truncate? if( _buffer[ 0 ] == 0 ) { return NULL; // <-------- early return for empty string } return _buffer; }
void MergeLineSection::addDirectory( uint_8 fileIdx, uint_16 oldDirIdx, MergeStringHdl & dir ) //--------------------------------------------------------------------- { uint_16 newDirIdx; MergeFileRelocKey relKey( fileIdx, oldDirIdx ); // NYI -- if oldDirIdx == 0, then it means in the current compile // directory, but that will possibly be different accross compunits. InternalAssert( oldDirIdx != 0 ); // NYI throw if( _directoriesByName->contains( dir ) ) { newDirIdx = (*_directoriesByName)[ dir ]; } else { newDirIdx = (uint_16)( _directories->entries() + 1 ); _directories->append( dir ); (*_directoriesByName)[ dir ] = newDirIdx; } (*_directoriesReloc)[ relKey ] = newDirIdx; }
int BotControl::CreateBot (String name, int skill, int personality, int team, int member) { // this function completely prepares bot entity (edict) for creation, creates team, skill, sets name etc, and // then sends result to bot constructor edict_t *bot = null; char outputName[33]; if (g_numWaypoints < 1) // don't allow creating bots with no waypoints loaded { CenterPrint ("Map not waypointed. Can't Create Bot"); return 0; } else if (g_waypointsChanged) // don't allow creating bots with changed waypoints (distance tables are messed up) { CenterPrint ("Waypoints has been changed. Load waypoints again..."); return 0; } if (skill < 0 || skill > 100) skill = engine->RandomInt (yb_minskill.GetInt (), yb_maxskill.GetInt ()); if (skill > 100 || skill < 0) skill = engine->RandomInt (0, 100); if (personality < 0 || personality > 2) { int randomPrecent = engine->RandomInt (0, 100); if (randomPrecent < 50) personality = PERSONALITY_NORMAL; else { if (engine->RandomInt (0, randomPrecent) < randomPrecent * 0.5) personality = PERSONALITY_CAREFUL; else personality = PERSONALITY_RUSHER; } } // setup name if (name.IsEmpty ()) { if (!g_botNames.IsEmpty ()) { bool nameFound = false; for (int i = 0; i < 8; i++) { if (nameFound) break; NameItem &botName = g_botNames.GetRandomElement (); if (botName.isUsed) continue; botName.isUsed = nameFound = true; strcpy (outputName, botName.name); } } else sprintf (outputName, "bot%i", engine->RandomInt (0, 100)); // just pick ugly random name } else strncpy (outputName, name, 21); if (!IsNullString (yb_nameprefix.GetString ()) || yb_skilltags.GetBool ()) { char prefixedName[33]; // temp buffer for storing modified name if (!IsNullString (yb_nameprefix.GetString ())) sprintf (prefixedName, "%s %s", yb_nameprefix.GetString (), outputName); else if (yb_skilltags.GetBool ()) sprintf (prefixedName, "%s (%d)", outputName, skill); else if (!IsNullString (yb_nameprefix.GetString ()) && yb_skilltags.GetBool ()) sprintf (prefixedName, "%s %s (%d)", yb_nameprefix.GetString (), outputName, skill); // buffer has been modified, copy to real name if (!IsNullString (prefixedName)) sprintf (outputName, prefixedName); } if (FNullEnt ((bot = (*g_engfuncs.pfnCreateFakeClient) (outputName)))) { CenterPrint ("Maximum players reached (%d/%d). Unable to create Bot.", engine->GetMaxClients (), engine->GetMaxClients ()); return 2; } int index = ENTINDEX (bot) - 1; InternalAssert (index >= 0 && index <= 32); // check index InternalAssert (m_bots[index] == null); // check bot slot m_bots[index] = new Bot (bot, skill, personality, team, member); if (m_bots == null) TerminateOnMalloc (); if (engine->GetDeveloperLevel () > 0) ServerPrint ("Connecting '%s'... (Skill %d)", STRING (bot->v.netname), skill); else ServerPrint ("Connecting YaPB... (Skill %d)", skill); return 1; }
void Bot::CheckReload (void) { // check the reload state if (GetCurrentTask ()->taskID == TASK_ESCAPEFROMBOMB || GetCurrentTask ()->taskID == TASK_PLANTBOMB || GetCurrentTask ()->taskID == TASK_DEFUSEBOMB || GetCurrentTask ()->taskID == TASK_PICKUPITEM || GetCurrentTask ()->taskID == TASK_THROWFBGRENADE || GetCurrentTask ()->taskID == TASK_THROWSMGRENADE || m_isUsingGrenade) { m_reloadState = RSTATE_NONE; return; } m_isReloading = false; // update reloading status m_reloadCheckTime = engine->GetTime () + 1.0f; if (m_reloadState != RSTATE_NONE) { int weaponIndex = 0, maxClip = 0; int weapons = pev->weapons; if (m_reloadState == RSTATE_PRIMARY) weapons &= WeaponBits_Primary; else if (m_reloadState == RSTATE_SECONDARY) weapons &= WeaponBits_Secondary; if (weapons == 0) { m_reloadState++; if (m_reloadState > RSTATE_SECONDARY) m_reloadState = RSTATE_NONE; return; } for (int i = 1; i < Const_MaxWeapons; i++) { if (weapons & (1 << i)) { weaponIndex = i; break; } } InternalAssert (weaponIndex); switch (weaponIndex) { case WEAPON_M249: maxClip = 100; break; case WEAPON_P90: maxClip = 50; break; case WEAPON_GALIL: maxClip = 35; break; case WEAPON_ELITE: case WEAPON_MP5: case WEAPON_TMP: case WEAPON_MAC10: case WEAPON_M4A1: case WEAPON_AK47: case WEAPON_SG552: case WEAPON_AUG: case WEAPON_SG550: maxClip = 30; break; case WEAPON_UMP45: case WEAPON_FAMAS: maxClip = 25; break; case WEAPON_GLOCK18: case WEAPON_FN57: case WEAPON_G3SG1: maxClip = 20; break; case WEAPON_P228: maxClip = 13; break; case WEAPON_USP: maxClip = 12; break; case WEAPON_AWP: case WEAPON_SCOUT: maxClip = 10; break; case WEAPON_M3: maxClip = 8; break; case WEAPON_DEAGLE: case WEAPON_XM1014: maxClip = 7; break; } if (m_ammoInClip[weaponIndex] < (maxClip * 0.8) && m_ammo[g_weaponDefs[weaponIndex].ammo1] > 0) { if (m_currentWeapon != weaponIndex) SelectWeaponByName (g_weaponDefs[weaponIndex].className); if ((pev->oldbuttons & IN_RELOAD) == RSTATE_NONE) pev->button |= IN_RELOAD; // press reload button m_isReloading = true; m_fearLevel = 1.0f; // SyPB Pro P.7 } else { // if we have enemy don't reload next weapon if ((m_states & (STATE_SEEINGENEMY | STATE_HEARENEMY)) || m_seeEnemyTime + 5.0f > engine->GetTime ()) { m_reloadState = RSTATE_NONE; return; } m_reloadState++; if (m_reloadState > RSTATE_SECONDARY) m_reloadState = RSTATE_NONE; return; } } }
void EnsureFailedLine(const TCHAR * AssertDescription, const char * lpszFileName, INT32 nLine) { InternalAssert( AssertDescription, lpszFileName, nLine, TRUE ); }
void MergeFile::copyFormTo( MergeFile& out, dr_section sect, uint_32& off, uint_32 form, uint_8 addrSize ) //----------------------------------------------------------------------- { uint_32 num; char * buffer; uint_32 bufLen; uint_8 buf8[ 8 ]; switch( form ) { /* do all simple numeric forms */ case DW_FORM_addr: case DW_FORM_flag: case DW_FORM_data1: case DW_FORM_ref1: case DW_FORM_data2: case DW_FORM_ref2: case DW_FORM_data4: case DW_FORM_ref4: case DW_FORM_sdata: case DW_FORM_udata: case DW_FORM_ref_udata: case DW_FORM_ref_addr: num = readForm( sect, off, form, addrSize ); out.writeForm( form, num, addrSize ); break; case DW_FORM_block1: bufLen = readByte( sect, off ); out.writeByte( (uint_8) bufLen ); if( bufLen ) { buffer = new char[ bufLen ]; readBlock( sect, off, buffer, bufLen ); out.writeBlock( buffer, bufLen ); delete [] buffer; } break; case DW_FORM_block2: bufLen = readWord( sect, off ); out.writeWord( (uint_16) bufLen ); if( bufLen ) { buffer = new char[ bufLen ]; readBlock( sect, off, buffer, bufLen ); out.writeBlock( buffer, bufLen ); delete [] buffer; } break; case DW_FORM_block4: bufLen = readDWord( sect, off ); out.writeDWord( bufLen ); if( bufLen ) { buffer = new char[ bufLen ]; readBlock( sect, off, buffer, bufLen ); out.writeBlock( buffer, bufLen ); delete [] buffer; } break; case DW_FORM_block: bufLen = readULEB128( sect, off ); if( bufLen ) { buffer = new char[ bufLen ]; readBlock( sect, off, buffer, bufLen ); out.writeBlock( buffer, bufLen ); delete [] buffer; } break; case DW_FORM_data8: readBlock( sect, off, buf8, 8 ); out.writeBlock( buf8, 8 ); break; case DW_FORM_string: do { num = readByte( sect, off ); out.writeByte( (uint_8) num ); } while( num != 0 ); break; case DW_FORM_indirect: num = readULEB128( sect, off ); out.writeULEB128( num ); copyFormTo( out, sect, off, num, addrSize ); break; default: #if DEBUG printf( "ACK -- form %#x\n", form ); #endif InternalAssert( 0 ); } }
void MergeFile::skipForm( dr_section sect, uint_32& off, uint_32 form, uint_8 addrSize ) //--------------------------------------------------------------------- { uint_32 value; switch( form ) { case DW_FORM_addr: off += addrSize; break; case DW_FORM_block1: off += readByte( sect, off ); break; case DW_FORM_block2: off += readWord( sect, off ); break; case DW_FORM_block4: off += readDWord( sect, off ); break; case DW_FORM_block: value = readULEB128( sect, off ); off += value; break; case DW_FORM_flag: case DW_FORM_data1: case DW_FORM_ref1: off += 1; break; case DW_FORM_data2: case DW_FORM_ref2: off += 2; break; case DW_FORM_ref_addr: // NYI: non-standard behaviour for form_ref case DW_FORM_data4: case DW_FORM_ref4: off += 4; break; case DW_FORM_data8: off += 8; break; case DW_FORM_sdata: readSLEB128( sect, off ); break; case DW_FORM_udata: case DW_FORM_ref_udata: readULEB128( sect, off ); break; case DW_FORM_string: while( readByte( sect, off ) != 0 ); break; case DW_FORM_indirect: value = readULEB128( sect, off ); skipForm( sect, off, value, addrSize ); break; default: #if DEBUG printf( "ACK -- form %#x\n", form ); #endif InternalAssert( 0 ); } }