Load item tables + price implementation

This commit is contained in:
Gent
2020-09-14 00:25:14 -04:00
parent f55cc8f36d
commit c91022030c
4 changed files with 44 additions and 7 deletions

View File

@@ -121,11 +121,25 @@ void TableData::init() {
std::cout << "[INFO] Loaded mission-related data" << std::endl;
// load all item data. i'm sorry. it has to be done
const char* setNames[10] = { "m_pBackItemTable", "m_pFaceItemTable", "m_pGlassItemTable", "m_pHatItemTable",
"m_pHeadItemTable", "m_pPantsItemTable", "m_pShirtsItemTable", "m_pShoesItemTable", "m_pWeaponItemTable",
"m_pVehicleItemTable"};
nlohmann::json itemSet;
for (int i = 0; i < 10; i++) {
itemSet = xdtData[setNames[i]]["m_pItemData"];
for (nlohmann::json::iterator item = itemSet.begin(); item != itemSet.end(); item++)
ItemManager::ItemData[std::pair<int32_t, int32_t>(item.value()["m_iItemNumber"], item.value()["m_iEquipLoc"])]
= { item.value()["m_iTradeAble"] == 1, item.value()["m_iSellAble"] == 1, item.value()["m_iItemPrice"], item.value()["m_iItemSellPrice"], item.value()["m_iStackNumber"], item.value()["m_iMinReqLev"] };
}
std::cout << "[INFO] Loaded " << ItemManager::ItemData.size() << " items" << std::endl;
// load vendor listings
nlohmann::json listings = xdtData["m_pVendorTable"]["m_pItemData"];
for (nlohmann::json::iterator listing = listings.begin(); listing != listings.end(); listing++) {
VendorListing vListing = {listing.value()["m_iSortNumber"], listing.value()["m_iItemType"], listing.value()["m_iitemID"], listing.value()["m_iSellCost"]};
VendorListing vListing = { listing.value()["m_iSortNumber"], listing.value()["m_iItemType"], listing.value()["m_iitemID"] };
ItemManager::VendorTables[listing.value()["m_iNpcNumber"]].push_back(vListing);
}