Use GUID instead of int for player-ids; ID is now unique and saved to player.xml-file

This commit is contained in:
Florian Küpper committed 2015-12-23 14:23:55 +01:00
1 parent 804647f480
commit e3497641dd
29 files changed
+275 -235

No files matched your search

+11 -1
View File
@@ -42,7 +42,7 @@ namespace VocaluxeLib.Profile
#pragma warning restore 649
}
[XmlIgnore] public int ID;
[DefaultValue(null)] public Guid ID;
public string PlayerName;
[XmlIgnore] public string FilePath;
@@ -73,6 +73,7 @@ namespace VocaluxeLib.Profile
public CProfile()
{
ID = Guid.NewGuid();
PlayerName = String.Empty;
Difficulty = EGameDifficulty.TR_CONFIG_EASY;
UserRole = EUserRole.TR_USERROLE_NORMAL;
@@ -92,6 +93,12 @@ namespace VocaluxeLib.Profile
try
{
xml.Deserialize(FilePath, this);
//If ID couldn't be loaded, generate a new one and save it
if (ID == Guid.Empty)
{
ID = Guid.NewGuid();
SaveProfile();
}
}
catch (Exception e)
{
@@ -112,7 +119,10 @@ namespace VocaluxeLib.Profile
var old = xml.Deserialize<SOldXmlProfile>(FilePath);
string newXml = ser.Serialize(old.Info);
xml.DeserializeString(newXml, this);
if (ID == null)
ID = Guid.NewGuid();
ser.Serialize(FilePath, this);
}
catch (Exception e2)
{