rodecomp/Source/Contents/NavigationRequest.cpp
ragnarok-clanker dc3d5ce1a5 Maintenance: Resubmission of 14942 (gate: three existing in-class helpers whose lines changed lacked an annotation; marked // INLINED
Batch #14943 by ragnarok-clanker: no function's compiled code changes; checked with 741 compiled unit(s), including every includer of Source/ActorPickNode.h, Source/Client/Browser/BrowserClientSite.h, Source/Client/Browser/BrowserPopupDispatch.h, Source/Client/Mode/CGameMode.h, Source/Client/Mode/CLoginMode.h, Source/Client/Mode/CMode.h, Source/Client/Mode/ModeDragState.h, Source/Client/Replay.h, Source/Client/Session.h, Source/Client/Stove/StoveMgr.h, Source/Contents/AchievementMgr.h, Source/Contents/ActorNameCard.h, Source/Contents/Actors/CharacterRender.h, Source/Contents/Actors/EffectActors.h, Source/Contents/Actors/GameActor.h, Source/Contents/Actors/GrannyGameActor.h, Source/Contents/Actors/GroundScope.h, Source/Contents/Actors/Item.h, Source/Contents/Actors/Npc.h, Source/Contents/Actors/Pc.h, Source/Contents/Actors/RenderObjectState.h, Source/Contents/Actors/Skill.h, Source/Contents/AdventureGuideMgr.h, Source/Contents/Camera/Camera.h, Source/Contents/Camera/CameraState.h, Source/Contents/CashEmotionMgr.h, Source/Contents/Configuration/GameSettingsMgr.h, Source/Contents/EffectResourceSwitcher.h, Source/Contents/Effects/AMachineEffect.h, Source/Contents/Effects/AcidifiedThrow.h, Source/Contents/Effects/AxeBoomerang.h, Source/Contents/Effects/BlastForge.h, Source/Contents/Effects/CaneOfEvilEyeEffect.h, Source/Contents/Effects/CharacterParticleBundle.h, Source/Contents/Effects/CloudKillEffect.h, Source/Contents/Effects/Effect.h, Source/Contents/Effects/EffectActor.h, Source/Contents/Effects/EffectEmitter.h, Source/Contents/Effects/EffectMaker.h, Source/Contents/Effects/EffectPrimitiveState.h, Source/Contents/Effects/FuumaShouakuEffect.h, Source/Contents/Effects/GravityControlEffect.h, Source/Contents/Effects/HealSpEffect.h, Source/Contents/Effects/Level99Effect.h, Source/Contents/Effects/MapChainEffect.h, Source/Contents/Effects/MonsterSkillEffects.h, Source/Contents/Effects/MsgEffect.h, Source/Contents/Effects/NyanggrassEffect.h, Source/Contents/Effects/Particle.h, Source/Contents/Effects/PowderingEffect.h, Source/Contents/Effects/RagEffectState.h, Source/Contents/Effects/RectUpEffect.h, Source/Contents/Effects/ShadowExceedEffect.h, Source/Contents/Effects/SkillEffects.h, Source/Contents/Effects/SpriteParticle.h, Source/Contents/Effects/StormCannonEffect.h, Source/Contents/Effects/ThrowEffects.h, Source/Contents/EntryQueueMgr.h, Source/Contents/EquipmentResourceMgr.h, Source/Contents/FlyingShipRouteInfo.h, Source/Contents/Ground/GroundGeometry.h, Source/Contents/GuildInfo.h, Source/Contents/Items/ItemDescription.h, Source/Contents/Items/ItemInfo.h, Source/Contents/MapSkyMgr.h, Source/Contents/Messenger/MessengerWindows.h, Source/Contents/Models/ModelNode.h, Source/Contents/NavigationManager.h, Source/Contents/Party/AdventurerAgencyMgr.h, Source/Contents/RDamageVar.h, Source/Contents/RenewQuestMgr.h, Source/Contents/ReputeMgr.h, Source/Contents/RodexMailStore.h, Source/Contents/RouletteMgr.h, Source/Contents/Schedule/Schedule.h, Source/Contents/SignBoard/SignBoard.h, Source/Contents/Skills/ClientSkills.h, Source/Contents/Skills/PlayerSkillBundle.h, Source/Contents/Skills/SkillInfo.h, Source/Contents/SpriteLayerDrawing.h, Source/Contents/TipBoxTitles.h, Source/Contents/UserData/AccountLinkedUserDataMgr.h, Source/Contents/UserData/NormalItemSlots.h, Source/Contents/World/World.h, Source/Contents/WorldView/WorldViewData.h, Source/Render/Primitives/LightmappedPrimitive.h, Source/Render/Primitives/RenderPrimitive.h, Source/Render/Renderer.h, Source/Render/Textures/SpritePixels.h, Source/Render/Textures/Texture.h, Source/Resource/EZeffectResource.h, Source/Resource/Models/AnimatedModelResource.h, Source/Resource/Models/GrannyModelResource.h, Source/Resource/Sprites/ActionResource.h, Source/Resource/World/GroundResource.h, Source/Resource/World/WorldResource.h, Source/Resource/XmlNode.h, Source/UI/AdventureGuide/UIAdventureGuide.h, Source/UI/Buttons/UIBmpRadioBtn.h, Source/UI/Buttons/UIDescriptRace.h, Source/UI/Buttons/UIItemTagButton.h, Source/UI/Buttons/UISlotBmpButton.h, Source/UI/Buttons/UISpriteButton.h, Source/UI/Buttons/UITVTextButton.h, Source/UI/Buttons/UITextureButton.h, Source/UI/CashEmotion/UICashEmotionListWnd.h, Source/UI/CashEmotion/UICashEmotionPack.h, Source/UI/CashShop/UICashShopWnd.h, Source/UI/Chat/UIChatRoomMakeWnd.h, Source/UI/Chat/UIChatRoomTitle.h, Source/UI/Chat/UINewChatWnd.h, Source/UI/Chat/UISubChatHisWnd.h, Source/UI/Chat/UISubChatMiniWnd.h, Source/UI/Chat/UIWhisperWnd.h, Source/UI/Clan/UIClanWnd.h, Source/UI/Dialogs/UIBookWnd.h, Source/UI/Dialogs/UIChooseWarpWnd.h, Source/UI/Dialogs/UIMenuWnd.h, Source/UI/Dialogs/UIMiniMapWnd.h, Source/UI/Dialogs/UIMinimapZoomWnd.h, Source/UI/Dialogs/UINpcEditDialogWnd.h, Source/UI/Dialogs/UIPasswordWnd.h, Source/UI/Dialogs/UISayDialogWnd.h, Source/UI/Dialogs/UISelectCartWnd.h, Source/UI/Dialogs/UITipboxWnd.h, Source/UI/Edit/UIEditBoxEx.h, Source/UI/Edit/UIEditCtrl.h, Source/UI/Edit/UIEditCtrl_Currency.h, Source/UI/Edit/UIItemTagCtrl.h, Source/UI/Enchant/EnchantUI.h, Source/UI/Exchange/UIExchangeUI.h, Source/UI/FrameSkin.h, Source/UI/GameSettings/GameSettingsUI.h, Source/UI/Gauges/UIPcGage.h, Source/UI/Guild/UIGuildHelperWnd.h, Source/UI/Guild/UIGuildWnd.h, Source/UI/Guild/UIGuild_Storage_Log.h, Source/UI/Item/UIEquipmentPropertiesWnd.h, Source/UI/Item/UIItemBaseWnd.h, Source/UI/Item/UIItemPurchaseWnd.h, Source/UI/Item/UIItemSellWnd2.h, Source/UI/Item/UIItemShopWnd.h, Source/UI/Item/UIItemShopWnd2.h, Source/UI/Item/UIItemStoreFindWnd.h, Source/UI/Item/UIItemStoreSubWnd.h, Source/UI/Item/UIItemStoreWnd.h, Source/UI/Item/UIItemWnd.h, Source/UI/Item/UIMerchantItemLogWnd.h, Source/UI/Item/UIParaItemShopWnd.h, Source/UI/Items/UICardItemIllustWnd.h, Source/UI/Items/UIEquipWnd.h, Source/UI/Items/UIExchangeWnd.h, Source/UI/Items/UIGameItem.h, Source/UI/Items/UIItemCollectionWnd.h, Source/UI/Items/UIItemIdentifyWnd.h, Source/UI/Items/UIItemParamChangeDisplayWnd.h, Source/UI/Items/UISwapEquipmentWnd.h, Source/UI/Layout/WindowGeometry.h, Source/UI/Lists/UIChatHisBox.h, Source/UI/Lists/UIComboBoxV2Wnd.h, Source/UI/Lists/UIImgMenu.h, Source/UI/Lists/UIListBoxID.h, Source/UI/Lists/UIListBoxTemplate.h, Source/UI/Lists/UIMemberListBox.h, Source/UI/Lists/UITabControl.h, Source/UI/Lists/UITagListBox.h, Source/UI/Lists/UITreeView.h, Source/UI/Menu/UIMenuIconWnd.h, Source/UI/Navigation/UINavigationV4Wnd.h, Source/UI/ProbabilityTable/UIProbabilityTable.h, Source/UI/Quest/UIQuestDisplay.h, Source/UI/Quest/UIRenewQuestUI.h, Source/UI/Quest/UIRenewQuestWnd.h, Source/UI/Rodex/UIRodexComposeWnd.h, Source/UI/Rodex/UIRodexInboxWnd.h, Source/UI/RuneSystem/UIRuneSystemWindows.h, Source/UI/RuneSystem/UIRuneSystemWnd.h, Source/UI/Shop/UIMerchantItemMyShopWnd.h, Source/UI/Shop/UIMerchantItemPurchaseMSGWnd.h, Source/UI/Shop/UIMerchantItemPurchaseWnd.h, Source/UI/Shop/UIMerchantItemShopWnd.h, Source/UI/Shop/UIMerchantMirrorItemWnd.h, Source/UI/Shop/UIMerchantShopMakeWnd.h, Source/UI/Shop/UIMerchantShopTitle.h, Source/UI/Skill/UISkillDescribeWnd.h, Source/UI/Skill/UISkillListWnd.h, Source/UI/SkillDelayInfo/SkillDelayInfo.h, Source/UI/StylingShop/UIStylingShopWnd.h, Source/UI/Text/CreateLineInfo.h, Source/UI/Text/UIAchWnd.h, Source/UI/Text/UIBalloonText.h, Source/UI/Text/UINameBalloonText.h, Source/UI/Text/UIStaticTextControl.h, Source/UI/Text/UIString.h, Source/UI/Text/UITextViewerControl.h, Source/UI/UIBarGraph.h, Source/UI/UIBartermarketWnd.h, Source/UI/UIChangeMaterialWnd.h, Source/UI/UIGradeEnchantWnd.h, Source/UI/UILapineScrollBar.h, Source/UI/UIMacroBlackListCheckWnd.h, Source/UI/UIMacroDetectorWnd.h, Source/UI/UIMacroReport.h, Source/UI/UIMacroUserInfoWnd.h, Source/UI/UIPreviewEquipWnd.h, Source/UI/UIRefiningWnd.h, Source/UI/UIScrollWnd.h, Source/UI/UISlotBitmap.h, Source/UI/Window/FuncDrawWNDChar.h, Source/UI/Window/UIBattleMsgOptionWnd.h, Source/UI/Window/UIChatRoomWnd.h, Source/UI/Window/UICollectionSystemWnd.h, Source/UI/Window/UIControl.h, Source/UI/Window/UIHomunInfoWnd.h, Source/UI/Window/UIHotKeyWnd.h, Source/UI/Window/UIJobListWnd.h, Source/UI/Window/UILoginOTPWnd.h, Source/UI/Window/UILoginWnd.h, Source/UI/Window/UIMakeCharWnd.h, Source/UI/Window/UIMonsterDisplayWnd.h, Source/UI/Window/UIMonsterInfoWnd.h, Source/UI/Window/UINavigationHelpWnd.h, Source/UI/Window/UINavigationWnd.h, Source/UI/Window/UINewMakeCharWnd.h, Source/UI/Window/UINewSelectCharWnd.h, Source/UI/Window/UINoticeWnd.h, Source/UI/Window/UIPetInfoWnd.h, Source/UI/Window/UIRegisterMgr.h, Source/UI/Window/UIRoMapWnd.h, Source/UI/Window/UIRodexContentsWnd.h, Source/UI/Window/UISecondCostumeWnd.h, Source/UI/Window/UISeekPartyMBWnd.h, Source/UI/Window/UISeekPartyWnd.h, Source/UI/Window/UISelCharForUServerWnd.h, Source/UI/Window/UISerachStoreInfoWnd.h, Source/UI/Window/UITransMenuWnd.h, Source/UI/Window/UIWindow.h, Source/UI/Window/UIWindowMgr.h, Source/UI/Window/UIWindowMgr.inl, Source/Utility/Lexicon/LexiconSerializer.h.
2026-11-08 16:44:36 +00:00

616 lines
15 KiB
C++

#include "Contents/NavigationManager.h"
#include "Client/Mode/ModeMgr.h"
#include "Client/Mode/CGameMode.h"
#include "Contents/World/World.h"
#include "Client/Session.h"
#include "Resource/ResourceMgr.h"
#include <cstdio>
#include <cstring>
#include <windows.h>
#include <shlwapi.h>
// OFFSET: 0x00B8C0B0
// FUNCTION: fn_19420
__declspec(noinline) CNavi_Object* FindNaviObjectByName(const char* name, const std::vector<CNavi_Object*>& objects) {
for (std::vector<CNavi_Object*>::const_iterator it = objects.begin(); it != objects.end(); ++it) {
if (name) {
if ((*it)->name == std::string(name)) {
return *it;
}
}
}
return nullptr;
}
// OFFSET: 0x00B8DF10
// FUNCTION: fn_19461
std::uint16_t CNavi_Object::GetFlag() const {
return this->flag;
}
// OFFSET: 0x00B8E600
// FUNCTION: fn_19474
const char* CNavi_Object::GetTitle() const {
return this->title.c_str();
}
// OFFSET: 0x00B8E620
// FUNCTION: fn_19476
const char* CNaviInfo::GetTitle() const {
return this->title.c_str();
}
// OFFSET: 0x00B8E630
// FUNCTION: fn_19477
const char* CNavi_Object::GetName() const {
return this->name.c_str();
}
// OFFSET: 0x00B8E7F0
// FUNCTION: fn_19484
NaviCell* CNavi_Object::GetCell(NaviCell* out) const {
const NaviCell cell = {this->cellX, this->cellY};
*out = cell;
return out;
}
// OFFSET: 0x00B8E810
// FUNCTION: fn_19485
const char* CNaviInfo::GetName() const {
return this->name.c_str();
}
// OFFSET: 0x00B8E820
// FUNCTION: fn_19486
std::size_t CNaviInfo::GetNameLength() const {
return this->name.size();
}
// OFFSET: 0x00B8E840
// FUNCTION: fn_19488
int CNavi_Object::GetIndex() const {
if (this->type == 300 || this->type == 301) {
return this->shortIndex;
}
return this->index;
}
// OFFSET: 0x00B8E8B0
// FUNCTION: fn_19493
int CNavi_Object::GetType() const {
return this->type;
}
// OFFSET: 0x00B8E8D0
// FUNCTION: fn_19495
int CNavi_Object::GetId() const {
return this->id;
}
// OFFSET: 0x00B8E910
// FUNCTION: fn_19498
CNaviInfo* CNavi_Object::GetInfo() const {
return this->info;
}
// OFFSET: 0x00B89940
// FUNCTION: fn_19387
__declspec(noinline) bool CNaviData::SetDestination(CNaviInfo* info, int cellX, int cellY) {
if (info == nullptr) {
return false;
}
this->info = info;
this->cellX = cellX;
this->cellY = cellY;
return true;
}
// OFFSET: 0x00BA1260
// FUNCTION: fn_19638
bool CNavigationManager::UpdateGround() {
CGameMode* mode = static_cast<CGameMode*>(g_modeMgr.GetGameMode());
if (mode == nullptr) {
return false;
}
auto* scene = mode->scene;
if (scene == nullptr) {
return false;
}
auto* terrain = scene->terrain;
if (terrain == nullptr) {
return false;
}
this->ground = scene->ground;
this->pathFinder.attr = terrain;
return true;
}
// OFFSET: 0x00BA12A0
// FUNCTION: fn_19639
int CNavigationManager::StateCount() const {
return static_cast<int>(this->states.size());
}
// OFFSET: 0x00BA12C0
// FUNCTION: fn_19640
int CNavigationManager::NodeCount() const {
return static_cast<int>(this->nodes.size());
}
// OFFSET: 0x00B9C730
// FUNCTION: fn_19622
void CNavigationManager::SetViewIcon(int icon) {
this->viewIcon = icon;
}
// OFFSET: 0x00B9F9B0
// FUNCTION: fn_19630
bool CNavigationManager::SetViewMode(int mode) {
if (mode != 1 && mode != 2 && mode != 0) {
return false;
}
this->viewMode = mode;
return true;
}
// OFFSET: 0x00B9F9E0
// FUNCTION: fn_19631
void CNavigationManager::BuildGridLabels() {
char path[260];
for (int index = 0; index < 8; ++index) {
std::memset(path, 0, sizeof(path));
std::sprintf(path, "유저인터페이스\\navigation_interface3\\navi_grid%d_%d.tga", this->viewIcon, index);
this->labels[index] = path;
}
}
// OFFSET: 0x00B97200
// FUNCTION: fn_19598
int CNavigationManager::RequestRoute(int cellX, int cellY) {
this->selectedNode = -1;
CNaviInfo* info = this->FindObject(g_session.m_navigationPlayerMap);
if (info == nullptr) {
const std::string resolved = ResourceMgr::Instance().aliases.ResolveMapName(g_session.m_navigationPlayerMap);
info = this->FindObject(resolved.c_str());
if (info == nullptr) {
return -93;
}
}
CNaviInfo* target = nullptr;
int destX = cellX;
int destY = cellY;
const int type = this->savedTarget.type;
if (type == 3) {
if (info == static_cast<CNavi_Object*>(this->savedTarget.object)->GetInfo()) {
return 2;
}
return -99;
}
if (type == 1) {
if (info == this->savedTarget.object) {
return 3;
}
return -99;
}
if (type == 0) {
if (cellX < 0 || cellY < 0) {
return -97;
}
target = static_cast<CNaviInfo*>(this->savedTarget.object);
} else if (type == 2) {
CNavi_Object* object = static_cast<CNavi_Object*>(this->savedTarget.object);
target = object->GetInfo();
NaviCell cell;
const NaviCell* result = object->GetCell(&cell);
destX = result->x;
destY = result->y;
}
if (info != target) {
return -99;
}
int startX = 0;
int startY = 0;
CGameMode* mode = static_cast<CGameMode*>(g_modeMgr.GetGameMode());
if (mode == nullptr) {
return -95;
}
mode->PlayerCell(&startX, &startY);
this->UpdateGround();
if (!this->BuildRoute(startX, startY, destX, destY, false)) {
return -99;
}
this->data.SetDestination(target, destX, destY);
this->drawRoute = true;
this->routeFlag = true;
this->drawDestination = true;
this->viewMode = 2;
return 9;
}
// OFFSET: 0x00B8E350
// FUNCTION: fn_19466
std::vector<CNavi_Link*>::iterator CNaviInfo::LinksBegin() {
return this->links.begin();
}
// OFFSET: 0x00B8E360
// FUNCTION: fn_19467
std::vector<CNavi_Link*>::iterator CNaviInfo::LinksEnd() {
return this->links.end();
}
// OFFSET: 0x00B8E760
// FUNCTION: fn_19481
bool CNaviInfo::IsVisited() const {
return this->visited;
}
// OFFSET: 0x00B90410
// FUNCTION: fn_19509
void CNaviInfo::SetVisited(bool visited) {
if (this->type == 5001) {
this->visited = visited;
}
}
// OFFSET: 0x00B8DF20
// FUNCTION: fn_19462
int CNaviInfo::GetCellY() const {
return this->cellY;
}
// OFFSET: 0x00B8DF30
// FUNCTION: fn_19463
int CNaviInfo::GetIndex() const {
return this->index;
}
// OFFSET: 0x00B8DF40
// FUNCTION: fn_19464
CNavi_Link* CNaviInfo::FindLink(unsigned int key, bool byId) {
if (byId) {
for (CNavi_Link* link : this->links) {
if (static_cast<unsigned int>(link->id) == key) {
return link;
}
}
return nullptr;
}
if (this->links.empty() || key >= this->links.size()) {
return nullptr;
}
return this->links[key];
}
// OFFSET: 0x00B8E640
// FUNCTION: fn_19478
CNavi_Object* CNaviInfo::FindNpc(unsigned int key, bool byId) {
if (byId) {
for (CNavi_Object* npc : this->npcs) {
if (static_cast<unsigned int>(npc->id) == key) {
return npc;
}
}
return nullptr;
}
if (this->npcs.empty() || key >= this->npcs.size()) {
return nullptr;
}
return this->npcs[key];
}
// OFFSET: 0x00B8E6F0
// FUNCTION: fn_19479
CNavi_Object* CNaviInfo::FindNpcAt(int cellX, int cellY) {
for (CNavi_Object* npc : this->npcs) {
if (npc->cellX == cellX && npc->cellY == cellY) {
return npc;
}
}
return nullptr;
}
// OFFSET: 0x00B8E750
// FUNCTION: fn_19480
std::vector<CNavi_Object*>* CNaviInfo::Npcs() {
return &this->npcs;
}
// OFFSET: 0x00B8E010
// FUNCTION: fn_19465
CNavi_Link* CNaviInfo::FindMatchingLink(CNavi_Link link) {
const CNavi_Link target = link;
for (CNavi_Link* candidate : this->links) {
if (candidate->cellX == target.cellX && candidate->cellY == target.cellY && candidate->linkedCellX == target.linkedCellX &&
candidate->linkedCellY == target.linkedCellY && candidate->info != nullptr &&
std::strcmp(candidate->info->name.c_str(), target.info->name.c_str()) == 0 && candidate->linkedInfo != nullptr &&
std::strcmp(candidate->linkedInfo->name.c_str(), target.linkedInfo->name.c_str()) == 0) {
return candidate;
}
}
return nullptr;
}
// OFFSET: 0x00B8D6F0
// FUNCTION: fn_19435
bool NavigationTarget::operator>(const NavigationTarget& other) const {
return std::strcmp(this->name.c_str(), other.name.c_str()) > 0;
}
// OFFSET: 0x00B8DEA0
// FUNCTION: fn_19459
int CNaviInfo::GetType() const {
return this->type;
}
// OFFSET: 0x00B8E370
// FUNCTION: fn_19468
std::vector<CNavi_Link*>* CNaviInfo::Links() {
return &this->links;
}
// OFFSET: 0x00B8E380
// FUNCTION: fn_19469
CNavi_Object* CNaviInfo::FindMob(unsigned int key, bool byId) {
if (byId) {
for (CNavi_Object* mob : this->mobs) {
if (static_cast<unsigned int>(mob->id) == key) {
return mob;
}
}
return nullptr;
}
if (this->mobs.empty() || key >= this->mobs.size()) {
return nullptr;
}
return this->mobs[key];
}
// OFFSET: 0x00B8E450
// FUNCTION: fn_19471
std::vector<CNavi_Object*>* CNaviInfo::Mobs() {
return &this->mobs;
}
// OFFSET: 0x00B8E460
// FUNCTION: fn_19472
CNavi_Object* CNaviInfo::FindMobByIndex(int index) {
for (std::vector<CNavi_Object*>::iterator it = this->mobs.begin(); it != this->mobs.end(); ++it) {
if (index == (*it)->GetIndex()) {
return *it;
}
}
return nullptr;
}
// OFFSET: 0x00B8E770
// FUNCTION: fn_19482
std::vector<NaviLink> CNavi_Object::CopyLinks() const {
return this->links;
}
// OFFSET: 0x00B8F500
// FUNCTION: fn_19503
bool CNaviInfo::IsSearchable(const char* name) const {
if (std::strcmp(name, "gl_in01") != 0 && std::strstr(name, "_in") != nullptr) {
return false;
}
return true;
}
// OFFSET: 0x00B8E970
// FUNCTION: fn_19500
void CNaviInfo::CollectTargets(int type, std::vector<NavigationTarget>& out) {
NavigationTarget target(type, nullptr);
if (std::strstr(this->name.c_str(), "_in") == nullptr && (type == 1 || type == 0)) {
target.name = this->name.c_str();
target.object = this;
target.type = 1;
out.push_back(target);
}
if (type == 2 || type == 0) {
target.type = 2;
for (CNavi_Object* npc : this->npcs) {
NaviCell cell;
const NaviCell* position = npc->GetCell(&cell);
target.x = position->x;
target.y = position->y;
target.name = npc->GetName();
target.object = npc;
out.push_back(target);
}
}
if (type == 3 || type == 0) {
target.type = 3;
for (CNavi_Object* mob : this->mobs) {
NaviCell cell;
const NaviCell* position = mob->GetCell(&cell);
target.x = position->x;
target.y = position->y;
target.name = mob->GetName();
target.object = mob;
out.push_back(target);
}
}
}
// OFFSET: 0x00B8EC70
// FUNCTION: fn_19501
void CNaviInfo::CollectMobsInRange(int minimum, int maximum, std::vector<NavigationTarget>& out) {
NavigationTarget target(3, nullptr);
for (CNavi_Object* mob : this->mobs) {
NaviCell lower;
NaviCell upper;
if (minimum <= mob->GetCell(&lower)->x && mob->GetCell(&upper)->x <= maximum) {
NaviCell cell;
const NaviCell* position = mob->GetCell(&cell);
target.x = position->x;
target.y = position->y;
target.name = mob->GetName();
target.object = mob;
out.push_back(target);
}
}
}
// OFFSET: 0x00B8FC40
// FUNCTION: fn_19505
void CNaviInfo::CollectMobsByTitle(std::string title, std::vector<NavigationTarget>& out) {
NavigationTarget target(3, nullptr);
for (CNavi_Object* mob : this->mobs) {
if (std::strcmp(mob->GetTitle(), title.c_str()) == 0) {
NaviCell cell;
const NaviCell* position = mob->GetCell(&cell);
target.x = position->x;
target.y = position->y;
target.name = mob->GetName();
target.object = mob;
out.push_back(target);
}
}
}
// OFFSET: 0x00B8E920
// FUNCTION: fn_19499
void CNaviInfo::Search(int type, const std::vector<std::string>& keywords, std::vector<NavigationTarget>& out) {
this->SearchMap(keywords, out);
if (type == 2 || type == 0) {
this->SearchMobs(keywords, out);
}
if (type == 3 || type == 0) {
this->SearchNpcs(keywords, out);
}
}
// OFFSET: 0x00B8EE50
// FUNCTION: fn_19502
void CNaviInfo::SearchMap(const std::vector<std::string>& keywords, std::vector<NavigationTarget>& out) {
NavigationTarget target(1, nullptr);
wchar_t buffer[100];
std::memset(buffer, 0, sizeof(buffer));
std::vector<std::wstring> wideKeywords;
for (const std::string& keyword : keywords) {
MultiByteToWideChar(CP_ACP, 0, keyword.c_str(), -1, buffer, 100);
wideKeywords.push_back(std::wstring(buffer));
}
const std::string text = this->name + ' ' + this->title + ' ';
MultiByteToWideChar(CP_ACP, 0, text.c_str(), -1, buffer, 100);
const std::wstring wideText(buffer);
const char* mapName = this->name.c_str();
if (std::strcmp(mapName, "gl_in01") != 0 && std::strstr(mapName, "_in") != nullptr) {
return;
}
bool matched = true;
for (const std::wstring& keyword : wideKeywords) {
matched &= StrStrIW(wideText.c_str(), keyword.c_str()) != nullptr;
}
if (!matched) {
return;
}
target.name = this->name;
target.object = this;
out.push_back(target);
target.type = 3;
for (CNavi_Object* mob : this->mobs) {
target.x = -1000;
target.y = -1000;
target.name = mob->GetName();
target.object = mob;
out.push_back(target);
}
}
// OFFSET: 0x00B8F560
// FUNCTION: fn_19504
void CNaviInfo::SearchMobs(const std::vector<std::string>& keywords, std::vector<NavigationTarget>& out) {
NavigationTarget target(3, nullptr);
wchar_t buffer[100];
std::memset(buffer, 0, sizeof(buffer));
std::vector<std::wstring> wideKeywords;
for (const std::string& keyword : keywords) {
MultiByteToWideChar(CP_ACP, 0, keyword.c_str(), -1, buffer, 100);
wideKeywords.push_back(std::wstring(buffer));
}
std::wstring entryText;
const std::string text = this->name + ' ' + this->title + ' ';
MultiByteToWideChar(CP_ACP, 0, text.c_str(), -1, buffer, 100);
const std::wstring wideText(buffer);
for (CNavi_Object* mob : this->mobs) {
MultiByteToWideChar(CP_ACP, 0, mob->GetName(), -1, buffer, 100);
entryText = buffer;
bool matched = true;
for (const std::wstring& keyword : wideKeywords) {
matched &= StrStrIW(entryText.c_str(), keyword.c_str()) != nullptr;
}
if (!matched) {
continue;
}
NaviCell cell;
const NaviCell* position = mob->GetCell(&cell);
target.x = position->x;
target.y = position->y;
target.name = mob->GetName();
target.object = mob;
out.push_back(target);
}
}
// OFFSET: 0x00B8FE40
// FUNCTION: fn_19506
void CNaviInfo::SearchNpcs(const std::vector<std::string>& keywords, std::vector<NavigationTarget>& out) {
NavigationTarget target(2, nullptr);
wchar_t buffer[100];
std::memset(buffer, 0, sizeof(buffer));
std::vector<std::wstring> wideKeywords;
for (const std::string& keyword : keywords) {
MultiByteToWideChar(CP_ACP, 0, keyword.c_str(), -1, buffer, 100);
wideKeywords.push_back(std::wstring(buffer));
}
std::wstring entryText;
for (CNavi_Object* npc : this->npcs) {
MultiByteToWideChar(CP_ACP, 0, npc->GetName(), -1, buffer, 100);
entryText = buffer;
bool matched = true;
for (const std::wstring& keyword : wideKeywords) {
matched &= StrStrIW(entryText.c_str(), keyword.c_str()) != nullptr;
}
if (!matched) {
continue;
}
NaviCell cell;
const NaviCell* position = npc->GetCell(&cell);
target.x = position->x;
target.y = position->y;
target.name = npc->GetName();
target.object = npc;
out.push_back(target);
}
}
// OFFSET: 0x00B8E410
// FUNCTION: fn_19470
CNavi_Object* CNaviInfo::FindMobByName(const char* name) {
return FindNaviObjectByName(name, this->mobs);
}