CEntity * CEventSA::GetEntity ( ) { DEBUG_TRACE("CEntity * CEventSA::GetEntity ( )"); if(this->GetEntityType() == EVENT_NULL) return NULL; CPoolsSA * pPools = (CPoolsSA *)pGame->GetPools(); CEntity * entity; switch(m_pInterface->m_eEventEntity) { case ENTITY_EVENT_PED: entity = (CEntity *)pPools->GetPedFromRef((DWORD)m_pInterface->m_nEventEntityRef); break; case ENTITY_EVENT_VEHICLE: entity = (CEntity *)pPools->GetVehicleFromRef((DWORD)m_pInterface->m_nEventEntityRef); break; case ENTITY_EVENT_OBJECT: entity = (CEntity *)pPools->GetObjectFromRef((DWORD)m_pInterface->m_nEventEntityRef); break; default: return NULL; } return entity; }
CEntity* CMarkerSA::GetEntity() { DEBUG_TRACE("CEntity * CMarkerSA::GetEntity ( )"); CPoolsSA* pPools = (CPoolsSA*)pGame->GetPools(); switch (internalInterface->BlipType) { case MARKER_TYPE_CAR: return (CEntity*)pPools->GetVehicleFromRef((DWORD)internalInterface->PoolIndex); case MARKER_TYPE_CHAR: return (CEntity*)pPools->GetPedFromRef((DWORD)internalInterface->PoolIndex); case MARKER_TYPE_OBJECT: return (CEntity*)pPools->GetObjectFromRef((DWORD)internalInterface->PoolIndex); default: return NULL; } }
CPlayerPedSA::CPlayerPedSA( ePedModel pedType ) { DEBUG_TRACE("CPlayerPedSA::CPlayerPedSA( ePedModel pedType )"); // based on CPlayerPed::SetupPlayerPed (R*) DWORD CPedOperatorNew = FUNC_CPedOperatorNew; DWORD CPlayerPedConstructor = FUNC_CPlayerPedConstructor; DWORD dwPedPointer = 0; _asm { push SIZEOF_CPLAYERPED call CPedOperatorNew add esp, 4 mov dwPedPointer, eax mov ecx, eax push 0 // set to 0 and they'll behave like AI peds push 1 call CPlayerPedConstructor } this->SetInterface((CEntitySAInterface *)dwPedPointer); this->Init(); // init our interfaces CPoolsSA * pools = (CPoolsSA *)pGame->GetPools ( ); this->internalID = pools->GetPedRef ( (DWORD *)this->GetInterface () ); CWorldSA * world = (CWorldSA *)pGame->GetWorld(); this->SetModelIndex(pedType); this->BeingDeleted = FALSE; this->DoNotRemoveFromGame = FALSE; this->SetType ( PLAYER_PED ); // Allocate a player data struct and set it as the players m_bIsLocal = false; m_pData = new CPlayerPedDataSAInterface; // Copy the local player data so we're defaulted to something good CPlayerPedSA* pLocalPlayerSA = dynamic_cast < CPlayerPedSA* > ( pools->GetPedFromRef ( (DWORD)1 ) ); if ( pLocalPlayerSA ) MemCpyFast ( m_pData, ((CPlayerPedSAInterface*)pLocalPlayerSA->GetInterface ())->pPlayerData, sizeof ( CPlayerPedDataSAInterface ) ); // Replace the player ped data in our ped interface with the one we just created GetPlayerPedInterface ()->pPlayerData = m_pData; // Set default stuff m_pData->m_bRenderWeapon = true; m_pData->m_Wanted = pLocalWanted; m_pData->m_fSprintEnergy = 1000.0f; // Clothes pointers or we'll crash later (TODO: Wrap up with some cloth classes and make it unique per player) m_pData->m_pClothes = pLocalClothes; // Not sure why was this here (svn blame reports that this line came from the old SVN), // but it's causing a bug in what the just streamed-in players that are in the air are // processed as if they would be standing on some surface, screwing velocity calculations // for players floating in air (using superman script, for example) because GTA:SA will // try to apply the floor friction to their velocity. //SetIsStanding ( true ); GetPlayerPedInterface ()->pedFlags.bCanBeShotInVehicle = true; GetPlayerPedInterface ()->pedFlags.bTestForShotInVehicle = true; // Stop remote players targeting eachother, this also stops the local player targeting them (needs to be fixed) GetPlayerPedInterface ()->pedFlags.bNeverEverTargetThisPed = true; GetPlayerPedInterface ()->pedFlags.bIsLanding = false; GetPlayerPedInterface ()->fRotationSpeed = 7.5; m_pInterface->bStreamingDontDelete = true; m_pInterface->bDontStream = true; world->Add ( m_pInterface, CPlayerPed_Constructor ); }