rodecomp/Source/Contents/Items/ItemDescription.cpp
ragnarok-clanker f8d3e8622d Maintenance: Rename placeholder sub_XXXXXX functions to evidence-based names (Lua registration strings, log/error strings, packet ids
Batch #13412 by ragnarok-clanker: no function's compiled code changes; checked with 592 compiled unit(s), including every includer of Source/Client/Mode/CGameMode.h, Source/Client/Session.h, Source/Contents/Actors/GameActor.h, Source/Contents/CashEmotionMgr.h, Source/Contents/ClientItemLists.h, Source/Contents/ClientState.h, Source/Contents/Configuration/GameSettingsMgr.h, Source/Contents/Items/ItemInfo.h, Source/Contents/NavigationManager.h, Source/Contents/RenewQuestMgr.h, Source/Contents/ReputeMgr.h, Source/Contents/Schedule/TimeScheduler.h, Source/Contents/WorldView/WorldViewData.h, Source/UI/Buttons/UIDescriptRace.h, Source/UI/CashEmotion/UICashEmotionListWnd.h, Source/UI/Dialogs/UIPasswordWnd.h, Source/UI/Edit/UIEditCtrl.h, Source/UI/Edit/UIItemTagCtrl.h, Source/UI/GameSettings/GameSettingsUI.h, Source/UI/Item/UIItemStoreSubWnd.h, Source/UI/Items/UISwapEquipmentWnd.h, Source/UI/Lists/UIChatHisBox.h, Source/UI/Lists/UITagListBox.h, Source/UI/Quest/UIOngoingQuestInfo.h, Source/UI/Quest/UIRenewQuestUI.h, Source/UI/Rodex/UIRodexComposeWnd.h, Source/UI/Text/UIAchWnd.h, Source/UI/UIGradeEnchantWnd.h, Source/UI/UIIngredientInfoWnd.h, Source/UI/UIMacroUserInfoWnd.h, Source/UI/Window/UINewSkillListWnd.h, Source/UI/Window/UIRegisterMgr.h, Source/UI/Window/UIWindow.h, Source/UI/Window/UIWindowMgr.h, Source/Utility/JsonCppLoader.h.
2026-11-06 16:30:12 +00:00

127 lines
3.8 KiB
C++

#include "Contents/Items/ItemDescription.h"
#include "Contents/Items/ItemInfo.h"
#include "Contents/Items/ItemNaming.h"
#include "Client/Session.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
// GLOBAL: gl_24500
std::map<int, ITEM_DESC> g_itemDescriptions;
// OFFSET: 0x006D3540
// FUNCTION: fn_06540
ITEM_DESC::ITEM_DESC()
: identifiedName(nullptr), identifiedResource(nullptr), unidentifiedName(nullptr), unidentifiedResource(nullptr), unknown_002C(0), slots(0),
unknown_0040(0) {
}
// OFFSET: 0x006D46A0
// FUNCTION: fn_06560
ITEM_DESC::ITEM_DESC(const ITEM_DESC&) = default;
// OFFSET: 0x006D3610
// FUNCTION: fn_06541
ITEM_DESC::~ITEM_DESC() = default;
// OFFSET: 0x006D5160
// FUNCTION: fn_06568
ITEM_DESC& ITEM_DESC::operator=(const ITEM_DESC& other) {
if (this == &other) {
return *this;
}
this->identifiedName = other.identifiedName;
this->identifiedResource = other.identifiedResource;
this->identifiedDescription = other.identifiedDescription;
this->unidentifiedName = other.unidentifiedName;
this->unidentifiedResource = other.unidentifiedResource;
this->unidentifiedDescription = other.unidentifiedDescription;
this->unknown_002C = other.unknown_002C;
this->slots = other.slots;
this->unknown_0034 = other.unknown_0034;
this->unknown_0040 = other.unknown_0040;
return *this;
}
// OFFSET: 0x006D3A00
// FUNCTION: fn_06545
ITEM_DESC& FindItemDescription(int id, std::map<int, ITEM_DESC>& values) {
static ITEM_DESC missing;
const auto entry = values.find(id);
return entry == values.end() ? missing : entry->second;
}
// OFFSET: 0x006D3AE0
// FUNCTION: fn_06546
ItemCardName& EnsureItemCardName(int id, std::map<int, ItemCardName>& values) {
const auto entry = values.find(id);
if (entry != values.end()) {
return entry->second;
}
return values.insert({id, ItemCardName{nullptr, nullptr, nullptr}}).first->second;
}
// OFFSET: 0x006D3C10
// FUNCTION: fn_06547
std::vector<const char*>& EnsureItemDescriptionLines(int id, std::map<int, std::vector<const char*>>& values) {
const auto entry = values.find(id);
if (entry != values.end()) {
return entry->second;
}
return values.insert({id, std::vector<const char*>()}).first->second;
}
// OFFSET: 0x006D5890
// FUNCTION: fn_06579
ITEM_DESC& FindItemDescription(int id) {
return FindItemDescription(id, g_itemDescriptions);
}
// OFFSET: 0x006D3DC0
// FUNCTION: fn_06548
ITEM_DESC& EnsureItemDescription(int id, std::map<int, ITEM_DESC>& values) {
const auto entry = values.find(id);
if (entry != values.end()) {
return entry->second;
}
return values.insert({id, ITEM_DESC()}).first->second;
}
// OFFSET: 0x00DDD280
// FUNCTION: fn_23382
void CSession::IconPath(char* output, const char* id, int identified) {
const ITEM_DESC& value = FindItemDescription(std::atoi(id));
const char* resource = identified != 0 ? value.identifiedResource : value.unidentifiedResource;
std::sprintf(output, "유저인터페이스\\item\\%s.bmp", resource);
}
// OFFSET: 0x006D5730
// FUNCTION: fn_06576
const std::vector<const char*>& ITEM_INFO::Description() const {
return this->identified == 1 ? FindItemDescription(std::atoi(this->itemId.c_str()), g_itemDescriptions).identifiedDescription
: FindItemDescription(std::atoi(this->itemId.c_str()), g_itemDescriptions).unidentifiedDescription;
}
// OFFSET: 0x006D5810
// FUNCTION: fn_06578
int ITEM_INFO::GetIdDisplayName(char* output, int& capacity, unsigned char consume) const {
const char* name = FindItemDescription(std::atoi(this->itemId.c_str()), g_itemDescriptions).identifiedName;
const int error = strncpy_s(output, capacity, name ? name : " ", _TRUNCATE);
if (error != 0 && error != 80) {
return 0;
}
const int length = output ? static_cast<int>(strnlen(output, capacity)) : 0;
if (consume != 0) {
capacity -= length;
}
return length;
}