-
-
Notifications
You must be signed in to change notification settings - Fork 438
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
Feature: replace atomic models with clump models #3003
Feature: replace atomic models with clump models #3003
Conversation
It must be done on disconnect and Is the new API ( |
it may be a case where people already have had models with multiple atomics/clump models but they didn't know and this change may cause old code to not be fully compatible thats why i added this function. "engineRestoreModel" is working, |
in ~2 weeks i'm going add functionality where models changes using "engineConvertAtomicToClumpModel(1337)" will be reverted back to atomic when you left the server. if anyone has any objectives, let me know |
Now it works a bit differently, instead of "convert" you change internal type of model, for now only availiable options are "clump" and "atomic", limitation is that you can change from atomic to clump, but not from clump to atomic until you previously set it to clump. I have made it to prevent potential crashes because i'm 100% sure that crash will happen if you convert ped to atomic, atomic to vehicle ect.
there's second function "engineGetModelInfoType" that return internal type of model, so for example first you have to change type, then replace it ( or probably restream world when type change ) there are things i, you need to test:
|
I think we should discuss more about possibility of merging this into existing API ( |
removed all new lua functions, now if you replace model it get converted to clump automatically, restore will convert model back to atomic if needed, same when you leave the server. |
What would be the use-case for this though? |
mostly for future pull requests, it opens doors to many features. |
Client/game_sa/CRenderWareSA.cpp
Outdated
return ((void(__cdecl*)(RpAtomic*, int))0x732230)(pRpAtomic, id); | ||
} | ||
|
||
typedef struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it's better not to use C-style struct declaration.
|
||
CModelInfo* pModelInfo = g_pGame->GetModelInfo(m_iModelID, true); | ||
|
||
if (!pModelInfo->IsValid() || m_eModelType != eClientModelType::OBJECT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetModelInfo can return nullptr what should be taken into account in this conditional expression.
{ | ||
CModelInfo* pModelInfo = g_pGame->GetModelInfo(m_iModelID, true); | ||
|
||
if (!pModelInfo->IsValid() || m_eModelType != eClientModelType::OBJECT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same
Client/game_sa/CModelInfoSA.cpp
Outdated
m_pInterface->pRwObject = nullptr; | ||
((void(__thiscall*)(CAtomicModelInfoSAInterface * pThis, RpAtomic * pAtomic)) vfbl->SetAtomic)(m_pInterface, pClonedAtomic); | ||
|
||
ppModelInfo[m_dwModelID] = m_pInterface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same potential memory leak
Goal of this pull request is to make possible to replace atomic models ( model with one submodel ) with clump models ( model with multiple submodels ).
To do this, i created new function that converts model
engineConvertAtomicToClumpModel( modelId )
Only "atomic" models can be converted to clumps, otherwise function return false
Probably better solution would be to add function to change model type, but in practice you want "atomic" or "clump" objects, if you want new vehicles, peds models just request new id's.
In my opinion it should be separete function because attempt to put it into
engineReplaceModel
may lead to a lot of confusions.Also, i consider another function to get model type, so for example by default: 370 returns "weapon", 404 "vehicle", 3425 "clump", 1337 "atomic".
before, only last atomic is visible:
after, all (2) atomics are visible:
1337 model on the left, 370 jetpack on the right
This pull request is still in progress, assume there are some memory leaks, i consider if it is important to revert model back to atomic