[saco] Fix compilation errors

This commit is contained in:
RD42 2024-10-28 00:00:41 +08:00
parent 55540b1f10
commit 15ab1d056a
14 changed files with 1764 additions and 19 deletions

View File

@ -7675,6 +7675,7 @@ bool CUniBuffer::SetText( LPCTSTR wszText )
WCHAR szBuffer[2048];
ConvertAnsiToWide(wszText, szBuffer, 2048);
SetText(szBuffer);
return true;
}

311
saco/d3d9/d3dutil.cpp Normal file
View File

@ -0,0 +1,311 @@
//-----------------------------------------------------------------------------
// File: D3DUtil.cpp
//
// Desc: Shortcut macros and functions for using DirectX objects
//
// Copyright (c) Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#define D3D_OVERLOADS
#include <math.h>
#include "include/D3DUtil.h"
#ifndef _T
#define _T TEXT
#endif
//-----------------------------------------------------------------------------
// Name: D3DUtil_GetDXSDKMediaPath()
// Desc: Returns the DirectX SDK media path, as stored in the system registry
// during the SDK install.
//-----------------------------------------------------------------------------
// MATCH
const TCHAR* D3DUtil_GetDXSDKMediaPath()
{
static TCHAR strNull[2] = _T("");
static TCHAR strPath[MAX_PATH + 20];
HKEY hKey;
DWORD type, size=MAX_PATH;
// Open the appropriate registry key
LONG result = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
_T("Software\\Microsoft\\DirectX SDK"),
0, KEY_READ, &hKey );
if( ERROR_SUCCESS != result )
return strNull;
result = RegQueryValueEx( hKey, _T("DX9S4SDK Samples Path"), NULL,
&type, (BYTE*)strPath, &size );
if( ERROR_SUCCESS != result )
{
result = RegQueryValueEx( hKey, _T("DX81SDK Samples Path"), NULL,
&type, (BYTE*)strPath, &size );
if( ERROR_SUCCESS != result )
{
result = RegQueryValueEx( hKey, _T("DX8SDK Samples Path"), NULL,
&type, (BYTE*)strPath, &size );
if( ERROR_SUCCESS != result )
{
RegCloseKey( hKey );
return strNull;
}
}
}
RegCloseKey( hKey );
lstrcat( strPath, _T("\\D3DIM\\Media\\") );
return strPath;
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_InitSurfaceDesc()
// Desc: Helper function called to build a DDSURFACEDESC2 structure,
// typically before calling CreateSurface() or GetSurfaceDesc()
//-----------------------------------------------------------------------------
// MATCH
VOID D3DUtil_InitSurfaceDesc( DDSURFACEDESC2& ddsd, DWORD dwFlags,
DWORD dwCaps )
{
ZeroMemory( &ddsd, sizeof(ddsd) );
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = dwFlags;
ddsd.ddsCaps.dwCaps = dwCaps;
ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_InitMaterial()
// Desc: Helper function called to build a D3DMATERIAL7 structure
//-----------------------------------------------------------------------------
VOID D3DUtil_InitMaterial( D3DMATERIAL7& mtrl, FLOAT r, FLOAT g, FLOAT b,
FLOAT a )
{
ZeroMemory( &mtrl, sizeof(D3DMATERIAL7) );
mtrl.dcvDiffuse.r = mtrl.dcvAmbient.r = r;
mtrl.dcvDiffuse.g = mtrl.dcvAmbient.g = g;
mtrl.dcvDiffuse.b = mtrl.dcvAmbient.b = b;
mtrl.dcvDiffuse.a = mtrl.dcvAmbient.a = a;
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_InitLight()
// Desc: Initializes a D3DLIGHT7 structure
//-----------------------------------------------------------------------------
VOID D3DUtil_InitLight( D3DLIGHT7& light, D3DLIGHTTYPE ltType,
FLOAT x, FLOAT y, FLOAT z )
{
ZeroMemory( &light, sizeof(D3DLIGHT7) );
light.dltType = ltType;
light.dcvDiffuse.r = 1.0f;
light.dcvDiffuse.g = 1.0f;
light.dcvDiffuse.b = 1.0f;
light.dcvSpecular = light.dcvDiffuse;
light.dvPosition.x = light.dvDirection.x = x;
light.dvPosition.y = light.dvDirection.y = y;
light.dvPosition.z = light.dvDirection.z = z;
light.dvAttenuation0 = 1.0f;
light.dvRange = D3DLIGHT_RANGE_MAX;
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetViewMatrix()
// Desc: Given an eye point, a lookat point, and an up vector, this
// function builds a 4x4 view matrix.
//-----------------------------------------------------------------------------
// MATCH
HRESULT D3DUtil_SetViewMatrix( D3DMATRIX& mat, D3DVECTOR& vFrom,
D3DVECTOR& vAt, D3DVECTOR& vWorldUp )
{
// Get the z basis vector, which points straight ahead. This is the
// difference from the eyepoint to the lookat point.
D3DVECTOR vView = vAt - vFrom;
FLOAT fLength = Magnitude( vView );
if( fLength < 1e-6f )
return E_INVALIDARG;
// Normalize the z basis vector
vView /= fLength;
// Get the dot product, and calculate the projection of the z basis
// vector onto the up vector. The projection is the y basis vector.
FLOAT fDotProduct = DotProduct( vWorldUp, vView );
D3DVECTOR vUp = vWorldUp - fDotProduct * vView;
// If this vector has near-zero length because the input specified a
// bogus up vector, let's try a default up vector
if( 1e-6f > ( fLength = Magnitude( vUp ) ) )
{
vUp = D3DVECTOR( 0.0f, 1.0f, 0.0f ) - vView.y * vView;
// If we still have near-zero length, resort to a different axis.
if( 1e-6f > ( fLength = Magnitude( vUp ) ) )
{
vUp = D3DVECTOR( 0.0f, 0.0f, 1.0f ) - vView.z * vView;
if( 1e-6f > ( fLength = Magnitude( vUp ) ) )
return E_INVALIDARG;
}
}
// Normalize the y basis vector
vUp /= fLength;
// The x basis vector is found simply with the cross product of the y
// and z basis vectors
D3DVECTOR vRight = CrossProduct( vUp, vView );
// Start building the matrix. The first three rows contains the basis
// vectors used to rotate the view to point at the lookat point
D3DUtil_SetIdentityMatrix( mat );
mat._11 = vRight.x; mat._12 = vUp.x; mat._13 = vView.x;
mat._21 = vRight.y; mat._22 = vUp.y; mat._23 = vView.y;
mat._31 = vRight.z; mat._32 = vUp.z; mat._33 = vView.z;
// Do the translation values (rotations are still about the eyepoint)
mat._41 = - DotProduct( vFrom, vRight );
mat._42 = - DotProduct( vFrom, vUp );
mat._43 = - DotProduct( vFrom, vView );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetProjectionMatrix()
// Desc: Sets the passed in 4x4 matrix to a perpsective projection matrix built
// from the field-of-view (fov, in y), aspect ratio, near plane (D),
// and far plane (F). Note that the projection matrix is normalized for
// element [3][4] to be 1.0. This is performed so that W-based range fog
// will work correctly.
//-----------------------------------------------------------------------------
// MATCH
HRESULT D3DUtil_SetProjectionMatrix( D3DMATRIX& mat, FLOAT fFOV, FLOAT fAspect,
FLOAT fNearPlane, FLOAT fFarPlane )
{
if( fabs(fFarPlane-fNearPlane) < 0.01f )
return E_INVALIDARG;
if( fabs(sin(fFOV/2)) < 0.01f )
return E_INVALIDARG;
FLOAT w = fAspect * ( cosf(fFOV/2)/sinf(fFOV/2) );
FLOAT h = 1.0f * ( cosf(fFOV/2)/sinf(fFOV/2) );
FLOAT Q = fFarPlane / ( fFarPlane - fNearPlane );
ZeroMemory( &mat, sizeof(D3DMATRIX) );
mat._11 = w;
mat._22 = h;
mat._33 = Q;
mat._34 = 1.0f;
mat._43 = -Q*fNearPlane;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetRotateXMatrix()
// Desc: Create Rotation matrix about X axis
//-----------------------------------------------------------------------------
// MATCH
VOID D3DUtil_SetRotateXMatrix( D3DMATRIX& mat, FLOAT fRads )
{
D3DUtil_SetIdentityMatrix( mat );
mat._22 = cosf( fRads );
mat._23 = sinf( fRads );
mat._32 = -sinf( fRads );
mat._33 = cosf( fRads );
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetRotateYMatrix()
// Desc: Create Rotation matrix about Y axis
//-----------------------------------------------------------------------------
// MATCH
VOID D3DUtil_SetRotateYMatrix( D3DMATRIX& mat, FLOAT fRads )
{
D3DUtil_SetIdentityMatrix( mat );
mat._11 = cosf( fRads );
mat._13 = -sinf( fRads );
mat._31 = sinf( fRads );
mat._33 = cosf( fRads );
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetRotateZMatrix()
// Desc: Create Rotation matrix about Z axis
//-----------------------------------------------------------------------------
// MATCH
VOID D3DUtil_SetRotateZMatrix( D3DMATRIX& mat, FLOAT fRads )
{
D3DUtil_SetIdentityMatrix( mat );
mat._11 = cosf( fRads );
mat._12 = sinf( fRads );
mat._21 = -sinf( fRads );
mat._22 = cosf( fRads );
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetRotationMatrix
// Desc: Create a Rotation matrix about vector direction
//-----------------------------------------------------------------------------
// MATCH
VOID D3DUtil_SetRotationMatrix( D3DMATRIX& mat, D3DVECTOR& vDir, FLOAT fRads )
{
FLOAT fCos = cosf( fRads );
FLOAT fSin = sinf( fRads );
D3DVECTOR v = Normalize( vDir );
mat._11 = ( v.x * v.x ) * ( 1.0f - fCos ) + fCos;
mat._12 = ( v.x * v.y ) * ( 1.0f - fCos ) - (v.z * fSin);
mat._13 = ( v.x * v.z ) * ( 1.0f - fCos ) + (v.y * fSin);
mat._21 = ( v.y * v.x ) * ( 1.0f - fCos ) + (v.z * fSin);
mat._22 = ( v.y * v.y ) * ( 1.0f - fCos ) + fCos ;
mat._23 = ( v.y * v.z ) * ( 1.0f - fCos ) - (v.x * fSin);
mat._31 = ( v.z * v.x ) * ( 1.0f - fCos ) - (v.y * fSin);
mat._32 = ( v.z * v.y ) * ( 1.0f - fCos ) + (v.x * fSin);
mat._33 = ( v.z * v.z ) * ( 1.0f - fCos ) + fCos;
mat._14 = mat._24 = mat._34 = 0.0f;
mat._41 = mat._42 = mat._43 = 0.0f;
mat._44 = 1.0f;
}
//-----------------------------------------------------------------------------
// Name: _DbgOut()
// Desc: Outputs a message to the debug stream
//-----------------------------------------------------------------------------
// MATCH
HRESULT _DbgOut( CHAR* strFile, DWORD dwLine, HRESULT hr, TCHAR* strMsg )
{
TCHAR buffer[256];
wsprintf( buffer, _T("%hs(%ld): "), strFile, dwLine );
OutputDebugString( buffer );
OutputDebugString( strMsg );
if( hr != (HRESULT) S_OK )
{
wsprintf( buffer, _T("(hr=%08lx)\n"), hr );
OutputDebugString( buffer );
}
OutputDebugString( _T("\n") );
return hr;
}

1381
saco/d3d9/dxutil.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -88,8 +88,8 @@ typedef struct _ENTITY_TYPE
MATRIX4X4 *mat; // 20-24
DWORD *pdwRenderWare; // 24-28
char _gap1C[6];
DWORD dwProcessingFlags; // 28-32
char _gap20[2];
WORD nModelIndex; // 34-36
char _gap24[18];

View File

@ -816,6 +816,20 @@ void CGame::AddToLocalMoney(int iAmount)
//-----------------------------------------------------------
void CGame::ResetLocalMoney()
{
int iMoney = GetLocalMoney();
if(!iMoney) return;
if(iMoney < 0) {
AddToLocalMoney(abs(iMoney));
} else {
AddToLocalMoney(-(iMoney));
}
}
//-----------------------------------------------------------
int CGame::GetLocalMoney()
{
return *(int *)0xB7CE50;

View File

@ -3,7 +3,9 @@
#include "address.h"
#include "common.h"
#include "vehicle.h"
#include "playerped.h"
#include "actorped.h"
#include "audio.h"
#include "camera.h"
#include "scripting.h"
@ -81,6 +83,7 @@ public:
void DisableMarker(DWORD dwMarkerID);
void AddToLocalMoney(int iAmount);
void ResetLocalMoney();
int GetLocalMoney();
BYTE GetActiveInterior();
@ -97,6 +100,8 @@ public:
//-----------------------------------------------------------
CCamera *GetCamera() { return m_pGameCamera; };
void FUNC_10062570() { field_55++; };
CPlayerPed *FindPlayerPed() {

View File

@ -7,6 +7,9 @@
#define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } }
#define IDC_CMDEDIT 1
#define MAX_PLAYER_NAME 24
#define MAX_SETTINGS_STRING 256
#define GTASA_VERSION_UNKNOWN 0
@ -29,6 +32,7 @@ typedef struct _GAME_SETTINGS {
#include "d3d9/include/d3d9.h"
#include "d3d9/include/d3dx9core.h"
#include "d3d9/common/dxstdafx.h"
#include "game/game.h"
#include "../raknet/RakClientInterface.h"

View File

@ -3,6 +3,7 @@
#include "../game/util.h"
extern CGame *pGame;
extern CNetGame *pNetGame;
//----------------------------------------------------------

View File

@ -76,6 +76,8 @@ public:
BOOL GetWalkStyle() { return field_3D5->bUseCJWalk; };
CPlayerPool * GetPlayerPool() { return m_pPools->pPlayerPool; };
CGangZonePool * GetGangZonePool() { return m_pPools->pGangZonePool; };
RakClientInterface * GetRakClient() { return m_pRakClient; };
void ResetMapIcons();
void SetMapIcon(BYTE byteIndex, float fX, float fY, float fZ, BYTE byteIcon, DWORD dwColor, int iStyle);

View File

@ -17,13 +17,13 @@ void GameModeRestart(RPCParameters *rpcParams) {}
void ConnectionRejected(RPCParameters *rpcParams) {}
void ClientMessage(RPCParameters *rpcParams) {}
void WorldTime(RPCParameters *rpcParams) {}
void Unk5F(RPCParameters *rpcParams) {}
void Unk3F(RPCParameters *rpcParams) {}
void Unk97(RPCParameters *rpcParams) {}
void Pickup(RPCParameters *rpcParams) {}
void DestroyPickup(RPCParameters *rpcParams) {}
void DestroyWeaponPickup(RPCParameters *rpcParams) {}
void ScmEvent(RPCParameters *rpcParams) {}
void Weather(RPCParameters *rpcParams) {}
void Unk1D(RPCParameters *rpcParams) {}
void Unk1E(RPCParameters *rpcParams) {}
void SetTimeEx(RPCParameters *rpcParams) {}
void ToggleClock(RPCParameters *rpcParams) {}
void Unk3C(RPCParameters *rpcParams) {}
void WorldPlayerAdd(RPCParameters *rpcParams) {}
void WorldPlayerDeath(RPCParameters *rpcParams) {}
@ -68,13 +68,13 @@ void RegisterRPCs(RakClientInterface * pRakClient)
REGISTER_STATIC_RPC(pRakClient,ConnectionRejected);
REGISTER_STATIC_RPC(pRakClient,ClientMessage);
REGISTER_STATIC_RPC(pRakClient,WorldTime);
REGISTER_STATIC_RPC(pRakClient,Unk5F);
REGISTER_STATIC_RPC(pRakClient,Unk3F);
REGISTER_STATIC_RPC(pRakClient,Unk97);
REGISTER_STATIC_RPC(pRakClient,Pickup);
REGISTER_STATIC_RPC(pRakClient,DestroyPickup);
REGISTER_STATIC_RPC(pRakClient,DestroyWeaponPickup);
REGISTER_STATIC_RPC(pRakClient,ScmEvent);
REGISTER_STATIC_RPC(pRakClient,Weather);
REGISTER_STATIC_RPC(pRakClient,Unk1D);
REGISTER_STATIC_RPC(pRakClient,Unk1E);
REGISTER_STATIC_RPC(pRakClient,SetTimeEx);
REGISTER_STATIC_RPC(pRakClient,ToggleClock);
REGISTER_STATIC_RPC(pRakClient,Unk3C);
REGISTER_STATIC_RPC(pRakClient,WorldPlayerAdd);
REGISTER_STATIC_RPC(pRakClient,WorldPlayerDeath);
@ -136,13 +136,13 @@ void UnRegisterRPCs(RakClientInterface * pRakClient)
UNREGISTER_STATIC_RPC(pRakClient,ConnectionRejected);
UNREGISTER_STATIC_RPC(pRakClient,ClientMessage);
UNREGISTER_STATIC_RPC(pRakClient,WorldTime);
UNREGISTER_STATIC_RPC(pRakClient,Unk5F);
UNREGISTER_STATIC_RPC(pRakClient,Unk3F);
UNREGISTER_STATIC_RPC(pRakClient,Unk97);
UNREGISTER_STATIC_RPC(pRakClient,Pickup);
UNREGISTER_STATIC_RPC(pRakClient,DestroyPickup);
UNREGISTER_STATIC_RPC(pRakClient,DestroyWeaponPickup);
UNREGISTER_STATIC_RPC(pRakClient,ScmEvent);
UNREGISTER_STATIC_RPC(pRakClient,Weather);
UNREGISTER_STATIC_RPC(pRakClient,Unk1D);
UNREGISTER_STATIC_RPC(pRakClient,Unk1E);
UNREGISTER_STATIC_RPC(pRakClient,SetTimeEx);
UNREGISTER_STATIC_RPC(pRakClient,ToggleClock);
UNREGISTER_STATIC_RPC(pRakClient,EditAttachedObject);
UNREGISTER_STATIC_RPC(pRakClient,EditObject);
UNREGISTER_STATIC_RPC(pRakClient,SelectObject);

View File

@ -3,6 +3,8 @@
#include <string>
#define INVALID_PLAYER_ID 0xFFFF
//----------------------------------------------------
class CPlayerPool

View File

@ -13,7 +13,7 @@ CRemotePlayer::CRemotePlayer()
{
field_1E7 = 0;
field_10A = 0;
field_1E5 = -1;
m_PlayerID = INVALID_PLAYER_ID;
field_1DD = 0;
field_1B8 = 0;
field_109 = -1;

View File

@ -43,7 +43,7 @@ private:
DWORD field_1D9;
int field_1DD;
int field_1E1;
short field_1E5;
PLAYERID m_PlayerID;
short field_1E7;
int field_1E9;
int field_1ED;

View File

@ -192,6 +192,12 @@
<File
RelativePath=".\game\keystuff.h">
</File>
<File
RelativePath=".\game\menu.cpp">
</File>
<File
RelativePath=".\game\menu.h">
</File>
<File
RelativePath=".\game\patches.cpp">
</File>
@ -228,6 +234,12 @@
<File
RelativePath=".\game\util.h">
</File>
<File
RelativePath=".\game\vehicle.cpp">
</File>
<File
RelativePath=".\game\vehicle.h">
</File>
</Filter>
<Filter
Name="archive"
@ -353,6 +365,12 @@
<File
RelativePath=".\net\playerpool.h">
</File>
<File
RelativePath=".\net\remoteplayer.cpp">
</File>
<File
RelativePath=".\net\remoteplayer.h">
</File>
<File
RelativePath=".\net\scriptrpc.cpp">
</File>
@ -899,6 +917,12 @@
<Filter
Name="d3dhook"
Filter="">
<File
RelativePath=".\d3dhook\ID3DXFontHook.cpp">
</File>
<File
RelativePath=".\d3dhook\ID3DXFontHook.h">
</File>
<File
RelativePath=".\d3dhook\IDirect3DDevice9Hook.cpp">
</File>