| 25 | #include "../common/item_data.h" |
| 26 | |
| 27 | void LoadItems(SharedDatabase *database, const std::string &prefix) { |
| 28 | EQ::IPCMutex mutex("items"); |
| 29 | mutex.Lock(); |
| 30 | |
| 31 | int32 items = -1; |
| 32 | uint32 max_item = 0; |
| 33 | database->GetItemsCount(items, max_item); |
| 34 | if(items == -1) { |
| 35 | EQ_EXCEPT("Shared Memory", "Unable to get any items from the database."); |
| 36 | } |
| 37 | |
| 38 | uint32 size = static_cast<uint32>(EQ::FixedMemoryHashSet<EQ::ItemData>::estimated_size(items, max_item)); |
| 39 | |
| 40 | auto Config = EQEmuConfig::get(); |
| 41 | std::string file_name = Config->SharedMemDir + prefix + std::string("items"); |
| 42 | EQ::MemoryMappedFile mmf(file_name, size); |
| 43 | mmf.ZeroFile(); |
| 44 | |
| 45 | void *ptr = mmf.Get(); |
| 46 | database->LoadItems(ptr, size, items, max_item); |
| 47 | mutex.Unlock(); |
| 48 | } |