Ejemplo n.º 1
0
/**
 * Submit a chunk to the script engine.
 * @param s The chunk.
 */
void Console::SubmitChunk(const std::string &s)
{
    chunk += s;

    try {
        Execute(chunk);
    }
    catch (const IncompleteExn&) {
        SetInputState(ISTATE_CONTINUE);
        return;
    }
    catch (const ScriptExn &exn) {
        LogError(exn.GetMessage());
    }

    chunk.clear();
    SetInputState(ISTATE_COMMAND);
}
Ejemplo n.º 2
0
void CGame::SetFocused(bool bFocused)
{
	// Set the focused flag
	m_bFocused = bFocused;

	if(bFocused) // We have focus
	{
		// Enable input
		SetInputState(true);
		CAudioManager::RestoreAllVolume();

		if(g_pMainMenu)
			g_pMainMenu->HideLoadingScreen();
	}
	else // We do not have focus
	{
		// Disable input
		SetInputState(false);
		CAudioManager::SetAllVolume(0.0f);
	}
}
Ejemplo n.º 3
0
void CGame::Initialize()
{
	// Ensure all game structures are correctly aligned
	assert(sizeof(IVCamData) == 0x74);
	assert(sizeof(IVCam) == 0x140);
	assert(sizeof(IVCheckpoint) == 0x30);
	assert(sizeof(IVEntity) == 0x74);
	assert(sizeof(IVDynamicEntity) == 0x10C);
	//assert(sizeof(IVBaseModelInfo) == 0x0); // TODO
	assert(sizeof(IVPadConfig) == 0x7B8);
	assert(sizeof(IVPadDataHistoryItem) == 0x8);
	assert(sizeof(IVPadDataHistory) == 0x200);
	assert(sizeof(IVPadData) == 0x10);
	assert(sizeof(IVPad) == 0x3A84);
	//assert(sizeof(IVPedTaskManager) == 0x0); // TODO
	assert(sizeof(IVPedWeaponSlot) == 0xC);
	assert(sizeof(IVPedWeapons) == 0x11A);
	assert(sizeof(IVPhysical) == 0x210);
	assert(sizeof(IVPed) == 0xF00);
	assert(sizeof(IVPlayerInfo) == 0x5C0);
	assert(sizeof(IVPlayerPed) == 0xF00);
	assert(sizeof(IVPool) == 0x1C);
	//assert(sizeof(IVTask) == 0x0); // TODO
	assert(sizeof(IVVehicle) == 0x20D0);
	assert(sizeof(IVWeaponInfo) == 0x110);
	assert(sizeof(CSimpleCollection<void>) == 0x8);

	// Get the process base address
	m_uiBaseAddress = (unsigned int)GetModuleHandle(NULL);

	if(m_uiBaseAddress == 0)
	{
		CLogFile::Printf("Invalid Game Base Detected. Exiting...");
		ExitProcess(0);
	}

	CLogFile::Printf("Game Base: 0x%p (0x%p)", m_uiBaseAddress, (m_uiBaseAddress - 0x400000));
	m_uiBaseAddress -= 0x400000;
	COffsets::Init(m_uiBaseAddress);

	if(COffsets::GetVersion() == GAME_VERSION_UNKNOWN)
	{
		MessageBox(NULL, "Unknown game version detected. IV:MP currently only supports version 1.0.7.0", "Unknown game version", NULL);
		ExitProcess(0);
	}

	if(Patch())
	{
		// DOES this native have any function, ida says nope
		#ifdef DEBUG
			Scripting::DebugOn();
			CLogFile::Printf("Applied GTAIV DEBUG mode");
		#endif

		CLogFile::Printf("Applied patches");
		InstallKeySyncHooks();
		InstallAimSyncHooks();
		CLogFile::Printf("Applied key sync/aim sync hooks");

		InstallIndicatorHooks();
		InstallTrafficLightHooks();
		CLogFile::Printf("Applied misc hooks");

		InstallScriptHooks();
		CLogFile::Printf("Applied script hooks");

	}
	else
	{
		MessageBox(NULL, "Failed to apply patches. IV:MP needs to apply certain patches to run", "Failed to apply patches", NULL);
		ExitProcess(0);
	}

	// Replace "Loading .." with "IV:MP is loading...", some user say that the label sometimes is shown
	//Scripting::SetMsgForLoadingScreen("IV:MP is loading....");

	/*Scripting::RequestScript("trainHelper");
	while(!Scripting::HasScriptLoaded("trainHelper")) {
		Sleep(10);
	}
	Scripting::StartNewScript("trainHelper", 1024);

	Scripting::RequestScript("carwash");
	while(!Scripting::HasScriptLoaded("carwash")) {
		Sleep(10);
	}
	Scripting::StartNewScript("carwash", 1024);*/

	SetInputState(true);
	SetState(GAME_STATE_NONE);

	// Create our pools class
	m_pPools = new CPools();

	// Create the pad instance
	m_pPad = new CIVPad((IVPad *)COffsets::VAR_Pads);

	// Initialize our game classes
	m_pStreaming = new CIVStreaming();
	m_pWeather = new CIVWeather();
	m_pWorld = new CIVWorld();

	// Initialize the model infos
	for(int i = 0; i < NUM_ModelInfos; i++)
		m_modelInfos[i].SetIndex(i);

	// Disable invalid models
	m_modelInfos[125].SetIndex(-1); // Ingot (FIX) //41
	m_modelInfos[180].SetIndex(-1); // Uranus (FIX) //96
	m_modelInfos[191].SetIndex(-1); // Hellfury (FIX) // 107
	m_modelInfos[195].SetIndex(-1); // Zombieb (FIX) // 111

	// Initialize the weapon infos
	for(int i = 0; i < NUM_WeaponInfos; i++)
	{
		// TODO: Make SetType update the weapon info pointer?
		m_weaponInfos[i].SetType((eWeaponType)i);
		m_weaponInfos[i].SetWeaponInfo((IVWeaponInfo *)((GetBase() + ARRAY_WeaponInfos) + (i * sizeof(IVWeaponInfo))));
	}
}