2019-07-07 20:56:15 +00:00
|
|
|
#include <StdAfx.h>
|
2018-03-29 17:01:57 -04:00
|
|
|
#include "PhatSDK.h"
|
|
|
|
|
#include "InferredPortalData.h"
|
2020-04-27 18:44:20 -07:00
|
|
|
#include "GameEventManager.h"
|
2018-03-29 17:01:57 -04:00
|
|
|
|
|
|
|
|
CInferredPortalData::CInferredPortalData()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CInferredPortalData::~CInferredPortalData()
|
|
|
|
|
{
|
2019-03-17 17:11:14 +00:00
|
|
|
//for (auto &entry : _mutationFilters)
|
|
|
|
|
//{
|
|
|
|
|
// delete entry.second;
|
|
|
|
|
//}
|
2018-03-29 17:01:57 -04:00
|
|
|
_mutationFilters.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CInferredPortalData::Init()
|
|
|
|
|
{
|
|
|
|
|
#ifndef PUBLIC_BUILD
|
2018-04-27 21:03:39 -07:00
|
|
|
SERVER_INFO << "Loading inferred portal data...";
|
2018-03-29 17:01:57 -04:00
|
|
|
#endif
|
|
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
fs::path dataPath(g_pGlobals->GetGameData("Data", "json"));
|
2018-10-15 20:35:15 -05:00
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
fs::create_directories(dataPath);
|
2018-11-29 10:10:26 -06:00
|
|
|
|
2019-01-13 10:55:05 -06:00
|
|
|
_regionData.Destroy();
|
2018-03-29 17:01:57 -04:00
|
|
|
|
2019-01-13 10:55:05 -06:00
|
|
|
if (!LoadJsonData(dataPath / "region.json", _regionData))
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
2019-01-13 10:55:05 -06:00
|
|
|
LoadCacheData(1, 0xe8b00434, 0x82092270, _regionData);
|
2018-03-29 17:01:57 -04:00
|
|
|
}
|
|
|
|
|
|
2019-01-13 10:55:05 -06:00
|
|
|
if (!LoadJsonData(dataPath / "spells.json", _spellTableData))
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
2019-01-13 10:55:05 -06:00
|
|
|
LoadCacheData(2, 0x5D97BAEC, 0x41675123, _spellTableData);
|
2018-03-29 17:01:57 -04:00
|
|
|
}
|
|
|
|
|
|
2019-01-13 10:55:05 -06:00
|
|
|
// Treasure Factory
|
2019-03-17 17:11:14 +00:00
|
|
|
if (!LoadJsonData(dataPath / "treasureTables.json", _treasureTableData))
|
|
|
|
|
{
|
|
|
|
|
LoadCacheData(3, 0x7DC126EB, 0x5F41B9AD, _treasureTableData);
|
|
|
|
|
SaveJsonData(dataPath / "treasureTables.json", _treasureTableData);
|
|
|
|
|
}
|
2019-02-16 22:16:48 +00:00
|
|
|
|
|
|
|
|
// WieldedTreasureType DIDs
|
2019-03-17 17:11:14 +00:00
|
|
|
LoadJsonData(dataPath / "wieldedTreasure.json", _treasureTableData._treasureEquipment);
|
2018-03-29 17:01:57 -04:00
|
|
|
|
2019-01-13 10:55:05 -06:00
|
|
|
// Recipe Factory
|
|
|
|
|
LoadCacheData(4, 0x5F41B9AD, 0x7DC126EB, _craftTableData);
|
|
|
|
|
|
|
|
|
|
if (!LoadJsonData(dataPath / "housePortalDestinations.json", _housePortalDests))
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
2019-01-13 10:55:05 -06:00
|
|
|
LoadCacheData(5, 0x887aef9c, 0xa92ec9ac, _housePortalDests);
|
2018-03-29 17:01:57 -04:00
|
|
|
}
|
|
|
|
|
|
2019-01-13 10:55:05 -06:00
|
|
|
if (!LoadJsonData(dataPath / "quests.json", _questDefDB))
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
2019-01-13 10:55:05 -06:00
|
|
|
LoadCacheData(8, 0xE80D81CA, 0x8ECA9786, _questDefDB);
|
2018-03-29 17:01:57 -04:00
|
|
|
}
|
|
|
|
|
|
2019-01-13 10:55:05 -06:00
|
|
|
// Mutations
|
2019-03-17 17:11:14 +00:00
|
|
|
if (!LoadJsonData(dataPath / "mutationFilters.json", _mutationFilters))
|
|
|
|
|
{
|
|
|
|
|
BYTE *data = NULL;
|
2019-07-07 20:56:15 +00:00
|
|
|
uint32_t length = 0;
|
2019-03-17 17:11:14 +00:00
|
|
|
if (LoadDataFromPhatDataBin(10, &data, &length, 0x5f1fa913, 0xe345c74c))
|
|
|
|
|
{
|
|
|
|
|
BinaryReader reader(data, length);
|
2018-03-29 17:01:57 -04:00
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
uint32_t numEntries = reader.Read<uint32_t>();
|
|
|
|
|
for (uint32_t i = 0; i < numEntries; i++)
|
2019-03-17 17:11:14 +00:00
|
|
|
{
|
2019-07-07 20:56:15 +00:00
|
|
|
uint32_t key = reader.Read<uint32_t>();
|
|
|
|
|
uint32_t dataLength = reader.Read<uint32_t>();
|
2018-03-29 17:01:57 -04:00
|
|
|
|
2019-03-17 17:11:14 +00:00
|
|
|
BinaryReader entryReader(reader.ReadArray(dataLength), dataLength);
|
|
|
|
|
_mutationFilters[key].UnPack(&entryReader);
|
|
|
|
|
}
|
2018-03-29 17:01:57 -04:00
|
|
|
|
2019-03-17 17:11:14 +00:00
|
|
|
delete[] data;
|
2019-01-13 10:55:05 -06:00
|
|
|
|
2019-03-17 17:11:14 +00:00
|
|
|
//SaveJsonData(dataPath / "mutationFilters.json", _mutationFilters);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-29 17:01:57 -04:00
|
|
|
|
2019-01-13 10:55:05 -06:00
|
|
|
if (!LoadJsonData(dataPath / "events.json", _gameEvents))
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
2019-01-13 10:55:05 -06:00
|
|
|
LoadCacheData(11, 0x812a7823, 0x8b28e107, _gameEvents);
|
2018-03-29 17:01:57 -04:00
|
|
|
}
|
|
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
std::vector<std::string> &words = _bannedwords;
|
2019-01-13 10:55:05 -06:00
|
|
|
LoadJsonData(dataPath / "bannedwords.json", [&words](json &data)
|
2018-05-19 00:03:18 -07:00
|
|
|
{
|
2019-01-13 10:55:05 -06:00
|
|
|
words = data.at("badwords").get<std::vector<std::string>>();
|
|
|
|
|
});
|
2018-05-19 00:03:18 -07:00
|
|
|
|
2020-07-07 20:22:20 +00:00
|
|
|
//std::set<uint32_t> &restrictions = _restrictedLBData;
|
|
|
|
|
//LoadJsonData(dataPath / "restrictedlandblocks.json", [&restrictions](json &data)
|
|
|
|
|
//{
|
|
|
|
|
// restrictions = data.at("restrictedlandblocks").get<std::set<uint32_t>>();
|
|
|
|
|
//});
|
2019-03-17 17:11:14 +00:00
|
|
|
|
2018-11-05 22:46:18 -05:00
|
|
|
|
2018-03-29 17:01:57 -04:00
|
|
|
#ifndef PUBLIC_BUILD
|
2018-04-27 21:03:39 -07:00
|
|
|
SERVER_INFO << "Finished loading inferred cell data.";
|
2018-03-29 17:01:57 -04:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
uint32_t CInferredPortalData::GetWCIDForTerrain(int32_t x, int32_t y, int index)
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
|
|
|
|
return _regionData.GetEncounter(x, y, index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSpellTableEx *CInferredPortalData::GetSpellTableEx()
|
|
|
|
|
{
|
|
|
|
|
return &_spellTableData._table;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
CCraftOperation *CInferredPortalData::GetCraftOperation(uint32_t source_wcid, uint32_t dest_wcid)
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
2019-07-07 20:56:15 +00:00
|
|
|
uint64_t toolComboKey = ((uint64_t)source_wcid << 32) | dest_wcid;
|
|
|
|
|
const uint32_t *opKey = g_pPortalDataEx->_craftTableData._precursorMap.lookup(toolComboKey);
|
2018-03-29 17:01:57 -04:00
|
|
|
|
|
|
|
|
if (!opKey)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return g_pPortalDataEx->_craftTableData._operations.lookup(*opKey);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
Position *CInferredPortalData::GetHousePortalDest(uint32_t house_id, uint32_t ignore_cell_id)
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
2018-10-15 17:17:30 -05:00
|
|
|
house_portal_table_t::mapped_type *dests = _housePortalDests.lookup(house_id);
|
2018-03-29 17:01:57 -04:00
|
|
|
|
|
|
|
|
if (dests)
|
|
|
|
|
{
|
|
|
|
|
for (auto &entry : *dests)
|
|
|
|
|
{
|
|
|
|
|
if (entry.objcell_id != ignore_cell_id)
|
|
|
|
|
return &entry;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
CMutationFilter *CInferredPortalData::GetMutationFilter(uint32_t id)
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
2018-10-15 17:17:30 -05:00
|
|
|
mutation_table_t::iterator entry = _mutationFilters.find(id & 0xFFFFFF);
|
2018-03-29 17:01:57 -04:00
|
|
|
|
|
|
|
|
if (entry != _mutationFilters.end())
|
|
|
|
|
{
|
2019-03-17 17:11:14 +00:00
|
|
|
return &(entry->second);
|
2018-03-29 17:01:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-05 22:46:18 -05:00
|
|
|
|
|
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
std::vector<std::string> CInferredPortalData::GetBannedwords()
|
2018-05-19 00:03:18 -07:00
|
|
|
{
|
2019-07-07 20:56:15 +00:00
|
|
|
return _bannedwords;
|
2018-05-19 00:03:18 -07:00
|
|
|
}
|
2018-03-29 17:01:57 -04:00
|
|
|
|
2020-07-07 20:22:20 +00:00
|
|
|
// std::set<uint32_t> CInferredPortalData::GetRestrictedLandblocks()
|
|
|
|
|
//{
|
|
|
|
|
// return _restrictedLBData;
|
|
|
|
|
//}
|
2020-04-27 18:44:20 -07:00
|
|
|
|
|
|
|
|
bool CInferredPortalData::ReloadQuestData()
|
|
|
|
|
{
|
|
|
|
|
fs::path dataPath(g_pGlobals->GetGameData("Data", "json"));
|
|
|
|
|
if (LoadJsonData(dataPath / "quests.json", g_pPortalDataEx->_questDefDB))
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CInferredPortalData::ReloadEventData()
|
|
|
|
|
{
|
|
|
|
|
fs::path dataPath(g_pGlobals->GetGameData("Data", "json"));
|
|
|
|
|
if (LoadJsonData(dataPath / "events.json", g_pGameEventManager->_gameEvents))
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|