diff --git a/sources/Commands/ACommandDB.uc b/sources/Commands/ACommandDB.uc index 25e8349..8f6cca9 100644 --- a/sources/Commands/ACommandDB.uc +++ b/sources/Commands/ACommandDB.uc @@ -113,8 +113,15 @@ protected function BuildData(CommandDataBuilder builder) protected function PushPlayer(EPlayer nextPlayer, Database callDatabase) { - queueWaitingListPlayers[queueWaitingListPlayers.length] = - EPlayer(nextPlayer.Copy()); + local EPlayer playerCopy; + + if (nextPlayer != none) { + playerCopy = EPlayer(nextPlayer.Copy()); + } + if (callDatabase != none) { + callDatabase.NewRef(); + } + queueWaitingListPlayers[queueWaitingListPlayers.length] = playerCopy; queueWaitingListDatabases[queueWaitingListDatabases.length] = callDatabase; } @@ -128,9 +135,10 @@ protected function EPlayer PopPlayer(Database relevantDatabase) while (i < queueWaitingListDatabases.length) { - if (queueWaitingListDatabases[i] != relevantDatabase) + if (queueWaitingListDatabases[i].IsEqual(relevantDatabase)) { result = queueWaitingListPlayers[i]; + queueWaitingListDatabases[i].FreeSelf(); queueWaitingListPlayers.Remove(i, 1); queueWaitingListDatabases.Remove(i, 1); break; @@ -235,11 +243,11 @@ private function DBPointerPair TryLoadingDB(BaseText databaseLink) if (databaseLink == none) { return result; } - result.database = _.db.Load(databaseLink); + result.database = _server.db.Load(databaseLink); if (result.database == none) { return result; } - result.pointer = _.db.GetPointer(databaseLink); + result.pointer = _server.db.GetPointer(databaseLink); return result; } @@ -248,12 +256,12 @@ protected function CreateDatabase(EPlayer instigator, Text databaseName) if (instigator == none) { return; } - if (_.db.ExistsLocal(databaseName)) + if (_server.db.ExistsLocal(databaseName)) { callerConsole.WriteLine(T(TDB_ALREADY_EXISTS)); return; } - if (_.db.NewLocal(databaseName) != none) { + if (_server.db.NewLocal(databaseName) != none) { callerConsole.WriteLine(T(TDB_CREATED)); } else { @@ -266,7 +274,7 @@ protected function DeleteDatabase(EPlayer instigator, Text databaseName) if (instigator == none) { return; } - if (_.db.DeleteLocal(databaseName)) { + if (_server.db.DeleteLocal(databaseName)) { callerConsole.WriteLine(T(TDA_DELETED)); } else { @@ -283,7 +291,7 @@ protected function ListDatabases(EPlayer instigator) if (instigator == none) { return; } - availableDatabases = _.db.ListLocal(); + availableDatabases = _server.db.ListLocal(); console = callerConsole; console.Write(T(TAVAILABLE_DATABASES)); for (i = 0; i < availableDatabases.length; i += 1)