Example #1
0
    public wstring SpawnString(int StringLength = 30)
    {
        wstring cString = null;
        int     num     = CalculateIndex(StringLength);

        if (num == -1)
        {
            return(cString);
        }
        List <wstring> list = GetList(num);

        if (list == null)
        {
            return(cString);
        }
        if (list.Count <= 0)
        {
            for (int i = 0; i < m_countArray[num]; i++)
            {
                wstring item = new wstring(m_lengthArray[num]);
                list.Add(item);
            }
        }
        cString = list[list.Count - 1];
        wstring expr_6F = cString;

        expr_6F.m_referenceCount += 1;
        cString.ClearString();
        list.RemoveAt(list.Count - 1);
        return(cString);
    }
Example #2
0
    public bool DeSpawnString(wstring str)
    {
        if (str == null)
        {
            return(false);
        }
        if (str.m_referenceCount == 0)
        {
        }
        int num = DeSpawnFindIndex(str.MaxLength);

        if (num == -1)
        {
            return(false);
        }
        List <wstring> list = GetList(num);

        if (list != null)
        {
            str.m_referenceCount -= 1;
            list.Add(str);
            return(true);
        }
        return(false);
    }
Example #3
0
    public unsafe static int ulongToStr(wstring s, ulong x, int digits = 1, bool bNumber = false)
    {
        if (s == null)
        {
            return(-1);
        }
        int i   = 0;
        int num = 0;

        fixed(char *ptr = s.ToString())
        {
            while (x != 0uL)
            {
                if (bNumber && num == 3)
                {
                    ptr[i++] = ',';
                    num      = 0;
                }
                ptr[i++] = m_numChar[(int)(checked ((IntPtr)(x % 10uL)))];
                x        = (ulong)(x * 0.1);
                if (bNumber)
                {
                    num++;
                }
            }
            while (i < digits)
            {
                ptr[i++] = m_numChar[0];
            }
            wstringManager.reverse(s, i);
            ptr[i]   = '\0';
            s.Length = i;
            return(i);
        }
    }
Example #4
0
 public wstringManager()
 {
     for (int i = 0; i < 50; i++)
     {
         wstring item = new wstring(1024);
         m_staticString.Add(item);
     }
     for (int j = 0; j < m_listCount; j++)
     {
         List <wstring> list = GetList(j);
         if (list != null)
         {
             for (int k = 0; k < m_countArray[j]; k++)
             {
                 wstring item2 = new wstring(m_lengthArray[j]);
                 list.Add(item2);
             }
         }
     }
     for (int l = 0; l < m_formatString.Length; l++)
     {
         wstring cString = new wstring(1024);
         m_formatString[l] = cString;
     }
 }
Example #5
0
 public void Substring(wstring s, int startIndex)
 {
     if (s == null || startIndex <= 0 || startIndex >= s.Length)
     {
         return;
     }
     Substring(s.ToString(), startIndex, s.Length - startIndex);
 }
Example #6
0
 public void Append(wstring value)
 {
     if (value == null)
     {
         return;
     }
     InternalAppend(value.ToString(), value.Length);
 }
Example #7
0
 public void Insert(int StartIndex, wstring textS, int SLength = -1)
 {
     if (textS == null)
     {
         return;
     }
     InternalInsert(StartIndex, textS.ToString(), (SLength != -1) ? SLength : textS.Length);
 }
Example #8
0
 public void AppendFormat(wstring format)
 {
     wstringManager.Instance.m_formatStringCount = 0;
     if (format == null)
     {
         return;
     }
     InternalAppendFormat(format.ToString(), format.Length);
 }
Example #9
0
 public bool StringToFormat(wstring tmpS)
 {
     if (m_formatStringCount < m_formatString.Length)
     {
         m_formatString[m_formatStringCount].ClearString();
         m_formatString[m_formatStringCount].Append(tmpS);
         m_formatStringCount++;
         return(true);
     }
     return(false);
 }
Example #10
0
    public unsafe static int IntToStr(wstring s, long x, int digits = 1, bool bNumber = false)
    {
        if (s == null)
        {
            return(-1);
        }
        int i    = 0;
        int num  = 0;
        int num2 = (x >= 0L) ? 1 : -1;

        if (num2 < 0)
        {
            x *= -1L;
        }

        fixed(char *ptr = s.ToString())
        {
            while (x != 0L)
            {
                if (bNumber && num == 3)
                {
                    ptr[i++] = ',';
                    num      = 0;
                }
                ptr[i++] = m_numChar[(int)(checked ((IntPtr)(x % 10L)))];
                x        = (long)((double)x * 0.1);
                if (bNumber)
                {
                    num++;
                }
            }
            while (i < digits)
            {
                ptr[i++] = m_numChar[0];
            }
            if (num2 < 0)
            {
                ptr[i++] = '-';
            }
            wstringManager.reverse(s, i);
            ptr[i]   = '\0';
            s.Length = i;
            return(i);
        }
    }
Example #11
0
    public unsafe int GetHashCode(bool bToUpper = false)
    {
        int hashCode;

        if (bToUpper)
        {
            wstring cString = wstringManager.Instance.StaticString1024();
            fixed(char *ptr = cString.ToString())
            {
                int num = 0;

                while (num < m_length && num < cString.MaxLength)
                {
                    if ('a' <= m_myString[num] && m_myString[num] <= 'z')
                    {
                        ptr[num] = (char)((int)m_myString[num] & -33);
                    }
                    else
                    {
                        ptr[num] = m_myString[num];
                    }
                    num++;
                }
                ptr[num] = '\0';
                cString.SetLength(num);
                hashCode = cString.ToString().GetHashCode();
                cString.SetLength(cString.MaxLength);
            }
        }
        else
        {
            fixed(char *ptr2 = m_myString)
            {
                SetLength(m_length);
                hashCode = m_myString.GetHashCode();
                SetLength(m_maxLength);
            }
        }
        return(hashCode);
    }
Example #12
0
    private unsafe static void reverse(wstring s, int len)
    {
        if (s == null)
        {
            return;
        }
        int i   = 0;
        int num = len - 1;

        while (i < num)
        {
            fixed(char *ptr = s.ToString())
            {
                char c = ptr[i];

                ptr[i]   = ptr[num];
                ptr[num] = c;
                i++;
                num--;
            }
        }
    }
Example #13
0
    void wstringTest()
    {
        using (profiler.Sample("wstring"))
        {
            using (profiler.Sample("Format"))
            {
                wstring gf = wstringManager.Instance.StaticString1024();
                gf.IntToFormat(123);
                gf.FloatToFormat(3.148f);
                gf.Append("Text");
                gf.AppendFormat("Number = {0}, Float = {1} String = {2}");
                int x = 10;
                wstringManager.Instance.DeSpawnString(gf);
            }

            using (profiler.Sample("Concat"))
            {
                wstring gf = wstringManager.Instance.StaticString1024();
                gf.Append("That's ");
                gf.Append("a lot");
                gf.Append(" of");
                gf.Append(" strings");
                gf.Append(" to ");
                gf.Append("concat");
                gf.AppendFormat("{0}{1}{2}{3}{4}{5}");
                wstringManager.Instance.DeSpawnString(gf);
                int x = 10;
            }
            //功能缺失只能使用string替代
            using (profiler.Sample("Substring + IndexOf + LastIndexOf"))
            {
                string path   = "Path/To/Some/File.txt";
                int    period = path.IndexOf('.');
                var    ext    = path.Substring(period + 1);
                var    file   = path.Substring(path.LastIndexOf('/') + 1, 4);
                int    x      = 10;
            }

            //功能缺失只能使用string替代
            using (profiler.Sample("Replace (char)"))
            {
                string input       = "This is some sort of text";
                string replacement = input.Replace('o', '0').Replace('i', '1');
                int    x           = 10;
            }
            //功能缺失只能使用string替代
            using (profiler.Sample("Replace (string)"))
            {
                string input       = "m_This is the is is form of text";
                string replacement = input.Replace("m_", "").Replace("is", "si");
                int    x           = 10;
            }
            using (profiler.Sample("Concat + Intern"))
            {
                for (int i = 0; i < 4; i++)
                {
                    wstring gf = wstringManager.Instance.StaticString1024();
                    gf.StringToFormat("Item");
                    gf.IntToFormat(i);
                    gf.AppendFormat("{0}{1}");
                    dict[string.Intern(gf.ToString())] = i;
                    wstringManager.Instance.DeSpawnString(gf);
                }
                wstring gf02 = wstringManager.Instance.StaticString1024();
                gf02.Append("I'm ");
                gf02.Append("long ");
                gf02.Append("gone ");
                gf02.Append("by ");
                gf02.Append("the ");
                gf02.Append("end ");
                gf02.Append("of ");
                gf02.Append("this ");
                gf02.Append("gstring block ");
                gf02.AppendFormat("{0}{1}{2}{3}{4}{5}{6}{7}");
                outsideString1 = gf02.ToString();
                wstringManager.Instance.DeSpawnString(gf02);
                wstring gf03 = wstringManager.Instance.StaticString1024();
                gf03.Append("I'll ");
                gf03.Append("be ");
                gf03.Append("still ");
                gf03.Append("around ");
                gf03.Append("here");
                gf03.Append("{0}{1}{2}{3}{4}");
                outsideString = string.Intern(gf03.ToString());
                wstringManager.Instance.DeSpawnString(gf03);
                int x = 10;
            }

            using (profiler.Sample("ToUpper + ToLower"))
            {
                wstring gf = wstringManager.Instance.StaticString1024();
                gf.Append("Hello");
                gf.AppendFormat("{0}");
                gf.ToUpper();
                wstring gf02 = wstringManager.Instance.StaticString1024();
                gf02.Append(gf);
                gf02.Append(gf.ToString().ToLower());
                gf02.AppendFormat("{0}{1}");
                wstringManager.Instance.DeSpawnString(gf);
                wstringManager.Instance.DeSpawnString(gf02);
                int x = 10;
            }
            if (!bigStringTest)
            {
                return;
            }
            using (profiler.Sample("BigStringEval"))
            {
                wstring gf = wstringManager.Instance.StaticString1024();
                gf.Append(bigString);
                gf.Append("hello");
                gf.AppendFormat("{0}{1}");
            }
        }
    }
Example #14
0
    private void InternalAppendFormat(string format, int lengthf)
    {
        if (m_myString == null || format == null)
        {
            return;
        }
        wstringManager instance = wstringManager.Instance;
        int            num      = 0;

        while (true)
        {
            char c;
            if (num < lengthf)
            {
                c = format[num];
                num++;
                if (c == '}')
                {
                    if (num >= lengthf || format[num] != '}')
                    {
                        break;
                    }
                    num++;
                }
                if (c == '{')
                {
                    if (num >= lengthf || format[num] != '{')
                    {
                        num--;
                        goto IL_8C;
                    }
                    num++;
                }
                Append(c);
                continue;
            }
IL_8C:
            if (num == lengthf)
            {
                return;
            }
            num++;
            if (num == lengthf || (c = format[num]) < '0' || c > '9')
            {
                return;
            }
            int num2 = 0;
            do
            {
                num2 = num2 * 10 + (int)c - 48;
                num++;
                if (num == lengthf)
                {
                    return;
                }
                c = format[num];
            }while (c >= '0' && c <= '9' && num2 < 1000000);
            wstring[] formatS = instance.m_formatString;
            if (num2 >= formatS.Length)
            {
                return;
            }
            while (num < lengthf && (c = format[num]) == ' ')
            {
                num++;
            }
            bool flag = false;
            int  num3 = 0;
            if (c == ',')
            {
                num++;
                while (num < lengthf && format[num] == ' ')
                {
                    num++;
                }
                if (num == lengthf)
                {
                    return;
                }
                c = format[num];
                if (c == '-')
                {
                    flag = true;
                    num++;
                    if (num == lengthf)
                    {
                        return;
                    }
                    c = format[num];
                }
                if (c < '0' || c > '9')
                {
                    return;
                }
                do
                {
                    num3 = num3 * 10 + (int)c - 48;
                    num++;
                    if (num == lengthf)
                    {
                        return;
                    }
                    c = format[num];
                    if (c < '0' || c > '9')
                    {
                        break;
                    }
                }while (num3 < 1000000);
            }
            while (num < lengthf && (c = format[num]) == ' ')
            {
                num++;
            }
            wstring cString = instance.StaticString1024();
            if (c == ':')
            {
                num++;
                while (num != lengthf)
                {
                    c = format[num];
                    num++;
                    if (c == '{')
                    {
                        if (num >= lengthf || format[num] != '{')
                        {
                            return;
                        }
                        num++;
                    }
                    else if (c == '}')
                    {
                        if (num >= lengthf || format[num] != '}')
                        {
                            num--;
                            goto IL_286;
                        }
                        num++;
                    }
                    cString.Append(c);
                }
                return;
            }
IL_286:
            if (c != '}')
            {
                return;
            }
            num++;
            wstring cString2 = null;
            if (formatS[num2] != null)
            {
                cString2 = formatS[num2];
            }
            if (cString2 == null)
            {
                cString2 = instance.StaticString1024();
            }
            int num4 = num3 - cString2.Length;
            if (!flag && num4 > 0)
            {
                Append(' ', num4);
            }
            Append(cString2);
            if (flag && num4 > 0)
            {
                Append(' ', num4);
            }
        }
    }
Example #15
0
    public unsafe static void DoubleToStr(wstring s, double f, int afterpoint = -1, bool bAfterPointShowZero = true)
    {
        int num  = 1;
        int num2 = -1;
        int num3 = (f >= 0.0) ? 1 : -1;

        if (num3 < 0)
        {
            f *= -1.0;
        }
        int num4;

        if (afterpoint < 0)
        {
            num4 = (int)f;
            double num5 = f - (double)num4;
            afterpoint = 0;
            while (num5 != 0.0 && num5 >= 0.0)
            {
                num5  = f * Math.Pow(10.0, (double)(afterpoint + 1));
                num4  = (int)num5;
                num5 -= (double)num4;
                afterpoint++;
            }
        }
        else
        {
            double num6 = f;
            for (int i = 0; i < afterpoint; i++)
            {
                num6 *= 10.0;
            }
            num4 = (int)num6;
        }
        while ((f *= 0.10000000149011612) >= 1.0)
        {
            num++;
        }
        if (!bAfterPointShowZero && afterpoint > 0)
        {
            int num7 = num4;
            int num8 = 0;
            for (int j = 0; j < afterpoint; j++)
            {
                if (num7 % 10 != 0)
                {
                    break;
                }
                num8++;
                num7 /= 10;
            }
            if (num8 > 0)
            {
                num4       /= (int)Math.Pow(10.0, (double)num8);
                afterpoint -= num8;
            }
        }
        if (afterpoint > 0)
        {
            num2 = num;
            num  = num + 1 + afterpoint;
        }
        if (num3 < 0)
        {
            num++;
            if (num2 != -1)
            {
                num2++;
            }
        }

        fixed(char *ptr = s.ToString())
        {
            for (int j = num; j >= 0; j--)
            {
                if (j == num)
                {
                    ptr[j] = '\0';
                }
                else if (j == num2)
                {
                    ptr[j] = '.';
                }
                else if (num3 < 0 && j == 0)
                {
                    ptr[j] = '-';
                }
                else
                {
                    int num9 = num4 % 10;
                    ptr[j] = m_numChar[num9];
                    num4   = (int)((float)num4 * 0.1f);
                }
            }
            s.Length = num;
        }
    }
Example #16
0
 public bool StringToFormat(wstring tmpS)
 {
     return(wstringManager.Instance.StringToFormat(tmpS));
 }
        public void ParseDungeonInfoData(string filename)
        {
            bool   bNormalScript  = true;
            string normalFilename = null;

            if (filename.IndexOf("HARD") != -1)
            {
                normalFilename = filename.Replace("HARD", "NORMAL");
                bNormalScript  = false;
            }
            else if (filename.IndexOf("EXPERT") != -1)
            {
                normalFilename = filename.Replace("EXPERT", "NORMAL");
                bNormalScript  = false;
            }

            if (bNormalScript == false)
            {
                ParseDungeonInfoData(normalFilename);
            }

            StreamReader sr = null;

            try
            {
                sr = new StreamReader(filename, Encoding.UTF8);
                string strFile = sr.ReadToEnd();
                if (strFile.IndexOf("g_pDungeonManager:AddDungeonData") != -1)
                {
                    strFile = strFile.Replace("g_pDungeonManager:AddDungeonData", "TABLE = ");
                    //strFile = strFile.Substring(0, strFile.Length - 3);

                    // Valid file

                    Lua newlua = new Lua();
                    LuaTool.DoFile(newlua, ScriptTreeManager.strMajorDir + "Enum.lua");
                    LuaTool.DoFile(newlua, ScriptTreeManager.strMajorDir + "StringID_def.lua");

                    newlua.DoString(strFile);

                    LuaTool.GetValue(newlua, "TABLE.dungeonID", out m_DungeonID, 0);

                    LuaTool.GetValue(newlua, "TABLE.dungeonName", out m_DungeonName_ID, -1);

                    LuaTool.GetValue(newlua, "TABLE.dataFileName", out m_DataFileName, "");

                    #region CopyedCode
#if false
                    //LUA_GET_VALUE(				luaManager, L"requireLevel",		pDungeonData->m_RequireLevel, 0 );
                    LUA_GET_VALUE_ENUM(luaManager, L"requireDungeonID", pDungeonData->m_RequireDungeonID,
                                       CX2Dungeon::DUNGEON_ID, CX2Dungeon::DI_NONE);


                    if (true == luaManager.BeginTable("EXTRA_REQUIRE_DUNGEON_ID"))
                    {
                        for (int iValueIndex = 1; true; iValueIndex++)
                        {
                            int iExtraDungeonID = -1;
                            if (true == luaManager.GetValue(iValueIndex, iExtraDungeonID))
                            {
                                if (-1 != iExtraDungeonID)
                                {
                                    pDungeonData->m_vecExtraRequireDungeonID.push_back((CX2Dungeon::DUNGEON_ID)iExtraDungeonID);
                                }
                            }
                            else
                            {
                                break;
                            }
                        }

                        luaManager.EndTable(); // EXTRA_REQUIRE_DUNGEON_ID
                    }


                    LUA_GET_VALUE(luaManager, L"IS_HELL_MODE", pDungeonData->m_bHellMode, false);


                    //{{ 2007. 8. 29  최육사
                    LUA_GET_VALUE(luaManager, L"requireItemID", pDungeonData->m_RequireItemID, 0);
                    LUA_GET_VALUE(luaManager, L"requireItemCount", pDungeonData->m_RequireItemCount, 0);
                    //}}


                    LUA_GET_VALUE(luaManager, L"requireItemID2", pDungeonData->m_RequireItemID2, 0);
                    LUA_GET_VALUE(luaManager, L"requireItemCount2", pDungeonData->m_RequireItemCount2, 0);



                    //{{ 2007. 10. 4  최육사  근성도
                    LUA_GET_VALUE(luaManager, L"requireSpirit", pDungeonData->m_RequireSpirit, 0);
                    //}}

                    LUA_GET_VALUE_ENUM(luaManager, L"difficulty", pDungeonData->m_eDifficulty, CX2Dungeon::DIFFICULTY_LEVEL, CX2Dungeon::DL_NORMAL);

                    LUA_GET_VALUE(luaManager, L"normalOnly", pDungeonData->m_bNormalOnly, false);
                    LUA_GET_VALUE(luaManager, L"m_fTimeLimit", pDungeonData->m_fTimeLimit, -1.f);


                    LUA_GET_VALUE(luaManager, L"m_MinLevel", pDungeonData->m_MinLevel, 0);
                    LUA_GET_VALUE(luaManager, L"m_MaxLevel", pDungeonData->m_MaxLevel, 0);


                    LUA_GET_VALUE_ENUM(luaManager, L"m_eDefaultDungeonLoungeWorldID", pDungeonData->m_eDefaultDungeonLoungeWorldID, CX2World::WORLD_ID, CX2World::WI_NONE);



                    LUA_GET_VALUE_ENUM(luaManager, L"m_eDungeonType", pDungeonData->m_eDungeonType, CX2Dungeon::DUNGEON_TYPE, CX2Dungeon::DT_NORMAL);
                    LUA_GET_VALUE(luaManager, L"m_bRelativeMonsterLevel", pDungeonData->m_bRelativeMonsterLevel, false);



                    // UI Data About..
                    LUA_GET_VALUE(luaManager, L"m_bArcadeMode", pDungeonData->m_UIData.m_bArcadeMode, false);

                    LUA_GET_VALUE(luaManager, L"m_TextureName", pDungeonData->m_UIData.m_TextureName, L"");
                    LUA_GET_VALUE(luaManager, L"m_PieceName", pDungeonData->m_UIData.m_PieceName, L"");
                    LUA_GET_VALUE(luaManager, L"m_Explanation", iStringIndex, STR_ID_EMPTY);
                    pDungeonData->m_UIData.m_Explanation = GET_STRING(iStringIndex);

                    LUA_GET_VALUE(luaManager, L"m_LocalStarPosX", pDungeonData->m_UIData.m_LocalStarPos.x, -999.0f);
                    LUA_GET_VALUE(luaManager, L"m_LocalStarPosY", pDungeonData->m_UIData.m_LocalStarPos.y, -999.0f);

                    LUA_GET_VALUE(luaManager, L"m_PopUpOffsetPosX", pDungeonData->m_UIData.m_PopUpOffsetPos.x, 0.0f);
                    LUA_GET_VALUE(luaManager, L"m_PopUpOffsetPosY", pDungeonData->m_UIData.m_PopUpOffsetPos.y, 0.0f);

                    //{{ 2009.1.22 김태완 던전별 로딩화면

                    LUA_GET_VALUE(luaManager, L"m_LoadingScreenFileName", pDungeonData->m_UIData.m_LoadingScreenFileName, L"");
                    LUA_GET_VALUE(luaManager, L"m_LoadingScreenFileName2", pDungeonData->m_UIData.m_LoadingScreenFileName2, L"");

                    //}}



                    wstring wstrBuf = L"";
                    if (true == luaManager.BeginTable("AUTO_DUNGEON_ROOM_TITLE"))
                    {
                        for (int iValueIndex = 1; true; iValueIndex++)
                        {
                            LUA_GET_VALUE_RETURN(luaManager, iValueIndex, iStringIndex, STR_ID_EMPTY, break; );

                            pDungeonData->m_UIData.m_vecAutoRoomTitle.push_back(GET_STRING(iStringIndex));
                        }