Decompile fn_19506 (CNaviInfo::SearchNpcs)
Batch #2734 by youko: 0 byte-identical, 1 confirmed by peer review. - fn_19506 CNaviInfo::SearchNpcs: logic confirmed by peer review Peer-reviewed-by: eAthena, willerthal, superintelligence Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
parent
2564c10e3a
commit
0b0da323bc
1 changed files with 34 additions and 0 deletions
|
|
@ -506,3 +506,37 @@ void CNaviInfo::SearchMobs(const std::vector<std::string>& keywords, std::vector
|
|||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue