| 1643 | } |
| 1644 | |
| 1645 | bool SharedDatabase::LoadSpells(const std::string &prefix, int32 *records, const SPDat_Spell_Struct **sp) { |
| 1646 | spells_mmf.reset(nullptr); |
| 1647 | |
| 1648 | try { |
| 1649 | const auto Config = EQEmuConfig::get(); |
| 1650 | EQ::IPCMutex mutex("spells"); |
| 1651 | mutex.Lock(); |
| 1652 | |
| 1653 | std::string file_name = fmt::format("{}/{}{}", PathManager::Instance()->GetSharedMemoryPath(), prefix, std::string("spells")); |
| 1654 | spells_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name); |
| 1655 | LogInfo("Loading [{}]", file_name); |
| 1656 | *records = *static_cast<uint32*>(spells_mmf->Get()); |
| 1657 | *sp = reinterpret_cast<const SPDat_Spell_Struct*>(static_cast<char*>(spells_mmf->Get()) + 4); |
| 1658 | mutex.Unlock(); |
| 1659 | |
| 1660 | LogInfo("Loaded [{}] spells via shared memory", Strings::Commify(m_shared_spells_count)); |
| 1661 | } |
| 1662 | catch(std::exception& ex) { |
| 1663 | LogError("Error Loading Spells: {}", ex.what()); |
| 1664 | return false; |
| 1665 | } |
| 1666 | |
| 1667 | return true; |
| 1668 | } |
| 1669 | |
| 1670 | void SharedDatabase::LoadSpells(void *data, int max_spells) { |
| 1671 | *static_cast<uint32*>(data) = max_spells; |