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(gamestate/rdr3): GET_ENTITY_MODEL for objects & animals #2044

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Korioz
Copy link
Contributor

@Korioz Korioz commented Jun 10, 2023

This fix will add support of GET_ENTITY_MODEL on objects and animals on rdr3.

Sample Lua code for testing:

CLIENT:

local function requestModel(model)
    RequestModel(model)
    while not HasModelLoaded(model) do
        Wait(0)
    end
end

RegisterCommand('test_sv_get_model', function()
    local pCoords = GetEntityCoords(PlayerPedId())
    local tests = {}

    do
        local model = `p_binoculars01x` & 0xFFFFFFFF
        requestModel(model)
        local object = CreateObjectNoOffset(model, pCoords.x, pCoords.y, pCoords.z, true, false, true, true)
        SetModelAsNoLongerNeeded(model)
        tests.object = { netId = NetworkGetNetworkIdFromEntity(object), model = model }
    end

    do
        local model = `a_c_alligator_01` & 0xFFFFFFFF
        requestModel(model)
        local animal = CreatePed(model, pCoords.x, pCoords.y, pCoords.z, 0.0, true, true)
        SetRandomOutfitVariation(animal, 1)
        tests.animal = { netId = NetworkGetNetworkIdFromEntity(animal), model = model }
    end

    Wait(1000) -- just in case for server awareness of entities
    TriggerServerEvent('testEntitiesModel', tests)
end, false)

SERVER:

local function testEntityModel(test, testId)
    local entity = NetworkGetEntityFromNetworkId(test.netId)
    local model = GetEntityModel(entity) & 0xFFFFFFFF
    local testMsg = 'TEST %s: %s (net id: %u, id: %u, client model: 0x%08X, server model: 0x%08X'
    print(testMsg:format(testId, test.model == model and 'PASSED' or 'FAILED', test.netId, entity, test.model, model))
end

RegisterNetEvent('testEntitiesModel', function(tests)
    testEntityModel(tests.animal, 'ANIMAL')
    testEntityModel(tests.object, 'OBJECT')
end)

@Korioz Korioz closed this Oct 16, 2023
@Korioz Korioz reopened this Oct 16, 2023
@Disquse Disquse self-assigned this Oct 17, 2023
@Korioz Korioz closed this Jul 2, 2024
@Korioz Korioz reopened this Oct 1, 2024
@github-actions github-actions bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Oct 1, 2024
@FabianTerhorst FabianTerhorst self-requested a review October 2, 2024 11:31
@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action invalid Requires changes before it's considered valid and can be (re)triaged and removed invalid Requires changes before it's considered valid and can be (re)triaged triage Needs a preliminary assessment to determine the urgency and required action labels Oct 3, 2024
bool m_unk6; // mostly false
bool m_unk7; // mostly false
uint32_t m_model;
#if 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't add dead code to the project. I appreciate If you can finish research and add all fields needed to serialization.

if (m_createdBy != 3 && (m_createdBy > 0x12 || (409602 & (1 << m_createdBy)) == 0))
{
s.Serialize(32, m_model);
#if 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

}
else
{
#if 0
Copy link
Contributor

Choose a reason for hiding this comment

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

And here

s.SerializeSigned(31, 27648.0f, dummy.dummyPosX);
s.SerializeSigned(31, 27648.0f, dummy.dummyPosY);
s.Serialize(31, 4416.0f, dummy.dummyPosZ);
dummy.dummyPosZ -= 1700.0f;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please leave comment why you are manipulating Z coord

#endif
}

#if 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Dead code again

{
ePopType m_popType;
uint32_t m_model;
#if 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Dead code


s.Serialize(32, m_model);

/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you describe idea of model replacement and this comment please?

}
*/

#if 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Dead code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Requires changes before it's considered valid and can be (re)triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants