Ejemplo n.º 1
0
/**
 * Constructor for CCivilianPedSA
 */
CCivilianPedSA::CCivilianPedSA( ePedModel pedType )
{
    DEBUG_TRACE("CCivilianPedSA::CCivilianPedSA( ePedModel pedType )");
    // based on CCivilianPed::SetupPlayerPed (R*)
    DWORD CPedOperatorNew = FUNC_CPedOperatorNew;
    DWORD CCivilianPedConstructor = FUNC_CCivilianPedConstructor;

    DWORD dwPedPointer = 0;
    _asm
    {
        push    SIZEOF_CCIVILIANPED
        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 // ped type
        call    CCivilianPedConstructor
    }
    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();
    world->Add(this->GetInterface(), CCivPed_Constructor);
    this->SetModelIndex(pedType);
    this->BeingDeleted = FALSE;
    this->DoNotRemoveFromGame = FALSE;
    this->SetType ( CIVILIAN_PED );

    this->m_pInterface->bStreamingDontDelete = true;
    this->m_pInterface->bDontStream = true;
}
Ejemplo n.º 2
0
CObjectSA::~CObjectSA( )
{
	DEBUG_TRACE("CObjectSA::~CObjectSA( )");
    //OutputDebugString("Attempting to destroy Object\n");
	if(!this->BeingDeleted && DoNotRemoveFromGame == false)
	{
		DWORD dwInterface = (DWORD)this->GetInterface();
        if ( dwInterface )
        {		
		    CWorldSA * world = (CWorldSA *)pGame->GetWorld();
		    world->Remove(this->GetInterface());
    	
            DWORD dwThis = (DWORD)this->GetInterface();
            DWORD dwFunc = this->GetInterface()->vtbl->Remove;
            _asm
            {
                mov		ecx, dwThis
                call    dwFunc
            }

		    dwFunc = this->GetInterface()->vtbl->SCALAR_DELETING_DESTRUCTOR; // we use the vtbl so we can be type independent
		    _asm	
		    {
			    mov		ecx, dwThis
			    push	1			//delete too
			    call	dwFunc
		    }
        
#ifdef MTA_USE_BUILDINGS_AS_OBJECTS
            DWORD dwModelID = this->internalInterface->m_nModelIndex;
            // REMOVE ref to colstore thingy
            dwFunc = 0x4107D0;
            _asm
            {
                mov     eax, dwModelID
                mov     eax, 0xA9B0C8[eax*4]
                mov     eax, [eax+20]
                movzx   eax, byte ptr [eax+40]
                push    eax
                call    dwFunc
                add     esp, 4
            }
#endif
        }

		this->BeingDeleted = true;
		((CPoolsSA *)pGame->GetPools())->RemoveObject((CObject *)(CObjectSA *)this);

        //OutputDebugString("Destroying Object\n");
	}
Ejemplo n.º 3
0
CEntitySA::~CEntitySA()
{
    // Unlink disabled-collisions
    while ( !m_disabledColl.empty() )
        SetCollidableWith( pGame->GetPools()->GetEntity( m_disabledColl.begin()->first ), true );

    if ( m_doNotRemoveFromGame )
        return;

    CWorldSA *world = pGame->GetWorld();
    world->Remove( m_pInterface );
    world->RemoveReferencesToDeletedObject( m_pInterface );

    // Clever little trick, eh
    delete m_pInterface;
}
Ejemplo n.º 4
0
CCivilianPedSA::~CCivilianPedSA( )
{
    DEBUG_TRACE("CCivilianPedSA::~CCivilianPedSA( )");
    if(!this->BeingDeleted && DoNotRemoveFromGame == false)
    {
        DWORD dwInterface = (DWORD)this->GetInterface();
        
        if ( (DWORD)this->GetInterface()->vtbl != VTBL_CPlaceable )
        {
            CWorldSA * world = (CWorldSA *)pGame->GetWorld();
            world->Remove(this->GetInterface(), CCivPed_Destructor);
        
            DWORD dwThis = (DWORD)this->GetInterface();
            DWORD dwFunc = this->GetInterface()->vtbl->SCALAR_DELETING_DESTRUCTOR; // we use the vtbl so we can be type independent
            _asm    
            {
                mov     ecx, dwThis
                push    1           //delete too
                call    dwFunc
            }
        }
Ejemplo n.º 5
0
CBuildingSA::~CBuildingSA( )
{
	DEBUG_TRACE("CBuildingSA::~CBuildingSA( )");
	if(!this->BeingDeleted && DoNotRemoveFromGame == false)
	{
		DWORD dwInterface = (DWORD)this->GetInterface();
		
		CWorldSA * world = (CWorldSA *)pGame->GetWorld();
		world->Remove(this->GetInterface());
	
		DWORD dwThis = (DWORD)this->GetInterface();
		DWORD dwFunc = this->GetInterface()->vtbl->SCALAR_DELETING_DESTRUCTOR; // we use the vtbl so we can be type independent
		_asm	
		{
			mov		ecx, dwThis
			push	1			//delete too
			call	dwFunc
		}

		this->BeingDeleted = true;
		//((CPoolsSA *)pGame->GetPools())->RemoveBuilding((CBuilding *)(CBuildingSA *)this);
	}
}
Ejemplo n.º 6
0
CObjectSA::CObjectSA(DWORD dwModel, bool bBreakingDisabled)
{
    DEBUG_TRACE("CObjectSA::CObjectSA( DWORD dwModel )");

    CWorldSA* world = (CWorldSA*)pGame->GetWorld();

    DWORD dwThis = 0;

#ifdef MTA_USE_BUILDINGS_AS_OBJECTS

    DWORD               dwFunc = 0x538090;            // CFileLoader__LoadObjectInstance
    CFileObjectInstance fileLoader;
    MemSetFast(&fileLoader, 0, sizeof(CFileObjectInstance));
    fileLoader.modelId = dwModel;
    fileLoader.rr = 1;
    fileLoader.areaNumber = 0;
    fileLoader.flags = -1;

    _asm
    {
        push    0
        lea     ecx, fileLoader
        push    ecx
        call    dwFunc
        add     esp, 8
        mov     dwThis, eax
    }

    this->SetInterface((CEntitySAInterface*)dwThis);

    MemPutFast<DWORD>(0xBCC0E0, dwThis);
    MemPutFast<DWORD>(0xBCC0D8, 1);

    dwFunc = 0x404DE0;            // CIplStore__SetupRelatedIpls
    DWORD dwTemp = 0;
    char  szTemp[255];
    strcpy(szTemp, "moo");

    _asm
    {
        push    0xBCC0E0
        push    -1
        lea     eax, szTemp
        push    eax
        call    dwFunc
        add     esp, 0xC
        mov     dwTemp, eax
    }

    dwFunc = 0x5B51E0;            // AddBuildingInstancesToWorld
    _asm
    {
        push    dwTemp
        call    dwFunc
        add     esp, 4
    }

    dwFunc = 0x405110;            // CIplStore__RemoveRelatedIpls
    _asm
    {
        push    -1
        call    dwFunc
        add     esp, 4
    }

    // VITAL to get colmodels to appear
    // this gets the level for a colmodel (colmodel+40)
    dwFunc = 0x4107A0;
    _asm
    {
        mov     eax, dwModel
        mov     eax, 0xA9B0C8[eax*4]
        mov     eax, [eax+20]
        movzx   eax, byte ptr [eax+40]
        push    eax
        call    dwFunc
        add     esp, 4
    }

#else

    DWORD CObjectCreate = FUNC_CObject_Create;
    DWORD dwObjectPtr = 0;
    _asm
    {
        push    1
        push    dwModel
        call    CObjectCreate
        add     esp, 8
        mov     dwObjectPtr, eax
    }
    if (dwObjectPtr)
    {
        this->SetInterface((CEntitySAInterface*)dwObjectPtr);

        world->Add(m_pInterface, CObject_Constructor);

        // Setup some flags
        this->BeingDeleted = FALSE;
        this->DoNotRemoveFromGame = FALSE;
        MemPutFast<BYTE>(dwObjectPtr + 316, 6);
        if (bBreakingDisabled)
        {
            // Set our immunities
            // Sum of all flags checked @ CPhysical__CanPhysicalBeDamaged
            CObjectSAInterface* pObjectSAInterface = GetObjectInterface();
            pObjectSAInterface->bBulletProof = true;
            pObjectSAInterface->bFireProof = true;
            pObjectSAInterface->bCollisionProof = true;
            pObjectSAInterface->bMeeleProof = true;
            pObjectSAInterface->bExplosionProof = true;
        }
        m_pInterface->bStreamingDontDelete = true;
    }
    else
    {
        // The exception handler doesn't work for some reason, so do this
        this->SetInterface(NULL);
    }
#endif

    this->internalID = pGame->GetPools()->GetObjectRef((DWORD*)this->GetInterface());

    m_ucAlpha = 255;

    if (m_pInterface)
    {
        ResetScale();
        CheckForGangTag();
    }
}
Ejemplo n.º 7
0
CObjectSA::CObjectSA( DWORD dwModel )
{
	DEBUG_TRACE("CObjectSA::CObjectSA( DWORD dwModel )");

    CWorldSA * world = (CWorldSA *)pGame->GetWorld();

    DWORD dwThis = 0;
    
#ifdef MTA_USE_BUILDINGS_AS_OBJECTS

    DWORD dwFunc = 0x538090; // CFileLoader__LoadObjectInstance
    CFileObjectInstance fileLoader;
    memset(&fileLoader, 0, sizeof(CFileObjectInstance));
    fileLoader.modelId = dwModel;
    fileLoader.rr = 1;
    fileLoader.areaNumber = 0;
    fileLoader.flags = -1;

    _asm
    {
        push    0
        lea     ecx, fileLoader
        push    ecx
        call    dwFunc
        add     esp, 8
        mov     dwThis, eax
    }

    this->SetInterface((CEntitySAInterface*)dwThis);
    
    *(DWORD *)(0xBCC0E0) = dwThis; // dw_buildings_created_this_scene
    *(DWORD *)0xBCC0D8 = 1; // dw_current_ipl_line

    dwFunc = 0x404DE0; // CIplStore__SetupRelatedIpls
    DWORD dwTemp = 0;
    char szTemp[255];
    strcpy(szTemp, "moo");

    _asm
    {
        push    0xBCC0E0
        push    -1
        lea     eax, szTemp
        push    eax
        call    dwFunc
        add     esp, 0xC
        mov     dwTemp, eax
    }

//    _asm int 3
    dwFunc = 0x5B51E0; // AddBuildingInstancesToWorld
    _asm
    {
        push    dwTemp
        call    dwFunc
        add     esp, 4
    }

    dwFunc = 0x405110; // CIplStore__RemoveRelatedIpls
    _asm
    {
        push    -1
        call    dwFunc
        add     esp, 4
    }

    // VITAL to get colmodels to appear
    // this gets the level for a colmodel (colmodel+40)
    dwFunc = 0x4107A0;
    _asm
    {
        mov     eax, dwModel
        mov     eax, 0xA9B0C8[eax*4]
        mov     eax, [eax+20]
        movzx   eax, byte ptr [eax+40]
        push    eax
        call    dwFunc
        add     esp, 4
    }

#else


	DWORD CObjectCreate = FUNC_CObject_Create;	
	DWORD dwObjectPtr = 0;
	_asm
	{
		push	1
		push	dwModel
		call	CObjectCreate
		add		esp, 8
		mov		dwObjectPtr, eax
	}
    if ( dwObjectPtr )
    {
	    this->SetInterface((CEntitySAInterface *)dwObjectPtr);

	    world->Add( m_pInterface );

        // Setup some flags
        this->BeingDeleted = FALSE;
	    this->DoNotRemoveFromGame = FALSE;
        *(BYTE *)(dwObjectPtr + 316) = 6;   // Related to moving stuff (eg: fire hydrants, default is 2)
        m_pInterface->bStreamingDontDelete = true;
    }
    else
    {
        // The exception handler doesn't work for some reason, so do this
        this->SetInterface ( NULL );
    }
#endif

    this->internalID = pGame->GetPools ()->GetObjectRef ( (DWORD *)this->GetInterface () );

    m_ucAlpha = 255;
    CheckForGangTag ();
}
Ejemplo n.º 8
0
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 );
}