rodecomp/Source/Contents/Actors/ActorPickNode.cpp
ragnarok-clanker d7c1911fa6 Maintenance: Move explicit-template linkage declarations out of the game source. 105 units' extern template lines (and the std tree a
Batch #17237 by ragnarok-clanker: no function's compiled code changes; checked with 105 compiled unit(s), including every includer of Source/Linkage/Source/Client/Mode/LoginMode.cpp.h, Source/Linkage/Source/Client/Session/SessionAchievements.cpp.h, Source/Linkage/Source/Client/Session/SessionPredicates.cpp.h, Source/Linkage/Source/Client/Session/SessionState.cpp.h, Source/Linkage/Source/Contents/Achievement/AchievementMgr.cpp.h, Source/Linkage/Source/Contents/Actors/ActorPickNode.cpp.h, Source/Linkage/Source/Contents/Actors/MercenaryAI.cpp.h, Source/Linkage/Source/Contents/Actors/Resources/RobeResources.cpp.h, Source/Linkage/Source/Contents/CashEmotion/CashEmotionMgr.cpp.h, Source/Linkage/Source/Contents/Effects/EffectResourceSwitcher.cpp.h, Source/Linkage/Source/Contents/Effects/Particles/AnimatedEmitterEffect.cpp.h, Source/Linkage/Source/Contents/Effects/Particles/Particle.cpp.h, Source/Linkage/Source/Contents/Effects/Skills/MonsterSkillEffects.cpp.h, Source/Linkage/Source/Contents/Emblems/EmblemCache.cpp.h, Source/Linkage/Source/Contents/Emblems/EmblemDataDownloadAsyncWork.cpp.h, Source/Linkage/Source/Contents/Emblems/EmblemDataMgr.cpp.h, Source/Linkage/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp.h, Source/Linkage/Source/Contents/Emblems/GuildEmblemLookup.cpp.h, Source/Linkage/Source/Contents/Hotkeys/EmotionHotkeys.cpp.h, Source/Linkage/Source/Contents/Items/ItemInfo.cpp.h, Source/Linkage/Source/Contents/Items/ItemNaming.cpp.h, Source/Linkage/Source/Contents/Map/PrivateAirplaneMgr.cpp.h, Source/Linkage/Source/Contents/Map/TownInfoMgr.cpp.h, Source/Linkage/Source/Contents/Messenger/MessengerMember.cpp.h, Source/Linkage/Source/Contents/Messenger/WhisperBlockMgr.cpp.h, Source/Linkage/Source/Contents/Models/ModelLighting.cpp.h, Source/Linkage/Source/Contents/Movies/BinkMovies.cpp.h, Source/Linkage/Source/Contents/Navigation/NavigationDestinations.cpp.h, Source/Linkage/Source/Contents/Navigation/NavigationRequest.cpp.h, Source/Linkage/Source/Contents/Navigation/NavigationRoute.cpp.h, Source/Linkage/Source/Contents/Party/AgencyRequests.cpp.h, Source/Linkage/Source/Contents/Party/LoadPartyInfoAsyncWork.cpp.h, Source/Linkage/Source/Contents/Party/LoadPartyListAsyncWork.cpp.h, Source/Linkage/Source/Contents/Party/RegisterPartyAsyncWork.cpp.h, Source/Linkage/Source/Contents/Repute/ReputeMgr.cpp.h, Source/Linkage/Source/Contents/Sound/SoundMgr.cpp.h, Source/Linkage/Source/Contents/Store/MCStoreInfoBackup.cpp.h, Source/Linkage/Source/Contents/Store/MCStoreInfoBackupAsyncWork.cpp.h, Source/Linkage/Source/Contents/Time/ClientTiming.cpp.h, Source/Linkage/Source/Contents/UserData/AccountLinkedUserDataLoadAsyncWork.cpp.h, Source/Linkage/Source/Contents/UserData/AccountLinkedUserDataMgr.cpp.h, Source/Linkage/Source/Contents/UserData/AccountLinkedUserDataSaveAsyncWork.cpp.h, Source/Linkage/Source/Contents/UserData/CharacterConfigSave.cpp.h, Source/Linkage/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp.h, Source/Linkage/Source/Contents/UserData/CharacterLinkedUserDataSaveAsyncWork.cpp.h, Source/Linkage/Source/File/DirectoryRemoval.cpp.h, Source/Linkage/Source/Network/NIPAddr.cpp.h, Source/Linkage/Source/Network/Packets/ActorNamePacket.cpp.h, Source/Linkage/Source/Render/Device/RenderBackends.cpp.h, Source/Linkage/Source/Render/Primitives/ScreenLine.cpp.h, Source/Linkage/Source/Render/Text/EmbedFont.cpp.h, Source/Linkage/Source/Resource/Models/RmaResource.cpp.h, Source/Linkage/Source/Resource/ResourceFailures.cpp.h, Source/Linkage/Source/Script/LuaScript.cpp.h, Source/Linkage/Source/Security/NProtectGameGuardMgr.cpp.h, Source/Linkage/Source/UI/Acceptance/UIExchangeAcceptWnd.cpp.h, Source/Linkage/Source/UI/Achievement/UIAchWnd.cpp.h, Source/Linkage/Source/UI/Buttons/UINaviLinkButton.cpp.h, Source/Linkage/Source/UI/CashShop/UICashShopWnd.cpp.h, Source/Linkage/Source/UI/Chat/UIChatRoomTitle.cpp.h, Source/Linkage/Source/UI/Dialogs/UIMessageBox.cpp.h, Source/Linkage/Source/UI/Dialogs/UINoteWnd.cpp.h, Source/Linkage/Source/UI/Edit/UIEditCtrl3.cpp.h, Source/Linkage/Source/UI/Enchant/UIEnchantUI.cpp.h, Source/Linkage/Source/UI/EntryQueue/UIEntryQueueWnd.cpp.h, Source/Linkage/Source/UI/Events/UICheckAttendanceWnd.cpp.h, Source/Linkage/Source/UI/GameSettings/GameSettingsUI.cpp.h, Source/Linkage/Source/UI/GameSettings/UIHotkeyGuideWnd.cpp.h, Source/Linkage/Source/UI/Gauges/UIBarGraph.cpp.h, Source/Linkage/Source/UI/Guild/UIGuildHelperWnd.cpp.h, Source/Linkage/Source/UI/Items/UIEquipmentPropertiesWnd.cpp.h, Source/Linkage/Source/UI/Items/UIItemReformWnd.cpp.h, Source/Linkage/Source/UI/Items/UIItemStoreComboBox.cpp.h, Source/Linkage/Source/UI/Items/UILapineBoxWnd.cpp.h, Source/Linkage/Source/UI/Items/UIMakeTargetProcessWnd.cpp.h, Source/Linkage/Source/UI/Items/UIMerchantItemLogWnd.cpp.h, Source/Linkage/Source/UI/Items/UISwapEquipmentWnd.cpp.h, Source/Linkage/Source/UI/Lists/UIChatHisBox.cpp.h, Source/Linkage/Source/UI/Lists/UIComboBoxDefWnd.cpp.h, Source/Linkage/Source/UI/Login/UIPasswordWnd.cpp.h, Source/Linkage/Source/UI/Macro/UIMacroDetectorWnd.cpp.h, Source/Linkage/Source/UI/Navigation/NavigationLink.cpp.h, Source/Linkage/Source/UI/Party/UIApplyForPartyWnd.cpp.h, Source/Linkage/Source/UI/Party/UIRegisterPartyWnd.cpp.h, Source/Linkage/Source/UI/Party/UISeekPartyMBWnd.cpp.h, Source/Linkage/Source/UI/Quest/UIRecommendedQuestInfo.cpp.h, Source/Linkage/Source/UI/Repute/UIReputeWnd.cpp.h, Source/Linkage/Source/UI/Rodex/UIRodexComposeWnd.cpp.h, Source/Linkage/Source/UI/RuneSystem/UIRuneSystemWnd.cpp.h, Source/Linkage/Source/UI/Shop/UIMerchantShopTitle.cpp.h, Source/Linkage/Source/UI/Shortcuts/UIShortCutWnd.cpp.h, Source/Linkage/Source/UI/Skill/UIGraffiStrboxWnd.cpp.h, Source/Linkage/Source/UI/SkillDelayInfo/UISkillDelayInfo.cpp.h, Source/Linkage/Source/UI/Status/UIBasicInfoWnd.cpp.h, Source/Linkage/Source/UI/Text/ColoredText.cpp.h, Source/Linkage/Source/UI/Text/ItemLinkDisplay.cpp.h, Source/Linkage/Source/UI/Text/TextMarkup.cpp.h, Source/Linkage/Source/UI/Text/UITagTextViewer.cpp.h, Source/Linkage/Source/UI/Text/UITextViewer.cpp.h, Source/Linkage/Source/UI/Window/UIFrameWnd.cpp.h, Source/Linkage/Source/UI/Window/UIWindow.cpp.h, Source/Linkage/Source/UI/Window/UIWindowFactory.cpp.h, Source/Linkage/Source/UI/Window/WindowRegistration.cpp.h, Source/Linkage/Source/UI/Window/WindowRetirement.cpp.h, Source/Linkage/Source/Utility/Threading/NThread.cpp.h.
2026-11-11 16:21:46 +00:00

222 lines
5.6 KiB
C++

#include "Contents/Actors/ActorPickNode.h"
#include "Contents/Camera/Camera.h"
#include "Contents/Movement/TerrainPathSearch.h"
#include "Client/Mode/CGameMode.h"
#include "Client/Mode/ModeMgr.h"
#include "Contents/Actors/Pc.h"
#include "Contents/Configuration/ServiceOptions.h"
#include "Contents/World/SkyBox.h"
#include "Contents/World/World.h"
#include "Render/Projection/RendererViewport.h"
#include "Render/Renderer.h"
#include "Render/Drawing/SpriteGeometry.h"
#include "Resource/World/TerrainResource.h"
#include <map>
#include <string>
// OFFSET: 0x00AD9530
// FUNCTION: fn_17878
std::uint32_t MovementRouteInterpolation::Duration() const {
return this->points[this->points.size() - 1].tick - this->points[0].tick;
}
// OFFSET: 0x00AD95F0
// FUNCTION: fn_17880
bool MovementRouteInterpolation::Empty() const {
return this->points.empty();
}
// OFFSET: 0x00AD9600
// FUNCTION: fn_17881
bool CPathFinder::Walkable(int column, int row) const {
return this->attr->Walkable(column, row);
}
// OFFSET: 0x00ADA690
// FUNCTION: fn_17906
CActorPickNode::~CActorPickNode() {
this->Clear();
}
// OFFSET: 0x00AD9980
// FUNCTION: fn_17889
bool CPathFinder::LoadAttr(std::string name) {
const auto found = this->attrCache.find(name);
if (found != this->attrCache.end()) {
this->attr = found->second;
return true;
}
C3dAttr* attr = new C3dAttr;
if (attr == nullptr) {
return false;
}
this->attrCache[name] = attr;
name += ".gat";
attr->Load(name.c_str());
this->attr = attr;
return true;
}
// OFFSET: 0x00ADA750
// FUNCTION: fn_17908
void CActorPickNode::AddPickInfo(ActorPickInfo* info) {
CActorPickNode* node = this;
while (node->children[0] != nullptr) {
const int x = static_cast<int>(info->left);
const int y = static_cast<int>(info->top);
const int centerX = node->bounds.right / 2;
const int centerY = node->bounds.bottom / 2;
if (x <= centerX) {
node = node->children[y <= centerY ? 0 : 3];
} else {
node = node->children[(y > centerY) + 1];
}
}
node->pickInfos.push_back(info);
}
// OFFSET: 0x00ADA850
// FUNCTION: fn_17909
void CActorPickNode::Clear() {
for (auto info = this->pickInfos.begin(); info != this->pickInfos.end(); ++info) {
if (*info) {
delete *info;
}
}
this->pickInfos.erase(this->pickInfos.begin(), this->pickInfos.end());
for (int index = 0; index < 4; ++index) {
if (this->children[index]) {
delete this->children[index];
this->children[index] = nullptr;
}
}
}
// OFFSET: 0x00ADA8F0
// FUNCTION: fn_17910
ActorPickInfo* CActorPickNode::Pick(float x, float y) {
if (this->children[0] == nullptr) {
ActorPickInfo* result = nullptr;
float bestDepth = 0.0f;
for (ActorPickInfo* info : this->pickInfos) {
if (x > info->left && x < info->right && y > info->top && y < info->bottom && info->depthOffset + info->depth > bestDepth) {
result = info;
bestDepth = info->depthOffset + info->depth;
}
}
return result;
}
int quadrant;
if (static_cast<int>(x) <= this->bounds.right / 2) {
quadrant = static_cast<int>(y) <= this->bounds.bottom / 2 ? 0 : 3;
} else {
quadrant = (static_cast<int>(y) > this->bounds.bottom / 2) + 1;
}
ActorPickInfo* result = this->children[quadrant]->Pick(x, y);
if (result) {
return result;
}
for (int index = 0; index < 4; ++index) {
if (quadrant != index) {
result = this->children[index]->Pick(x, y);
if (result) {
return result;
}
}
}
return nullptr;
}
// OFFSET: 0x00ADAA60
// FUNCTION: fn_17911
void CActorPickNode::MakeQuardTree(int depth, ActorPickBounds bounds) {
this->Clear();
this->bounds = bounds;
if (depth != 0) {
for (int index = 0; index < 4; ++index) {
CActorPickNode* child = new CActorPickNode;
this->children[index] = child;
ActorPickBounds childBounds = this->bounds;
switch (index) {
case 0:
childBounds.right /= 2;
childBounds.bottom /= 2;
break;
case 1:
childBounds.left = childBounds.right / 2 + 1;
childBounds.bottom /= 2;
break;
case 2:
childBounds.left = childBounds.right / 2 + 1;
childBounds.top = childBounds.bottom / 2 + 1;
break;
case 3:
childBounds.right /= 2;
childBounds.top = childBounds.bottom / 2 + 1;
break;
}
child->MakeQuardTree(depth - 1, childBounds);
}
}
}
// GLOBAL: gl_24536
float g_projectionScale = 0.16f;
// GLOBAL: gl_24775
int g_worldViewDrawn;
// OFFSET: 0x00ADAC70
// FUNCTION: fn_17912
CView::CView() {
this->camera.target[0] = 0.0f;
this->camera.target[1] = 0.0f;
this->camera.target[2] = 0.0f;
this->camera.desiredTarget[0] = 0.0f;
this->camera.desiredTarget[1] = 0.0f;
this->camera.desiredTarget[2] = 0.0f;
this->backupCurrentTarget[0] = 0.0f;
this->backupCurrentTarget[1] = 0.0f;
this->backupCurrentTarget[2] = 0.0f;
this->backupDesiredTarget[0] = 0.0f;
this->backupDesiredTarget[1] = 0.0f;
this->backupDesiredTarget[2] = 0.0f;
this->frame.eye[0] = 0.0f;
this->frame.eye[1] = 0.0f;
this->frame.eye[2] = 0.0f;
this->frame.up[0] = 0.0f;
this->frame.up[1] = 0.0f;
this->frame.up[2] = 0.0f;
this->camera.yaw = 0.0f;
this->shake.enabled = 0;
this->skyBox = nullptr;
this->shake.start = 0;
*reinterpret_cast<unsigned char*>(&this->shake.resetFlags) = 0;
}
CView::~CView() {
if (this->skyBox) {
delete this->skyBox;
}
}
// OFFSET: 0x00ADC150
// FUNCTION: fn_17928
void CView::Reset() {
this->camera.Reset();
this->frame.up[0] = 0;
this->frame.up[1] = 1;
this->frame.up[2] = 0;
}
// OFFSET: 0x00ADC1D0
// FUNCTION: fn_17929
void CView::OnExitFrame() {
}