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

Allow allocating models server-side #2533

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

Open
TheNormalnij wants to merge 60 commits into multitheftauto:master
base: master
Choose a base branch
Loading
from TheNormalnij:TheNormalnij/model_allocation_server

Conversation

@TheNormalnij
Copy link
Member

@TheNormalnij TheNormalnij commented Jan 30, 2022
edited
Loading

Fixes #2427

-- Get all allocated models
table getAllocatedModels([string modelType])
-- Get free id's list
table getFreeModels()
-- Allocate model
bool allocateModelFromParent(number parentId)
-- Unload model, works for custom models
bool unloadModel(nuber modelId)

lopezloo, Proxy-99, gta191977649, curukcesetgurmesi, Weaita, Vadya963, Fernando-A-Rocha, turret001, jayceon123, theSarrum, and 7 more reacted with thumbs up emoji Fernando-A-Rocha, Proxy-99, and Wannacry-ops reacted with heart emoji Proxy-99, Fernando-A-Rocha, and Wannacry-ops reacted with rocket emoji
@TheNormalnij TheNormalnij added the enhancement New feature or request label Jan 30, 2022
@TheNormalnij TheNormalnij added this to the Backlog milestone Jan 30, 2022
@github-actions github-actions bot added the stale Inactive for over 90 days, to be closed label May 1, 2022
Copy link
Contributor

github-actions bot commented May 1, 2022

This draft pull request is stale because it has been open for at least 90 days with no activity. Please continue on your draft pull request or it will be closed in 30 days automatically.

brenodanyel, ZbyK77, Fernando-A-Rocha, and gta191977649 reacted with confused emoji

@TheNormalnij TheNormalnij force-pushed the TheNormalnij/model_allocation_server branch from efff3b5 to 5698387 Compare May 10, 2022 21:41
Copy link
Member Author

WIP

@TheNormalnij TheNormalnij removed the stale Inactive for over 90 days, to be closed label May 10, 2022
@TheNormalnij TheNormalnij marked this pull request as ready for review June 12, 2022 20:30
Copy link
Member Author

Fixes #2571

Proxy-99 reacted with thumbs up emoji Fernando-A-Rocha, MrSol0, and C0DELEVEL reacted with heart emoji

@patrikjuvonen patrikjuvonen marked this pull request as draft April 8, 2023 13:36
@patrikjuvonen patrikjuvonen added the feedback Further information is requested label Apr 8, 2023
@github-actions github-actions bot added the stale Inactive for over 90 days, to be closed label Jul 8, 2023
Copy link
Contributor

github-actions bot commented Jul 8, 2023

This draft pull request is stale because it has been open for at least 90 days with no activity. Please continue on your draft pull request or it will be closed in 30 days automatically.

@TheNormalnij TheNormalnij removed the stale Inactive for over 90 days, to be closed label Jul 15, 2023
@TheNormalnij TheNormalnij removed the feedback Further information is requested label Mar 25, 2024
Copy link
Contributor

@TracerDS TracerDS left a comment

Choose a reason for hiding this comment

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

Thats a huge PR, good job so far

eModelInfoType CModelInfoSA::GetModelType()
{
return ((eModelInfoType(*)())m_pInterface->VFTBL->GetModelType)();
return (eModelInfoType)((uint8_t(*)())m_pInterface->VFTBL->GetModelType)();
Copy link
Contributor

@TracerDS TracerDS Jun 6, 2024

Choose a reason for hiding this comment

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

Change std::uint8_t to uint8_t. Let's stick to C++ headers and namespaces

Copy link
Member Author

@TheNormalnij TheNormalnij Jun 7, 2024

Choose a reason for hiding this comment

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

I would prefer uint8_t in all cases. cstdint types are standard these days.
I think std:: for numbers adds too much noise.

Copy link
Contributor

@TracerDS TracerDS Jun 7, 2024
edited
Loading

Choose a reason for hiding this comment

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

I would prefer uint8_t in all cases. cstdint types are standard these days. I think std:: for numbers adds too much noise.

cstdint doesnt guarantee standard types in the global namespace but does guarantee having them in the std namespace
stdint.h doesnt guarantee standard types in the std namespace but does guarantee having them in the global namespace

If we go with cstdint (as we should) then std:: is required by a C++ standard (unless you do using on them)

In the end, its the matter of preference, right?


CClientModelManager::CClientModelManager() : m_Models(std::make_unique<std::shared_ptr<CClientModel>[]>(g_pGame->GetBaseIDforCOL()))
{
const unsigned int uiMaxModelID = g_pGame->GetBaseIDforCOL();
Copy link
Contributor

@TracerDS TracerDS Jun 6, 2024

Choose a reason for hiding this comment

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

auto or std::uint32_t?


bool CClientModelManager::RemoveClientModel(const int modelId)
{
if (m_Models[modelId] == nullptr)
Copy link
Contributor

@TracerDS TracerDS Jun 6, 2024

Choose a reason for hiding this comment

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

if (!m_Models[modelId])


int CClientModelManager::GetFirstFreeModelID(void)
{
const unsigned int uiMaxModelID = g_pGame->GetBaseIDforCOL();
Copy link
Contributor

@TracerDS TracerDS Jun 6, 2024

Choose a reason for hiding this comment

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

auto or std::uint32_t?

void CClientModelManager::DeallocateModelsAllocatedByResource(CResource* pResource)
{
const unsigned int uiMaxModelID = g_pGame->GetBaseIDforCOL();
for (unsigned int i = 0; i < uiMaxModelID; i++)
Copy link
Contributor

@TracerDS TracerDS Jun 6, 2024

Choose a reason for hiding this comment

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

auto maybe?

class CModelVehicle : public CModelBase
{
public:
CModelVehicle(uint32_t uiModelID, const SModelVehicleDefs& SModelVehicleDefs);
Copy link
Contributor

@TracerDS TracerDS Jun 6, 2024

Choose a reason for hiding this comment

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

std::uint32_t instead of uint32_t

Comment on lines +48 to +65
CHandlingEntry* GetVehicleHandling() { return m_pVehicleHandling; };
const CHandlingEntry* GetOriginalHandling() { return &m_modelDef.handling; };
void SetVehicleDefaultHandling(CHandlingEntry& pEntry) { m_modelDef.handling = pEntry; }
void SetVehicleHandling(CHandlingEntry* pEntry) { m_pVehicleHandling = pEntry; };
void SetVehicleHandlingChanged(bool bState) { m_bVehicleHandlingChanged = bState; };
bool HasVehicleHandlingChanged() { return m_bVehicleHandlingChanged; };

void SetVehicleDafaultColors(CVehicleColors colors) { m_modelDef.vehicleColors = colors; };

bool HasDamageModel();
bool HasDoors() { return m_modelDef.bHasDoors; };
bool IsTrailer() { return m_modelDef.eVehicleModelType == eVehicleType::TRAILER; };
const char* GetVehicleName() { return m_modelDef.strVehicleName; };
eVehicleType GetVehicleType() { return m_modelDef.eVehicleModelType; }
uint8_t GetVariantsCount() { return m_modelDef.uiVariantsCount; };
uint8_t GetAttributes() { return m_modelDef.cAttributes; };
uint8_t GetPassengesCount() { return m_modelDef.uiMaxPassengers; };
eVehicleVariationType GetVariationType() { return m_modelDef.eVariationType; };
Copy link
Contributor

@TracerDS TracerDS Jun 6, 2024

Choose a reason for hiding this comment

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

remove trailing ; from end of the lines, add const to getters, add noexcept if you can

CVehicleColor GetRandomColor() { return m_modelDef.vehicleColors.GetRandomColor(); }
void AddColor(const CVehicleColor& color) { return m_modelDef.vehicleColors.AddColor(color); };

void GetRandomVariation(unsigned char& ucVariant, unsigned char& ucVariant2);
Copy link
Contributor

@TracerDS TracerDS Jun 6, 2024

Choose a reason for hiding this comment

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

std::uint8_t instead of unsigned char

uint32_t uiModelsCount = listSimpleAllocatedModels.size();
BitStream.Write(uiModelsCount);

for (auto model : listSimpleAllocatedModels)
Copy link
Contributor

@TracerDS TracerDS Jun 6, 2024

Choose a reason for hiding this comment

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

const auto& model


if (BitStream.Can(eBitStreamVersion::SimpleModelAllocation))
{
uint32_t uiModelsCount = listSimpleAllocatedModels.size();
Copy link
Contributor

@TracerDS TracerDS Jun 6, 2024

Choose a reason for hiding this comment

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

std::uint32_t instead of uint32_t

Copy link
Contributor

TracerDS commented Aug 5, 2024

Any updates?

Copy link
Contributor

Is this a draft?

Copy link

YSAFE commented Oct 8, 2024

Is it still in progress?

Copy link
Contributor

Directly related to #2251

Copy link
Member

Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

2 more reviewers

@TracerDS TracerDS TracerDS requested changes

@patrikjuvonen patrikjuvonen patrikjuvonen requested changes

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

enhancement New feature or request

Projects

None yet

Milestone

1.7.1

Development

Successfully merging this pull request may close these issues.

Supporting setVehicleHandling on the client side, for vehicles created on the server side. (Custom vehicles, engineRequestModel)

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