public string GetFilenameWithoutExtension(plVersion v) { if (v.IsPlasma20) return String.Format("{0}_{1}_{2}", fAge, fChapter, fPage); else return String.Format("{0}_{1}", fAge, fPage); }
public string GetFilename(plVersion v) { if (v.IsPlasma20) return String.Format("{0}_{1}_{2}.prp", fAge, fChapter, fPage); else return String.Format("{0}_{1}.prp", fAge, fPage); }
/// <summary> /// Gets the ***version-specific*** plCreatable Type ID for a given Creatable /// </summary> /// <param name="pCre">The Creatable to get the ID of</param> /// <param name="v">The Plasma Version to get the ID for</param> /// <returns>Unmanaged Creatable Type</returns> public static ushort ClassIndex(plCreatable pCre, plVersion v) { string name = ClassName(pCre); if (Enum.IsDefined(typeof(plCreatableID), name)) return plManagedType.ClassIndex(name, v); else throw new plFactoryException("plCreatable not in list of types!"); }
/// <summary> /// Translates a given class name to a ***version-specific*** Creatable ID /// </summary> /// <param name="type">Creatable ID to translate</param> /// <param name="v">Plasma Version to translate to</param> /// <returns>Translated Creatable ID</returns> public static ushort ClassIndex(string type, plVersion v) { if (fTypeMaps == null) IBuildTypeMaps(); ushort value = (ushort)plCreatableID.NULL; foreach (KeyValuePair<plTypeBounds, Type> kvp in fTypeMaps) { if (kvp.Key.UpperBoundary >= v && v >= kvp.Key.LowerBoundary) try { value = (ushort)Enum.Parse(kvp.Value, type); } catch (ArgumentException) { throw new plFactoryException(String.Format("Internal Type 0x{0} is not defined", type)); } } return value; }
public plVersionException(plVersion version) : base("Invalid Plasma Version") { base.Data.Add("plVersion", version); }
private ContentsFlags IGetContentFlags(plVersion v) { ContentsFlags contents = (ContentsFlags)0; if (fLoadMask != plLoadMask.Always) { contents |= ContentsFlags.kHasLoadMask; if (v.IsPlasma21) contents |= ContentsFlags.kHasLoadMask2; } if (v.IsPlasma20) if (fCloneID != 0 || fClonePlayerID != 0) contents |= ContentsFlags.kHasCloneIDs; return contents; }
public override void Read(hsStream s, hsResMgr mgr) { base.Read(s, mgr); // Cache it. fVersion = mgr.Version; // Cyan stores these values, but we're just going to // save the stream and have fun with it... fBuffer = new byte[s.ReadInt()]; Compression type = (Compression)s.ReadByte(); uint len = s.ReadUInt(); if (type == Compression.kZlib) { short streamType = s.ReadShort(); byte[] buf = s.ReadBytes((int)len - 2); // Create a zlib-compatible inflator // Note: incoming has no zlib header/footer // System.IO.Compression sucks. Inflater zlib = new Inflater(true); zlib.Inflate(buf); Buffer.BlockCopy(BitConverter.GetBytes(streamType), 0, fBuffer, 0, 2); Buffer.BlockCopy(buf, 0, fBuffer, 2, buf.Length); } else fBuffer = s.ReadBytes((int)len); }
public uint UnParse(plVersion v) { if (Invalid) return UInt32.MaxValue; uint pgNum = (uint)fPageNum; if (fSeqPrefix < 0) return (uint)(pgNum - (fSeqPrefix << (v.IsUruLive ? 16 : 8)) + (v.IsUruLive ? 0xFF000001 : 0xFFFF0001)); else if (fSeqPrefix > 0) return (uint)(pgNum + (fSeqPrefix << (v.IsUruLive ? 16 : 8)) + 33); else return 0; }
public void Parse(plVersion v, uint id) { if (id == UInt32.MaxValue) { fFlags = (LocFlags)0; fSeqPrefix = Int32.MaxValue; fPageNum = Int32.MaxValue; return; } else if (id == 0) return; if ((id & 0x80000000) != 0) { id -= (v.IsUruLive ? 0xFF000001 : 0xFFFF0001); fSeqPrefix = (int)(id >> (v.IsUruLive ? 16 : 8)); fPageNum = (int)(id - (fSeqPrefix << (v.IsUruLive ? 16 : 8))); fSeqPrefix = -fSeqPrefix; } else { id -= 33; fSeqPrefix = (int)(id >> (v.IsUruLive ? 16 : 8)); fPageNum = (int)(id - (fSeqPrefix << (v.IsUruLive ? 16 : 8))); } }
public plTypeBounds(plVersion low, plVersion high) { fLowerBound = low; fUpperBound = high; }