public void setString(string text) { MobFileSection cur = this; var encoding = Encoding.GetEncoding(1251); MobFileSectionInfo info = cur.info; byte[] temp; int delta = BitConverter.ToInt32(cur.Data, 4) - 8; switch (info.Type) { case SectionType.ST_STRING: case SectionType.ST_SCRIPT: temp = new byte[text.Length + 8]; Array.Copy(cur.Data, temp, 8); encoding.GetBytes(text).CopyTo(temp, 8); break; case SectionType.ST_SCRIPT_ENC: delta -= 4; temp = new byte[text.Length + 12]; Array.Copy(cur.Data, temp, 12); encoding.GetBytes(text).CopyTo(temp, 12); CryptScript(temp); break; default: return; } cur.Data = temp; delta = text.Length - delta; FixSize(delta); }
public string toString() { MobFileSection cur = this; var encoding = Encoding.GetEncoding(1251); MobFileSectionInfo info = cur.info; int delta = 0; string result = ""; switch (info.Type) { case SectionType.ST_STRING: case SectionType.ST_SCRIPT: delta = BitConverter.ToInt32(cur.Data, 4) - 8; result = encoding.GetString(cur.Data, 8, delta); break; case SectionType.ST_SCRIPT_ENC: delta = BitConverter.ToInt32(cur.Data, 4) - 12; CryptScript(cur.Data); result = encoding.GetString(cur.Data, 12, delta); CryptScript(cur.Data); break; } return(result); }
public object UserValue; // Адовый костыль. Здесь будут храниться всякие ГУИшные данные public MobFileSection(MobFileSection owner = null) { this.Owner = owner; Data = null; //data_size = 0; info = null; Items = null; Readed = false; }