Beispiel #1
0
 public static void SetVersion(UPDATE_VERSION which, ELEMENT_VER version)
 {
     if (which == UPDATE_VERSION.Local)
     {
         Patcher.Instance.UpdateInfo.curVersion = version.ToString();
     }
     else if (which == UPDATE_VERSION.Server)
     {
         Patcher.Instance.UpdateInfo.serverVersion = version.ToString();
     }
 }
Beispiel #2
0
    //写本地版本文件
    public UpdateRetCode SetLocalVersion(ELEMENT_VER ver)
    {
        try
        {
            StreamWriter writer = FileOperate.CreateTextFile(strGameOldVerFile);
            if (writer == null)
            {
                return(UpdateRetCode.file_err);
            }

            writer.WriteLine(ver.ToString());
            writer.Close();
        }
        catch (Exception)
        {
            return(UpdateRetCode.file_err);
        }

        return(UpdateRetCode.success);
    }
Beispiel #3
0
    //如果本地文件不存在,设置为初始版本, 如果当前版本 < 初始版本,则写新版本, ret是否新写入baseVersion
    public bool SetFirstVersion(ELEMENT_VER ver, bool bForceWrite)
    {
        m_baseVer = ver;

        if (bForceWrite || !FileOperate.IsFileExist(strGameOldVerFile))
        {
            if (!FileOperate.MakeDir(strGameOldVerFile))
            {
                LogString(HobaText.Format("[SetFirstVersion] MakeDir {0} Failed!", strGameOldVerFile));
            }
            UpdateRetCode ret = SetLocalVersion(ver);
            if (ret != UpdateRetCode.success)
            {
                LogString(HobaText.Format("[SetFirstVersion] SetLocalVersion {0} Failed!", strGameOldVerFile));
            }
            else
            {
                return(true);
            }
        }
        else
        {
            ELEMENT_VER localVersion;
            if (GetLocalVersion(out localVersion) && localVersion < m_baseVer)
            {
                LogString(HobaText.Format("[SetFirstVersion] Local Version File Exist {0}! Write New Version From: {1} To {2}", strGameOldVerFile, localVersion.ToString(), ver.ToString()));

                if (!FileOperate.MakeDir(strGameOldVerFile))
                {
                    LogString(HobaText.Format("[SetFirstVersion] MakeDir {0} Failed2!", strGameOldVerFile));
                }
                UpdateRetCode ret = SetLocalVersion(ver);
                if (ret != UpdateRetCode.success)
                {
                    LogString(HobaText.Format("[SetFirstVersion] SetLocalVersion {0} Failed2!", strGameOldVerFile));
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                LogString(HobaText.Format("[SetFirstVersion] Local Version File Exist {0}!", strGameOldVerFile));
            }
        }

        return(false);
    }