| 25 | #include "../common/spdat.h" |
| 26 | |
| 27 | void LoadSpells(SharedDatabase *database, const std::string &prefix) { |
| 28 | EQ::IPCMutex mutex("spells"); |
| 29 | mutex.Lock(); |
| 30 | int records = database->GetMaxSpellID() + 1; |
| 31 | if(records == 0) { |
| 32 | EQ_EXCEPT("Shared Memory", "Unable to get any spells from the database."); |
| 33 | } |
| 34 | |
| 35 | uint32 size = records * sizeof(SPDat_Spell_Struct) + sizeof(uint32); |
| 36 | |
| 37 | auto Config = EQEmuConfig::get(); |
| 38 | std::string file_name = Config->SharedMemDir + prefix + std::string("spells"); |
| 39 | EQ::MemoryMappedFile mmf(file_name, size); |
| 40 | mmf.ZeroFile(); |
| 41 | |
| 42 | void *ptr = mmf.Get(); |
| 43 | database->LoadSpells(ptr, records); |
| 44 | mutex.Unlock(); |
| 45 | } |
| 46 |
no test coverage detected