MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / deletePlayer

Method deletePlayer

source/game/StarPlayerStorage.cpp:213–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213void 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
242WorldChunks PlayerStorage::loadShipData(Uuid const& uuid) {
243 RecursiveMutexLocker locker(m_mutex);

Callers 1

initCharSelectionMenuMethod · 0.80

Calls 8

strfFunction · 0.85
singletonClass · 0.85
hexMethod · 0.80
configurationMethod · 0.80
toUIntMethod · 0.80
containsMethod · 0.45
removeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected