openmultiplayer / openmultiplayer/open.mp
getCameraTargetObject -> invalid cast?
Nobody has claimed this yet.
- 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);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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