Patch WebserverFlokuepDevelopTest

This commit is contained in:
Florian Küpper committed 2013-12-19 09:02:40 +01:00
1 parent 42b82f5b29
commit 0c807862a8
8 files changed
+277 -67

No files matched your search

+14 -12
View File
@@ -212,7 +212,7 @@ namespace Vocaluxe.Base
public static void LoadProfiles()
{
var change = new SChange {Action = EAction.LoadProfiles};
var change = new SChange { Action = EAction.LoadProfiles };
lock (_QueueMutex)
{
@@ -222,7 +222,7 @@ namespace Vocaluxe.Base
public static void LoadAvatars()
{
var change = new SChange {Action = EAction.LoadAvatars};
var change = new SChange { Action = EAction.LoadAvatars };
lock (_QueueMutex)
{
@@ -235,7 +235,7 @@ namespace Vocaluxe.Base
if (newProfile == null)
return;
var change = new SChange {Action = EAction.AddProfile, Profile = newProfile};
var change = new SChange { Action = EAction.AddProfile, Profile = newProfile };
lock (_QueueMutex)
{
@@ -248,7 +248,7 @@ namespace Vocaluxe.Base
if (editProfile == null)
return;
var change = new SChange {Action = EAction.EditProfile, Profile = editProfile};
var change = new SChange { Action = EAction.EditProfile, Profile = editProfile };
lock (_QueueMutex)
{
@@ -261,7 +261,7 @@ namespace Vocaluxe.Base
if (!IsProfileIDValid(profileID))
return;
var change = new SChange {Action = EAction.DeleteProfile, ProfileID = profileID};
var change = new SChange { Action = EAction.DeleteProfile, ProfileID = profileID };
lock (_QueueMutex)
{
@@ -274,7 +274,7 @@ namespace Vocaluxe.Base
if (newAvatar == null)
return;
var change = new SChange {Action = EAction.AddAvatar, Avatar = newAvatar};
var change = new SChange { Action = EAction.AddAvatar, Avatar = newAvatar };
lock (_QueueMutex)
{
@@ -287,7 +287,7 @@ namespace Vocaluxe.Base
if (editAvatar == null)
return;
var change = new SChange {Action = EAction.EditAvatar, Avatar = editAvatar};
var change = new SChange { Action = EAction.EditAvatar, Avatar = editAvatar };
lock (_QueueMutex)
{
@@ -310,9 +310,9 @@ namespace Vocaluxe.Base
if (!IsProfileIDValid(profileID))
{
return null;
}
}
return _Profiles[profileID];
return _Profiles[profileID];
}
public static IEnumerable<CAvatar> GetAvatars()
@@ -442,8 +442,10 @@ namespace Vocaluxe.Base
{
if (!IsProfileIDValid(profileID))
return;
_Profiles[profileID].UserRole = option;
//Only allow the change of TR_USERROLE_GUEST, TR_USERROLE_NORMAL and TR_USERROLE_ADMIN
const EUserRole mask = (EUserRole.TR_USERROLE_GUEST | EUserRole.TR_USERROLE_NORMAL | EUserRole.TR_USERROLE_ADMIN);
option &= mask;
_Profiles[profileID].UserRole = (_Profiles[profileID].UserRole & ~mask) | option;
}
public static EOffOn GetActive(int profileID)
@@ -464,7 +466,7 @@ namespace Vocaluxe.Base
if (!IsProfileIDValid(profileID))
return true; // this will prevent from saving dummy profiles to highscore db
return _Profiles[profileID].UserRole == EUserRole.TR_USERROLE_GUEST;
return _Profiles[profileID].UserRole.HasFlag(EUserRole.TR_USERROLE_GUEST);
}
public static bool IsActive(int profileID)
+21 -8
View File
@@ -228,7 +228,10 @@ namespace Vocaluxe.Base.Server
if (profile.Type >= 0 && profile.Type <= 1)
{
newProfile.UserRole = (EUserRole)profile.Type;
var option = profile.Type == 0 ? EUserRole.TR_USERROLE_GUEST : EUserRole.TR_USERROLE_NORMAL;
//Only allow the change of TR_USERROLE_GUEST and TR_USERROLE_NORMAL
const EUserRole mask = EUserRole.TR_USERROLE_NORMAL;
newProfile.UserRole = (newProfile.UserRole & mask) | option;
}
if (!string.IsNullOrEmpty(profile.Password))
@@ -281,10 +284,11 @@ namespace Vocaluxe.Base.Server
IsEditable = !isReadonly,
ProfileId = profile.ID,
PlayerName = profile.PlayerName,
Type = (int)profile.UserRole,
//Is TR_USERROLE_GUEST or TR_USERROLE_NORMAL?
Type = (profile.UserRole.HasFlag(EUserRole.TR_USERROLE_NORMAL)?1:0),
Difficulty = (int)profile.Difficulty
};
CAvatar avatar = profile.Avatar;
if (avatar != null)
{
@@ -502,7 +506,7 @@ namespace Vocaluxe.Base.Server
{
throw new ArgumentException("invalid songId");
}
if (position < 0 || CPlaylists.Playlists[playlistId].Songs.Count <= position
if (position < 0 || CPlaylists.Playlists[playlistId].Songs.Count <= position
|| CPlaylists.Playlists[playlistId].Songs[position].SongID != songId)
{
throw new ArgumentException("invalid position");
@@ -521,7 +525,7 @@ namespace Vocaluxe.Base.Server
{
throw new ArgumentException("invalid songId");
}
if (CPlaylists.Playlists[playlistId].Songs.Count < newPosition)
{
throw new ArgumentException("invalid newPosition");
@@ -673,7 +677,10 @@ namespace Vocaluxe.Base.Server
throw new ArgumentException("Invalid profileId");
}
return (int)profile.UserRole;
//Hide TR_USERROLE_GUEST and TR_USERROLE_NORMAL
const EUserRole mask = (EUserRole.TR_USERROLE_GUEST | EUserRole.TR_USERROLE_NORMAL);
return (int)(profile.UserRole & ~mask);
}
private static void _SetUserRole(int profileId, int userRole)
@@ -683,8 +690,14 @@ namespace Vocaluxe.Base.Server
{
throw new ArgumentException("Invalid profileId");
}
profile.UserRole = (EUserRole)userRole;
var option = (EUserRole)userRole;
//Only allow the change of all options exept TR_USERROLE_GUEST and TR_USERROLE_NORMAL
const EUserRole mask = (EUserRole.TR_USERROLE_GUEST | EUserRole.TR_USERROLE_NORMAL);
option &= ~mask;
profile.UserRole = (profile.UserRole & mask) | option;
CProfiles.EditProfile(profile);
CProfiles.Update();