Prevent DB players from occupying same slot

This commit is contained in:
Gent S
2020-11-25 19:15:30 -05:00
parent ea5b7104be
commit 872425640d
3 changed files with 25 additions and 13 deletions

View File

@@ -208,6 +208,16 @@ bool Database::isNameFree(std::string firstName, std::string lastName) {
.empty());
}
bool Database::isSlotFree(int accountId, int slotNum) {
std::lock_guard<std::mutex> lock(dbCrit);
return
(db.get_all<DbPlayer>
(where((c(&DbPlayer::AccountID) == accountId)
and (c(&DbPlayer::slot) == slotNum)))
.empty());
}
int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID) {
std::lock_guard<std::mutex> lock(dbCrit);