Example #1
0
/**
 * \todo allow the addon to change the size of the pools (see 0x4C0270 - CPools::Initialise) (in start game?)
 */
CGameSA::CGameSA()
{
    pGame = this;
    m_bAsyncScriptEnabled = false;
    m_bAsyncScriptForced = false;
    m_bASyncLoadingSuspended = false;
    m_iCheckStatus = 0;

    SetInitialVirtualProtect();

    // Initialize the offsets
    eGameVersion version = FindGameVersion ();
    switch ( version )
    {
        case VERSION_EU_10: COffsets::Initialize10EU (); break;
        case VERSION_US_10: COffsets::Initialize10US (); break;
        case VERSION_11:    COffsets::Initialize11 (); break;
        case VERSION_20:    COffsets::Initialize20 (); break;
    }

    // Set the model ids for all the CModelInfoSA instances
    for ( int i = 0; i < MODELINFO_MAX; i++ )
    {
        ModelInfo [i].SetModelID ( i );
    }

    DEBUG_TRACE("CGameSA::CGameSA()");
    this->m_pAudioEngine            = new CAudioEngineSA((CAudioEngineSAInterface*)CLASS_CAudioEngine);
    this->m_pAudioContainer         = new CAudioContainerSA();
    this->m_pWorld                  = new CWorldSA();
    this->m_pPools                  = new CPoolsSA();
    this->m_pClock                  = new CClockSA();
    this->m_pRadar                  = new CRadarSA();
    this->m_pCamera                 = new CCameraSA((CCameraSAInterface *)CLASS_CCamera);
    this->m_pCoronas                = new CCoronasSA();
    this->m_pCheckpoints            = new CCheckpointsSA();
    this->m_pPickups                = new CPickupsSA();
    this->m_pExplosionManager       = new CExplosionManagerSA();
    this->m_pHud                    = new CHudSA();
    this->m_pFireManager            = new CFireManagerSA();
    this->m_p3DMarkers              = new C3DMarkersSA();
    this->m_pPad                    = new CPadSA((CPadSAInterface *)CLASS_CPad);
    this->m_pTheCarGenerators       = new CTheCarGeneratorsSA();
    this->m_pCAERadioTrackManager   = new CAERadioTrackManagerSA();
    this->m_pWeather                = new CWeatherSA();
    this->m_pMenuManager            = new CMenuManagerSA();
    this->m_pText                   = new CTextSA();
    this->m_pStats                  = new CStatsSA();
    this->m_pFont                   = new CFontSA();
    this->m_pPathFind               = new CPathFindSA();
    this->m_pPopulation             = new CPopulationSA();
    this->m_pTaskManagementSystem   = new CTaskManagementSystemSA();
    this->m_pSettings               = new CSettingsSA();
    this->m_pCarEnterExit           = new CCarEnterExitSA();
    this->m_pControllerConfigManager = new CControllerConfigManagerSA();
    this->m_pProjectileInfo         = new CProjectileInfoSA();
    this->m_pRenderWare             = new CRenderWareSA( version );
    this->m_pHandlingManager        = new CHandlingManagerSA ();
    this->m_pEventList              = new CEventListSA();
    this->m_pGarages                = new CGaragesSA ( (CGaragesSAInterface *)CLASS_CGarages);
    this->m_pTasks                  = new CTasksSA ( (CTaskManagementSystemSA*)m_pTaskManagementSystem );
    this->m_pAnimManager            = new CAnimManagerSA;
    this->m_pStreaming              = new CStreamingSA;
    this->m_pVisibilityPlugins      = new CVisibilityPluginsSA;
    this->m_pKeyGen                 = new CKeyGenSA;
    this->m_pRopes                  = new CRopesSA;
    this->m_pFx                     = new CFxSA ( (CFxSAInterface *)CLASS_CFx );
    this->m_pWaterManager           = new CWaterManagerSA ();
    this->m_pWeaponStatsManager     = new CWeaponStatManagerSA ();
    this->m_pPointLights            = new CPointLightsSA ();

    // Normal weapon types (WEAPONSKILL_STD)
    for ( int i = 0; i < NUM_WeaponInfosStdSkill; i++)
    {
        eWeaponType weaponType = (eWeaponType)(WEAPONTYPE_PISTOL + i);
        WeaponInfos[i] = new CWeaponInfoSA( (CWeaponInfoSAInterface *)(ARRAY_WeaponInfo + i*CLASSSIZE_WeaponInfo), weaponType );
        m_pWeaponStatsManager->CreateWeaponStat ( WeaponInfos[i], (eWeaponType)(weaponType - WEAPONTYPE_PISTOL), WEAPONSKILL_STD );
    }

    // Extra weapon types for skills (WEAPONSKILL_POOR,WEAPONSKILL_PRO,WEAPONSKILL_SPECIAL)
    int index;
    eWeaponSkill weaponSkill = eWeaponSkill::WEAPONSKILL_POOR;
    for ( int skill = 0; skill < 3 ; skill++ )
    {
        //STD is created first, then it creates "extra weapon types" (poor, pro, special?) but in the enum 1 = STD which meant the STD weapon skill contained pro info
        if ( skill >= 1 )
        {
            if ( skill == 1 )
            {
                weaponSkill = eWeaponSkill::WEAPONSKILL_PRO;
            }
            if ( skill == 2 )
            {
                weaponSkill = eWeaponSkill::WEAPONSKILL_SPECIAL;
            }
        }
        for ( int i = 0; i < NUM_WeaponInfosOtherSkill; i++ )
        {
            eWeaponType weaponType = (eWeaponType)(WEAPONTYPE_PISTOL + i);
            index = NUM_WeaponInfosStdSkill + skill*NUM_WeaponInfosOtherSkill + i;
            WeaponInfos[index] = new CWeaponInfoSA( (CWeaponInfoSAInterface *)(ARRAY_WeaponInfo + index*CLASSSIZE_WeaponInfo), weaponType );
            m_pWeaponStatsManager->CreateWeaponStat ( WeaponInfos[index], weaponType, weaponSkill );
        }
    }

    m_pPlayerInfo = new CPlayerInfoSA ( (CPlayerInfoSAInterface *)CLASS_CPlayerInfo );

    // Init cheat name => address map
    m_Cheats [ CHEAT_HOVERINGCARS     ] = new SCheatSA((BYTE *)VAR_HoveringCarsEnabled);
    m_Cheats [ CHEAT_FLYINGCARS       ] = new SCheatSA((BYTE *)VAR_FlyingCarsEnabled);
    m_Cheats [ CHEAT_EXTRABUNNYHOP    ] = new SCheatSA((BYTE *)VAR_ExtraBunnyhopEnabled);
    m_Cheats [ CHEAT_EXTRAJUMP        ] = new SCheatSA((BYTE *)VAR_ExtraJumpEnabled);

    // New cheats for Anticheat
    m_Cheats [ CHEAT_TANKMODE         ] = new SCheatSA((BYTE *)VAR_TankModeEnabled, false);
    m_Cheats [ CHEAT_NORELOAD         ] = new SCheatSA((BYTE *)VAR_NoReloadEnabled, false);
    m_Cheats [ CHEAT_PERFECTHANDLING  ] = new SCheatSA((BYTE *)VAR_PerfectHandling, false);
    m_Cheats [ CHEAT_ALLCARSHAVENITRO ] = new SCheatSA((BYTE *)VAR_AllCarsHaveNitro, false);
    m_Cheats [ CHEAT_BOATSCANFLY      ] = new SCheatSA((BYTE *)VAR_BoatsCanFly, false);
    m_Cheats [ CHEAT_INFINITEOXYGEN   ] = new SCheatSA((BYTE *)VAR_InfiniteOxygen, false);
    m_Cheats [ CHEAT_WALKUNDERWATER   ] = new SCheatSA((BYTE *)VAR_WalkUnderwater, false);
    m_Cheats [ CHEAT_FASTERCLOCK      ] = new SCheatSA((BYTE *)VAR_FasterClock, false);
    m_Cheats [ CHEAT_FASTERGAMEPLAY   ] = new SCheatSA((BYTE *)VAR_FasterGameplay, false);
    m_Cheats [ CHEAT_SLOWERGAMEPLAY   ] = new SCheatSA((BYTE *)VAR_SlowerGameplay, false);
    m_Cheats [ CHEAT_ALWAYSMIDNIGHT   ] = new SCheatSA((BYTE *)VAR_AlwaysMidnight, false);
    m_Cheats [ CHEAT_FULLWEAPONAIMING ] = new SCheatSA((BYTE *)VAR_FullWeaponAiming, false);
    m_Cheats [ CHEAT_INFINITEHEALTH   ] = new SCheatSA((BYTE *)VAR_InfiniteHealth, false);
    m_Cheats [ CHEAT_NEVERWANTED      ] = new SCheatSA((BYTE *)VAR_NeverWanted, false);
    m_Cheats [ CHEAT_HEALTARMORMONEY  ] = new SCheatSA((BYTE *)VAR_HealthArmorMoney, false);

    // Change pool sizes here
    m_pPools->SetPoolCapacity ( TASK_POOL, 5000 );                  // Default is 500
    m_pPools->SetPoolCapacity ( OBJECT_POOL, 700 );                 // Default is 350
    m_pPools->SetPoolCapacity ( EVENT_POOL, 5000 );                 // Default is 200
    m_pPools->SetPoolCapacity ( COL_MODEL_POOL, 12000 );            // Default is 10150
    m_pPools->SetPoolCapacity ( ENV_MAP_MATERIAL_POOL, 16000 );     // Default is 4096
    m_pPools->SetPoolCapacity ( ENV_MAP_ATOMIC_POOL, 4000 );        // Default is 1024
    m_pPools->SetPoolCapacity ( SPEC_MAP_MATERIAL_POOL, 16000 );    // Default is 4096

    // Increase streaming object instances list size
    MemPut < WORD > ( 0x05B8E55, 30000 );         // Default is 12000
    MemPut < WORD > ( 0x05B8EB0, 30000 );         // Default is 12000

    CModelInfoSA::StaticSetHooks ();
    CPlayerPedSA::StaticSetHooks ();
    CRenderWareSA::StaticSetHooks ();
    CRenderWareSA::StaticSetClothesReplacingHooks ();
    CTasksSA::StaticSetHooks ();
}
Example #2
0
/**
 * \todo allow the addon to change the size of the pools (see 0x4C0270 - CPools::Initialise) (in start game?)
 */
CGameSA::CGameSA()
{
	pGame = this;
    // Unprotect all of the GTASA code at once and leave it that way
    DWORD oldProt;
    VirtualProtect((LPVOID)0x401000, 0x4A3000, PAGE_EXECUTE_READWRITE, &oldProt);

    // Initialize the offsets
    eGameVersion version = FindGameVersion ();
    switch ( version )
    {
        case VERSION_EU_10: COffsets::Initialize10EU (); break;
        case VERSION_US_10: COffsets::Initialize10US (); break;
        case VERSION_11:    COffsets::Initialize11 (); break;
        case VERSION_20:    COffsets::Initialize20 (); break;
    }

    // Set the model ids for all the CModelInfoSA instances
    for ( int i = 0; i < MODELINFO_MAX; i++ )
    {
        ModelInfo[i].SetModelID ( i );
    }

	DEBUG_TRACE("CGameSA::CGameSA()");
	this->m_pAudio					= new CAudioSA();
	this->m_pWorld					= new CWorldSA();
	this->m_pPools					= new CPoolsSA();
	this->m_pClock					= new CClockSA();
	this->m_pRadar 					= new CRadarSA();
	this->m_pCamera					= new CCameraSA((CCameraSAInterface *)CLASS_CCamera);
	this->m_pCoronas				= new CCoronasSA();
	this->m_pCheckpoints			= new CCheckpointsSA();
	this->m_pPickups				= new CPickupsSA();
	this->m_pExplosionManager		= new CExplosionManagerSA();
	this->m_pHud					= new CHudSA();
	this->m_pFireManager			= new CFireManagerSA();
	this->m_p3DMarkers				= new C3DMarkersSA();
	this->m_pPad					= new CPadSA((CPadSAInterface *)CLASS_CPad);
	this->m_pTheCarGenerators		= new CTheCarGeneratorsSA();
	this->m_pCAERadioTrackManager	= new CAERadioTrackManagerSA();
	this->m_pWeather				= new CWeatherSA();
	this->m_pMenuManager			= new CMenuManagerSA();
	this->m_pText					= new CTextSA();
	this->m_pStats					= new CStatsSA();
	this->m_pFont					= new CFontSA();
	this->m_pPathFind				= new CPathFindSA();
	this->m_pPopulation				= new CPopulationSA();
	this->m_pTaskManagementSystem   = new CTaskManagementSystemSA();
	this->m_pSettings               = new CSettingsSA();
	this->m_pCarEnterExit           = new CCarEnterExitSA();
	this->m_pControllerConfigManager = new CControllerConfigManagerSA();
	this->m_pProjectileInfo         = new CProjectileInfoSA();
	this->m_pRenderWare				= new CRenderWareSA( version );
	this->m_pHandlingManager        = new CHandlingManagerSA ();
	this->m_pEventList              = new CEventListSA();
	this->m_pGarages                = new CGaragesSA ( (CGaragesSAInterface *)CLASS_CGarages);
	this->m_pTasks                  = new CTasksSA ( (CTaskManagementSystemSA*)m_pTaskManagementSystem );
	this->m_pAnimManager            = new CAnimManagerSA;
	this->m_pStreaming              = new CStreamingSA;
	this->m_pVisibilityPlugins      = new CVisibilityPluginsSA;
	this->m_pKeyGen                 = new CKeyGenSA;
	this->m_pRopes                  = new CRopesSA;
	this->m_pFx                     = new CFxSA ( (CFxSAInterface *)CLASS_CFx );
	this->m_pWaterManager           = new CWaterManagerSA ();

    // Normal weapon types (WEAPONSKILL_STD)
	for ( int i = 0; i < NUM_WeaponInfosStdSkill; i++)
		WeaponInfos[i] = new CWeaponInfoSA((CWeaponInfoSAInterface *)(ARRAY_WeaponInfo + i*CLASSSIZE_WeaponInfo), (eWeaponType)(WEAPONTYPE_PISTOL + i));

    // Extra weapon types for skills (WEAPONSKILL_POOR,WEAPONSKILL_PRO,WEAPONSKILL_SPECIAL)
    int index;
    for ( int skill = 0; skill < 3 ; skill++ )
    {
        for ( int i = 0; i < NUM_WeaponInfosOtherSkill; i++ )
        {
            index = NUM_WeaponInfosStdSkill + skill*NUM_WeaponInfosOtherSkill + i;
            WeaponInfos[index] = new CWeaponInfoSA((CWeaponInfoSAInterface *)(ARRAY_WeaponInfo + index*CLASSSIZE_WeaponInfo), (eWeaponType)(WEAPONTYPE_PISTOL + i));
        }
    }

	m_pPlayerInfo = new CPlayerInfoSA ( (CPlayerInfoSAInterface *)CLASS_CPlayerInfo );

    // Init cheat name => address map
    m_Cheats [ CHEAT_HOVERINGCARS  ] = (BYTE *)VAR_HoveringCarsEnabled;
    m_Cheats [ CHEAT_FLYINGCARS    ] = (BYTE *)VAR_FlyingCarsEnabled;
    m_Cheats [ CHEAT_EXTRABUNNYHOP ] = (BYTE *)VAR_ExtraBunnyhopEnabled;
    m_Cheats [ CHEAT_EXTRAJUMP     ] = (BYTE *)VAR_ExtraJumpEnabled;
}