LocHelper.cs
/// <summary>
/// Add string to the end of the loc file
/// </summary>
/// <param name="stringId"></param>
/// <param name="content"></param>
Add string to the end of the loc file
Add string to the end of the loc file
public void AddString(string stringId, string content)
        {
            uint hashId = 0;
            if (stringId.Length > 2 && stringId[0] == '0' && stringId[1] == 'x')
            {
                try
                {
                    hashId = UInt32.Parse(stringId.Substring(2), System.Globalization.NumberStyles.AllowHexSpecifier);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error! invalid string key:'{0}'", stringId);
                    throw e;
                }
            }
            else 
                hashId = HashHelper.HashString(stringId);
            UInt16 sz = (UInt16)((content.Length * 2) + 2 + 4 + 4); 
            bool sixZeros = false;
            if (sz % 4 != 0)
            {
                sz += (UInt16)2;
                sixZeros = true;
            }
            if (BodyEnd + sz > mData.Count)
            {
                AddBytes( (int)(BodyEnd + sz ) - mData.Count); 
            }
            int stringLoc = (int)(BodyEnd - 4);
            BinUtils.WriteNumberAtLocation(stringLoc, hashId, mData);
            BinUtils.Write2ByteNumberAtLocation(stringLoc + 4, sz, mData);
            stringLoc += 6; 
            for (int i = 0; i < content.Length; i++)
            {
                BinUtils.Write2ByteNumberAtLocation(stringLoc, content[i], mData);
                stringLoc += 2;
            }
            BinUtils.WriteNumberAtLocation(stringLoc, 0, mData);
            if (sixZeros)
                BinUtils.Write2ByteNumberAtLocation(stringLoc + 4, 0, mData);
            AddBodySize(sz);
        }
public void AddString ( string stringId , string content ) { uint hashId = 0 ; if ( stringId . Length > 2 && stringId [ 0 ] == ' ' && stringId [ 1 ] == ' ' ) { try { hashId = UInt32 . Parse ( stringId . Substring ( 2 ) , System . Globalization . NumberStyles . AllowHexSpecifier ) ; } catch ( Exception e ) { Console . WriteLine ( " " , stringId ) ; throw e ; } } else hashId = HashHelper . HashString ( stringId ) ; UInt16 sz = ( UInt16 ) ( ( content . Length * 2 ) + 2 + 4 + 4 ) ; bool sixZeros = false ; if ( sz % 4 != 0 ) { sz += ( UInt16 ) 2 ; sixZeros = true ; } if ( BodyEnd + sz > mData . Count ) { AddBytes ( ( int ) ( BodyEnd + sz ) - mData . Count ) ; } int stringLoc = ( int ) ( BodyEnd - 4 ) ; BinUtils . WriteNumberAtLocation ( stringLoc , hashId , mData ) ; BinUtils . Write2ByteNumberAtLocation ( stringLoc + 4 , sz , mData ) ; stringLoc += 6 ; for ( int i = 0 ; i < content . Length ; i ++ ) { BinUtils . Write2ByteNumberAtLocation ( stringLoc , content [ i ] , mData ) ; stringLoc += 2 ; } BinUtils . WriteNumberAtLocation ( stringLoc , 0 , mData ) ; if ( sixZeros ) BinUtils . Write2ByteNumberAtLocation ( stringLoc + 4 , 0 , mData ) ; AddBodySize ( sz ) ; }
Add string to the end of the loc file
Add string to the end of the loc file
// 2:size info 4:hashId 4 min zero bytes //write hashId // write the size // lay down string  /** MODIFYING 'stringLoc' NOW!! **/
stringId
string
None
content
string
None