[saco] Add DoInitStuff() and DoProcessStuff()

* Updates `TheGraphicsLoop()`
This commit is contained in:
RD42 2024-02-18 22:05:04 +08:00
parent bd5ff19c90
commit ff4a8795f2
5 changed files with 109 additions and 2 deletions

View File

@ -2,6 +2,7 @@
#pragma once
#define ADDR_HWND 0xC97C1C
#define ADDR_ID3D9DEVICE 0xC97C28
#define ADDR_KEYSTATES 0xB73458

View File

@ -64,6 +64,8 @@ public:
void DrawGangZone(float* fPos, DWORD dwColor);
DWORD GetD3DDevice();
DWORD GetD3D() { return *(DWORD *)ADDR_ID3D9DEVICE; };
HWND GetMainWindowHwnd() { return *(HWND *)ADDR_HWND; };
void StartGame();

View File

@ -7,6 +7,9 @@ int iGtaVersion=0;
GAME_SETTINGS tSettings;
CHAR szArtworkProxy[MAX_PATH+1];
CHAR szConfigFile[MAX_PATH+1];
CHAR byte_1026E710[256]; // unused
CHAR szChatLogFile[MAX_PATH+1];
CHAR szSAMPDir[MAX_PATH+1];
CHAR szCacheDir[MAX_PATH+1];
@ -23,6 +26,11 @@ CFontRender *pDefaultFont=0;
//DWORD dword_1026EBA4=0;
//DWORD dword_1026EBA8=0;
BOOL bGameInited=FALSE;
IDirect3D9 *pD3D;
IDirect3DDevice9 *pD3DDevice = NULL;
HANDLE hInstance=0;
bool bShowDebugLabels = false;
@ -34,6 +42,7 @@ CFileSystem *pFileSystem=NULL;
// forwards
BOOL SubclassGameWindow();
void TheGraphicsLoop();
LONG WINAPI exc_handler(_EXCEPTION_POINTERS* exc_inf);
void sub_1009DD50();
@ -213,8 +222,55 @@ void CallRwRenderStateGet(int state, int *option)
//----------------------------------------------------
void DoInitStuff()
{
// GAME INIT
if(!bGameInited)
{
SetupDirectories();
sprintf(szConfigFile, "%s\\sa-mp.cfg", szSAMPDir);
sprintf(szChatLogFile, "%s\\chatlog.txt", szSAMPDir);
pConfig = new CConfig(szConfigFile);
timeBeginPeriod(1); // increases the accuracy of Sleep()
sub_1009DD50();
SubclassGameWindow();
// Grab the real IDirect3D9 * from the game.
pD3D = (IDirect3D9 *)pGame->GetD3D();
// Grab the real IDirect3DDevice9 * from the game.
pD3DDevice = (IDirect3DDevice9 *)pGame->GetD3DDevice();
// TODO: DoInitStuff
bGameInited = TRUE;
return;
}
}
//----------------------------------------------------
void DoProcessStuff()
{
DoInitStuff();
}
//----------------------------------------------------
void TheGraphicsLoop()
{
_asm pushad // because we're called from a hook
DoProcessStuff();
_asm popad
}
//----------------------------------------------------

View File

@ -22,6 +22,8 @@ typedef struct _GAME_SETTINGS {
CHAR szDebugScript[MAX_SETTINGS_STRING+1];
} GAME_SETTINGS;
#include "d3d9/include/d3d9.h"
#include "d3d9/include/d3dx9core.h"
#include "game/game.h"
#include "../raknet/RakClientInterface.h"

View File

@ -19,6 +19,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="d3d9\include\"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SACO_EXPORTS"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
@ -32,7 +33,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="wsock32.lib"
AdditionalDependencies="wsock32.lib winmm.lib"
OutputFile="$(OutDir)/samp.dll"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
@ -69,6 +70,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="d3d9\include\"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SACO_EXPORTS"
RuntimeLibrary="0"
StructMemberAlignment="1"
@ -81,7 +83,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="wsock32.lib"
AdditionalDependencies="wsock32.lib winmm.lib"
OutputFile="$(OutDir)/samp.dll"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
@ -477,6 +479,50 @@
RelativePath="..\raknet\TEABlockEncryptor.h">
</File>
</Filter>
<Filter
Name="d3dhook"
Filter="">
<Filter
Name="d3d9"
Filter="">
<File
RelativePath=".\d3d9\include\d3d.h">
</File>
<File
RelativePath=".\d3d9\include\d3d9.h">
</File>
<File
RelativePath=".\d3d9\include\d3d9caps.h">
</File>
<File
RelativePath=".\d3d9\include\d3d9types.h">
</File>
<File
RelativePath=".\d3d9\include\d3dx9.h">
</File>
<File
RelativePath=".\d3d9\include\d3dx9core.h">
</File>
<File
RelativePath=".\d3d9\include\d3dx9effect.h">
</File>
<File
RelativePath=".\d3d9\include\d3dx9math.h">
</File>
<File
RelativePath=".\d3d9\include\d3dx9mesh.h">
</File>
<File
RelativePath=".\d3d9\include\d3dx9shader.h">
</File>
<File
RelativePath=".\d3d9\include\d3dx9shape.h">
</File>
<File
RelativePath=".\d3d9\include\d3dx9tex.h">
</File>
</Filter>
</Filter>
<File
RelativePath=".\audiostream.cpp">
</File>