Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new vehicle upgrades #3261

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Client/mods/deathmatch/logic/CVehicleUpgrades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ bool CVehicleUpgrades::IsUpgradeCompatible(unsigned short usUpgrade)
return false;

unsigned short usModel = m_pVehicle->GetModel();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unsigned short usModel = m_pVehicle->GetModel();
unsigned short usModel = m_pVehicle->GetModel();
usModel = g_pGame->GetModelInfo(usModel)->GetParentID() || usModel;

This do same thing, but less code.

Copy link
Member

@tederis tederis Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This do same thing, but less code.

Your expression will produce 1 all the time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (auto* pModelInfo = g_pGame->GetModelInfo(usModel); pModelInfo && pModelInfo->GetParentID() != 0)
        usModel = static_cast<uint16_t>(pModelInfo->GetParentID());

Would be better I guess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol. I forgot about this in c++. Ty @tederis

// Wheels should be compatible with any vehicle which have wheels, except
// bike/bmx (they're buggy). Vortex is technically a car, but it has no
// wheels.
Expand All @@ -80,7 +81,15 @@ bool CVehicleUpgrades::IsUpgradeCompatible(unsigned short usUpgrade)
return true;

bool bReturn = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable

switch (usModel)
int model = NULL;
int modelRequestIDParent = g_pGame->GetModelInfo(usModel)->GetParentID();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable

if (modelRequestIDParent == 0){
model = usModel;
}else{
model = modelRequestIDParent;
}

switch (model)
{
case 400:
bReturn = (us == 1020 || us == 1021 || us == 1019 || us == 1018 || us == 1013 || us == 1024 || us == 1008 || us == 1009 || us == 1010);
Expand Down
2 changes: 1 addition & 1 deletion Client/multiplayer_sa/CMultiplayerSA_1.3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ void CVehicleModelInterface_SetClump()
{
// Loop through all vehicles and find the vehicle id that this interface belongs to
CModelInfo* pModelInfo = NULL;
for (int i = 400; i < 612; i++)
for (int i = 400; i < 80000000; i++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It adds more than one parts. Here you specified only the GTA vehicle ids for (int i = 400; i < 612; i++), but it was not checking when there were more ids, so I increased the number. This is a temporary solution. I could not connect the deatmach file to the multiplayer:sa file to capture the parent id. I did something like this for him and it worked.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is extremely inefficient and can lead to freezes when spawning vehicles.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How else can I prevent it? I already thought of this I put it as a temporary solution and it worked

Copy link
Member

@tederis tederis Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see, there is two possible solutions. The first one is to use one of the associative containers to link model ptr to a model ID at the game's start. And the second one is to store model ID in CBaseModelInfo class(but it will require reverse engineering skills). Maybe there is something else, it requires additional study.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tederis
I updated it again, can you check it? I tested it and it worksworks

{
pModelInfo = pGameInterface->GetModelInfo(i);
if (pModelInfo && (DWORD)pModelInfo->GetInterface() == (DWORD)pLoadingModelInfo)
Expand Down