Ejemplo n.º 1
0
    public bool AddTable(string key, LoadComplateCB lcCB)
    {
        if (tableList_ == null)
        {
            try {
                hashWaiting_.Add(key, lcCB);
            } catch {
                MagiDebug.LogError(string.Format("Table key already {0}", key));
            }
            return(true);
        }
        else
        {
            string tableName;
            if (hashTableName_.TryGetValue(key, out tableName) == false)
            {
                if (key.Contains("weapontrail") || key.Contains("sound"))
                {
                    MagiDebug.Log(string.Format("{0} table not found.", key));
                    return(false);
                }

                MagiDebug.LogError(string.Format("{0} table not found.", key));
                return(false);
            }
            StartCoroutine(OpenTable(key, tableName, lcCB));
        }
        return(true);
    }
Ejemplo n.º 2
0
    void TableListLoadComplateCB(Table table)
    {
        if (table == null)
        {
            return;
        }
        tableList_ = table;
        string name, filename;

        foreach (var id in tableList_.Line.Keys)
        {
            tableList_.GetString(out name, id, "szName", true);
            tableList_.GetString(out filename, id, "szTableFile", true);
            if (name == "")
            {
                continue;
            }
            if (hashTableName_.ContainsKey(name) == true)
            {
                MagiDebug.LogError(string.Format("tablelist already key = , {0}", name));
                continue;
            }
            hashTableName_.Add(name, filename);
        }
        loadComplate_ = true;
    }
Ejemplo n.º 3
0
    public static bool ReadAssetBundleCheckInfo(out Dictionary <string, CAssetBundleCheck> hashAssetBundleCheck, string filename)
    {
        hashAssetBundleCheck = new Dictionary <string, CAssetBundleCheck>();
        if (File.Exists(filename) == false)
        {
            return(false);
        }
        string[] pathFile = File.ReadAllLines(filename);

        char[] separators = new char[] { ',' };
        foreach (string file in pathFile)
        {
            string[] assetBundleCheck = file.Split(separators);
            if (assetBundleCheck.Length != 4)
            {
                MagiDebug.LogError("assetBundleCheck.Length != 4");
                return(false);
            }

            CAssetBundleCheck abc = new CAssetBundleCheck();
            abc.count = System.UInt32.Parse(assetBundleCheck[1], System.Globalization.NumberStyles.Integer);
            abc.size  = System.UInt64.Parse(assetBundleCheck[2], System.Globalization.NumberStyles.Integer);
            abc.crc   = System.UInt64.Parse(assetBundleCheck[3], System.Globalization.NumberStyles.Integer);

            hashAssetBundleCheck.Add(assetBundleCheck[0], abc);
        }
        return(true);
    }
Ejemplo n.º 4
0
 public void ErrorMessageBox(int id, string columnName, bool errorCheck)
 {
     if (errorCheck == false)
     {
         return;
     }
     MagiDebug.LogError(string.Format("Table = {0}, ID = {1}, Column = {2}", name_, id, columnName));
 }
Ejemplo n.º 5
0
    /// <summary>
    /// <para>name : Send</para>
    /// <para>parameter : string</para>
    /// <para>return : void</para>
    /// <para>describe : Send message if socket is not closed.</para>
    /// </summary>
    void Send(string message)
    {
        try {
            byte[] sendBuffer = new UTF8Encoding().GetBytes(message);
            tcpSocket.BeginSend(sendBuffer, 0, sendBuffer.Length, SocketFlags.None, new System.AsyncCallback(TcpSendCallBack), message);
        } catch (SocketException ex) {
            MagiDebug.LogError(string.Format("Send Fail. {0}", ex.Message));

            CloseSocket(SendMessageErrorType.RES_SEND_RETRY);
            InitSocket();
        } catch (System.ObjectDisposedException obEx) {
            MagiDebug.LogError(string.Format("Socket DisposedException, {0}", obEx));
            InitSocket(false);
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// <para>name : BeginConnect</para>
    /// <para>parameter : </para>
    /// <para>return : void</para>
    /// <para>describe : Begin connect if socket is not connected.</para>
    /// </summary>
    void BeginConnect()
    {
        doConnect = false;

        if (tcpSocket == null ||
            tcpSocket.Connected)
        {
            return;
        }

        try {
            tcpSocket.BeginConnect(ipAddress, port, new System.AsyncCallback(TcpConnectCallBack), tcpSocket);
        } catch (SocketException ex) {
            MagiDebug.LogError(string.Format("Connect Fail. {0}:{1}, {2}", ipAddress, port, ex));
            InitSocket();
        } catch (System.ObjectDisposedException obEx) {
            MagiDebug.LogError(string.Format("Socket DisposedException, {0}", obEx));
            InitSocket(false);
        }
    }
Ejemplo n.º 7
0
    public bool ReadColumnName(int nColumnNum, ref Table table, BinaryReader binReader)
    {
        string strName = "";

        if (table == null)
        {
            return(false);
        }

        try {
            table.ColumnName.Clear();
            for (int i = 0; i < nColumnNum; i++)
            {
                ReadString(out strName, binReader);
                table.ColumnName.Add(strName, i);
                strName = "";
            }
        } catch (Exception ex) {
            MagiDebug.LogError(string.Format("{0}, {1}, {2}, {3}", table.Name, strName, nColumnNum, ex.Message));
        }
        return(true);
    }
Ejemplo n.º 8
0
        public bool GetFloatSplit(out float[] value, int id, string columnName, bool errorCheck, params char[] separator)
        {
            int    index = GetIndex(columnName);
            string temp;
            bool   result = GetString(out temp, id, index, columnName, errorCheck);

            if (temp == "")
            {
                value = null;
                return(true);
            }
            string[] valueTemp = temp.Split(separator);
            value = new float[valueTemp.Length];
            for (int i = 0; i < valueTemp.Length; ++i)
            {
                try {
                    value[i] = Convert.ToSingle(valueTemp[i]);
                } catch {
                    MagiDebug.LogError(string.Format("GetFloatSplit Error - {0}, {1}", id, columnName));
                }
            }
            return(result);
        }
Ejemplo n.º 9
0
        public bool GetVectorSplit(out Vector3 vector, int id, string columnName, bool errorCheck, params char[] separator)
        {
            int    index = GetIndex(columnName);
            string temp;
            bool   result = GetString(out temp, id, index, columnName, errorCheck);

            vector = Vector3.zero;

            if (temp == "")
            {
                return(true);
            }

            string[] valueTemp = temp.Split(separator);
            float[]  value     = new float[valueTemp.Length];

            if (value.Length > 3)
            {
                MagiDebug.LogError(string.Format("GetVectorSplit Error - more 3 vec."));
                return(false);
            }

            for (int i = 0; i < valueTemp.Length; ++i)
            {
                try {
                    value[i] = Convert.ToSingle(valueTemp[i]);
                } catch {
                    MagiDebug.LogError(string.Format("GetVectorSplit Error - {0}, {1}", id, columnName));
                }
            }

            Vector3 reVec = new Vector3(value[0], value[1], value[2]);

            vector = reVec;

            return(result);
        }
Ejemplo n.º 10
0
    IEnumerator OpenTable(string key, string tableName, LoadComplateCB lcCB)
    {
        string url = "";

        MemoryStream stream = null;

        switch (OptionManager.Instance.pathType)
        {
        case OptionManager.EPathType.Develop: {
            url = OptionManager.ROOT_PATH + "/" + tableUrl_ + "/bytes/" + tableName + ".bytes";

            TextAsset bytes = Resources.LoadAssetAtPath(url, typeof(TextAsset)) as TextAsset;
            if (bytes == null)
            {
                MagiDebug.Log(string.Format("{0}, bytes==null", url));
                break;
            }
            stream = new MemoryStream(bytes.bytes);
        }
        break;

        case OptionManager.EPathType.Live: {
            AssetBundle assetBundle;
            if (PatchManager.Instance.FindAssetBundle("table", out assetBundle))
            {
                TextAsset bytes = assetBundle.Load(key, typeof(TextAsset)) as TextAsset;
                if (bytes == null)
                {
                    MagiDebug.LogError(key + " table not found.");
                    yield break;
                }

                stream = new MemoryStream(bytes.bytes);
            }
        }
        break;
        }

        if (stream == null)
        {
            MagiDebug.Log(stream + "," + key + "," + tableName);
            yield break;
        }

        BinaryReader binReader = new BinaryReader(stream);
        Table        table     = new Table(key);

        int lineNum   = binReader.ReadInt32();
        int columnNum = binReader.ReadInt32();

        if (ReadColumnName(columnNum, ref table, binReader) == false)
        {
            yield break;
        }
        if (ReadColumnType(columnNum, ref table, binReader) == false)
        {
            yield break;
        }

        for (int i = 0; i < lineNum; i++)
        {
            if (ReadData(columnNum, ref table, binReader) == false)
            {
                yield break;
            }
        }

        try {
            hashTable_.Add(key, table);
        } catch {
            MagiDebug.LogError(string.Format("Table key already {0}, {1}", key, tableName));
        }
        if (lcCB != null)
        {
            lcCB(table);
        }
    }
Ejemplo n.º 11
0
    public bool ReadData(int nColumnNum, ref Table table, BinaryReader binReader)
    {
        SLineTable lineTable = new SLineTable();

        try {
            foreach (var columnType in table.ColumnType)
            {
                switch (columnType)
                {
                case Table.Type.INT: {
                    int nInt = binReader.ReadInt32();
                    lineTable.listIndex.Add(nInt);
                }
                break;

                case Table.Type.FLOAT: {
                    float fFloat = binReader.ReadSingle();
                    lineTable.listFloat.Add(fFloat);
                    int nIdx = lineTable.listFloat.Count - 1;
                    lineTable.listIndex.Add(nIdx);
                }
                break;

                case Table.Type.STRING: {
                    string strString;
                    ReadString(out strString, binReader);
                    lineTable.listString.Add(strString);
                    int nIdx = lineTable.listString.Count - 1;
                    lineTable.listIndex.Add(nIdx);
                }
                break;

                case Table.Type.WSTRING: {
                    string strString;
                    ReadWString(out strString, binReader);
                    lineTable.listWString.Add(strString);
                    int nIdx = lineTable.listWString.Count - 1;
                    lineTable.listIndex.Add(nIdx);
                }
                break;

                case Table.Type.INT64: {
                    long nInt64 = binReader.ReadInt64();
                    lineTable.listInt64.Add(nInt64);
                    int nIdx = lineTable.listInt64.Count - 1;
                    lineTable.listIndex.Add(nIdx);
                }
                break;
                }
                ;
            }

            if (lineTable.listIndex.Count == 0)
            {
                return(false);
            }

            table.Line.Add(lineTable.listIndex[0], lineTable);
        } catch (Exception ex) {
            MagiDebug.LogError(string.Format("{0}, {1}, {2}", table.Name, lineTable.listIndex[0], ex.Message));
        }
        return(true);
    }
Ejemplo n.º 12
0
    static void ExecutePatch(string local, string target)
    {
        //        System.DateTime nowDateTime = System.DateTime.Now.ToString("yyyy-MM-dd_HH:mm:ss");
        System.DateTime nowDateTime = System.DateTime.Now;

        BuildTarget buildTarget;
        string      targetPath = "";

        switch (target)
        {
        case "Android": {
            targetPath  = "android/";
            buildTarget = BuildTarget.Android;
        }
        break;

        case "iPhone": {
            targetPath  = "iphone/";
            buildTarget = BuildTarget.iPhone;
        }
        break;

        default:
            return;
        }

        string localPath = local.ToLower() + "/";

        //patch revision info 로딩.
        int    lastRevision          = 0;
        string version               = "";
        string infoPatchRevisionInfo = GetAssetbundlePath(buildTarget) + localPath + targetPath + @"patchRevisionInfo.txt";

        if (File.Exists(infoPatchRevisionInfo) == true)
        {
            string[] infoPatchRevision = File.ReadAllLines(infoPatchRevisionInfo);
            if (infoPatchRevision.Length <= 2)
            {
                MagiDebug.LogError(string.Format("{0} file error", infoPatchRevisionInfo));
                return;
            }

            lastRevision = System.Int32.Parse(infoPatchRevision[0]);
            version      = infoPatchRevision[1];
        }

        else
        {
            version = nowDateTime.ToString("yyyy-MM-dd_HH:mm:ss");
        }

        lastRevision++;

        EditorUtility.UnloadUnusedAssets();

        string lastAssetBundleCheckInfoFileName = "AssetBundleCheckInfo3_" + target + ".txt";
        //        Object[] listObject = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);

        List <string> fileList;

        GetPrefabsFolderFileNameList(out fileList);

        //pathlist 작업.
        string newAssetbundlePath = GetAssetbundlePath(buildTarget) + localPath + targetPath + lastRevision.ToString() + "/";
        string lastAssetBundleCheckInfoPathName = System.Environment.CurrentDirectory + @"/Assets/Prefabs/" + lastAssetBundleCheckInfoFileName;
        string errorListPath = System.Environment.CurrentDirectory + @"/Assets/Prefabs/" + "AssetBundleError.txt";

        Dictionary <string, CAssetBundleCheck> lastAssetBundleCheckInfo = new Dictionary <string, CAssetBundleCheck>();

        ReadAssetBundleCheckInfo(out lastAssetBundleCheckInfo, lastAssetBundleCheckInfoPathName);
        Dictionary <string, CAssetBundleCheck> assetBundleCheckInfo = new Dictionary <string, CAssetBundleCheck>();

        Dictionary <string, List <Object> > hashAssetBundle = new Dictionary <string, List <Object> >();
        //        for (int i = 0; i < listObject.Length; ++i)
        //        {
        //            Object o = listObject[i];

        List <ePatchInfo> newPathInfoAssetBundle = new List <ePatchInfo>();
        ePatchInfo        currentPatchInfo       = new ePatchInfo();

        for (int i = 0; i < fileList.Count; ++i)
        {
            Object o = null;
            try {
                o = AssetDatabase.LoadMainAssetAtPath(fileList[i]);
            } catch {
                MagiDebug.LogError(string.Format("AssetDatabase.LoadMainAssetAtPath error, {0}", fileList[i]));
                continue;
            }

            if (o == null)
            {
                MagiDebug.LogError("AssetDatabase.LoadMainAssetAtPath == false, " + fileList[i]);
                continue;
            }
            //Object o = fileList[i];

            //            MagiDebug.Log(o);

            string assetPath = AssetDatabase.GetAssetPath(o).ToLower();
            if (assetPath.Contains("assets/prefabs/") == false)
            {
                continue;
            }
            if (assetPath.Contains("assets/prefabs/pathinfo") == true)
            {
                continue;
            }
            if (assetPath.Contains("assets/prefabs/patchrevisioninfo.txt") == true)
            {
                continue;
            }

            float s = (float)i / fileList.Count;
            EditorUtility.DisplayProgressBar("Make AssetBundleCheckInfo", assetPath, s);

            string assetBundleName = GetAssetBundleName(assetPath);
            if (assetBundleName == "")
            {
                continue;
            }

            if (assetBundleCheckInfo.ContainsKey(assetBundleName) == true)
            {
                CAssetBundleCheck temp = assetBundleCheckInfo[assetBundleName];
                GetAssetBundleCheck(o, ref temp);
            }
            else
            {
                CAssetBundleCheck temp = new CAssetBundleCheck();
                GetAssetBundleCheck(o, ref temp);
                assetBundleCheckInfo.Add(assetBundleName, temp);
            }

            if (hashAssetBundle.ContainsKey(assetBundleName) == true)
            {
                hashAssetBundle[assetBundleName].Add(o);
            }
            else
            {
                var listO = new List <Object>();
                listO.Add(o);
                hashAssetBundle.Add(assetBundleName, listO);
            }

            System.GC.Collect();
            for (int n = 0; n < System.GC.MaxGeneration; ++n)
            {
                System.GC.Collect(n, System.GCCollectionMode.Forced);
            }
            System.GC.WaitForPendingFinalizers();
            EditorUtility.UnloadUnusedAssets();
        }
        EditorUtility.ClearProgressBar();

        if (assetBundleCheckInfo.Count == 0)
        {
            return;
        }

        string buildAssetBundle = System.Environment.CurrentDirectory + @"/Assets/Prefabs/" + "BuildAssetBundle.txt";

        int  c   = 0;
        uint crc = 0;

        foreach (var p in hashAssetBundle)
        {
            c++;
            float s = (float)c / hashAssetBundle.Count;
            EditorUtility.DisplayProgressBar("BuildAssetBundle", p.Key, s);

            CAssetBundleCheck abc;
            if (assetBundleCheckInfo.TryGetValue(p.Key, out abc) == false)
            {
                continue;
            }

            if (lastAssetBundleCheckInfo.ContainsKey(p.Key) == true)
            {
                CAssetBundleCheck lastAbc;
                lastAssetBundleCheckInfo.TryGetValue(p.Key, out lastAbc);
                if (abc.count == lastAbc.count && abc.crc == lastAbc.crc && abc.size == lastAbc.size)
                {
                    continue;
                }
            }

            string path = newAssetbundlePath + p.Key + ".assetbundle";
            MagiDebug.Log(path);

            if (!Directory.Exists(newAssetbundlePath))
            {
                Directory.CreateDirectory(newAssetbundlePath);
            }

            File.WriteAllText(buildAssetBundle, path);

            BuildPipeline.PushAssetDependencies();

            if (BuildPipeline.BuildAssetBundle(p.Value[0], p.Value.ToArray(), path, out crc, BuildAssetBundleOptions.CollectDependencies, buildTarget) == false)
            {
                MagiDebug.LogError("BuildPipeline.BuildAssetBundle == false, " + path);
            }

            BuildPipeline.PopAssetDependencies();

            currentPatchInfo         = new ePatchInfo();
            currentPatchInfo.key     = p.Key;
            currentPatchInfo.version = lastRevision;
            currentPatchInfo.crc     = crc;

            newPathInfoAssetBundle.Add(currentPatchInfo);
        }

        EditorUtility.ClearProgressBar();

        // 패치할 파일이 없으면 pass
        if (newPathInfoAssetBundle.Count == 0)
        {
            return;
        }

        //revision 버젼 저장.
        List <ePatchInfo> finalPatchInfo = new List <ePatchInfo>();

        if (File.Exists(infoPatchRevisionInfo) == true)
        {
            string[] infoPatchRevision = File.ReadAllLines(infoPatchRevisionInfo);
            if (infoPatchRevision.Length <= 2)
            {
                MagiDebug.LogError(string.Format("{0} file error", infoPatchRevisionInfo));
                return;
            }

            ePatchInfo newPatchInfo;
            ePatchInfo patchInfo;
            string[]   szAssetBundleInfo;
            for (int i = 2; i < infoPatchRevision.Length; i++)
            {
                szAssetBundleInfo = infoPatchRevision[i].Split(',');

                if (szAssetBundleInfo.Length < 3)
                {
                    continue;
                }

                patchInfo         = new ePatchInfo();
                patchInfo.key     = szAssetBundleInfo[0];
                patchInfo.version = System.Int32.Parse(szAssetBundleInfo[1]);
                patchInfo.crc     = System.UInt32.Parse(szAssetBundleInfo[2]);

                newPatchInfo = newPathInfoAssetBundle.Find(delegate(ePatchInfo a) {
                    return(a.key.Equals(patchInfo.key));
                });

                if (newPatchInfo != null)
                {
                    finalPatchInfo.Add(newPatchInfo);
                }
                else
                {
                    finalPatchInfo.Add(patchInfo);
                }
            }
        }

        else
        {
            finalPatchInfo.AddRange(newPathInfoAssetBundle);
        }

        finalPatchInfo.Sort(delegate(ePatchInfo a, ePatchInfo b) {
            return(a.key.CompareTo(b.key));
        });

        List <string> szFinalPatchInfo = new List <string>();

        for (int i = 0; i < finalPatchInfo.Count; i++)
        {
            szFinalPatchInfo.Add(string.Format("{0},{1},{2}", finalPatchInfo[i].key, finalPatchInfo[i].version.ToString(), finalPatchInfo[i].crc.ToString()));
        }

        List <string> revisionInfo = new List <string>();

        revisionInfo.Add(lastRevision.ToString());
        revisionInfo.Add(version.ToString());

        revisionInfo.AddRange(szFinalPatchInfo);

        if (File.Exists(infoPatchRevisionInfo) == true)
        {
            File.Delete(infoPatchRevisionInfo);
        }

        File.WriteAllLines(infoPatchRevisionInfo, revisionInfo.ToArray());

        WriteAssetBundleCheckInfo(assetBundleCheckInfo, lastAssetBundleCheckInfoPathName);

        MagiDebug.Log(System.DateTime.Now - nowDateTime);

        #region FTP unload작업.
        //{
        //    //            string ftpRoot = "app/rustyhearts/" + targetPath + lastRevision.ToString() + "/";
        //    string ftpRoot = localPath + targetPath + lastRevision.ToString() + "/";
        //    MagiFtp magiFtp = new MagiFtp("1.214.41.130", "rh_rpg", "z00games?!ftp");

        //    string ftpRoot2 = localPath + targetPath + lastRevision.ToString();
        //    magiFtp.MakeDirectory(ftpRoot2);

        //    for (int i = 0; i < pathInfoAssetBundle.Count; )
        //    {
        //        string ftpFile = ftpRoot + pathInfoAssetBundle[i] + ".assetbundle";
        //        string clientPath = newAssetbundlePath + pathInfoAssetBundle[i] + ".assetbundle";

        //        //                FtpDelete(magiFtp, ftpFile);
        //        CreateNewAssetbundles.FtpUpload(magiFtp, ftpFile, clientPath);

        //        float s = (float)i / pathInfoAssetBundle.Count;
        //        EditorUtility.DisplayProgressBar("Upload", clientPath, s);
        //        ++i;
        //    }
        //    EditorUtility.ClearProgressBar();

        //    // fileinfo.txt upload
        //    {
        //        string ftpDir = ftpRoot + Path.GetFileName(newFileInfoPathName);
        //        string clientPath = newFileInfoPathName;
        //        CreateNewAssetbundles.FtpUpload(magiFtp, ftpDir, clientPath);
        //    }

        //    // patchRevisionInfo.txt upload
        //    {
        //        string ftpDir = localPath + targetPath + "patchRevisionInfo.txt";
        //        string clientPath = infoPatchRevisionInfo;
        //        CreateNewAssetbundles.FtpUpload(magiFtp, ftpDir, clientPath);
        //    }
        //}
        #endregion
    }