Fixes #1239
This commit is contained in:
parent
ad2f56e251
commit
b9046da5f4
1 changed files with 26 additions and 27 deletions
|
|
@ -418,13 +418,16 @@ namespace TShockAPI.DB
|
||||||
Region r = GetRegionByName(regionName);
|
Region r = GetRegionByName(regionName);
|
||||||
if (r != null)
|
if (r != null)
|
||||||
{
|
{
|
||||||
r.RemoveID(TShock.Users.GetUserID(userName));
|
if (!r.RemoveID(TShock.Users.GetUserID(userName)))
|
||||||
string ids = string.Join(",", r.AllowedIDs);
|
{
|
||||||
int q = database.Query("UPDATE Regions SET UserIds=@0 WHERE RegionName=@1 AND WorldID=@2", ids,
|
return false;
|
||||||
regionName, Main.worldID.ToString());
|
|
||||||
if (q > 0)
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string ids = string.Join(",", r.AllowedIDs);
|
||||||
|
return database.Query("UPDATE Regions SET UserIds=@0 WHERE RegionName=@1 AND WorldID=@2", ids,
|
||||||
|
regionName, Main.worldID.ToString()) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -765,16 +768,18 @@ namespace TShockAPI.DB
|
||||||
/// <param name="ids">String of IDs to set</param>
|
/// <param name="ids">String of IDs to set</param>
|
||||||
public void SetAllowedIDs(String ids)
|
public void SetAllowedIDs(String ids)
|
||||||
{
|
{
|
||||||
String[] id_arr = ids.Split(',');
|
String[] idArr = ids.Split(',');
|
||||||
List<int> id_list = new List<int>();
|
List<int> idList = new List<int>();
|
||||||
foreach (String id in id_arr)
|
|
||||||
|
foreach (String id in idArr)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int.TryParse(id, out i);
|
if (int.TryParse(id, out i) && i != 0)
|
||||||
if (i != 0)
|
{
|
||||||
id_list.Add(i);
|
idList.Add(i);
|
||||||
}
|
}
|
||||||
AllowedIDs = id_list;
|
}
|
||||||
|
AllowedIDs = idList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -786,12 +791,14 @@ namespace TShockAPI.DB
|
||||||
// prevent null pointer exceptions
|
// prevent null pointer exceptions
|
||||||
if (!string.IsNullOrEmpty(groups))
|
if (!string.IsNullOrEmpty(groups))
|
||||||
{
|
{
|
||||||
List<String> groupArr = groups.Split(',').ToList();
|
List<String> groupList = groups.Split(',').ToList();
|
||||||
|
|
||||||
for (int i = 0; i < groupArr.Count; i++)
|
for (int i = 0; i < groupList.Count; i++)
|
||||||
groupArr[i] = groupArr[i].Trim();
|
{
|
||||||
|
groupList[i] = groupList[i].Trim();
|
||||||
|
}
|
||||||
|
|
||||||
AllowedGroups = groupArr;
|
AllowedGroups = groupList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -799,18 +806,10 @@ namespace TShockAPI.DB
|
||||||
/// Removes a user's access to the region
|
/// Removes a user's access to the region
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">User ID to remove</param>
|
/// <param name="id">User ID to remove</param>
|
||||||
public void RemoveID(int id)
|
/// <returns>true if the user was found and removed from the region's allowed users</returns>
|
||||||
|
public bool RemoveID(int id)
|
||||||
{
|
{
|
||||||
var index = -1;
|
return AllowedIDs.Remove(id);
|
||||||
for (int i = 0; i < AllowedIDs.Count; i++)
|
|
||||||
{
|
|
||||||
if (AllowedIDs[i] == id)
|
|
||||||
{
|
|
||||||
index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AllowedIDs.RemoveAt(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue