public void Serialize(object h) { pack = new ByteArrayBuilder(); pack.Add((uint)0); Add(h); WriteAll(); long pos = stream.Position; pack.Add((uint)pos); stream.Seek(0, SeekOrigin.Begin); WriteAll(); stream.Seek(pos, SeekOrigin.Begin); ArrayList n = new ArrayList(); n.AddRange(new int[codes.Count]); IDictionaryEnumerator pe = codes.GetEnumerator(); while (pe.MoveNext()) { n[(int)pe.Value] = (string)pe.Key; } Add(n); WriteAll(); }
public object Deserialize() { byte[] b = new byte[4]; stream.Read(b, 0, b.Length); pack = new ByteArray(b); uint pos = pack.GetDWord(); stream.Seek(pos, SeekOrigin.Begin); b = new byte[stream.Length - pos]; stream.Read(b, 0, b.Length); pack = new ByteArray(b); codes.Clear(); ArrayList n = Get() as ArrayList; for (int i = 0; i < n.Count; i++) { codes.Add((uint)i, n[i]); } stream.Seek(4, SeekOrigin.Begin); b = new byte[pos - 4]; stream.Read(b, 0, b.Length); pack = new ByteArray(b); return(Get()); }
bool Create(ByteArrayBase items) { base.Create(); while (items.pos < items.Length) { AddItem(items); } SetUpdateValue(UpdateFields.UNIT_FIELD_FLAGS, (uint)0x1008); // player for (ushort i = 0; i < stat.Length; i++) { SetUpdateValue(UpdateFields.PLAYER_FIELD_POSSTAT0 + i, (uint)0); SetUpdateValue(UpdateFields.PLAYER_FIELD_NEGSTAT0 + i, (uint)0); } SetUpdateValue(UpdateFields.PLAYER_FIELD_COINAGE, (uint)0); SetUpdateValue(UpdateFields.PLAYER_BYTES, (uint)(((uint)skin) | ((uint)face << 8) | ((uint)hairStyle << 16) | ((uint)hairColor << 24))); SetUpdateValue(UpdateFields.PLAYER_BYTES_2, (uint)((facialHair << 8) + (1 << 24))); SetUpdateValue(UpdateFields.PLAYER_XP, xp); SetUpdateValue(UpdateFields.PLAYER_NEXT_LEVEL_XP, Script.GetNextLevelXP(this)); SetUpdateValue(UpdateFields.PLAYER_REST_STATE_EXPERIENCE, restxp); SetUpdateValue(UpdateFields.PLAYER_CHARACTER_POINTS1, (uint)0); SetUpdateValue(UpdateFields.PLAYER_FIELD_MOD_DAMAGE_DONE_NEG, (uint)0); SetUpdateValueFloat(UpdateFields.PLAYER_AMMO_ID, (float)1.0); UpdateItemStats(); return(true); }
protected override bool Create(Character c, Hashtable data, ByteArrayBase moredata) { if (!base.Create(c, data, moredata)) { return(false); } items = new Item[(int)data["containerslots"]]; SetUpdateValue(UpdateFields.CONTAINER_FIELD_NUM_SLOTS, (uint)items.Length); while (moredata != null) { SlotID slot = (SlotID)moredata.GetByte(); if (slot == SlotID.CHARACTER) { break; } uint e = moredata.GetDWord(); ushort len = moredata.GetWord(); Item n = new Item(gameServer); n = n.Create(c, e, new ByteArray(moredata.GetArray(len))); if (n != null) { n.SetUpdateValue(UpdateFields.ITEM_FIELD_CONTAINED, GUID); //n.SetUpdateValue(UpdateFields.ITEM_FIELD_CONTAINED_01, GUID); SetItem(slot, n); } } return(true); }
public Item Create(Character c, uint entry, ByteArrayBase data) { Hashtable r = GetData(entry); if (r == null) { return(null); } Item p = null; if (r.Contains("containerslots")) { p = new Container(gameServer); } else { p = new Item(gameServer); } p.Entry = entry; if (p.Create(c, r, data)) { return(p); } return(null); }
bool AddItem(ByteArrayBase data) { byte slot; uint id; ushort len; data.Get(out slot).Get(out id).Get(out len); ByteArray b = null; if (len > 0) { b = new ByteArray(data.GetArray(len)); } Item n = new Item(gameServer); n = n.Create(this, id, b); if (n == null) { return(false); } return(AddItem((SlotID)slot, n)); }
protected virtual bool Create(Character c, Hashtable data, ByteArrayBase moredata) { if (!data.Contains("model")) { return(false); } base.Create(c.NextGUID()); model = (uint)(int)data["model"]; SetUpdateValue(UpdateFields.ITEM_FIELD_OWNER, c.GUID); //SetUpdateValue(UpdateFields.ITEM_FIELD_OWNER_01, c.GUID); SetUpdateValue(UpdateFields.ITEM_FIELD_CONTAINED, c.GUID); //SetUpdateValue(UpdateFields.ITEM_FIELD_CONTAINED_01, c.GUID); if (data.Contains("inventorytype")) { wornType = (WORN)(int)data["inventorytype"]; } if (data.Contains("quality")) { quality = (byte)(int)data["quality"]; } uint moreflags = 0; if (moredata != null) { moredata.Get(out mdurability).Get(out durability).Get(out stackcount).Get(out flags).Get(out moreflags); } else { if (data.Contains("durability")) { durability = mdurability = (ushort)(int)data["durability"]; } if (data.Contains("stackcount")) { stackcount = (byte)(int)data["stackcount"]; } } bonusData = data["bonus"] as int[]; damageData = data["damage"] as int[]; spellData = data["spell"] as int[]; resData = new int[7]; for (int i = 1; i <= 7; i++) { string str = "resistance" + i.ToString(); if (data.Contains(str)) { resData[i - 1] = (int)data[str]; } } if (data.Contains("delay")) { delay = (int)data["delay"]; } SetUpdateValue(UpdateFields.ITEM_FIELD_STACK_COUNT, stackcount); SetUpdateValue(UpdateFields.ITEM_FIELD_FLAGS, flags); SetUpdateValue(UpdateFields.ITEM_FIELD_DURABILITY, (uint)durability); SetUpdateValue(UpdateFields.ITEM_FIELD_MAXDURABILITY, (uint)mdurability); return(true); }