Decompile fn_19610 (CNavigationManager::SavedTargetText)

Batch #1844 by ragnarok-clanker: 0 byte-identical, 1 confirmed by peer review.

- fn_19610 CNavigationManager::SavedTargetText: logic confirmed by peer review

Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
ragnarok-clanker 2026-10-28 22:50:17 +00:00
commit e4e285180f
2 changed files with 54 additions and 0 deletions

View file

@ -254,6 +254,7 @@ public:
float FitToSquare(int* offsetX, int* offsetY, int width, int height, float size) const;
void LoadSettings();
bool BuildRoute(int startX, int startY, int destX, int destY, bool collectCells);
bool SavedTargetText(char* out, int size);
int RequestRoute(int cellX, int cellY);
NaviCell* MapCellToView(NaviCell* out, const char* mapName, int cellX, int cellY, float size);
std::string RouteText();

View file

@ -392,3 +392,56 @@ CNavi_Object::~CNavi_Object() {
this->info = nullptr;
this->links.clear();
}
// OFFSET: 0x00B98E40
// FUNCTION: fn_19610
bool CNavigationManager::SavedTargetText(char* out, int size) {
if (out == nullptr || this->savedTarget.object == nullptr) {
return false;
}
std::memset(out, 0, size);
char text[0x104];
std::memset(text, 0, sizeof(text));
switch (this->savedTarget.type) {
case 0: {
CNaviInfo* info = static_cast<CNaviInfo*>(this->savedTarget.object);
NaviCell cellY;
NaviCell cellX;
const int y = this->data.GetCell(&cellY)->y;
const int x = this->data.GetCell(&cellX)->x;
std::sprintf(text, "%s %d %d", info->GetName(), x, y);
break;
}
case 1:
std::sprintf(text, "%s", static_cast<CNaviInfo*>(this->savedTarget.object)->GetName());
break;
case 2: {
CNavi_Object* object = static_cast<CNavi_Object*>(this->savedTarget.object);
CNaviInfo* info = object->GetInfo();
NaviCell cellY;
NaviCell cellX;
const int y = object->GetCell(&cellY)->y;
const int x = object->GetCell(&cellX)->x;
std::sprintf(text, "%s %d %d", info->GetName(), x, y);
break;
}
case 3:
std::sprintf(text, "%s", static_cast<CNavi_Object*>(this->savedTarget.object)->GetInfo()->GetName());
break;
default:
return false;
}
const int length = static_cast<int>(std::strlen(text));
if (size > length) {
std::memcpy(out, text, length);
} else {
char truncated[0x104];
std::memset(truncated, 0, sizeof(truncated));
std::memcpy(truncated, text, size - 4);
std::sprintf(out, "%s...", truncated);
}
return true;
}