diff --git a/src/ItemManager.cpp b/src/ItemManager.cpp index 994f9ea..15b76e7 100644 --- a/src/ItemManager.cpp +++ b/src/ItemManager.cpp @@ -971,7 +971,7 @@ int ItemManager::getCrateItem(sItemBase& result, int itemSetId, int rarity, int std::pair key = std::make_pair(itemSetId, rarity); if (CrateItems.find(key) == CrateItems.end()) { - std::cout << "[WARN] Item Set ID " << itemSetId << " Rarity " << rarity << " items have not been found" << std::endl; + std::cout << "[WARN] Item Set ID " << itemSetId << " Rarity " << rarity << " does not exist" << std::endl; return -1; } @@ -986,8 +986,7 @@ int ItemManager::getCrateItem(sItemBase& result, int itemSetId, int rarity, int } if (items.size() == 0) { - std::cout << "[WARN] Gender inequality! Set ID " << itemSetId << " Rarity " << rarity << " contains only " - << (playerGender == 2 ? "boys" : "girls") << " items?!" << std::endl; + std::cout << "[WARN] Set ID " << itemSetId << " Rarity " << rarity << " contains no valid items" << std::endl; return -1; } diff --git a/src/RacingManager.cpp b/src/RacingManager.cpp index e60e505..62ce450 100644 --- a/src/RacingManager.cpp +++ b/src/RacingManager.cpp @@ -9,6 +9,7 @@ std::map RacingManager::EPData; std::map RacingManager::EPRaces; +std::map, std::vector>> RacingManager::EPRewards; void RacingManager::init() { REGISTER_SHARD_PACKET(P_CL2FE_REQ_EP_RACE_START, racingStart); diff --git a/src/RacingManager.hpp b/src/RacingManager.hpp index fa2b719..6844686 100644 --- a/src/RacingManager.hpp +++ b/src/RacingManager.hpp @@ -3,7 +3,7 @@ #include "CNShardServer.hpp" struct EPInfo { - int zoneX, zoneY, EPID, maxScore; + int zoneX, zoneY, EPID, maxScore, maxTime; }; struct EPRace { @@ -15,6 +15,7 @@ namespace RacingManager { extern std::map EPData; extern std::map EPRaces; + extern std::map, std::vector>> EPRewards; void init(); diff --git a/src/TableData.cpp b/src/TableData.cpp index 48033be..f64dbc5 100644 --- a/src/TableData.cpp +++ b/src/TableData.cpp @@ -539,6 +539,52 @@ void TableData::loadDrops() { std::cout << "[INFO] Loaded " << ItemManager::Crates.size() << " Crates containing " << itemCount << " items" << std::endl; + // Racing rewards + nlohmann::json racing = dropData["Racing"]; + for (nlohmann::json::iterator _race = racing.begin(); _race != racing.end(); _race++) { + auto race = _race.value(); + int raceEPID = race["EPID"]; + + // find the instance data corresponding to the EPID + int EPMap = -1; + for (auto& it = RacingManager::EPData.begin(); it != RacingManager::EPData.end(); it++) { + if (it->second.EPID == raceEPID) { + EPMap = it->first; + } + } + + if (EPMap == -1) { // not found + char buff[255]; + sprintf(buff, "EP with ID %d not found", raceEPID); + throw TableException(std::string(buff)); + } + + // time limit isn't stored in the XDT, so we include it in the reward table instead + RacingManager::EPData[EPMap].maxTime = race["TimeLimit"]; + + // score cutoffs + std::vector rankScores; + for (nlohmann::json::iterator _rankScore = race["RankScores"].begin(); _rankScore != race["RankScores"].end(); _rankScore++) { + rankScores.push_back((int)_rankScore.value()); + } + + // reward IDs for each rank + std::vector rankRewards; + for (nlohmann::json::iterator _rankReward = race["Rewards"].begin(); _rankReward != race["Rewards"].end(); _rankReward++) { + rankRewards.push_back((int)_rankReward.value()); + } + + if (rankScores.size() != 5 || rankScores.size() != rankRewards.size()) { + char buff[255]; + sprintf(buff, "Race in EP %d doesn't have exactly 5 score/reward pairs", raceEPID); + throw TableException(std::string(buff)); + } + + RacingManager::EPRewards[raceEPID] = std::make_pair(rankScores, rankRewards); + } + + std::cout << "[INFO] Loaded rewards for " << RacingManager::EPRewards.size() << " IZ races" << std::endl; + } catch (const std::exception& err) { std::cerr << "[FATAL] Malformed drops.json file! Reason:" << err.what() << std::endl; diff --git a/tdata b/tdata index 75d82f3..9650bb3 160000 --- a/tdata +++ b/tdata @@ -1 +1 @@ -Subproject commit 75d82f3155687d73ad72cfc479d2c2c7c3ecd20f +Subproject commit 9650bb3abbf55e77f9b7b10b93a4957757e93cd7