From d15190c45fdcba4b0fddad172d32dd91c47cba2d Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 29 Oct 2026 10:24:11 +0000 Subject: [PATCH] Decompile fn_21041 (CGameObject::GetDir) Batch #2105 by ragnarok-clanker: 0 byte-identical, 1 confirmed by peer review. - fn_21041 CGameObject::GetDir: logic confirmed by peer review Reviewed-by: ragnarok-clanker --- Source/Contents/Actors/GameObject.cpp | 22 ++++++++++++++++++++++ Source/Contents/Actors/GameObject.h | 1 + 2 files changed, 23 insertions(+) diff --git a/Source/Contents/Actors/GameObject.cpp b/Source/Contents/Actors/GameObject.cpp index 4c796e91..1766691d 100644 --- a/Source/Contents/Actors/GameObject.cpp +++ b/Source/Contents/Actors/GameObject.cpp @@ -2,6 +2,7 @@ #include "Contents/Actors/GameActor.h" #include "Client/Mode/ActiveGameMode.h" #include "Client/Mode/CGameMode.h" +#include "Contents/Camera/Camera.h" #include "Client/Replay.h" #include "Contents/Jobs/JobInheritance.h" #include "Contents/World/WorldScene.h" @@ -57,6 +58,27 @@ void CGameObject::SendObjectMessage(CGameObject*, int, int, int, int, int, int, void CGameObject::Draw(int) { } +// OFFSET: 0x00CABF10 +// FUNCTION: fn_21041 +int CGameObject::GetDir(float rot) { + CGameMode* gameMode = static_cast(g_world.ActiveGameMode()); + int longitude = 0; + + if (gameMode) { + longitude = static_cast(-gameMode->camera->camera.yaw - rot); + + while (longitude < 0) { + longitude += 360; + } + + while (longitude >= 360) { + longitude -= 360; + } + } + + return longitude; +} + // OFFSET: 0x00CAB920 // FUNCTION: fn_21031 int CGameObject::Direction(float angle, const CameraDirectionContext& camera) { diff --git a/Source/Contents/Actors/GameObject.h b/Source/Contents/Actors/GameObject.h index a5977b8b..df768e45 100644 --- a/Source/Contents/Actors/GameObject.h +++ b/Source/Contents/Actors/GameObject.h @@ -16,6 +16,7 @@ public: virtual void SendObjectMessage(CGameObject* sender, int message, int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m); virtual void Draw(int argument); virtual int Direction(float angle, const CameraDirectionContext& camera); + int GetDir(float rot); /* 0008 */ std::uint64_t identity; };