From d1c5e272a8c9aaf3fdf61f6560d2de44d46e8679 Mon Sep 17 00:00:00 2001 From: Gent Date: Thu, 17 Sep 2020 12:59:30 -0400 Subject: [PATCH] Fix vehicle type override --- src/NPCManager.hpp | 1 - src/TableData.cpp | 22 +++++++++++++++++++++- src/TableData.hpp | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/NPCManager.hpp b/src/NPCManager.hpp index 697a870..97fef2a 100644 --- a/src/NPCManager.hpp +++ b/src/NPCManager.hpp @@ -34,5 +34,4 @@ namespace NPCManager { void npcVendorBuyback(CNSocket* sock, CNPacketData* data); void npcVendorBuyBattery(CNSocket* sock, CNPacketData* data); void npcCombineItems(CNSocket* sock, CNPacketData* data); - void updatePlayerNPCS(CNSocket* sock, PlayerView& plr); } diff --git a/src/TableData.cpp b/src/TableData.cpp index 84d5cc5..8076809 100644 --- a/src/TableData.cpp +++ b/src/TableData.cpp @@ -112,7 +112,8 @@ void TableData::init() { itemSet = xdtData[setNames[i]]["m_pItemData"]; for (nlohmann::json::iterator _item = itemSet.begin(); _item != itemSet.end(); _item++) { auto item = _item.value(); - ItemManager::ItemData[std::pair(item["m_iItemNumber"], i == 11 ? 9 : (i == 10 ? 7 : (int)item["m_iEquipLoc"]))] + int typeOverride = getItemType(i); + ItemManager::ItemData[std::pair(item["m_iItemNumber"], typeOverride != -1 ? typeOverride : (int)item["m_iEquipLoc"])] = { item["m_iTradeAble"] == 1, item["m_iSellAble"] == 1, item["m_iItemPrice"], item["m_iItemSellPrice"], item["m_iStackNumber"], i > 9 ? 0 : (int)item["m_iMinReqLev"], i > 9 ? 1 : (int)item["m_iRarity"] }; } @@ -190,3 +191,22 @@ void TableData::cleanup() { for (auto& pair : NPCManager::NPCs) delete pair.second; } + +int TableData::getItemType(int itemSet) { + int overriden; + switch (itemSet) + { + case 11: + overriden = 9; + break; + case 10: + overriden = 7; + break; + case 9: + overriden = 10; + break; + default: + overriden = -1; + } + return overriden; +} diff --git a/src/TableData.hpp b/src/TableData.hpp index 2ba22b4..bf89c68 100644 --- a/src/TableData.hpp +++ b/src/TableData.hpp @@ -4,4 +4,6 @@ namespace TableData { void init(); void cleanup(); + + int getItemType(int); }