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

Allow allocating models server-side #2533

Open
wants to merge 60 commits into
base: master
Choose a base branch
from

Conversation

TheNormalnij
Copy link
Contributor

@TheNormalnij TheNormalnij commented Jan 30, 2022

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)

@TheNormalnij TheNormalnij added the enhancement New feature or request label Jan 30, 2022
@TheNormalnij TheNormalnij added this to the Backlog milestone Jan 30, 2022
@TheNormalnij TheNormalnij self-assigned this Jan 30, 2022
@github-actions github-actions bot added the stale Inactive for over 90 days, to be closed label May 1, 2022
@github-actions
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.

@TheNormalnij TheNormalnij force-pushed the TheNormalnij/model_allocation_server branch from efff3b5 to 5698387 Compare May 10, 2022 21:41
@TheNormalnij
Copy link
Contributor 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
@TheNormalnij
Copy link
Contributor Author

Fixes #2571

@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
@github-actions
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

@@ -2022,7 +2022,7 @@ void CModelInfoSA::RestoreAllObjectsPropertiesGroups()

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

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
Contributor Author

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

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?

* LICENSE: See LICENSE in the top level directory
* FILE: mods/deathmatch/logic/CClientModelManager.cpp
* PURPOSE: Model manager class
*
*****************************************************************************/

#include "StdInc.h"

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

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?

@@ -57,6 +56,18 @@ bool CClientModelManager::Remove(const std::shared_ptr<CClientModel>& pModel)
return false;
}

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

Choose a reason for hiding this comment

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

if (!m_Models[modelId])


return Remove(modelId);
}

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

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?

@@ -124,6 +135,47 @@ void CClientModelManager::DeallocateModelsAllocatedByResource(CResource* pResour
for (unsigned int i = 0; i < uiMaxModelID; i++)
Copy link
Contributor

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

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

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

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants