rodecomp/Source/Contents/Items/SelectPackageItemMgr.cpp
ragnarok-clanker b51e87ee7d Decompile 46 functions in Source/Contents/Skills/SkillActionDruid.cpp, Source/Contents/Items/SelectPackageItemMgr.cpp, ...
Batch #4416 by youko: 17 byte-identical, 29 confirmed by peer review.

- fn_04427 utility::FillRandomBytes: logic confirmed by peer review
- fn_04439 CSelectPackageItemMgr::CSelectPackageItemMgr: logic confirmed by peer review
- fn_04445 CSelectPackageItemMgr::AddTab: logic confirmed by peer review
- fn_04446 CSelectPackageItemMgr::FindItems: logic confirmed by peer review
- fn_04454 Singleton<CSelectPackageItemMgr>::GetInstance: logic confirmed by peer review
- fn_04456 CSelectPackageItemMgr::LuaAddTab: logic confirmed by peer review
- fn_04458 CSkillAction_DR_WERERAPTOR::Slot02: byte-identical
- fn_04459 CSkillAction_DR_WERERAPTOR::Slot11: logic confirmed by peer review
- fn_04460 CEfstAction_WERERAPTOR::Slot03: logic confirmed by peer review
- fn_04461 CEfstAction_WERERAPTOR::Slot04: logic confirmed by peer review
- fn_04463 CSkillAction_DR_ENRAGE_WOLF::Slot01: byte-identical
- fn_04464 CSkillAction_DR_ENRAGE_WOLF::Slot02: byte-identical
- fn_04465 CSkillAction_DR_ENRAGE_WOLF::Slot08: logic confirmed by peer review
- fn_04467 CEfstAction_ENRAGE_WOLF::Slot03: logic confirmed by peer review
- fn_04468 CEfstAction_ENRAGE_WOLF::Slot04: logic confirmed by peer review
- fn_04469 CSkillAction_DR_BLOOD_HOWLING::Slot01: byte-identical
- fn_04470 CSkillAction_DR_BLOOD_HOWLING::Slot02: byte-identical
- fn_04471 CSkillAction_DR_BLOOD_HOWLING::Slot08: logic confirmed by peer review
- fn_04473 CEfstAction_BLOOD_HOWLING::Slot03: logic confirmed by peer review
- fn_04474 CEfstAction_BLOOD_HOWLING::Slot04: logic confirmed by peer review
- fn_04475 CSkillAction_DR_NOMERCY_CLAW::Slot02: byte-identical
- fn_04477 CSkillAction_DR_HUNGER::Slot02: byte-identical
- fn_04478 CSkillAction_DR_HUNGER::Slot11: logic confirmed by peer review
- fn_04479 CSkillAction_DR_HUNGER::Slot15: logic confirmed by peer review
- fn_04480 CSkillAction_DR_CRUEL_BITE::Slot02: byte-identical
- fn_04482 CSkillAction_DR_ENRAGE_RAPTOR::Slot01: byte-identical
- fn_04483 CSkillAction_DR_ENRAGE_RAPTOR::Slot02: byte-identical
- fn_04484 CSkillAction_DR_ENRAGE_RAPTOR::Slot08: logic confirmed by peer review
- fn_04486 CEfstAction_ENRAGE_RAPTOR::Slot03: logic confirmed by peer review
- fn_04487 CEfstAction_ENRAGE_RAPTOR::Slot04: logic confirmed by peer review
- fn_04488 CSkillAction_DR_PREENING::Slot01: byte-identical
- fn_04489 CSkillAction_DR_PREENING::Slot02: byte-identical
- fn_04490 CSkillAction_DR_PREENING::Slot08: logic confirmed by peer review
- fn_04492 CEfstAction_PREENING::Slot03: logic confirmed by peer review
- fn_04493 CEfstAction_PREENING::Slot04: logic confirmed by peer review
- fn_04494 CSkillAction_DR_SHOOTING_FEATHER::Slot02: byte-identical
- fn_04497 CSkillAction_DR_FLICKING_TONADO::Slot02: byte-identical
- fn_04498 CSkillAction_DR_FLICKING_TONADO::Slot11: logic confirmed by peer review
- fn_04499 CSkillAction_DR_LOW_FLIGHT::Slot02: byte-identical
- fn_04501 CSkillAction_DR_NATURE_SHIELD::Slot01: byte-identical
- fn_04502 CSkillAction_DR_NATURE_SHIELD::Slot02: byte-identical
- fn_04503 CSkillAction_DR_NATURE_SHIELD::Slot08: logic confirmed by peer review
- fn_04504 CSkillAction_DR_NATURE_SHIELD::Slot11: logic confirmed by peer review
- fn_04505 CEfstAction_NATURE_SHIELD::Slot03: logic confirmed by peer review
- fn_04506 CEfstAction_NATURE_SHIELD::Slot04: logic confirmed by peer review
- fn_04507 CEfstAction_GROUND_GROW::Slot01: logic confirmed by peer review

Peer-reviewed-by: eAthena, willerthal, KWDev
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
Adds to the build: Source/Contents/Skills/SkillActionDruid.cpp, Source/Contents/Items/SelectPackageItemMgr.cpp, Source/Utility/Random/RandomBytes.cpp
2026-10-30 02:59:20 +00:00

91 lines
2.6 KiB
C++

#include "Contents/Items/SelectPackageItemMgr.h"
#include "Network/TextEncoding.h"
extern "C" {
#include <lua.h>
}
#include <new>
// GLOBAL: gl_24790
template <>
CSelectPackageItemMgr* Singleton<CSelectPackageItemMgr>::s_instance = nullptr;
// OFFSET: 0x0061E280
// FUNCTION: fn_04439
CSelectPackageItemMgr::CSelectPackageItemMgr() {
}
// OFFSET: 0x0061EC30
// FUNCTION: fn_04445
void CSelectPackageItemMgr::AddTab(int packageId, int tabIndex, const std::string& name, int itemCount) {
if (this->m_packages.find(packageId) == this->m_packages.end()) {
this->m_packages[packageId] = std::map<int, SelectPackageTab>();
}
if (this->m_packages[packageId].find(tabIndex) == this->m_packages[packageId].end()) {
this->m_packages[packageId][tabIndex] = SelectPackageTab();
}
this->m_packages[packageId][tabIndex].name = name;
this->m_packages[packageId][tabIndex].items.resize(itemCount);
}
// OFFSET: 0x0061EF60
// FUNCTION: fn_04446
std::optional<std::vector<ITEM_INFO>*> CSelectPackageItemMgr::FindItems(int packageId, int tabIndex) {
std::map<int, std::map<int, SelectPackageTab>>::iterator package = this->m_packages.find(packageId);
if (package != this->m_packages.end()) {
std::map<int, SelectPackageTab>::iterator tab = package->second.find(tabIndex);
if (tab != package->second.end()) {
return &tab->second.items;
}
}
return std::nullopt;
}
// OFFSET: 0x0061F9A0
// FUNCTION: fn_04454
template <>
CSelectPackageItemMgr* Singleton<CSelectPackageItemMgr>::GetInstance() {
if (!s_instance) {
s_instance = new (std::nothrow) CSelectPackageItemMgr;
}
return s_instance;
}
// OFFSET: 0x0061FD90
// FUNCTION: fn_04456
int CSelectPackageItemMgr::LuaAddTab(lua_State* L) {
if (!lua_isnumber(L, -4)) {
lua_pushboolean(L, 0);
lua_pushstring(L, "L_AddTab : 1st argument must be number");
return 2;
}
if (!lua_isnumber(L, -3)) {
lua_pushboolean(L, 0);
lua_pushstring(L, "L_AddTab : 2nd argument must be number");
return 2;
}
if (!lua_isstring(L, -2)) {
lua_pushboolean(L, 0);
lua_pushstring(L, "L_AddTab : 3rd argument must be string");
return 2;
}
if (!lua_isnumber(L, -1)) {
lua_pushboolean(L, 0);
lua_pushstring(L, "L_AddTab : 4th argument must be number");
return 2;
}
int packageId = static_cast<int>(lua_tonumber(L, -4));
int tabIndex = static_cast<int>(lua_tonumber(L, -3));
std::string name = FromUtf8(lua_tostring(L, -2), g_textCodePage);
int itemCount = static_cast<int>(lua_tonumber(L, -1));
CSelectPackageItemMgr::GetInstance()->AddTab(packageId, tabIndex, name, itemCount);
lua_pushboolean(L, 1);
lua_pushstring(L, "good");
return 2;
}