Skip to content

[Fix] Fix Object Name Init, User Refs, and Client Sync on Close#4861

Merged
Akkadius merged 3 commits intoEQEmu:masterfrom
zimp-wow:objfixes_upstream
May 15, 2025
Merged

[Fix] Fix Object Name Init, User Refs, and Client Sync on Close#4861
Akkadius merged 3 commits intoEQEmu:masterfrom
zimp-wow:objfixes_upstream

Conversation

@zimp-wow
Copy link
Copy Markdown
Contributor

Description

Couple minor fixes to object behaviors I found when working with the object API.

Issue 1: Fix uninitialized char* in object.cpp

Objects created via the API would show trash data in their name. This change memsets the char array to zero in the constructors.

Issue 2: Clear object user and user tradeskill object on reset.

A call to Object:Delete(true) would uninitialize a lot of fields in the object but leave lingering references to the user who was using it as well as a reference back to that object from the user. This would cause a zone crash if the user continued to interact with the object. I've added a 'Close' call to the top of ResetState to clear these references.

Issue 3: Send clear object packet on Object::Close()

Calling Object:Close() would move any items in the object's inventory back into the user's inventory but not actually update the client that the object's inventory was now empty, creating the appearance that there were two items.

This change sends a ClearObject packet to the active user when close is called.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Testing

Akk-stack with rof2 client.

Test script

function player_say(e)
        if e.message:findi("object") then
                local id = eq.create_ground_object_from_model("IT70_ACTORDEF", e.self:GetX() + 10, e.self:GetY() + 10, e.self:GetZ(), e.self:GetHeading(), 19);
                eq.debug("Object id: "..id);
        end

        if e.message:findi("objreset") then
                local id_str = string.gsub(e.message, "objreset ", "");
                local id = tonumber(id_str) or -1;
                eq.debug("Resetting obj "..id);
                if id > 0 then
                        local obj = eq.get_entity_list():GetObjectByID(id);
                        obj:Delete(true);
                end
        end

        if e.message:findi("objclose") then
                local id_str = string.gsub(e.message, "objclose ", "");
                local id = tonumber(id_str) or -1;
                eq.debug("Close obj "..id);
                if id > 0 then
                        local obj = eq.get_entity_list():GetObjectByID(id);
                        obj:Close();
                end
        end
end

Issue 1:

Before
image

After
image

Issue 2:

Before
image

After
image

Issue 3:

Original stack trace
image

Crash did not reproduce after fix applied.

Checklist

  • I have tested my changes
  • I have performed a self-review of my code. Ensuring variables, functions and methods are named in a human-readable way, comments are added only where naming of variables, functions and methods can't give enough context.
  • I own the changes of my code and take responsibility for the potential issues that occur

@Akkadius Akkadius changed the title Object API bugfixes. [Fix] Fix Object Name Init, User Refs, and Client Sync on Close May 15, 2025
Copy link
Copy Markdown
Contributor

@Akkadius Akkadius left a comment

Choose a reason for hiding this comment

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

Thank you sir

@Akkadius Akkadius merged commit 3d607d3 into EQEmu:master May 15, 2025
1 check passed
@Akkadius Akkadius mentioned this pull request May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants