Skip to content

getCameraTargetObject -> invalid cast? #1070

Description

@ikkentim

I've been trying to get the camera target of a player and was looking for IPlayer->getCameraTargetPlayerObject() but that doesn't appear to exist. I did however find that getCameraTargetObject does some player object related checking, but it looks like if it finds the player object the player camera is targeting, it tries to cast the IPlayerObject* to an IObject*

As far as I'm aware this is not a valid cast.

Shouldn't a separate getCameraTargetPlayerObject function be added?

// SDK declarations
struct IObject : public IBaseObject
{
    // (...)
};

struct IPlayerObject : public IBaseObject
{
    // (...)
};
IPlayerObject* player_object = data->get(cameraTargetObject_);
if (player_object)
{
	return reinterpret_cast<IObject*>(player_object);
}

https://github.com/openmultiplayer/open.mp/blob/5c4e67b4b3223b792f9cb44df54a809af047883d/Server/Source/player.cpp#L134C1-L138C5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions