Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added dynamic ped ID allocating(based on lopezloo pull request) #151

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

Merged
qaisjp merged 15 commits into multitheftauto:master from Neproify:dynamicidallocation
Aug 23, 2018

Conversation

@Neproify
Copy link
Contributor

@Neproify Neproify commented Jun 28, 2017
edited by qaisjp
Loading

Authors: @lopezloo, @Neproify, @ArranTuna

Dynamic ped ID allocation based on @lopezloo pull request - #65
With api proposed by @sbx320

Functions:

engineRequestModel(string type)

  • type: {"ped"}(Other things can be added in future?)
  • Returns: bool or int
  • bool: false if model wasn't allocated
  • int: ID of allocated model

engineFreeModel(int modelID)

  • Returns: bool
  • true if model was deallocated
  • false if it wasn't

How it looks like?
mta-screen_2017年06月28日_20-43-37
mta-screen_2017年06月28日_20-43-42

Test resource:
testresource.tar.gz

Citizen01, Dezash, and Flatlinero reacted with thumbs up emoji PlatinMTA reacted with heart emoji
Copy link
Member

@sbx320 sbx320 left a comment

Choose a reason for hiding this comment

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

good work 👍

Some minor things:

  • (void) is pointless, just remove the void there
  • nullptr should be preferred to NULL

if ( !argStream.HasErrors () )
{
eClientModelType eModelType;
if ( stricmp( strModelType, "ped" ) == 0 )
Copy link
Member

Choose a reason for hiding this comment

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

strModelType == "ped" would be better here. No real need to make it case-insensitive or use C functions.


CClientModel * pModel = new CClientModel( m_pManager, iModelID, eModelType );
pModel->Allocate ();
m_pManager->GetModelManager ()->Add ( pModel );
Copy link
Member

Choose a reason for hiding this comment

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

You are already doing m_pModelManager->Add ( this ); in the constructor of CClientModel.

Ideally we'd eliminate the use of new entirely and just use unique_ptrs for the managers in general to avoid memleaks entirely.

m_dwModelID <= 288) ||
(m_dwModelID >= 290 &&
m_dwModelID <= 312));
return ( GetInterface() && GetInterface()->pColModel && GetInterface()->pColModel == ( CColModelSAInterface * ) VAR_CTempColModels_ModelPed1 );
Copy link
Member

Choose a reason for hiding this comment

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

Did you check whether all peds always have a colmodel VAR_CTempColModels_ModelPed1? The 1 seems to imply there might be more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about that. That was based on lopez research.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like there is only one collision? Seems weird...

http://gtaforums.com/topic/809134-restoring-the-pedscol/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to end the topic - GTA is using hardcoded ped collision, so all peds are using the same collision. @sbx320

@qaisjp qaisjp added the enhancement New feature or request label Jul 2, 2017
@Necktrox Necktrox dismissed sbx320’s stale review February 18, 2018 13:19

"GTA is using hardcoded ped collision, so all peds are using the same collision"

Copy link

During testing I noticed that you can leak model IDs when you execute the /allocate commands multiple times. Restarting the resource doesn't deallocate the allocated IDs, which should be done by MTA, not the resource.

@Necktrox Necktrox added feedback Further information is requested pr:needs-testing labels Feb 18, 2018
Copy link
Contributor Author

@Necktrox Fixed.

BTW. It is almost year later... I'm lazy guy. :P

PlatinMTA reacted with heart emoji

eClientModelType GetModelType ( void ) { return m_eModelType; };
bool Allocate ( void );
bool Deallocate ( void );
void SetResourceThatAllocatedIt(CResource* pResource) { m_pOwnedByResource = pResource; }
Copy link
Contributor

Choose a reason for hiding this comment

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

a better name might be SetParentResource with a comment "This is the resource that allocated this model"


pModelInfo->DeallocateModel ();

this->SetResourceThatAllocatedIt(NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

we use nullptr wherever possible now

Copy link
Contributor Author

Neproify commented Aug 3, 2018

@qaisjp Is everything fine now?

@qaisjp qaisjp merged commit 34d4eed into multitheftauto:master Aug 23, 2018
qaisjp added a commit that referenced this pull request Aug 29, 2018
Needs further testing. Lets make custom animations the big 1.5.6
feature.
This reverts commit 34d4eed.
Copy link

dretax commented Sep 1, 2018

Heh. Nice one.

qaisjp added a commit that referenced this pull request Sep 8, 2019
This reverts commit 242684e.
Original PR can be found at #151.
Co-authored-by: lopezloo <lopez@multitheftauto.pl>
Co-authored-by: Neproify <Neproify@users.noreply.github.com>
Co-authored-by: Arran <arrantuna@hotmail.co.uk>
Co-authored-by: Qais Patankar <qaisjp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sbx320 sbx320 sbx320 left review comments

+1 more reviewer

@qaisjp qaisjp qaisjp left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

feedback Further information is requested refactor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /