Browse Source

Change `UserAPI` to make "all" user group contain all players

develop
Anton Tarasenko 1 year ago
parent
commit
a26b0adf05
  1. 35
      sources/Users/Users_Feature.uc

35
sources/Users/Users_Feature.uc

@ -70,16 +70,7 @@ var private LoggerAPI.Definition errDBContainsNonLowerRegister;
protected function OnEnabled() protected function OnEnabled()
{ {
local Commands_Feature feature;
_.users._reloadFeature(); _.users._reloadFeature();
feature =
Commands_Feature(class'Commands_Feature'.static.GetEnabledInstance());
if (feature != none)
{
feature.RegisterCommand(class'ACommandUserGroups');
feature.FreeSelf();
}
if (_server.IsAvailable()) { if (_server.IsAvailable()) {
LoadUserData(); LoadUserData();
SetupPersistentData(usePersistentData); SetupPersistentData(usePersistentData);
@ -96,9 +87,7 @@ protected function OnDisabled()
_.users._reloadFeature(); _.users._reloadFeature();
feature = feature =
Commands_Feature(class'Commands_Feature'.static.GetEnabledInstance()); Commands_Feature(class'Commands_Feature'.static.GetEnabledInstance());
if (feature != none) if (feature != none) {
{
feature.RemoveCommand(class'ACommandUserGroups');
feature.FreeSelf(); feature.FreeSelf();
} }
ResetUploadedUserGroups(); ResetUploadedUserGroups();
@ -590,9 +579,9 @@ public final function bool AddGroup(BaseText groupName)
local Text lowerCaseGroupName; local Text lowerCaseGroupName;
local HashTable emptyHashTable; local HashTable emptyHashTable;
if (groupName == none) { if (groupName == none) return false;
return false; if (groupName.Compare(P("all"), SCASE_INSENSITIVE)) return false;
}
lowerCaseGroupName = groupName.LowerCopy(); lowerCaseGroupName = groupName.LowerCopy();
if (loadedGroupToUsersMap.HasKey(lowerCaseGroupName)) if (loadedGroupToUsersMap.HasKey(lowerCaseGroupName))
{ {
@ -676,9 +665,9 @@ public final function bool RemoveGroup(BaseText groupName)
local bool groupExists; local bool groupExists;
local Text lowerCaseGroupName; local Text lowerCaseGroupName;
if (groupName == none) { if (groupName == none) return false;
return false; if (groupName.Compare(P("all"), SCASE_INSENSITIVE)) return false;
}
lowerCaseGroupName = groupName.LowerCopy(); lowerCaseGroupName = groupName.LowerCopy();
groupExists = loadedGroupToUsersMap.HasKey(lowerCaseGroupName); groupExists = loadedGroupToUsersMap.HasKey(lowerCaseGroupName);
if (!groupExists) if (!groupExists)
@ -754,9 +743,9 @@ public final function bool IsGroupExisting(BaseText groupName)
local bool result; local bool result;
local Text lowerCaseGroupName; local Text lowerCaseGroupName;
if (groupName == none) { if (groupName == none) return false;
return false; if (groupName.Compare(P("all"), SCASE_INSENSITIVE)) return true;
}
lowerCaseGroupName = groupName.LowerCopy(); lowerCaseGroupName = groupName.LowerCopy();
result = loadedGroupToUsersMap.HasKey(lowerCaseGroupName); result = loadedGroupToUsersMap.HasKey(lowerCaseGroupName);
lowerCaseGroupName.FreeSelf(); lowerCaseGroupName.FreeSelf();
@ -811,6 +800,7 @@ public final function bool AddSteamIDToGroup(
if (steamID == none) return false; if (steamID == none) return false;
if (loadedGroupToUsersMap == none) return false; if (loadedGroupToUsersMap == none) return false;
if (groupName == none) return false; if (groupName == none) return false;
if (groupName.Compare(P("all"), SCASE_INSENSITIVE)) return true;
lowercaseGroupName = groupName.LowerCopy(); lowercaseGroupName = groupName.LowerCopy();
groupUsers = loadedGroupToUsersMap.GetHashTable(lowercaseGroupName); groupUsers = loadedGroupToUsersMap.GetHashTable(lowercaseGroupName);
@ -1000,6 +990,7 @@ public final function bool RemoveSteamIDFromGroup(
if (steamID == none) return false; if (steamID == none) return false;
if (groupName == none) return false; if (groupName == none) return false;
if (groupName.Compare(P("all"), SCASE_INSENSITIVE)) return false;
if (loadedGroupToUsersMap == none) return false; if (loadedGroupToUsersMap == none) return false;
lowercaseGroupName = groupName.LowerCopy(); lowercaseGroupName = groupName.LowerCopy();
@ -1195,6 +1186,7 @@ public final function array<Text> GetGroupsForSteamID(BaseText steamID)
if (loadedGroupToUsersMap == none) return result; if (loadedGroupToUsersMap == none) return result;
if (steamID == none) return result; if (steamID == none) return result;
result[0] = P("all").Copy();
immutableSteamID = steamID.LowerCopy(); immutableSteamID = steamID.LowerCopy();
iter = HashTableIterator(loadedGroupToUsersMap.Iterate()); iter = HashTableIterator(loadedGroupToUsersMap.Iterate());
while (!iter.HasFinished()) while (!iter.HasFinished())
@ -1962,6 +1954,7 @@ public final function bool IsSteamIDInGroup(
if (loadedGroupToUsersMap == none) return false; if (loadedGroupToUsersMap == none) return false;
if (groupName == none) return false; if (groupName == none) return false;
if (groupName.Compare(P("all"), SCASE_INSENSITIVE)) return true;
if (steamID == none) return false; if (steamID == none) return false;
lowerGroupName = groupName.LowerCopy(); lowerGroupName = groupName.LowerCopy();

Loading…
Cancel
Save