//----------------------------------------------------------------------------- // Name: ~CLevelLoader() // Desc: Destructor //----------------------------------------------------------------------------- CLevelLoader::~CLevelLoader() { // Ensure we are not being deleted in the middle of an IO op. Dbg_Assert( IsIdle()); // These should be already be cleaned up. Dbg_Assert( m_hSignature == INVALID_HANDLE_VALUE ); Dbg_Assert( m_pSysMemBuffer == NULL ); Dbg_Assert( m_pFileSig == NULL ); // Close all handles. for( UINT i = 0; i < m_dwNumLevels; i++ ) { CloseHandle( m_pLevels[i].hDVDFile ); CloseHandle( m_pLevels[i].hHDFile ); CloseHandle( m_pLevels[i].hSigFile ); } // We don't own this memory, so don't delete it. m_pSysMemData = NULL; // Free the level state array. delete [] m_pLevels; m_pLevels = NULL; }
void CCar::debug_wheels() { Dbg_Assert( GetModel() ); Gfx::CSkeleton* pCarSkeleton = this->GetSkeleton(); Dbg_Assert( pCarSkeleton ); // draw skeleton for ( int i = 0; i < 6; i++ ) { Mth::Matrix objMatrix = m_matrix; objMatrix[Mth::POS] = m_pos; Mth::Matrix wsMatrix = *(pCarSkeleton->GetMatrices() + i) * objMatrix; Mth::Vector pos = wsMatrix[Mth::POS]; pos[Y] += 48.0f; wsMatrix[Mth::POS] = Mth::Vector( 0.0f, 0.0f, 0.0f, 1.0f ); // set up bounding box SBBox theBox; theBox.m_max.Set(10.0f, 10.0f, 10.0f); theBox.m_min.Set(-10.0f, -10.0f, -10.0f); // For now, draw a bounding box Gfx::AddDebugBox( wsMatrix, pos, &theBox, NULL, 1, NULL ); } }
Str::String SSpecialTrickInfo::GetTrickSlotString ( void ) const { if ( IsUnassigned() ) { return Script::GetLocalString( "sp_str_unassigned" ); } Script::CArray* pButtonArray = Script::GetArray( "SpecialCombos" ); Dbg_Assert( pButtonArray ); for ( int i = 0; i < (int)pButtonArray->GetSize(); i++ ) { Script::CScriptStructure* pStructure = pButtonArray->GetStructure( i ); Dbg_Assert( pStructure ); uint32 currTrickSlot; pStructure->GetChecksum( "trickslot", &currTrickSlot, true ); if ( currTrickSlot == m_TrickSlot ) { const char* pTrickSlotString; pStructure->GetText( "desc", &pTrickSlotString, true ); return pTrickSlotString; } } return "Unknown"; }
void CGapManager::EndGap(CClonedPiece *pGapPiece, CConcreteMetaPiece *pRegularMeta, int tab_index) { Dbg_Assert(pGapPiece); Dbg_Assert(pRegularMeta); Dbg_MsgAssert(tab_index >= 0 && tab_index < vMAX_GAPS, ("invalid tab_index")); GapInfo *pStartInfo = mp_gapInfoTab[tab_index]; Dbg_Assert(pStartInfo); //Ryan("Ending gap 0x%x\n", m_currentId); // find empty slot for (int i = 0; i < vMAX_GAPS; i++) if (!mp_gapInfoTab[i]) { mp_gapInfoTab[i] = pStartInfo; mp_gapInfoTab[i]->m_id[1] = m_currentId++; mp_gapInfoTab[i]->mp_gapPiece[1] = pGapPiece; //mp_gapInfoTab[i]->mp_gapPiece[0]->UnmarkAsGapInProgress(); //mp_gapInfoTab[i]->mp_gapPiece[1]->UnmarkAsGapInProgress(); mp_gapInfoTab[i]->mp_regularMeta[1] = pRegularMeta; mp_gapInfoTab[i]->m_descriptor.tabIndex = tab_index; m_startOfGap[i] = false; return; } Dbg_MsgAssert(0, ("out of gap slots")); return; }
Script::CStruct* CBettingGuy::GetBetParams() { Script::CStruct* p_params = NULL; if ( m_currentMinigame ) { CGoalManager* pGoalManager = GetGoalManager(); Dbg_Assert( pGoalManager ); CGoal* pGoal = pGoalManager->GetGoal( m_currentMinigame ); Dbg_Assert( pGoal ); Script::CStruct* p_temp = pGoal->GetParams(); switch ( m_currentDifficulty ) { case 1: p_temp->GetStructure( "bet_easy", &p_params, Script::NO_ASSERT ); break; case 2: p_temp->GetStructure( "bet_medium", &p_params, Script::NO_ASSERT ); break; case 3: p_temp->GetStructure( "bet_hard", &p_params, Script::NO_ASSERT ); break; default: Dbg_MsgAssert( 0, ( "Betting game had unknown difficulty level" ) ); } } return p_params; }
void Entity::AttachComponent(Component* component) { Dbg_Assert(component != NULL); Dbg_Assert(FindComponent(component) == NULL); m_components.insert(STL::pair<CRC, Component*>(component->GetName(), component)); component->Attach(this); }
void CSkaterFinalizePhysicsComponent::Finalize ( ) { mp_core_physics_component = GetSkaterCorePhysicsComponentFromObject(GetObject()); mp_state_component = GetSkaterStateComponentFromObject(GetObject()); Dbg_Assert(mp_core_physics_component); Dbg_Assert(mp_state_component); }
CPs2Mesh::CPs2Mesh(uint32* pModelData, int modelDataSize, uint8* pCASData, Nx::CTexDict* pTexDict, uint32 texDictOffset, bool isSkin, bool doShadowVolume) { Dbg_Assert( pTexDict ); mp_texDict = pTexDict; // polys should only be hidden once m_polysAlreadyHidden = false; m_isPipped = false; m_numCASData = 0; // don't do this for models if ( isSkin && pCASData ) { build_casdata_table( pCASData ); } // GJ: The geomnodes blow off the texDictOffset, // which means it won't work with skater models, // or the 10 board gameobjs in the boardshop. if ( !isSkin && texDictOffset == 0 ) { // since we're not actually opening a PIP file // we don't need to keep track of it m_isPipped = false; // this should already be in GEOM format, // by the time the data arrives here... // (we're not loading up the Pip through the // normal Pip::Load process, so we need // to remember the pointer to the pip data // so that we can delete it later) mp_pipData = (uint8*)Mem::Malloc( modelDataSize ); Dbg_Assert( mp_pipData ); memcpy( mp_pipData, pModelData, modelDataSize ); // process data in place // final arg (0) says to hold it in a database to be rendered later // (as opposed to rendering it unconditionally, LOADFLAG_RENDERNOW) mp_geomNode = NxPs2::CGeomNode::sProcessInPlace( mp_pipData, 0 ); // Get hierarchy array mp_hierarchyObjects = (CHierarchyObject*) NxPs2::CGeomNode::sGetHierarchyArray(mp_pipData, m_numHierarchyObjects); } else { NxPs2::sScene* pTextureDictionary = ((Nx::CPs2TexDict*)mp_texDict)->GetEngineTextureDictionary(); NxPs2::LoadScene( pModelData, modelDataSize, pTextureDictionary, true, true, texDictOffset, doShadowVolume ); mp_geomNode = NULL; } // temporary lookup table is no longer needed NxPs2::DestroyCASDataLookupTable(); }
void CTexDict::AddTexture(CTexture *p_texture) { Dbg_Assert(mp_texture_lookup); Dbg_Assert(p_texture); mp_texture_lookup->PutItem(p_texture->GetChecksum(), p_texture); plat_add_texture(p_texture); }
bool CBettingGuy::EndBetAttempt( uint32 goalId ) { // this acts like a secondary deactivate if ( IsActive() && m_currentMinigame == goalId && m_inAttempt && !m_shouldMove ) { //printf("CBettingGuy::EndBetAttempt\n"); // printf("step 2\n"); m_inAttempt = false; Script::CStruct* pBetParams = GetBetParams(); // check that they haven't exceeded the number of tries int max_attempts; pBetParams->GetInteger( "tries", &max_attempts, Script::ASSERT ); // we're challenging them to break a record CGoalManager* pGoalManager = GetGoalManager(); Dbg_Assert( pGoalManager ); Script::CStruct* pMinigameParams = pGoalManager->GetGoal( m_currentMinigame )->GetParams(); Dbg_Assert( pMinigameParams ); if ( m_currentChallenge ) { // printf("step 3\n"); int last_attempt; if ( pMinigameParams->GetInteger( "last_attempt", &last_attempt, Script::NO_ASSERT ) ) { printf("got a last attempt of %i\n", last_attempt); printf("m_currentChallenge is %i\n", m_currentChallenge); if ( last_attempt >= m_currentChallenge ) { // printf("you won the bet!\n"); // beat the bet and call the minigame's bet_success script this->Win(); return true; } } } // check that this isn't their last try m_numTries++; if ( m_numTries >= max_attempts ) { Lose(); return true; } // if it's not a challenge minigame, it's probably a trickspot // minigame. In that case, we'll be told when the game is won // the the gap script. } return false; }
void CGapManager::SetGapInfo(int tab_index, GapDescriptor &descriptor) { Dbg_MsgAssert(tab_index >= 0 && tab_index < vMAX_GAPS, ("invalid tab_index")); Dbg_Assert(mp_gapInfoTab[tab_index]); Dbg_Assert(descriptor.tabIndex >= 0 && descriptor.tabIndex < vMAX_GAPS); sprintf(mp_gapInfoTab[tab_index]->mp_text, "%s", descriptor.text); mp_gapInfoTab[tab_index]->m_descriptor = descriptor; RegisterGapsWithSkaterCareer(); //mp_gapInfoTab[tab_index]->mp_gapPiece[0]->MakeTriggerable(true); //mp_gapInfoTab[tab_index]->mp_gapPiece[1]->MakeTriggerable(true); }
void CManual::Init ( CCompositeObject *pSkater ) { mpSkater = pSkater; Dbg_Assert(mpSkater); mpSkaterBalanceTrickComponent = GetSkaterBalanceTrickComponentFromObject(mpSkater); Dbg_Assert(mpSkaterBalanceTrickComponent); mpSkaterScoreComponent = GetSkaterScoreComponentFromObject(mpSkater); Dbg_Assert(mpSkaterScoreComponent); mpInputComponent = GetInputComponentFromObject(mpSkater); Dbg_Assert(mpInputComponent); }
//----------------------------------------------------------------------------- // Name: AsyncStreamLevel // Desc: Loads all the resources from the given XPR asynchronously using DMA //----------------------------------------------------------------------------- VOID CLevelLoader::AsyncStreamLevel( DWORD dwLevel ) { Dbg_Assert( IsIdle() ); Dbg_Assert( dwLevel < m_dwNumLevels ); // We are no longer idle. m_IOState = Begin; // set current level m_pCurrentLevel = &m_pLevels[dwLevel]; m_dwCurrentLevel = dwLevel; // Start timer. m_dStartTime = Tmr::GetTime(); }
CGeom * CPs2Geom::plat_clone(bool instance, CModel* pDestModel) { Dbg_MsgAssert(mp_instance == NULL, ("Wrong version of CPs2Geom::plat_clone() for CGeomNodes")); Dbg_Assert(mp_oldInstance); // Copy into new geom CPs2Geom *p_new_geom = new CPs2Geom(*this); Dbg_Assert(p_new_geom); int numBones; numBones = pDestModel->GetNumBones(); Mth::Matrix temp; temp.Identity(); p_new_geom->mp_matrices = ((CPs2Model*)pDestModel)->GetMatrices(); NxPs2::sScene* pScene = mp_oldInstance->GetScene(); Dbg_Assert( pScene ); if ( numBones ) { p_new_geom->mp_oldInstance = new NxPs2::CInstance(pScene, temp, mp_oldInstance->HasColorPerMaterial(), numBones, p_new_geom->mp_matrices ); } else { p_new_geom->mp_oldInstance = new NxPs2::CInstance(pScene, temp, mp_oldInstance->HasColorPerMaterial()); } Dbg_Assert(p_new_geom->mp_oldInstance); // Copy the colors from instance if (mp_oldInstance->HasColorPerMaterial()) { int num_colors = mp_oldInstance->GetScene()->NumMeshes; for (int i = 0; i < num_colors; i++) { p_new_geom->mp_oldInstance->SetMaterialColorByIndex(i, mp_oldInstance->GetMaterialColorByIndex(i)); } } else { p_new_geom->mp_oldInstance->SetColor(mp_oldInstance->GetColor()); } return p_new_geom; }
uint32 CTrickChecksumTable::GetChecksumFromIndex( int index ) { Dbg_Assert( index >= 0 && index < m_NumChecksums ); return m_Checksum[index]; }
void CPs2Mesh::HidePolys( uint32 mask ) { int count = 0; // this function should only be called once per mesh // because after the ADC bits are squeezed, // the pointers are no longer valid... // (was causing a crash in the secret level // with random peds that were doing poly removal) if ( m_polysAlreadyHidden ) { return; } // printf( "Hiding polys with mask 0x%08x\n", mask); for ( int j = 0; j < m_numCASData; j++ ) { Dbg_Assert( mp_CASData ); if ( mp_CASData[j].mask & mask ) { if ( mp_CASData[j].pADCBit ) { *mp_CASData[j].pADCBit = 0xC000; } count++; } } // printf( "Hiding %d polys\n", count ); m_polysAlreadyHidden = true; }
bool CMovieManager::SetMoviePauseMode( uint32 name, bool pause_mode ) { if ( m_movieDetailsList.CountItems() == 0 ) { // no movies in the queue return false; } if ( name == 0 ) { // no name specified, so set the current movie CMovieDetails* pDetails = get_movie_details( 0 ); Dbg_Assert( pDetails ); pDetails->SetPauseMode( pause_mode ); } else { // a name was specified, so only do this movie CMovieDetails* pDetails = get_movie_details_by_name( name ); if ( pDetails ) { pDetails->SetPauseMode( pause_mode ); } else { Dbg_MsgAssert( 0, ( "Movie to set pause mode (%s) not found\n", Script::FindChecksumName(name) ) ); } } return true; }
void CCollisionComponent::InitCollision( Nx::CollType type, Nx::CCollObjTriData *p_coll_tri_data ) { Dbg_Assert( !mp_collision ); if ( p_coll_tri_data ) { mp_collision = Nx::CCollObj::sCreateMovableCollision(type, p_coll_tri_data, 1, GetObject()); } else { Obj::CModelComponent* pModelComponent = GetModelComponentFromObject( GetObject() ); Dbg_MsgAssert( pModelComponent, ( "Initing collision on something with no model component" ) ); Nx::CModel* pModel = pModelComponent->GetModel(); Dbg_MsgAssert( pModel, ( "Initing collision on something with no model" ) ); Ass::CAssMan * ass_man = Ass::CAssMan::Instance(); Nx::CMesh* pMesh = (Nx::CMesh*)ass_man->GetAsset(pModel->GetFileName(), false); if (pMesh) { mp_collision = Nx::CCollObj::sCreateMovableCollision(type, pMesh->GetCollisionTriDataArray(), pMesh->GetCollisionTriDataArraySize(), GetObject()); } else { mp_collision = Nx::CCollObj::sCreateMovableCollision(type, NULL, 0, GetObject()); } } }
bool CMovieManager::IsMovieHeld( uint32 name ) { if ( m_movieDetailsList.CountItems() == 0 ) { return false; } if ( name != 0 ) { CMovieDetails* pDetails = get_movie_details_by_name( name ); if ( pDetails ) { return pDetails->IsHeld(); } else { // movie not found in list! return false; } } else { CMovieDetails* pDetails = get_movie_details( 0 ); Dbg_Assert( pDetails ); return pDetails->IsHeld(); } }
//----------------------------------------------------------------------------- // Name: CRestIO() // Desc: Records last state for current level and get ready for IO //----------------------------------------------------------------------------- VOID CLevelLoader::ResetStreaming() { // record last state m_pCurrentLevel->bWasPreCached = m_pCurrentLevel->bIsPreCached; m_pCurrentLevel->bWasCacheCorrupted = m_pCurrentLevel->bIsCacheCorrupted; // begin signature Dbg_Assert( m_hSignature == INVALID_HANDLE_VALUE ); m_hSignature = XCalculateSignatureBegin( XCALCSIG_FLAG_NON_ROAMABLE ); Dbg_Assert( m_hSignature != INVALID_HANDLE_VALUE ); // create file sig buffer // Dbg_Assert( m_pFileSig == NULL ); // Dbg_Assert( XCALCSIG_SIGNATURE_SIZE + sizeof(SIG_MAGIC) <= HD_SECTOR_SIZE ); // m_pFileSig = new BYTE[HD_SECTOR_SIZE]; }
void CVibrationComponent::Update() { Dbg_Assert(mp_input_device); if (!m_active_state) { Suspend(true); return; } // check the duration of active actuators for (int i = vVB_NUM_ACTUATORS; i--; ) { // actuator inactive or has no associated duration if (!mp_vibration_timers[i].active) continue; // duration not yet up if (Tmr::ElapsedTime(mp_vibration_timers[i].start_time) < mp_vibration_timers[i].duration) continue; // NOTE: ignoring all replay code in VibrationComponent for now // Replay::WritePadVibration(i, 0); // turn off actuator mp_input_device->ActivateActuator(i, 0); mp_vibration_timers[i].active = false; } }
bool CPs2Geom::plat_render(Mth::Matrix* pRootMatrix, Mth::Matrix* pBoneMatrices, int numBones) { // implies it's got a skin if ( mp_oldInstance ) { Dbg_Assert( mp_oldInstance ); if ( numBones > 0 ) { mp_oldInstance->SetBoneTransforms( pBoneMatrices ); } mp_oldInstance->SetTransform(*pRootMatrix); Dbg_MsgAssert( numBones <= mp_oldInstance->GetNumBones(), ( "Bone mismatch Trying to render %d bones, but model was initialized with %d bones", numBones, mp_oldInstance->GetNumBones() ) ); } if ( mp_instance ) { m_rootMatrix = *pRootMatrix; if ( numBones ) { mp_instance->SetBoneTransforms( pBoneMatrices ); } Dbg_MsgAssert( numBones <= mp_instance->GetNumBones(), ( "Bone mismatch Trying to render %d bones, but model was initialized with %d bones", numBones, mp_instance->GetNumBones() ) ); } return true; }
const Mth::CBBox & CSector::GetBoundingBox() const { if (mp_geom) { return mp_geom->GetBoundingBox(); } else { Dbg_Assert(mp_coll_sector); CCollObjTriData *p_coll_data = mp_coll_sector->GetGeometry(); Dbg_Assert(p_coll_data); return p_coll_data->GetBBox(); // return plat_get_bounding_box(); } }
void CPs2Geom::plat_set_uv_wibble_offsets(float u_offset, float v_offset) { Dbg_Assert(mp_instance); NxPs2::CGeomNode *p_node = mp_instance; // Get leaf while (!p_node->IsLeaf()) { p_node = p_node->GetChild(); } // Do on all siblings while (p_node) { if (p_node->IsUVWibbled()) { p_node->SetUVWibbleOffsets(u_offset, v_offset); // If we are setting the offsets, then we should want to use the explicit mode p_node->UseExplicitUVWibble(true); } p_node = p_node->GetSibling(); } }
Script::CStruct* CMovieManager::GetMovieParams( uint32 name ) { if ( m_movieDetailsList.CountItems() == 0 ) { // no movies in the queue return NULL; } if ( name == 0 ) { // no name specified, so set the current movie CMovieDetails* pDetails = get_movie_details( 0 ); Dbg_Assert( pDetails ); if ( pDetails ) return pDetails->GetParams(); } else { // a name was specified, so only do this movie CMovieDetails* pDetails = get_movie_details_by_name( name ); if ( pDetails ) return pDetails->GetParams(); } return NULL; }
// win func that gets called automatically by update endbetattempt func bool CBettingGuy::Win() { printf("CBettingGuy::Win\n"); CGoalManager* pGoalManager = GetGoalManager(); Dbg_Assert( pGoalManager ); pGoalManager->AddCash( m_betAmount ); Reset(); RunCallbackScript( vSUCCESS ); m_numBetsWon++; m_straightWins++; if ( m_straightWins > 3 && m_currentDifficulty < 3 ) { m_currentDifficulty++; m_straightWins = 0; } m_straightLosses = 0; m_shouldMove = true; SetInactive(); return true; }
void CSkaterStancePanelComponent::Update() { Front::CSpriteElement* p_stance_icon = static_cast< Front::CSpriteElement* >(Front::CScreenElementManager::Instance()->GetElement( CRCD(0x968ae5dd, "the_boardstance_sprite") + static_cast< CSkater* >(GetObject())->GetHeapIndex() ).Convert()); Dbg_Assert(p_stance_icon); int stance = determine_stance(); if (stance == m_last_stance) return; m_last_stance = stance; if (stance == 5) { p_stance_icon->SetAlpha(0.0f, Front::CScreenElement::FORCE_INSTANT); } else { const static uint32 sp_texture_checksums[] = { CRCD(0x33a15296, "nollie_icon"), CRCD(0xbe91f3b6, "fakie_icon"), CRCD(0x9f9d3907, "switch_icon"), CRCD(0xb793ef40, "sw_pressure_icon"), CRCD(0x4e304fa1, "pressure_icon") }; p_stance_icon->SetTexture(sp_texture_checksums[stance]); p_stance_icon->SetAlpha(1.0f, Front::CScreenElement::FORCE_INSTANT); } }
//----------------------------------------------------------------------------- // Name: CLevelLoader() // Desc: Constructor //----------------------------------------------------------------------------- CLevelLoader::CLevelLoader() : m_pSysMemData( NULL ), m_dwSysMemSize( 0 ), m_pLevels( NULL ), m_dwNumLevels( 0 ), m_pCurrentLevel( NULL ), m_IOState( Idle ), m_pSysMemBuffer( NULL ), m_pFileSig( NULL ), m_hSignature( INVALID_HANDLE_VALUE ) { // create file sig buffer Dbg_Assert( m_pFileSig == NULL ); Dbg_Assert( XCALCSIG_SIGNATURE_SIZE + sizeof(SIG_MAGIC) <= HD_SECTOR_SIZE ); m_pFileSig = new BYTE[HD_SECTOR_SIZE]; }
void CPs2Window2D::plat_update_engine() { int x0 = (int) (((float) m_xpos) * NxPs2::SDraw2D::GetScreenScaleX()); int y0 = (int) (((float) m_ypos) * NxPs2::SDraw2D::GetScreenScaleY()); Dbg_Assert(x0 >= 0); Dbg_Assert(y0 >= 0); int x1 = x0 + (int) (((float) m_width ) * NxPs2::SDraw2D::GetScreenScaleX()) - 1; int y1 = y0 + (int) (((float) m_height) * NxPs2::SDraw2D::GetScreenScaleY()) - 1; Dbg_Assert(x1 >= 0); Dbg_Assert(y1 >= 0); mp_plat_window->SetScissor(x0, y0, x1, y1); }
//----------------------------------------------------------------------------- // Name: RefreshLevelStates // Desc: Refreshes the level loader's level states //----------------------------------------------------------------------------- HRESULT CLevelLoader::RefreshLevelStates() { Dbg_Assert( IsIdle()); // Init states. for( UINT i = 0; i < m_dwNumLevels; i++ ) { m_pLevels[i].bIsPreCached = FALSE; m_pLevels[i].bIsCacheCorrupted = FALSE; m_pLevels[i].bIsOpen = FALSE; m_pLevels[i].dwSysMemSize = 0; m_pLevels[i].dwVidMemSize = 0; // Close any opened handles. CloseHandle( m_pLevels[i].hDVDFile ); CloseHandle( m_pLevels[i].hSigFile ); CloseHandle( m_pLevels[i].hHDFile ); m_pLevels[i].hDVDFile = INVALID_HANDLE_VALUE; m_pLevels[i].hHDFile = INVALID_HANDLE_VALUE; m_pLevels[i].hSigFile = INVALID_HANDLE_VALUE; } return S_OK; }