Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Add first III/VC target config, adjust controls, close #74
Browse files Browse the repository at this point in the history
  • Loading branch information
gennariarmando committed Feb 28, 2022
1 parent 43a80f8 commit ee4f0ec
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 48 deletions.
105 changes: 75 additions & 30 deletions premake5.lua
Original file line number Diff line number Diff line change
@@ -1,65 +1,110 @@
workspace "v-hud"
configurations { "Release", "Debug" }
configurations { "ReleaseSA", "DebugSA", "ReleaseVC", "DebugVC", "ReleaseIII", "DebugIII" }
location "project_files"

project "v-hud"
kind "SharedLib"
language "C++"
targetdir "output/asi/"
objdir ("output/obj")
targetextension ".asi"
characterset ("MBCS")
linkoptions "/SAFESEH:NO"
buildoptions { "-std:c++latest", "/permissive" }
defines { "_CRT_SECURE_NO_WARNINGS", "_CRT_NON_CONFORMING_SWPRINTFS", "_USE_MATH_DEFINES" }
disablewarnings { "4244", "4800", "4305", "4073", "4838", "4996", "4221", "4430", "26812", "26495", "6031" }
defines { "_DX9_SDK_INSTALLED" }
links { "d3d9", "d3dx9", "bass" }

files {
"source/**.*",
"vendor/pugixml/src/*.*",
"vendor/pugixml/src/*.*"
}

includedirs {
"source/**",
"source/**"
}

includedirs {
"vendor/GInputAPI",
"$(PLUGIN_SDK_DIR)/shared/",
"$(PLUGIN_SDK_DIR)/shared/game/",
"$(PLUGIN_SDK_DIR)/plugin_sa/",
"$(PLUGIN_SDK_DIR)/plugin_sa/game_sa/",
"vendor/pugixml/src",
"$(DXSDK_DIR)/Include/",
"vendor/ModUtils",
"vendor/bass"
}

filter { "configurations:*III" }
defines { "GTAIII", "PLUGIN_SGV_10EN" }
includedirs {
"$(PLUGIN_SDK_DIR)/plugin_III/",
"$(PLUGIN_SDK_DIR)/plugin_III/game_III/",
"$(RWD3D9_DIR)/source"
}
targetname "VHudIII"
debugdir "$(GTA_III_DIR)"
debugcommand "$(GTA_III_DIR)/gta3.exe"
postbuildcommands "copy /y \"$(TargetPath)\" \"$(GTA_III_DIR)\\scripts\\VHudIII.asi\""
libdirs { "$(RWD3D9_DIR)/libs" }
links { "rwd3d9" }

filter { "configurations:*VC" }
defines { "GTAVC", "PLUGIN_SGV_10EN" }
includedirs {
"$(PLUGIN_SDK_DIR)/plugin_vc/",
"$(PLUGIN_SDK_DIR)/plugin_vc/game_vc/",
"$(RWD3D9_DIR)/source"
}
targetname "VHudVC"
debugdir "$(GTA_VC_DIR)"
debugcommand "$(GTA_VC_DIR)/gta-vc.exe"
postbuildcommands "copy /y \"$(TargetPath)\" \"$(GTA_VC_DIR)\\scripts\\VHudVC.asi\""
libdirs { "$(RWD3D9_DIR)/libs" }
links { "rwd3d9" }

filter { "configurations:*SA" }
defines { "GTASA", "PLUGIN_SGV_10US" }
includedirs {
"$(PLUGIN_SDK_DIR)/plugin_sa/",
"$(PLUGIN_SDK_DIR)/plugin_sa/game_sa/"
}
targetname "VHud"
debugdir "$(GTA_SA_DIR)"
debugcommand "$(GTA_SA_DIR)/gta-sa.exe"
postbuildcommands "copy /y \"$(TargetPath)\" \"$(GTA_SA_DIR)\\scripts\\VHud.asi\""

filter { }

libdirs {
"$(PLUGIN_SDK_DIR)/output/lib/",
"$(DXSDK_DIR)/Lib/x86",
"vendor/bass"
}

kind "SharedLib"
language "C++"
targetdir "output/asi/"
objdir ("output/obj")
targetextension ".asi"
characterset ("MBCS")
linkoptions "/SAFESEH:NO"
buildoptions { "-std:c++latest", "/permissive" }
defines { "_CRT_SECURE_NO_WARNINGS", "_CRT_NON_CONFORMING_SWPRINTFS", "_USE_MATH_DEFINES" }
disablewarnings { "4244", "4800", "4305", "4073", "4838", "4996", "4221", "4430", "26812", "26495", "6031" }
defines { "GTASA", "PLUGIN_SGV_10US", "_DX9_SDK_INSTALLED" }
links { "d3d9", "d3dx9", "bass" }

filter "configurations:Debug"
links { "plugin_d" }
targetname "VHud"
filter "configurations:Debug*"
defines { "DEBUG" }
symbols "on"
staticruntime "on"
debugdir "$(GTA_SA_DIR)"
debugcommand "$(GTA_SA_DIR)/gta-sa.exe"
postbuildcommands "copy /y \"$(TargetPath)\" \"$(GTA_SA_DIR)\\scripts\\VHud.asi\""

filter "configurations:Release"
links { "plugin" }
targetname "VHud"
filter "configurations:Release*"
defines { "NDEBUG" }
symbols "off"
optimize "On"
staticruntime "on"
debugdir "$(GTA_SA_DIR)"
debugcommand "$(GTA_SA_DIR)/gta-sa.exe"
postbuildcommands "copy /y \"$(TargetPath)\" \"$(GTA_SA_DIR)\\scripts\\VHud.asi\""

filter "configurations:ReleaseSA"
links { "plugin" }
filter "configurations:ReleaseVC"
links { "plugin_vc" }
filter "configurations:ReleaseIII"
links { "plugin_iii" }

filter "configurations:DebugSA"
links { "plugin_d" }
filter "configurations:DebugVC"
links { "plugin_vc_d" }
filter "configurations:DebugIII"
links { "plugin_iii_d" }

filter { }
5 changes: 4 additions & 1 deletion source/3dMarkersNew.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef GTASA
#include "VHud.h"
#include "3dMarkersNew.h"
#include "TextureMgr.h"
Expand Down Expand Up @@ -133,4 +134,6 @@ void C3dMarkersNew::Shutdown() {
}

bInitialised = false;
}
}

#endif
2 changes: 2 additions & 0 deletions source/CellPhone.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef GTASA
#include "VHud.h"
#include "CellPhone.h"
#include "HudNew.h"
Expand Down Expand Up @@ -544,3 +545,4 @@ void CCellPhone::Draw() {
DrawPhone(HUD_RIGHT(382.0f), HUD_BOTTOM(offset));
}

#endif
23 changes: 14 additions & 9 deletions source/FontNew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

#include "pugixml.hpp"

#ifndef GTASA
#include "rwd3d9.h"
#endif

using namespace plugin;
using namespace pugi;

Expand Down Expand Up @@ -275,7 +279,7 @@ void CFontNew::Clear() {
}

long CFontNew::AddFont(CFontTT t, LPD3DXFONT* font) {
return D3DXCreateFontA(GetD3DDevice(), t.height, t.width, FW_NORMAL, 0, FALSE, t.charSet, OUT_DEFAULT_PRECIS, t.quality, DEFAULT_PITCH | FF_DONTCARE, t.fontName, font);
return D3DXCreateFontA((LPDIRECT3DDEVICE9)RwD3D9GetCurrentD3DDevice(), t.height, t.width, FW_NORMAL, 0, FALSE, t.charSet, OUT_DEFAULT_PRECIS, t.quality, DEFAULT_PITCH | FF_DONTCARE, t.fontName, font);
}

void CFontNew::Shutdown() {
Expand Down Expand Up @@ -939,10 +943,11 @@ float CFontNew::DrawChar(bool print, bool calc, float x, float y, char c, int st
IDirect3DVertexShader9* savedVertexShader = NULL;
IDirect3DPixelShader9* savedPixelShader = NULL;

GetD3DDevice()->GetRenderState(D3DRS_COLORWRITEENABLE, &savedColorWrite);
GetD3DDevice()->GetVertexDeclaration(&savedVertexDecl);
GetD3DDevice()->GetVertexShader(&savedVertexShader);
GetD3DDevice()->GetPixelShader(&savedPixelShader);
auto device = (LPDIRECT3DDEVICE9)RwD3D9GetCurrentD3DDevice();
device->GetRenderState(D3DRS_COLORWRITEENABLE, &savedColorWrite);
device->GetVertexDeclaration(&savedVertexDecl);
device->GetVertexShader(&savedVertexShader);
device->GetPixelShader(&savedPixelShader);

D3DXMatrixScaling(&S, w, h, 1.0f);
m_pSprite->GetTransform(&P);
Expand All @@ -952,10 +957,10 @@ float CFontNew::DrawChar(bool print, bool calc, float x, float y, char c, int st
m_pSprite->End();
m_pSprite->SetTransform(&P);

GetD3DDevice()->SetRenderState(D3DRS_COLORWRITEENABLE, savedColorWrite);
GetD3DDevice()->SetVertexDeclaration(savedVertexDecl);
GetD3DDevice()->SetVertexShader(savedVertexShader);
GetD3DDevice()->SetPixelShader(savedPixelShader);
device->SetRenderState(D3DRS_COLORWRITEENABLE, savedColorWrite);
device->SetVertexDeclaration(savedVertexDecl);
device->SetVertexShader(savedVertexShader);
device->SetPixelShader(savedPixelShader);
}

if (calc) {
Expand Down
16 changes: 14 additions & 2 deletions source/GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ static LateStaticInit InstallHooks([]() {
pathNodes[i] = -1;
}

#ifdef GTASA
patch::SetFloat(0x450ACD + 1, MAX_SEARCH_RADIUS);
patch::SetPointer(0x451782, &pathNodes);
patch::SetPointer(0x451904, &pathNodes);
patch::SetPointer(0x451AC3, &pathNodes);
patch::SetPointer(0x451B33, &pathNodes);
patch::SetUInt(0x4518F8, MAX_PATH_NODES);
patch::SetUInt(0x4519B0, MAX_PATH_NODES - 5);
#endif
});

void CGPS::Init() {
Expand Down Expand Up @@ -150,15 +152,22 @@ void CGPS::DrawLine(CVector2D const&a, CVector2D const&b, float width, CRGBA col
}

void CGPS::ProcessPath(CLocalization& l) {
if (!FindPlayerPed(0))
#ifdef GTASA
if (!FindPlayerPed(PLAYER_ID))
return;

CVector start = FindPlayerCentreOfWorld(0);
CVector end = l.vecDest;

#ifdef GTASA
ThePaths.DoPathSearch(0, start, CNodeAddress(), end, l.resultNodes, &l.nNodesCount, MAX_NODE_POINTS, &l.fGPSDistance,
999999.0f, NULL, 999999.0f, false, CNodeAddress(), false, false);

#else
CVehicle* veh = FindPlayerPed(PLAYER_ID)->m_pVehicle;
if (!veh)
return;
ThePaths.DoPathSearch(0, start, -1, end, l.resultNodes, &l.nNodesCount, MAX_NODE_POINTS, veh, NULL, 999999.0f, -1);
#endif
if (l.nNodesCount > 0) {
for (short i = 0; i < l.nNodesCount; i++) {
CVector nodePosn = ThePaths.GetPathNode(l.resultNodes[i])->GetNodeCoors();
Expand All @@ -184,9 +193,11 @@ void CGPS::ProcessPath(CLocalization& l) {
DrawLine(l.nodePoints[i], l.nodePoints[i + 1], w, col);
}
}
#endif
}

void CGPS::DrawPathLine() {
#ifdef GTASA
if (!MenuNew.Settings.gpsRoute)
return;

Expand Down Expand Up @@ -249,6 +260,7 @@ void CGPS::DrawPathLine() {
}
}
}
#endif
}

char CGPS::GetPathDirection(CVector start, CVector plr, CVector end) {
Expand Down
4 changes: 4 additions & 0 deletions source/GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ struct CLocalization {
float fGPSDistance;
char nPathDirection;
short nNodesCount;
#ifdef GTASA
CNodeAddress resultNodes[MAX_NODE_POINTS];
#else
CPathNode* resultNodes[MAX_NODE_POINTS];
#endif
CVector2D nodePoints[MAX_NODE_POINTS];
unsigned int pathColor;

Expand Down
6 changes: 6 additions & 0 deletions source/GameLogicNew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ using namespace plugin;
CGameLogicNew GameLogicNew;

static LateStaticInit InstallHooks([]() {
#ifdef GTASA
CdeclEvent<AddressList<0x442128, H_CALL>, PRIORITY_BEFORE, ArgPickNone, void()> onResurrection;
#elif GTAVC
CdeclEvent<AddressList<0x42B9CA, H_CALL>, PRIORITY_BEFORE, ArgPickNone, void()> onResurrection;
#elif GTA3
CdeclEvent<AddressList<0X421BDE, H_CALL>, PRIORITY_BEFORE, ArgPickNone, void()> onResurrection;
#endif

onResurrection += [] {
CHudNew::ReInit();
Expand Down
3 changes: 2 additions & 1 deletion source/HudNew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ static LateStaticInit InstallHooks([]() {
};
patch::RedirectJump(0x705331, (void*)0x7053AF);

patch::PutRetn(0x742CF0);
patch::Nop(0x7434F2, 5);
patch::Nop(0x7433A3, 5);

// CMessages::InsertPlayerControlKeysInString

Expand Down
10 changes: 5 additions & 5 deletions source/PadNew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CControls Controls[NUM_CONTROL_ACTIONS] = {
{ "PED_ANSWER_PHONE", KEY(rsTAB), GAMEPAD_LEFTSHOULDER1, GAMEPAD_LEFTSHOULDER1 },
{ "SNEAK_ABOUT", KEY(rsLCTRL), GAMEPAD_NONE, GAMEPAD_NONE },
{ "VEHICLE_FIREWEAPON", MOUSE(rsMOUSELEFTBUTTON), GAMEPAD_CIRCLE, GAMEPAD_CIRCLE },
{ "VEHICLE_FIREWEAPON_ALT", KEY(rsLCTRL), GAMEPAD_LEFTSHOULDER1, GAMEPAD_CROSS },
{ "VEHICLE_FIREWEAPON_ALT", KEY(rsRCTRL), GAMEPAD_LEFTSHOULDER1, GAMEPAD_CROSS },
{ "VEHICLE_STEERLEFT", KEY('A'), GAMEPAD_THUMBLXL, GAMEPAD_THUMBLXL },
{ "VEHICLE_STEERRIGHT", KEY('D'), GAMEPAD_THUMBLXR, GAMEPAD_THUMBLXR },
{ "VEHICLE_STEERUP", KEY(rsPGUP), GAMEPAD_THUMBLYU },
Expand All @@ -61,10 +61,10 @@ CControls Controls[NUM_CONTROL_ACTIONS] = {
{ "VEHICLE_LOOKRIGHT", KEY('E'), GAMEPAD_THUMBRXR, GAMEPAD_THUMBRXR },
{ "VEHICLE_LOOKBEHIND", KEY('C'), GAMEPAD_THUMBR, GAMEPAD_THUMBR, },
{ "VEHICLE_MOUSELOOK", KEY(rsNULL), GAMEPAD_NONE, GAMEPAD_NONE },
{ "VEHICLE_TURRETLEFT", KEY(rsPADLEFT), GAMEPAD_THUMBRXL, GAMEPAD_THUMBRXL },
{ "VEHICLE_TURRETRIGHT", KEY(rsPADRIGHT), GAMEPAD_THUMBRXR, GAMEPAD_THUMBRXR },
{ "VEHICLE_TURRETUP", KEY(rsPADUP), GAMEPAD_THUMBRYU, GAMEPAD_THUMBRYU },
{ "VEHICLE_TURRETDOWN", KEY(rsPADDOWN), GAMEPAD_THUMBRYD, GAMEPAD_THUMBRYD },
{ "VEHICLE_TURRETLEFT", KEY('T'), GAMEPAD_THUMBRXL, GAMEPAD_THUMBRXL},
{ "VEHICLE_TURRETRIGHT", KEY('G'), GAMEPAD_THUMBRXR, GAMEPAD_THUMBRXR},
{ "VEHICLE_TURRETUP", KEY('R'), GAMEPAD_THUMBRYU, GAMEPAD_THUMBRYU },
{ "VEHICLE_TURRETDOWN", KEY('Y'), GAMEPAD_THUMBRYD, GAMEPAD_THUMBRYD },
{ "PED_CYCLE_TARGET_LEFT", KEY('Q'), GAMEPAD_LEFTSHOULDER2, GAMEPAD_LEFTSHOULDER1 },
{ "PED_CYCLE_TARGET_RIGHT", KEY('E'), GAMEPAD_RIGHTSHOULDER2, GAMEPAD_RIGHTSHOULDER1 },
{ "PED_CENTER_CAMERA_BEHIND_PLAYER", KEY(rsNULL), GAMEPAD_LEFTSHOULDER1, GAMEPAD_RIGHTSHOULDER1 },
Expand Down
6 changes: 6 additions & 0 deletions source/VHud.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
#include "LateStaticInit.h"


#ifdef GTASA
#define PLAYER_ID 0
#else
#define PLAYER_ID
#endif

enum eUGEvents {
UG_EVENT_BEFORE_RENDER2DSTUFF,
UG_EVENT_AFTER_RENDER2DSTUFF,
Expand Down

0 comments on commit ee4f0ec

Please sign in to comment.