|
|
@ -156,6 +156,166 @@ private final function SaveLocalData() |
|
|
|
_.memory.Free(activeConfigName); |
|
|
|
_.memory.Free(activeConfigName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns names of all available groups that users can belong to. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* In case this feature is configured to load user groups from a database |
|
|
|
|
|
|
|
* (either local or remote), the returned value is a locally cached one. |
|
|
|
|
|
|
|
* This helps us avoid having to query database each time we want to check |
|
|
|
|
|
|
|
* something about user groups, but it also means we might have an outdated |
|
|
|
|
|
|
|
* information. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return Array with names of all available groups. |
|
|
|
|
|
|
|
* All array elements are guaranteed to be not-`none`, unique and in |
|
|
|
|
|
|
|
* lower case. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public final function array<Text> GetAvailableGroups() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local int i; |
|
|
|
|
|
|
|
local array<Text> result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < loadedUserGroups.length; i += 1) { |
|
|
|
|
|
|
|
result[i] = loadedUserGroups[i].Copy(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final function bool AddSteamIDToGroup( |
|
|
|
|
|
|
|
BaseText steamID, |
|
|
|
|
|
|
|
BaseText groupName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local Text lowercaseGroupName; |
|
|
|
|
|
|
|
local HashTable groupUsers; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (loadedGroupToUsersMap == none) return false; |
|
|
|
|
|
|
|
if (groupName == none) return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lowercaseGroupName = groupName.LowerCopy(); |
|
|
|
|
|
|
|
groupUsers = loadedGroupToUsersMap.GetHashTable(lowercaseGroupName); |
|
|
|
|
|
|
|
lowercaseGroupName.FreeSelf(); |
|
|
|
|
|
|
|
if (groupUsers == none) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
groupUsers.SetItem(steamID, none); |
|
|
|
|
|
|
|
groupUsers.FreeSelf(); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final /*unreal*/ function bool AddSteamIDToGroup_S( |
|
|
|
|
|
|
|
string steamID, |
|
|
|
|
|
|
|
string groupName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local bool result; |
|
|
|
|
|
|
|
local MutableText idWrapper, groupWrapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
idWrapper = _.text.FromStringM(steamID); |
|
|
|
|
|
|
|
groupWrapper = _.text.FromStringM(groupName); |
|
|
|
|
|
|
|
result = AddSteamIDToGroup(idWrapper, groupWrapper); |
|
|
|
|
|
|
|
idWrapper.FreeSelf(); |
|
|
|
|
|
|
|
groupWrapper.FreeSelf(); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final function bool AddUserIDToGroup( |
|
|
|
|
|
|
|
UserID id, |
|
|
|
|
|
|
|
BaseText groupName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local bool result; |
|
|
|
|
|
|
|
local Text steamID; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (groupName == none) return false; |
|
|
|
|
|
|
|
if (id == none) return false; |
|
|
|
|
|
|
|
steamID = id.GetSteamID64String(); |
|
|
|
|
|
|
|
if (steamID == none) return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = AddSteamIDToGroup(steamID, groupName); |
|
|
|
|
|
|
|
steamID.FreeSelf(); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final function bool AddUserToGroup(User user, BaseText groupName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local bool result; |
|
|
|
|
|
|
|
local UserID id; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (groupName == none) return false; |
|
|
|
|
|
|
|
if (user == none) return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
id = user.GetID(); |
|
|
|
|
|
|
|
result = AddUserIDToGroup(id, groupName); |
|
|
|
|
|
|
|
_.memory.Free(id); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final function bool RemoveSteamIDFromGroup( |
|
|
|
|
|
|
|
BaseText steamID, |
|
|
|
|
|
|
|
BaseText groupName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local bool hadUser; |
|
|
|
|
|
|
|
local Text lowercaseGroupName; |
|
|
|
|
|
|
|
local HashTable groupUsers; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (groupName == none) return false; |
|
|
|
|
|
|
|
if (loadedGroupToUsersMap == none) return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lowercaseGroupName = groupName.LowerCopy(); |
|
|
|
|
|
|
|
groupUsers = loadedGroupToUsersMap.GetHashTable(lowercaseGroupName); |
|
|
|
|
|
|
|
lowercaseGroupName.FreeSelf(); |
|
|
|
|
|
|
|
if (groupUsers == none) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
hadUser = groupUsers.HasKey(steamID); |
|
|
|
|
|
|
|
groupUsers.RemoveItem(steamID); |
|
|
|
|
|
|
|
groupUsers.FreeSelf(); |
|
|
|
|
|
|
|
return hadUser; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final /*unreal*/ function bool RemoveSteamIDFromGroup_S( |
|
|
|
|
|
|
|
string steamID, |
|
|
|
|
|
|
|
string groupName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local bool result; |
|
|
|
|
|
|
|
local MutableText idWrapper, groupWrapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
idWrapper = _.text.FromStringM(steamID); |
|
|
|
|
|
|
|
groupWrapper = _.text.FromStringM(groupName); |
|
|
|
|
|
|
|
result = RemoveSteamIDFromGroup(idWrapper, groupWrapper); |
|
|
|
|
|
|
|
idWrapper.FreeSelf(); |
|
|
|
|
|
|
|
groupWrapper.FreeSelf(); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final function bool RemoveUserIDFromGroup( |
|
|
|
|
|
|
|
UserID id, |
|
|
|
|
|
|
|
BaseText groupName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local bool result; |
|
|
|
|
|
|
|
local Text steamID; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (groupName == none) return false; |
|
|
|
|
|
|
|
if (id == none) return false; |
|
|
|
|
|
|
|
steamID = id.GetSteamID64String(); |
|
|
|
|
|
|
|
if (steamID == none) return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = RemoveSteamIDFromGroup(steamID, groupName); |
|
|
|
|
|
|
|
steamID.FreeSelf(); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final function bool RemoveUserFromGroup(User user, BaseText groupName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local bool result; |
|
|
|
|
|
|
|
local UserID id; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (groupName == none) return false; |
|
|
|
|
|
|
|
if (user == none) return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
id = user.GetID(); |
|
|
|
|
|
|
|
result = RemoveUserIDFromGroup(id, groupName); |
|
|
|
|
|
|
|
_.memory.Free(id); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns names of all groups available for the user with a SteamID given by |
|
|
|
* Returns names of all groups available for the user with a SteamID given by |
|
|
|
* `steamID`. |
|
|
|
* `steamID`. |
|
|
@ -176,8 +336,7 @@ private final function SaveLocalData() |
|
|
|
* If passed SteamID is `none` or data wasn't yet loaded - returns empty |
|
|
|
* If passed SteamID is `none` or data wasn't yet loaded - returns empty |
|
|
|
* array. |
|
|
|
* array. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public final /*unreal*/ function array<Text> GetGroupsForSteamID( |
|
|
|
public final function array<Text> GetGroupsForSteamID(BaseText steamID) |
|
|
|
BaseText steamID) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
local Text immutableSteamID; |
|
|
|
local Text immutableSteamID; |
|
|
|
local array<Text> result; |
|
|
|
local array<Text> result; |
|
|
@ -316,7 +475,7 @@ public final function array<Text> GetGroupsForUser(User user) |
|
|
|
* correspond to unique players. |
|
|
|
* correspond to unique players. |
|
|
|
* If data wasn't yet loaded - returns empty array. |
|
|
|
* If data wasn't yet loaded - returns empty array. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public final function array<UserID> GetGroupMembers(Text groupName) |
|
|
|
public final function array<UserID> GetGroupMembers(BaseText groupName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
local int i; |
|
|
|
local int i; |
|
|
|
local Text lowerCaseGroupName; |
|
|
|
local Text lowerCaseGroupName; |
|
|
|