openmultiplayer / openmultiplayer/open.mp

getCameraTargetObject -> invalid cast?

Open
#1,070 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
641
Forks
208
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Server/Source/player.cpp at lines 134-138 and compare getCameraTargetObject with the SDK declarations for IObject and IPlayerObject. Trace the data->get(cameraTargetObject_) result and determine whether the cast is valid or whether a separate player-object camera-target entry point is needed. Done when the camera-target API returns the correct object type without the reported invalid cast.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.