Batch #3523 by eAthena: 0 byte-identical, 9 confirmed by peer review. - fn_03809 MaterialKey::MaterialKey: logic confirmed by peer review - fn_03814 MaterialKeyLess::operator(): logic confirmed by peer review - fn_03816 CChangeMaterialMgr::CreateInstance: logic confirmed by peer review - fn_03817 CChangeMaterialMgr::DestroyInstance: logic confirmed by peer review - fn_03818 CChangeMaterialMgr::Load: logic confirmed by peer review - fn_03819 CChangeMaterialMgr::InsertRecipe: logic confirmed by peer review - fn_03820 ChangeMaterialRecipeList::Add: logic confirmed by peer review - fn_03821 ChangeMaterialFormat: logic confirmed by peer review - fn_03840 CChangeMaterialMgr::LuaInsertRecipe: logic confirmed by peer review Peer-reviewed-by: Yommy Reviewed-by: ragnarok-clanker Adds to the build: Source/Contents/Items/ChangeMaterialMgr.cpp
90 lines
2.3 KiB
C++
90 lines
2.3 KiB
C++
#ifndef RAGNAROK_SOURCE_CONTENTS_ITEMS_CHANGEMATERIALMGR_H
|
|
#define RAGNAROK_SOURCE_CONTENTS_ITEMS_CHANGEMATERIALMGR_H
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct lua_State;
|
|
|
|
struct ChangeMaterialEntry {
|
|
/* 0000 */ int itemId;
|
|
/* 0004 */ int count;
|
|
|
|
// INLINED
|
|
bool operator<(const ChangeMaterialEntry& other) const {
|
|
return this->itemId < other.itemId;
|
|
}
|
|
};
|
|
|
|
struct ChangeMaterialProduct {
|
|
/* 0000 */ int itemId;
|
|
/* 0004 */ int count;
|
|
/* 0008 */ int rate;
|
|
};
|
|
|
|
struct ChangeMaterialRecipe {
|
|
// INLINED
|
|
ChangeMaterialRecipe(std::vector<ChangeMaterialEntry> materials, std::vector<ChangeMaterialProduct> products, int type)
|
|
: materials(materials), products(products), type(type) {
|
|
}
|
|
|
|
/* 0000 */ std::vector<ChangeMaterialEntry> materials;
|
|
/* 000C */ std::vector<ChangeMaterialProduct> products;
|
|
/* 0018 */ int type;
|
|
};
|
|
|
|
struct ChangeMaterialResult {
|
|
// INLINED
|
|
ChangeMaterialResult(bool success, const char* message) : success(success), message(message) {
|
|
}
|
|
|
|
/* 0000 */ bool success;
|
|
/* 0004 */ std::string message;
|
|
};
|
|
|
|
struct MaterialKey {
|
|
explicit MaterialKey(const std::vector<ChangeMaterialEntry>& materials);
|
|
|
|
/* 0000 */ std::vector<int> itemIds;
|
|
};
|
|
|
|
struct MaterialKeyLess {
|
|
bool operator()(const MaterialKey& left, const MaterialKey& right) const;
|
|
};
|
|
|
|
class ChangeMaterialRecipeList {
|
|
public:
|
|
ChangeMaterialResult Add(std::vector<ChangeMaterialEntry> materials, std::vector<ChangeMaterialProduct> products, int type);
|
|
|
|
/* 0000 */ std::vector<ChangeMaterialRecipe> m_recipes;
|
|
};
|
|
|
|
class CChangeMaterialMgr {
|
|
public:
|
|
// INLINED
|
|
CChangeMaterialMgr() : m_isValid(true) {
|
|
}
|
|
|
|
static bool CreateInstance();
|
|
static void DestroyInstance();
|
|
static int LuaInsertRecipe(lua_State* L);
|
|
|
|
bool Load();
|
|
ChangeMaterialResult InsertRecipe(std::vector<ChangeMaterialEntry> materials, const std::vector<ChangeMaterialProduct>& products, int type);
|
|
|
|
/* 0000 */ std::map<MaterialKey, ChangeMaterialRecipeList, MaterialKeyLess> m_library;
|
|
/* 0008 */ bool m_isValid;
|
|
};
|
|
|
|
std::string ChangeMaterialFormat(const char* format, ...);
|
|
|
|
extern CChangeMaterialMgr* g_changeMaterialMgr;
|
|
|
|
#if defined(_WIN32) && !defined(_WIN64)
|
|
static_assert(sizeof(ChangeMaterialRecipe) == 0x1C);
|
|
static_assert(sizeof(ChangeMaterialResult) == 0x1C);
|
|
static_assert(sizeof(CChangeMaterialMgr) == 0xC);
|
|
#endif
|
|
|
|
#endif
|