Esempio n. 1
0
 public static PlayerOwnServerId ReadPlayer(string playerName, ref bool isNewUser)
 {
     try
     {
         string root = Data.RootPath + "/Players";
         if (!Directory.Exists(root))
         {
             Directory.CreateDirectory(root);
         }
         root += "/" + playerName + ".bin";
         if (!File.Exists(root))
         {
             isNewUser = true;
         }
         Stream            file      = __FILE_GETSTREAM(root);
         BinaryFormatter   binFormat = new BinaryFormatter();
         PlayerOwnServerId llc       = (PlayerOwnServerId)binFormat.Deserialize(file);
         return(llc);
     }
     catch
     {
         isNewUser = true;
         return(new PlayerOwnServerId());
     }
 }
Esempio n. 2
0
 public static void WritePlayer(string playerName, PlayerOwnServerId playerData)
 {
     try
     {
         string          root      = Data.RootPath + "/Players/" + playerName + ".bin";
         Stream          file      = __FILE_GETSTREAM(root);
         BinaryFormatter binFormat = new BinaryFormatter();
         binFormat.Serialize(file, playerData);
     }
     catch
     {
         Logger.WriteLine(LogLevel.Info, "存储玩家 " + playerName + " 的存档时出现问题,但这可能并不严重。如果短时间内多次出现关于此玩家的类似消息,需要强制登出玩家。");
     }
 }