| 211 | } |
| 212 | |
| 213 | void PlayerStorage::deletePlayer(Uuid const& uuid) { |
| 214 | RecursiveMutexLocker locker(m_mutex); |
| 215 | if (!m_savedPlayersCache.contains(uuid)) |
| 216 | throw PlayerException(strf("No such stored player with uuid '{}'", uuid.hex())); |
| 217 | |
| 218 | m_savedPlayersCache.remove(uuid); |
| 219 | |
| 220 | auto uuidHex = uuid.hex(); |
| 221 | auto storagePrefix = File::relativeTo(m_storageDirectory, uuidHex); |
| 222 | auto backupPrefix = File::relativeTo(m_backupDirectory, uuidHex); |
| 223 | |
| 224 | auto removeIfExists = [](String const& prefix, String const& suffix) { |
| 225 | if (File::exists(prefix + suffix)) { |
| 226 | File::remove(prefix + suffix); |
| 227 | } |
| 228 | }; |
| 229 | |
| 230 | removeIfExists(storagePrefix, ".player"); |
| 231 | removeIfExists(storagePrefix, ".shipworld"); |
| 232 | |
| 233 | auto configuration = Root::singleton().configuration(); |
| 234 | unsigned playerBackupFileCount = configuration->get("playerBackupFileCount").toUInt(); |
| 235 | |
| 236 | for (unsigned i = 1; i <= playerBackupFileCount; ++i) { |
| 237 | removeIfExists(backupPrefix, strf(".player.bak{}", i)); |
| 238 | removeIfExists(backupPrefix, strf(".shipworld.bak{}", i)); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | WorldChunks PlayerStorage::loadShipData(Uuid const& uuid) { |
| 243 | RecursiveMutexLocker locker(m_mutex); |
no test coverage detected